@hadoku/watchparty-ui 0.45.27 → 0.45.28

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.
@@ -1,11 +1,11 @@
1
1
  import { jsx as d, jsxs as _, Fragment as Se } from "react/jsx-runtime";
2
- import Ke, { useState as $, useRef as P, useEffect as L, useCallback as U, useMemo as Ee, Component as Yr, useContext as Jt, createContext as Bn, useId as Xr, useEffectEvent as fe } from "react";
3
- import { k as Zr, M as es, m as ts, f as ns, a as rs, C as dt, g as Qt, i as ss, S as as, r as vt, d as E, e as ee, b as is, u as x, A as pt, c as os, h as tt, j as Dn, n as On, D as it, w as I, l as cs, o as ls, s as Hn, p as Un, q as jn, t as ds, L as us, v as fs, x as hs, y as qt, z as ps, B as ms, E as gs, F as bs, G as Gn, H as Yt, I as Wn, J as Kn, K as ys, N as vs, O as Ie, P as fn, T as Tt, Q as Ss, R as Vn, U as ws, V as xs, W as zn, X as Y, Y as Es, Z as Jn, _ as Qn, $ as Xe, a0 as Ms, a1 as ks, a2 as _s, a3 as As, a4 as Ts, a5 as hn, a6 as ze, a7 as Cs, a8 as pn, a9 as Is, aa as Rs, ab as mn, ac as Fs, ad as Ns, ae as Ls, af as $s, ag as Ps, ah as gn, ai as bn, aj as Bs, ak as qn, al as yn, am as Ds, an as gt, ao as Os, ap as Hs, aq as Us, ar as js, as as Gs, at as Ws, au as Ks, av as Vs, aw as zs, ax as Js } from "./index-DOW8Etk-.js";
2
+ import Ke, { useState as $, useRef as P, useEffect as L, useCallback as U, useMemo as Ee, Component as qr, useContext as Pn, createContext as Bn, useId as Yr, useEffectEvent as fe } from "react";
3
+ import { k as Xr, M as Zr, m as es, f as ts, a as ns, C as dt, g as Jt, i as rs, S as ss, r as vt, d as E, e as ee, b as as, u as x, A as pt, c as is, h as tt, j as Dn, n as On, D as it, w as C, l as os, o as cs, s as Hn, p as Un, q as jn, t as ls, L as ds, v as us, x as fs, y as Qt, z as hs, B as ps, E as ms, F as gs, G as Gn, H as qt, I as Wn, J as Kn, K as bs, N as ys, O as Ce, P as un, T as Tt, Q as vs, R as Vn, U as Ss, V as ws, W as zn, X as Y, Y as xs, Z as Jn, _ as Qn, $ as Xe, a0 as Es, a1 as Ms, a2 as ks, a3 as _s, a4 as As, a5 as fn, a6 as ze, a7 as Ts, a8 as hn, a9 as Is, aa as Cs, ab as pn, ac as Rs, ad as Fs, ae as Ns, af as Ls, ag as $s, ah as mn, ai as gn, aj as Ps, ak as qn, al as bn, am as Bs, an as gt, ao as Ds, ap as Os, aq as Hs, ar as Us, as as js, at as Gs, au as Ws, av as Ks, aw as Vs, ax as zs } from "./index-CXl-xAUD.js";
4
4
  import { createPortal as wt } from "react-dom";
