@moq/watch 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -404,7 +404,7 @@ const Ge = (e) => (n, t, r, s) => {
404
404
  throw Cn(a, s?.callee), a;
405
405
  }
406
406
  return o.value;
407
- }, Re = (e) => (n, t, r) => {
407
+ }, Ue = (e) => (n, t, r) => {
408
408
  const s = r ? { ...r, async: !1 } : { async: !1 }, i = n._zod.run({ value: t, issues: [] }, s);
409
409
  if (i instanceof Promise)
410
410
  throw new oe();
@@ -412,26 +412,26 @@ const Ge = (e) => (n, t, r, s) => {
412
412
  success: !1,
413
413
  error: new (e ?? Zn)(i.issues.map((o) => X(o, s, H())))
414
414
  } : { success: !0, data: i.value };
415
- }, Xt = /* @__PURE__ */ Re(Fn), Ue = (e) => async (n, t, r) => {
415
+ }, Xt = /* @__PURE__ */ Ue(Fn), Re = (e) => async (n, t, r) => {
416
416
  const s = r ? Object.assign(r, { async: !0 }) : { async: !0 };
417
417
  let i = n._zod.run({ value: t, issues: [] }, s);
418
418
  return i instanceof Promise && (i = await i), i.issues.length ? {
419
419
  success: !1,
420
420
  error: new e(i.issues.map((o) => X(o, s, H())))
421
421
  } : { success: !0, data: i.value };
422
- }, Kt = /* @__PURE__ */ Ue(Fn), Yt = (e) => (n, t, r) => {
422
+ }, Kt = /* @__PURE__ */ Re(Fn), Yt = (e) => (n, t, r) => {
423
423
  const s = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
424
424
  return Ge(e)(n, t, s);
425
425
  }, Qt = (e) => (n, t, r) => Ge(e)(n, t, r), er = (e) => async (n, t, r) => {
426
426
  const s = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
427
427
  return Je(e)(n, t, s);
428
428
  }, nr = (e) => async (n, t, r) => Je(e)(n, t, r), tr = (e) => (n, t, r) => {
429
- const s = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
430
- return Re(e)(n, t, s);
431
- }, rr = (e) => (n, t, r) => Re(e)(n, t, r), sr = (e) => async (n, t, r) => {
432
429
  const s = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
433
430
  return Ue(e)(n, t, s);
434
- }, ir = (e) => async (n, t, r) => Ue(e)(n, t, r), or = /^[cC][^\s-]{8,}$/, ar = /^[0-9a-z]+$/, cr = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, ur = /^[0-9a-vA-V]{20}$/, dr = /^[A-Za-z0-9]{27}$/, lr = /^[a-zA-Z0-9_-]{21}$/, fr = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, hr = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, en = (e) => e ? new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, pr = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, mr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
431
+ }, rr = (e) => (n, t, r) => Ue(e)(n, t, r), sr = (e) => async (n, t, r) => {
432
+ const s = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
433
+ return Re(e)(n, t, s);
434
+ }, ir = (e) => async (n, t, r) => Re(e)(n, t, r), or = /^[cC][^\s-]{8,}$/, ar = /^[0-9a-z]+$/, cr = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, ur = /^[0-9a-vA-V]{20}$/, dr = /^[A-Za-z0-9]{27}$/, lr = /^[a-zA-Z0-9_-]{21}$/, fr = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, hr = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, en = (e) => e ? new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, pr = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, mr = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
435
435
  function wr() {
436
436
  return new RegExp(mr, "u");
437
437
  }
@@ -493,7 +493,7 @@ const Er = (e) => {
493
493
  continue: !n.abort
494
494
  });
495
495
  };
