@vindral/web-sdk 4.1.4-22-gcde161e2 → 4.1.4-24-g8881df4e

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
@@ -12,7 +12,7 @@ var rB = (i, A, t) => A in i ? EQ(i, A, { enumerable: !0, configurable: !0, writ
12
12
  for (var t of EB(A))
13
13
  nn.call(A, t) && rB(i, t, A[t]);
14
14
  return i;
15
- }, P = (i, A) => wr(i, mr(A)), Qn = (i, A) => EQ(i, "name", { value: A, configurable: !0 });
15
+ }, Y = (i, A) => wr(i, mr(A)), Qn = (i, A) => EQ(i, "name", { value: A, configurable: !0 });
16
16
  var an = (i, A) => {
17
17
  var t = {};
18
18
  for (var e in i)
@@ -1370,7 +1370,7 @@ class v extends Error {
1370
1370
  I(this, "toStringifiable", () => {
1371
1371
  var g;
1372
1372
  const t = this.source(), e = t instanceof Error ? t.stack : this.stack;
1373
- return P(D({}, this.extra), {
1373
+ return Y(D({}, this.extra), {
1374
1374
  code: this.props.code,
1375
1375
  isFatal: this.props.isFatal,
1376
1376
  type: this.props.type,
@@ -1557,7 +1557,7 @@ const pn = {
1557
1557
  }), Fn = (i, A, t, e, g, B) => r(null, null, function* () {
1558
1558
  let C;
1559
1559
  for (const Q of e) {
1560
- const o = t == null ? void 0 : t.map((c) => P(D({}, c), {
1560
+ const o = t == null ? void 0 : t.map((c) => Y(D({}, c), {
1561
1561
  robustness: Q,
1562
1562
  contentType: B ? `${g === "audioCapabilities" ? "audio/mp4" : "video/mp4"}; codecs="${B}"` : c.contentType
1563
1563
  }));
@@ -3136,7 +3136,7 @@ const oA = (i, A, t) => {
3136
3136
  const A = new Xa();
3137
3137
  return ((t = i.samples[0]) == null ? void 0 : t.producerReferenceTime) !== void 0 && ah(A, i.trackId, i.samples[0].producerReferenceTime, i.timestamp), A.moofOffset = A.writer.position(), Hh(A, i), qh(A, i), A.writer.buffer();
3138
3138
  }, vh = (i, A) => {
3139
- const t = i.map((C) => P(D({}, C), {
3139
+ const t = i.map((C) => Y(D({}, C), {
3140
3140
  data: new Uint8Array(C.data)
3141
3141
  }));
3142
3142
  if (!t[0])
@@ -3168,7 +3168,7 @@ const oA = (i, A, t) => {
3168
3168
  throw new Error("No sps or pps provided");
3169
3169
  return Yc(e);
3170
3170
  }, Yh = (i, A) => {
3171
- const t = i.map((Q) => P(D({}, Q), {
3171
+ const t = i.map((Q) => Y(D({}, Q), {
3172
3172
  data: new Uint8Array(Q.data)
3173
3173
  }));
3174
3174
  if (!t[0])
@@ -3209,7 +3209,7 @@ const oA = (i, A, t) => {
3209
3209
  sampleRate: 48e3
3210
3210
  }
3211
3211
  ]), xh = (i, A) => {
3212
- const t = i.map((C) => P(D({}, C), {
3212
+ const t = i.map((C) => Y(D({}, C), {
3213
3213
  data: new Uint8Array(C.data)
3214
3214
  }));
3215
3215
  if (!t[0])
@@ -3273,11 +3273,11 @@ const oA = (i, A, t) => {
3273
3273
  o = i.readBit() !== 0;
3274
3274
  const $ = i.readBits(5) + 1;
3275
3275
  for (let F = 0; F < $; F++) {
3276
- const k = i.readBits(12), Y = i.readBits(5);
3276
+ const k = i.readBits(12), T = i.readBits(5);
3277
3277
  let tA = 0;
3278
- if (Y > 7 && (tA = i.readBit()), C)
3278
+ if (T > 7 && (tA = i.readBit()), C)
3279
3279
  throw new Error("decoderModelInfoPresentFlag==1");
3280
- o && i.readBit() !== 0 && i.readBits(4), h.push({ tier: tA, operatingPointIdc: k, seqLevelIdx: Y });
3280
+ o && i.readBit() !== 0 && i.readBits(4), h.push({ tier: tA, operatingPointIdc: k, seqLevelIdx: T });
3281
3281
  }
3282
3282
  }
3283
3283
  const d = i.readBits(4) + 1, u = i.readBits(4) + 1, m = i.readBits(d) + 1, S = i.readBits(u) + 1;
@@ -3381,7 +3381,7 @@ const oA = (i, A, t) => {
3381
3381
  height: A.maxFrameHeight
3382
3382
  };
3383
3383
  }, Id = (i, A) => {
3384
- const t = i.map((Q) => P(D({}, Q), {
3384
+ const t = i.map((Q) => Y(D({}, Q), {
3385
3385
  data: new Uint8Array(Q.data)
3386
3386
  }));
3387
3387
  if (!t[0])
@@ -4010,15 +4010,15 @@ class Hd {
4010
4010
  if (Md(Q)) {
4011
4011
  const o = Q.channels.map((a) => {
4012
4012
  const c = this.toChannel(a, g), h = Na(a.catalog);
4013
- return P(D(D({}, a), c), { renditions: h });
4013
+ return Y(D(D({}, a), c), { renditions: h });
4014
4014
  });
4015
- return P(D({}, Q), { channels: o });
4015
+ return Y(D({}, Q), { channels: o });
4016
4016
  } else {
4017
4017
  const o = Q.channels.map((a) => {
4018
4018
  const c = this.toChannel(a, g);
4019
4019
  return D(D({}, a), c);
4020
4020
  });
4021
- return P(D({}, Q), { channels: o });
4021
+ return Y(D({}, Q), { channels: o });
4022
4022
  }
4023
4023
  });
4024
4024
  }
@@ -6715,7 +6715,7 @@ class vl {
6715
6715
  const u = this.track.timestampRange();
6716
6716
  if (u && a >= u[1])
6717
6717
  break;
6718
- s(this, vI).debug("fragment", P(D({}, A), {
6718
+ s(this, vI).debug("fragment", Y(D({}, A), {
6719
6719
  startTime: a,
6720
6720
  endTime: h,
6721
6721
  subscribeId: C.subscribeId,
@@ -7204,7 +7204,7 @@ function Vl(i) {
7204
7204
  if (!Wl(t))
7205
7205
  throw new Error("Invalid drm object");
7206
7206
  const B = t, { fairplayCertificate: e } = B, g = an(B, ["fairplayCertificate"]);
7207
- return P(D({}, g), {
7207
+ return Y(D({}, g), {
7208
7208
  fairplayCertificate: e ? Ol(e) : void 0
7209
7209
  });
7210
7210
  }
@@ -7223,7 +7223,7 @@ class Vo {
7223
7223
  if (C.done)
7224
7224
  throw new Error("No drm object received");
7225
7225
  const Q = Vl(C.value.payload);
7226
- return new Vo(P(D({}, Q), { videoCodec: t, audioCodec: e }));
7226
+ return new Vo(Y(D({}, Q), { videoCodec: t, audioCodec: e }));
7227
7227
  } catch (a) {
7228
7228
  var c = a, h = !0;
7229
7229
  } finally {
@@ -7973,7 +7973,7 @@ class tu extends $A {
7973
7973
  this.logger.info("On error", D({}, this.options)), this.close("one websocket had an error"), this.emit("error", new v("WebSocket error", { code: "websocket_error", isFatal: !1 }));
7974
7974
  });
7975
7975
  I(this, "onClose", (t) => {
7976
- switch (this.logger.info("Closed", P(D({}, this.options), {
7976
+ switch (this.logger.info("Closed", Y(D({}, this.options), {
7977
7977
  reason: t.reason,
7978
7978
  code: t.code,
7979
7979
  isSuspended: this.isSuspended
@@ -8021,7 +8021,7 @@ class tu extends $A {
8021
8021
  const { url: e, connectionCount: g } = yield this.options.connectHandler();
8022
8022
  if (this.connectStartTime = Date.now(), !this.shouldContinueConnecting)
8023
8023
  return this._isConnectInProgress = !1, this.logger.info("Connection aborted"), !1;
8024
- this.logger.info("Connecting websockets", P(D({}, this.options), { url: e }));
8024
+ this.logger.info("Connecting websockets", Y(D({}, this.options), { url: e }));
8025
8025
  for (let B = 0; B < g; B++) {
8026
8026
  const C = new WebSocket(e);
8027
8027
  C.binaryType = "arraybuffer", C.onmessage = (Q) => this.onMessage(B, Q), C.addEventListener("error", this.onError), C.addEventListener("close", this.onClose), C.addEventListener("open", this.onOpen), this.websockets.push(C);
@@ -8296,7 +8296,7 @@ const $i = class $i {
8296
8296
  E(this, kt, !0), (A = this.connectionImpl) == null || A.unsuspend(), this.connect();
8297
8297
  });
8298
8298
  I(this, "getState", () => this.connectionImpl ? this.connectionImpl.getState() : "disconnected");
8299
- I(this, "getStatistics", () => this.connectionImpl ? P(D({}, this.connectionImpl.getStatistics()), {
8299
+ I(this, "getStatistics", () => this.connectionImpl ? Y(D({}, this.connectionImpl.getStatistics()), {
8300
8300
  rtt: Be(s(this, Gt).items()),
8301
8301
  estimatedBandwidth: this.estimatedBandwidth,
8302
8302
  connectCount: s(this, Ag),
@@ -8382,7 +8382,7 @@ Gt = new WeakMap(), kt = new WeakMap(), $I = new WeakMap(), _t = new WeakMap(),
8382
8382
  this.emitter,
8383
8383
  this.logger,
8384
8384
  this.apiClient,
8385
- P(D({}, this.config), {
8385
+ Y(D({}, this.config), {
8386
8386
  connectInfo: g,
8387
8387
  edgeUrl: Q
8388
8388
  }),
@@ -8390,7 +8390,7 @@ Gt = new WeakMap(), kt = new WeakMap(), $I = new WeakMap(), _t = new WeakMap(),
8390
8390
  ) : (uA(typeof Q == "string", "Edge URL is expected to be a string"), this.connectionImpl = yield lo.start(
8391
8391
  this.emitter,
8392
8392
  this.logger,
8393
- P(D({}, this.config), {
8393
+ Y(D({}, this.config), {
8394
8394
  connectInfo: g,
8395
8395
  edgeUrl: Q
8396
8396
  }),
@@ -8420,7 +8420,7 @@ Gt = new WeakMap(), kt = new WeakMap(), $I = new WeakMap(), _t = new WeakMap(),
8420
8420
  }, I($i, "PING_TIMEOUT", 1e3), I($i, "create", (A, t, e) => new $i(A, t, e));
8421
8421
  let uo = $i;
8422
8422
  const kQ = () => ({
8423
- video: P(D({}, RB()), {
8423
+ video: Y(D({}, RB()), {
8424
8424
  bitRate: ke()
8425
8425
  }),
8426
8426
  audio: {
@@ -8458,7 +8458,7 @@ const kQ = () => ({
8458
8458
  I(this, "setUserSpecifiedCap", (A) => {
8459
8459
  var e;
8460
8460
  const t = (e = this.getUserSpecifiedCap()) != null ? e : kQ();
8461
- this.userSpecifiedCap = P(D({}, t), {
8461
+ this.userSpecifiedCap = Y(D({}, t), {
8462
8462
  video: D(D({}, t.video), A.video),
8463
8463
  audio: D(D({}, t.audio), A.audio)
8464
8464
  }), this.evaluateConstraintCap();
@@ -8484,7 +8484,7 @@ const kQ = () => ({
8484
8484
  });
8485
8485
  I(this, "evaluateConstraintCap", () => {
8486
8486
  var C, Q, o, a, c;
8487
- const A = this.sizeBasedResolutionCapEnabled ? P(D({}, kQ()), { video: Bu() }) : kQ();
8487
+ const A = this.sizeBasedResolutionCapEnabled ? Y(D({}, kQ()), { video: Bu() }) : kQ();
8488
8488
  if (!this.resizeObserver) {
8489
8489
  const h = this.element.getBoundingClientRect();
8490
8490
  this.elementSize = { width: h.width, height: h.height };
@@ -8725,7 +8725,7 @@ const nu = (i) => (A, t, e) => A.timestamp <= t || A.timestampAdded <= e - i, se
8725
8725
  this.timers.unload(), this.emitter.off("add event", this.addEvent);
8726
8726
  });
8727
8727
  I(this, "addEvent", (A) => {
8728
- this.logger.debug("Adding event", { event: A }), !this.waitingEvents.some((t) => typeof t.id != "undefined" && t.id === A.id) && this.waitingEvents.push(P(D({}, A), { timestampAdded: Date.now() }));
8728
+ this.logger.debug("Adding event", { event: A }), !this.waitingEvents.some((t) => typeof t.id != "undefined" && t.id === A.id) && this.waitingEvents.push(Y(D({}, A), { timestampAdded: Date.now() }));
8729
8729
  });
8730
8730
  I(this, "extractEvent", (A, t) => {
8731
8731
  t.type === "video" && A.channelId !== t.channelId && this.addEvent({
@@ -8922,7 +8922,7 @@ const vC = class vC extends $A {
8922
8922
  I(this, "onDecodedFrame", (t) => {
8923
8923
  if (!(this.gainNode && this.audio && this.audio.isRunning)) {
8924
8924
  if (t.type === "audio") {
8925
- this.preInitSampleQueue.push(P(D({}, t), { data: t.data.slice(0, t.data.length) }));
8925
+ this.preInitSampleQueue.push(Y(D({}, t), { data: t.data.slice(0, t.data.length) }));
8926
8926
  const e = this.clockSource.currentTime;
8927
8927
  this.preInitSampleQueue.filterPop(({ timestamp: g, timescale: B }) => g / B * 1e3 > e);
8928
8928
  }
@@ -9903,7 +9903,7 @@ class Cr {
9903
9903
  }
9904
9904
  }
9905
9905
  function mu(i, { mediaSource: A, mimeType: t, codec: e }) {
9906
- return P(D({}, i), {
9906
+ return Y(D({}, i), {
9907
9907
  state: "initialized",
9908
9908
  mimeType: t,
9909
9909
  codec: e,
@@ -10921,7 +10921,7 @@ const jn = 5e3, pu = () => Fa() || iQ() || Lr(), zn = () => pu() ? 100 : 0, _n =
10921
10921
  if (this.isSuspended)
10922
10922
  return;
10923
10923
  if (!g || !B) {
10924
- this.logger.info("Initial timing info", { syncInfo: t }), this.channelSyncInfo.set(A, P(D({}, t), { localTimestamp: e, timeDifferences: new sA(12) }));
10924
+ this.logger.info("Initial timing info", { syncInfo: t }), this.channelSyncInfo.set(A, Y(D({}, t), { localTimestamp: e, timeDifferences: new sA(12) }));
10925
10925
  return;
10926
10926
  }
10927
10927
  const C = t.wallclockTime - g.wallclockTime, Q = t.timestamp - g.timestamp, o = e - g.localTimestamp, a = Q - o;
@@ -10935,7 +10935,7 @@ const jn = 5e3, pu = () => Fa() || iQ() || Lr(), zn = () => pu() ? 100 : 0, _n =
10935
10935
  wallclockDelta: C,
10936
10936
  localWallclockDelta: o
10937
10937
  }), Math.abs(a) >= this.bufferSource.getTargetBufferTime() * 2) {
10938
- this.logger.info("Resetting sync info", { diffFromEstimated: a }), this.channelSyncInfo.set(A, P(D({}, t), {
10938
+ this.logger.info("Resetting sync info", { diffFromEstimated: a }), this.channelSyncInfo.set(A, Y(D({}, t), {
10939
10939
  localTimestamp: e,
10940
10940
  timeDifferences: new sA(g.timeDifferences.maxSize + 1)
10941
10941
  })), this.currentChannelId && this.currentChannelId === A && (this.reset(), this.emitter.emit("channel reset"));
@@ -10979,15 +10979,13 @@ class Xo {
10979
10979
  I(this, "trackingState", /* @__PURE__ */ new Map());
10980
10980
  // Running jitter calculation (RFC 3550 style - exponential moving average with /16)
10981
10981
  I(this, "runningJitter", /* @__PURE__ */ new Map());
10982
- // Reactive jitter calculation (more sensitive - exponential moving average with /4)
10983
- I(this, "reactiveJitter", /* @__PURE__ */ new Map());
10984
10982
  // Recent jitter samples for spike detection
10985
10983
  I(this, "recentJitterSamples", /* @__PURE__ */ new Map());
10986
10984
  I(this, "load", () => {
10987
10985
  this.logger.debug("JitterModule loaded");
10988
10986
  });
10989
10987
  I(this, "unload", () => {
10990
- this.trackingState.clear(), this.runningJitter.clear(), this.reactiveJitter.clear(), this.recentJitterSamples.clear(), this.logger.debug("JitterModule unloaded");
10988
+ this.trackingState.clear(), this.runningJitter.clear(), this.recentJitterSamples.clear(), this.logger.debug("JitterModule unloaded");
10991
10989
  });
10992
10990
  this.logger = A;
10993
10991
  }
@@ -11008,15 +11006,15 @@ class Xo {
11008
11006
  * (derived from media timestamps) with the actual inter-arrival time.
11009
11007
  */
11010
11008
  recordSample(A) {
11011
- var m, S;
11012
- const t = this.getTrackingKey(A.type, A.renditionId), e = performance.now(), g = A.timestamp / A.timescale * 1e3, B = this.trackingState.get(t);
11009
+ var d, u, m, S;
11010
+ const t = this.getTrackingKey(A.type, A.renditionId), e = (m = (u = (d = globalThis.performance) == null ? void 0 : d.now) == null ? void 0 : u.call(d)) != null ? m : Date.now(), g = A.timestamp / A.timescale * 1e3, B = this.trackingState.get(t);
11013
11011
  if (!B) {
11014
11012
  this.trackingState.set(t, {
11015
11013
  lastArrivalTime: e,
11016
11014
  lastTimestampMs: g,
11017
11015
  jitterSamples: new sA($n),
11018
11016
  interArrivalTimes: new sA($n)
11019
- }), this.runningJitter.set(t, 0), this.reactiveJitter.set(t, 0), this.recentJitterSamples.set(t, new sA(Aa));
11017
+ }), this.runningJitter.set(t, 0), this.recentJitterSamples.set(t, new sA(Aa));
11020
11018
  return;
11021
11019
  }
11022
11020
  const C = g - B.lastTimestampMs;
@@ -11026,12 +11024,10 @@ class Xo {
11026
11024
  }
11027
11025
  const Q = e - B.lastArrivalTime, o = Math.abs(Q - C);
11028
11026
  B.jitterSamples.push(o), B.interArrivalTimes.push(Q);
11029
- const a = (m = this.runningJitter.get(t)) != null ? m : 0, c = a + (o - a) / 16;
11027
+ const a = (S = this.runningJitter.get(t)) != null ? S : 0, c = a + (o - a) / 16;
11030
11028
  this.runningJitter.set(t, c);
11031
- const h = (S = this.reactiveJitter.get(t)) != null ? S : 0, d = h + (o - h) / 4;
11032
- this.reactiveJitter.set(t, d);
11033
- let u = this.recentJitterSamples.get(t);
11034
- u || (u = new sA(Aa), this.recentJitterSamples.set(t, u)), u.push(o), B.lastArrivalTime = e, B.lastTimestampMs = g;
11029
+ let h = this.recentJitterSamples.get(t);
11030
+ h || (h = new sA(Aa), this.recentJitterSamples.set(t, h)), h.push(o), B.lastArrivalTime = e, B.lastTimestampMs = g;
11035
11031
  }
11036
11032
  /**
11037
11033
  * Get jitter statistics for a specific media type.
@@ -11039,21 +11035,17 @@ class Xo {
11039
11035
  * All jitter values are rounded to integer milliseconds for cleaner statistics aggregation.
11040
11036
  */
11041
11037
  getJitterForType(A) {
11042
- var t, e, g, B;
11043
- for (const [C, Q] of this.trackingState)
11044
- if (C.startsWith(A)) {
11045
- const o = Q.jitterSamples.items();
11046
- if (o.length < 1)
11038
+ var t, e, g;
11039
+ for (const [B, C] of this.trackingState)
11040
+ if (B.startsWith(A)) {
11041
+ if (C.jitterSamples.items().length < 1)
11047
11042
  return;
11048
- const a = Be(o), c = (t = this.runningJitter.get(C)) != null ? t : 0, h = (e = this.reactiveJitter.get(C)) != null ? e : 0, d = (B = (g = this.recentJitterSamples.get(C)) == null ? void 0 : g.items()) != null ? B : [], u = d.length > 0 ? Math.max(...d) : 0;
11043
+ const o = (t = this.runningJitter.get(B)) != null ? t : 0, a = (g = (e = this.recentJitterSamples.get(B)) == null ? void 0 : e.items()) != null ? g : [], { min: c, max: h, average: d } = Be(a);
11049
11044
  return {
11050
- jitter: Math.round(c),
11051
- reactiveJitter: Math.round(h),
11052
- recentMaxJitter: Math.round(u),
11053
- averageJitter: Math.round(a.average),
11054
- maxJitter: Math.round(a.max),
11055
- minJitter: Math.round(a.min),
11056
- sampleCount: o.length
11045
+ min: Math.round(c),
11046
+ max: Math.round(h),
11047
+ last: Math.round(d),
11048
+ average: Math.round(o)
11057
11049
  };
11058
11050
  }
11059
11051
  }
@@ -11071,12 +11063,12 @@ class Xo {
11071
11063
  reset(A, t) {
11072
11064
  if (A !== void 0 && t !== void 0) {
11073
11065
  const e = this.getTrackingKey(A, t);
11074
- this.trackingState.delete(e), this.runningJitter.delete(e), this.reactiveJitter.delete(e), this.recentJitterSamples.delete(e);
11066
+ this.trackingState.delete(e), this.runningJitter.delete(e), this.recentJitterSamples.delete(e);
11075
11067
  } else if (A !== void 0)
11076
11068
  for (const e of this.trackingState.keys())
11077
- e.startsWith(A) && (this.trackingState.delete(e), this.runningJitter.delete(e), this.reactiveJitter.delete(e), this.recentJitterSamples.delete(e));
11069
+ e.startsWith(A) && (this.trackingState.delete(e), this.runningJitter.delete(e), this.recentJitterSamples.delete(e));
11078
11070
  else
11079
- this.trackingState.clear(), this.runningJitter.clear(), this.reactiveJitter.clear(), this.recentJitterSamples.clear();
11071
+ this.trackingState.clear(), this.runningJitter.clear(), this.recentJitterSamples.clear();
11080
11072
  }
11081
11073
  getStatistics() {
11082
11074
  return {
@@ -11094,7 +11086,7 @@ const Fu = {
11094
11086
  maxRetries: 10,
11095
11087
  maxErrorReports: 50,
11096
11088
  maxEvents: 50
11097
- }, RQ = (i, A) => P(D({}, A), { type: i, timestamp: (/* @__PURE__ */ new Date()).toISOString(), discriminator: "web" }), _C = class _C {
11089
+ }, RQ = (i, A) => Y(D({}, A), { type: i, timestamp: (/* @__PURE__ */ new Date()).toISOString(), discriminator: "web" }), _C = class _C {
11098
11090
  constructor(A, t, e, g) {
11099
11091
  I(this, "logger");
11100
11092
  I(this, "timers", new yA());
@@ -11117,7 +11109,7 @@ const Fu = {
11117
11109
  I(this, "addStats", ({ isFinal: A, initiator: t } = { isFinal: !1, initiator: "interval" }, e = {}) => {
11118
11110
  if (!this.options.includeStats)
11119
11111
  return;
11120
- const g = this.parentContext.getStatistics(), B = RQ("stats", P(D(D({}, e), g), { isFinal: A, initiator: t, count: this.statsCount++ }));
11112
+ const g = this.parentContext.getStatistics(), B = RQ("stats", Y(D(D({}, e), g), { isFinal: A, initiator: t, count: this.statsCount++ }));
11121
11113
  this.unsentLines.push(B);
11122
11114
  });
11123
11115
  I(this, "addEvent", (A) => {
@@ -11267,7 +11259,7 @@ const Uu = 6, Nu = (i) => {
11267
11259
  var p, b, y;
11268
11260
  Q.flags && ug(Q.flags) && (t = (p = Q.compositionTimeOffset) != null ? p : 0), Q.timestamp += t, Q.compositionTimeOffset = ((b = Q.compositionTimeOffset) != null ? b : 0) - t;
11269
11261
  const a = Q.timestamp / Q.timescale, h = o.flags && ug(o.flags) ? (y = o.compositionTimeOffset) != null ? y : 0 : t, u = (o.timestamp + h) / o.timescale, m = Math.max(0, Math.round((u - a) * Q.timescale));
11270
- return m > 0 && (e = m), P(D({}, Q), {
11262
+ return m > 0 && (e = m), Y(D({}, Q), {
11271
11263
  /*
11272
11264
  During resync timeshifts we may end up with negative durations (normalized to 0 above) which is not allowed in mse (the MseModule
11273
11265
  drops the frame) so we use the last known duration instead. This is not ideal but it's better than dropping the frame.
@@ -11294,7 +11286,7 @@ const Uu = 6, Nu = (i) => {
11294
11286
  };
11295
11287
  }, bu = (i, A, t) => {
11296
11288
  if (Fi(A))
11297
- return D(P(D({}, i), {
11289
+ return D(Y(D({}, i), {
11298
11290
  type: "video",
11299
11291
  codec: A.codec,
11300
11292
  isSync: ug(i.flags),
@@ -11305,7 +11297,7 @@ const Uu = 6, Nu = (i) => {
11305
11297
  }), t);
11306
11298
  if (A.codec === "webvtt")
11307
11299
  throw new Error("WebVTT is not supported");
11308
- return P(D({}, i), {
11300
+ return Y(D({}, i), {
11309
11301
  type: "audio",
11310
11302
  channels: A.channels,
11311
11303
  sampleRate: A.sampleRate,
@@ -11482,7 +11474,7 @@ const Mt = class Mt extends $A {
11482
11474
  var a;
11483
11475
  this.sessionId = wn();
11484
11476
  const e = this.modules.subscription.getTargetSubscription(), g = t.channels.find((c) => c.channelId === e.channelId);
11485
- if (this.emitter.emit("connect info", t), "timeshift" in t && t.timeshift ? (t.timeshift, this._channels = t.channels.map((c) => P(D({}, c), {
11477
+ if (this.emitter.emit("connect info", t), "timeshift" in t && t.timeshift ? (t.timeshift, this._channels = t.channels.map((c) => Y(D({}, c), {
11486
11478
  timeshift: t.timeshift
11487
11479
  })), this.emit("timeshift info", t.timeshift)) : 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(
11488
11480
  t.channels.map((c) => r(this, null, function* () {
@@ -11713,11 +11705,18 @@ const Mt = class Mt extends $A {
11713
11705
  *
11714
11706
  * Use undocumented properties at your own risk.
11715
11707
  */
11716
- I(this, "getStatistics", () => Object.values(this.modules).reduce(
11717
- (t, e) => e && "getStatistics" in e ? D(D({}, t), e.getStatistics()) : t,
11718
- // Safety: We know that the collective statistics from module map will equal Statistic because the Statistics type is inferred from moduleMap
11719
- this.getRuntimeInfo()
11720
- ));
11708
+ I(this, "getStatistics", () => {
11709
+ const t = Object.values(this.modules).reduce(
11710
+ (g, B) => B && "getStatistics" in B ? D(D({}, g), B.getStatistics()) : g,
11711
+ // Safety: We know that the collective statistics from module map will equal Statistic because the Statistics type is inferred from moduleMap
11712
+ this.getRuntimeInfo()
11713
+ ), e = Math.round(
11714
+ this.timeActive > 0 ? (t.bytesReceived || 0) * 8 / (this.timeActive / 1e3) : 0
11715
+ );
11716
+ return Y(D({}, t), {
11717
+ averageBitRate: e
11718
+ });
11719
+ });
11721
11720
  I(this, "resetModules", () => {
11722
11721
  Object.values(this.modules).forEach((t) => {
11723
11722
  t && "reset" in t && t.reset();
@@ -11727,7 +11726,7 @@ const Mt = class Mt extends $A {
11727
11726
  const t = this.modules.canvasModule ? this.options.get("iosMediaElementEnabled") : void 0;
11728
11727
  return D({
11729
11728
  uptime: Date.now() - this.createdAt,
11730
- version: "4.1.4-22-gcde161e2",
11729
+ version: "4.1.4-24-g8881df4e",
11731
11730
  clientId: this.clientId,
11732
11731
  sessionId: this.sessionId,
11733
11732
  channelId: this.channelId,
@@ -11947,21 +11946,21 @@ const Mt = class Mt extends $A {
11947
11946
  w.telemetry && ((x = this.modules.telemetry) == null || x.unload(), this.modules.telemetry = gC.create(
11948
11947
  this.logger.createContext("TelemetryModule"),
11949
11948
  this.emitter,
11950
- P(D({}, w.telemetry), {
11949
+ Y(D({}, w.telemetry), {
11951
11950
  enabled: this.options.get("telemetryEnabled") && W
11952
11951
  }),
11953
11952
  this
11954
11953
  ), this.modules.telemetry.load());
11955
11954
  }), this.emitter.on("adapt level", (w) => {
11956
- var F, k, Y, tA, M;
11955
+ var F, k, T, tA, M;
11957
11956
  this.logger.debug("adapt level", { direction: w });
11958
- const f = this.modules.renditions.getRenditionLevels(), W = this.modules.renditions.getRenditionLevel(), O = f.findIndex((T) => T === W), q = f.length - 1;
11957
+ const f = this.modules.renditions.getRenditionLevels(), W = this.modules.renditions.getRenditionLevel(), O = f.findIndex((P) => P === W), q = f.length - 1;
11959
11958
  let x = O;
11960
11959
  switch (w) {
11961
11960
  case "upgrade":
11962
11961
  {
11963
- const T = Math.min(O + 1, q), FA = f[T], Ji = (F = this.modules.connection.estimatedBandwidth) != null ? F : ke(), Cg = ((Y = (k = FA == null ? void 0 : FA.audio) == null ? void 0 : k.bitRate) != null ? Y : 0) + ((M = (tA = FA == null ? void 0 : FA.video) == null ? void 0 : tA.bitRate) != null ? M : 0), Ne = Ji * 2 > Cg;
11964
- FA && Ne && this.modules.adaptivity.isQoSOk(FA) && (x = T);
11962
+ const P = Math.min(O + 1, q), FA = f[P], Ji = (F = this.modules.connection.estimatedBandwidth) != null ? F : ke(), Cg = ((T = (k = FA == null ? void 0 : FA.audio) == null ? void 0 : k.bitRate) != null ? T : 0) + ((M = (tA = FA == null ? void 0 : FA.video) == null ? void 0 : tA.bitRate) != null ? M : 0), Ne = Ji * 2 > Cg;
11963
+ FA && Ne && this.modules.adaptivity.isQoSOk(FA) && (x = P);
11965
11964
  }
11966
11965
  break;
11967
11966
  case "downgrade":
@@ -11982,7 +11981,7 @@ const Mt = class Mt extends $A {
11982
11981
  if (x === O)
11983
11982
  return;
11984
11983
  const $ = f[x];
11985
- this.alignSizeAndBitRate(P(D({}, this.targetSubscription), {
11984
+ this.alignSizeAndBitRate(Y(D({}, this.targetSubscription), {
11986
11985
  video: D(D({}, this.targetSubscription.video), $ == null ? void 0 : $.video),
11987
11986
  audio: D(D({}, this.targetSubscription.audio), $ == null ? void 0 : $.audio)
11988
11987
  })), this.emitter.emit("adapted level");
@@ -12045,7 +12044,7 @@ const Mt = class Mt extends $A {
12045
12044
  this.logger.warn("Received unwanted message", D({}, W));
12046
12045
  return;
12047
12046
  }
12048
- wA(P(D({}, W), { channelId: f.channelId }));
12047
+ wA(Y(D({}, W), { channelId: f.channelId }));
12049
12048
  }), this.emitter.on("received moq data", (w) => {
12050
12049
  var x, $, F;
12051
12050
  const f = w.payload.mediaType(), W = w.channelId, O = w.renditionId, q = this.modules.sync.processFragment(W, w.payload);
@@ -12065,17 +12064,17 @@ const Mt = class Mt extends $A {
12065
12064
  }), this.modules.incomingData.add(f, w.payload.rawBytes().byteLength), q.fragment().emsgs.forEach((k) => {
12066
12065
  if (!k.presentationTime)
12067
12066
  return;
12068
- const Y = xc(k.data);
12069
- Y && this.modules.event.addEvent({
12067
+ const T = xc(k.data);
12068
+ T && this.modules.event.addEvent({
12070
12069
  id: k.id,
12071
12070
  timestamp: k.presentationTime / k.timescale * 1e3 - this.modules.sync.getTimeshiftOffset(),
12072
- content: Y.txx.value,
12071
+ content: T.txx.value,
12073
12072
  type: "metadata"
12074
12073
  });
12075
12074
  }), this.modules.decoder) {
12076
- const k = (x = q.header().init().moov.traks[0]) == null ? void 0 : x.mdia.minf.stbl.stsd, Y = ($ = k == null ? void 0 : k.avc1) == null ? void 0 : $.avcC.bytes, tA = (F = k == null ? void 0 : k.codec) != null ? F : "h264";
12077
- if (Y) {
12078
- const M = Y.buffer.slice(Y.byteOffset, Y.byteOffset + Y.byteLength);
12075
+ const k = (x = q.header().init().moov.traks[0]) == null ? void 0 : x.mdia.minf.stbl.stsd, T = ($ = k == null ? void 0 : k.avc1) == null ? void 0 : $.avcC.bytes, tA = (F = k == null ? void 0 : k.codec) != null ? F : "h264";
12076
+ if (T) {
12077
+ const M = T.buffer.slice(T.byteOffset, T.byteOffset + T.byteLength);
12079
12078
  if (f === "text")
12080
12079
  throw new Error("Subtitles are not supported");
12081
12080
  this.emitter.emit("init segment", {
@@ -12092,11 +12091,11 @@ const Mt = class Mt extends $A {
12092
12091
  });
12093
12092
  }
12094
12093
  for (let M = 0; M < q.samplesCount(); M++) {
12095
- const T = q.sample(M);
12096
- T && this.emitter.emit("coded sample", P(D({}, T), {
12094
+ const P = q.sample(M);
12095
+ P && this.emitter.emit("coded sample", Y(D({}, P), {
12097
12096
  renditionId: O,
12098
12097
  channelId: W,
12099
- data: T.data.buffer.slice(T.data.byteOffset, T.data.byteOffset + T.data.byteLength)
12098
+ data: P.data.buffer.slice(P.data.byteOffset, P.data.byteOffset + P.data.byteLength)
12100
12099
  }));
12101
12100
  }
12102
12101
  } else
@@ -12114,13 +12113,13 @@ const Mt = class Mt extends $A {
12114
12113
  if (w.renditionId !== 0) {
12115
12114
  const $ = Ra(q);
12116
12115
  if ($ && $.language !== void 0) {
12117
- const k = new $a().parse($.content || ""), Y = x / 1e3, tA = s(this, xA).find((T) => T.language === $.language), M = Y - s(this, fi);
12118
- if (E(this, fi, Y), tA) {
12116
+ const k = new $a().parse($.content || ""), T = x / 1e3, tA = s(this, xA).find((P) => P.language === $.language), M = T - s(this, fi);
12117
+ if (E(this, fi, T), tA) {
12119
12118
  if (tA.cues)
12120
- for (const T of tA.cues)
12121
- T.startTime -= M, T.endTime -= M;
12122
- for (const T of k) {
12123
- const FA = new VTTCue(T.startTime - Y, T.endTime - Y, T.text);
12119
+ for (const P of tA.cues)
12120
+ P.startTime -= M, P.endTime -= M;
12121
+ for (const P of k) {
12122
+ const FA = new VTTCue(P.startTime - T, P.endTime - T, P.text);
12124
12123
  tA.addCue(FA);
12125
12124
  }
12126
12125
  }
@@ -12136,7 +12135,7 @@ const Mt = class Mt extends $A {
12136
12135
  if (O === "text")
12137
12136
  throw new Error("Subtitles are not supported");
12138
12137
  if (this.modules.incomingData.add(O, w.payload.byteLength), Ed(w.flags)) {
12139
- const q = P(D({
12138
+ const q = Y(D({
12140
12139
  type: O,
12141
12140
  data: w.payload,
12142
12141
  codec: W.codec
@@ -12556,7 +12555,7 @@ const Mt = class Mt extends $A {
12556
12555
  * Aligns size and bitrate to match a rendition level correctly
12557
12556
  */
12558
12557
  alignSizeAndBitRate(t) {
12559
- const e = this.modules.constraintCap.constrainSubscription(P(D({}, t), {
12558
+ const e = this.modules.constraintCap.constrainSubscription(Y(D({}, t), {
12560
12559
  video: D({}, t.video),
12561
12560
  audio: D({}, t.audio)
12562
12561
  })), g = this.modules.constraintCap.getUserSpecifiedCap();
@@ -13371,7 +13370,7 @@ class cD {
13371
13370
  thumbnailModule: this.thumbnailModule
13372
13371
  }));
13373
13372
  const B = (t == null ? void 0 : t.channelSelectionEnabled) || ((h = (c = t == null ? void 0 : t.channelSelectionOptions) == null ? void 0 : c.barButton) == null ? void 0 : h.enabled), C = (u = (d = t == null ? void 0 : t.channelSelectionOptions) == null ? void 0 : d.barButton) == null ? void 0 : u.thumbnails;
13374
- this.bar = new Lw(P(D({
13373
+ this.bar = new Lw(Y(D({
13375
13374
  vindral: this.core,
13376
13375
  thumbnailModule: this.thumbnailModule
13377
13376
  }, e), {
@@ -13473,18 +13472,18 @@ var oD = (function() {
13473
13472
  try {
13474
13473
  if (F == CA && c) return new Uint8Array(c);
13475
13474
  if (AA(F)) try {
13476
- var k = O(F.slice(37)), Y = new Uint8Array(k.length);
13477
- for (F = 0; F < k.length; ++F) Y[F] = k.charCodeAt(F);
13478
- var tA = Y;
13479
- } catch (T) {
13475
+ var k = O(F.slice(37)), T = new Uint8Array(k.length);
13476
+ for (F = 0; F < k.length; ++F) T[F] = k.charCodeAt(F);
13477
+ var tA = T;
13478
+ } catch (P) {
13480
13479
  throw Error("Converting base64 string to bytes failed.");
13481
13480
  }
13482
13481
  else tA = void 0;
13483
13482
  var M = tA;
13484
13483
  if (M) return M;
13485
13484
  throw "both async and sync fetching of the wasm failed";
13486
- } catch (T) {
13487
- EA(T);
13485
+ } catch (P) {
13486
+ EA(P);
13488
13487
  }
13489
13488
  }
13490
13489
  function w() {
@@ -13502,33 +13501,33 @@ var oD = (function() {
13502
13501
  var k = F.shift();
13503
13502
  if (typeof k == "function") k(t);
13504
13503
  else {
13505
- var Y = k.s;
13506
- typeof Y == "number" ? k.o === void 0 ? p.get(Y)() : p.get(Y)(k.o) : Y(k.o === void 0 ? null : k.o);
13504
+ var T = k.s;
13505
+ typeof T == "number" ? k.o === void 0 ? p.get(T)() : p.get(T)(k.o) : T(k.o === void 0 ? null : k.o);
13507
13506
  }
13508
13507
  }
13509
13508
  }
13510
13509
  var W = [null, [], []], O = typeof atob == "function" ? atob : function(F) {
13511
- var k = "", Y = 0;
13510
+ var k = "", T = 0;
13512
13511
  F = F.replace(/[^A-Za-z0-9\+\/=]/g, "");
13513
13512
  do {
13514
- var tA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(Y++)), M = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(Y++)), T = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(Y++)), FA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(Y++));
13515
- tA = tA << 2 | M >> 4, M = (M & 15) << 4 | T >> 2;
13516
- var Ji = (T & 3) << 6 | FA;
13517
- k += String.fromCharCode(tA), T !== 64 && (k += String.fromCharCode(M)), FA !== 64 && (k += String.fromCharCode(Ji));
13518
- } while (Y < F.length);
13513
+ var tA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(T++)), M = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(T++)), P = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(T++)), FA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(F.charAt(T++));
13514
+ tA = tA << 2 | M >> 4, M = (M & 15) << 4 | P >> 2;
13515
+ var Ji = (P & 3) << 6 | FA;
13516
+ k += String.fromCharCode(tA), P !== 64 && (k += String.fromCharCode(M)), FA !== 64 && (k += String.fromCharCode(Ji));
13517
+ } while (T < F.length);
13519
13518
  return k;
13520
13519
  }, q = { d: function() {
13521
13520
  EA();
13522
- }, f: function(F, k, Y) {
13523
- m.copyWithin(F, k, k + Y);
13521
+ }, f: function(F, k, T) {
13522
+ m.copyWithin(F, k, k + T);
13524
13523
  }, c: function() {
13525
13524
  return !1;
13526
13525
  }, e: function() {
13527
13526
  return 0;
13528
13527
  }, b: function() {
13529
- }, a: function(F, k, Y, tA) {
13530
- for (var M = 0, T = 0; T < Y; T++) {
13531
- for (var FA = S[k + 8 * T >> 2], Ji = S[k + (8 * T + 4) >> 2], Cg = 0; Cg < Ji; Cg++) {
13528
+ }, a: function(F, k, T, tA) {
13529
+ for (var M = 0, P = 0; P < T; P++) {
13530
+ for (var FA = S[k + 8 * P >> 2], Ji = S[k + (8 * P + 4) >> 2], Cg = 0; Cg < Ji; Cg++) {
13532
13531
  var Ne = m[FA + Cg], nQ = W[F];
13533
13532
  if (Ne === 0 || Ne === 10) {
13534
13533
  Ne = F === 1 ? o : a;
@@ -13562,14 +13561,14 @@ var oD = (function() {
13562
13561
  function k(M) {
13563
13562
  F(M.instance);
13564
13563
  }
13565
- function Y(M) {
13566
- return w().then(function(T) {
13564
+ function T(M) {
13565
+ return w().then(function(P) {
13567
13566
  return WebAssembly.instantiate(
13568
- T,
13567
+ P,
13569
13568
  tA
13570
13569
  );
13571
- }).then(M, function(T) {
13572
- a("failed to asynchronously prepare wasm: " + T), EA(T);
13570
+ }).then(M, function(P) {
13571
+ a("failed to asynchronously prepare wasm: " + P), EA(P);
13573
13572
  });
13574
13573
  }
13575
13574
  var tA = { a: q };
@@ -13579,11 +13578,11 @@ var oD = (function() {
13579
13578
  return a("Module.instantiateWasm callback failed with error: " + M), !1;
13580
13579
  }
13581
13580
  return (function() {
13582
- return c || typeof WebAssembly.instantiateStreaming != "function" || AA(CA) || typeof fetch != "function" ? Y(k) : fetch(CA, { credentials: "same-origin" }).then(function(M) {
13581
+ return c || typeof WebAssembly.instantiateStreaming != "function" || AA(CA) || typeof fetch != "function" ? T(k) : fetch(CA, { credentials: "same-origin" }).then(function(M) {
13583
13582
  return WebAssembly.instantiateStreaming(M, tA).then(
13584
13583
  k,
13585
- function(T) {
13586
- return a("wasm streaming compile failed: " + T), a("falling back to ArrayBuffer instantiation"), Y(k);
13584
+ function(P) {
13585
+ return a("wasm streaming compile failed: " + P), a("falling back to ArrayBuffer instantiation"), T(k);
13587
13586
  }
13588
13587
  );
13589
13588
  });
@@ -13683,7 +13682,7 @@ const Yg = class Yg {
13683
13682
  I(this, "enqueue", (A) => {
13684
13683
  try {
13685
13684
  const t = Date.now(), e = this.decoder.decode(A.data);
13686
- this.decodedSamples.push(P(D({}, A), {
13685
+ this.decodedSamples.push(Y(D({}, A), {
13687
13686
  type: "audio",
13688
13687
  format: "f32",
13689
13688
  data: e,