5
- import { Icon as ut, THEMES as Qs, useHadokuThemeOptional as qs } from "@wolffm/themes";
6
- import { HadokuThemePicker as Ys, ConnectedSettings as Xs } from "@wolffm/task-ui-components";
7
- import { createRoot as Zs } from "react-dom/client";
8
- function ea(t) {
5
+ import { Icon as ut, THEMES as Js, useHadokuThemeOptional as Qs } from "@wolffm/themes";
6
+ import { HadokuThemePicker as qs, ConnectedSettings as Ys } from "@wolffm/task-ui-components";
7
+ import { createRoot as Xs } from "react-dom/client";
8
+ function Zs(t) {
9
9
  return t.kind === "file";
10
10
  }
11
11
  class Yn extends Error {
@@ -33,42 +33,42 @@ function yt(t) {
33
33
  return "Image upload failed";
34
34
  }
35
35
  }
36
- function ta(t) {
36
+ function ea(t) {
37
37
  return t instanceof dt ? yt(t.reason) : t instanceof Yn ? t.message : "Image upload failed";
38
38
  }
39
- function na(t) {
39
+ function ta(t) {
40
40
  const e = t.type.toLowerCase().split(";")[0].trim();
41
- return e && Zr(e) !== "image" ? yt("unsupported-type") : t.size > es.image ? yt("too-large") : t.size === 0 ? yt("invalid") : null;
41
+ return e && Xr(e) !== "image" ? yt("unsupported-type") : t.size > Zr.image ? yt("too-large") : t.size === 0 ? yt("invalid") : null;
42
+ }
43
+ function na(t) {
44
+ return ts(t);
42
45
  }
43
46
  function ra(t) {
44
47
  return ns(t);
45
48
  }
46
- function sa(t) {
47
- return rs(t);
48
- }
49
- async function aa(t) {
50
- const e = await ts(t);
49
+ async function sa(t) {
50
+ const e = await es(t);
51
51
  return { w: e?.width ?? 0, h: e?.height ?? 0 };
52
52
  }
53
- async function ia(t, e = {}) {
54
- const n = await Qt().upload(t, { signal: e.signal });
55
- if (!ss(n.key))
53
+ async function aa(t, e = {}) {
54
+ const n = await Jt().upload(t, { signal: e.signal });
55
+ if (!rs(n.key))
56
56
  throw new Yn("Image upload returned an unusable key");
57
57
  return { key: n.key, deduplicated: n.deduplicated === !0 };
58
58
  }
59
- async function oa(t, e = {}) {
59
+ async function ia(t, e = {}) {
60
60
  const n = [];
61
61
  for (const r of t) {
62
62
  if (r.kind === "remote") {
63
63
  n.push({ key: r.key, w: r.w, h: r.h, ...r.title ? { title: r.title } : {} });
64
64
  continue;
65
65
  }
66
- const { key: s } = await ia(r.file, e);
66
+ const { key: s } = await aa(r.file, e);
67
67
  n.push({ key: s, w: r.w, h: r.h });
68
68
  }
69
69
  return n;
70
70
  }
71
- function ca(t) {
71
+ function oa(t) {
72
72
  return {
73
73
  error: t instanceof Error ? t.message : String(t),
74
74
  name: t instanceof Error ? t.name : typeof t,
@@ -76,14 +76,14 @@ function ca(t) {
76
76
  status: t instanceof dt ? t.status : void 0
77
77
  };
78
78
  }
79
- function la(t) {
79
+ function ca(t) {
80
80
  const e = P(t);
81
81
  return L(() => {
82
82
  e.current = t;
83
83
  }), [e, `${t.cdnBase}|${t.uploadPath}`];
84
84
  }
85
- function da(t, e, n, r = {}) {
86
- const { limit: s, debounceMs: i = as } = r, [a, l] = la(t), [o, c] = $([]), [u, f] = $(null), [p, v] = $(!1), [g, h] = $(null), [y, w] = $(0), A = P(null);
85
+ function la(t, e, n, r = {}) {
86
+ const { limit: s, debounceMs: i = ss } = r, [a, l] = ca(t), [o, c] = $([]), [u, f] = $(null), [p, v] = $(!1), [g, h] = $(null), [y, w] = $(0), A = P(null);
87
87
  L(() => {
88
88
  w(0), f(null);
89
89
  }, [n, e]), L(() => {
@@ -100,7 +100,7 @@ function da(t, e, n, r = {}) {
100
100
  signal: b.signal
101
101
  });
102
102
  if (k) return;
103
- c((C) => m ? S.results : [...C, ...S.results]), f(S.next);
103
+ c((I) => m ? S.results : [...I, ...S.results]), f(S.next);
104
104
  } catch (S) {
105
105
  if (k || S instanceof Error && S.name === "AbortError") return;
106
106
  h(S instanceof dt ? S : new dt("unknown", String(S)));
@@ -127,17 +127,17 @@ function da(t, e, n, r = {}) {
127
127
  }, [p, u]);
128
128
  return { items: o, loading: p, error: g, hasMore: u !== null, loadMore: F };
129
129
  }
130
- const Gt = 240, je = 8, ua = 28, Xn = 240;
131
- function fa(t, e, n) {
130
+ const Gt = 240, je = 8, da = 28, Xn = 240;
131
+ function ua(t, e, n) {
132
132
  let r = e.left - Gt - je;
133
133
  r < je && (r = e.right + je), r = Math.min(r, n.width - Gt - je), r = Math.max(je, r);
134
- const s = Xn + ua;
134
+ const s = Xn + da;
135
135
  let i = t.top + t.height / 2 - s / 2;
136
136
  return i = Math.min(i, n.height - s - je), i = Math.max(je, i), { left: r, top: i };
137
137
  }
138
- const Zn = "/dataplatform/api/memes", ha = 120;
139
- function pa({ onClose: t, onPick: e, onUnavailable: n }) {
140
- const [r, s] = $(""), i = P(null), a = P(null), l = Qt(), { items: o, loading: c, error: u, hasMore: f, loadMore: p } = da(
138
+ const Zn = "/dataplatform/api/memes", fa = 120;
139
+ function ha({ onClose: t, onPick: e, onUnavailable: n }) {
140
+ const [r, s] = $(""), i = P(null), a = P(null), l = Jt(), { items: o, loading: c, error: u, hasMore: f, loadMore: p } = la(
141
141
  l,
142
142
  Zn,
143
143
  r.trim()
@@ -149,17 +149,17 @@ function pa({ onClose: t, onPick: e, onUnavailable: n }) {
149
149
  }, []), F = U(() => {
150
150
  A(), y(null);
151
151
  }, [A]), k = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(hover: hover)").matches, m = U(
152
- (b, S, C = !1) => {
152
+ (b, S, I = !1) => {
153
153
  const D = i.current;
154
154
  if (!D) return;
155
155
  const H = () => y({
156
156
  item: b,
157
- ...fa(S.getBoundingClientRect(), D.getBoundingClientRect(), {
157
+ ...ua(S.getBoundingClientRect(), D.getBoundingClientRect(), {
158
158
  width: window.innerWidth,
159
159
  height: window.innerHeight
160
160
  })
161
161
  });
162
- A(), C ? H() : w.current = window.setTimeout(H, ha);
162
+ A(), I ? H() : w.current = window.setTimeout(H, fa);
163
163
  },
164
164
  [A]
165
165
  );
@@ -168,10 +168,10 @@ function pa({ onClose: t, onPick: e, onUnavailable: n }) {
168
168
  }, [v, n]), L(() => {
169
169
  a.current?.focus();
170
170
  }, []), L(() => {
171
- const b = (C) => {
172
- C.key === "Escape" && (C.stopPropagation(), t());
173
- }, S = (C) => {
174
- i.current && !i.current.contains(C.target) && t();
171
+ const b = (I) => {
172
+ I.key === "Escape" && (I.stopPropagation(), t());
173
+ }, S = (I) => {
174
+ i.current && !i.current.contains(I.target) && t();
175
175
  };
176
176
  return document.addEventListener("keydown", b), document.addEventListener("mousedown", S), () => {
177
177
  document.removeEventListener("keydown", b), document.removeEventListener("mousedown", S);
@@ -228,11 +228,11 @@ function pa({ onClose: t, onPick: e, onUnavailable: n }) {
228
228
  onClick: () => T(b),
229
229
  title: b.title,
230
230
  "data-testid": "meme-result",
231
- onMouseEnter: (C) => {
232
- k && m(b, C.currentTarget);
231
+ onMouseEnter: (I) => {
232
+ k && m(b, I.currentTarget);
233
233
  },
234
234
  onMouseLeave: F,
235
- onFocus: (C) => m(b, C.currentTarget, !0),
235
+ onFocus: (I) => m(b, I.currentTarget, !0),
236
236
  onBlur: F,
237
237
  className: "group relative aspect-square overflow-hidden rounded border border-border-light bg-bg-alt focus:outline-none focus:border-primary hover:border-primary",
238
238
  children: /* @__PURE__ */ d(
@@ -302,12 +302,12 @@ function pa({ onClose: t, onPick: e, onUnavailable: n }) {
302
302
  );
303
303
  }
304
304
  function er({ open: t, ...e }) {
305
- return t ? /* @__PURE__ */ d(pa, { ...e }) : null;
305
+ return t ? /* @__PURE__ */ d(ha, { ...e }) : null;
306
306
  }
307
- function ma(t) {
307
+ function pa(t) {
308
308
  return typeof t == "object" && t !== null && typeof t.mount == "function";
309
309
  }
310
- function ga(t) {
310
+ function ma(t) {
311
311
  if (typeof t != "object" || t === null)
312
312
  return !1;
313
313
  const e = t;
@@ -317,7 +317,7 @@ const Wt = "watchparty:open-media-drawer";
317
317
  function tr(t) {
318
318
  E("navigation", `Select Media clicked (${t})`), window.dispatchEvent(new CustomEvent(Wt));
319
319
  }
320
- class nr extends Yr {
320
+ class nr extends qr {
321
321
  state = { hasError: !1 };
322
322
  static getDerivedStateFromError() {
323
323
  return { hasError: !0 };
@@ -348,11 +348,11 @@ function xt() {
348
348
  return n(), document.addEventListener("fullscreenchange", n), () => document.removeEventListener("fullscreenchange", n);
349
349
  }, []), t;
350
350
  }
351
- function Xt(t) {
351
+ function Yt(t) {
352
352
  return t.hasMedia && (t.chatCollapsed || t.isFullscreen);
353
353
  }
354
- function Zt(t) {
355
- return t.isLeader ? Xt(t) ? t.gameOverlay && !t.isFullscreen ? "room-corner" : "control-bar" : "chat-toolbar" : "none";
354
+ function Xt(t) {
355
+ return t.isLeader ? Yt(t) ? t.gameOverlay && !t.isFullscreen ? "room-corner" : "control-bar" : "chat-toolbar" : "none";
356
356
  }
357
357
  function rr(t) {
358
358
  return t.hasMedia ? t.gameOverlay && !t.isFullscreen ? "room-corner" : "control-bar" : "none";
@@ -363,11 +363,11 @@ function sr(t, e) {
363
363
  if (n.author === e && n.avatarUrl) return n.avatarUrl;
364
364
  }
365
365
  }
366
- const ar = Bn(!0);
367
- function ir() {
368
- const t = Jt(ar);
366
+ const ga = Bn(!0);
367
+ function ar() {
368
+ const t = Pn(ga);
369
369
  L(() => {
370
- t && is();
370
+ t && as();
371
371
  }, [t]);
372
372
  }
373
373
  function ba(t, e) {
@@ -376,11 +376,11 @@ function ba(t, e) {
376
376
  if (n.author === e && n.cosmetics) return JSON.stringify(n.cosmetics);
377
377
  return "";
378
378
  }
379
- function or(t) {
380
- const e = Jt(ar), n = x((r) => e ? ba(r.roster, t) : "");
381
- return Ee(() => n ? JSON.parse(n) : void 0, [n]);
379
+ function ir(t) {
380
+ const e = x((n) => ba(n.roster, t));
381
+ return Ee(() => e ? JSON.parse(e) : void 0, [e]);
382
382
  }
383
- function cr(t) {
383
+ function or(t) {
384
384
  return t ? { "--hc-base": t } : {};
385
385
  }
386
386
  const ft = Ke.memo(
@@ -401,7 +401,7 @@ function ya(t, e) {
401
401
  };
402
402
  }, [t, e]);
403
403
  }
404
- function lr({ sprite: t, url: e, alt: n, worn: r }) {
404
+ function cr({ sprite: t, url: e, alt: n, worn: r }) {
405
405
  return /* @__PURE__ */ _("span", { className: "hc-av", style: { "--hc-sz": "32px" }, children: [
406
406
  /* @__PURE__ */ d("span", { className: "hc-pic", children: /* @__PURE__ */ d(
407
407
  pt,
@@ -413,7 +413,7 @@ function lr({ sprite: t, url: e, alt: n, worn: r }) {
413
413
  fallback: /* @__PURE__ */ d("span", { className: "inline-block w-8 h-8 bg-bg-alt/50 rounded-full flex-shrink-0" })
414
414
  }
415
415
  ) }),
416
- r?.overlay && /* @__PURE__ */ d(ft, { html: os(r), style: { display: "contents" } })
416
+ r?.overlay && /* @__PURE__ */ d(ft, { html: is(r), style: { display: "contents" } })
417
417
  ] });
418
418
  }
419
419
  function va(t) {
@@ -421,7 +421,7 @@ function va(t) {
421
421
  }
422
422
  const Sa = Bn(null);
423
423
  function wa() {
424
- return Jt(Sa);
424
+ return Pn(Sa);
425
425
  }
426
426
  function xa({ src: t, title: e, onClose: n }) {
427
427
  L(() => {
@@ -469,11 +469,11 @@ function xa({ src: t, title: e, onClose: n }) {
469
469
  s
470
470
  ) : null;
471
471
  }
472
- const Ct = 240, Ea = 320;
472
+ const It = 240, Ea = 320;
473
473
  function Ma({ image: t }) {
474
474
  const [e, n] = $(!1), r = vt(t.key);
475
475
  if (!r) return null;
476
- const s = t.w > 0 && t.h > 0, i = s ? Math.min(1, Ea / t.w, Ct / t.h) : 1;
476
+ const s = t.w > 0 && t.h > 0, i = s ? Math.min(1, Ea / t.w, It / t.h) : 1;
477
477
  return /* @__PURE__ */ _(Se, { children: [
478
478
  /* @__PURE__ */ d(
479
479
  "a",
@@ -496,7 +496,7 @@ function Ma({ image: t }) {
496
496
  width: s ? Math.round(t.w * i) : void 0,
497
497
  height: s ? Math.round(t.h * i) : void 0,
498
498
  className: "rounded border border-border-light object-contain bg-bg-alt/30",
499
- style: s ? { aspectRatio: `${t.w} / ${t.h}`, maxWidth: "100%", maxHeight: Ct } : { maxWidth: "100%", maxHeight: Ct }
499
+ style: s ? { aspectRatio: `${t.w} / ${t.h}`, maxWidth: "100%", maxHeight: It } : { maxWidth: "100%", maxHeight: It }
500
500
  }
501
501
  )
502
502
  }
@@ -511,17 +511,17 @@ function Ma({ image: t }) {
511
511
  )
512
512
  ] });
513
513
  }
514
- function dr({ images: t }) {
514
+ function lr({ images: t }) {
515
515
  return t?.length ? /* @__PURE__ */ d("div", { className: "flex flex-wrap gap-1 mt-1", "data-testid": "chat-images", children: t.map((e, n) => /* @__PURE__ */ d(Ma, { image: e }, `${e.key}-${n}`)) }) : null;
516
516
  }
517
517
  function ka(t, e) {
518
518
  return t.author && e.author ? t.author === e.author : !!e.clientId && t.clientId === e.clientId;
519
519
  }
520
- function It(t) {
520
+ function Ct(t) {
521
521
  return new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
522
522
  }
523
523
  const _a = Ke.memo(function({ message: e }) {
524
- const n = x((u) => u.me.clientId), r = x((u) => u.me.clientId ? u.roster[u.me.clientId]?.author : void 0), s = ka(e, { clientId: n, author: r }), i = x((u) => sr(u.roster, e.author)), a = tt(e.sprite, i), l = or(e.isSystem ? void 0 : e.author), o = P(null);
524
+ const n = x((u) => u.me.clientId), r = x((u) => u.me.clientId ? u.roster[u.me.clientId]?.author : void 0), s = ka(e, { clientId: n, author: r }), i = x((u) => sr(u.roster, e.author)), a = tt(e.sprite, i), l = ir(e.isSystem ? void 0 : e.author), o = P(null);
525
525
  ya(o, !!l);
526
526
  const [c] = $(
527
527
  () => e.live && e.text ? Dn(e.text, l) : null
@@ -529,24 +529,24 @@ const _a = Ke.memo(function({ message: e }) {
529
529
  return e.isSystem && e.systemType === "recap" ? /* @__PURE__ */ d("div", { className: "px-2 py-1.5", children: /* @__PURE__ */ _("div", { className: "border-l-2 border-border-light pl-2.5 py-0.5", children: [
530
530
  /* @__PURE__ */ _("div", { className: "text-[10px] uppercase tracking-wide text-text-muted mb-0.5", children: [
531
531
  "Recap",
532
- /* @__PURE__ */ d("span", { className: "ml-1.5 normal-case tracking-normal opacity-60", children: It(e.ts) })
532
+ /* @__PURE__ */ d("span", { className: "ml-1.5 normal-case tracking-normal opacity-60", children: Ct(e.ts) })
533
533
  ] }),
534
534
  /* @__PURE__ */ d("p", { className: "text-[13px] text-text-secondary leading-relaxed whitespace-pre-wrap break-words", children: e.text })
535
535
  ] }) }) : e.isSystem ? /* @__PURE__ */ _("div", { className: "px-2 py-0.5 text-[11px] text-text-muted italic text-center leading-tight", children: [
536
536
  e.text,
537
- /* @__PURE__ */ d("span", { className: "ml-1 text-[10px] opacity-50", children: It(e.ts) })
538
- ] }) : /* @__PURE__ */ _("div", { ref: o, style: cr(a), className: `flex items-start gap-2 px-2 py-1 hover:bg-bg-card/20 ${s ? "bg-bg-card/30" : ""}`, children: [
539
- /* @__PURE__ */ d(lr, { sprite: e.sprite, url: i, alt: e.name, worn: l }),
537
+ /* @__PURE__ */ d("span", { className: "ml-1 text-[10px] opacity-50", children: Ct(e.ts) })
538
+ ] }) : /* @__PURE__ */ _("div", { ref: o, style: or(a), className: `flex items-start gap-2 px-2 py-1 hover:bg-bg-card/20 ${s ? "bg-bg-card/30" : ""}`, children: [
539
+ /* @__PURE__ */ d(cr, { sprite: e.sprite, url: i, alt: e.name, worn: l }),
540
540
  /* @__PURE__ */ _("div", { className: "flex-1 min-w-0 -mt-0.5", children: [
541
541
  l ? /* @__PURE__ */ d(ft, { html: On(e.name, l), className: "text-[13px]", style: { color: a } }) : /* @__PURE__ */ d("span", { className: "font-medium text-[13px]", style: { color: a }, children: e.name }),
542
- /* @__PURE__ */ d("span", { className: "text-[10px] text-text-muted opacity-60 ml-1.5", children: It(e.ts) }),
542
+ /* @__PURE__ */ d("span", { className: "text-[10px] text-text-muted opacity-60 ml-1.5", children: Ct(e.ts) }),
543
543
  e.text && (c ? /* @__PURE__ */ d(ft, { as: "p", html: c, className: "text-[13px] text-text break-words leading-snug m-0" }) : /* @__PURE__ */ d("p", { className: "text-[13px] text-text break-words leading-snug m-0", children: e.text })),
544
- /* @__PURE__ */ d(dr, { images: e.images })
544
+ /* @__PURE__ */ d(lr, { images: e.images })
545
545
  ] })
546
546
  ] });
547
547
  });
548
548
  function Aa() {
549
- ir();
549
+ ar();
550
550
  const t = x((s) => s.chat), e = P(null), n = P(!1), r = U(() => {
551
551
  const s = e.current;
552
552
  if (!s) return;
@@ -576,7 +576,7 @@ function Aa() {
576
576
  }
577
577
  );
578
578
  }
579
- const en = [
579
+ const Zt = [
580
580
  {
581
581
  name: "recap",
582
582
  description: "Summarise the previous episode of what is loaded",
@@ -602,7 +602,7 @@ function Ta(t) {
602
602
  const e = t.slice(et.length);
603
603
  return /\s/.test(e) ? null : e.toLowerCase();
604
604
  }
605
- function Ca(t, e = en) {
605
+ function Ia(t, e = Zt) {
606
606
  const n = t.toLowerCase();
607
607
  if (!n) return [...e].sort((s, i) => s.name.localeCompare(i.name));
608
608
  const r = [];
@@ -612,13 +612,13 @@ function Ca(t, e = en) {
612
612
  }
613
613
  return r.sort((s, i) => s.rank - i.rank || s.cmd.name.localeCompare(i.cmd.name)).map((s) => s.cmd);
614
614
  }
615
- function Ia(t) {
615
+ function Ca(t) {
616
616
  return `${et}${t.name} `;
617
617
  }
618
618
  function Rt(t, e) {
619
619
  return e <= 0 ? 0 : (t % e + e) % e;
620
620
  }
621
- function Ra(t, e = en) {
621
+ function Ra(t, e = Zt) {
622
622
  const n = t.trim();
623
623
  if (!n) return null;
624
624
  if (!n.startsWith(et)) return { kind: "chat", text: n };
@@ -670,7 +670,7 @@ function Na({
670
670
  }
671
671
  );
672
672
  }
673
- function ur({
673
+ function dr({
674
674
  pending: t,
675
675
  uploading: e,
676
676
  onRemove: n
@@ -697,24 +697,24 @@ function ur({
697
697
  )
698
698
  ] }, r.id)) }) : null;
699
699
  }
700
- function fr() {
700
+ function ur() {
701
701
  const [t, e] = $([]), [n, r] = $(!1), s = x((h) => h.pushToast), i = P(/* @__PURE__ */ new Set());
702
702
  L(() => () => {
703
703
  for (const h of i.current) URL.revokeObjectURL(h);
704
704
  i.current.clear();
705
705
  }, []);
706
706
  const a = U((h) => {
707
- ea(h) && (URL.revokeObjectURL(h.previewUrl), i.current.delete(h.previewUrl));
707
+ Zs(h) && (URL.revokeObjectURL(h.previewUrl), i.current.delete(h.previewUrl));
708
708
  }, []), l = U(async (h) => {
709
709
  if (!h.length) return;
710
710
  const y = [];
711
711
  for (const w of h) {
712
- const A = na(w);
712
+ const A = ta(w);
713
713
  if (A) {
714
714
  s("error", A);
715
715
  continue;
716
716
  }
717
- const { w: F, h: k } = await aa(w), m = URL.createObjectURL(w);
717
+ const { w: F, h: k } = await sa(w), m = URL.createObjectURL(w);
718
718
  i.current.add(m), y.push({
719
719
  kind: "file",
720
720
  id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
@@ -749,7 +749,7 @@ function fr() {
749
749
  w: h.width ?? 0,
750
750
  h: h.height ?? 0,
751
751
  title: h.title || void 0
752
- }]), Qt().catalogue(Zn).recordUse(h.key));
752
+ }]), Jt().catalogue(Zn).recordUse(h.key));
753
753
  }, [s]), c = U((h) => {
754
754
  e((y) => {
755
755
  const w = y.find((A) => A.id === h);
@@ -761,10 +761,10 @@ function fr() {
761
761
  return [];
762
762
  });
763
763
  }, [a]), f = U((h) => {
764
- const y = ra(h.clipboardData);
764
+ const y = na(h.clipboardData);
765
765
  y.length && (h.preventDefault(), l(y));
766
766
  }, [l]), p = U((h) => {
767
- const y = sa(h.dataTransfer);
767
+ const y = ra(h.dataTransfer);
768
768
  y.length && (h.preventDefault(), l(y));
769
769
  }, [l]), v = U((h) => {
770
770
  h.dataTransfer?.types?.includes("Files") && h.preventDefault();
@@ -772,9 +772,9 @@ function fr() {
772
772
  if (!t.length) return [];
773
773
  r(!0);
774
774
  try {
775
- return await oa(t);
775
+ return await ia(t);
776
776
  } catch (h) {
777
- return I("chat", "Image upload failed", ca(h)), s("error", ta(h)), null;
777
+ return C("chat", "Image upload failed", oa(h)), s("error", ea(h)), null;
778
778
  } finally {
779
779
  r(!1);
780
780
  }
@@ -792,10 +792,10 @@ function fr() {
792
792
  onDragOver: v
793
793
  };
794
794
  }
795
- const vn = jn, La = Un;
796
- function $a({ commands: t = en }) {
797
- const [e, n] = $(""), [r, s] = $(!1), [i, a] = $({ q: null, i: 0 }), [l, o] = $(!1), c = P(null), u = Xr(), [f, p] = $(!1), [v, g] = $(!1), h = fr(), y = x((N) => N.snapshot.mediaId), w = x((N) => N.pushToast), A = x((N) => N.setTierlistOpen), F = !!y, k = Ta(e), m = Ee(
798
- () => k === null ? [] : Ca(k, t),
795
+ const yn = jn, La = Un;
796
+ function $a({ commands: t = Zt }) {
797
+ const [e, n] = $(""), [r, s] = $(!1), [i, a] = $({ q: null, i: 0 }), [l, o] = $(!1), c = P(null), u = Yr(), [f, p] = $(!1), [v, g] = $(!1), h = ur(), y = x((N) => N.snapshot.mediaId), w = x((N) => N.pushToast), A = x((N) => N.setTierlistOpen), F = !!y, k = Ta(e), m = Ee(
798
+ () => k === null ? [] : Ia(k, t),
799
799
  [k, t]
800
800
  ), T = k !== null && !l && m.length > 0, R = i.q === k ? Rt(i.i, m.length) : 0, b = U(
801
801
  (N) => a({ q: k, i: N }),
@@ -811,16 +811,16 @@ function $a({ commands: t = en }) {
811
811
  w("info", t.map((W) => W.usage).join(" "));
812
812
  break;
813
813
  case "recap":
814
- ls();
814
+ cs();
815
815
  break;
816
816
  case "tierlist":
817
- cs(), A(!0);
817
+ os(), A(!0);
818
818
  break;
819
819
  default:
820
820
  w("info", `${N.usage} is not implemented yet.`);
821
821
  }
822
- }, [F, w, t, A]), C = U((N) => {
823
- n(Ia(N)), o(!1), c.current?.focus();
822
+ }, [F, w, t, A]), I = U((N) => {
823
+ n(Ca(N)), o(!1), c.current?.focus();
824
824
  }, []), D = U(async (N) => {
825
825
  if (N.preventDefault(), r || h.uploading) return;
826
826
  const O = Ra(e, t);
@@ -848,21 +848,21 @@ function $a({ commands: t = en }) {
848
848
  else if (N.key === "Tab") {
849
849
  N.preventDefault();
850
850
  const O = m[R];
851
- O && C(O);
851
+ O && I(O);
852
852
  } else if (N.key === "Enter") {
853
853
  N.preventDefault();
854
854
  const O = m[R];
855
- O && C(O);
855
+ O && I(O);
856
856
  }
857
857
  }
858
- }, [T, m, R, C, b]);
858
+ }, [T, m, R, I, b]);
859
859
  L(() => {
860
860
  const N = () => {
861
861
  document.hidden || !document.hasFocus() || (c.current?.focus(), c.current?.scrollIntoView({ block: "nearest" }));
862
862
  };
863
863
  return window.addEventListener("watchparty:focus-chat-input", N), () => window.removeEventListener("watchparty:focus-chat-input", N);
864
864
  }, []);
865
- const j = vn - e.length, V = j <= 100, X = T ? m[R] : void 0;
865
+ const j = yn - e.length, V = j <= 100, X = T ? m[R] : void 0;
866
866
  return /* @__PURE__ */ _(
867
867
  "form",
868
868
  {
@@ -874,7 +874,7 @@ function $a({ commands: t = en }) {
874
874
  onDragOver: h.onDragOver,
875
875
  className: "p-2 border-t border-border",
876
876
  children: [
877
- /* @__PURE__ */ d(ur, { pending: h.pending, uploading: h.uploading, onRemove: h.remove }),
877
+ /* @__PURE__ */ d(dr, { pending: h.pending, uploading: h.uploading, onRemove: h.remove }),
878
878
  /* @__PURE__ */ _("div", { className: "relative", children: [
879
879
  T && /* @__PURE__ */ d(
880
880
  Na,
@@ -882,7 +882,7 @@ function $a({ commands: t = en }) {
882
882
  commands: m,
883
883
  activeIndex: R,
884
884
  hasMedia: F,
885
- onPick: C,
885
+ onPick: I,
886
886
  onHover: b,
887
887
  listboxId: u
888
888
  }
@@ -910,7 +910,7 @@ function $a({ commands: t = en }) {
910
910
  n(N.target.value), o(!1);
911
911
  },
912
912
  onKeyDown: H,
913
- maxLength: vn,
913
+ maxLength: yn,
914
914
  placeholder: "Send a message",
915
915
  role: "combobox",
916
916
  "aria-expanded": T,
@@ -1018,25 +1018,25 @@ function nt() {
1018
1018
  return x((t) => !!t.snapshot.leaderId && t.snapshot.leaderId === t.me.clientId);
1019
1019
  }
1020
1020
  function Et() {
1021
- const t = x((n) => n.activeGameId), e = ds();
1021
+ const t = x((n) => n.activeGameId), e = ls();
1022
1022
  return t ? e.find((n) => n.id === t) ?? null : null;
1023
1023
  }
1024
- function tn() {
1024
+ function en() {
1025
1025
  return x((t) => Oa({
1026
1026
  leaderId: t.snapshot.leaderId,
1027
1027
  clientId: t.me.clientId,
1028
1028
  keyType: Wa(Ga(globalThis.location?.pathname), t.roomKeyType)
1029
1029
  }));
1030
1030
  }
1031
- function hr() {
1031
+ function fr() {
1032
1032
  return x((t) => t.readiness);
1033
1033
  }
1034
1034
  function Ka() {
1035
1035
  return x((t) => t.snapshot);
1036
1036
  }
1037
1037
  const Va = 3e4;
1038
- function pr() {
1039
- const t = hr(), [e, n] = $(!1), [r, s] = $({ mediaId: t.mediaId, ready: t.ready });
1038
+ function hr() {
1039
+ const t = fr(), [e, n] = $(!1), [r, s] = $({ mediaId: t.mediaId, ready: t.ready });
1040
1040
  return (r.mediaId !== t.mediaId || r.ready !== t.ready) && (s({ mediaId: t.mediaId, ready: t.ready }), n(!1)), L(() => {
1041
1041
  if (t.ready) return;
1042
1042
  const i = setTimeout(() => n(!0), Va);
@@ -1051,28 +1051,28 @@ function za({ draw: t }) {
1051
1051
  return t(n) ?? void 0;
1052
1052
  }, [t]), /* @__PURE__ */ d("div", { ref: e, "data-testid": "game-settings" });
1053
1053
  }
1054
- const Ja = qt(() => import("./AdminPanel-DwCWmVfW.js")), Qa = qt(() => import("./PlaylistPanel-DEEnr7Mj.js"));
1054
+ const Ja = Qt(() => import("./AdminPanel-CqJPu1ee.js")), Qa = Qt(() => import("./PlaylistPanel-Ck8PUq7r.js"));
1055
1055
  function qa() {
1056
- const t = x((p) => p.chatCollapsed), e = xt(), n = x((p) => p.sidebarTab), r = x((p) => p.setSidebarTab), s = x((p) => p.healthSnapshot?.clients.length ?? 0), i = x((p) => !!p.playlist), a = nt(), l = tn(), o = x((p) => p.gameSettings), c = x((p) => p.snapshot.mediaId), u = Et() !== null;
1057
- if (Xt({ hasMedia: !!c, chatCollapsed: t, isFullscreen: e }))
1056
+ const t = x((p) => p.chatCollapsed), e = xt(), n = x((p) => p.sidebarTab), r = x((p) => p.setSidebarTab), s = x((p) => p.healthSnapshot?.clients.length ?? 0), i = x((p) => !!p.playlist), a = nt(), l = en(), o = x((p) => p.gameSettings), c = x((p) => p.snapshot.mediaId), u = Et() !== null;
1057
+ if (Yt({ hasMedia: !!c, chatCollapsed: t, isFullscreen: e }))
1058
1058
  return null;
1059
1059
  const f = n === "health" && !a || n === "playlist" && !i ? "chat" : n;
1060
1060
  return /* @__PURE__ */ _("aside", { className: "w-80 self-stretch border-l border-border flex flex-col bg-bg relative z-10", children: [
1061
1061
  /* @__PURE__ */ _("div", { className: "chat-toolbar relative flex items-center gap-1 px-2 py-1.5 border-b border-border", children: [
1062
1062
  /* @__PURE__ */ d(
1063
- us,
1063
+ ds,
1064
1064
  {
1065
1065
  to: "/",
1066
1066
  className: "p-1.5 rounded text-text-secondary hover:text-white hover:bg-bg-alt transition-colors cursor-pointer",
1067
1067
  title: "Home",
1068
1068
  "aria-label": "Home",
1069
1069
  onClick: () => {
1070
- E("navigation", "Home button clicked (chat toolbar)"), fs();
1070
+ E("navigation", "Home button clicked (chat toolbar)"), us();
1071
1071
  },
1072
1072
  children: /* @__PURE__ */ d("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" }) })
1073
1073
  }
1074
1074
  ),
1075
- Zt({ isLeader: l, hasMedia: !!c, chatCollapsed: t, isFullscreen: e, gameOverlay: u }) === "chat-toolbar" && /* @__PURE__ */ d(
1075
+ Xt({ isLeader: l, hasMedia: !!c, chatCollapsed: t, isFullscreen: e, gameOverlay: u }) === "chat-toolbar" && /* @__PURE__ */ d(
1076
1076
  "button",
1077
1077
  {
1078
1078
  onClick: () => tr("chat toolbar"),
@@ -1082,9 +1082,9 @@ function qa() {
1082
1082
  children: /* @__PURE__ */ d("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M7 4v16M17 4v16M3 8h4m10 0h4M3 12h18M3 16h4m10 0h4M4 4h16a1 1 0 011 1v14a1 1 0 01-1 1H4a1 1 0 01-1-1V5a1 1 0 011-1z" }) })
1083
1083
  }
1084
1084
  ),
1085
- /* @__PURE__ */ d(Ys, {}),
1086
- /* @__PURE__ */ d(Xs, { onNameChange: (p) => {
1087
- p && x.getState().me.clientId && hs(p);
1085
+ /* @__PURE__ */ d(qs, {}),
1086
+ /* @__PURE__ */ d(Ys, { onNameChange: (p) => {
1087
+ p && x.getState().me.clientId && fs(p);
1088
1088
  }, children: o ? /* @__PURE__ */ d(za, { draw: o }) : null }),
1089
1089
  /* @__PURE__ */ d(Da, {})
1090
1090
  ] }),
@@ -1123,12 +1123,12 @@ function qa() {
1123
1123
  ] })
1124
1124
  ] });
1125
1125
  }
1126
- const Sn = (t) => typeof t == "string" && Qs.includes(t);
1126
+ const vn = (t) => typeof t == "string" && Js.includes(t);
1127
1127
  function Ya(t, e, n) {
1128
- return Sn(e) ? e : Sn(n) ? n : "dark";
1128
+ return vn(e) ? e : vn(n) ? n : "dark";
1129
1129
  }
1130
1130
  function Xa(t, e) {
1131
- if (!ps(t)) return null;
1131
+ if (!hs(t)) return null;
1132
1132
  const n = new URL(t, e);
1133
1133
  return n.origin === e ? n.href : null;
1134
1134
  }
@@ -1181,7 +1181,7 @@ function ei(t) {
1181
1181
  return;
1182
1182
  }
1183
1183
  if (r) return;
1184
- if (!ma(p)) {
1184
+ if (!pa(p)) {
1185
1185
  u("the game module does not export mount()");
1186
1186
  return;
1187
1187
  }
@@ -1193,7 +1193,7 @@ function ei(t) {
1193
1193
  u(`the game failed to start: ${Je(h)}`, h);
1194
1194
  return;
1195
1195
  }
1196
- if (!ga(g)) {
1196
+ if (!ma(g)) {
1197
1197
  u("the game's mount() did not return { unmount, update }");
1198
1198
  return;
1199
1199
  }
@@ -1223,13 +1223,13 @@ function ei(t) {
1223
1223
  }
1224
1224
  };
1225
1225
  }
1226
- function wn({ activity: t, roomKey: e, layer: n }) {
1227
- const r = P(null), s = P(null), [i, a] = $(null), [l, o] = $(!1), c = x((k) => k.snapshot.leaderId), u = x((k) => k.me.clientId), f = !!c && c === u, p = x((k) => k.name), v = qs()?.theme, g = Ya(void 0, v, ms().theme), h = Ee(() => ({
1226
+ function Sn({ activity: t, roomKey: e, layer: n }) {
1227
+ const r = P(null), s = P(null), [i, a] = $(null), [l, o] = $(!1), c = x((k) => k.snapshot.leaderId), u = x((k) => k.me.clientId), f = !!c && c === u, p = x((k) => k.name), v = Qs()?.theme, g = Ya(void 0, v, ps().theme), h = Ee(() => ({
1228
1228
  roomKey: e,
1229
1229
  identity: {
1230
1230
  // The registry userId — what RoomChrome's `userId` prop is.
1231
- userId: bs(),
1232
- userType: gs(),
1231
+ userId: gs(),
1232
+ userType: ms(),
1233
1233
  name: p || null
1234
1234
  },
1235
1235
  theme: g,
@@ -1238,9 +1238,9 @@ function wn({ activity: t, roomKey: e, layer: n }) {
1238
1238
  E("game", "bundle close", { gameId: t.id, isLeader: f, layer: n }), n !== "base" && (f ? Gn(null) : o(!0));
1239
1239
  }
1240
1240
  }), [e, p, g, f, t.id, n]), y = fe(() => h), w = fe((k, m) => {
1241
- I("game", "bundle failed", { gameId: t.id, message: k, cause: String(m) }), a(k);
1241
+ C("game", "bundle failed", { gameId: t.id, message: k, cause: String(m) }), a(k);
1242
1242
  }), A = fe((k, m) => {
1243
- I("game", "bundle settings failed", { gameId: t.id, message: k, cause: String(m) });
1243
+ C("game", "bundle settings failed", { gameId: t.id, message: k, cause: String(m) });
1244
1244
  });
1245
1245
  if (L(() => {
1246
1246
  const k = r.current, m = t.load;
@@ -1252,8 +1252,8 @@ function wn({ activity: t, roomKey: e, layer: n }) {
1252
1252
  ctx: y(),
1253
1253
  onError: w,
1254
1254
  onSettingsAvailable: n === "overlay" ? (S) => {
1255
- const C = x.getState().gameSettings;
1256
- S ? T(R) : C === R && T(null);
1255
+ const I = x.getState().gameSettings;
1256
+ S ? T(R) : I === R && T(null);
1257
1257
  } : void 0,
1258
1258
  onSettingsError: A
1259
1259
  });
@@ -1311,37 +1311,37 @@ function ni({ open: t, onClose: e, header: n, footer: r, children: s }) {
1311
1311
  function ri({ open: t, onClose: e }) {
1312
1312
  return /* @__PURE__ */ d(ni, { open: t, onClose: e, children: /* @__PURE__ */ d("div", { className: "px-4 py-3 text-xs text-text-muted", children: "Loading…" }) });
1313
1313
  }
1314
- const mr = 9e3, xn = 1500, si = {
1314
+ const pr = 9e3, wn = 1500, si = {
1315
1315
  classic: "[text-shadow:_-1px_-1px_0_#000,_1px_-1px_0_#000,_-1px_1px_0_#000,_1px_1px_0_#000,_0_-1px_0_#000,_0_1px_0_#000,_-1px_0_0_#000,_1px_0_0_#000]",
1316
1316
  cinema: "drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)]",
1317
1317
  minimal: "drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)] drop-shadow-[0_0_8px_rgba(0,0,0,0.7)]",
1318
1318
  contrast: "bg-black/70 px-2 py-0.5 rounded"
1319
1319
  };
1320
1320
  function ai({ message: t, age: e, ccStyle: n }) {
1321
- const r = mr - xn;
1321
+ const r = pr - wn;
1322
1322
  let s = 1;
1323
- e > r && (s = Math.max(0, 1 - (e - r) / xn));
1324
- const i = si[n], a = x((u) => sr(u.roster, t.author)), l = tt(t.sprite, a), o = or(t.isSystem ? void 0 : t.author), [c] = $(
1323
+ e > r && (s = Math.max(0, 1 - (e - r) / wn));
1324
+ const i = si[n], a = x((u) => sr(u.roster, t.author)), l = tt(t.sprite, a), o = ir(t.isSystem ? void 0 : t.author), [c] = $(
1325
1325
  () => t.live && t.text ? Dn(t.text, o) : null
1326
1326
  );
1327
1327
  return /* @__PURE__ */ _(
1328
1328
  "div",
1329
1329
  {
1330
1330
  className: `flex items-start gap-2 py-1 ${i}`,
1331
- style: { opacity: s, transition: "opacity 0.15s ease-out", ...cr(l) },
1331
+ style: { opacity: s, transition: "opacity 0.15s ease-out", ...or(l) },
1332
1332
  children: [
1333
- /* @__PURE__ */ d(lr, { sprite: t.sprite, url: a, worn: o }),
1333
+ /* @__PURE__ */ d(cr, { sprite: t.sprite, url: a, worn: o }),
1334
1334
  /* @__PURE__ */ _("div", { className: "min-w-0 flex-1", style: { WebkitTextStroke: "0.5px black", paintOrder: "stroke fill" }, children: [
1335
1335
  o ? /* @__PURE__ */ d(ft, { html: On(t.name, o), className: "text-sm mr-2", style: { color: l } }) : /* @__PURE__ */ d("span", { className: "font-medium text-sm mr-2", style: { color: l }, children: t.name }),
1336
1336
  c ? /* @__PURE__ */ d(ft, { html: c, className: "text-sm text-white break-words" }) : /* @__PURE__ */ d("span", { className: "text-sm text-white break-words", children: t.text }),
1337
- /* @__PURE__ */ d(dr, { images: t.images })
1337
+ /* @__PURE__ */ d(lr, { images: t.images })
1338
1338
  ] })
1339
1339
  ]
1340
1340
  }
1341
1341
  );
1342
1342
  }
1343
1343
  function ii() {
1344
- ir();
1344
+ ar();
1345
1345
  const t = x((f) => f.chat), e = x((f) => f.chatCollapsed), n = x((f) => f.floatingChatEnabled), r = x((f) => f.mediaPrefs.subtitleStyle), [s, i] = $(!1), [a, l] = $(() => Date.now());
1346
1346
  L(() => {
1347
1347
  const f = () => {
@@ -1357,7 +1357,7 @@ function ii() {
1357
1357
  return () => clearInterval(f);
1358
1358
  }, [o]);
1359
1359
  const c = n && (e || s), u = Ee(() => {
1360
- const f = a - mr;
1360
+ const f = a - pr;
1361
1361
  return t.filter((p) => !p.isSystem && p.ts > f).slice(-12);
1362
1362
  }, [t, a]);
1363
1363
  return !c || u.length === 0 ? null : /* @__PURE__ */ d(
@@ -1378,15 +1378,15 @@ function ii() {
1378
1378
  );
1379
1379
  }
1380
1380
  const oi = 2;
1381
- function gr(t) {
1382
- return t.duration_ms > 0 && t.duration_ms - t.playhead_ms <= Yt;
1381
+ function mr(t) {
1382
+ return t.duration_ms > 0 && t.duration_ms - t.playhead_ms <= qt;
1383
1383
  }
1384
- function br(t) {
1384
+ function gr(t) {
1385
1385
  const e = t.video_ready_state ?? -1;
1386
- return e < 0 ? !0 : !(e <= oi && t.buffered_ahead_ms > Yt);
1386
+ return e < 0 ? !0 : !(e <= oi && t.buffered_ahead_ms > qt);
1387
1387
  }
1388
1388
  function Ec(t) {
1389
- return t.playhead_ms === 0 && !t.is_buffering && t.buffered_ahead_ms === 0 ? "idle" : t.is_buffering ? "buffering" : gr(t) ? "healthy" : !br(t) || t.buffered_ahead_ms <= Wn ? "critical" : t.buffered_ahead_ms <= Yt ? "warning" : "healthy";
1389
+ return t.playhead_ms === 0 && !t.is_buffering && t.buffered_ahead_ms === 0 ? "idle" : t.is_buffering ? "buffering" : mr(t) ? "healthy" : !gr(t) || t.buffered_ahead_ms <= Wn ? "critical" : t.buffered_ahead_ms <= qt ? "warning" : "healthy";
1390
1390
  }
1391
1391
  const Mc = {
1392
1392
  idle: "Idle",
@@ -1396,7 +1396,7 @@ const Mc = {
1396
1396
  healthy: "Healthy"
1397
1397
  };
1398
1398
  let bt = null;
1399
- function yr() {
1399
+ function br() {
1400
1400
  if (bt) return bt;
1401
1401
  try {
1402
1402
  const t = window.AudioContext ?? window.webkitAudioContext;
@@ -1405,64 +1405,64 @@ function yr() {
1405
1405
  }
1406
1406
  return bt;
1407
1407
  }
1408
- function vr(t) {
1408
+ function yr(t) {
1409
1409
  t.state === "suspended" && t.resume().catch(() => {
1410
1410
  });
1411
1411
  }
1412
- function Sr(t, e, n, r) {
1412
+ function vr(t, e, n, r) {
1413
1413
  t.gain.setValueAtTime(0, e), t.gain.linearRampToValueAtTime(n, e + 5e-3), t.gain.exponentialRampToValueAtTime(1e-4, e + r);
1414
1414
  }
1415
1415
  function We(t, e, n = 0.15, r = 0) {
1416
- const s = yr();
1416
+ const s = br();
1417
1417
  if (!s) return;
1418
- vr(s);
1418
+ yr(s);
1419
1419
  const i = s.currentTime + r, a = s.createOscillator(), l = s.createGain();
1420
- a.type = "sine", a.frequency.value = t, Sr(l, i, n, e / 1e3), a.connect(l).connect(s.destination), a.start(i), a.stop(i + e / 1e3 + 0.05);
1420
+ a.type = "sine", a.frequency.value = t, vr(l, i, n, e / 1e3), a.connect(l).connect(s.destination), a.start(i), a.stop(i + e / 1e3 + 0.05);
1421
1421
  }
1422
1422
  function Ft(t, e, n, r, s = 0.15, i = 0) {
1423
- const a = yr();
1423
+ const a = br();
1424
1424
  if (!a) return;
1425
- vr(a);
1425
+ yr(a);
1426
1426
  const l = a.currentTime + i, o = a.createOscillator(), c = a.createOscillator(), u = a.createGain(), f = a.createGain();
1427
- o.type = "sine", o.frequency.value = t, c.type = "sine", c.frequency.value = e, u.gain.value = n * e, c.connect(u).connect(o.frequency), Sr(f, l, s, r / 1e3), o.connect(f).connect(a.destination), o.start(l), o.stop(l + r / 1e3 + 0.05), c.start(l), c.stop(l + r / 1e3 + 0.05);
1427
+ o.type = "sine", o.frequency.value = t, c.type = "sine", c.frequency.value = e, u.gain.value = n * e, c.connect(u).connect(o.frequency), vr(f, l, s, r / 1e3), o.connect(f).connect(a.destination), o.start(l), o.stop(l + r / 1e3 + 0.05), c.start(l), c.stop(l + r / 1e3 + 0.05);
1428
1428
  }
1429
- function wr() {
1429
+ function Sr() {
1430
1430
  We(700, 60, 0.14, 0), We(700, 60, 0.14, 0.1), We(932, 120, 0.17, 0.2);
1431
1431
  }
1432
- function xr() {
1432
+ function wr() {
1433
1433
  We(784, 45, 0.07, 0), We(1047, 60, 0.07, 0.045);
1434
1434
  }
1435
- function Er() {
1435
+ function xr() {
1436
1436
  We(659, 45, 0.06, 0), We(494, 70, 0.06, 0.045);
1437
1437
  }
1438
- function Mr() {
1438
+ function Er() {
1439
1439
  Ft(587, 1174, 3, 320, 0.12, 0), Ft(880, 1760, 3, 320, 0.12, 0.06), Ft(884, 1768, 3, 320, 0.08, 0.06);
1440
1440
  }
1441
1441
  Kn("__WP_SOUNDS__", {
1442
- start: wr,
1443
- finish: Mr,
1444
- on: xr,
1445
- off: Er
1442
+ start: Sr,
1443
+ finish: Er,
1444
+ on: wr,
1445
+ off: xr
1446
1446
  });
1447
- const En = { on: 0, off: 0 };
1447
+ const xn = { on: 0, off: 0 };
1448
1448
  function ci(t, e, n, r) {
1449
- if (!n || !r) return En;
1449
+ if (!n || !r) return xn;
1450
1450
  const s = new Set(t), i = new Set(e);
1451
1451
  let a = 0;
1452
1452
  for (const o of i) s.has(o) || a++;
1453
1453
  let l = 0;
1454
1454
  for (const o of s) i.has(o) || l++;
1455
- return a === 0 && l === 0 ? En : { on: a, off: l };
1455
+ return a === 0 && l === 0 ? xn : { on: a, off: l };
1456
1456
  }
1457
- const li = 1200, be = 52, St = 4, Kt = (be - St) / 2, Mn = 2 * Math.PI * Kt, $e = be - St * 2 - 4;
1457
+ const li = 1200, be = 52, St = 4, Kt = (be - St) / 2, En = 2 * Math.PI * Kt, $e = be - St * 2 - 4;
1458
1458
  function di(t) {
1459
- return gr(t) ? !0 : br(t) ? t.buffered_ahead_ms >= Ie : !1;
1459
+ return mr(t) ? !0 : gr(t) ? t.buffered_ahead_ms >= Ce : !1;
1460
1460
  }
1461
1461
  function ui(t) {
1462
1462
  return `hsl(${Math.round(t * 120)}, 90%, 55%)`;
1463
1463
  }
1464
1464
  function fi({ client: t, pictureUrl: e, fading: n, onFadeEnd: r }) {
1465
- const s = Math.min(1, t.buffered_ahead_ms / Ie), i = Mn * (1 - s), a = ui(s), l = tt(t.sprite_id, e);
1465
+ const s = Math.min(1, t.buffered_ahead_ms / Ce), i = En * (1 - s), a = ui(s), l = tt(t.sprite_id, e);
1466
1466
  return /* @__PURE__ */ _(
1467
1467
  "div",
1468
1468
  {
@@ -1504,7 +1504,7 @@ function fi({ client: t, pictureUrl: e, fading: n, onFadeEnd: r }) {
1504
1504
  stroke: a,
1505
1505
  strokeWidth: St,
1506
1506
  strokeLinecap: "round",
1507
- strokeDasharray: Mn,
1507
+ strokeDasharray: En,
1508
1508
  strokeDashoffset: i,
1509
1509
  style: { transition: "stroke-dashoffset 0.4s ease, stroke 0.4s ease" }
1510
1510
  }
@@ -1622,7 +1622,7 @@ function hi({ clientId: t, sprite: e, pictureUrl: n, name: r, isReady: s, isSelf
1622
1622
  );
1623
1623
  }
1624
1624
  const pi = { status: null, entries: [], completed: /* @__PURE__ */ new Set(), below: /* @__PURE__ */ new Set() };
1625
- function kn(t, e) {
1625
+ function Mn(t, e) {
1626
1626
  if (!e || e.clients.length === 0) return { ...t, status: e, entries: [] };
1627
1627
  const n = new Set(t.completed), r = new Set(t.below), s = [];
1628
1628
  for (const i of e.clients) {
@@ -1632,8 +1632,8 @@ function kn(t, e) {
1632
1632
  return { status: e, entries: s, completed: n, below: r };
1633
1633
  }
1634
1634
  function mi() {
1635
- const t = x((m) => m.bufferStatus), e = x((m) => m.readyCheck), n = x((m) => m.roster), r = x((m) => m.me.clientId), s = x((m) => m.snapshot.playing), i = nt(), [a, l] = $(() => kn(pi, t));
1636
- a.status !== t && l(kn(a, t));
1635
+ const t = x((m) => m.bufferStatus), e = x((m) => m.readyCheck), n = x((m) => m.roster), r = x((m) => m.me.clientId), s = x((m) => m.snapshot.playing), i = nt(), [a, l] = $(() => Mn(pi, t));
1636
+ a.status !== t && l(Mn(a, t));
1637
1637
  const o = a.entries, c = (m) => {
1638
1638
  l((T) => {
1639
1639
  const R = new Set(T.completed), b = new Set(T.below);
@@ -1641,9 +1641,9 @@ function mi() {
1641
1641
  });
1642
1642
  }, u = new Set(e.ready), f = Object.values(n), p = !!r && u.has(r), v = e.active && f.length > 0 && e.ready.length >= f.length, g = P(e.active), h = P(v);
1643
1643
  L(() => {
1644
- !g.current && e.active && wr(), g.current = e.active;
1644
+ !g.current && e.active && Sr(), g.current = e.active;
1645
1645
  }, [e.active]), L(() => {
1646
- !h.current && v && Mr(), h.current = v;
1646
+ !h.current && v && Er(), h.current = v;
1647
1647
  }, [v]);
1648
1648
  const y = P(e.ready), w = P(e.active);
1649
1649
  L(() => {
@@ -1653,7 +1653,7 @@ function mi() {
1653
1653
  w.current,
1654
1654
  e.active
1655
1655
  );
1656
- m > 0 && xr(), T > 0 && Er(), y.current = e.ready, w.current = e.active;
1656
+ m > 0 && wr(), T > 0 && xr(), y.current = e.ready, w.current = e.active;
1657
1657
  }, [e.ready, e.active]);
1658
1658
  const A = e.active, F = !A && o.length > 0, k = !A && !F && i && f.length > 0 && !s;
1659
1659
  return !A && !F && !k ? null : /* @__PURE__ */ _(Se, { children: [
@@ -1694,7 +1694,7 @@ function mi() {
1694
1694
  name: m.name || "Anon",
1695
1695
  isReady: u.has(m.clientId),
1696
1696
  isSelf: m.clientId === r,
1697
- onToggle: () => ys(!p)
1697
+ onToggle: () => bs(!p)
1698
1698
  },
1699
1699
  m.clientId
1700
1700
  )) })
@@ -1714,7 +1714,7 @@ function mi() {
1714
1714
  {
1715
1715
  type: "button",
1716
1716
  "data-testid": "start-ready-check",
1717
- onClick: () => vs(),
1717
+ onClick: () => ys(),
1718
1718
  className: "px-2.5 py-1 rounded bg-black/55 text-xs font-semibold tracking-wide hover:bg-black/75 transition-colors",
1719
1719
  style: { color: "#fff", pointerEvents: "auto" },
1720
1720
  title: "Ask everyone if they're ready",
@@ -1734,10 +1734,10 @@ const Vt = {
1734
1734
  D: "var(--color-tier-d)",
1735
1735
  F: "var(--color-tier-f)"
1736
1736
  }, Ge = "unranked";
1737
- function kr(t) {
1737
+ function Mr(t) {
1738
1738
  t?.complete && t.naturalWidth > 0 && (t.dataset.loaded = "true");
1739
1739
  }
1740
- function _n({
1740
+ function kn({
1741
1741
  entry: t,
1742
1742
  draggable: e,
1743
1743
  picked: n,
@@ -1769,7 +1769,7 @@ function _n({
1769
1769
  loading: "eager",
1770
1770
  decoding: "async",
1771
1771
  draggable: !1,
1772
- ref: kr,
1772
+ ref: Mr,
1773
1773
  onLoad: (i) => {
1774
1774
  i.currentTarget.dataset.loaded = "true";
1775
1775
  },
@@ -1844,9 +1844,9 @@ function bi({
1844
1844
  function yi() {
1845
1845
  const t = x((b) => b.tierlistOpen), e = x((b) => b.setTierlistOpen), n = x((b) => b.tierlist), r = x((b) => b.tierlistDraft), s = x((b) => b.tierlistSaving), i = x((b) => b.moveTierlistItem), [a, l] = $(null), [o, c] = $(null), [u, f] = $(null), [p, v] = $(null), [g, h] = $("mine");
1846
1846
  L(() => {
1847
- fn(!0);
1847
+ un(!0);
1848
1848
  }, []), L(() => {
1849
- t && fn(!0);
1849
+ t && un(!0);
1850
1850
  }, [t]), L(() => {
1851
1851
  if (!t) return;
1852
1852
  const b = (S) => {
@@ -1856,15 +1856,15 @@ function yi() {
1856
1856
  }, [t, e]);
1857
1857
  const y = Ee(() => new Map((n?.items ?? []).map((b) => [b.id, b])), [n]), w = Ee(() => {
1858
1858
  const b = { S: [], A: [], B: [], C: [], D: [], F: [], [Ge]: [] }, S = /* @__PURE__ */ new Set();
1859
- for (const C of Tt)
1860
- for (const D of r[C] ?? []) {
1859
+ for (const I of Tt)
1860
+ for (const D of r[I] ?? []) {
1861
1861
  const H = y.get(D);
1862
- H && (b[C].push(H), S.add(D));
1862
+ H && (b[I].push(H), S.add(D));
1863
1863
  }
1864
- for (const C of y.values()) S.has(C.id) || b[Ge].push(C);
1864
+ for (const I of y.values()) S.has(I.id) || b[Ge].push(I);
1865
1865
  return b;
1866
- }, [r, y]), A = (b, S, C) => {
1867
- const D = [...b.querySelectorAll("article[data-item-id]")].filter((j) => j.dataset.itemId !== C);
1866
+ }, [r, y]), A = (b, S, I) => {
1867
+ const D = [...b.querySelectorAll("article[data-item-id]")].filter((j) => j.dataset.itemId !== I);
1868
1868
  let H = 0;
1869
1869
  for (const j of D) {
1870
1870
  const V = j.getBoundingClientRect();
@@ -1878,14 +1878,14 @@ function yi() {
1878
1878
  onDragLeave: () => c((S) => S === b ? null : S),
1879
1879
  onDrop: (S) => {
1880
1880
  S.preventDefault(), c(null);
1881
- const C = S.dataTransfer.getData("text/plain");
1882
- C && i(C, b === Ge ? null : b, A(S.currentTarget, S.clientX, C));
1881
+ const I = S.dataTransfer.getData("text/plain");
1882
+ I && i(I, b === Ge ? null : b, A(S.currentTarget, S.clientX, I));
1883
1883
  },
1884
1884
  onClick: () => {
1885
1885
  a && (i(a, b === Ge ? null : b), l(null));
1886
1886
  }
1887
1887
  }), k = U(async () => {
1888
- await Ss(x.getState().tierlistDraft) && v(Date.now());
1888
+ await vs(x.getState().tierlistDraft) && v(Date.now());
1889
1889
  }, []);
1890
1890
  if (L(() => {
1891
1891
  if (p === null) return;
@@ -1951,12 +1951,12 @@ function yi() {
1951
1951
  ...F(b),
1952
1952
  className: `flex items-center gap-2 p-2 overflow-x-auto transition-colors ${o === b ? "bg-primary/15 ring-1 ring-inset ring-primary" : "bg-bg-card"}`,
1953
1953
  children: w[b].map((S) => /* @__PURE__ */ d(
1954
- _n,
1954
+ kn,
1955
1955
  {
1956
1956
  entry: S,
1957
1957
  draggable: !0,
1958
1958
  picked: a === S.id,
1959
- onPick: () => l((C) => C === S.id ? null : S.id),
1959
+ onPick: () => l((I) => I === S.id ? null : S.id),
1960
1960
  onDragStart: () => l(null)
1961
1961
  },
1962
1962
  S.id
@@ -1970,7 +1970,7 @@ function yi() {
1970
1970
  ...F(Ge),
1971
1971
  className: `flex items-center gap-2 p-2 overflow-x-auto min-h-[96px] border-t border-dashed border-border transition-colors ${o === Ge ? "bg-primary/15 ring-1 ring-inset ring-primary" : "bg-bg"}`,
1972
1972
  children: w[Ge].map((b) => /* @__PURE__ */ d(
1973
- _n,
1973
+ kn,
1974
1974
  {
1975
1975
  entry: b,
1976
1976
  draggable: !0,
@@ -1984,7 +1984,7 @@ function yi() {
1984
1984
  )
1985
1985
  ] }),
1986
1986
  R === "everyone" && n && /* @__PURE__ */ d(Se, { children: Tt.map((b) => {
1987
- const S = n.placed.filter((C) => C.tier === b);
1987
+ const S = n.placed.filter((I) => I.tier === b);
1988
1988
  return /* @__PURE__ */ _("div", { className: "grid grid-cols-[56px_1fr] border-b border-border/50 min-h-[86px]", children: [
1989
1989
  /* @__PURE__ */ d(
1990
1990
  "div",
@@ -1994,27 +1994,27 @@ function yi() {
1994
1994
  children: /* @__PURE__ */ d("span", { className: "text-2xl font-bold leading-none", children: b })
1995
1995
  }
1996
1996
  ),
1997
- /* @__PURE__ */ d("div", { className: "flex items-stretch gap-2 p-2 overflow-x-auto bg-bg-card", children: S.map((C) => {
1998
- const D = y.get(C.mediaId);
1997
+ /* @__PURE__ */ d("div", { className: "flex items-stretch gap-2 p-2 overflow-x-auto bg-bg-card", children: S.map((I) => {
1998
+ const D = y.get(I.mediaId);
1999
1999
  return /* @__PURE__ */ _(
2000
2000
  "div",
2001
2001
  {
2002
2002
  tabIndex: 0,
2003
- onMouseEnter: (H) => f({ anchor: H.currentTarget.getBoundingClientRect(), itemId: C.mediaId }),
2003
+ onMouseEnter: (H) => f({ anchor: H.currentTarget.getBoundingClientRect(), itemId: I.mediaId }),
2004
2004
  onMouseLeave: () => f(null),
2005
- onFocus: (H) => f({ anchor: H.currentTarget.getBoundingClientRect(), itemId: C.mediaId }),
2005
+ onFocus: (H) => f({ anchor: H.currentTarget.getBoundingClientRect(), itemId: I.mediaId }),
2006
2006
  onBlur: () => f(null),
2007
- "aria-label": `${D?.displayName ?? C.mediaId} — score ${C.score.toFixed(2)}. ${Object.entries(C.votes).map(([H, j]) => `${n.names[H] ?? "viewer"} ${j}`).join(", ")}`,
2007
+ "aria-label": `${D?.displayName ?? I.mediaId} — score ${I.score.toFixed(2)}. ${Object.entries(I.votes).map(([H, j]) => `${n.names[H] ?? "viewer"} ${j}`).join(", ")}`,
2008
2008
  className: "w-[124px] shrink-0 rounded-md overflow-hidden bg-bg-alt border border-border hover:border-primary transition-colors",
2009
2009
  children: [
2010
2010
  /* @__PURE__ */ d(
2011
2011
  "img",
2012
2012
  {
2013
- src: Vn(C.mediaId, D?.thumbnail),
2013
+ src: Vn(I.mediaId, D?.thumbnail),
2014
2014
  alt: "",
2015
2015
  loading: "eager",
2016
2016
  decoding: "async",
2017
- ref: kr,
2017
+ ref: Mr,
2018
2018
  onLoad: (H) => {
2019
2019
  H.currentTarget.dataset.loaded = "true";
2020
2020
  },
@@ -2024,14 +2024,14 @@ function yi() {
2024
2024
  className: "tl-card-img w-full aspect-video object-cover bg-bg-card"
2025
2025
  }
2026
2026
  ),
2027
- /* @__PURE__ */ d("div", { className: "px-1.5 pt-1 text-[11px] leading-tight text-text-secondary line-clamp-2 min-h-[28px]", children: D?.displayName ?? C.mediaId }),
2027
+ /* @__PURE__ */ d("div", { className: "px-1.5 pt-1 text-[11px] leading-tight text-text-secondary line-clamp-2 min-h-[28px]", children: D?.displayName ?? I.mediaId }),
2028
2028
  /* @__PURE__ */ _("div", { className: "px-1.5 pb-1 flex items-center gap-1 text-[10px] tabular-nums text-text-muted", children: [
2029
2029
  /* @__PURE__ */ d("span", { children: "score" }),
2030
- /* @__PURE__ */ d("span", { className: "text-text-secondary", children: C.score.toFixed(2) })
2030
+ /* @__PURE__ */ d("span", { className: "text-text-secondary", children: I.score.toFixed(2) })
2031
2031
  ] })
2032
2032
  ]
2033
2033
  },
2034
- C.mediaId
2034
+ I.mediaId
2035
2035
  );
2036
2036
  }) })
2037
2037
  ] }, b);
@@ -2093,13 +2093,13 @@ function Ai({ className: t = "w-5 h-5" }) {
2093
2093
  function Ti({ className: t = "w-5 h-5" }) {
2094
2094
  return /* @__PURE__ */ d("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 5l7 7-7 7" }) });
2095
2095
  }
2096
- function Ci({ className: t = "w-4 h-4" }) {
2096
+ function Ii({ className: t = "w-4 h-4" }) {
2097
2097
  return /* @__PURE__ */ _("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
2098
2098
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 4v16" }),
2099
2099
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15 12l-5 4v-8l5 4z" })
2100
2100
  ] });
2101
2101
  }
2102
- function Ii({ className: t = "w-4 h-4" }) {
2102
+ function Ci({ className: t = "w-4 h-4" }) {
2103
2103
  return /* @__PURE__ */ _("svg", { className: t, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
2104
2104
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M20 4v16" }),
2105
2105
  /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 12l5 4v-8l-5 4z" })
@@ -2117,7 +2117,7 @@ function Fi({ className: t = "w-5 h-5" }) {
2117
2117
  function Ni({ className: t = "w-5 h-5" }) {
2118
2118
  return /* @__PURE__ */ d("svg", { className: t, fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ d("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M7 4v16M17 4v16M3 8h4m10 0h4M3 12h18M3 16h4m10 0h4M4 4h16a1 1 0 011 1v14a1 1 0 01-1 1H4a1 1 0 01-1-1V5a1 1 0 011-1z" }) });
2119
2119
  }
2120
- function _r({ site: t = "control bar", className: e = "ctr-btn" }) {
2120
+ function kr({ site: t = "control bar", className: e = "ctr-btn" }) {
2121
2121
  return /* @__PURE__ */ d(
2122
2122
  "button",
2123
2123
  {
@@ -2130,18 +2130,18 @@ function _r({ site: t = "control bar", className: e = "ctr-btn" }) {
2130
2130
  );
2131
2131
  }
2132
2132
  function Li() {
2133
- const t = x((a) => a.chatCollapsed), e = x((a) => a.toggleChatCollapsed), n = x((a) => !!a.snapshot.mediaId), r = xt(), s = Xt({ hasMedia: n, chatCollapsed: t, isFullscreen: r });
2133
+ const t = x((a) => a.chatCollapsed), e = x((a) => a.toggleChatCollapsed), n = x((a) => !!a.snapshot.mediaId), r = xt(), s = Yt({ hasMedia: n, chatCollapsed: t, isFullscreen: r });
2134
2134
  return { panelHidden: s, toggle: () => {
2135
2135
  if (E("chat", s ? "Show chat" : "Hide chat", { isFullscreen: r, chatCollapsed: t }), !s) {
2136
2136
  e();
2137
2137
  return;
2138
2138
  }
2139
2139
  t && e(), document.fullscreenElement && document.exitFullscreen().catch((a) => {
2140
- I("ui", "Exit fullscreen failed", { error: a?.message });
2140
+ C("ui", "Exit fullscreen failed", { error: a?.message });
2141
2141
  });
2142
2142
  } };
2143
2143
  }
2144
- function Ar({ className: t }) {
2144
+ function _r({ className: t }) {
2145
2145
  const { panelHidden: e, toggle: n } = Li(), r = e ? "Show chat" : "Hide chat";
2146
2146
  return /* @__PURE__ */ d(
2147
2147
  "button",
@@ -2152,12 +2152,12 @@ function Ar({ className: t }) {
2152
2152
  title: r,
2153
2153
  "aria-label": r,
2154
2154
  "aria-expanded": !e,
2155
- children: e ? /* @__PURE__ */ d(Ii, { className: "w-5 h-5" }) : /* @__PURE__ */ d(Ci, { className: "w-5 h-5" })
2155
+ children: e ? /* @__PURE__ */ d(Ci, { className: "w-5 h-5" }) : /* @__PURE__ */ d(Ii, { className: "w-5 h-5" })
2156
2156
  }
2157
2157
  );
2158
2158
  }
2159
2159
  function $i() {
2160
- const t = x((u) => u.chatCollapsed), e = x((u) => !!u.snapshot.mediaId), n = xt(), r = Et(), s = nt(), i = tn(), a = Zt({
2160
+ const t = x((u) => u.chatCollapsed), e = x((u) => !!u.snapshot.mediaId), n = xt(), r = Et(), s = nt(), i = en(), a = Xt({
2161
2161
  isLeader: i,
2162
2162
  hasMedia: e,
2163
2163
  chatCollapsed: t,
@@ -2165,30 +2165,30 @@ function $i() {
2165
2165
  gameOverlay: r !== null
2166
2166
  }) === "room-corner", l = s && r !== null && !n, o = rr({ hasMedia: e, isFullscreen: n, gameOverlay: r !== null }) === "room-corner";
2167
2167
  return !a && !l && !o ? null : /* @__PURE__ */ _("div", { className: "absolute top-2 right-2 z-40 flex items-center gap-2", "data-testid": "room-corner-controls", children: [
2168
- a && /* @__PURE__ */ d(_r, { site: "room corner", className: "corner-btn" }),
2168
+ a && /* @__PURE__ */ d(kr, { site: "room corner", className: "corner-btn" }),
2169
2169
  l && /* @__PURE__ */ d("button", { type: "button", onClick: () => {
2170
2170
  E("game", "game_select", { gameId: null, source: "room corner" }), Gn(null);
2171
2171
  }, className: "corner-btn", title: "Stop game", "aria-label": "Stop game", children: /* @__PURE__ */ d(Ri, {}) }),
2172
- o && /* @__PURE__ */ d(Ar, { className: "corner-btn" })
2172
+ o && /* @__PURE__ */ d(_r, { className: "corner-btn" })
2173
2173
  ] });
2174
2174
  }
2175
2175
  function Pi() {
2176
- L(() => ws((t) => {
2177
- const e = xs(t);
2176
+ L(() => Ss((t) => {
2177
+ const e = ws(t);
2178
2178
  E("avatar", "Avatar changed in the settings popout", { sprite: e, source: t.avatar?.source }), zn(e);
2179
2179
  }), []);
2180
2180
  }
2181
- const Tr = [];
2182
- function An(t) {
2183
- Tr.push(t);
2181
+ const Ar = [];
2182
+ function _n(t) {
2183
+ Ar.push(t);
2184
2184
  }
2185
2185
  function Qe() {
2186
- const t = Tr.splice(0);
2186
+ const t = Ar.splice(0);
2187
2187
  for (const e of t)
2188
2188
  try {
2189
2189
  e();
2190
2190
  } catch (n) {
2191
- I("audio", "audio-unlock callback threw", Y(n));
2191
+ C("audio", "audio-unlock callback threw", Y(n));
2192
2192
  }
2193
2193
  }
2194
2194
  let Nt = !1;
@@ -2203,7 +2203,7 @@ function Oi(t) {
2203
2203
  return t === "leader" || t === "viewer" ? t : null;
2204
2204
  }
2205
2205
  async function Hi(t) {
2206
- const e = Es(), n = await fetch(`${e}/api/rooms/validate/${encodeURIComponent(t)}`);
2206
+ const e = xs(), n = await fetch(`${e}/api/rooms/validate/${encodeURIComponent(t)}`);
2207
2207
  if (n.status === 404) return null;
2208
2208
  if (!n.ok) throw new Error(`validate returned ${n.status}`);
2209
2209
  const r = await n.json();
@@ -2220,7 +2220,7 @@ async function Ui(t) {
2220
2220
  await new Promise((r) => setTimeout(r, Di));
2221
2221
  continue;
2222
2222
  }
2223
- I("room", "Room key type probe failed, falling back to socket truth", Y(n));
2223
+ C("room", "Room key type probe failed, falling back to socket truth", Y(n));
2224
2224
  }
2225
2225
  }
2226
2226
  function Pe(t, e) {
@@ -2234,7 +2234,7 @@ function ji() {
2234
2234
  return Pe("home");
2235
2235
  }
2236
2236
  function Gi() {
2237
- const t = Ka(), e = hr(), n = nt(), r = pr(), s = n && r && !e.ready, i = !e.ready && !s;
2237
+ const t = Ka(), e = fr(), n = nt(), r = hr(), s = n && r && !e.ready, i = !e.ready && !s;
2238
2238
  return /* @__PURE__ */ d(
2239
2239
  "button",
2240
2240
  {
@@ -2242,14 +2242,14 @@ function Gi() {
2242
2242
  disabled: i || !n,
2243
2243
  onClick: () => {
2244
2244
  if (!n) {
2245
- I("controls", "Play/pause click blocked: not leader");
2245
+ C("controls", "Play/pause click blocked: not leader");
2246
2246
  return;
2247
2247
  }
2248
2248
  if (i) {
2249
- I("controls", "Play/pause click blocked: not ready", { readyCount: e.readyCount, total: e.total });
2249
+ C("controls", "Play/pause click blocked: not ready", { readyCount: e.readyCount, total: e.total });
2250
2250
  return;
2251
2251
  }
2252
- s && I("controls", "Play/pause: leader overriding stuck readiness gate", { readyCount: e.readyCount, total: e.total }), E("controls", "Play/pause clicked", { action: t.playing ? "pause" : "play" }), Pe(t.playing ? "pause" : "play");
2252
+ s && C("controls", "Play/pause: leader overriding stuck readiness gate", { readyCount: e.readyCount, total: e.total }), E("controls", "Play/pause clicked", { action: t.playing ? "pause" : "play" }), Pe(t.playing ? "pause" : "play");
2253
2253
  },
2254
2254
  className: "ctr-btn",
2255
2255
  title: s ? "Some viewers still loading — play anyway" : i ? "Waiting for sync..." : n ? t.playing ? "Pause" : "Play" : "Only the leader can control playback",
@@ -2287,24 +2287,24 @@ function Lt(t) {
2287
2287
  return n > 0 ? `${n}:${r.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}` : `${r}:${s.toString().padStart(2, "0")}`;
2288
2288
  }
2289
2289
  function Ji({ durationMs: t, displayPlayheadMs: e }) {
2290
- const n = x((S) => S.snapshot), r = x((S) => S.readiness), s = nt(), i = pr(), a = s && i && !r.ready, l = P(null), [o, c] = $(null), [u, f] = $(0), [p, v] = $(!1), [g, h] = $(null), y = P(0), [w, A] = $(n.mediaId);
2290
+ const n = x((S) => S.snapshot), r = x((S) => S.readiness), s = nt(), i = hr(), a = s && i && !r.ready, l = P(null), [o, c] = $(null), [u, f] = $(0), [p, v] = $(!1), [g, h] = $(null), y = P(0), [w, A] = $(n.mediaId);
2291
2291
  w !== n.mediaId && (A(n.mediaId), h(null), v(!1));
2292
2292
  const F = e ?? n.playheadMs;
2293
2293
  !p && g !== null && Math.abs(F - g) < Wn && h(null);
2294
2294
  const k = t || 0, m = Vi({ localValue: g, displayPlayheadMs: e, snapshotPlayheadMs: n.playheadMs }), T = P(0);
2295
2295
  L(() => {
2296
2296
  if (p || g === null) return;
2297
- const S = 1e4 - (Date.now() - T.current), C = setTimeout(() => {
2298
- I("seek", "SeekBar local override timed out — seek never completed", {
2297
+ const S = 1e4 - (Date.now() - T.current), I = setTimeout(() => {
2298
+ C("seek", "SeekBar local override timed out — seek never completed", {
2299
2299
  target: Math.round(g),
2300
2300
  actual: Math.round(F),
2301
2301
  delta: Math.round(Math.abs(F - g))
2302
2302
  }), h(null);
2303
2303
  }, Math.max(0, S));
2304
- return () => clearTimeout(C);
2304
+ return () => clearTimeout(I);
2305
2305
  }, [F, p, g]);
2306
2306
  const R = U((S) => {
2307
- const C = S.currentTarget.getBoundingClientRect(), D = S.clientX - C.left, H = D / C.width, j = Math.round(H * k);
2307
+ const I = S.currentTarget.getBoundingClientRect(), D = S.clientX - I.left, H = D / I.width, j = Math.round(H * k);
2308
2308
  c(D), f(Math.max(0, Math.min(j, k)));
2309
2309
  }, [k]), b = U(() => {
2310
2310
  c(null);
@@ -2322,8 +2322,8 @@ function Ji({ durationMs: t, displayPlayheadMs: e }) {
2322
2322
  disabled: Ki({ isLeader: s, ready: r.ready, canOverride: a, durationMs: k }),
2323
2323
  style: { "--progress": `${zi(m, k) * 100}%` },
2324
2324
  onChange: (S) => {
2325
- const C = Number(S.target.value);
2326
- h(C), T.current = Date.now();
2325
+ const I = Number(S.target.value);
2326
+ h(I), T.current = Date.now();
2327
2327
  },
2328
2328
  onMouseDown: () => {
2329
2329
  v(!0), y.current = e ?? n.playheadMs;
@@ -2498,7 +2498,7 @@ function eo({ videoRef: t }) {
2498
2498
  i?.requestFullscreen && await i.requestFullscreen();
2499
2499
  }
2500
2500
  } catch (i) {
2501
- I("ui", "Fullscreen toggle failed", { error: i?.message });
2501
+ C("ui", "Fullscreen toggle failed", { error: i?.message });
2502
2502
  }
2503
2503
  };
2504
2504
  return /* @__PURE__ */ d(
@@ -2532,18 +2532,18 @@ function to({
2532
2532
  onChatActivity: h,
2533
2533
  onMenuHeld: y
2534
2534
  }) {
2535
- const w = nt(), A = x((z) => z.chatCollapsed), F = xt(), k = tn(), m = Et() !== null, T = Zt({
2535
+ const w = nt(), A = x((z) => z.chatCollapsed), F = xt(), k = en(), m = Et() !== null, T = Xt({
2536
2536
  isLeader: k,
2537
2537
  hasMedia: !0,
2538
2538
  chatCollapsed: A,
2539
2539
  isFullscreen: F,
2540
2540
  gameOverlay: m
2541
- }) === "control-bar", R = rr({ hasMedia: !0, isFullscreen: F, gameOverlay: m }) === "control-bar", b = x((z) => z.floatingChatEnabled), S = P(null), C = P(null), [D, H] = $(!1), [j, V] = $(!1), [X, N] = $(""), [O, Q] = $(!1), W = fr(), [re, le] = $(!1), [Re, Ve] = $(!1), Mt = U(async (z) => {
2541
+ }) === "control-bar", R = rr({ hasMedia: !0, isFullscreen: F, gameOverlay: m }) === "control-bar", b = x((z) => z.floatingChatEnabled), S = P(null), I = P(null), [D, H] = $(!1), [j, V] = $(!1), [X, N] = $(""), [O, Q] = $(!1), W = ur(), [re, le] = $(!1), [Re, Ve] = $(!1), Mt = U(async (z) => {
2542
2542
  if (z.key !== "Enter") return;
2543
2543
  const he = X.trim();
2544
2544
  if (!he && !W.pending.length || O || W.uploading) return;
2545
2545
  const Me = await W.uploadPending();
2546
- Me !== null && (Hn(he, Me), N(""), W.clear(), Q(!0), setTimeout(() => Q(!1), Un), !document.hidden && document.hasFocus() && C.current?.focus());
2546
+ Me !== null && (Hn(he, Me), N(""), W.clear(), Q(!0), setTimeout(() => Q(!1), Un), !document.hidden && document.hasFocus() && I.current?.focus());
2547
2547
  }, [X, O, W]);
2548
2548
  L(() => () => y?.(!1), [e, y]);
2549
2549
  const Be = r ?? !0, ye = U(() => {
@@ -2589,7 +2589,7 @@ function to({
2589
2589
  /* @__PURE__ */ _("div", { ref: S, className: we, children: [
2590
2590
  w && /* @__PURE__ */ _("div", { className: "cluster", children: [
2591
2591
  /* @__PURE__ */ d(Gi, {}),
2592
- T && /* @__PURE__ */ d(_r, {}),
2592
+ T && /* @__PURE__ */ d(kr, {}),
2593
2593
  /* @__PURE__ */ d(Wi, {})
2594
2594
  ] }),
2595
2595
  /* @__PURE__ */ d("div", { className: "cluster-seek", children: /* @__PURE__ */ d(Ji, { durationMs: n, displayPlayheadMs: g }) }),
@@ -2636,7 +2636,7 @@ function to({
2636
2636
  onDrop: W.onDrop,
2637
2637
  onDragOver: W.onDragOver,
2638
2638
  children: [
2639
- /* @__PURE__ */ d(ur, { pending: W.pending, uploading: W.uploading, onRemove: W.remove }),
2639
+ /* @__PURE__ */ d(dr, { pending: W.pending, uploading: W.uploading, onRemove: W.remove }),
2640
2640
  /* @__PURE__ */ d(
2641
2641
  er,
2642
2642
  {
@@ -2651,7 +2651,7 @@ function to({
2651
2651
  /* @__PURE__ */ d(
2652
2652
  "input",
2653
2653
  {
2654
- ref: C,
2654
+ ref: I,
2655
2655
  type: "text",
2656
2656
  value: X,
2657
2657
  onChange: (z) => {
@@ -2682,7 +2682,7 @@ function to({
2682
2682
  }
2683
2683
  ),
2684
2684
  /* @__PURE__ */ _("div", { className: "cluster cluster-tight", children: [
2685
- R && /* @__PURE__ */ d(Ar, { className: "ctr-btn" }),
2685
+ R && /* @__PURE__ */ d(_r, { className: "ctr-btn" }),
2686
2686
  /* @__PURE__ */ d(eo, { videoRef: t })
2687
2687
  ] })
2688
2688
  ] }),
@@ -2726,7 +2726,7 @@ function io(t) {
2726
2726
  function oo(t, e, n) {
2727
2727
  return t.playheadMs + (t.playing ? Math.max(0, n - e) : 0);
2728
2728
  }
2729
- function Cr(t) {
2729
+ function Tr(t) {
2730
2730
  const e = t.split("/").filter(Boolean);
2731
2731
  return e.length >= 2 ? e.slice(-2).join(" ") : e[e.length - 1] || t;
2732
2732
  }
@@ -2735,7 +2735,7 @@ function co(t) {
2735
2735
  return e.length >= 2 && n.push(`${e.slice(0, -1).join("/")}/poster.jpg`), n;
2736
2736
  }
2737
2737
  function lo({ mediaId: t, visible: e }) {
2738
- return t ? /* @__PURE__ */ d("div", { className: `media-title ${e ? "show" : ""}`, children: Cr(t) }) : null;
2738
+ return t ? /* @__PURE__ */ d("div", { className: `media-title ${e ? "show" : ""}`, children: Tr(t) }) : null;
2739
2739
  }
2740
2740
  const qe = 3, uo = 1e3, fo = 15e3, Z = {
2741
2741
  EQUAL: 1e-3,
@@ -2747,8 +2747,8 @@ function ct(t, e = {}) {
2747
2747
  const { baseMs: n = uo, capMs: r = fo, jitter: s = 0.25 } = e, i = Math.min(n * Math.pow(2, t - 1), r), a = s > 0 ? Math.round(i * Math.random() * s) : 0;
2748
2748
  return i + a;
2749
2749
  }
2750
- const Tn = 15, ho = 35e3, po = 2e3, Bt = 10;
2751
- function Ce(t, e) {
2750
+ const An = 15, ho = 35e3, po = 2e3, Bt = 10;
2751
+ function Ie(t, e) {
2752
2752
  if (t.length === 0) return 0;
2753
2753
  if (e >= t[t.length - 1].end_ms) return t.length - 1;
2754
2754
  let n = 0, r = t.length - 1;
@@ -2758,8 +2758,8 @@ function Ce(t, e) {
2758
2758
  }
2759
2759
  return n;
2760
2760
  }
2761
- function nn(t, e) {
2762
- const n = Ce(t, e);
2761
+ function tn(t, e) {
2762
+ const n = Ie(t, e);
2763
2763
  if (t.length === 0 || t[0].keyframe === void 0) return n;
2764
2764
  for (let r = n; r >= 0; r--)
2765
2765
  if (t[r].keyframe) return r;
@@ -2792,7 +2792,7 @@ function ot(t) {
2792
2792
  const e = go / t * 1e3 * bo;
2793
2793
  return Math.max(3e4, Math.min(12e4, Math.round(e)));
2794
2794
  }
2795
- function Cn(t, e) {
2795
+ function Tn(t, e) {
2796
2796
  for (let n = e; n >= 0; n--)
2797
2797
  if (t[n]?.keyframe) return n;
2798
2798
  return -1;
@@ -2888,16 +2888,16 @@ function xo({ subtitleUrl: t, videoRef: e, style: n, enabled: r }) {
2888
2888
  if (!b.ok) throw new Error(`Failed to fetch subtitles (status ${b.status})`);
2889
2889
  const S = await b.text();
2890
2890
  if (m) return;
2891
- const C = vo(S);
2892
- i(C);
2891
+ const I = vo(S);
2892
+ i(I);
2893
2893
  return;
2894
2894
  } catch (b) {
2895
2895
  if (m) return;
2896
2896
  if (R < T) {
2897
2897
  const S = ct(R + 1, { baseMs: 1e3, capMs: 2e3, jitter: 0 });
2898
- I("subtitles", `Fetch failed, retrying in ${S}ms (attempt ${R + 1}/${T + 1})`, { error: b?.message }), await new Promise((C) => setTimeout(C, S));
2898
+ C("subtitles", `Fetch failed, retrying in ${S}ms (attempt ${R + 1}/${T + 1})`, { error: b?.message }), await new Promise((I) => setTimeout(I, S));
2899
2899
  } else
2900
- I("subtitles", "All fetch attempts failed", { error: b?.message }), i([]);
2900
+ C("subtitles", "All fetch attempts failed", { error: b?.message }), i([]);
2901
2901
  }
2902
2902
  }
2903
2903
  })().catch((R) => ee("subtitles", "Subtitle load threw", Y(R))), () => {
@@ -2928,7 +2928,7 @@ function xo({ subtitleUrl: t, videoRef: e, style: n, enabled: r }) {
2928
2928
  const m = e.current, T = o.current?.parentElement;
2929
2929
  if (!m || !T) return;
2930
2930
  const R = () => {
2931
- const b = T.clientHeight, S = T.clientWidth, C = m.videoWidth || 1920, D = m.videoHeight || 1080, H = Math.min(S / C, b / D), j = D * H, V = (b - j) / 2, X = Math.max(16, j * 0.035), N = Math.max(X * 0.8, j * 0.055);
2931
+ const b = T.clientHeight, S = T.clientWidth, I = m.videoWidth || 1920, D = m.videoHeight || 1080, H = Math.min(S / I, b / D), j = D * H, V = (b - j) / 2, X = Math.max(16, j * 0.035), N = Math.max(X * 0.8, j * 0.055);
2932
2932
  u(Math.max(V + N, 40)), p(X);
2933
2933
  };
2934
2934
  return R(), window.addEventListener("resize", R), m.addEventListener("loadedmetadata", R), () => {
@@ -3017,7 +3017,7 @@ function Ne(t) {
3017
3017
  function Le(t, e = Eo) {
3018
3018
  t.length > e && t.splice(0, t.length - e);
3019
3019
  }
3020
- class Co {
3020
+ class Io {
3021
3021
  // Fetch
3022
3022
  _fetches = [];
3023
3023
  _fetchTimeoutCount = 0;
@@ -3196,9 +3196,9 @@ class Co {
3196
3196
  this._fetches = [], this._fetchTimeoutCount = 0, this._fetchErrorCount = 0, this._appends = [], this._appendStarts.clear(), this._appendTimeouts = [], this._seeks = [], this._waitForSeekedTimeouts = 0, this._audioDrifts = [], this._stalls = [], this._stallStart = null, this._evictCounts = {}, this._evicts = [], this._browserEvictions = [];
3197
3197
  }
3198
3198
  }
3199
- const oe = new Co();
3199
+ const oe = new Io();
3200
3200
  Kn("__WP_PERF__", oe);
3201
- class Io {
3201
+ class Co {
3202
3202
  cache = /* @__PURE__ */ new Map();
3203
3203
  getOrCreate(e) {
3204
3204
  let n = this.cache.get(e);
@@ -3227,7 +3227,7 @@ class Io {
3227
3227
  if (n.length === 0) return 0;
3228
3228
  const r = this.cache.get(e);
3229
3229
  if (!r) return 0;
3230
- const s = nn(n, 0);
3230
+ const s = tn(n, 0);
3231
3231
  let i = 0;
3232
3232
  for (let a = s; a < n.length && r.fragments.has(a); a++)
3233
3233
  i = n[a].end_ms;
@@ -3237,7 +3237,7 @@ class Io {
3237
3237
  this.cache.clear();
3238
3238
  }
3239
3239
  }
3240
- const ve = new Io(), Rn = 60, Ro = 5e3;
3240
+ const ve = new Co(), Cn = 60, Ro = 5e3;
3241
3241
  class Fo {
3242
3242
  constructor(e) {
3243
3243
  this.deps = e;
@@ -3318,7 +3318,7 @@ class Fo {
3318
3318
  if (this.evictStartedAt === 0)
3319
3319
  return this.evictStartedAt = Date.now(), !0;
3320
3320
  const e = Date.now() - this.evictStartedAt;
3321
- return e < Ro ? !0 : (I("buffer", `EVICT-STUCK isEvicting held ${e}ms — clearing; a remove() updateend was lost, eviction was disabled`), oe.recordEvict("stuck-recovered", 0, 0), this._isEvicting = !1, this.evictStartedAt = 0, !1);
3321
+ return e < Ro ? !0 : (C("buffer", `EVICT-STUCK isEvicting held ${e}ms — clearing; a remove() updateend was lost, eviction was disabled`), oe.recordEvict("stuck-recovered", 0, 0), this._isEvicting = !1, this.evictStartedAt = 0, !1);
3322
3322
  }
3323
3323
  /** Called on dispose, on SourceBuffer error, and on media change
3324
3324
  * (FragmentManager.setIndex) — see the note at that call site. */
@@ -3361,8 +3361,8 @@ class Fo {
3361
3361
  const s = e / 1e3, i = n.buffered, a = this.deps.getPendingSeekTargetMs(), l = a === null ? null : a / 1e3;
3362
3362
  for (let o = 0; o < i.length; o++) {
3363
3363
  const c = i.start(o), u = i.end(o);
3364
- if (c < s - Rn && u > s) {
3365
- const y = s - Rn;
3364
+ if (c < s - Cn && u > s) {
3365
+ const y = s - Cn;
3366
3366
  E("buffer", `EVICT-START [behind-tail-trim] range=${c.toFixed(2)}-${u.toFixed(2)} → trim [${c.toFixed(2)}-${y.toFixed(2)}] playhead=${s.toFixed(2)}`), this._doEvict(c, y, "behind-tail-trim");
3367
3367
  return;
3368
3368
  }
@@ -3392,7 +3392,7 @@ class Fo {
3392
3392
  try {
3393
3393
  s.remove(e, n);
3394
3394
  } catch (a) {
3395
- this._isEvicting = !1, this.evictStartedAt = 0, I("buffer", `Eviction remove() failed: ${a.message}`);
3395
+ this._isEvicting = !1, this.evictStartedAt = 0, C("buffer", `Eviction remove() failed: ${a.message}`);
3396
3396
  }
3397
3397
  }
3398
3398
  }
@@ -3515,7 +3515,7 @@ class Ze {
3515
3515
  // timing, and APPEND-HOLD reason counts. Read by emitInitDigest() which warns
3516
3516
  // once at gate-pass time so the load shape is visible in session logs without
3517
3517
  // wp:reportLogs=true.
3518
- static INIT_TRACK_FRAGS = Ms;
3518
+ static INIT_TRACK_FRAGS = Es;
3519
3519
  loadStartTs = 0;
3520
3520
  initFetchStart = 0;
3521
3521
  initFetchEnd = 0;
@@ -3590,8 +3590,8 @@ class Ze {
3590
3590
  * `fragment-route.realmedia.test.ts`; this is the client-side backstop.
3591
3591
  */
3592
3592
  async tryFragmentRoute(e, n, r) {
3593
- if (this.fragmentRouteDisabled || !this.delivery || !ks()) return null;
3594
- const s = _s(this.delivery, e);
3593
+ if (this.fragmentRouteDisabled || !this.delivery || !Ms()) return null;
3594
+ const s = ks(this.delivery, e);
3595
3595
  if (!s)
3596
3596
  return this.disableFragmentRoute(e, "could not build a URL for this config"), null;
3597
3597
  try {
@@ -3609,7 +3609,7 @@ class Ze {
3609
3609
  }
3610
3610
  }
3611
3611
  disableFragmentRoute(e, n) {
3612
- this.fragmentRouteDisabled || (this.fragmentRouteDisabled = !0, I("buffer", "FRAG-ROUTE disabled, falling back to Range", {
3612
+ this.fragmentRouteDisabled || (this.fragmentRouteDisabled = !0, C("buffer", "FRAG-ROUTE disabled, falling back to Range", {
3613
3613
  target: String(e),
3614
3614
  reason: n,
3615
3615
  hitsBeforeFailure: this.fragmentRouteHits,
@@ -3675,7 +3675,7 @@ class Ze {
3675
3675
  );
3676
3676
  if (c) {
3677
3677
  if (this.initTtfbMs = c.ttfbMs, this.initCfStatus = c.cfStatus, l = c.buf, a()) {
3678
- I("buffer", "INIT-FETCH stale on completion, discarding bytes", {
3678
+ C("buffer", "INIT-FETCH stale on completion, discarding bytes", {
3679
3679
  expectedMediaId: r,
3680
3680
  currentMediaId: this.mediaId
3681
3681
  });
@@ -3692,7 +3692,7 @@ class Ze {
3692
3692
  throw await f.body?.cancel().catch(() => {
3693
3693
  }), new Error(`init expected 206, got ${f.status}`);
3694
3694
  if (l = await f.arrayBuffer(), a()) {
3695
- I("buffer", "INIT-FETCH stale on completion, discarding bytes", {
3695
+ C("buffer", "INIT-FETCH stale on completion, discarding bytes", {
3696
3696
  expectedMediaId: r,
3697
3697
  currentMediaId: this.mediaId
3698
3698
  });
@@ -3718,14 +3718,14 @@ class Ze {
3718
3718
  }
3719
3719
  this.initAppendDone = performance.now(), this.initState = "loaded", this.initRetryCount = 0, E("buffer", `INIT-LOADED sbRanges=[${ge(this.sourceBuffer?.buffered).join(", ")}]`), this.processAppendQueue();
3720
3720
  } catch (l) {
3721
- ee("buffer", "Init segment fetch/append failed", { error: l.message }), a() || (this.initState = "pending", this.initRetryCount += 1, this.initRetryCount >= As ? (this.initFailed = !0, I("buffer", "INIT-GIVE-UP — init segment failed repeatedly; rejecting waiters for fast recovery", {
3721
+ ee("buffer", "Init segment fetch/append failed", { error: l.message }), a() || (this.initState = "pending", this.initRetryCount += 1, this.initRetryCount >= _s ? (this.initFailed = !0, C("buffer", "INIT-GIVE-UP — init segment failed repeatedly; rejecting waiters for fast recovery", {
3722
3722
  attempts: this.initRetryCount,
3723
3723
  error: l.message
3724
3724
  }), this.rejectAllWaiters(new Error("init segment failed after repeated retries"))) : this.disposed || setTimeout(() => {
3725
3725
  !this.disposed && this.initState === "pending" && this.fetchInit().catch((o) => {
3726
3726
  ee("buffer", "INIT-RETRY failed", Y(o));
3727
3727
  });
3728
- }, Ts));
3728
+ }, As));
3729
3729
  }
3730
3730
  }
3731
3731
  /** Runs inside updateend after an append completes. Decides whether MSE
@@ -3777,7 +3777,7 @@ class Ze {
3777
3777
  }
3778
3778
  }
3779
3779
  const o = Math.min(8, a * 0.5);
3780
- l < o ? I("buffer", `EOS-SKIP — last frag appended but buffered span ${l.toFixed(2)}s < ${o.toFixed(2)}s threshold; mid-join, not end-of-clip ${JSON.stringify({
3780
+ l < o ? C("buffer", `EOS-SKIP — last frag appended but buffered span ${l.toFixed(2)}s < ${o.toFixed(2)}s threshold; mid-join, not end-of-clip ${JSON.stringify({
3781
3781
  appendedIdx: n,
3782
3782
  mediaDurationSec: a.toFixed(1),
3783
3783
  sbRanges: ge(e.buffered)
@@ -3787,7 +3787,7 @@ class Ze {
3787
3787
  const i = (this.discardCounts.get(n) ?? 0) + 1;
3788
3788
  this.discardCounts.set(n, i), this.fragmentStates.set(n, "pending");
3789
3789
  const a = this.fragments[n]?.keyframe;
3790
- I("buffer", `APPEND-DISCARDED #${n} (attempt ${i}, kf=${a ?? "n/a"}) not in SB after appendBuffer — ${a === !1 ? "non-keyframe fragment, needs preceding IDR in SB" : "keyframe-valid bytes refused — likely browser MSE eviction/pressure (overloaded host?)"}; sbRanges=[${ge(e.buffered).join(", ")}] queueLen=${this.appendQueue.length}`);
3790
+ C("buffer", `APPEND-DISCARDED #${n} (attempt ${i}, kf=${a ?? "n/a"}) not in SB after appendBuffer — ${a === !1 ? "non-keyframe fragment, needs preceding IDR in SB" : "keyframe-valid bytes refused — likely browser MSE eviction/pressure (overloaded host?)"}; sbRanges=[${ge(e.buffered).join(", ")}] queueLen=${this.appendQueue.length}`);
3791
3791
  }
3792
3792
  }
3793
3793
  /** Two-stage gap detection, runs on every updateend. A gap is worth warning
@@ -3820,7 +3820,7 @@ class Ze {
3820
3820
  return;
3821
3821
  }
3822
3822
  const i = r.join("|"), a = Date.now();
3823
- this.stableGapSignature !== i ? (this.stableGapSignature = i, this.stableGapSince = a) : a - this.stableGapSince >= hn && a - this.lastGapWarnMs > hn && (this.lastGapWarnMs = a, I("buffer", `SB has ${e.buffered.length} ranges with ${r.length} stable unfillable gap(s) ${JSON.stringify({
3823
+ this.stableGapSignature !== i ? (this.stableGapSignature = i, this.stableGapSince = a) : a - this.stableGapSince >= fn && a - this.lastGapWarnMs > fn && (this.lastGapWarnMs = a, C("buffer", `SB has ${e.buffered.length} ranges with ${r.length} stable unfillable gap(s) ${JSON.stringify({
3824
3824
  ranges: ge(e.buffered),
3825
3825
  unfillableGaps: r,
3826
3826
  stableForMs: a - this.stableGapSince,
@@ -3847,7 +3847,7 @@ class Ze {
3847
3847
  const r = n ?? ot(this.getAverageDownloadRate());
3848
3848
  return new Promise((s, i) => {
3849
3849
  const a = setTimeout(() => {
3850
- this.appendWaiters = this.appendWaiters.filter((l) => l.index !== e), oe.recordAppendTimeout(e, r, this.appendQueue.length), I("buffer", "waitForAppend timeout", {
3850
+ this.appendWaiters = this.appendWaiters.filter((l) => l.index !== e), oe.recordAppendTimeout(e, r, this.appendQueue.length), C("buffer", "waitForAppend timeout", {
3851
3851
  track: this.label,
3852
3852
  index: e,
3853
3853
  timeoutMs: r,
@@ -3971,7 +3971,7 @@ class Ze {
3971
3971
  }
3972
3972
  if (n.length === 0) return;
3973
3973
  const r = ge(e).join(", ") || "(none)";
3974
- oe.recordBrowserEviction(n.length, r), I("buffer", "BROWSER-EVICTION — browser silently evicted buffered fragments at its MSE memory quota", {
3974
+ oe.recordBrowserEviction(n.length, r), C("buffer", "BROWSER-EVICTION — browser silently evicted buffered fragments at its MSE memory quota", {
3975
3975
  failureMode: "browser dropped SourceBuffer data with no event; fragmentStates was stale. Uncaught, a seek into the evicted region sets currentTime onto absent data → waitForSeeked timeout → frozen player. Reconcile reset these to pending so the seek re-fetches.",
3976
3976
  evictedCount: n.length,
3977
3977
  evictedFragments: n.length <= 24 ? n.join(",") : `${n.slice(0, 24).join(",")}…+${n.length - 24}`,
@@ -3982,11 +3982,11 @@ class Ze {
3982
3982
  }
3983
3983
  resolveTarget(e) {
3984
3984
  this.reconcileLoadedStates();
3985
- const n = Ce(this.fragments, e);
3985
+ const n = Ie(this.fragments, e);
3986
3986
  if (this.isBuffered(e)) return { status: "buffered", fragmentIndex: n };
3987
3987
  const r = this.currentJobs.get(n);
3988
3988
  if (r) return { status: "loading", fragmentIndex: n, existingPromise: r.promise };
3989
- const s = Math.max(0, n - Tn), i = Math.min(this.fragments.length - 1, n + Tn);
3989
+ const s = Math.max(0, n - An), i = Math.min(this.fragments.length - 1, n + An);
3990
3990
  for (let a = s; a <= i; a++) {
3991
3991
  const l = this.fragmentStates.get(a);
3992
3992
  if (l === "loaded" || l === "loading") return { status: "nearby-pending", fragmentIndex: n };
@@ -4002,20 +4002,20 @@ class Ze {
4002
4002
  E("buffer", `ENSURE-SKIP — mediaSource.readyState=${this.mediaSource?.readyState ?? "null"}`);
4003
4003
  return;
4004
4004
  }
4005
- this.sourceBuffer.buffered.length > 1 && I("mse", "Buffer gaps detected during seek", { targetMs: e, ranges: ge(this.sourceBuffer?.buffered).join(", ") }), this.eviction.evictSeekGap(e), await this._fetchRange(e, { abort: !0, signal: r, caller: n });
4005
+ this.sourceBuffer.buffered.length > 1 && C("mse", "Buffer gaps detected during seek", { targetMs: e, ranges: ge(this.sourceBuffer?.buffered).join(", ") }), this.eviction.evictSeekGap(e), await this._fetchRange(e, { abort: !0, signal: r, caller: n });
4006
4006
  }
4007
4007
  }
4008
4008
  async _fetchRange(e, n) {
4009
4009
  if (this.disposed || !this.sourceBuffer || !this.fragments.length || this.hasDataAhead(e) || this.mediaSource?.readyState !== "open") return;
4010
4010
  const { abort: r = !1, minimal: s = !1, signal: i, caller: a = "unknown" } = n;
4011
4011
  r && this.abortAllJobs(a);
4012
- const l = Ce(this.fragments, e);
4012
+ const l = Ie(this.fragments, e);
4013
4013
  if (r) {
4014
- const h = Ce(this.fragments, e + Xe);
4014
+ const h = Ie(this.fragments, e + Xe);
4015
4015
  for (let y = l; y <= h; y++)
4016
4016
  this.discardCounts.delete(y), this.fetchErrorCycles.delete(y);
4017
4017
  }
4018
- const o = nn(this.fragments, e), c = this.fragments[o], u = c && this.sourceBuffer?.buffered && Dt(this.sourceBuffer.buffered, c.start_ms, c.end_ms), f = u ? l : o, p = s ? Math.min(this.fragments.length - 1, l + 1) : Ce(this.fragments, e + Ie);
4018
+ const o = tn(this.fragments, e), c = this.fragments[o], u = c && this.sourceBuffer?.buffered && Dt(this.sourceBuffer.buffered, c.start_ms, c.end_ms), f = u ? l : o, p = s ? Math.min(this.fragments.length - 1, l + 1) : Ie(this.fragments, e + Ce);
4019
4019
  this.initRange && this.initState !== "loaded" && await this.fetchInit();
4020
4020
  const v = [], g = [];
4021
4021
  for (let h = f; h <= p; h++) {
@@ -4078,7 +4078,7 @@ class Ze {
4078
4078
  continue;
4079
4079
  }
4080
4080
  l.push(this.fetchFragment(o).catch((c) => {
4081
- I("buffer", "Fragment fetch failed in batch", { index: o, error: c.message });
4081
+ C("buffer", "Fragment fetch failed in batch", { index: o, error: c.message });
4082
4082
  }));
4083
4083
  }
4084
4084
  E("buffer", `FETCH-BATCH [${s / n + 1}/${Math.ceil(r.length / n)}] launching=[${i.filter((o) => !a.some((c) => c.startsWith(`#${o}`))).join(",")}] skipped=[${a.join(",")}]`), l.length > 0 && await Promise.allSettled(l);
@@ -4179,9 +4179,9 @@ class Ze {
4179
4179
  }
4180
4180
  if ((c.name === "TimeoutError" || c.message?.includes("signal timed out") || c.message?.includes("The operation was aborted")) && c.name !== "AbortError") {
4181
4181
  const f = ot(this.getAverageDownloadRate());
4182
- this.downloadSamples.push({ bytes: 0, durationMs: f }), this.downloadSamples.length > Bt && this.downloadSamples.shift(), oe.recordFetchTimeout(e), I("buffer", `FETCH-ERR #${e} [${i}] attempt=${o} timeout=${f}ms avgRate=${Math.round(this.getAverageDownloadRate())}Bps error=${c.message}`);
4182
+ this.downloadSamples.push({ bytes: 0, durationMs: f }), this.downloadSamples.length > Bt && this.downloadSamples.shift(), oe.recordFetchTimeout(e), C("buffer", `FETCH-ERR #${e} [${i}] attempt=${o} timeout=${f}ms avgRate=${Math.round(this.getAverageDownloadRate())}Bps error=${c.message}`);
4183
4183
  } else
4184
- I("buffer", `FETCH-ERR #${e} [${i}] attempt=${o} error=${c.message}`);
4184
+ C("buffer", `FETCH-ERR #${e} [${i}] attempt=${o} error=${c.message}`);
4185
4185
  if (this.isInInitPhase() && this.recordInitFragEvent(e, { err: (c.name === "TimeoutError" ? "timeout" : c.message?.slice(0, 40)) || "err" }), this.fragmentStates.set(e, "pending"), o < qe) {
4186
4186
  await new Promise((f) => setTimeout(f, ct(o)));
4187
4187
  continue;
@@ -4211,7 +4211,7 @@ class Ze {
4211
4211
  if (e <= 0 || this.fragments.length === 0 || this.fragments[0].keyframe === void 0) return !1;
4212
4212
  const n = this.fragments[e];
4213
4213
  if (!n || n.keyframe) return !1;
4214
- const r = Cn(this.fragments, e - 1);
4214
+ const r = Tn(this.fragments, e - 1);
4215
4215
  if (r < 0 || this.fragmentStates.get(r) !== "error") return !1;
4216
4216
  const s = this.fragments[r];
4217
4217
  if (this.sourceBuffer ? Dt(this.sourceBuffer.buffered, s.start_ms, s.end_ms) : !1) return !1;
@@ -4222,9 +4222,9 @@ class Ze {
4222
4222
  l.push(o);
4223
4223
  continue;
4224
4224
  }
4225
- Cn(this.fragments, o.index - 1) === r ? (a.push(o.index), this.fragmentStates.set(o.index, "pending")) : l.push(o);
4225
+ Tn(this.fragments, o.index - 1) === r ? (a.push(o.index), this.fragmentStates.set(o.index, "pending")) : l.push(o);
4226
4226
  }
4227
- return a.length === 0 ? !1 : (this.appendQueue = l, I("buffer", `APPEND-DROP-DEPENDENT [${a.join(",")}] — keyframe #${r} in error, not in SB`, {
4227
+ return a.length === 0 ? !1 : (this.appendQueue = l, C("buffer", `APPEND-DROP-DEPENDENT [${a.join(",")}] — keyframe #${r} in error, not in SB`, {
4228
4228
  kfIdx: r,
4229
4229
  dropped: a,
4230
4230
  remainingQueue: this.appendQueue.map((o) => o.index)
@@ -4253,8 +4253,8 @@ class Ze {
4253
4253
  if (this.appendHold?.index !== e)
4254
4254
  return this.appendHold = { index: e, since: r }, !1;
4255
4255
  const s = r - this.appendHold.since;
4256
- if (s < Cs) return !1;
4257
- I("buffer", `APPEND-HOLD-BREAK #${e} held ${s}ms behind ${n.length} pending fetch(es) — declaring them dead so the queue can drain`, {
4256
+ if (s < Ts) return !1;
4257
+ C("buffer", `APPEND-HOLD-BREAK #${e} held ${s}ms behind ${n.length} pending fetch(es) — declaring them dead so the queue can drain`, {
4258
4258
  headIndex: e,
4259
4259
  heldMs: s,
4260
4260
  blockers: n.slice().sort((i, a) => i - a),
@@ -4262,7 +4262,7 @@ class Ze {
4262
4262
  liveJobs: Array.from(this.currentJobs.keys()).sort((i, a) => i - a)
4263
4263
  });
4264
4264
  for (const i of n)
4265
- this.currentJobs.get(i)?.abortController.abort(), this.currentJobs.delete(i), this.pendingFetchIndices.delete(i), this.fragmentStates.set(i, "error"), this.errorTimestamps.set(i, r), this.fetchErrorCycles.set(i, pn);
4265
+ this.currentJobs.get(i)?.abortController.abort(), this.currentJobs.delete(i), this.pendingFetchIndices.delete(i), this.fragmentStates.set(i, "error"), this.errorTimestamps.set(i, r), this.fetchErrorCycles.set(i, hn);
4266
4266
  return this.appendHold = null, !0;
4267
4267
  }
4268
4268
  processAppendQueue() {
@@ -4309,15 +4309,15 @@ class Ze {
4309
4309
  const a = this.fragments[i];
4310
4310
  a && a.start_ms > r && (r = a.start_ms, n = i);
4311
4311
  }
4312
- if (n < 0 || r - e < Ie) return;
4312
+ if (n < 0 || r - e < Ce) return;
4313
4313
  const s = this.currentJobs.get(n);
4314
4314
  s && (s.abortController.abort(), this.currentJobs.delete(n), this.fragmentStates.set(n, "pending"));
4315
4315
  }
4316
4316
  prefetchAround(e) {
4317
4317
  if (this.disposed || !this.sourceBuffer || (this.currentPlayheadMs = e, this.currentJobs.size >= ze)) return;
4318
- const n = Ce(this.fragments, e), r = Math.min(this.fragments.length - 1, Ce(this.fragments, e + Xe)), s = Date.now();
4318
+ const n = Ie(this.fragments, e), r = Math.min(this.fragments.length - 1, Ie(this.fragments, e + Xe)), s = Date.now();
4319
4319
  for (let a = n; a <= r; a++)
4320
- this.fragmentStates.get(a) === "error" && s - (this.errorTimestamps.get(a) ?? 0) >= Is && ((this.fetchErrorCycles.get(a) ?? 0) >= pn ? E("buffer", `PREFETCH-DEAD #${a} cycles=${this.fetchErrorCycles.get(a)} not resetting`) : (this.fragmentStates.set(a, "pending"), this.errorTimestamps.delete(a)));
4320
+ this.fragmentStates.get(a) === "error" && s - (this.errorTimestamps.get(a) ?? 0) >= Is && ((this.fetchErrorCycles.get(a) ?? 0) >= hn ? E("buffer", `PREFETCH-DEAD #${a} cycles=${this.fetchErrorCycles.get(a)} not resetting`) : (this.fragmentStates.set(a, "pending"), this.errorTimestamps.delete(a)));
4321
4321
  let i = 0;
4322
4322
  for (let a = n; a <= r && i < ze - this.currentJobs.size; a++) {
4323
4323
  const l = this.fragmentStates.get(a);
@@ -4336,7 +4336,7 @@ class Ze {
4336
4336
  const c = this.fragmentStates.get(o) ?? "pending";
4337
4337
  a[c] = (a[c] ?? 0) + 1;
4338
4338
  }
4339
- ((a.pending ?? 0) > 0 || (a.error ?? 0) > 0) && I("buffer", "PREFETCH-STALL no new fetches launched", {
4339
+ ((a.pending ?? 0) > 0 || (a.error ?? 0) > 0) && C("buffer", "PREFETCH-STALL no new fetches launched", {
4340
4340
  stateMap: a,
4341
4341
  jobs: this.currentJobs.size,
4342
4342
  maxJobs: ze,
@@ -4369,7 +4369,7 @@ class Ze {
4369
4369
  abortAllJobs(e) {
4370
4370
  if (this.generationAbort.abort(), this.generationAbort = new AbortController(), this.currentJobs.size === 0 && this.appendQueue.length === 0) return;
4371
4371
  const r = Array.from(this.currentJobs.keys()).sort((o, c) => o - c).map((o) => `#${o}=${this.fragmentStates.get(o) || "?"}`), s = this.appendQueue.map((o) => o.index), i = Array.from(this.pendingFetchIndices).sort((o, c) => o - c), a = this.appendWaiters.map((o) => o.index);
4372
- I("buffer", `ABORT-ALL [${e || "unknown"}] ${JSON.stringify({
4372
+ C("buffer", `ABORT-ALL [${e || "unknown"}] ${JSON.stringify({
4373
4373
  killedJobs: r,
4374
4374
  queuedAppends: s,
4375
4375
  pendingFetches: i,
@@ -4435,7 +4435,7 @@ class Ze {
4435
4435
  u.fetchStart && (f.fs = Math.round(u.fetchStart - this.loadStartTs)), u.fetchStart && u.fetchEnd && (f.fM = Math.round(u.fetchEnd - u.fetchStart)), u.queued && u.fetchEnd && (f.qD = Math.round(u.queued - u.fetchEnd)), u.queued && u.appendDone && (f.aM = Math.round(u.appendDone - u.queued)), u.bytes && (f.B = u.bytes), u.ttfbMs !== void 0 && (f.tt = u.ttfbMs), u.cf && (f.cf = u.cf), u.err && (f.e = u.err), a.push(f);
4436
4436
  }
4437
4437
  const o = this.getLoadedCount();
4438
- I("buffer", `INIT-DIGEST [${e}] reason=${n} ${JSON.stringify({
4438
+ C("buffer", `INIT-DIGEST [${e}] reason=${n} ${JSON.stringify({
4439
4439
  loadMs: s,
4440
4440
  initMs: i,
4441
4441
  loaded: o,
@@ -4447,12 +4447,12 @@ class Ze {
4447
4447
  })}`);
4448
4448
  }
4449
4449
  dumpBufferDiagnostics(e, n) {
4450
- const r = Ce(this.fragments, e), s = Math.max(0, r - 3), i = Math.min(this.fragments.length - 1, r + 6), a = [];
4450
+ const r = Ie(this.fragments, e), s = Math.max(0, r - 3), i = Math.min(this.fragments.length - 1, r + 6), a = [];
4451
4451
  for (let l = s; l <= i; l++) {
4452
4452
  const o = this.fragments[l], c = this.fragmentStates.get(l) || "unknown";
4453
4453
  a.push(`#${l}[${(o.start_ms / 1e3).toFixed(1)}-${(o.end_ms / 1e3).toFixed(1)}s]=${c}${this.currentJobs.has(l) ? "+job" : ""}${l === r ? " <<PLAYHEAD" : ""}`);
4454
4454
  }
4455
- I("buffer", `BUFFER-DIAG [${n}] ${JSON.stringify({
4455
+ C("buffer", `BUFFER-DIAG [${n}] ${JSON.stringify({
4456
4456
  playheadMs: Math.round(e),
4457
4457
  aheadMs: Math.round(this.getBufferedAheadMs(e)),
4458
4458
  isBuffered: this.isBuffered(e),
@@ -4570,13 +4570,13 @@ class Ze {
4570
4570
  if (this.eosRetryTimer) return;
4571
4571
  this.eosRetryTimer = setTimeout(() => {
4572
4572
  this.eosRetryTimer = null, this.tryEndOfStream();
4573
- }, Rs);
4573
+ }, Cs);
4574
4574
  return;
4575
4575
  }
4576
4576
  try {
4577
4577
  e.endOfStream(), this.pendingEndOfStream = !1, E("buffer", "END-OF-STREAM signalled");
4578
4578
  } catch (n) {
4579
- I("buffer", "endOfStream call failed", { error: n.message }), this.pendingEndOfStream = !1;
4579
+ C("buffer", "endOfStream call failed", { error: n.message }), this.pendingEndOfStream = !1;
4580
4580
  }
4581
4581
  }
4582
4582
  dispose() {
@@ -4589,22 +4589,22 @@ function No(t, e) {
4589
4589
  function Lo(t) {
4590
4590
  return t.override !== null ? t.override : t.globalEnabled || No(t.selectedAudioLang, t.hasEngSub);
4591
4591
  }
4592
- const Ir = "wp_reload_history", rn = "wp_phantom_reload", Rr = 5 * 6e4, Fn = 3;
4592
+ const Ir = "wp_reload_history", nn = "wp_phantom_reload", Cr = 5 * 6e4, Rn = 3;
4593
4593
  function $o() {
4594
4594
  try {
4595
4595
  const t = sessionStorage.getItem(Ir);
4596
- return (t ? JSON.parse(t) : []).filter((n) => Date.now() - n < Rr);
4596
+ return (t ? JSON.parse(t) : []).filter((n) => Date.now() - n < Cr);
4597
4597
  } catch {
4598
4598
  return [];
4599
4599
  }
4600
4600
  }
4601
4601
  function zt(t, e) {
4602
4602
  const n = $o();
4603
- if (n.length >= Fn) {
4604
- mn(
4603
+ if (n.length >= Rn) {
4604
+ pn(
4605
4605
  "error",
4606
4606
  "buffer",
4607
- `AUTO-RELOAD SUPPRESSED reason=${t} — ${n.length} reloads in ${Rr / 6e4}m, giving up (connection looks unstable)`,
4607
+ `AUTO-RELOAD SUPPRESSED reason=${t} — ${n.length} reloads in ${Cr / 6e4}m, giving up (connection looks unstable)`,
4608
4608
  e
4609
4609
  );
4610
4610
  try {
@@ -4617,19 +4617,19 @@ function zt(t, e) {
4617
4617
  return !1;
4618
4618
  }
4619
4619
  try {
4620
- n.push(Date.now()), sessionStorage.setItem(Ir, JSON.stringify(n)), sessionStorage.setItem(rn, String(Date.now()));
4620
+ n.push(Date.now()), sessionStorage.setItem(Ir, JSON.stringify(n)), sessionStorage.setItem(nn, String(Date.now()));
4621
4621
  } catch {
4622
4622
  }
4623
- mn("error", "buffer", `AUTO-RELOAD reason=${t} attempt=${n.length}/${Fn}`, e);
4623
+ pn("error", "buffer", `AUTO-RELOAD reason=${t} attempt=${n.length}/${Rn}`, e);
4624
4624
  try {
4625
4625
  window.location.reload();
4626
4626
  } catch {
4627
4627
  }
4628
4628
  return !0;
4629
4629
  }
4630
- function Nn() {
4630
+ function Fn() {
4631
4631
  try {
4632
- const t = sessionStorage.getItem(rn);
4632
+ const t = sessionStorage.getItem(nn);
4633
4633
  return t ? Number(t) : null;
4634
4634
  } catch {
4635
4635
  return null;
@@ -4637,7 +4637,7 @@ function Nn() {
4637
4637
  }
4638
4638
  function Po() {
4639
4639
  try {
4640
- sessionStorage.removeItem(rn);
4640
+ sessionStorage.removeItem(nn);
4641
4641
  } catch {
4642
4642
  }
4643
4643
  }
@@ -4652,20 +4652,20 @@ function Bo() {
4652
4652
  function Do(t, e) {
4653
4653
  return t === "disallowed" ? "deferred" : e ? "user-muted" : t === "allowed-muted" ? "muted-bridge" : "audible";
4654
4654
  }
4655
- function Fr(t, e) {
4655
+ function Rr(t, e) {
4656
4656
  const n = Bo(), r = Do(n, e.userWantsMuted);
4657
4657
  E(e.label, "autoplay plan", { policy: n ?? "unknown", plan: r, userWantsMuted: e.userWantsMuted });
4658
4658
  const s = () => {
4659
4659
  t.muted = !0, t.play().then(() => {
4660
- e.onMutedBridge?.(), An(() => {
4660
+ e.onMutedBridge?.(), _n(() => {
4661
4661
  e.userWantsMuted || (t.muted = !1, e.onUnmuted?.(), E(e.label, "autoplay bridge unmuted on interaction"));
4662
4662
  });
4663
- }).catch((i) => I(e.label, "muted-bridge play failed", { error: i?.name }));
4663
+ }).catch((i) => C(e.label, "muted-bridge play failed", { error: i?.name }));
4664
4664
  };
4665
- return r === "deferred" ? (An(() => {
4666
- t.play().catch((i) => I(e.label, "deferred play retry failed", { error: i?.name }));
4665
+ return r === "deferred" ? (_n(() => {
4666
+ t.play().catch((i) => C(e.label, "deferred play retry failed", { error: i?.name }));
4667
4667
  }), r) : r === "muted-bridge" ? (s(), r) : (t.muted = e.userWantsMuted, t.play().catch((i) => {
4668
- i?.name === "NotAllowedError" && !e.userWantsMuted ? s() : i?.name !== "AbortError" && I(e.label, "video.play() failed", { error: i?.name, message: i?.message });
4668
+ i?.name === "NotAllowedError" && !e.userWantsMuted ? s() : i?.name !== "AbortError" && C(e.label, "video.play() failed", { error: i?.name, message: i?.message });
4669
4669
  }), r);
4670
4670
  }
4671
4671
  const ht = {
@@ -4674,14 +4674,14 @@ const ht = {
4674
4674
  /** Room-level seeks from snapshot changes — highest priority. */
4675
4675
  SEEK_EFFECT: 3
4676
4676
  };
4677
- function Nr(t, e = 3e3) {
4677
+ function Fr(t, e = 3e3) {
4678
4678
  return new Promise((n) => {
4679
4679
  if (!t.seeking) {
4680
4680
  n();
4681
4681
  return;
4682
4682
  }
4683
4683
  const r = setTimeout(() => {
4684
- t.removeEventListener("seeked", s), oe.recordWaitForSeekedTimeout(), I("seek-coord", "waitForSeeked timed out", {
4684
+ t.removeEventListener("seeked", s), oe.recordWaitForSeekedTimeout(), C("seek-coord", "waitForSeeked timed out", {
4685
4685
  currentTime: t.currentTime.toFixed(2),
4686
4686
  readyState: t.readyState,
4687
4687
  timeoutMs: e
@@ -4733,7 +4733,7 @@ class Oo {
4733
4733
  targetMs: Math.round(e.targetMs),
4734
4734
  videoTime: n ? Math.round(n.currentTime * 1e3) : null,
4735
4735
  videoPaused: n?.paused
4736
- }), e.onAborted?.(null), Promise.resolve(null)) : (this._currentAbort ? (I("seek-coord", `SUBMIT PREEMPT [${this._currentCaller}] → [${e.caller}]`, {
4736
+ }), e.onAborted?.(null), Promise.resolve(null)) : (this._currentAbort ? (C("seek-coord", `SUBMIT PREEMPT [${this._currentCaller}] → [${e.caller}]`, {
4737
4737
  newTargetMs: Math.round(e.targetMs)
4738
4738
  }), this._currentAbort.abort(), this._currentAbort = null) : E("seek-coord", `SUBMIT [${e.caller}]`, {
4739
4739
  targetMs: Math.round(e.targetMs),
@@ -4756,7 +4756,7 @@ class Oo {
4756
4756
  this._currentAbort = n, this._seekInFlight = !0, this._currentPriority = e.priority, this._currentCaller = e.caller, this._currentTargetMs = e.targetMs;
4757
4757
  const { targetMs: r, caller: s } = e, i = e.pauseSeekResume ?? !0, a = this.deps.videoRef.current, l = this.deps.fragmentManagerRef.current;
4758
4758
  if (!a || !l)
4759
- return I("seek-coord", `EXECUTE bail — missing ${a ? "fragmentManager" : "video"}`, { caller: s }), this._clear(n), null;
4759
+ return C("seek-coord", `EXECUTE bail — missing ${a ? "fragmentManager" : "video"}`, { caller: s }), this._clear(n), null;
4760
4760
  const o = performance.now(), c = !a.paused;
4761
4761
  try {
4762
4762
  i && c && this._pause(a), this._checkAborted(n);
@@ -4772,9 +4772,9 @@ class Oo {
4772
4772
  } else
4773
4773
  E("seek-coord", `ALREADY BUFFERED [${s}] target=${Math.round(r)}ms`);
4774
4774
  const p = r / 1e3;
4775
- a.currentTime = p, await Nr(a), this._checkAborted(n);
4775
+ a.currentTime = p, await Fr(a), this._checkAborted(n);
4776
4776
  const v = a.currentTime * 1e3, g = Math.round(performance.now() - o);
4777
- I("seek-coord", `SEEK-DIGEST [${s}] route=${this._lastSeekRoute} ${g}ms`, {
4777
+ C("seek-coord", `SEEK-DIGEST [${s}] route=${this._lastSeekRoute} ${g}ms`, {
4778
4778
  targetMs: Math.round(r),
4779
4779
  actualMs: Math.round(v),
4780
4780
  delta: Math.round(v - r),
@@ -4792,7 +4792,7 @@ class Oo {
4792
4792
  return u.name === "AbortError" ? (E("seek-coord", `PREEMPTED [${s}] after ${f}ms`, {
4793
4793
  targetMs: Math.round(r),
4794
4794
  videoTime: Math.round(a.currentTime * 1e3)
4795
- }), e.onAborted?.(null), null) : (I("seek-coord", `FAILED [${s}] after ${f}ms: ${u?.message}`, {
4795
+ }), e.onAborted?.(null), null) : (C("seek-coord", `FAILED [${s}] after ${f}ms: ${u?.message}`, {
4796
4796
  targetMs: Math.round(r),
4797
4797
  videoTime: Math.round(a.currentTime * 1e3),
4798
4798
  videoReady: a.readyState,
@@ -4863,7 +4863,7 @@ class Oo {
4863
4863
  for (const o of n)
4864
4864
  o.isBuffered(r) || l.push(
4865
4865
  this._smartBuffer(o, r, `${s}-audio`, i).catch((c) => {
4866
- c.name !== "AbortError" && I("seek-coord", `Audio FM buffer failed during ${s}`, {
4866
+ c.name !== "AbortError" && C("seek-coord", `Audio FM buffer failed during ${s}`, {
4867
4867
  error: c?.message
4868
4868
  });
4869
4869
  })
@@ -4876,7 +4876,7 @@ class Oo {
4876
4876
  }
4877
4877
  _resume(e) {
4878
4878
  const n = x.getState();
4879
- Fr(e, {
4879
+ Rr(e, {
4880
4880
  userWantsMuted: n.mediaPrefs.muted,
4881
4881
  onMutedBridge: () => x.getState().setMutedForAutoplay(!0),
4882
4882
  onUnmuted: () => x.getState().setMutedForAutoplay(!1),
@@ -4886,12 +4886,12 @@ class Oo {
4886
4886
  }
4887
4887
  let lt = null;
4888
4888
  function Ho() {
4889
- lt === null && (E("health", "Starting health reporting"), Ln(), lt = window.setInterval(Ln, Fs));
4889
+ lt === null && (E("health", "Starting health reporting"), Nn(), lt = window.setInterval(Nn, Rs));
4890
4890
  }
4891
4891
  function Uo() {
4892
4892
  lt !== null && (E("health", "Stopping health reporting"), window.clearInterval(lt), lt = null);
4893
4893
  }
4894
- function Ln() {
4894
+ function Nn() {
4895
4895
  const t = Jn();
4896
4896
  if (!t.connected) return;
4897
4897
  const e = x.getState();
@@ -4922,9 +4922,9 @@ function Ln() {
4922
4922
  fragments_error: i.fragmentStates.error || 0,
4923
4923
  video_ready_state: r?.readyState ?? -1,
4924
4924
  duration_ms: n.getMediaEndMs(),
4925
- delivery_arm: Ls(),
4925
+ delivery_arm: Ns(),
4926
4926
  ...jo(r),
4927
- pong_age_ms: Ns(),
4927
+ pong_age_ms: Fs(),
4928
4928
  reported_at: Date.now()
4929
4929
  });
4930
4930
  }
@@ -4962,27 +4962,27 @@ function Wo() {
4962
4962
  };
4963
4963
  }, [i]), { controlsVisible: t, showControls: i, hideControls: a, setControlsHeld: l };
4964
4964
  }
4965
- const Lr = [], $r = [], Ko = {
4966
- fragments: Lr,
4965
+ const Nr = [], Lr = [], Ko = {
4966
+ fragments: Nr,
4967
4967
  durationMs: null,
4968
4968
  mseCodec: null,
4969
4969
  initSegment: void 0,
4970
- audioTracks: $r,
4970
+ audioTracks: Lr,
4971
4971
  contentToken: null
4972
4972
  };
4973
4973
  function Vo(t, e) {
4974
4974
  if (!t || t.url !== e) return Ko;
4975
4975
  const n = t.data;
4976
4976
  return {
4977
- fragments: n.fragments || Lr,
4977
+ fragments: n.fragments || Nr,
4978
4978
  durationMs: n.duration_ms || null,
4979
4979
  mseCodec: n.mse_codec || null,
4980
4980
  initSegment: n.init_segment || void 0,
4981
- audioTracks: n.audio_tracks || $r,
4981
+ audioTracks: n.audio_tracks || Lr,
4982
4982
  contentToken: n.content_token || null
4983
4983
  };
4984
4984
  }
4985
- function $n(t) {
4985
+ function Ln(t) {
4986
4986
  try {
4987
4987
  const e = performance.getEntriesByName(t, "resource");
4988
4988
  if (!e.length) return null;
@@ -5021,7 +5021,7 @@ function zo(t) {
5021
5021
  const u = await o.text(), f = Math.round(performance.now() - l) - c, p = JSON.parse(u), v = Math.round(performance.now() - l) - c - f, g = c + f + v;
5022
5022
  if (r.signal.aborted) return;
5023
5023
  n({ url: t, data: p });
5024
- const h = $n(t);
5024
+ const h = Ln(t);
5025
5025
  E("mse", "Index loaded", {
5026
5026
  attempt: i + 1,
5027
5027
  headerMs: c,
@@ -5039,8 +5039,8 @@ function zo(t) {
5039
5039
  } catch (o) {
5040
5040
  if (r.signal.aborted) return;
5041
5041
  i++;
5042
- const c = Math.round(performance.now() - l), u = $n(t);
5043
- I("mse", `Index fetch attempt ${i} failed (${c}ms)`, {
5042
+ const c = Math.round(performance.now() - l), u = Ln(t);
5043
+ C("mse", `Index fetch attempt ${i} failed (${c}ms)`, {
5044
5044
  error: o?.message,
5045
5045
  elapsedMs: c,
5046
5046
  ...u && { timing: u }
@@ -5062,9 +5062,9 @@ const Ht = {
5062
5062
  selectedSubtitleIndex: 0
5063
5063
  };
5064
5064
  function Jo(t) {
5065
- const [e, n] = $(Ht), r = $s(), s = x((u) => u.mediaPrefs.preferredAudioLang), [i, a] = $(t);
5065
+ const [e, n] = $(Ht), r = Ls(), s = x((u) => u.mediaPrefs.preferredAudioLang), [i, a] = $(t);
5066
5066
  i !== t && (a(t), t && n(Ht));
5067
- const l = fe(() => ({ origin: Ps(r), preferredAudioLang: s }));
5067
+ const l = fe(() => ({ origin: $s(r), preferredAudioLang: s }));
5068
5068
  L(() => {
5069
5069
  if (!t) return;
5070
5070
  const u = new AbortController(), { origin: f, preferredAudioLang: p } = l();
@@ -5077,7 +5077,7 @@ function Jo(t) {
5077
5077
  } catch (g) {
5078
5078
  const h = Y(g);
5079
5079
  if (h.name === "AbortError") return;
5080
- I("mse", "Tracks fetch error", { mediaId: t, status: v?.status, ...h }), n(Ht);
5080
+ C("mse", "Tracks fetch error", { mediaId: t, status: v?.status, ...h }), n(Ht);
5081
5081
  }
5082
5082
  })().catch((g) => ee("mse", "Tracks load threw", { mediaId: t, ...Y(g) })), () => {
5083
5083
  u.abort();
@@ -5111,7 +5111,7 @@ function Xo(t, e, n, r, s, i) {
5111
5111
  }), l = fe((w, A) => {
5112
5112
  for (const F of i?.current ?? [])
5113
5113
  F.hasIndex && (F.reconcileLoadedStates(), F.fetchNearby(w).catch((k) => {
5114
- k?.name !== "AbortError" && I("sync", "audio FM recovery fetchNearby failed", {
5114
+ k?.name !== "AbortError" && C("sync", "audio FM recovery fetchNearby failed", {
5115
5115
  reason: A,
5116
5116
  currentMs: Math.round(w),
5117
5117
  error: k?.message
@@ -5133,8 +5133,8 @@ function Xo(t, e, n, r, s, i) {
5133
5133
  g.current = null;
5134
5134
  const S = t.current;
5135
5135
  if (!S) return;
5136
- const C = x.getState(), D = n.current, H = qo({
5137
- roomPlaying: C.snapshot.playing,
5136
+ const I = x.getState(), D = n.current, H = qo({
5137
+ roomPlaying: I.snapshot.playing,
5138
5138
  videoPaused: S.paused,
5139
5139
  seekInFlight: !!D?.seekInFlight,
5140
5140
  advancedMs: (S.currentTime - h.current) * 1e3
@@ -5146,7 +5146,7 @@ function Xo(t, e, n, r, s, i) {
5146
5146
  const j = S.currentTime * 1e3, V = e.current, X = Date.now();
5147
5147
  y.current === null && (y.current = X);
5148
5148
  const N = X - y.current;
5149
- if (I("sync", "SILENT-STALL playhead frozen with no `waiting` event", {
5149
+ if (C("sync", "SILENT-STALL playhead frozen with no `waiting` event", {
5150
5150
  currentTime: +S.currentTime.toFixed(2),
5151
5151
  readyState: S.readyState,
5152
5152
  frozenMs: N,
@@ -5161,7 +5161,7 @@ function Xo(t, e, n, r, s, i) {
5161
5161
  }), l(j, "silent-stall"), V) {
5162
5162
  V.reconcileLoadedStates();
5163
5163
  const O = V.findNextRangeStart(j, Pt);
5164
- O !== null && D ? (I("sync", "SILENT-STALL gap-skip", {
5164
+ O !== null && D ? (C("sync", "SILENT-STALL gap-skip", {
5165
5165
  currentMs: Math.round(j),
5166
5166
  gapSkipTarget: Math.round(O)
5167
5167
  }), D.submit({
@@ -5171,7 +5171,7 @@ function Xo(t, e, n, r, s, i) {
5171
5171
  pauseSeekResume: !1
5172
5172
  }).catch((Q) => ee("sync", "SILENT-STALL gap-skip seek threw", Y(Q)))) : V.fetchNearby(j).catch((Q) => {
5173
5173
  const W = Y(Q);
5174
- W.name !== "AbortError" && I("sync", "SILENT-STALL fetchNearby failed", {
5174
+ W.name !== "AbortError" && C("sync", "SILENT-STALL fetchNearby failed", {
5175
5175
  currentMs: Math.round(j),
5176
5176
  error: W.error
5177
5177
  });
@@ -5194,7 +5194,7 @@ function Xo(t, e, n, r, s, i) {
5194
5194
  function T() {
5195
5195
  const S = w.currentTime * 1e3;
5196
5196
  f.current = Date.now();
5197
- const C = x.getState(), D = C.snapshot.playing, H = !!C.snapshot.leaderId && C.snapshot.leaderId === C.me.clientId, j = C.snapshot.playheadMs + (C.snapshot.playing ? Date.now() - C.snapshotReceivedAt : 0);
5197
+ const I = x.getState(), D = I.snapshot.playing, H = !!I.snapshot.leaderId && I.snapshot.leaderId === I.me.clientId, j = I.snapshot.playheadMs + (I.snapshot.playing ? Date.now() - I.snapshotReceivedAt : 0);
5198
5198
  E("sync", "VIDEO waiting event", {
5199
5199
  currentTime: w.currentTime.toFixed(2),
5200
5200
  readyState: w.readyState,
@@ -5205,7 +5205,7 @@ function Xo(t, e, n, r, s, i) {
5205
5205
  const V = e.current, X = n.current, N = V?.getBufferedAheadMs(S) ?? 0;
5206
5206
  if (V && N < 1e3 && V.dumpBufferDiagnostics(S, "stall-onset"), D && N >= 1e3) {
5207
5207
  const O = a(S);
5208
- Object.keys(O).length > 0 && I("sync", "STALL-TRACKS video buffer healthy at stall — per-track geometry", {
5208
+ Object.keys(O).length > 0 && C("sync", "STALL-TRACKS video buffer healthy at stall — per-track geometry", {
5209
5209
  currentMs: Math.round(S),
5210
5210
  videoAheadMs: Math.round(N),
5211
5211
  ...O
@@ -5215,7 +5215,7 @@ function Xo(t, e, n, r, s, i) {
5215
5215
  V.reconcileLoadedStates();
5216
5216
  const O = V.getBufferedAheadMs(S), Q = V.findNextRangeStart(S, Pt);
5217
5217
  if (Q !== null && X)
5218
- I("sync", "GAP-SKIP seeking over late-IDR gap", {
5218
+ C("sync", "GAP-SKIP seeking over late-IDR gap", {
5219
5219
  currentMs: Math.round(S),
5220
5220
  gapSkipTarget: Math.round(Q)
5221
5221
  }), X.submit({
@@ -5226,7 +5226,7 @@ function Xo(t, e, n, r, s, i) {
5226
5226
  }).catch((W) => ee("sync", "GAP-SKIP seek threw", Y(W)));
5227
5227
  else if (O < 500) {
5228
5228
  const W = V.getForwardGapDiag(S);
5229
- W && W.nextRangeStartMs !== null && I("sync", "STALL-GAP not skipped", {
5229
+ W && W.nextRangeStartMs !== null && C("sync", "STALL-GAP not skipped", {
5230
5230
  currentMs: Math.round(S),
5231
5231
  atEdge: W.atEdge,
5232
5232
  aheadInRangeMs: Math.round(W.aheadInRangeMs),
@@ -5235,7 +5235,7 @@ function Xo(t, e, n, r, s, i) {
5235
5235
  windowMs: Pt
5236
5236
  }), V.fetchNearby(S).catch((re) => {
5237
5237
  const le = Y(re);
5238
- le.name !== "AbortError" && I("sync", "Stall recovery fetchNearby failed", {
5238
+ le.name !== "AbortError" && C("sync", "Stall recovery fetchNearby failed", {
5239
5239
  currentMs: Math.round(S),
5240
5240
  error: le.error
5241
5241
  });
@@ -5245,8 +5245,8 @@ function Xo(t, e, n, r, s, i) {
5245
5245
  H && D && !c.current && (c.current = setTimeout(() => {
5246
5246
  c.current = null;
5247
5247
  const O = x.getState(), Q = !!O.snapshot.leaderId && O.snapshot.leaderId === O.me.clientId, W = !!n.current?.seekInFlight;
5248
- Q && !w.paused && w.readyState < 3 && !W && (I("sync", "Leader stall threshold reached — pausing room", { stallMs: gn }), u.current = !0, Pe("pause"));
5249
- }, gn)), D && !p.current && (v.current = w.currentTime, p.current = setTimeout(() => {
5248
+ Q && !w.paused && w.readyState < 3 && !W && (C("sync", "Leader stall threshold reached — pausing room", { stallMs: mn }), u.current = !0, Pe("pause"));
5249
+ }, mn)), D && !p.current && (v.current = w.currentTime, p.current = setTimeout(() => {
5250
5250
  p.current = null;
5251
5251
  const O = t.current;
5252
5252
  if (!O) return;
@@ -5272,14 +5272,14 @@ function Xo(t, e, n, r, s, i) {
5272
5272
  }
5273
5273
  function R() {
5274
5274
  oe.recordStallEnd(), c.current && (clearTimeout(c.current), c.current = null), p.current && (clearTimeout(p.current), p.current = null), y.current = null, F();
5275
- const S = x.getState(), C = S.snapshot.playing, D = !!S.snapshot.leaderId && S.snapshot.leaderId === S.me.clientId;
5276
- !C && !w.paused && o(w), D && u.current && !C && (u.current = !1, I("sync", "Leader stall recovered — resuming room", { currentTime: w.currentTime.toFixed(2) }), Pe("play"));
5275
+ const S = x.getState(), I = S.snapshot.playing, D = !!S.snapshot.leaderId && S.snapshot.leaderId === S.me.clientId;
5276
+ !I && !w.paused && o(w), D && u.current && !I && (u.current = !1, C("sync", "Leader stall recovered — resuming room", { currentTime: w.currentTime.toFixed(2) }), Pe("play"));
5277
5277
  const H = f.current !== null ? Date.now() - f.current : null;
5278
5278
  f.current = null;
5279
5279
  const j = x.getState(), V = j.snapshot.playheadMs + (j.snapshot.playing ? Date.now() - j.snapshotReceivedAt : 0), X = w.currentTime * 1e3;
5280
5280
  E("sync", "VIDEO playing event", {
5281
5281
  currentTime: w.currentTime.toFixed(2),
5282
- shouldPlay: C,
5282
+ shouldPlay: I,
5283
5283
  stallDurationMs: H,
5284
5284
  // Positive = viewer is behind server; negative = viewer is ahead.
5285
5285
  driftMs: H !== null ? Math.round(V - X) : null
@@ -5321,9 +5321,9 @@ function ec(t, e, n, r, s, i) {
5321
5321
  s({ bufferedEndMs: y });
5322
5322
  }
5323
5323
  };
5324
- a.current = setInterval(v, bn);
5324
+ a.current = setInterval(v, gn);
5325
5325
  const g = () => {
5326
- performance.now() - p >= bn * Zo && v();
5326
+ performance.now() - p >= gn * Zo && v();
5327
5327
  };
5328
5328
  if (c && (c.addEventListener("timeupdate", g), l.current = () => c.removeEventListener("timeupdate", g)), c && !n.current?.seekInFlight) {
5329
5329
  p = performance.now();
@@ -5339,7 +5339,7 @@ function tc(t, e, n, r, s, i) {
5339
5339
  const f = t.current;
5340
5340
  if (!f || !r) return;
5341
5341
  const p = a.playheadMs, v = n.current, g = l !== o.current;
5342
- o.current = l, !(!g && Math.abs(p - v) <= Bs) && (E("buffer", "Seek triggered", {
5342
+ o.current = l, !(!g && Math.abs(p - v) <= Ps) && (E("buffer", "Seek triggered", {
5343
5343
  targetMs: p,
5344
5344
  lastApplied: v,
5345
5345
  delta: Math.round(p - v),
@@ -5357,7 +5357,7 @@ function tc(t, e, n, r, s, i) {
5357
5357
  p && v ? (E("sync", "Play/pause sync", { playing: p, videoPaused: v, currentTime: Math.round(f.currentTime * 1e3) }), c(f)) : !p && !v && (E("sync", "Play/pause sync", { playing: p, videoPaused: v, currentTime: Math.round(f.currentTime * 1e3) }), u(f));
5358
5358
  }, [a.playing, r, t, e]);
5359
5359
  }
5360
- function Pn(t, e) {
5360
+ function $n(t, e) {
5361
5361
  return new Promise((n, r) => {
5362
5362
  const s = setTimeout(n, t);
5363
5363
  e.addEventListener("abort", () => {
@@ -5378,13 +5378,13 @@ function nc(t) {
5378
5378
  const c = a.videos[o], { mediaUrl: u, indexUrl: f } = qn(c.mediaId), p = 3e3, v = async () => {
5379
5379
  for (; !l.signal.aborted && (t.current?.getPendingCount() ?? 0) !== 0; )
5380
5380
  try {
5381
- await Pn(2e3, l.signal);
5381
+ await $n(2e3, l.signal);
5382
5382
  } catch {
5383
5383
  return !1;
5384
5384
  }
5385
5385
  if (l.signal.aborted) return !1;
5386
5386
  try {
5387
- await Pn(p, l.signal);
5387
+ await $n(p, l.signal);
5388
5388
  } catch {
5389
5389
  return !1;
5390
5390
  }
@@ -5395,18 +5395,18 @@ function nc(t) {
5395
5395
  try {
5396
5396
  const m = await fetch(f, { signal: l.signal });
5397
5397
  if (!m.ok) {
5398
- I("prebuffer", `index.json fetch failed for ${c.mediaId}: HTTP ${m.status}`);
5398
+ C("prebuffer", `index.json fetch failed for ${c.mediaId}: HTTP ${m.status}`);
5399
5399
  continue;
5400
5400
  }
5401
5401
  g = await m.json();
5402
5402
  } catch (m) {
5403
5403
  if (l.signal.aborted) return;
5404
- I("prebuffer", `index.json fetch error for ${c.mediaId}`, Y(m));
5404
+ C("prebuffer", `index.json fetch error for ${c.mediaId}`, Y(m));
5405
5405
  continue;
5406
5406
  }
5407
5407
  const { fragments: h, init_segment: y } = g;
5408
5408
  if (!h?.length) continue;
5409
- const w = nn(h, 0), A = Ce(h, Ie), F = ve.getInit(c.mediaId) !== void 0, k = ve.getBufferedMs(c.mediaId, h) >= Ie;
5409
+ const w = tn(h, 0), A = Ie(h, Ce), F = ve.getInit(c.mediaId) !== void 0, k = ve.getBufferedMs(c.mediaId, h) >= Ce;
5410
5410
  if (F && k) {
5411
5411
  E("prebuffer", `${c.mediaId} already fully pre-buffered, skipping`);
5412
5412
  continue;
@@ -5417,7 +5417,7 @@ function nc(t) {
5417
5417
  const m = await fetch(u, {
5418
5418
  headers: {
5419
5419
  Range: `bytes=${y.start_byte}-${y.end_byte}`,
5420
- "X-Buffer-Ahead-Ms": String(yn)
5420
+ "X-Buffer-Ahead-Ms": String(bn)
5421
5421
  // background fetch — low priority
5422
5422
  },
5423
5423
  signal: l.signal
@@ -5428,7 +5428,7 @@ function nc(t) {
5428
5428
  }
5429
5429
  } catch (m) {
5430
5430
  if (l.signal.aborted) return;
5431
- I("prebuffer", `Init fetch failed for ${c.mediaId}`, Y(m));
5431
+ C("prebuffer", `Init fetch failed for ${c.mediaId}`, Y(m));
5432
5432
  }
5433
5433
  }
5434
5434
  for (let m = w; m <= A; m++) {
@@ -5440,7 +5440,7 @@ function nc(t) {
5440
5440
  const R = await fetch(u, {
5441
5441
  headers: {
5442
5442
  Range: `bytes=${T.start_byte}-${T.end_byte}`,
5443
- "X-Buffer-Ahead-Ms": String(yn)
5443
+ "X-Buffer-Ahead-Ms": String(bn)
5444
5444
  },
5445
5445
  signal: l.signal
5446
5446
  });
@@ -5450,14 +5450,14 @@ function nc(t) {
5450
5450
  }
5451
5451
  } catch (R) {
5452
5452
  if (l.signal.aborted) return;
5453
- I("prebuffer", `Fragment #${m} fetch failed for ${c.mediaId}`, Y(R));
5453
+ C("prebuffer", `Fragment #${m} fetch failed for ${c.mediaId}`, Y(R));
5454
5454
  }
5455
5455
  }
5456
5456
  E("prebuffer", `Pre-buffer complete for ${c.mediaId}`);
5457
5457
  }
5458
5458
  E("prebuffer", "All playlist videos pre-buffered");
5459
5459
  })().catch((o) => {
5460
- o?.name !== "AbortError" && I("prebuffer", `Pre-buffer loop error: ${o?.message}`);
5460
+ o?.name !== "AbortError" && C("prebuffer", `Pre-buffer loop error: ${o?.message}`);
5461
5461
  }), () => {
5462
5462
  E("prebuffer", "Pre-buffer aborted", { playlistId: a.id }), l.abort();
5463
5463
  };
@@ -5494,7 +5494,7 @@ function ac(t, e, n, r, s, i) {
5494
5494
  E(Te, "resync not needed", { reason: u, driftMs: w });
5495
5495
  return;
5496
5496
  }
5497
- y.kind === "seek" ? I(Te, "BG-RESYNC seek", { reason: u, driftMs: w, elementMs: Math.round(g) }) : E(Te, "resync", { reason: u, plan: y.kind, driftMs: w }), y.kind === "resume" ? i(f) : p && p.submit({ targetMs: y.targetMs, priority: ht.SEEK_EFFECT, caller: `bg-resync:${u}` });
5497
+ y.kind === "seek" ? C(Te, "BG-RESYNC seek", { reason: u, driftMs: w, elementMs: Math.round(g) }) : E(Te, "resync", { reason: u, plan: y.kind, driftMs: w }), y.kind === "resume" ? i(f) : p && p.submit({ targetMs: y.targetMs, priority: ht.SEEK_EFFECT, caller: `bg-resync:${u}` });
5498
5498
  });
5499
5499
  L(() => {
5500
5500
  const u = t.current;
@@ -5520,14 +5520,14 @@ function ac(t, e, n, r, s, i) {
5520
5520
  if (!u || typeof navigator > "u" || !("mediaSession" in navigator)) return;
5521
5521
  const f = navigator.mediaSession;
5522
5522
  let p = !1;
5523
- const v = Cr(n), g = (k) => {
5523
+ const v = Tr(n), g = (k) => {
5524
5524
  p || typeof MediaMetadata > "u" || (f.metadata = new MediaMetadata({
5525
5525
  title: v,
5526
5526
  artist: "Watch Party",
5527
5527
  artwork: k ? [{ src: k }] : []
5528
5528
  }));
5529
5529
  };
5530
- g(null), sc(co(n).map(Ds)).then(g);
5530
+ g(null), sc(co(n).map(Bs)).then(g);
5531
5531
  const h = (k) => () => {
5532
5532
  const m = x.getState(), T = so(k, { isLeader: rc(), roomPlaying: m.snapshot.playing });
5533
5533
  switch (E(Te, "media session press", { action: k, result: T.kind }), k === "pause" && (l.current = Date.now()), T.kind) {
@@ -5561,7 +5561,7 @@ function ac(t, e, n, r, s, i) {
5561
5561
  try {
5562
5562
  f.setPositionState({ duration: k, position: Math.min(Math.max(u.currentTime, 0), k), playbackRate: u.playbackRate || 1 });
5563
5563
  } catch (m) {
5564
- I(Te, "setPositionState rejected", Y(m));
5564
+ C(Te, "setPositionState rejected", Y(m));
5565
5565
  }
5566
5566
  }, A = () => {
5567
5567
  f.playbackState = "playing", w();
@@ -5623,54 +5623,54 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5623
5623
  if (!w) return null;
5624
5624
  const B = t.replace(new RegExp(`/${gt.replace(/\./g, "\\.")}$`), "");
5625
5625
  return B === t ? null : { baseUrl: B, token: w, trackId: M };
5626
- }, [w, t]), k = g !== null && y.length > 0, m = x((M) => M.readiness), T = P(!1), R = P(!1), b = P(null), S = P(null), C = P(null), D = P(0), H = P(0), j = P(null), [V, X] = $(0), N = P([]), O = P([]), Q = P(-1), W = P(!1), re = P(null), le = P(0), Re = P(null), Ve = P(0), Mt = x((M) => M.bufferState), Be = x((M) => M.setBufferState), {
5626
+ }, [w, t]), k = g !== null && y.length > 0, m = x((M) => M.readiness), T = P(!1), R = P(!1), b = P(null), S = P(null), I = P(null), D = P(0), H = P(0), j = P(null), [V, X] = $(0), N = P([]), O = P([]), Q = P(-1), W = P(!1), re = P(null), le = P(0), Re = P(null), Ve = P(0), Mt = x((M) => M.bufferState), Be = x((M) => M.setBufferState), {
5627
5627
  audioTracks: ye,
5628
5628
  subtitleTracks: De,
5629
5629
  selectedAudioIndex: we,
5630
5630
  setSelectedAudioIndex: rt,
5631
5631
  selectedSubtitleIndex: z,
5632
5632
  setSelectedSubtitleIndex: he
5633
- } = Jo(n), Me = x((M) => M.mediaPrefs), kt = x((M) => M.mutedForAutoplay), Pr = x((M) => M.setMutedForAutoplay), sn = x((M) => M.setSubtitlesEnabled), Br = x((M) => M.setSubtitleStyle), _t = x((M) => M.setPreferredAudioLang), Dr = Me.subtitlesEnabled, an = Me.subtitleStyle, Or = ye[we]?.lang, Hr = De.some((M) => M.lang === "eng"), [Ur, on] = $(null), st = Lo({
5634
- override: Ur,
5635
- globalEnabled: Dr,
5636
- selectedAudioLang: Or,
5637
- hasEngSub: Hr
5638
- }), jr = U(() => {
5633
+ } = Jo(n), Me = x((M) => M.mediaPrefs), kt = x((M) => M.mutedForAutoplay), $r = x((M) => M.setMutedForAutoplay), rn = x((M) => M.setSubtitlesEnabled), Pr = x((M) => M.setSubtitleStyle), _t = x((M) => M.setPreferredAudioLang), Br = Me.subtitlesEnabled, sn = Me.subtitleStyle, Dr = ye[we]?.lang, Or = De.some((M) => M.lang === "eng"), [Hr, an] = $(null), st = Lo({
5634
+ override: Hr,
5635
+ globalEnabled: Br,
5636
+ selectedAudioLang: Dr,
5637
+ hasEngSub: Or
5638
+ }), Ur = U(() => {
5639
5639
  const M = !st;
5640
- on(M), sn(M);
5641
- }, [st, sn]), mt = U((M) => {
5640
+ an(M), rn(M);
5641
+ }, [st, rn]), mt = U((M) => {
5642
5642
  const B = x.getState();
5643
- Fr(M, {
5643
+ Rr(M, {
5644
5644
  userWantsMuted: B.mediaPrefs.muted,
5645
5645
  onMutedBridge: () => B.setMutedForAutoplay(!0),
5646
5646
  onUnmuted: () => B.setMutedForAutoplay(!1),
5647
5647
  label: "video"
5648
5648
  });
5649
- }, []), cn = U((M) => {
5649
+ }, []), on = U((M) => {
5650
5650
  M.pause();
5651
- }, []), [Gr, ln] = $(0), [Wr, Kr] = $(n);
5652
- Wr !== n && (Kr(n), on(null), ln(0)), L(() => {
5651
+ }, []), [jr, cn] = $(0), [Gr, Wr] = $(n);
5652
+ Gr !== n && (Wr(n), an(null), cn(0)), L(() => {
5653
5653
  const M = r.current;
5654
5654
  if (!M) return;
5655
5655
  const B = () => {
5656
- ln(Math.round(M.currentTime * 1e3));
5656
+ cn(Math.round(M.currentTime * 1e3));
5657
5657
  };
5658
5658
  return M.addEventListener("timeupdate", B), () => M.removeEventListener("timeupdate", B);
5659
5659
  }, []);
5660
5660
  const at = U((M) => {
5661
5661
  Be({ isBuffering: M });
5662
- }, [Be]), dn = U((M) => {
5662
+ }, [Be]), ln = U((M) => {
5663
5663
  if (H.current >= cc) {
5664
5664
  zt("phantom-recreate-exhausted", { reason: M, recreates: H.current, mediaId: n });
5665
5665
  return;
5666
5666
  }
5667
- H.current += 1, D.current = 0, I("buffer", "MSE-RECREATE — rebuilding MediaSource to clear corrupt buffer", {
5667
+ H.current += 1, D.current = 0, C("buffer", "MSE-RECREATE — rebuilding MediaSource to clear corrupt buffer", {
5668
5668
  reason: M,
5669
5669
  attempt: H.current
5670
5670
  }), X((B) => B + 1);
5671
5671
  }, [n]);
5672
5672
  async function At() {
5673
- const M = C.current, B = r.current;
5673
+ const M = I.current, B = r.current;
5674
5674
  if (!M || !p.length || R.current) return;
5675
5675
  const pe = x.getState().snapshot, K = pe.playheadMs || 0;
5676
5676
  E("buffer", "Initializing playback", { mediaId: n, startMs: K, playing: pe.playing }), M.setPlayhead(K);
@@ -5678,30 +5678,30 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5678
5678
  try {
5679
5679
  const ie = N.current, te = ie.map(
5680
5680
  (G) => G.ensureBuffered(K, "initial-audio").catch((se) => {
5681
- (G.isDisposed ? E : I)("buffer", G.isDisposed ? "Audio FM initial load cancelled by media change" : "Audio FM initial ensureBuffered failed", {
5681
+ (G.isDisposed ? E : C)("buffer", G.isDisposed ? "Audio FM initial load cancelled by media change" : "Audio FM initial ensureBuffered failed", {
5682
5682
  error: se?.message
5683
5683
  });
5684
5684
  })
5685
5685
  );
5686
5686
  if (await M.ensureBuffered(K, "initial"), M.isDisposed) return;
5687
- const ne = Os;
5687
+ const ne = Ds;
5688
5688
  await Promise.allSettled(te);
5689
5689
  const J = ie.map(
5690
- (G) => G.waitForBuffered(K + Ie, ne)
5691
- ), xe = await M.waitForBuffered(K + Ie, ne);
5692
- if (await Promise.allSettled(J), xe || I("buffer", "Buffer gate timeout — proceeding with partial buffer", {
5690
+ (G) => G.waitForBuffered(K + Ce, ne)
5691
+ ), xe = await M.waitForBuffered(K + Ce, ne);
5692
+ if (await Promise.allSettled(J), xe || C("buffer", "Buffer gate timeout — proceeding with partial buffer", {
5693
5693
  startMs: K,
5694
5694
  aheadMs: Math.round(M.getBufferedAheadMs(K)),
5695
- targetMs: Ie
5695
+ targetMs: Ce
5696
5696
  }), M.isDisposed) return;
5697
5697
  if (M.getBufferedAheadMs(K) > ic && M.getLoadedCount() === 0) {
5698
- M.dumpBufferDiagnostics(K, "phantom-detected"), I("buffer", "PHANTOM-BUFFER detected at gate — recreating MediaSource", {
5698
+ M.dumpBufferDiagnostics(K, "phantom-detected"), C("buffer", "PHANTOM-BUFFER detected at gate — recreating MediaSource", {
5699
5699
  gateAheadMs: Math.round(M.getBufferedAheadMs(K)),
5700
5700
  loaded: M.getLoadedCount(),
5701
5701
  startMs: Math.round(K),
5702
5702
  recreateAttempt: H.current,
5703
5703
  mediaId: n
5704
- }), dn("phantom-buffer");
5704
+ }), ln("phantom-buffer");
5705
5705
  return;
5706
5706
  }
5707
5707
  const Oe = Math.round(performance.now() - de);
@@ -5710,7 +5710,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5710
5710
  totalMs: Oe
5711
5711
  });
5712
5712
  const ke = xe ? "gate-pass" : "gate-timeout";
5713
- M.emitInitDigest("video", ke), ie.forEach((G, se) => G.emitInitDigest(`audio:${se}`, ke)), T.current || (T.current = !0, Hs(n));
5713
+ M.emitInitDigest("video", ke), ie.forEach((G, se) => G.emitInitDigest(`audio:${se}`, ke)), T.current || (T.current = !0, Os(n));
5714
5714
  let q = K;
5715
5715
  if (B && q > 0) {
5716
5716
  const G = B.buffered;
@@ -5718,9 +5718,9 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5718
5718
  const se = q / 1e3, ae = G.start(0);
5719
5719
  se < ae && ae - se < 1 && (q = ae * 1e3);
5720
5720
  }
5721
- B.currentTime = q / 1e3, await Nr(B, 3e3);
5721
+ B.currentTime = q / 1e3, await Fr(B, 3e3);
5722
5722
  }
5723
- le.current = q, i(!0), R.current = !0, D.current = 0, Nn() && I("buffer", "RECOVERY-SUCCESS — playback initialized after an auto-reload", { mediaId: n }), Po(), E("buffer", "initializePlayback complete", {
5723
+ le.current = q, i(!0), R.current = !0, D.current = 0, Fn() && C("buffer", "RECOVERY-SUCCESS — playback initialized after an auto-reload", { mediaId: n }), Po(), E("buffer", "initializePlayback complete", {
5724
5724
  mediaId: n,
5725
5725
  startMs: K,
5726
5726
  seekMs: q,
@@ -5758,19 +5758,19 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5758
5758
  });
5759
5759
  },
5760
5760
  onAborted: (Fe) => {
5761
- Fe === null ? I("buffer", "Viewer correction preempted by sync seek — OK") : I("buffer", "Viewer correction aborted", { error: Fe?.message });
5761
+ Fe === null ? C("buffer", "Viewer correction preempted by sync seek — OK") : C("buffer", "Viewer correction aborted", { error: Fe?.message });
5762
5762
  }
5763
5763
  });
5764
5764
  }
5765
5765
  }
5766
5766
  } catch (G) {
5767
- I("buffer", "Viewer correction failed (non-fatal), prefetch will fill gaps", {
5767
+ C("buffer", "Viewer correction failed (non-fatal), prefetch will fill gaps", {
5768
5768
  error: G?.message
5769
5769
  });
5770
5770
  }
5771
5771
  } catch (ie) {
5772
5772
  if (!R.current && M.getLoadedCount() > 0) {
5773
- I("buffer", "ensureBuffered failed but have buffer — setting mseReady for recovery", {
5773
+ C("buffer", "ensureBuffered failed but have buffer — setting mseReady for recovery", {
5774
5774
  loadedCount: M.getLoadedCount(),
5775
5775
  error: ie?.message
5776
5776
  }), i(!0), R.current = !0;
@@ -5791,17 +5791,17 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5791
5791
  attempt: D.current,
5792
5792
  sbFull: ne,
5793
5793
  initFailed: J
5794
- }), dn(ne ? "sourcebuffer-full" : J ? "init-failed" : "init-retry-cap")) : (ee("buffer", "Initialize playback error — will retry in 3s", {
5794
+ }), ln(ne ? "sourcebuffer-full" : J ? "init-failed" : "init-retry-cap")) : (ee("buffer", "Initialize playback error — will retry in 3s", {
5795
5795
  error: te,
5796
5796
  mediaId: n,
5797
5797
  attempt: D.current
5798
5798
  }), setTimeout(() => {
5799
- C.current && !M.isDisposed && !R.current && (E("buffer", "Retrying initializePlayback"), At().catch(jt));
5799
+ I.current && !M.isDisposed && !R.current && (E("buffer", "Retrying initializePlayback"), At().catch(jt));
5800
5800
  }, 3e3));
5801
5801
  }
5802
5802
  }
5803
5803
  }
5804
- const Vr = fe(() => ({
5804
+ const Kr = fe(() => ({
5805
5805
  useMseAudio: k,
5806
5806
  selectedAudioIndex: we,
5807
5807
  mseAudioTracks: y,
@@ -5818,10 +5818,10 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5818
5818
  fragments: K,
5819
5819
  deliveryFor: de,
5820
5820
  initializePlayback: ie
5821
- } = Vr();
5821
+ } = Kr();
5822
5822
  j.current !== n && (j.current = n, H.current = 0, D.current = 0);
5823
- const te = Nn();
5824
- te && I("buffer", "POST-AUTO-RELOAD — this load follows an auto-reload recovery", {
5823
+ const te = Fn();
5824
+ te && C("buffer", "POST-AUTO-RELOAD — this load follows an auto-reload recovery", {
5825
5825
  reloadAtMs: te,
5826
5826
  sinceReloadMs: Date.now() - te,
5827
5827
  mediaId: n
@@ -5830,12 +5830,12 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5830
5830
  const J = new MediaSource();
5831
5831
  S.current = J;
5832
5832
  const xe = new Ze(at);
5833
- C.current = xe;
5833
+ I.current = xe;
5834
5834
  const Oe = ++Ve.current;
5835
5835
  window.__FRAGMENT_MANAGER__ = xe, window.__AUDIO_FRAGMENT_MANAGERS__ = N.current;
5836
5836
  const ke = new Oo({
5837
5837
  videoRef: r,
5838
- fragmentManagerRef: C,
5838
+ fragmentManagerRef: I,
5839
5839
  audioFragmentManagersRef: N
5840
5840
  });
5841
5841
  re.current = ke, window.__SEEK_COORDINATOR__ = ke, Ho();
@@ -5849,7 +5849,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5849
5849
  }, ce = t.replace(new RegExp(`/${gt.replace(/\./g, "\\.")}$`), ""), _e = () => {
5850
5850
  try {
5851
5851
  const G = `video/mp4; codecs="${g}"`;
5852
- MediaSource.isTypeSupported(G) || (I("mse", `Codec not supported by browser MSE: ${G}`), x.getState().pushToast("error", "Video codec not supported by your browser.")), E("mse", `addSourceBuffer: ${G}`);
5852
+ MediaSource.isTypeSupported(G) || (C("mse", `Codec not supported by browser MSE: ${G}`), x.getState().pushToast("error", "Video codec not supported by your browser.")), E("mse", `addSourceBuffer: ${G}`);
5853
5853
  const se = J.addSourceBuffer(G);
5854
5854
  if (b.current = se, se.addEventListener("error", () => {
5855
5855
  const ae = r.current?.error;
@@ -5861,7 +5861,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5861
5861
  }), xe.setSourceBuffer(se, J), M) {
5862
5862
  const ae = Math.max(0, Math.min(B, pe.length - 1)), ue = pe[ae], me = ue.mse_codec;
5863
5863
  if (!MediaSource.isTypeSupported(me))
5864
- I("mse", `Audio codec not supported: ${me}, track=${ue.track_id}`);
5864
+ C("mse", `Audio codec not supported: ${me}, track=${ue.track_id}`);
5865
5865
  else
5866
5866
  try {
5867
5867
  const Ae = J.addSourceBuffer(me);
@@ -5878,7 +5878,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5878
5878
  );
5879
5879
  Fe.setSourceBuffer(Ae, J), N.current.push(Fe), O.current.push(Ae), Q.current = ae, E("mse", `Audio SB added: codec=${me} track=${ue.track_id} lang=${ue.lang} idx=${ae}`);
5880
5880
  } catch (Ae) {
5881
- I("mse", `Audio SB creation failed for track ${ue.track_id}`, { error: Ae?.message });
5881
+ C("mse", `Audio SB creation failed for track ${ue.track_id}`, { error: Ae?.message });
5882
5882
  }
5883
5883
  const Ue = r.current;
5884
5884
  Ue && (Ue.muted = !1);
@@ -5900,11 +5900,11 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5900
5900
  ie().catch(jt);
5901
5901
  }
5902
5902
  } catch (G) {
5903
- I("buffer", "MSE source error", { error: G?.message });
5903
+ C("buffer", "MSE source error", { error: G?.message });
5904
5904
  }
5905
5905
  };
5906
5906
  return q && (J.addEventListener("sourceopen", _e), ne = URL.createObjectURL(J), q.src = ne, q.addEventListener("error", He)), () => {
5907
- q?.pause(), q && q.removeEventListener("error", He), J.removeEventListener("sourceopen", _e), Uo(), ke.dispose(), re.current = null, xe.dispose(), C.current = null, window.__FRAGMENT_MANAGER__ = null, window.__AUDIO_FRAGMENT_MANAGERS__ = null;
5907
+ q?.pause(), q && q.removeEventListener("error", He), J.removeEventListener("sourceopen", _e), Uo(), ke.dispose(), re.current = null, xe.dispose(), I.current = null, window.__FRAGMENT_MANAGER__ = null, window.__AUDIO_FRAGMENT_MANAGERS__ = null;
5908
5908
  for (const G of N.current) G.dispose();
5909
5909
  if (N.current = [], J.readyState === "open") {
5910
5910
  for (const G of [b.current, ...O.current])
@@ -5922,8 +5922,8 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5922
5922
  Re.current?.(), R.current = !1, T.current = !1, b.current = null, i(!1);
5923
5923
  };
5924
5924
  }, [t, n, g, h, at, V]);
5925
- const zr = fe(() => {
5926
- const M = C.current, B = Ve.current;
5925
+ const Vr = fe(() => {
5926
+ const M = I.current, B = Ve.current;
5927
5927
  if (S.current?.readyState === "open" && b.current && p.length && M) {
5928
5928
  if (M.hasIndex && M.epoch === B) return;
5929
5929
  if (M.setIndex(p, t, h, n, A()), M.epoch = B, k) {
@@ -5943,10 +5943,10 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5943
5943
  }
5944
5944
  });
5945
5945
  L(() => {
5946
- zr();
5946
+ Vr();
5947
5947
  }, [p, t, h, y]), L(() => {
5948
5948
  const M = () => {
5949
- C.current?.abortStaleJobs("socket-reconnect");
5949
+ I.current?.abortStaleJobs("socket-reconnect");
5950
5950
  for (const B of N.current) B.abortStaleJobs("socket-reconnect");
5951
5951
  };
5952
5952
  return window.addEventListener("watchparty:socket-reconnect", M), () => window.removeEventListener("watchparty:socket-reconnect", M);
@@ -5964,7 +5964,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5964
5964
  }
5965
5965
  const M = S.current;
5966
5966
  if (!M || M.readyState !== "open") {
5967
- I("audio", `MSE audio swap skipped — MediaSource readyState=${M?.readyState}`);
5967
+ C("audio", `MSE audio swap skipped — MediaSource readyState=${M?.readyState}`);
5968
5968
  return;
5969
5969
  }
5970
5970
  const B = r.current;
@@ -5976,7 +5976,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5976
5976
  try {
5977
5977
  const te = N.current[0], ne = O.current[0];
5978
5978
  if (!ne) {
5979
- I("audio", "swap skipped — no audio SourceBuffer ref");
5979
+ C("audio", "swap skipped — no audio SourceBuffer ref");
5980
5980
  return;
5981
5981
  }
5982
5982
  te && te.dispose();
@@ -5991,10 +5991,10 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
5991
5991
  ne.remove(0, 1 / 0), await ce;
5992
5992
  }
5993
5993
  } catch (ce) {
5994
- I("audio", "SB clear failed during swap", { error: ce?.message });
5994
+ C("audio", "SB clear failed during swap", { error: ce?.message });
5995
5995
  }
5996
5996
  if (M.readyState !== "open") {
5997
- I("audio", "MSE audio swap aborted mid-flight — MS no longer open");
5997
+ C("audio", "MSE audio swap aborted mid-flight — MS no longer open");
5998
5998
  return;
5999
5999
  }
6000
6000
  const J = new Ze(
@@ -6015,23 +6015,23 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
6015
6015
  const He = J.ensureBuffered(ke, "audio-swap", q.signal);
6016
6016
  J.supersededSignal.addEventListener("abort", () => q.abort(), { once: !0 }), He.catch((ce) => {
6017
6017
  const _e = J.isDisposed || q.signal.aborted;
6018
- (_e ? E : I)("audio", _e ? "audio-swap load superseded by a seek or a later swap" : "audio-swap ensureBuffered failed", { error: ce?.message });
6018
+ (_e ? E : C)("audio", _e ? "audio-swap load superseded by a seek or a later swap" : "audio-swap ensureBuffered failed", { error: ce?.message });
6019
6019
  }), E("audio", `MSE audio swap DONE idx=${pe} track=${K.track_id}`);
6020
6020
  } finally {
6021
6021
  W.current = !1;
6022
6022
  }
6023
6023
  })().catch((te) => ee("audio", "MSE audio swap failed", Y(te)));
6024
- }, [k, s, we, y, n, t, at, A]), tc(re, r, le, s, mt, cn), Xo(r, C, re, s, cn, N), ac(r, re, n, v ?? 0, s, mt);
6025
- const { stopPrefetch: un } = ec(r, C, re, s, Be, N);
6026
- nc(C), L(() => {
6027
- Re.current = un;
6028
- }, [un]);
6029
- const Jr = U(() => {
6024
+ }, [k, s, we, y, n, t, at, A]), tc(re, r, le, s, mt, on), Xo(r, I, re, s, on, N), ac(r, re, n, v ?? 0, s, mt);
6025
+ const { stopPrefetch: dn } = ec(r, I, re, s, Be, N);
6026
+ nc(I), L(() => {
6027
+ Re.current = dn;
6028
+ }, [dn]);
6029
+ const zr = U(() => {
6030
6030
  const M = r.current?.parentElement;
6031
- M && (document.fullscreenElement ? document.exitFullscreen().catch((B) => I("ui", "exitFullscreen failed", Y(B))) : M.requestFullscreen().catch((B) => I("ui", "requestFullscreen failed", Y(B))));
6032
- }, []), Qr = U((M) => {
6031
+ M && (document.fullscreenElement ? document.exitFullscreen().catch((B) => C("ui", "exitFullscreen failed", Y(B))) : M.requestFullscreen().catch((B) => C("ui", "requestFullscreen failed", Y(B))));
6032
+ }, []), Jr = U((M) => {
6033
6033
  M.preventDefault();
6034
- }, []), qr = st && De[z] ? De[z].url : null;
6034
+ }, []), Qr = st && De[z] ? De[z].url : null;
6035
6035
  return /* @__PURE__ */ _(
6036
6036
  "div",
6037
6037
  {
@@ -6046,16 +6046,16 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
6046
6046
  ref: r,
6047
6047
  className: "w-full h-full",
6048
6048
  playsInline: !0,
6049
- onDoubleClick: Jr,
6050
- onContextMenu: Qr
6049
+ onDoubleClick: zr,
6050
+ onContextMenu: Jr
6051
6051
  }
6052
6052
  ),
6053
6053
  /* @__PURE__ */ d(
6054
6054
  xo,
6055
6055
  {
6056
- subtitleUrl: qr,
6056
+ subtitleUrl: Qr,
6057
6057
  videoRef: r,
6058
- style: an,
6058
+ style: sn,
6059
6059
  enabled: st
6060
6060
  }
6061
6061
  ),
@@ -6067,7 +6067,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
6067
6067
  mediaId: n,
6068
6068
  durationMs: v || void 0,
6069
6069
  visible: o,
6070
- displayPlayheadMs: Gr,
6070
+ displayPlayheadMs: jr,
6071
6071
  audioTracks: ye,
6072
6072
  selectedAudioIndex: we,
6073
6073
  onAudioSelect: (M) => {
@@ -6079,9 +6079,9 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
6079
6079
  selectedSubtitleIndex: z,
6080
6080
  onSubtitleSelect: he,
6081
6081
  subtitlesEnabled: st,
6082
- onSubtitlesToggle: jr,
6083
- subtitleStyle: an,
6084
- onSubtitleStyleChange: Br,
6082
+ onSubtitlesToggle: Ur,
6083
+ subtitleStyle: sn,
6084
+ onSubtitleStyleChange: Pr,
6085
6085
  onChatActivity: () => c(5e3),
6086
6086
  onMenuHeld: f
6087
6087
  }
@@ -6092,7 +6092,7 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
6092
6092
  type: "button",
6093
6093
  onClick: () => {
6094
6094
  const M = r.current;
6095
- M && (M.muted = !1), Pr(!1);
6095
+ M && (M.muted = !1), $r(!1);
6096
6096
  },
6097
6097
  className: "autoplay-sound-badge",
6098
6098
  children: [
@@ -6111,12 +6111,12 @@ function lc({ mediaUrl: t, indexUrl: e, mediaId: n }) {
6111
6111
  }
6112
6112
  function dc() {
6113
6113
  const t = x((n) => n.snapshot.mediaId), e = Ee(() => t ? { mediaId: t, ...qn(t) } : null, [t]);
6114
- return e ? /* @__PURE__ */ d(nr, { children: /* @__PURE__ */ d(lc, { mediaUrl: e.mediaUrl, indexUrl: e.indexUrl, mediaId: e.mediaId }) }) : /* @__PURE__ */ d(Gs, {});
6114
+ return e ? /* @__PURE__ */ d(nr, { children: /* @__PURE__ */ d(lc, { mediaUrl: e.mediaUrl, indexUrl: e.indexUrl, mediaId: e.mediaId }) }) : /* @__PURE__ */ d(js, {});
6115
6115
  }
6116
6116
  const uc = (t) => {
6117
- const e = Zs(t);
6117
+ const e = Xs(t);
6118
6118
  return e.render(
6119
- /* @__PURE__ */ d(Us.Provider, { value: js(), children: /* @__PURE__ */ d(dc, {}) })
6119
+ /* @__PURE__ */ d(Hs.Provider, { value: Us(), children: /* @__PURE__ */ d(dc, {}) })
6120
6120
  ), {
6121
6121
  update() {
6122
6122
  },
@@ -6134,12 +6134,12 @@ const uc = (t) => {
6134
6134
  id: "player",
6135
6135
  name: "Media player",
6136
6136
  load: () => Promise.resolve(fc)
6137
- }, pc = qt(() => import("./MediaDrawer-kz_YdaqY.js"));
6137
+ }, pc = Qt(() => import("./MediaDrawer-CXffVb5D.js"));
6138
6138
  function mc() {
6139
6139
  const t = x((u) => u.snapshot), e = x((u) => u.ensureAutoIdentity), n = Et(), r = Ee(
6140
6140
  () => n ? Za(n, window.location.origin) : null,
6141
6141
  [n]
6142
- ), s = Ws(), i = P(!1), [a, l] = $(!1), o = s.roomKey || null;
6142
+ ), s = Gs(), i = P(!1), [a, l] = $(!1), o = s.roomKey || null;
6143
6143
  Pi(), L(() => Bi(), []), L(() => {
6144
6144
  o && Ui(o);
6145
6145
  }, [o]), L(() => {
@@ -6153,20 +6153,20 @@ function mc() {
6153
6153
  try {
6154
6154
  await Promise.race([
6155
6155
  Promise.all([
6156
+ Ws(),
6156
6157
  Ks(),
6157
- Vs(),
6158
- zs().then(zn)
6158
+ Vs().then(zn)
6159
6159
  ]),
6160
6160
  new Promise((g) => setTimeout(g, f))
6161
6161
  ]);
6162
6162
  } catch (g) {
6163
- I("room", "pre-join wait threw, proceeding anyway", { err: g?.message });
6163
+ C("room", "pre-join wait threw, proceeding anyway", { err: g?.message });
6164
6164
  }
6165
6165
  if (u) return;
6166
6166
  const p = x.getState();
6167
6167
  E("room", "Joining room", { roomKey: o, name: p.name, sprite: p.sprite }), e();
6168
6168
  const v = x.getState();
6169
- Js({
6169
+ zs({
6170
6170
  room_key: o,
6171
6171
  name: v.name || void 0,
6172
6172
  sprite: v.sprite || void 0
@@ -6180,8 +6180,8 @@ function mc() {
6180
6180
  }
6181
6181
  return o ? /* @__PURE__ */ _("div", { className: "relative flex-1 flex overflow-hidden min-h-0", children: [
6182
6182
  /* @__PURE__ */ _("div", { className: "flex-1 relative bg-black overflow-hidden min-w-0", children: [
6183
- /* @__PURE__ */ d(wn, { activity: hc, roomKey: t.roomId ?? "", layer: "base" }),
6184
- r && t.roomId && /* @__PURE__ */ d(nr, { children: /* @__PURE__ */ d(wn, { activity: r, roomKey: t.roomId, layer: "overlay" }, r.id) }),
6183
+ /* @__PURE__ */ d(Sn, { activity: hc, roomKey: t.roomId ?? "", layer: "base" }),
6184
+ r && t.roomId && /* @__PURE__ */ d(nr, { children: /* @__PURE__ */ d(Sn, { activity: r, roomKey: t.roomId, layer: "overlay" }, r.id) }),
6185
6185
  /* @__PURE__ */ _(vi, { children: [
6186
6186
  /* @__PURE__ */ d(ii, {}),
6187
6187
  /* @__PURE__ */ d(mi, {}),
@@ -6191,7 +6191,7 @@ function mc() {
6191
6191
  ] }),
6192
6192
  /* @__PURE__ */ d(qa, {}),
6193
6193
  /* @__PURE__ */ d(Ke.Suspense, { fallback: /* @__PURE__ */ d(ri, { open: a, onClose: c }), children: /* @__PURE__ */ d(pc, { open: a, onClose: c }) })
6194
- ] }) : (I("room", "No room key provided"), /* @__PURE__ */ d("div", { className: "flex-1 flex items-center justify-center p-6", children: /* @__PURE__ */ _("div", { className: "text-text-secondary", children: [
6194
+ ] }) : (C("room", "No room key provided"), /* @__PURE__ */ d("div", { className: "flex-1 flex items-center justify-center p-6", children: /* @__PURE__ */ _("div", { className: "text-text-secondary", children: [
6195
6195
  "No room key provided. Go to the ",
6196
6196
  /* @__PURE__ */ d("a", { href: "/", className: "underline", children: "home page" }),
6197
6197
  " to select a room."
@@ -6211,6 +6211,6 @@ export {
6211
6211
  Ec as c,
6212
6212
  nt as d,
6213
6213
  _c as s,
6214
- tn as u
6214
+ en as u
6215
6215
  };
6216
- //# sourceMappingURL=Room-DgBCVk-f.js.map
6216
+ //# sourceMappingURL=Room-CQy_wCnX.js.map