496
- }), Rr = /* @__PURE__ */ l("$ZodCheckMultipleOf", (e, n) => {
496
+ }), Ur = /* @__PURE__ */ l("$ZodCheckMultipleOf", (e, n) => {
497
497
  x.init(e, n), e._zod.onattach.push((t) => {
498
498
  var r;
499
499
  (r = t._zod.bag).multipleOf ?? (r.multipleOf = n.value);
@@ -509,7 +509,7 @@ const Er = (e) => {
509
509
  continue: !n.abort
510
510
  });
511
511
  };
512
- }), Ur = /* @__PURE__ */ l("$ZodCheckNumberFormat", (e, n) => {
512
+ }), Rr = /* @__PURE__ */ l("$ZodCheckNumberFormat", (e, n) => {
513
513
  x.init(e, n), n.format = n.format || "float64";
514
514
  const t = n.format?.includes("int"), r = t ? "int" : "number", [s, i] = Zt[n.format];
515
515
  e._zod.onattach.push((o) => {
@@ -1050,7 +1050,7 @@ const ms = /* @__PURE__ */ l("$ZodJWT", (e, n) => {
1050
1050
  }), t;
1051
1051
  };
1052
1052
  }), ws = /* @__PURE__ */ l("$ZodNumberFormat", (e, n) => {
1053
- Ur.init(e, n), Xn.init(e, n);
1053
+ Rr.init(e, n), Xn.init(e, n);
1054
1054
  }), gs = /* @__PURE__ */ l("$ZodBoolean", (e, n) => {
1055
1055
  z.init(e, n), e._zod.pattern = Or, e._zod.parse = (t, r) => {
1056
1056
  if (n.coerce)
@@ -1190,19 +1190,19 @@ const _s = /* @__PURE__ */ l("$ZodObject", (e, n) => {
1190
1190
  }), ks = /* @__PURE__ */ l("$ZodObjectJIT", (e, n) => {
1191
1191
  _s.init(e, n);
1192
1192
  const t = e._zod.parse, r = Pe(() => Kn(n)), s = (p) => {
1193
- const m = new jr(["shape", "payload", "ctx"]), y = r.value, g = (U) => {
1194
- const k = Qe(U);
1193
+ const m = new jr(["shape", "payload", "ctx"]), y = r.value, g = (R) => {
1194
+ const k = Qe(R);
1195
1195
  return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1196
1196
  };
1197
1197
  m.write("const input = payload.value;");
1198
1198
  const M = /* @__PURE__ */ Object.create(null);
1199
1199
  let q = 0;
1200
- for (const U of y.keys)
1201
- M[U] = `key_${q++}`;
1200
+ for (const R of y.keys)
1201
+ M[R] = `key_${q++}`;
1202
1202
  m.write("const newResult = {};");
1203
- for (const U of y.keys) {
1204
- const k = M[U], O = Qe(U), B = p[U]?._zod?.optout === "optional";
1205
- m.write(`const ${k} = ${g(U)};`), B ? m.write(`
1203
+ for (const R of y.keys) {
1204
+ const k = M[R], O = Qe(R), B = p[R]?._zod?.optout === "optional";
1205
+ m.write(`const ${k} = ${g(R)};`), B ? m.write(`
1206
1206
  if (${k}.issues.length) {
1207
1207
  if (${O} in input) {
1208
1208
  payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
@@ -1240,7 +1240,7 @@ const _s = /* @__PURE__ */ l("$ZodObject", (e, n) => {
1240
1240
  }
1241
1241
  m.write("payload.value = newResult;"), m.write("return payload;");
1242
1242
  const Z = m.compile();
1243
- return (U, k) => Z(p, U, k);
1243
+ return (R, k) => Z(p, R, k);
1244
1244
  };
1245
1245
  let i;
1246
1246
  const o = ge, a = !$n.jitless, u = a && Ct.value, d = n.catchall;
@@ -1537,7 +1537,7 @@ const et = /* @__PURE__ */ l("$ZodOptional", (e, n) => {
1537
1537
  const t = n.innerType._zod.pattern;
1538
1538
  return t ? new RegExp(`^(${Ve(t.source)}|null)$`) : void 0;
1539
1539
  }), b(e._zod, "values", () => n.innerType._zod.values ? /* @__PURE__ */ new Set([...n.innerType._zod.values, null]) : void 0), e._zod.parse = (t, r) => t.value === null ? t : n.innerType._zod.run(t, r);
1540
- }), Rs = /* @__PURE__ */ l("$ZodDefault", (e, n) => {
1540
+ }), Us = /* @__PURE__ */ l("$ZodDefault", (e, n) => {
1541
1541
  z.init(e, n), e._zod.optin = "optional", b(e._zod, "values", () => n.innerType._zod.values), e._zod.parse = (t, r) => {
1542
1542
  if (r.direction === "backward")
1543
1543
  return n.innerType._zod.run(t, r);
@@ -1550,7 +1550,7 @@ const et = /* @__PURE__ */ l("$ZodOptional", (e, n) => {
1550
1550
  function on(e, n) {
1551
1551
  return e.value === void 0 && (e.value = n.defaultValue), e;
1552
1552
  }
1553
- const Us = /* @__PURE__ */ l("$ZodPrefault", (e, n) => {
1553
+ const Rs = /* @__PURE__ */ l("$ZodPrefault", (e, n) => {
1554
1554
  z.init(e, n), e._zod.optin = "optional", b(e._zod, "values", () => n.innerType._zod.values), e._zod.parse = (t, r) => (r.direction === "backward" || t.value === void 0 && (t.value = n.defaultValue), n.innerType._zod.run(t, r));
1555
1555
  }), Ns = /* @__PURE__ */ l("$ZodNonOptional", (e, n) => {
1556
1556
  z.init(e, n), b(e._zod, "values", () => {
@@ -2016,7 +2016,7 @@ function De(e, n) {
2016
2016
  }
2017
2017
  // @__NO_SIDE_EFFECTS__
2018
2018
  function pn(e, n) {
2019
- return new Rr({
2019
+ return new Ur({
2020
2020
  check: "multiple_of",
2021
2021
  ...w(n),
2022
2022
  value: e
@@ -2147,7 +2147,7 @@ function Ai(e, n, t) {
2147
2147
  }
2148
2148
  // @__NO_SIDE_EFFECTS__
2149
2149
  function Pi(e) {
2150
- const n = /* @__PURE__ */ Ri((t) => (t.addIssue = (r) => {
2150
+ const n = /* @__PURE__ */ Ui((t) => (t.addIssue = (r) => {
2151
2151
  if (typeof r == "string")
2152
2152
  t.issues.push(ve(r, t.value, n._zod.def));
2153
2153
  else {
@@ -2158,7 +2158,7 @@ function Pi(e) {
2158
2158
  return n;
2159
2159
  }
2160
2160
  // @__NO_SIDE_EFFECTS__
2161
- function Ri(e, n) {
2161
+ function Ui(e, n) {
2162
2162
  const t = new x({
2163
2163
  check: "custom",
2164
2164
  ...w(n)
@@ -2392,7 +2392,7 @@ function $(e, n) {
2392
2392
  }
2393
2393
  return !1;
2394
2394
  }
2395
- const Ui = (e, n = {}) => (t) => {
2395
+ const Ri = (e, n = {}) => (t) => {
2396
2396
  const r = rt({ ...t, processors: n });
2397
2397
  return P(e, r), st(r, e), it(r, e);
2398
2398
  }, Oe = (e, n, t = {}) => (r) => {
@@ -2615,12 +2615,12 @@ const uo = (e, n) => {
2615
2615
  });
2616
2616
  }, F = l("ZodError", uo, {
2617
2617
  Parent: Error
2618
- }), lo = /* @__PURE__ */ Ge(F), fo = /* @__PURE__ */ Je(F), ho = /* @__PURE__ */ Re(F), po = /* @__PURE__ */ Ue(F), mo = /* @__PURE__ */ Yt(F), wo = /* @__PURE__ */ Qt(F), go = /* @__PURE__ */ er(F), vo = /* @__PURE__ */ nr(F), bo = /* @__PURE__ */ tr(F), yo = /* @__PURE__ */ rr(F), _o = /* @__PURE__ */ sr(F), ko = /* @__PURE__ */ ir(F), I = /* @__PURE__ */ l("ZodType", (e, n) => (z.init(e, n), Object.assign(e["~standard"], {
2618
+ }), lo = /* @__PURE__ */ Ge(F), fo = /* @__PURE__ */ Je(F), ho = /* @__PURE__ */ Ue(F), po = /* @__PURE__ */ Re(F), mo = /* @__PURE__ */ Yt(F), wo = /* @__PURE__ */ Qt(F), go = /* @__PURE__ */ er(F), vo = /* @__PURE__ */ nr(F), bo = /* @__PURE__ */ tr(F), yo = /* @__PURE__ */ rr(F), _o = /* @__PURE__ */ sr(F), ko = /* @__PURE__ */ ir(F), I = /* @__PURE__ */ l("ZodType", (e, n) => (z.init(e, n), Object.assign(e["~standard"], {
2619
2619
  jsonSchema: {
2620
2620
  input: Oe(e, "input"),
2621
2621
  output: Oe(e, "output")
2622
2622
  }
2623
- }), e.toJSONSchema = Ui(e, {}), e.def = n, e.type = n.type, Object.defineProperty(e, "_def", { value: n }), e.check = (...t) => e.clone(Y(n, {
2623
+ }), e.toJSONSchema = Ri(e, {}), e.def = n, e.type = n.type, Object.defineProperty(e, "_def", { value: n }), e.check = (...t) => e.clone(Y(n, {
2624
2624
  checks: [
2625
2625
  ...n.checks ?? [],
2626
2626
  ...t.map((r) => typeof r == "function" ? { _zod: { check: r, def: { check: "custom" }, onattach: [] } } : r)
@@ -2645,7 +2645,7 @@ const uo = (e, n) => {
2645
2645
  const t = e._zod.bag;
2646
2646
  e.format = t.format ?? null, e.minLength = t.minimum ?? null, e.maxLength = t.maximum ?? null, e.regex = (...r) => e.check(/* @__PURE__ */ gi(...r)), e.includes = (...r) => e.check(/* @__PURE__ */ yi(...r)), e.startsWith = (...r) => e.check(/* @__PURE__ */ _i(...r)), e.endsWith = (...r) => e.check(/* @__PURE__ */ ki(...r)), e.min = (...r) => e.check(/* @__PURE__ */ Te(...r)), e.max = (...r) => e.check(/* @__PURE__ */ nt(...r)), e.length = (...r) => e.check(/* @__PURE__ */ tt(...r)), e.nonempty = (...r) => e.check(/* @__PURE__ */ Te(1, ...r)), e.lowercase = (r) => e.check(/* @__PURE__ */ vi(r)), e.uppercase = (r) => e.check(/* @__PURE__ */ bi(r)), e.trim = () => e.check(/* @__PURE__ */ zi()), e.normalize = (...r) => e.check(/* @__PURE__ */ Si(...r)), e.toLowerCase = () => e.check(/* @__PURE__ */ Ii()), e.toUpperCase = () => e.check(/* @__PURE__ */ Ei()), e.slugify = () => e.check(/* @__PURE__ */ Ti());
2647
2647
  }), So = /* @__PURE__ */ l("ZodString", (e, n) => {
2648
- We.init(e, n), at.init(e, n), e.email = (t) => e.check(/* @__PURE__ */ Fs(zo, t)), e.url = (t) => e.check(/* @__PURE__ */ Gs(Io, t)), e.jwt = (t) => e.check(/* @__PURE__ */ ai(Zo, t)), e.emoji = (t) => e.check(/* @__PURE__ */ Js(Eo, t)), e.guid = (t) => e.check(/* @__PURE__ */ ln(mn, t)), e.uuid = (t) => e.check(/* @__PURE__ */ Bs(Ie, t)), e.uuidv4 = (t) => e.check(/* @__PURE__ */ js(Ie, t)), e.uuidv6 = (t) => e.check(/* @__PURE__ */ Vs(Ie, t)), e.uuidv7 = (t) => e.check(/* @__PURE__ */ Ls(Ie, t)), e.nanoid = (t) => e.check(/* @__PURE__ */ Ws(To, t)), e.guid = (t) => e.check(/* @__PURE__ */ ln(mn, t)), e.cuid = (t) => e.check(/* @__PURE__ */ Hs(Oo, t)), e.cuid2 = (t) => e.check(/* @__PURE__ */ Xs(Ao, t)), e.ulid = (t) => e.check(/* @__PURE__ */ Ks(Po, t)), e.base64 = (t) => e.check(/* @__PURE__ */ si(Co, t)), e.base64url = (t) => e.check(/* @__PURE__ */ ii(xo, t)), e.xid = (t) => e.check(/* @__PURE__ */ Ys(Ro, t)), e.ksuid = (t) => e.check(/* @__PURE__ */ Qs(Uo, t)), e.ipv4 = (t) => e.check(/* @__PURE__ */ ei(No, t)), e.ipv6 = (t) => e.check(/* @__PURE__ */ ni(Mo, t)), e.cidrv4 = (t) => e.check(/* @__PURE__ */ ti($o, t)), e.cidrv6 = (t) => e.check(/* @__PURE__ */ ri(Do, t)), e.e164 = (t) => e.check(/* @__PURE__ */ oi(qo, t)), e.datetime = (t) => e.check(to(t)), e.date = (t) => e.check(so(t)), e.time = (t) => e.check(oo(t)), e.duration = (t) => e.check(co(t));
2648
+ We.init(e, n), at.init(e, n), e.email = (t) => e.check(/* @__PURE__ */ Fs(zo, t)), e.url = (t) => e.check(/* @__PURE__ */ Gs(Io, t)), e.jwt = (t) => e.check(/* @__PURE__ */ ai(Zo, t)), e.emoji = (t) => e.check(/* @__PURE__ */ Js(Eo, t)), e.guid = (t) => e.check(/* @__PURE__ */ ln(mn, t)), e.uuid = (t) => e.check(/* @__PURE__ */ Bs(Ie, t)), e.uuidv4 = (t) => e.check(/* @__PURE__ */ js(Ie, t)), e.uuidv6 = (t) => e.check(/* @__PURE__ */ Vs(Ie, t)), e.uuidv7 = (t) => e.check(/* @__PURE__ */ Ls(Ie, t)), e.nanoid = (t) => e.check(/* @__PURE__ */ Ws(To, t)), e.guid = (t) => e.check(/* @__PURE__ */ ln(mn, t)), e.cuid = (t) => e.check(/* @__PURE__ */ Hs(Oo, t)), e.cuid2 = (t) => e.check(/* @__PURE__ */ Xs(Ao, t)), e.ulid = (t) => e.check(/* @__PURE__ */ Ks(Po, t)), e.base64 = (t) => e.check(/* @__PURE__ */ si(Co, t)), e.base64url = (t) => e.check(/* @__PURE__ */ ii(xo, t)), e.xid = (t) => e.check(/* @__PURE__ */ Ys(Uo, t)), e.ksuid = (t) => e.check(/* @__PURE__ */ Qs(Ro, t)), e.ipv4 = (t) => e.check(/* @__PURE__ */ ei(No, t)), e.ipv6 = (t) => e.check(/* @__PURE__ */ ni(Mo, t)), e.cidrv4 = (t) => e.check(/* @__PURE__ */ ti($o, t)), e.cidrv6 = (t) => e.check(/* @__PURE__ */ ri(Do, t)), e.e164 = (t) => e.check(/* @__PURE__ */ oi(qo, t)), e.datetime = (t) => e.check(to(t)), e.date = (t) => e.check(so(t)), e.time = (t) => e.check(oo(t)), e.duration = (t) => e.check(co(t));
2649
2649
  });
2650
2650
  function S(e) {
2651
2651
  return /* @__PURE__ */ Zs(So, e);
@@ -2670,9 +2670,9 @@ const E = /* @__PURE__ */ l("ZodStringFormat", (e, n) => {
2670
2670
  Yr.init(e, n), E.init(e, n);
2671
2671
  }), Po = /* @__PURE__ */ l("ZodULID", (e, n) => {
2672
2672
  Qr.init(e, n), E.init(e, n);
2673
- }), Ro = /* @__PURE__ */ l("ZodXID", (e, n) => {
2673
+ }), Uo = /* @__PURE__ */ l("ZodXID", (e, n) => {
2674
2674
  es.init(e, n), E.init(e, n);
2675
- }), Uo = /* @__PURE__ */ l("ZodKSUID", (e, n) => {
2675
+ }), Ro = /* @__PURE__ */ l("ZodKSUID", (e, n) => {
2676
2676
  ns.init(e, n), E.init(e, n);
2677
2677
  }), No = /* @__PURE__ */ l("ZodIPv4", (e, n) => {
2678
2678
  os.init(e, n), E.init(e, n);
@@ -2886,7 +2886,7 @@ function yn(e) {
2886
2886
  });
2887
2887
  }
2888
2888
  const aa = /* @__PURE__ */ l("ZodDefault", (e, n) => {
2889
- Rs.init(e, n), I.init(e, n), e._zod.processJSONSchema = (t, r, s) => Xi(e, t, r, s), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
2889
+ Us.init(e, n), I.init(e, n), e._zod.processJSONSchema = (t, r, s) => Xi(e, t, r, s), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
2890
2890
  });
2891
2891
  function ca(e, n) {
2892
2892
  return new aa({
@@ -2898,7 +2898,7 @@ function ca(e, n) {
2898
2898
  });
2899
2899
  }
2900
2900
  const ua = /* @__PURE__ */ l("ZodPrefault", (e, n) => {
2901
- Us.init(e, n), I.init(e, n), e._zod.processJSONSchema = (t, r, s) => Ki(e, t, r, s), e.unwrap = () => e._zod.def.innerType;
2901
+ Rs.init(e, n), I.init(e, n), e._zod.processJSONSchema = (t, r, s) => Ki(e, t, r, s), e.unwrap = () => e._zod.def.innerType;
2902
2902
  });
2903
2903
  function da(e, n) {
2904
2904
  return new ua({
@@ -3051,7 +3051,7 @@ const D = J().int().nonnegative().max(Number.MAX_SAFE_INTEGER).brand("u53"), ft
3051
3051
  // If provided, this broadcaster is signaling the location of other peers.
3052
3052
  // The payload is a JSON blob keyed by handle for each peer.
3053
3053
  peers: be.optional()
3054
- }), Wc = He(S(), ht), Hc = T({
3054
+ }), Kc = He(S(), ht), Yc = T({
3055
3055
  name: S().optional(),
3056
3056
  // name
3057
3057
  avatar: S().optional(),
@@ -3159,7 +3159,7 @@ const D = J().int().nonnegative().max(Number.MAX_SAFE_INTEGER).brand("u53"), ft
3159
3159
  capabilities: za.optional(),
3160
3160
  preview: be.optional()
3161
3161
  });
3162
- function Ra(e) {
3162
+ function Ua(e) {
3163
3163
  const t = new TextDecoder().decode(e);
3164
3164
  try {
3165
3165
  const r = JSON.parse(t);
@@ -3168,10 +3168,10 @@ function Ra(e) {
3168
3168
  throw console.warn("invalid catalog", t), r;
3169
3169
  }
3170
3170
  }
3171
- async function Ua(e) {
3171
+ async function Ra(e) {
3172
3172
  const n = await e.readFrame();
3173
3173
  if (n)
3174
- return Ra(n);
3174
+ return Ua(n);
3175
3175
  }
3176
3176
  function pt(e) {
3177
3177
  return e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer;
@@ -3781,13 +3781,13 @@ function St(e, n) {
3781
3781
  throw new Error(
3782
3782
  `Sample ${g} would overflow mdat: offset=${m}, size=${q}, mdatLength=${f.length}`
3783
3783
  );
3784
- const U = g === 0 && u.firstSampleFlags !== void 0 ? u.firstSampleFlags : M.sampleFlags ?? c, k = M.sampleCompositionTimeOffset ?? 0, O = new Uint8Array(f.slice(m, m + q));
3784
+ const R = g === 0 && u.firstSampleFlags !== void 0 ? u.firstSampleFlags : M.sampleFlags ?? c, k = M.sampleCompositionTimeOffset ?? 0, O = new Uint8Array(f.slice(m, m + q));
3785
3785
  m += q;
3786
- const j = y + k, B = Math.round(j * 1e6 / n), R = U === 0 || (U & 65536) === 0;
3786
+ const j = y + k, B = Math.round(j * 1e6 / n), U = R === 0 || (R & 65536) === 0;
3787
3787
  p.push({
3788
3788
  data: O,
3789
3789
  timestamp: B,
3790
- keyframe: R
3790
+ keyframe: U
3791
3791
  }), y += Z;
3792
3792
  }
3793
3793
  return p;
@@ -3946,7 +3946,7 @@ function Pn(e) {
3946
3946
  flags: 0,
3947
3947
  entryCount: 0,
3948
3948
  entries: []
3949
- }, U = zt(), k = It(), O = Et(), Me = we([a, {
3949
+ }, R = zt(), k = It(), O = Et(), Me = we([a, {
3950
3950
  type: "moov",
3951
3951
  boxes: [c, {
3952
3952
  type: "trak",
@@ -3957,7 +3957,7 @@ function Pn(e) {
3957
3957
  boxes: [p, g, {
3958
3958
  type: "stbl",
3959
3959
  // biome-ignore lint/suspicious/noExplicitAny: Raw boxes for types without library writers
3960
- boxes: [q, Z, U, k, O]
3960
+ boxes: [q, Z, R, k, O]
3961
3961
  }]
3962
3962
  }]
3963
3963
  }]
@@ -3980,7 +3980,7 @@ function Pn(e) {
3980
3980
  ke.set(new Uint8Array(V.buffer, V.byteOffset, V.byteLength), fe), fe += V.byteLength;
3981
3981
  return ke;
3982
3982
  }
3983
- function Rn(e) {
3983
+ function Un(e) {
3984
3984
  const { sampleRate: n, numberOfChannels: t, description: r, codec: s, container: i } = e, o = i.kind === "cmaf" ? i.timescale : 1e6, a = i.kind === "cmaf" ? i.trackId : 1, c = {
3985
3985
  type: "ftyp",
3986
3986
  majorBrand: "isom",
@@ -4064,7 +4064,7 @@ function Rn(e) {
4064
4064
  entryCount: 1,
4065
4065
  // biome-ignore lint/suspicious/noExplicitAny: Raw sample entry box
4066
4066
  entries: [gc(s, n, t, r)]
4067
- }, U = {
4067
+ }, R = {
4068
4068
  type: "stts",
4069
4069
  version: 0,
4070
4070
  flags: 0,
@@ -4081,7 +4081,7 @@ function Rn(e) {
4081
4081
  boxes: [m, M, {
4082
4082
  type: "stbl",
4083
4083
  // biome-ignore lint/suspicious/noExplicitAny: Raw boxes for types without library writers
4084
- boxes: [Z, U, k, O, j]
4084
+ boxes: [Z, R, k, O, j]
4085
4085
  }]
4086
4086
  }]
4087
4087
  }]
@@ -4192,13 +4192,13 @@ function Tt(e) {
4192
4192
  }]
4193
4193
  }, y = we([m]);
4194
4194
  let g = 0;
4195
- for (const R of y)
4196
- g += R.byteLength;
4195
+ for (const U of y)
4196
+ g += U.byteLength;
4197
4197
  f.dataOffset = g + 8;
4198
4198
  const M = we([m]);
4199
4199
  g = 0;
4200
- for (const R of M)
4201
- g += R.byteLength;
4200
+ for (const U of M)
4201
+ g += U.byteLength;
4202
4202
  const q = new ArrayBuffer(n.byteLength), Z = new Uint8Array(q);
4203
4203
  Z.set(n);
4204
4204
  const k = we([{
@@ -4206,14 +4206,14 @@ function Tt(e) {
4206
4206
  data: Z
4207
4207
  }]);
4208
4208
  let O = 0;
4209
- for (const R of k)
4210
- O += R.byteLength;
4209
+ for (const U of k)
4210
+ O += U.byteLength;
4211
4211
  const j = new Uint8Array(g + O);
4212
4212
  let B = 0;
4213
- for (const R of M)
4214
- j.set(new Uint8Array(R.buffer, R.byteOffset, R.byteLength), B), B += R.byteLength;
4215
- for (const R of k)
4216
- j.set(new Uint8Array(R.buffer, R.byteOffset, R.byteLength), B), B += R.byteLength;
4213
+ for (const U of M)
4214
+ j.set(new Uint8Array(U.buffer, U.byteOffset, U.byteLength), B), B += U.byteLength;
4215
+ for (const U of k)
4216
+ j.set(new Uint8Array(U.buffer, U.byteOffset, U.byteLength), B), B += U.byteLength;
4217
4217
  return j;
4218
4218
  }
4219
4219
  class le {
@@ -4261,23 +4261,30 @@ class le {
4261
4261
  timestamp: i,
4262
4262
  keyframe: t
4263
4263
  };
4264
- t = !1, n.frames.push(o), (!n.latest || i > n.latest) && (n.latest = i), this.#u(), n.consumer.sequence === this.#t ? (this.#s?.(), this.#s = void 0) : this.#d();
4264
+ t = !1, n.frames.push(o), (n.latest === void 0 || i > n.latest) && (n.latest = i), this.#u(), n.consumer.sequence === this.#t ? (this.#s?.(), this.#s = void 0) : this.#d();
4265
4265
  }
4266
4266
  } catch {
4267
4267
  } finally {
4268
- n.consumer.sequence === this.#t && (this.#t += 1, this.#s?.(), this.#s = void 0), n.consumer.close();
4268
+ n.done = !0, n.consumer.sequence === this.#t && (this.#t += 1), this.#u(), this.#s?.(), this.#s = void 0, n.consumer.close();
4269
4269
  }
4270
4270
  }
4271
4271
  #d() {
4272
- if (this.#e.length < 2) return;
4273
- const n = this.#e[0];
4274
- let t, r;
4275
- for (const i of this.#e) {
4276
- if (!i.latest) continue;
4277
- const o = i.frames.at(0)?.timestamp ?? i.latest;
4278
- (t === void 0 || o < t) && (t = o), (r === void 0 || i.latest > r) && (r = i.latest);
4272
+ if (this.#t === void 0) return;
4273
+ let n = !1;
4274
+ for (; this.#e.length >= 2; ) {
4275
+ const t = A.Time.Micro.fromMilli(this.#r.peek());
4276
+ let r, s;
4277
+ for (const a of this.#e) {
4278
+ if (a.latest === void 0) continue;
4279
+ const c = a.frames.at(0)?.timestamp ?? a.latest;
4280
+ (r === void 0 || c < r) && (r = c), (s === void 0 || a.latest > s) && (s = a.latest);
4281
+ }
4282
+ if (r === void 0 || s === void 0 || s - r <= t) break;
4283
+ const o = this.#e.shift();
4284
+ if (!o) break;
4285
+ this.#t = this.#e[0]?.consumer.sequence, console.warn(`skipping slow group: ${o.consumer.sequence} -> ${this.#t}`), o.consumer.close(), o.frames.length = 0, n = !0;
4279
4286
  }
4280
- t === void 0 || r === void 0 || r - t < A.Time.Micro.fromMilli(this.#r.peek()) || (this.#t !== void 0 && n.consumer.sequence <= this.#t && (this.#e.shift(), this.#t = this.#e[0]?.consumer.sequence, console.warn(`skipping slow group: ${n.consumer.sequence} < ${this.#t}`), n.consumer.close(), n.frames.length = 0), this.#u(), this.#s?.(), this.#s = void 0);
4287
+ n && (this.#u(), this.#s?.(), this.#s = void 0);
4281
4288
  }
4282
4289
  // Returns the next frame in order, along with the group number.
4283
4290
  // If frame is undefined, the group is done.
@@ -4287,7 +4294,8 @@ class le {
4287
4294
  const t = this.#e[0].frames.shift();
4288
4295
  if (t)
4289
4296
  return this.#u(), { frame: t, group: this.#e[0].consumer.sequence };
4290
- if (this.#t > this.#e[0].consumer.sequence) {
4297
+ if (this.#t > this.#e[0].consumer.sequence || this.#e[0].done) {
4298
+ this.#e[0].consumer.sequence === this.#t && (this.#t += 1);
4291
4299
  const r = this.#e.shift();
4292
4300
  if (r)
4293
4301
  return this.#u(), { frame: void 0, group: r.consumer.sequence };
@@ -4311,11 +4319,12 @@ class le {
4311
4319
  }
4312
4320
  #u() {
4313
4321
  const n = [];
4314
- for (const t of this.#e) {
4315
- const r = t.frames.at(0);
4316
- if (!r || !t.latest) continue;
4317
- const s = A.Time.Milli.fromMicro(r.timestamp), i = A.Time.Milli.fromMicro(t.latest), o = n.at(-1);
4318
- o && o.end >= s ? o.end = A.Time.Milli.max(o.end, i) : n.push({ start: s, end: i });
4322
+ let t;
4323
+ for (const r of this.#e) {
4324
+ const s = r.frames.at(0);
4325
+ if (!s || r.latest === void 0) continue;
4326
+ const i = A.Time.Milli.fromMicro(s.timestamp), o = A.Time.Milli.fromMicro(r.latest), a = n.at(-1), c = t?.done && t.consumer.sequence + 1 === r.consumer.sequence;
4327
+ a && (a.end >= i || c) ? a.end = A.Time.Milli.max(a.end, o) : n.push({ start: i, end: o }), t = r;
4319
4328
  }
4320
4329
  this.#i.set(n);
4321
4330
  }
@@ -4329,7 +4338,7 @@ class le {
4329
4338
  navigator.userAgent.toLowerCase().includes("chrome");
4330
4339
  navigator.userAgent.toLowerCase().includes("firefox");
4331
4340
  let xe;
4332
- async function Un() {
4341
+ async function Rn() {
4333
4342
  return globalThis.AudioEncoder && globalThis.AudioDecoder ? !0 : (xe || (console.warn("using Opus polyfill; performance may be degraded"), xe = Promise.all([
4334
4343
  import("./libav-opus-af-BlMWboA7.js"),
4335
4344
  import("./main-DGBFe0O7.js")
@@ -4606,7 +4615,7 @@ var Effect = class _Effect {
4606
4615
  this.#scheduled = false;
4607
4616
  if (this.#fn) {
4608
4617
  this.#fn(this);
4609
- if (DEV && this.#unwatch.length === 0) {
4618
+ if (DEV && this.#dispose !== void 0 && this.#unwatch.length === 0 && this.#dispose.length === 0 && this.#async.length === 0) {
4610
4619
  console.warn("Effect did not subscribe to any signals; it will never rerun.", this.#stack);
4611
4620
  }
4612
4621
  }
@@ -4766,10 +4775,6 @@ var Effect = class _Effect {
4766
4775
  target.addEventListener(type, listener, options);
4767
4776
  this.cleanup(() => target.removeEventListener(type, listener, options));
4768
4777
  }
4769
- // Reschedule the effect to run again.
4770
- reload() {
4771
- this.#schedule();
4772
- }
4773
4778
  // Register a cleanup function.
4774
4779
  cleanup(fn) {
4775
4780
  if (this.#dispose === void 0) {
@@ -5184,6 +5189,11 @@ function setInt32(dst, v) {
5184
5189
  return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
5185
5190
  }
5186
5191
 
5192
+ // ../lite/src/util/error.ts
5193
+ function unreachable(value) {
5194
+ throw new Error(\`unreachable: \${value}\`);
5195
+ }
5196
+
5187
5197
  // ../../node_modules/.bun/async-mutex@0.5.0/node_modules/async-mutex/index.mjs
5188
5198
  var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
5189
5199
  var E_ALREADY_LOCKED = new Error("mutex already locked");
@@ -5727,8 +5737,7 @@ var Publish = class _Publish {
5727
5737
  await w.bool(this.forward);
5728
5738
  await w.u53(0);
5729
5739
  } else {
5730
- const _ = version;
5731
- throw new Error(\`unsupported version: \${_}\`);
5740
+ unreachable(version);
5732
5741
  }
5733
5742
  }
5734
5743
  async encode(w, version) {
@@ -5774,8 +5783,7 @@ var Publish = class _Publish {
5774
5783
  forward
5775
5784
  });
5776
5785
  } else {
5777
- const _ = version;
5778
- throw new Error(\`unsupported version: \${_}\`);
5786
+ unreachable(version);
5779
5787
  }
5780
5788
  }
5781
5789
  };
@@ -6147,8 +6155,7 @@ var ClientSetup = class _ClientSetup {
6147
6155
  }
6148
6156
  await this.parameters.encode(w, version);
6149
6157
  } else {
6150
- const _ = version;
6151
- throw new Error(\`unsupported version: \${_}\`);
6158
+ unreachable(version);
6152
6159
  }
6153
6160
  }
6154
6161
  async encode(w, version) {
@@ -6171,8 +6178,7 @@ var ClientSetup = class _ClientSetup {
6171
6178
  const parameters = await Parameters.decode(r, version);
6172
6179
  return new _ClientSetup({ versions: supportedVersions, parameters });
6173
6180
  } else {
6174
- const _ = version;
6175
- throw new Error(\`unsupported version: \${_}\`);
6181
+ unreachable(version);
6176
6182
  }
6177
6183
  }
6178
6184
  static async decode(r, version) {
@@ -6194,8 +6200,7 @@ var ServerSetup = class _ServerSetup {
6194
6200
  await w.u53(this.version);
6195
6201
  await this.parameters.encode(w, version);
6196
6202
  } else {
6197
- const _ = version;
6198
- throw new Error(\`unsupported version: \${_}\`);
6203
+ unreachable(version);
6199
6204
  }
6200
6205
  }
6201
6206
  async encode(w, version) {
@@ -6210,8 +6215,7 @@ var ServerSetup = class _ServerSetup {
6210
6215
  const parameters = await Parameters.decode(r, version);
6211
6216
  return new _ServerSetup({ version: selectedVersion, parameters });
6212
6217
  } else {
6213
- const _ = version;
6214
- throw new Error(\`unsupported version: \${_}\`);
6218
+ unreachable(version);
6215
6219
  }
6216
6220
  }
6217
6221
  static async decode(r, version) {
@@ -6256,8 +6260,7 @@ var Subscribe = class _Subscribe {
6256
6260
  await w.u53(2);
6257
6261
  await w.u53(0);
6258
6262
  } else {
6259
- const _ = version;
6260
- throw new Error(\`unsupported version: \${_}\`);
6263
+ unreachable(version);
6261
6264
  }
6262
6265
  }
6263
6266
  async encode(w, version) {
@@ -6309,8 +6312,7 @@ var Subscribe = class _Subscribe {
6309
6312
  await Parameters.decode(r, version);
6310
6313
  return new _Subscribe({ requestId, trackNamespace, trackName, subscriberPriority });
6311
6314
  } else {
6312
- const _ = version;
6313
- throw new Error(\`unsupported version: \${_}\`);
6315
+ unreachable(version);
6314
6316
  }
6315
6317
  }
6316
6318
  };
@@ -6335,8 +6337,7 @@ var SubscribeOk = class _SubscribeOk {
6335
6337
  await w.bool(false);
6336
6338
  await w.u53(0);
6337
6339
  } else {
6338
- const _ = version;
6339
- throw new Error(\`unsupported version: \${_}\`);
6340
+ unreachable(version);
6340
6341
  }
6341
6342
  }
6342
6343
  async encode(w, version) {
@@ -6363,8 +6364,7 @@ var SubscribeOk = class _SubscribeOk {
6363
6364
  }
6364
6365
  await Parameters.decode(r, version);
6365
6366
  } else {
6366
- const _ = version;
6367
- throw new Error(\`unsupported version: \${_}\`);
6367
+ unreachable(version);
6368
6368
  }
6369
6369
  return new _SubscribeOk({ requestId, trackAlias });
6370
6370
  }
@@ -7029,30 +7029,37 @@ let Ec = class {
7029
7029
  const o = i.get(s.buffered), a = i.get(this.#o);
7030
7030
  this.#a.update(() => Oc(o, a));
7031
7031
  }), n.spawn(async () => {
7032
- if (!await Un()) return;
7033
- const o = new AudioDecoder({
7034
- output: (c) => this.#f(c),
7035
- error: (c) => console.error(c)
7032
+ if (!await Rn()) return;
7033
+ let o = 0;
7034
+ const a = new AudioDecoder({
7035
+ output: (u) => {
7036
+ if (o++, o <= 3) {
7037
+ u.close();
7038
+ return;
7039
+ }
7040
+ this.#f(u);
7041
+ },
7042
+ error: (u) => console.error(u)
7036
7043
  });
7037
- n.cleanup(() => o.close());
7038
- const a = r.description ? L(r.description) : void 0;
7039
- for (o.configure({
7044
+ n.cleanup(() => a.close());
7045
+ const c = r.description ? L(r.description) : void 0;
7046
+ for (a.configure({
7040
7047
  ...r,
7041
- description: a
7048
+ description: c
7042
7049
  }); ; ) {
7043
- const c = await s.next();
7044
- if (!c) break;
7045
- const { frame: u } = c;
7046
- if (!u) continue;
7047
- this.#t.update((f) => ({
7048
- bytesReceived: (f?.bytesReceived ?? 0) + u.data.byteLength
7050
+ const u = await s.next();
7051
+ if (!u) break;
7052
+ const { frame: d } = u;
7053
+ if (!d) continue;
7054
+ this.#t.update((p) => ({
7055
+ bytesReceived: (p?.bytesReceived ?? 0) + d.data.byteLength
7049
7056
  }));
7050
- const d = new EncodedAudioChunk({
7051
- type: u.keyframe ? "key" : "delta",
7052
- data: u.data,
7053
- timestamp: u.timestamp
7057
+ const f = new EncodedAudioChunk({
7058
+ type: d.keyframe ? "key" : "delta",
7059
+ data: d.data,
7060
+ timestamp: d.timestamp
7054
7061
  });
7055
- o.decode(d);
7062
+ a.decode(f);
7056
7063
  }
7057
7064
  });
7058
7065
  }
@@ -7063,7 +7070,7 @@ let Ec = class {
7063
7070
  const a = o.get(this.#o);
7064
7071
  this.#a.update(() => a);
7065
7072
  }), n.spawn(async () => {
7066
- if (!await Un()) return;
7073
+ if (!await Rn()) return;
7067
7074
  const a = new AudioDecoder({
7068
7075
  output: (c) => this.#f(c),
7069
7076
  error: (c) => console.error(c)
@@ -7192,8 +7199,8 @@ class Ac {
7192
7199
  const s = r.get(this.source.root);
7193
7200
  if (!s) return;
7194
7201
  const i = new GainNode(s.context, { gain: r.get(this.volume) });
7195
- s.connect(i), r.set(this.#e, i), r.run(() => {
7196
- r.get(this.source.enabled) && (i.connect(s.context.destination), r.cleanup(() => i.disconnect()));
7202
+ s.connect(i), r.set(this.#e, i), r.run((o) => {
7203
+ o.get(this.source.enabled) && (i.connect(s.context.destination), o.cleanup(() => i.disconnect()));
7197
7204
  });
7198
7205
  }), this.#n.run((r) => {
7199
7206
  const s = r.get(this.#e);
@@ -7276,7 +7283,7 @@ class Ot {
7276
7283
  this.#e.close();
7277
7284
  }
7278
7285
  }
7279
- const Kc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7286
+ const eu = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
7280
7287
  __proto__: null,
7281
7288
  Muxer: Ot
7282
7289
  }, Symbol.toStringTag, { value: "Module" }));
@@ -7334,7 +7341,7 @@ class Pc {
7334
7341
  this.signals.close();
7335
7342
  }
7336
7343
  }
7337
- const Rc = 500, Uc = 100;
7344
+ const Uc = 500, Rc = 100;
7338
7345
  class Nc {
7339
7346
  enabled;
7340
7347
  // Don't download any longer
@@ -7363,7 +7370,10 @@ class Nc {
7363
7370
  }
7364
7371
  #c(n) {
7365
7372
  const t = n.getAll([this.enabled, this.source.broadcast, this.source.track, this.source.config]);
7366
- if (!t) return;
7373
+ if (!t) {
7374
+ this.#n.set(void 0);
7375
+ return;
7376
+ }
7367
7377
  const [r, s, i, o] = t, a = n.get(s.active);
7368
7378
  if (!a) return;
7369
7379
  let c = new Mc({
@@ -7378,14 +7388,21 @@ class Nc {
7378
7388
  const d = u.get(this.#n);
7379
7389
  if (d) {
7380
7390
  const f = u.get(c.timestamp), p = u.get(d.timestamp);
7381
- if (!f || p && p > f + Uc) return;
7391
+ if (!f || p && p > f + Rc) return;
7382
7392
  }
7383
- this.#n.set(c), c = void 0;
7393
+ this.#n.set(c), c = void 0, u.close();
7384
7394
  });
7385
7395
  }
7386
7396
  #d(n) {
7387
7397
  const t = n.get(this.#n);
7388
- t && (n.cleanup(() => t.close()), n.proxy(this.#r, t.frame), n.proxy(this.#e, t.timestamp), n.proxy(this.#o, t.buffered));
7398
+ if (!t) {
7399
+ this.#o.set([]);
7400
+ return;
7401
+ }
7402
+ n.cleanup(() => t.close()), n.run((r) => {
7403
+ const s = r.get(t.frame);
7404
+ this.#r.update((i) => (i?.close(), s?.clone()));
7405
+ }), n.proxy(this.#e, t.timestamp), n.proxy(this.#o, t.buffered);
7389
7406
  }
7390
7407
  #l(n) {
7391
7408
  const t = n.get(this.source.catalog);
@@ -7412,7 +7429,7 @@ class Nc {
7412
7429
  }
7413
7430
  this.#s.set(!1), n.timer(() => {
7414
7431
  this.#s.set(!0);
7415
- }, Rc);
7432
+ }, Uc);
7416
7433
  }
7417
7434
  close() {
7418
7435
  this.#r.update((n) => {
@@ -7753,17 +7770,20 @@ class qc {
7753
7770
  #s(n) {
7754
7771
  const t = n.get(this.canvas);
7755
7772
  if (!t || n.get(this.paused)) return;
7756
- const s = new IntersectionObserver(
7757
- (i) => {
7758
- for (const o of i)
7759
- this.decoder.enabled.set(o.isIntersecting);
7773
+ let s = !1;
7774
+ const i = new IntersectionObserver(
7775
+ (a) => {
7776
+ for (const c of a)
7777
+ s = c.isIntersecting, this.decoder.enabled.set(s && !document.hidden);
7760
7778
  },
7761
7779
  {
7762
7780
  // fire when even a small part is visible
7763
7781
  threshold: 0.01
7764
7782
  }
7765
- );
7766
- n.cleanup(() => this.decoder.enabled.set(!1)), s.observe(t), n.cleanup(() => s.disconnect());
7783
+ ), o = () => {
7784
+ this.decoder.enabled.set(s && !document.hidden);
7785
+ };
7786
+ document.addEventListener("visibilitychange", o), n.cleanup(() => document.removeEventListener("visibilitychange", o)), n.cleanup(() => this.decoder.enabled.set(!1)), i.observe(t), n.cleanup(() => i.disconnect());
7767
7787
  }
7768
7788
  #i(n) {
7769
7789
  const t = n.get(this.#r);
@@ -7789,7 +7809,38 @@ class qc {
7789
7809
  this.#n?.close(), this.#n = void 0, this.#e.close();
7790
7810
  }
7791
7811
  }
7792
- let Zc = class {
7812
+ function Zc(e) {
7813
+ return (n) => {
7814
+ const t = [], r = [];
7815
+ for (const [s, i] of n)
7816
+ if (i.codedWidth && i.codedHeight) {
7817
+ const o = i.codedWidth * i.codedHeight;
7818
+ o <= e ? t.push({ name: s, size: o }) : r.push({ name: s, size: o });
7819
+ }
7820
+ return t.sort((s, i) => i.size - s.size), t.length > 0 ? t.map((s) => s.name) : r.length > 0 ? (r.sort((s, i) => s.size - i.size), [r[0].name]) : n.map(([s]) => s);
7821
+ };
7822
+ }
7823
+ function Fc(e) {
7824
+ return (n) => {
7825
+ const t = [], r = [];
7826
+ for (const [s, i] of n)
7827
+ i.bitrate != null && i.bitrate <= e ? t.push({ name: s, bitrate: i.bitrate }) : i.bitrate != null && r.push({ name: s, bitrate: i.bitrate });
7828
+ return t.sort((s, i) => i.bitrate - s.bitrate), t.length > 0 ? t.map((s) => s.name) : r.length > 0 ? (r.sort((s, i) => s.bitrate - i.bitrate), [r[0].name]) : n.map(([s]) => s);
7829
+ };
7830
+ }
7831
+ function Bc(e) {
7832
+ let n = e[0];
7833
+ for (const t of e) {
7834
+ const [, r] = t, [, s] = n, i = (r.codedWidth ?? 0) * (r.codedHeight ?? 0), o = (s.codedWidth ?? 0) * (s.codedHeight ?? 0);
7835
+ if (i !== o) {
7836
+ i > o && (n = t);
7837
+ continue;
7838
+ }
7839
+ (r.bitrate ?? 0) > (s.bitrate ?? 0) && (n = t);
7840
+ }
7841
+ return n[0];
7842
+ }
7843
+ let jc = class {
7793
7844
  broadcast;
7794
7845
  target;
7795
7846
  #n = new h(void 0);
@@ -7833,21 +7884,24 @@ let Zc = class {
7833
7884
  n.set(this.#e, i), n.set(this.#t, o), n.set(this.sync.video, o.jitter);
7834
7885
  }
7835
7886
  /**
7836
- * Select the best rendition based on target pixel count.
7837
- * Rounds up to the closest larger rendition, or falls back to the largest smaller one.
7887
+ * Select the best rendition using a generic filter system.
7888
+ *
7889
+ * Each enabled filter returns matching renditions sorted by preference.
7890
+ * The first rendition present in every filter's output is selected.
7891
+ * If no rendition satisfies all filters, a warning is logged.
7838
7892
  */
7839
7893
  #c(n, t) {
7840
7894
  const r = Object.entries(n);
7841
7895
  if (r.length === 0) return;
7842
7896
  if (r.length === 1) return r[0][0];
7843
- const s = t?.pixels ?? Number.MAX_SAFE_INTEGER / 2 - 1;
7844
- let i, o, a, c;
7845
- for (const [u, d] of r) {
7846
- if (!d.codedHeight || !d.codedWidth) continue;
7847
- const f = d.codedHeight * d.codedWidth;
7848
- f > s && (!o || f < o) ? (i = u, o = f) : f < s && (!c || f > c) && (a = u, c = f);
7849
- }
7850
- return i || a || (console.warn("no width/height information, choosing the first supported rendition"), r[0][0]);
7897
+ const s = [];
7898
+ if (t?.pixels != null && s.push(Zc(t.pixels)), t?.bitrate != null && s.push(Fc(t.bitrate)), s.length === 0)
7899
+ return Bc(r);
7900
+ const i = s.map((a) => a(r)), o = i.map((a) => new Set(a));
7901
+ for (const a of i[0])
7902
+ if (o.every((c) => c.has(a)))
7903
+ return a;
7904
+ console.warn("conflicting rendition filters, no rendition satisfies all criteria");
7851
7905
  }
7852
7906
  close() {
7853
7907
  this.#s.close();
@@ -7861,7 +7915,7 @@ function At(e) {
7861
7915
  }
7862
7916
  return n;
7863
7917
  }
7864
- class Fc {
7918
+ class Vc {
7865
7919
  // The source of the video.
7866
7920
  source;
7867
7921
  // The stats of the video.
@@ -7876,7 +7930,7 @@ class Fc {
7876
7930
  this.source = n;
7877
7931
  }
7878
7932
  }
7879
- class Bc {
7933
+ class Lc {
7880
7934
  source;
7881
7935
  // The volume of the audio, between 0 and 1.
7882
7936
  volume = new h(0.5);
@@ -7890,7 +7944,7 @@ class Bc {
7890
7944
  this.source = n;
7891
7945
  }
7892
7946
  }
7893
- class eu {
7947
+ class ru {
7894
7948
  element = new h(void 0);
7895
7949
  broadcast;
7896
7950
  jitter;
@@ -7903,11 +7957,11 @@ class eu {
7903
7957
  #e;
7904
7958
  signals = new C();
7905
7959
  constructor(n) {
7906
- this.element = h.from(n?.element), this.broadcast = h.from(n?.broadcast), this.jitter = h.from(n?.jitter ?? 100), this.#e = new Pc({ jitter: this.jitter }), this.#n = new Zc(this.#e, {
7960
+ this.element = h.from(n?.element), this.broadcast = h.from(n?.broadcast), this.jitter = h.from(n?.jitter ?? 100), this.#e = new Pc({ jitter: this.jitter }), this.#n = new jc(this.#e, {
7907
7961
  broadcast: this.broadcast
7908
- }), this.#r = new Lc(this.#e, {
7962
+ }), this.#r = new Wc(this.#e, {
7909
7963
  broadcast: this.broadcast
7910
- }), this.video = new Fc(this.#n), this.audio = new Bc(this.#r), this.paused = h.from(n?.paused ?? !1), this.signals.run(this.#t.bind(this));
7964
+ }), this.video = new Vc(this.#n), this.audio = new Lc(this.#r), this.paused = h.from(n?.paused ?? !1), this.signals.run(this.#t.bind(this));
7911
7965
  }
7912
7966
  #t(n) {
7913
7967
  const t = n.get(this.element);
@@ -7927,7 +7981,7 @@ class eu {
7927
7981
  const r = new Ot(this.#e, {
7928
7982
  paused: this.paused,
7929
7983
  element: t
7930
- }), s = new Cc(r, this.#n), i = new jc(r, this.#r, {
7984
+ }), s = new Cc(r, this.#n), i = new Gc(r, this.#r, {
7931
7985
  volume: this.audio.volume,
7932
7986
  muted: this.audio.muted
7933
7987
  });
@@ -7939,7 +7993,7 @@ class eu {
7939
7993
  this.signals.close();
7940
7994
  }
7941
7995
  }
7942
- class jc {
7996
+ class Gc {
7943
7997
  muxer;
7944
7998
  source;
7945
7999
  volume;
@@ -7950,7 +8004,7 @@ class jc {
7950
8004
  buffered = this.#r;
7951
8005
  #e = new C();
7952
8006
  constructor(n, t, r) {
7953
- this.muxer = n, this.source = t, this.source.supported.set(Vc), this.volume = h.from(r?.volume ?? 0.5), this.muted = h.from(r?.muted ?? !1), this.#e.run(this.#t.bind(this)), this.#e.run(this.#a.bind(this));
8007
+ this.muxer = n, this.source = t, this.source.supported.set(Jc), this.volume = h.from(r?.volume ?? 0.5), this.muted = h.from(r?.muted ?? !1), this.#e.run(this.#t.bind(this)), this.#e.run(this.#a.bind(this));
7954
8008
  }
7955
8009
  #t(n) {
7956
8010
  const t = n.get(this.muxer.element);
@@ -7986,7 +8040,7 @@ class jc {
7986
8040
  if (r.container.kind !== "cmaf") throw new Error("unreachable");
7987
8041
  const o = r.container.timescale;
7988
8042
  n.spawn(async () => {
7989
- const a = Rn(r);
8043
+ const a = Un(r);
7990
8044
  for (await this.#s(s, a); ; ) {
7991
8045
  const c = await t.readFrame();
7992
8046
  if (!c) return;
@@ -8000,7 +8054,7 @@ class jc {
8000
8054
  latency: this.source.sync.latency
8001
8055
  });
8002
8056
  n.cleanup(() => o.close()), n.spawn(async () => {
8003
- const a = Rn(r);
8057
+ const a = Un(r);
8004
8058
  await this.#s(s, a);
8005
8059
  let c = 1, u, d;
8006
8060
  for (; ; ) {
@@ -8041,10 +8095,10 @@ class jc {
8041
8095
  this.#e.close();
8042
8096
  }
8043
8097
  }
8044
- async function Vc(e) {
8098
+ async function Jc(e) {
8045
8099
  return MediaSource.isTypeSupported(`audio/mp4; codecs="${e.codec}"`);
8046
8100
  }
8047
- class Lc {
8101
+ class Wc {
8048
8102
  broadcast;
8049
8103
  target;
8050
8104
  #n = new h(void 0);
@@ -8105,7 +8159,7 @@ class Lc {
8105
8159
  this.#s.close();
8106
8160
  }
8107
8161
  }
8108
- class nu {
8162
+ class su {
8109
8163
  connection;
8110
8164
  enabled;
8111
8165
  name;
@@ -8163,7 +8217,7 @@ class nu {
8163
8217
  async #o(n) {
8164
8218
  try {
8165
8219
  for (; ; ) {
8166
- const t = await Ua(n);
8220
+ const t = await Ra(n);
8167
8221
  if (!t) break;
8168
8222
  console.debug("received catalog", this.name.peek(), t), this.#r.set(t), this.status.set("live");
8169
8223
  }
@@ -8178,22 +8232,22 @@ class nu {
8178
8232
  }
8179
8233
  }
8180
8234
  export {
8181
- nu as B,
8235
+ su as B,
8182
8236
  Nc as D,
8183
8237
  Ac as E,
8184
8238
  Cc as M,
8185
8239
  ue as P,
8186
8240
  qc as R,
8187
- Zc as S,
8241
+ jc as S,
8188
8242
  Ec as a,
8189
- jc as b,
8190
- Lc as c,
8191
- Wc as d,
8243
+ Gc as b,
8244
+ Wc as c,
8245
+ Kc as d,
8192
8246
  ht as e,
8193
- Hc as f,
8194
- eu as g,
8247
+ Yc as f,
8248
+ ru as g,
8195
8249
  Pc as h,
8196
- Kc as m,
8250
+ eu as m,
8197
8251
  At as t
8198
8252
  };
8199
- //# sourceMappingURL=broadcast-DhcOJtcZ.js.map
8253
+ //# sourceMappingURL=broadcast-DFnI-aDr.js.map