@hadoku/watchparty-ui 0.45.96 → 0.45.97

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.
@@ -558,7 +558,10 @@ const ut = o.enum(["anilist", "tmdb"]), uo = o.object({
558
558
  * Not addable: a movie, or a title with no usable Latin-script name. The
559
559
  * scraper matches releases by `SxxExx`, so a film can never arrive through it.
560
560
  */
561
- addable: o.boolean()
561
+ addable: o.boolean(),
562
+ /** AniList links this entry to another season (a PREQUEL or SEQUEL), so the
563
+ * drawer offers its season list (`GET /api/search/seasons`). */
564
+ hasSeasons: o.boolean()
562
565
  });
563
566
  o.object({
564
567
  results: o.array(uo),
@@ -574,6 +577,22 @@ const mo = o.object({
574
577
  thumb: o.string().nullable()
575
578
  });
576
579
  o.object({ results: o.array(mo) });
580
+ const fo = o.object({
581
+ id: o.string(),
582
+ title: o.string(),
583
+ /** 1-based position in the chain. */
584
+ number: o.number().int(),
585
+ /** When it first aired; either may be null for an unannounced season. */
586
+ year: o.number().int().nullable(),
587
+ month: o.number().int().min(1).max(12).nullable(),
588
+ episodes: o.number().int().nullable(),
589
+ format: o.string().nullable(),
590
+ onWatchlist: o.boolean()
591
+ });
592
+ o.object({
593
+ /** Requested id → its show's seasons. An id AniList does not know is absent. */
594
+ chains: o.record(o.string(), o.array(fo))
595
+ });
577
596
  o.object({
578
597
  source: ut,
579
598
  id: o.string().regex(/^\d{1,12}$/)
@@ -585,7 +604,7 @@ o.object({
585
604
  * chain), or null when it could not tell. */
586
605
  season: o.number().int().nullable()
587
606
  });
588
- const fo = 99, po = o.object({
607
+ const po = 99, ho = o.object({
589
608
  id: o.number().int(),
590
609
  series: o.string(),
591
610
  season: o.number().int().nullable(),
@@ -605,14 +624,14 @@ const fo = 99, po = o.object({
605
624
  * is unknown. */
606
625
  episodes: o.object({ ready: o.number().int(), downloaded: o.number().int() }).nullable()
607
626
  });
608
- o.object({ entries: o.array(po) });
627
+ o.object({ entries: o.array(ho) });
609
628
  o.object({
610
- season: o.number().int().min(1).max(fo).nullable().optional(),
629
+ season: o.number().int().min(1).max(po).nullable().optional(),
611
630
  title: o.string().trim().min(1).max(200).optional(),
612
631
  retired: o.boolean().optional()
613
632
  }).strict().refine((e) => e.season !== void 0 || e.title !== void 0 || e.retired !== void 0, { message: "nothing to change" });
614
633
  let xe = null, _n = on;
615
- function ho(e) {
634
+ function go(e) {
616
635
  e.cdnBase && (_n = e.cdnBase);
617
636
  }
618
637
  function wn() {
@@ -625,7 +644,7 @@ function Ge() {
625
644
  function je(e) {
626
645
  return !st(e) || !wn() ? null : Ge().urlFor(e);
627
646
  }
628
- function go(e) {
647
+ function yo(e) {
629
648
  return e.kind === "file";
630
649
  }
631
650
  class Sn extends Error {
@@ -653,42 +672,42 @@ function Ae(e) {
653
672
  return "Image upload failed";
654
673
  }
655
674
  }
656
- function yo(e) {
675
+ function bo(e) {
657
676
  return e instanceof et ? Ae(e.reason) : e instanceof Sn ? e.message : "Image upload failed";
658
677
  }
659
- function bo(e) {
678
+ function vo(e) {
660
679
  const t = e.type.toLowerCase().split(";")[0].trim();
661
680
  return t && lr(t) !== "image" ? Ae("unsupported-type") : e.size > cr.image ? Ae("too-large") : e.size === 0 ? Ae("invalid") : null;
662
681
  }
663
- function vo(e) {
682
+ function _o(e) {
664
683
  return ur(e);
665
684
  }
666
- function _o(e) {
685
+ function wo(e) {
667
686
  return mr(e);
668
687
  }
669
- async function wo(e) {
688
+ async function So(e) {
670
689
  const t = await dr(e);
671
690
  return { w: t?.width ?? 0, h: t?.height ?? 0 };
672
691
  }
673
- async function So(e, t = {}) {
692
+ async function xo(e, t = {}) {
674
693
  const n = await Ge().upload(e, { signal: t.signal });
675
694
  if (!st(n.key))
676
695
  throw new Sn("Image upload returned an unusable key");
677
696
  return { key: n.key, deduplicated: n.deduplicated === !0 };
678
697
  }
679
- async function xo(e, t = {}) {
698
+ async function Co(e, t = {}) {
680
699
  const n = [];
681
700
  for (const r of e) {
682
701
  if (r.kind === "remote") {
683
702
  n.push({ key: r.key, w: r.w, h: r.h, ...r.title ? { title: r.title } : {} });
684
703
  continue;
685
704
  }
686
- const { key: a } = await So(r.file, t);
705
+ const { key: a } = await xo(r.file, t);
687
706
  n.push({ key: a, w: r.w, h: r.h });
688
707
  }
689
708
  return n;
690
709
  }
691
- function Co(e) {
710
+ function Io(e) {
692
711
  return {
693
712
  error: e instanceof Error ? e.message : String(e),
694
713
  name: e instanceof Error ? e.name : typeof e,
@@ -699,30 +718,30 @@ function Co(e) {
699
718
  function mt(e) {
700
719
  return e.key === "Escape" || e.key === "GoBack" || e.key === "BrowserBack" || e.key === "XF86Back" || e.keyCode === 461 || e.keyCode === 10009;
701
720
  }
702
- function Io(e) {
721
+ function To(e) {
703
722
  return `/tv?return=${encodeURIComponent(e.pathname + e.search)}`;
704
723
  }
705
- function To({ className: e }) {
724
+ function ko({ className: e }) {
706
725
  return /* @__PURE__ */ c(
707
726
  "a",
708
727
  {
709
- href: Io(window.location),
728
+ href: To(window.location),
710
729
  className: e,
711
730
  "data-testid": "sign-in-with-code",
712
731
  children: "Sign in with a code"
713
732
  }
714
733
  );
715
734
  }
716
- const nt = 240, ne = 8, ko = 28, xn = 240;
717
- function Eo(e, t, n) {
735
+ const nt = 240, ne = 8, Eo = 28, xn = 240;
736
+ function Ao(e, t, n) {
718
737
  let r = t.left - nt - ne;
719
738
  r < ne && (r = t.right + ne), r = Math.min(r, n.width - nt - ne), r = Math.max(ne, r);
720
- const a = xn + ko;
739
+ const a = xn + Eo;
721
740
  let i = e.top + e.height / 2 - a / 2;
722
741
  return i = Math.min(i, n.height - a - ne), i = Math.max(ne, i), { left: r, top: i };
723
742
  }
724
- const Cn = "/dataplatform/api/memes", Ao = 120;
725
- function No({ onClose: e, onPick: t, onUnavailable: n }) {
743
+ const Cn = "/dataplatform/api/memes", No = 120;
744
+ function Po({ onClose: e, onPick: t, onUnavailable: n }) {
726
745
  const [r, a] = k(""), i = G(null), s = G(null), l = Ge(), { items: d, loading: h, error: f, hasMore: M, loadMore: R } = Nr(
727
746
  l,
728
747
  Cn,
@@ -740,12 +759,12 @@ function No({ onClose: e, onPick: t, onUnavailable: n }) {
740
759
  if (!F) return;
741
760
  const ae = () => x({
742
761
  item: C,
743
- ...Eo(O.getBoundingClientRect(), F.getBoundingClientRect(), {
762
+ ...Ao(O.getBoundingClientRect(), F.getBoundingClientRect(), {
744
763
  width: window.innerWidth,
745
764
  height: window.innerHeight
746
765
  })
747
766
  });
748
- y(), P ? ae() : w.current = window.setTimeout(ae, Ao);
767
+ y(), P ? ae() : w.current = window.setTimeout(ae, No);
749
768
  },
750
769
  [y]
751
770
  );
@@ -803,7 +822,7 @@ function No({ onClose: e, onPick: t, onUnavailable: n }) {
803
822
  "data-reason": D,
804
823
  children: D === "unauthenticated" ? /* @__PURE__ */ _(le, { children: [
805
824
  "Sign in to browse memes · ",
806
- /* @__PURE__ */ c(To, { className: "underline text-on-danger-bg" })
825
+ /* @__PURE__ */ c(ko, { className: "underline text-on-danger-bg" })
807
826
  ] }) : D === "forbidden" ? "Your account can't browse the meme library" : "Meme library is unavailable"
808
827
  }
809
828
  ),
@@ -890,8 +909,8 @@ function No({ onClose: e, onPick: t, onUnavailable: n }) {
890
909
  }
891
910
  );
892
911
  }
893
- function Po({ open: e, ...t }) {
894
- return e ? /* @__PURE__ */ c(No, { ...t }) : null;
912
+ function Ro({ open: e, ...t }) {
913
+ return e ? /* @__PURE__ */ c(Po, { ...t }) : null;
895
914
  }
896
915
  const ft = {
897
916
  serverOrigin: `http://localhost:${lt}`,
@@ -899,24 +918,24 @@ const ft = {
899
918
  cdnBase: on
900
919
  };
901
920
  let Ne = { ...ft };
902
- function Ro(e) {
921
+ function Do(e) {
903
922
  const t = Object.fromEntries(
904
923
  Object.entries(e).filter(([n, r]) => r !== void 0)
905
924
  );
906
- Ne = { ...Ne, ...t }, ho({ cdnBase: Ne.cdnBase });
925
+ Ne = { ...Ne, ...t }, go({ cdnBase: Ne.cdnBase });
907
926
  }
908
927
  function _e() {
909
928
  return Ne;
910
929
  }
911
- const Do = it(ft);
912
- function Oo(e) {
930
+ const Oo = it(ft);
931
+ function Mo(e) {
913
932
  return e.serverOrigin?.replace(/\/$/, "") || "";
914
933
  }
915
934
  function In() {
916
- return Oo(_e());
935
+ return Mo(_e());
917
936
  }
918
937
  const Tn = it(null);
919
- function Mo() {
938
+ function Lo() {
920
939
  return Zt(Tn);
921
940
  }
922
941
  const kn = it(!0);
@@ -935,7 +954,7 @@ const ge = Le.memo(
935
954
  },
936
955
  (e, t) => e.html === t.html && e.as === t.as && e.className === t.className && JSON.stringify(e.style) === JSON.stringify(t.style)
937
956
  );
938
- function Lo(e, t) {
957
+ function jo(e, t) {
939
958
  E(() => {
940
959
  const n = e.current;
941
960
  if (!n || !t || typeof IntersectionObserver > "u") return;
@@ -975,7 +994,7 @@ function pt(e, t) {
975
994
  return !1;
976
995
  }
977
996
  }
978
- function jo() {
997
+ function Uo() {
979
998
  try {
980
999
  const e = qe();
981
1000
  if (!e) return [];
@@ -995,7 +1014,7 @@ function Ue(e) {
995
1014
  } catch {
996
1015
  }
997
1016
  }
998
- function Uo(e) {
1017
+ function Ho(e) {
999
1018
  const t = W(e);
1000
1019
  return t === null ? null : t === "true" ? !0 : t === "false" ? !1 : null;
1001
1020
  }
@@ -1004,16 +1023,16 @@ let Pn = !1;
1004
1023
  function Ve(e, t) {
1005
1024
  Nn.set(e, t), Pn && Rn(e, t);
1006
1025
  }
1007
- function Ho() {
1026
+ function Fo() {
1008
1027
  Pn = !0;
1009
1028
  for (const [e, t] of Nn) Rn(e, t);
1010
1029
  }
1011
1030
  function Rn(e, t) {
1012
1031
  typeof window > "u" || (window[e] = t);
1013
1032
  }
1014
- const pe = [], Fo = 500;
1033
+ const pe = [], $o = 500;
1015
1034
  let Pe = [], rt = null;
1016
- const $o = 1e3, Bo = 200;
1035
+ const Bo = 1e3, Wo = 200;
1017
1036
  let ot = null;
1018
1037
  function Dn(e) {
1019
1038
  ot = e;
@@ -1021,19 +1040,19 @@ function Dn(e) {
1021
1040
  function On() {
1022
1041
  return W(de.REPORT_LOGS_FLAG) === "true";
1023
1042
  }
1024
- function Wo() {
1043
+ function Go() {
1025
1044
  if (typeof window > "u") return !1;
1026
1045
  if (window.__WP_DEBUG__ || new URLSearchParams(window.location.search).get("debug") === "true") return !0;
1027
1046
  const t = W(de.DEBUG_FLAG);
1028
1047
  return t !== null && t !== "false";
1029
1048
  }
1030
- function Go() {
1049
+ function qo() {
1031
1050
  const e = W(de.DEBUG_FLAG);
1032
1051
  if (!e || e === "true") return null;
1033
1052
  const t = e.split(",").map((n) => n.trim().toLowerCase()).filter(Boolean);
1034
1053
  return t.length > 0 ? new Set(t) : null;
1035
1054
  }
1036
- function qo() {
1055
+ function Vo() {
1037
1056
  return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
1038
1057
  hour12: !1,
1039
1058
  hour: "2-digit",
@@ -1042,8 +1061,8 @@ function qo() {
1042
1061
  fractionalSecondDigits: 3
1043
1062
  });
1044
1063
  }
1045
- function Vo(e) {
1046
- pe.push(e), pe.length > Fo && pe.shift();
1064
+ function Ko(e) {
1065
+ pe.push(e), pe.length > $o && pe.shift();
1047
1066
  }
1048
1067
  const Ke = {
1049
1068
  debug: "color: #64748b; font-weight: normal;",
@@ -1052,7 +1071,7 @@ const Ke = {
1052
1071
  category: "color: #3b82f6; font-weight: bold;",
1053
1072
  time: "color: #6b7280; font-weight: normal;"
1054
1073
  };
1055
- function Ko(e) {
1074
+ function Yo(e) {
1056
1075
  try {
1057
1076
  return JSON.stringify(e);
1058
1077
  } catch {
@@ -1067,12 +1086,12 @@ function ht(e, t, n, r, a, i, s) {
1067
1086
  data: s,
1068
1087
  timestamp: Date.now()
1069
1088
  };
1070
- if (Vo(l), (n || On()) && Et(l), !r) {
1071
- if (!Wo()) return;
1072
- const f = Go();
1089
+ if (Ko(l), (n || On()) && Et(l), !r) {
1090
+ if (!Go()) return;
1091
+ const f = qo();
1073
1092
  if (f && !f.has(a.toLowerCase())) return;
1074
1093
  }
1075
- const d = qo(), h = s !== void 0 ? " " + Ko(s) : "";
1094
+ const d = Vo(), h = s !== void 0 ? " " + Yo(s) : "";
1076
1095
  t(
1077
1096
  `%c[${d}]%c [${a}]%c ${i}${h}`,
1078
1097
  Ke.time,
@@ -1089,25 +1108,25 @@ function I(e, t, n) {
1089
1108
  function Re(e, t, n) {
1090
1109
  ht("error", console.error, !0, !0, e, t, n);
1091
1110
  }
1092
- function Yo() {
1111
+ function Xo() {
1093
1112
  return [...pe];
1094
1113
  }
1095
- function Xo() {
1114
+ function zo() {
1096
1115
  pe.length = 0;
1097
1116
  }
1098
- function zo(e) {
1117
+ function Jo(e) {
1099
1118
  const t = e && e.length > 0 ? e.join(",") : "true";
1100
1119
  pt(de.DEBUG_FLAG, t), console.log("[wp] Debug mode enabled");
1101
1120
  }
1102
- function Jo() {
1121
+ function Qo() {
1103
1122
  Ue(de.DEBUG_FLAG), console.log("[wp] Debug mode disabled");
1104
1123
  }
1105
- const Qo = 1024, Zo = 5e4;
1106
- function ea(e) {
1124
+ const Zo = 1024, ea = 5e4;
1125
+ function ta(e) {
1107
1126
  if (e == null) return e;
1108
1127
  try {
1109
1128
  const t = JSON.stringify(e);
1110
- if (t.length <= Qo) return e;
1129
+ if (t.length <= Zo) return e;
1111
1130
  if (typeof e == "object" && !Array.isArray(e)) {
1112
1131
  const n = {};
1113
1132
  for (const [r, a] of Object.entries(e)) {
@@ -1121,7 +1140,7 @@ function ea(e) {
1121
1140
  return "[unserializable]";
1122
1141
  }
1123
1142
  }
1124
- async function ta() {
1143
+ async function na() {
1125
1144
  if (Pe.length === 0) return;
1126
1145
  const e = Pe;
1127
1146
  Pe = [], rt = null;
@@ -1135,7 +1154,7 @@ async function ta() {
1135
1154
  level: l.level,
1136
1155
  category: l.category,
1137
1156
  message: l.message,
1138
- data: ea(l.data),
1157
+ data: ta(l.data),
1139
1158
  timestamp: l.timestamp,
1140
1159
  url: typeof window < "u" ? window.location.href : void 0,
1141
1160
  userAgent: typeof navigator < "u" ? navigator.userAgent : void 0,
@@ -1145,7 +1164,7 @@ async function ta() {
1145
1164
  let i = [], s = 0;
1146
1165
  for (const l of a) {
1147
1166
  const d = JSON.stringify(l).length + 1;
1148
- s + d > Zo && i.length > 0 && (await fetch(r, {
1167
+ s + d > ea && i.length > 0 && (await fetch(r, {
1149
1168
  method: "POST",
1150
1169
  headers: { "Content-Type": "application/json" },
1151
1170
  body: JSON.stringify({ logs: i })
@@ -1162,9 +1181,9 @@ async function ta() {
1162
1181
  }
1163
1182
  function Et(e) {
1164
1183
  if (Pe.push(e), !rt) {
1165
- const t = On() ? Bo : $o;
1184
+ const t = On() ? Wo : Bo;
1166
1185
  rt = setTimeout(() => {
1167
- ta();
1186
+ na();
1168
1187
  }, t);
1169
1188
  }
1170
1189
  }
@@ -1172,16 +1191,16 @@ function we(e) {
1172
1191
  return e instanceof Error ? { error: e.message, name: e.name } : { error: String(e), name: typeof e };
1173
1192
  }
1174
1193
  Ve("__wpDebug", {
1175
- enable: zo,
1176
- disable: Jo,
1177
- history: Yo,
1178
- clear: Xo
1194
+ enable: Jo,
1195
+ disable: Qo,
1196
+ history: Xo,
1197
+ clear: zo
1179
1198
  });
1180
- const na = 1280;
1181
- function ra(e) {
1182
- return e.screenWidth < na ? !1 : e.noHoverNoPointer || e.anyHoverNone && e.maxTouchPoints === 0;
1199
+ const ra = 1280;
1200
+ function oa(e) {
1201
+ return e.screenWidth < ra ? !1 : e.noHoverNoPointer || e.anyHoverNone && e.maxTouchPoints === 0;
1183
1202
  }
1184
- function oa() {
1203
+ function aa() {
1185
1204
  const e = (t) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(t).matches;
1186
1205
  return {
1187
1206
  noHoverNoPointer: e("(hover: none) and (pointer: none)"),
@@ -1191,11 +1210,11 @@ function oa() {
1191
1210
  };
1192
1211
  }
1193
1212
  let At = null;
1194
- function aa() {
1195
- return At ??= ra(oa()), At;
1213
+ function ia() {
1214
+ return At ??= oa(aa()), At;
1196
1215
  }
1197
1216
  function Nt() {
1198
- return aa();
1217
+ return ia();
1199
1218
  }
1200
1219
  const Q = {
1201
1220
  resolved: !1,
@@ -1205,23 +1224,23 @@ const Q = {
1205
1224
  function gt() {
1206
1225
  return Q.accountId ? Q.accountId : Q.resolved && Q.userType === "public" ? "anon" : null;
1207
1226
  }
1208
- function ia(e) {
1227
+ function sa(e) {
1209
1228
  Q.resolved = !0, e.userType && (Q.userType = e.userType), e.userId !== void 0 && (Q.accountId = e.userId && e.userId !== "public" ? e.userId : null);
1210
1229
  }
1211
1230
  function yt() {
1212
1231
  return Q.accountId ?? "public";
1213
1232
  }
1214
- function sa() {
1233
+ function la() {
1215
1234
  return gt() ?? "unscoped";
1216
1235
  }
1217
1236
  function Mn(e) {
1218
1237
  return We(e) ? Kr[e] : "var(--color-neutral-bg)";
1219
1238
  }
1220
- function la(e) {
1239
+ function ca(e) {
1221
1240
  return We(e) ? `${_e().serverOrigin.replace(/\/$/, "")}${Xr(e)}` : void 0;
1222
1241
  }
1223
1242
  let ye = null, Ce = null;
1224
- function ca() {
1243
+ function da() {
1225
1244
  return ye ? Promise.resolve() : Ce || (Ce = (async () => {
1226
1245
  try {
1227
1246
  const e = _e().serverOrigin.replace(/\/$/, ""), t = await fetch(`${e}/media/sprites/names.json`, { cache: "no-cache" });
@@ -1240,7 +1259,7 @@ function re(e) {
1240
1259
  const t = e.toLowerCase();
1241
1260
  return Be.some((n) => n === t) ? !0 : ye ? Object.values(ye).some((n) => n.toLowerCase() === t) : !1;
1242
1261
  }
1243
- const da = o.object({
1262
+ const ua = o.object({
1244
1263
  // Identity. There is deliberately NO `name`: a person's name is their
1245
1264
  // hadoku key-registry name, resolved by the server from whoami and renamed
1246
1265
  // through hadoku_site's POST /session/name (operator decision 2026-10-08).
@@ -1267,13 +1286,13 @@ const da = o.object({
1267
1286
  subtitleStyle: o.string().optional()
1268
1287
  }), he = Sr({
1269
1288
  appId: "watchparty",
1270
- schema: da
1271
- }), ua = /* @__PURE__ */ new Set(["theme", "themeMode"]);
1289
+ schema: ua
1290
+ }), ma = /* @__PURE__ */ new Set(["theme", "themeMode"]);
1272
1291
  function He(e) {
1273
1292
  const t = gt();
1274
1293
  return t ? `prefs-cache:${t}:${e}` : null;
1275
1294
  }
1276
- function ma() {
1295
+ function fa() {
1277
1296
  return gt() === null;
1278
1297
  }
1279
1298
  function Pt(e) {
@@ -1287,9 +1306,9 @@ function Pt(e) {
1287
1306
  return {};
1288
1307
  }
1289
1308
  }
1290
- function fa() {
1309
+ function pa() {
1291
1310
  let e = 0;
1292
- for (const t of jo()) {
1311
+ for (const t of Uo()) {
1293
1312
  const n = t.startsWith("prefs-cache:") && t.endsWith(":watchparty"), r = t === Fe || t.startsWith(`${Fe}:`) && !t.endsWith(":_serverSynced_v1");
1294
1313
  if (!n && !r) continue;
1295
1314
  const a = W(t);
@@ -1310,7 +1329,7 @@ function fa() {
1310
1329
  let Ln = null, jn = null;
1311
1330
  const Rt = /* @__PURE__ */ new Set();
1312
1331
  function bt() {
1313
- if (ma())
1332
+ if (fa())
1314
1333
  return u("preferences", "Boot read deferred — session pending, identity unresolved"), {};
1315
1334
  const e = Pt("portfolio"), t = Pt("watchparty"), n = Object.keys(e).length > 0 ? e : Ln ?? {}, r = Object.keys(t).length > 0 ? t : jn ?? {}, a = yt() || "public";
1316
1335
  if (Rt.has(a))
@@ -1335,15 +1354,15 @@ function bt() {
1335
1354
  }), s;
1336
1355
  }
1337
1356
  let Un = !1;
1338
- function pa() {
1357
+ function ha() {
1339
1358
  const e = yt();
1340
1359
  return !e || e === "public";
1341
1360
  }
1342
1361
  function q(e, t) {
1343
- pa() && (Un = !0), ua.has(e) ? fe.save({ [e]: t }, { scope: "device" }).catch((n) => I("preferences", "themePrefs.save failed", { key: e, err: n?.message })) : he.save({ [e]: t }).catch((n) => I("preferences", "watchpartyPrefs.save failed", { key: e, err: n?.message })), u("preferences", "Saved (via SDK)", { key: e, value: t });
1362
+ ha() && (Un = !0), ma.has(e) ? fe.save({ [e]: t }, { scope: "device" }).catch((n) => I("preferences", "themePrefs.save failed", { key: e, err: n?.message })) : he.save({ [e]: t }).catch((n) => I("preferences", "watchpartyPrefs.save failed", { key: e, err: n?.message })), u("preferences", "Saved (via SDK)", { key: e, value: t });
1344
1363
  }
1345
1364
  let Ie = null, Dt = !1;
1346
- function ha() {
1365
+ function ga() {
1347
1366
  return Ie || (Ie = (async () => {
1348
1367
  if (typeof window > "u") return !1;
1349
1368
  try {
@@ -1369,7 +1388,7 @@ function ha() {
1369
1388
  // Post-fetch cache state: should be non-zero if SDK wrote it.
1370
1389
  sdkThemeBytesPost: a?.length ?? 0,
1371
1390
  sdkAppBytesPost: i?.length ?? 0
1372
- }), await ga(e, t), Un ? (u("preferences", "Promoting this load's pre-auth picks to the signed-in user"), await Promise.all([
1391
+ }), await ya(e, t), Un ? (u("preferences", "Promoting this load's pre-auth picks to the signed-in user"), await Promise.all([
1373
1392
  fe.promoteAnonPrefsToUser().catch(() => {
1374
1393
  }),
1375
1394
  he.promoteAnonPrefsToUser().catch(() => {
@@ -1381,7 +1400,7 @@ function ha() {
1381
1400
  })(), Ie);
1382
1401
  }
1383
1402
  const Fe = "watchparty_preferences";
1384
- fa();
1403
+ pa();
1385
1404
  function at() {
1386
1405
  const e = yt();
1387
1406
  return !e || e === "public" ? Fe : `${Fe}:${e}`;
@@ -1399,7 +1418,7 @@ function Hn() {
1399
1418
  function Ot() {
1400
1419
  Ue(at()), Ue(`${at()}:_serverSynced_v1`);
1401
1420
  }
1402
- async function ga(e, t) {
1421
+ async function ya(e, t) {
1403
1422
  const n = Hn();
1404
1423
  if (!n || Object.keys(n).length === 0) return;
1405
1424
  const r = Object.keys(e ?? {}).length > 0, a = Object.keys(t ?? {}).length > 0, i = {}, s = {};
@@ -1456,16 +1475,16 @@ function jt(e) {
1456
1475
  }
1457
1476
  }).catch((t) => I("preferences", "store import failed", { reason: e, err: t?.message }));
1458
1477
  }
1459
- const Fn = 320, $e = 240, vt = 640, ya = 320, ba = 36, Ut = 16;
1478
+ const Fn = 320, $e = 240, vt = 640, ba = 320, va = 36, Ut = 16;
1460
1479
  function Y(e, t) {
1461
1480
  if (!Number.isFinite(e)) return Fn;
1462
1481
  let n = vt;
1463
- return t !== void 0 && Number.isFinite(t) && t > 0 && (n = Math.min(n, t - ya)), n = Math.max(n, $e), Math.round(Math.min(n, Math.max($e, e)));
1482
+ return t !== void 0 && Number.isFinite(t) && t > 0 && (n = Math.min(n, t - ba)), n = Math.max(n, $e), Math.round(Math.min(n, Math.max($e, e)));
1464
1483
  }
1465
1484
  function Ht(e, t, n, r) {
1466
1485
  return Y(e + (t - n), r);
1467
1486
  }
1468
- function va(e, t, n) {
1487
+ function _a(e, t, n) {
1469
1488
  switch (t) {
1470
1489
  case "ArrowLeft":
1471
1490
  return Y(e + Ut, n);
@@ -1479,8 +1498,8 @@ function va(e, t, n) {
1479
1498
  return null;
1480
1499
  }
1481
1500
  }
1482
- function _a(e, t) {
1483
- return { collapsed: e, width: e ? ba : t };
1501
+ function wa(e, t) {
1502
+ return { collapsed: e, width: e ? va : t };
1484
1503
  }
1485
1504
  function $n(e, t) {
1486
1505
  const n = new Set(t.map((i) => i.id)), r = t.reduce((i, s) => Math.max(i, s.ts), -1 / 0), a = e.filter((i) => !n.has(i.id) && i.ts > r);
@@ -1721,7 +1740,7 @@ function Wn(e) {
1721
1740
  const t = typeof window < "u" ? window.location.href : "http://localhost/", n = new URL(e, t).pathname;
1722
1741
  return `${n.endsWith("/") ? n : `${n}/`}socket.io/`;
1723
1742
  }
1724
- function wa(e) {
1743
+ function Sa(e) {
1725
1744
  const t = typeof window < "u" ? window.location.href : "http://localhost/", n = e.namespace ?? "/chat";
1726
1745
  return {
1727
1746
  url: `${new URL(e.origin, t).origin}${n.startsWith("/") ? n : `/${n}`}`,
@@ -1735,12 +1754,12 @@ function Ft(e) {
1735
1754
  function _t() {
1736
1755
  return K !== null;
1737
1756
  }
1738
- function Sa(e) {
1757
+ function xa(e) {
1739
1758
  if (K)
1740
1759
  if (De = e, Z)
1741
1760
  Z.connected && Z.emit(v.JOIN, e);
1742
1761
  else {
1743
- const { url: t, path: n } = wa(K), r = tt(t, { path: n, transports: ["websocket", "polling"] });
1762
+ const { url: t, path: n } = Sa(K), r = tt(t, { path: n, transports: ["websocket", "polling"] });
1744
1763
  Z = r, u("chat", "External chat socket", { url: t, path: n }), qn(r), r.on(v.ERROR, (a) => {
1745
1764
  const i = a?.message || a?.code || "chat error";
1746
1765
  I("chat", `Chat server error: ${i}`, { code: a?.code }), m.getState().pushToast("error", i);
@@ -1749,7 +1768,7 @@ function Sa(e) {
1749
1768
  }), r.on("connect_error", (a) => I("chat", "Chat connection error", { message: a?.message }));
1750
1769
  }
1751
1770
  }
1752
- function xa(e) {
1771
+ function Ca(e) {
1753
1772
  Z?.emit(v.CHAT_SEND, e);
1754
1773
  }
1755
1774
  function Gn() {
@@ -1785,10 +1804,10 @@ function qn(e, t = () => !0) {
1785
1804
  });
1786
1805
  }
1787
1806
  let Vn = null;
1788
- function Ca(e) {
1807
+ function Ia(e) {
1789
1808
  Vn = e;
1790
1809
  }
1791
- function Ia(e = Vn) {
1810
+ function Ta(e = Vn) {
1792
1811
  if (!e) return null;
1793
1812
  const t = typeof window < "u" ? window.location.href : "http://localhost/", n = e.namespace ?? "/room";
1794
1813
  return {
@@ -1796,18 +1815,18 @@ function Ia(e = Vn) {
1796
1815
  path: e.path ?? Wn(e.origin)
1797
1816
  };
1798
1817
  }
1799
- function Ta(e) {
1818
+ function ka(e) {
1800
1819
  return `${In()}/media/${e}`.replace(/\\/g, "/");
1801
1820
  }
1802
- function ka(e, t) {
1803
- return Ta(t ?? `${e}/poster.jpg`);
1821
+ function Ea(e, t) {
1822
+ return ka(t ?? `${e}/poster.jpg`);
1804
1823
  }
1805
- function Ea(e) {
1824
+ function Aa(e) {
1806
1825
  return `${In()}${e}`.replace(/\\/g, "/");
1807
1826
  }
1808
- async function Aa(e) {
1827
+ async function Na(e) {
1809
1828
  try {
1810
- const t = await fetch(Ea("/api/tierlist"));
1829
+ const t = await fetch(Aa("/api/tierlist"));
1811
1830
  if (!t.ok)
1812
1831
  return I("tierlist", "Board fetch failed", { status: t.status }), null;
1813
1832
  const n = await t.json();
@@ -1821,35 +1840,35 @@ async function Aa(e) {
1821
1840
  }
1822
1841
  }
1823
1842
  let Bt = !1;
1824
- function Na() {
1843
+ function Pa() {
1825
1844
  if (Bt || typeof Image > "u") return;
1826
1845
  const e = m.getState().tierlist;
1827
1846
  if (!(!e || e.items.length === 0)) {
1828
1847
  Bt = !0;
1829
1848
  for (const t of e.items) {
1830
1849
  const n = new Image();
1831
- n.decoding = "async", n.src = ka(t.id, t.thumbnail);
1850
+ n.decoding = "async", n.src = Ea(t.id, t.thumbnail);
1832
1851
  }
1833
1852
  u("tierlist", "Warming posters", { count: e.items.length });
1834
1853
  }
1835
1854
  }
1836
- function Pa() {
1855
+ function Ra() {
1837
1856
  const e = m.getState(), t = rn(Object.values(e.roster).map((a) => a.sprite), void 0, Be);
1838
1857
  if (!t)
1839
1858
  return I("socket", "sprite_taken: no available sprites to retry with"), null;
1840
1859
  const n = !!e.name && !re(e.name), r = n ? e.name : be(t);
1841
1860
  return u("socket", "sprite_taken: retrying with a free character", { from: e.sprite, to: t, name: r, keptCustomName: n }), e.setSessionIdentity(r, t), { name: r, sprite: t };
1842
1861
  }
1843
- function Ra(e) {
1862
+ function Da(e) {
1844
1863
  const t = m.getState(), n = e ? t.roster[e] : void 0;
1845
1864
  return !n || !!n.sprite && n.sprite === t.sprite;
1846
1865
  }
1847
- const Da = "hadoku:name";
1848
- function Oa(e) {
1866
+ const Oa = "hadoku:name";
1867
+ function Ma(e) {
1849
1868
  const t = Tr(e);
1850
1869
  return We(t) ? t : null;
1851
1870
  }
1852
- async function Ma(e = {}) {
1871
+ async function La(e = {}) {
1853
1872
  const t = await Ir({
1854
1873
  ...e,
1855
1874
  onError: (r) => I("avatar", "Avatar settings read failed — keeping the auto-assigned character", we(r))
@@ -1863,7 +1882,7 @@ function Wt(e) {
1863
1882
  const r = !!(t.me.clientId && t.roster[t.me.clientId]?.registryName) || !t.name || !re(t.name) ? t.name : be(e);
1864
1883
  return t.setSessionIdentity(r, e), !0;
1865
1884
  }
1866
- function La(e, t, n) {
1885
+ function ja(e, t, n) {
1867
1886
  if (!n) return () => {
1868
1887
  };
1869
1888
  const r = (a) => {
@@ -1872,26 +1891,26 @@ function La(e, t, n) {
1872
1891
  };
1873
1892
  return n.addEventListener(e, r), () => n.removeEventListener(e, r);
1874
1893
  }
1875
- const ja = () => typeof window > "u" ? void 0 : window;
1876
- function Ua(e, t = ja()) {
1877
- return La(Da, (n) => {
1894
+ const Ua = () => typeof window > "u" ? void 0 : window;
1895
+ function Ha(e, t = Ua()) {
1896
+ return ja(Oa, (n) => {
1878
1897
  typeof n.name == "string" && n.name.trim() && e(n.name);
1879
1898
  }, t);
1880
1899
  }
1881
- const Ha = 10;
1882
- function Fa(e = typeof window < "u" ? window : void 0) {
1900
+ const Fa = 10;
1901
+ function $a(e = typeof window < "u" ? window : void 0) {
1883
1902
  if (!e) return { framed: !1, depth: 0 };
1884
1903
  try {
1885
1904
  let t = 0, n = e;
1886
- for (; n !== n.parent && t < Ha; )
1905
+ for (; n !== n.parent && t < Fa; )
1887
1906
  t++, n = n.parent;
1888
1907
  return { framed: e.top ? e.top !== e.self : t > 0, depth: t };
1889
1908
  } catch {
1890
1909
  return { framed: !1, depth: 0 };
1891
1910
  }
1892
1911
  }
1893
- const $a = "watchparty_fragment_delivery";
1894
- function Ba() {
1912
+ const Ba = "watchparty_fragment_delivery";
1913
+ function Wa() {
1895
1914
  if (typeof window > "u") return null;
1896
1915
  try {
1897
1916
  const e = new URLSearchParams(window.location.search).get("fragmentDelivery");
@@ -1899,27 +1918,27 @@ function Ba() {
1899
1918
  if (e === "0" || e === "false") return !1;
1900
1919
  } catch {
1901
1920
  }
1902
- return Uo($a);
1921
+ return Ho(Ba);
1903
1922
  }
1904
- let Wa = { ...gn }, Ye = null;
1923
+ let Ga = { ...gn }, Ye = null;
1905
1924
  const Gt = "watchparty_delivery_client_id";
1906
- function Ga() {
1925
+ function qa() {
1907
1926
  const e = W(Gt);
1908
1927
  if (e) return e;
1909
1928
  const t = globalThis.crypto?.randomUUID?.() ?? `d${Math.random().toString(36).slice(2)}`;
1910
1929
  return pt(Gt, t) ? t : "";
1911
1930
  }
1912
- function qa() {
1913
- return Ye === null && (Ye = to(Wa, Ga(), Ba())), Ye;
1914
- }
1915
1931
  function Va() {
1916
- return qa();
1932
+ return Ye === null && (Ye = to(Ga, qa(), Wa())), Ye;
1933
+ }
1934
+ function Ka() {
1935
+ return Va();
1917
1936
  }
1918
1937
  let Oe;
1919
1938
  function Kn() {
1920
1939
  return W(Cr) || void 0;
1921
1940
  }
1922
- function Ka() {
1941
+ function Ya() {
1923
1942
  if (Oe) return;
1924
1943
  const e = Kn();
1925
1944
  if (e) {
@@ -1932,10 +1951,10 @@ function Ka() {
1932
1951
  u("identity", "device id unavailable — joining without one");
1933
1952
  });
1934
1953
  }
1935
- function Ya() {
1954
+ function Xa() {
1936
1955
  return Oe ??= Kn();
1937
1956
  }
1938
- function Xa(e, t) {
1957
+ function za(e, t) {
1939
1958
  let n = 0;
1940
1959
  for (const r of e.videos) {
1941
1960
  const a = de.voteKey(t, e.id, r.mediaId);
@@ -1943,49 +1962,49 @@ function Xa(e, t) {
1943
1962
  }
1944
1963
  return n;
1945
1964
  }
1946
- const za = 2e4, Ja = 1e4;
1947
- function Qa() {
1965
+ const Ja = 2e4, Qa = 1e4;
1966
+ function Za() {
1948
1967
  return { unansweredSince: null, lastPongAt: null, lastTickAt: null };
1949
1968
  }
1950
- function Za(e, t) {
1969
+ function ei(e, t) {
1951
1970
  e.lastPongAt = t, e.unansweredSince = null;
1952
1971
  }
1953
- function ei(e, t, n) {
1954
- const r = e.lastTickAt !== null && t - e.lastTickAt > Ja;
1955
- return e.lastTickAt = t, n ? r || e.unansweredSince === null ? (e.unansweredSince = t, !1) : t - e.unansweredSince > za : (e.unansweredSince = null, !1);
1972
+ function ti(e, t, n) {
1973
+ const r = e.lastTickAt !== null && t - e.lastTickAt > Qa;
1974
+ return e.lastTickAt = t, n ? r || e.unansweredSince === null ? (e.unansweredSince = t, !1) : t - e.unansweredSince > Ja : (e.unansweredSince = null, !1);
1956
1975
  }
1957
- function ti(e, t) {
1976
+ function ni(e, t) {
1958
1977
  return e.lastPongAt === null ? void 0 : Math.max(0, t - e.lastPongAt);
1959
1978
  }
1960
1979
  let S = null, $ = null, Me = null, B = null, X = null;
1961
- const ni = ai(), se = Qa();
1980
+ const ri = ii(), se = Za();
1962
1981
  let Te = null, Xe = null, qt = 0, wt = null, ve = !1, St = !1, me = !1, Yn = null;
1963
- function ri(e) {
1982
+ function oi(e) {
1964
1983
  const t = oe(), n = m.getState();
1965
1984
  if (n.me.clientId && n.roster[n.me.clientId])
1966
1985
  return (e.name || e.sprite) && (u("socket", "Identity update (already joined)", { name: e.name, sprite: e.sprite }), t.emit(v.IDENTITY_UPDATE, { name: e.name, sprite: e.sprite })), t;
1967
- const r = oi(e);
1968
- return X = r, wt = { name: r.name, sprite: r.sprite }, _t() && Sa(r), t.connected ? (u("socket", "Emitting join", r), t.emit(v.JOIN, r)) : t.once("connect", () => {
1986
+ const r = ai(e);
1987
+ return X = r, wt = { name: r.name, sprite: r.sprite }, _t() && xa(r), t.connected ? (u("socket", "Emitting join", r), t.emit(v.JOIN, r)) : t.once("connect", () => {
1969
1988
  u("socket", "Emitting join", r), t.emit(v.JOIN, r);
1970
1989
  }), t;
1971
1990
  }
1972
- function oi(e) {
1991
+ function ai(e) {
1973
1992
  return {
1974
1993
  room_key: e.room_key,
1975
1994
  name: e.name,
1976
1995
  sprite: e.sprite,
1977
1996
  // Entry-path telemetry — see lib/embedContext.ts. Sent on every join AND
1978
1997
  // rejoin (lastJoinPayload carries it), so a reconnect keeps the attribution.
1979
- embed: Fa(),
1980
- delivery_arm: Va(),
1998
+ embed: $a(),
1999
+ delivery_arm: Ka(),
1981
2000
  // Identity tier input — see lib/deviceId.ts. Sent on every join AND rejoin
1982
2001
  // (lastJoinPayload carries it) so a reconnect lands on the same
1983
2002
  // ParticipantId rather than minting a new person.
1984
- device_id: Ya(),
1985
- tab_id: ni
2003
+ device_id: Xa(),
2004
+ tab_id: ri
1986
2005
  };
1987
2006
  }
1988
- function ai() {
2007
+ function ii() {
1989
2008
  const e = globalThis.crypto;
1990
2009
  if (e && typeof e.randomUUID == "function") return e.randomUUID();
1991
2010
  const t = new Uint8Array(16);
@@ -2000,7 +2019,7 @@ function oe() {
2000
2019
  const r = window.location;
2001
2020
  (r.hostname === "localhost" || r.hostname === "127.0.0.1") && r.port === String(sn) && (t = `${r.protocol}//${r.hostname}:${lt}`, u("socket", "Using dev fallback origin", { origin: t }));
2002
2021
  }
2003
- const n = Ia();
2022
+ const n = Ta();
2004
2023
  if (n)
2005
2024
  S = tt(n.url, { path: n.path, transports: ["websocket", "polling"] }), u("socket", "Socket initialized on the room origin", n);
2006
2025
  else {
@@ -2008,14 +2027,14 @@ function oe() {
2008
2027
  S = tt(r, { path: Pr, transports: ["websocket", "polling"] }), u("socket", "Socket initialized", { origin: t });
2009
2028
  }
2010
2029
  Ve("__SOCKET__", S), B && (clearTimeout(B), B = null), $ = null, Me = setInterval(() => {
2011
- if (ei(se, Date.now(), !!S?.connected)) {
2030
+ if (ti(se, Date.now(), !!S?.connected)) {
2012
2031
  I("socket", "PONG-WATCHDOG no time_pong for 20s — replacing the connection", {
2013
2032
  sid: S?.id,
2014
- lastPongAgeMs: ti(se, Date.now()) ?? null
2033
+ lastPongAgeMs: ni(se, Date.now()) ?? null
2015
2034
  }), Xe = "pong-watchdog", se.unansweredSince = null, S?.io.engine?.close();
2016
2035
  return;
2017
2036
  }
2018
- gi();
2037
+ yi();
2019
2038
  }, zr), S.on("connect", () => {
2020
2039
  St = !1;
2021
2040
  const r = S?.id;
@@ -2052,14 +2071,14 @@ function oe() {
2052
2071
  me = !0;
2053
2072
  }), S.on("disconnect", (r) => {
2054
2073
  Dn(null), Te = { reason: Xe ?? r, at: Date.now() }, Xe = null, u("socket", "Disconnected", { reason: r });
2055
- }), S.on("connect_error", (r) => Re("socket", "Connection error", { message: r?.message })), S.on("reconnect_attempt", (r) => I("socket", "Reconnect attempt", { attempt: r })), S.on("reconnect_failed", () => Re("socket", "Reconnect failed")), pi(S);
2074
+ }), S.on("connect_error", (r) => Re("socket", "Connection error", { message: r?.message })), S.on("reconnect_attempt", (r) => I("socket", "Reconnect attempt", { attempt: r })), S.on("reconnect_failed", () => Re("socket", "Reconnect failed")), hi(S);
2056
2075
  }
2057
2076
  return S;
2058
2077
  }
2059
2078
  function ze(e) {
2060
2079
  return e.play_state === "playing" || e.playing === !0;
2061
2080
  }
2062
- function ii(e) {
2081
+ function si(e) {
2063
2082
  e.on(v.SNAPSHOT, (t) => {
2064
2083
  e.emit(hn.SYNC), m.getState().applySnapshot({
2065
2084
  roomId: t.room_id ?? null,
@@ -2112,7 +2131,7 @@ function ii(e) {
2112
2131
  }), e.on(v.CONTROL_ACK, (t) => {
2113
2132
  typeof t?.client_seq == "number" && typeof t?.server_seq == "number" && u("socket", "Control ack received", t);
2114
2133
  }), e.on(v.TIME_PONG, (t) => {
2115
- if (Za(se, Date.now()), $ && $.ts) {
2134
+ if (ei(se, Date.now()), $ && $.ts) {
2116
2135
  const n = Date.now() - $.ts;
2117
2136
  m.getState().addRttSample(n, t?.server_ts, $.ts), $ = null, B && (clearTimeout(B), B = null), u("socket", "Time sync RTT", { rtt: n, offset: m.getState().drift.offsetMs });
2118
2137
  }
@@ -2122,11 +2141,11 @@ function ii(e) {
2122
2141
  m.getState().setReadiness({ mediaId: n, ready: i, readyCount: r, total: a }), u("socket", "Ready state received", { mediaId: n, readyCount: r, total: a, ready: i });
2123
2142
  });
2124
2143
  }
2125
- function si(e) {
2144
+ function li(e) {
2126
2145
  const t = pr(e);
2127
2146
  return t ? { cosmetics: t } : {};
2128
2147
  }
2129
- function li(e) {
2148
+ function ci(e) {
2130
2149
  e.on(v.PRESENCE, (t) => {
2131
2150
  if (!t) return;
2132
2151
  if (Array.isArray(t.users)) {
@@ -2140,7 +2159,7 @@ function li(e) {
2140
2159
  isLeader: l.is_leader,
2141
2160
  ...l.registry_name ? { registryName: !0 } : {},
2142
2161
  ...l.avatar_url ? { avatarUrl: l.avatar_url } : {},
2143
- ...si(l.cosmetics)
2162
+ ...li(l.cosmetics)
2144
2163
  };
2145
2164
  const a = m.getState(), i = S?.id, s = i ? r[i] : void 0;
2146
2165
  if (s?.registryName)
@@ -2162,7 +2181,7 @@ function li(e) {
2162
2181
  }
2163
2182
  });
2164
2183
  }
2165
- function ci(e) {
2184
+ function di(e) {
2166
2185
  e.on(Se.STATE, (t) => {
2167
2186
  m.getState().applyPlaylistState({
2168
2187
  playlist: t?.playlist ?? null,
@@ -2175,54 +2194,54 @@ function ci(e) {
2175
2194
  m.getState().setPlaylistResults(t ?? null), u("playlist", "Results received", { playlistId: t?.playlist?.id, update: t?.update === !0 });
2176
2195
  }), e.on(Se.VOTES_CLEARED, (t) => {
2177
2196
  if (!t?.playlistId || !Array.isArray(t.mediaIds)) return;
2178
- const n = Xa(
2197
+ const n = za(
2179
2198
  { id: t.playlistId, videos: t.mediaIds.map((a) => ({ mediaId: a })) },
2180
- sa()
2199
+ la()
2181
2200
  ), r = m.getState();
2182
2201
  r.playlist?.id === t.playlistId && r.applyPlaylistState({ playlist: r.playlist, activeIndex: r.activePlaylistIndex, myVotes: {} }), u("playlist", "Votes cleared by leader", { playlistId: t.playlistId, removed: n });
2183
2202
  });
2184
2203
  }
2185
- function di(e) {
2204
+ function ui(e) {
2186
2205
  e.on(Gr.UPDATED, () => {
2187
- u("tierlist", "Someone saved — refreshing the board"), Aa(!1);
2206
+ u("tierlist", "Someone saved — refreshing the board"), Na(!1);
2188
2207
  });
2189
2208
  }
2190
- function ui(e) {
2209
+ function mi(e) {
2191
2210
  e.on(qr.STATE, (t) => {
2192
2211
  if (!t || typeof t.active != "boolean") return;
2193
2212
  const n = Array.isArray(t.ready) ? t.ready.filter((r) => typeof r == "string") : [];
2194
2213
  m.getState().setReadyCheckState({ active: t.active, ready: n }), u("ready-check", "State received", { active: t.active, readyCount: n.length });
2195
2214
  });
2196
2215
  }
2197
- function mi(e) {
2216
+ function fi(e) {
2198
2217
  e.on(hn.ACTIVE, (t) => {
2199
2218
  const n = typeof t?.gameId == "string" ? t.gameId : null;
2200
2219
  m.getState().setActiveGameId(n), u("game", "game_active", { gameId: n });
2201
2220
  });
2202
2221
  }
2203
- function fi(e) {
2222
+ function pi(e) {
2204
2223
  e.on(v.HEALTH_SNAPSHOT, (t) => {
2205
2224
  m.getState().setHealthSnapshot(t);
2206
2225
  }), e.on(v.BUFFER_STATUS, (t) => {
2207
2226
  m.getState().setBufferStatus(t);
2208
2227
  });
2209
2228
  }
2210
- function pi(e) {
2211
- ii(e), li(e), qn(e, () => !_t()), fi(e), ci(e), di(e), ui(e), mi(e), e.on(v.ERROR, (t) => {
2229
+ function hi(e) {
2230
+ si(e), ci(e), qn(e, () => !_t()), pi(e), di(e), ui(e), mi(e), fi(e), e.on(v.ERROR, (t) => {
2212
2231
  const n = t?.code || "error/unknown";
2213
2232
  if (n === "conflict" && t?.message === "sprite_held_by_you") {
2214
2233
  St = !0, u("socket", "sprite held by this account's other connection: keeping the server-assigned sprite");
2215
2234
  return;
2216
2235
  }
2217
2236
  if (n === "conflict" && t?.message === "sprite_taken") {
2218
- if (Ra(S?.id)) {
2237
+ if (Da(S?.id)) {
2219
2238
  u("socket", "sprite_taken: stale, the server already has our sprite");
2220
2239
  return;
2221
2240
  }
2222
2241
  ve = !0;
2223
2242
  let s;
2224
2243
  try {
2225
- s = Pa();
2244
+ s = Ra();
2226
2245
  } finally {
2227
2246
  ve = !1;
2228
2247
  }
@@ -2253,11 +2272,11 @@ function pi(e) {
2253
2272
  (n.startsWith("auth/") ? I : Re)("socket", `Server error: ${a}`, { code: n, raw: t }), m.getState().pushToast("error", a);
2254
2273
  });
2255
2274
  }
2256
- function hi(e, t) {
2275
+ function gi(e, t) {
2257
2276
  const n = t?.length ? { text: e, images: t } : { text: e };
2258
- _t() ? xa(n) : oe().emit(v.CHAT_SEND, n);
2277
+ _t() ? Ca(n) : oe().emit(v.CHAT_SEND, n);
2259
2278
  }
2260
- function gi() {
2279
+ function yi() {
2261
2280
  $ || ($ = { ts: Date.now() }, oe().emit(v.TIME_PING, {}), B = setTimeout(() => {
2262
2281
  $ && (u("socket", "Time ping timed out after 10s, clearing inflight"), $ = null), B = null;
2263
2282
  }, 1e4));
@@ -2277,10 +2296,10 @@ function Xn(e) {
2277
2296
  const r = m.getState(), a = { avatar: !0 };
2278
2297
  r.sprite && r.sprite !== t.sprite && (a.sprite = r.sprite), r.name && r.name !== t.name && (a.name = r.name), u("socket", "Sending avatar change", a), oe().emit(v.IDENTITY_UPDATE, a);
2279
2298
  }
2280
- function yi(e) {
2281
- m.getState().me.clientId && bi(e);
2299
+ function bi(e) {
2300
+ m.getState().me.clientId && vi(e);
2282
2301
  }
2283
- function bi(e, t) {
2302
+ function vi(e, t) {
2284
2303
  const n = {};
2285
2304
  e && (n.name = e), !(!n.name && !n.sprite) && (u("socket", "Sending identity update", n), oe().emit(v.IDENTITY_UPDATE, n));
2286
2305
  }
@@ -2296,14 +2315,14 @@ m.subscribe((e, t) => {
2296
2315
  const s = {};
2297
2316
  a && (s.name = e.name, ke.name = e.name), i && (s.sprite = e.sprite, ke.sprite = e.sprite), u("socket", "Identity reassert (store change)", s), S?.connected ? S.emit(v.IDENTITY_UPDATE, s) : oe().emit(v.IDENTITY_UPDATE, s);
2298
2317
  });
2299
- function vi() {
2318
+ function _i() {
2300
2319
  Me && (clearInterval(Me), Me = null), B && (clearTimeout(B), B = null), $ = null, se.unansweredSince = null, se.lastTickAt = null;
2301
2320
  }
2302
- function _i() {
2321
+ function wi() {
2303
2322
  u("socket", "clearJoinState called", { hadPayload: X !== null, room_key: X?.room_key }), X = null, me = !1, Yn = null;
2304
2323
  }
2305
2324
  function Vt() {
2306
- u("socket", "leaveRoom called", { room_key: X?.room_key }), _i(), vi(), Gn(), S && (S.disconnect(), S = null), m.setState({
2325
+ u("socket", "leaveRoom called", { room_key: X?.room_key }), wi(), _i(), Gn(), S && (S.disconnect(), S = null), m.setState({
2307
2326
  me: { clientId: null, nextClientSeq: 1 },
2308
2327
  roster: {},
2309
2328
  snapshot: { roomId: null, mediaId: null, playheadMs: 0, playing: !1, serverSeq: 0, leaderId: null },
@@ -2318,31 +2337,31 @@ function Vt() {
2318
2337
  activeGameId: null
2319
2338
  });
2320
2339
  }
2321
- function wi() {
2340
+ function Si() {
2322
2341
  u("chat", "Emitting recap_request"), oe().emit("recap_request");
2323
2342
  }
2324
- function Si() {
2343
+ function xi() {
2325
2344
  E(() => {
2326
2345
  const e = Er(), t = kr((r, a) => {
2327
- const i = Oa(a);
2346
+ const i = Ma(a);
2328
2347
  u("avatar", "Avatar changed in the settings popout", { sprite: i, source: a.avatar?.source }), Xn(i);
2329
- }), n = Ua((r) => {
2330
- u("avatar", "Renamed in the settings popout", { name: r }), yi(r);
2348
+ }), n = Ha((r) => {
2349
+ u("avatar", "Renamed in the settings popout", { name: r }), bi(r);
2331
2350
  });
2332
2351
  return () => {
2333
2352
  t(), n(), e();
2334
2353
  };
2335
2354
  }, []);
2336
2355
  }
2337
- function xi(e, t) {
2356
+ function Ci(e, t) {
2338
2357
  return (t ? yr(t) : null) ?? Mn(e);
2339
2358
  }
2340
2359
  function xt(e, t) {
2341
2360
  return E(() => {
2342
2361
  t && hr(t);
2343
- }, [t]), nr(gr, () => xi(e, t), () => Mn(e));
2362
+ }, [t]), nr(gr, () => Ci(e, t), () => Mn(e));
2344
2363
  }
2345
- function Ci(e, t) {
2364
+ function Ii(e, t) {
2346
2365
  if (t.clientId) {
2347
2366
  const n = e[t.clientId];
2348
2367
  if (n && (!t.author || !n.author || n.author === t.author)) return n;
@@ -2351,8 +2370,8 @@ function Ci(e, t) {
2351
2370
  for (const n of Object.values(e)) if (n.author === t.author) return n;
2352
2371
  }
2353
2372
  }
2354
- function Ii(e, t, n) {
2355
- const r = Ci(e, t);
2373
+ function Ti(e, t, n) {
2374
+ const r = Ii(e, t);
2356
2375
  return r ? {
2357
2376
  name: r.name || n.name,
2358
2377
  // A connection briefly without a character (a reconnect waiting for one to
@@ -2363,11 +2382,11 @@ function Ii(e, t, n) {
2363
2382
  here: !0
2364
2383
  } : { name: n.name, sprite: n.sprite, pictureUrl: n.pictureUrl, here: !1 };
2365
2384
  }
2366
- function Ti(e, t, n) {
2385
+ function ki(e, t, n) {
2367
2386
  return !t || !n.here ? e : t.split(un).join(n.name);
2368
2387
  }
2369
2388
  function zn(e, t) {
2370
- const n = m((r) => JSON.stringify(Ii(r.roster, e, t)));
2389
+ const n = m((r) => JSON.stringify(Ti(r.roster, e, t)));
2371
2390
  return ee(() => JSON.parse(n), [n]);
2372
2391
  }
2373
2392
  function Jn({ sprite: e, url: t, alt: n = "", className: r, style: a, fallback: i }) {
@@ -2385,7 +2404,7 @@ function Jn({ sprite: e, url: t, alt: n = "", className: r, style: a, fallback:
2385
2404
  onError: () => l(t)
2386
2405
  }
2387
2406
  );
2388
- const d = la(e);
2407
+ const d = ca(e);
2389
2408
  return d ? /* @__PURE__ */ c("img", { src: d, alt: n, crossOrigin: "anonymous", className: r, style: a, draggable: !1 }) : /* @__PURE__ */ c(le, { children: i });
2390
2409
  }
2391
2410
  function Qn({ sprite: e, url: t, alt: n, worn: r }) {
@@ -2403,17 +2422,17 @@ function Qn({ sprite: e, url: t, alt: n, worn: r }) {
2403
2422
  r?.overlay && /* @__PURE__ */ c(ge, { html: br(r), style: { display: "contents" } })
2404
2423
  ] });
2405
2424
  }
2406
- function ki(e) {
2425
+ function Ei(e) {
2407
2426
  return !(e.button !== 0 || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey);
2408
2427
  }
2409
- function Ei({ src: e, title: t, onClose: n }) {
2428
+ function Ai({ src: e, title: t, onClose: n }) {
2410
2429
  E(() => {
2411
2430
  const i = (s) => {
2412
2431
  mt(s) && (s.stopPropagation(), n());
2413
2432
  };
2414
2433
  return document.addEventListener("keydown", i, !0), () => document.removeEventListener("keydown", i, !0);
2415
2434
  }, [n]);
2416
- const r = Mo(), a = typeof document > "u" ? null : document.fullscreenElement ?? r ?? document.body;
2435
+ const r = Lo(), a = typeof document > "u" ? null : document.fullscreenElement ?? r ?? document.body;
2417
2436
  return a ? Ar(
2418
2437
  /* @__PURE__ */ _(
2419
2438
  "div",
@@ -2452,11 +2471,11 @@ function Ei({ src: e, title: t, onClose: n }) {
2452
2471
  a
2453
2472
  ) : null;
2454
2473
  }
2455
- const Je = 240, Ai = 320;
2456
- function Ni({ image: e }) {
2474
+ const Je = 240, Ni = 320;
2475
+ function Pi({ image: e }) {
2457
2476
  const [t, n] = k(!1), r = je(e.key);
2458
2477
  if (!r) return null;
2459
- const a = e.w > 0 && e.h > 0, i = a ? Math.min(1, Ai / e.w, Je / e.h) : 1;
2478
+ const a = e.w > 0 && e.h > 0, i = a ? Math.min(1, Ni / e.w, Je / e.h) : 1;
2460
2479
  return /* @__PURE__ */ _(le, { children: [
2461
2480
  /* @__PURE__ */ c(
2462
2481
  "a",
@@ -2467,7 +2486,7 @@ function Ni({ image: e }) {
2467
2486
  className: "block max-w-full cursor-zoom-in",
2468
2487
  "data-testid": "chat-image",
2469
2488
  onClick: (s) => {
2470
- ki(s) && (s.preventDefault(), n(!0));
2489
+ Ei(s) && (s.preventDefault(), n(!0));
2471
2490
  },
2472
2491
  children: /* @__PURE__ */ c(
2473
2492
  "img",
@@ -2485,7 +2504,7 @@ function Ni({ image: e }) {
2485
2504
  }
2486
2505
  ),
2487
2506
  t && /* @__PURE__ */ c(
2488
- Ei,
2507
+ Ai,
2489
2508
  {
2490
2509
  src: r,
2491
2510
  title: e.title,
@@ -2495,20 +2514,20 @@ function Ni({ image: e }) {
2495
2514
  ] });
2496
2515
  }
2497
2516
  function Zn({ images: e }) {
2498
- return e?.length ? /* @__PURE__ */ c("div", { className: "flex flex-wrap gap-1 mt-1", "data-testid": "chat-images", children: e.map((t, n) => /* @__PURE__ */ c(Ni, { image: t }, `${t.key}-${n}`)) }) : null;
2517
+ return e?.length ? /* @__PURE__ */ c("div", { className: "flex flex-wrap gap-1 mt-1", "data-testid": "chat-images", children: e.map((t, n) => /* @__PURE__ */ c(Pi, { image: t }, `${t.key}-${n}`)) }) : null;
2499
2518
  }
2500
- function Pi(e, t) {
2519
+ function Ri(e, t) {
2501
2520
  return e.author && t.author ? e.author === t.author : !!t.clientId && e.clientId === t.clientId;
2502
2521
  }
2503
2522
  function Qe(e) {
2504
2523
  return new Date(e).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
2505
2524
  }
2506
- const Ri = Le.memo(function({ message: t }) {
2507
- const n = m((f) => f.me.clientId), r = m((f) => f.me.clientId ? f.roster[f.me.clientId]?.author : void 0), a = Pi(t, { clientId: n, author: r }), i = zn(
2525
+ const Di = Le.memo(function({ message: t }) {
2526
+ const n = m((f) => f.me.clientId), r = m((f) => f.me.clientId ? f.roster[f.me.clientId]?.author : void 0), a = Ri(t, { clientId: n, author: r }), i = zn(
2508
2527
  { clientId: t.clientId, author: t.author },
2509
2528
  { name: t.name, sprite: t.sprite }
2510
2529
  ), s = xt(i.sprite, i.pictureUrl), l = t.isSystem ? void 0 : i.cosmetics, d = G(null);
2511
- Lo(d, !!l);
2530
+ jo(d, !!l);
2512
2531
  const [h] = k(
2513
2532
  () => t.live && t.text ? tn(t.text, l) : null
2514
2533
  );
@@ -2519,7 +2538,7 @@ const Ri = Le.memo(function({ message: t }) {
2519
2538
  ] }),
2520
2539
  /* @__PURE__ */ c("p", { className: "text-[13px] text-text-secondary leading-relaxed whitespace-pre-wrap break-words", children: t.text })
2521
2540
  ] }) }) : t.isSystem ? /* @__PURE__ */ _("div", { className: "px-2 py-0.5 text-[11px] text-text-muted italic text-center leading-tight", children: [
2522
- Ti(t.text, t.template, i),
2541
+ ki(t.text, t.template, i),
2523
2542
  /* @__PURE__ */ c("span", { className: "ml-1 text-[10px] opacity-50", children: Qe(t.ts) })
2524
2543
  ] }) : /* @__PURE__ */ _("div", { ref: d, style: An(s), className: `flex items-start gap-2 px-2 py-1 hover:bg-bg-card/20 ${a ? "bg-bg-card/30" : ""}`, children: [
2525
2544
  /* @__PURE__ */ c(Qn, { sprite: i.sprite, url: i.pictureUrl, alt: i.name, worn: l }),
@@ -2531,7 +2550,7 @@ const Ri = Le.memo(function({ message: t }) {
2531
2550
  ] })
2532
2551
  ] });
2533
2552
  });
2534
- function Di() {
2553
+ function Oi() {
2535
2554
  En();
2536
2555
  const e = m((a) => a.chat), t = G(null), n = G(!1), r = A(() => {
2537
2556
  const a = t.current;
@@ -2556,7 +2575,7 @@ function Di() {
2556
2575
  /* @__PURE__ */ c("span", { className: "text-[10px] text-text-muted whitespace-nowrap", children: new Date(a.ts).toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" }) }),
2557
2576
  /* @__PURE__ */ c("div", { className: "flex-1 h-px bg-border" })
2558
2577
  ] }),
2559
- /* @__PURE__ */ c(Ri, { message: a })
2578
+ /* @__PURE__ */ c(Di, { message: a })
2560
2579
  ] }, a.id);
2561
2580
  }) })
2562
2581
  }
@@ -2583,12 +2602,12 @@ const Ct = [
2583
2602
  scope: "local"
2584
2603
  }
2585
2604
  ], ce = "/";
2586
- function Oi(e) {
2605
+ function Mi(e) {
2587
2606
  if (!e.startsWith(ce)) return null;
2588
2607
  const t = e.slice(ce.length);
2589
2608
  return /\s/.test(t) ? null : t.toLowerCase();
2590
2609
  }
2591
- function Mi(e, t = Ct) {
2610
+ function Li(e, t = Ct) {
2592
2611
  const n = e.toLowerCase();
2593
2612
  if (!n) return [...t].sort((a, i) => a.name.localeCompare(i.name));
2594
2613
  const r = [];
@@ -2598,23 +2617,23 @@ function Mi(e, t = Ct) {
2598
2617
  }
2599
2618
  return r.sort((a, i) => a.rank - i.rank || a.cmd.name.localeCompare(i.cmd.name)).map((a) => a.cmd);
2600
2619
  }
2601
- function Li(e) {
2620
+ function ji(e) {
2602
2621
  return `${ce}${e.name} `;
2603
2622
  }
2604
2623
  function Ze(e, t) {
2605
2624
  return t <= 0 ? 0 : (e % t + t) % t;
2606
2625
  }
2607
- function ji(e, t = Ct) {
2626
+ function Ui(e, t = Ct) {
2608
2627
  const n = e.trim();
2609
2628
  if (!n) return null;
2610
2629
  if (!n.startsWith(ce)) return { kind: "chat", text: n };
2611
2630
  const r = n.slice(ce.length), a = r.search(/\s/), i = (a === -1 ? r : r.slice(0, a)).toLowerCase(), s = a === -1 ? "" : r.slice(a).trim(), l = t.find((d) => d.name.toLowerCase() === i);
2612
2631
  return l ? { kind: "command", command: l, args: s } : { kind: "chat", text: n };
2613
2632
  }
2614
- function Ui(e, t) {
2633
+ function Hi(e, t) {
2615
2634
  return e.requiresMedia && !t.hasMedia ? `${ce}${e.name} needs an episode loaded.` : null;
2616
2635
  }
2617
- function Hi({
2636
+ function Fi({
2618
2637
  commands: e,
2619
2638
  activeIndex: t,
2620
2639
  hasMedia: n,
@@ -2656,7 +2675,7 @@ function Hi({
2656
2675
  }
2657
2676
  );
2658
2677
  }
2659
- function Fi({
2678
+ function $i({
2660
2679
  pending: e,
2661
2680
  uploading: t,
2662
2681
  onRemove: n
@@ -2683,24 +2702,24 @@ function Fi({
2683
2702
  )
2684
2703
  ] }, r.id)) }) : null;
2685
2704
  }
2686
- function $i() {
2705
+ function Bi() {
2687
2706
  const [e, t] = k([]), [n, r] = k(!1), a = m((p) => p.pushToast), i = G(/* @__PURE__ */ new Set());
2688
2707
  E(() => () => {
2689
2708
  for (const p of i.current) URL.revokeObjectURL(p);
2690
2709
  i.current.clear();
2691
2710
  }, []);
2692
2711
  const s = A((p) => {
2693
- go(p) && (URL.revokeObjectURL(p.previewUrl), i.current.delete(p.previewUrl));
2712
+ yo(p) && (URL.revokeObjectURL(p.previewUrl), i.current.delete(p.previewUrl));
2694
2713
  }, []), l = A(async (p) => {
2695
2714
  if (!p.length) return;
2696
2715
  const x = [];
2697
2716
  for (const w of p) {
2698
- const y = bo(w);
2717
+ const y = vo(w);
2699
2718
  if (y) {
2700
2719
  a("error", y);
2701
2720
  continue;
2702
2721
  }
2703
- const { w: g, h: T } = await wo(w), N = URL.createObjectURL(w);
2722
+ const { w: g, h: T } = await So(w), N = URL.createObjectURL(w);
2704
2723
  i.current.add(N), x.push({
2705
2724
  kind: "file",
2706
2725
  id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
@@ -2747,10 +2766,10 @@ function $i() {
2747
2766
  return [];
2748
2767
  });
2749
2768
  }, [s]), M = A((p) => {
2750
- const x = vo(p.clipboardData);
2769
+ const x = _o(p.clipboardData);
2751
2770
  x.length && (p.preventDefault(), l(x));
2752
2771
  }, [l]), R = A((p) => {
2753
- const x = _o(p.dataTransfer);
2772
+ const x = wo(p.dataTransfer);
2754
2773
  x.length && (p.preventDefault(), l(x));
2755
2774
  }, [l]), D = A((p) => {
2756
2775
  p.dataTransfer?.types?.includes("Files") && p.preventDefault();
@@ -2758,9 +2777,9 @@ function $i() {
2758
2777
  if (!e.length) return [];
2759
2778
  r(!0);
2760
2779
  try {
2761
- return await xo(e);
2780
+ return await Co(e);
2762
2781
  } catch (p) {
2763
- return I("chat", "Image upload failed", Co(p)), a("error", yo(p)), null;
2782
+ return I("chat", "Image upload failed", Io(p)), a("error", bo(p)), null;
2764
2783
  } finally {
2765
2784
  r(!1);
2766
2785
  }
@@ -2778,16 +2797,16 @@ function $i() {
2778
2797
  onDragOver: D
2779
2798
  };
2780
2799
  }
2781
- const Kt = ln, Bi = Rr;
2782
- function Wi({ commands: e = Ct }) {
2783
- const [t, n] = k(""), [r, a] = k(!1), [i, s] = k({ q: null, i: 0 }), [l, d] = k(!1), h = G(null), f = rr(), [M, R] = k(!1), [D, H] = k(!1), p = $i(), x = m((b) => b.snapshot.mediaId), w = m((b) => b.pushToast), y = m((b) => b.setTierlistOpen), g = !!x, T = Oi(t), N = ee(
2784
- () => T === null ? [] : Mi(T, e),
2800
+ const Kt = ln, Wi = Rr;
2801
+ function Gi({ commands: e = Ct }) {
2802
+ const [t, n] = k(""), [r, a] = k(!1), [i, s] = k({ q: null, i: 0 }), [l, d] = k(!1), h = G(null), f = rr(), [M, R] = k(!1), [D, H] = k(!1), p = Bi(), x = m((b) => b.snapshot.mediaId), w = m((b) => b.pushToast), y = m((b) => b.setTierlistOpen), g = !!x, T = Mi(t), N = ee(
2803
+ () => T === null ? [] : Li(T, e),
2785
2804
  [T, e]
2786
2805
  ), j = T !== null && !l && N.length > 0, U = i.q === T ? Ze(i.i, N.length) : 0, C = A(
2787
2806
  (b) => s({ q: T, i: b }),
2788
2807
  [T]
2789
2808
  ), O = A((b, L) => {
2790
- const ue = Ui(b, { hasMedia: g });
2809
+ const ue = Hi(b, { hasMedia: g });
2791
2810
  if (ue) {
2792
2811
  w("info", ue);
2793
2812
  return;
@@ -2797,19 +2816,19 @@ function Wi({ commands: e = Ct }) {
2797
2816
  w("info", e.map((tr) => tr.usage).join(" "));
2798
2817
  break;
2799
2818
  case "recap":
2800
- wi();
2819
+ Si();
2801
2820
  break;
2802
2821
  case "tierlist":
2803
- Na(), y(!0);
2822
+ Pa(), y(!0);
2804
2823
  break;
2805
2824
  default:
2806
2825
  w("info", `${b.usage} is not implemented yet.`);
2807
2826
  }
2808
2827
  }, [g, w, e, y]), P = A((b) => {
2809
- n(Li(b)), d(!1), h.current?.focus();
2828
+ n(ji(b)), d(!1), h.current?.focus();
2810
2829
  }, []), F = A(async (b) => {
2811
2830
  if (b.preventDefault(), r || p.uploading) return;
2812
- const L = ji(t, e);
2831
+ const L = Ui(t, e);
2813
2832
  if (!L && !p.pending.length) return;
2814
2833
  if (L?.kind === "command" && p.pending.length) {
2815
2834
  w("info", "Send images on their own, not with a command.");
@@ -2820,7 +2839,7 @@ function Wi({ commands: e = Ct }) {
2820
2839
  return;
2821
2840
  }
2822
2841
  const ue = await p.uploadPending();
2823
- ue !== null && (hi(L?.text ?? "", ue), n(""), p.clear(), a(!0), setTimeout(() => a(!1), Bi), !document.hidden && document.hasFocus() && h.current?.focus());
2842
+ ue !== null && (gi(L?.text ?? "", ue), n(""), p.clear(), a(!0), setTimeout(() => a(!1), Wi), !document.hidden && document.hasFocus() && h.current?.focus());
2824
2843
  }, [t, r, O, p, w, e]), ae = A((b) => {
2825
2844
  if (b.key === "Escape" && j) {
2826
2845
  b.preventDefault(), d(!0);
@@ -2860,10 +2879,10 @@ function Wi({ commands: e = Ct }) {
2860
2879
  onDragOver: p.onDragOver,
2861
2880
  className: "p-2 border-t border-border",
2862
2881
  children: [
2863
- /* @__PURE__ */ c(Fi, { pending: p.pending, uploading: p.uploading, onRemove: p.remove }),
2882
+ /* @__PURE__ */ c($i, { pending: p.pending, uploading: p.uploading, onRemove: p.remove }),
2864
2883
  /* @__PURE__ */ _("div", { className: "relative", children: [
2865
2884
  j && /* @__PURE__ */ c(
2866
- Hi,
2885
+ Fi,
2867
2886
  {
2868
2887
  commands: N,
2869
2888
  activeIndex: U,
@@ -2874,7 +2893,7 @@ function Wi({ commands: e = Ct }) {
2874
2893
  }
2875
2894
  ),
2876
2895
  /* @__PURE__ */ c(
2877
- Po,
2896
+ Ro,
2878
2897
  {
2879
2898
  open: M,
2880
2899
  onClose: () => R(!1),
@@ -2927,11 +2946,11 @@ function Wi({ commands: e = Ct }) {
2927
2946
  }
2928
2947
  );
2929
2948
  }
2930
- function Gi() {
2949
+ function qi() {
2931
2950
  const e = m((n) => n.roster), t = Object.values(e);
2932
- return t.length ? /* @__PURE__ */ c("div", { className: "flex flex-col gap-1", children: t.map((n) => /* @__PURE__ */ c(qi, { u: n }, n.clientId)) }) : /* @__PURE__ */ c("div", { className: "text-xs text-text-muted", children: "No users online" });
2951
+ return t.length ? /* @__PURE__ */ c("div", { className: "flex flex-col gap-1", children: t.map((n) => /* @__PURE__ */ c(Vi, { u: n }, n.clientId)) }) : /* @__PURE__ */ c("div", { className: "text-xs text-text-muted", children: "No users online" });
2933
2952
  }
2934
- function qi({ u: e }) {
2953
+ function Vi({ u: e }) {
2935
2954
  const t = xt(e.sprite, e.avatarUrl);
2936
2955
  return /* @__PURE__ */ _("div", { className: "flex items-center gap-2 py-0.5", children: [
2937
2956
  /* @__PURE__ */ c(
@@ -2948,7 +2967,7 @@ function qi({ u: e }) {
2948
2967
  e.isLeader && /* @__PURE__ */ c("span", { className: "ml-auto px-1.5 py-0.5 rounded text-[9px] font-medium bg-success/20 text-success", children: "Leader" })
2949
2968
  ] });
2950
2969
  }
2951
- function Vi() {
2970
+ function Ki() {
2952
2971
  const e = m((i) => Object.keys(i.roster).length), [t, n] = k(!1), r = G(null), a = G(null);
2953
2972
  return E(() => {
2954
2973
  if (!t) return;
@@ -2984,7 +3003,7 @@ function Vi() {
2984
3003
  e,
2985
3004
  " online"
2986
3005
  ] }),
2987
- /* @__PURE__ */ c(Gi, {})
3006
+ /* @__PURE__ */ c(qi, {})
2988
3007
  ] })
2989
3008
  ] });
2990
3009
  }
@@ -2997,7 +3016,7 @@ function Yt({ className: e = "fixed bottom-4 left-1/2 -translate-x-1/2" }) {
2997
3016
  };
2998
3017
  }, [t, n]), /* @__PURE__ */ c("div", { className: `${e} flex flex-col gap-2 z-50`, children: t.map((r) => /* @__PURE__ */ c("div", { className: `px-3 py-2 rounded text-sm shadow font-medium border ${r.kind === "error" ? "bg-danger-bg text-on-danger-bg border-danger" : "bg-bg-card border-border-light text-text"}`, children: r.msg }, r.id)) });
2999
3018
  }
3000
- const er = 9e3, Xt = 1500, Ki = {
3019
+ const er = 9e3, Xt = 1500, Yi = {
3001
3020
  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]",
3002
3021
  cinema: "drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)]",
3003
3022
  minimal: "drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)] drop-shadow-[0_0_8px_rgba(0,0,0,0.7)]",
@@ -3006,11 +3025,11 @@ const er = 9e3, Xt = 1500, Ki = {
3006
3025
  textShadow: "none",
3007
3026
  filter: "drop-shadow(0 0 1px black) drop-shadow(0 0 1px black)"
3008
3027
  };
3009
- function Yi({ message: e, age: t, ccStyle: n }) {
3028
+ function Xi({ message: e, age: t, ccStyle: n }) {
3010
3029
  const r = er - Xt;
3011
3030
  let a = 1;
3012
3031
  t > r && (a = Math.max(0, 1 - (t - r) / Xt));
3013
- const i = Ki[n], s = zn(
3032
+ const i = Yi[n], s = zn(
3014
3033
  { clientId: e.clientId, author: e.author },
3015
3034
  { name: e.name, sprite: e.sprite }
3016
3035
  ), l = xt(s.sprite, s.pictureUrl), d = s.cosmetics, [h] = k(
@@ -3032,7 +3051,7 @@ function Yi({ message: e, age: t, ccStyle: n }) {
3032
3051
  }
3033
3052
  );
3034
3053
  }
3035
- function Xi({ shown: e, className: t }) {
3054
+ function zi({ shown: e, className: t }) {
3036
3055
  En();
3037
3056
  const n = m((d) => d.chat), r = m((d) => d.mediaPrefs.subtitleStyle), [a, i] = k(() => Date.now()), s = n.length > 0;
3038
3057
  E(() => {
@@ -3051,7 +3070,7 @@ function Xi({ shown: e, className: t }) {
3051
3070
  className: `wp-floating-chat pointer-events-none flex flex-col ${t}`,
3052
3071
  "data-testid": "floating-chat",
3053
3072
  children: l.map((d) => /* @__PURE__ */ c(
3054
- Yi,
3073
+ Xi,
3055
3074
  {
3056
3075
  message: d,
3057
3076
  age: a - d.ts,
@@ -3063,38 +3082,38 @@ function Xi({ shown: e, className: t }) {
3063
3082
  );
3064
3083
  }
3065
3084
  const Qt = (e) => typeof e == "string" && ar.includes(e);
3066
- function zi(e, t, n) {
3085
+ function Ji(e, t, n) {
3067
3086
  return e || (Qt(t) ? t : Qt(n) ? n : "dark");
3068
3087
  }
3069
- function Ji(e, t) {
3088
+ function Qi(e, t) {
3070
3089
  if (t(e.clientWidth), typeof ResizeObserver > "u") return () => {
3071
3090
  };
3072
3091
  const n = new ResizeObserver(() => t(e.clientWidth));
3073
3092
  return n.observe(e), () => n.disconnect();
3074
3093
  }
3075
- function Qi(e) {
3094
+ function Zi(e) {
3076
3095
  const t = e?.trim() ?? "";
3077
3096
  return t ? { source: "host", name: t } : { source: "auto" };
3078
3097
  }
3079
- function Zi(e) {
3098
+ function es(e) {
3080
3099
  if (e.source !== "host") return;
3081
3100
  const { setSessionIdentity: t, sprite: n } = m.getState();
3082
3101
  t(e.name, n);
3083
3102
  }
3084
- function es({ className: e = "w-4 h-4" }) {
3103
+ function ts({ className: e = "w-4 h-4" }) {
3085
3104
  return /* @__PURE__ */ _("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
3086
3105
  /* @__PURE__ */ c("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 4v16" }),
3087
3106
  /* @__PURE__ */ c("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15 12l-5 4v-8l5 4z" })
3088
3107
  ] });
3089
3108
  }
3090
- function ts({ className: e = "w-4 h-4" }) {
3109
+ function ns({ className: e = "w-4 h-4" }) {
3091
3110
  return /* @__PURE__ */ _("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
3092
3111
  /* @__PURE__ */ c("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M20 4v16" }),
3093
3112
  /* @__PURE__ */ c("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 12l5 4v-8l-5 4z" })
3094
3113
  ] });
3095
3114
  }
3096
- const ns = 1500;
3097
- function bs({
3115
+ const rs = 1500;
3116
+ function vs({
3098
3117
  roomKey: e,
3099
3118
  serverOrigin: t,
3100
3119
  roomOrigin: n,
@@ -3111,8 +3130,8 @@ function bs({
3111
3130
  debug: D,
3112
3131
  children: H
3113
3132
  }) {
3114
- const [p, x] = k(null), { setFrame: w, ...y } = rs(M, R), g = m((F) => F.floatingChatEnabled), T = en(() => h), N = ee(() => (ia({ userType: s, userId: l ?? null }), bt().theme), [s, l]), j = ir(), U = j?.theme, C = ee(
3115
- () => zi(d, U, N),
3133
+ const [p, x] = k(null), { setFrame: w, ...y } = os(M, R), g = m((F) => F.floatingChatEnabled), T = en(() => h), N = ee(() => (sa({ userType: s, userId: l ?? null }), bt().theme), [s, l]), j = ir(), U = j?.theme, C = ee(
3134
+ () => Ji(d, U, N),
3116
3135
  [d, U, N]
3117
3136
  );
3118
3137
  E(() => {
@@ -3122,36 +3141,36 @@ function bs({
3122
3141
  [t, e]
3123
3142
  );
3124
3143
  return E(() => {
3125
- D && Ho();
3126
- }, [D]), Si(), E(() => {
3127
- Ro({ serverOrigin: t, defaultRoomKey: e }), Ca(n ? { origin: n, path: r } : null), Ft(a && !n ? { origin: a, path: i } : null), m.getState().rehydrateFromPrefs(), Ka();
3144
+ D && Fo();
3145
+ }, [D]), xi(), E(() => {
3146
+ Do({ serverOrigin: t, defaultRoomKey: e }), Ia(n ? { origin: n, path: r } : null), Ft(a && !n ? { origin: a, path: i } : null), m.getState().rehydrateFromPrefs(), Ya();
3128
3147
  let F = !1;
3129
- const ae = ca();
3148
+ const ae = da();
3130
3149
  return (async () => {
3131
3150
  try {
3132
3151
  await Promise.race([
3133
3152
  Promise.all([
3134
3153
  ae,
3135
- ha().then((z) => {
3154
+ ga().then((z) => {
3136
3155
  z && m.getState().rehydrateFromPrefs();
3137
3156
  }),
3138
3157
  // The character chosen in the settings popout (lib/avatar.ts).
3139
- Ma().then(Xn)
3158
+ La().then(Xn)
3140
3159
  ]),
3141
- new Promise((z) => setTimeout(z, ns))
3160
+ new Promise((z) => setTimeout(z, rs))
3142
3161
  ]);
3143
3162
  } catch (z) {
3144
3163
  I("room-chrome", "pre-join wait threw, proceeding anyway", we(z));
3145
3164
  }
3146
3165
  if (F) return;
3147
- const ie = Qi(T());
3148
- m.getState().ensureAutoIdentity(), Zi(ie);
3166
+ const ie = Zi(T());
3167
+ m.getState().ensureAutoIdentity(), es(ie);
3149
3168
  const te = m.getState();
3150
- u("room-chrome", "Joining room", { roomKey: e, name: te.name, sprite: te.sprite }), ri({ room_key: e, name: te.name || void 0, sprite: te.sprite || void 0 });
3169
+ u("room-chrome", "Joining room", { roomKey: e, name: te.name, sprite: te.sprite }), oi({ room_key: e, name: te.name || void 0, sprite: te.sprite || void 0 });
3151
3170
  })(), () => {
3152
3171
  F = !0, Vt(), Ft(null);
3153
3172
  };
3154
- }, [e, t, n, r, a, i, s, l]), /* @__PURE__ */ c(Do.Provider, { value: P, children: /* @__PURE__ */ c(kn.Provider, { value: !1, children: /* @__PURE__ */ c(Tn.Provider, { value: p, children: /* @__PURE__ */ _("div", { ref: w, className: "wp-room-chrome-frame", children: [
3173
+ }, [e, t, n, r, a, i, s, l]), /* @__PURE__ */ c(Oo.Provider, { value: P, children: /* @__PURE__ */ c(kn.Provider, { value: !1, children: /* @__PURE__ */ c(Tn.Provider, { value: p, children: /* @__PURE__ */ _("div", { ref: w, className: "wp-room-chrome-frame", children: [
3155
3174
  /* @__PURE__ */ c("div", { className: "wp-room-chrome-frame__content", children: H }),
3156
3175
  /* @__PURE__ */ c(
3157
3176
  "aside",
@@ -3171,11 +3190,11 @@ function bs({
3171
3190
  title: "Show chat",
3172
3191
  "aria-label": "Show chat",
3173
3192
  "aria-expanded": !1,
3174
- children: /* @__PURE__ */ c(ts, {})
3193
+ children: /* @__PURE__ */ c(ns, {})
3175
3194
  }
3176
3195
  ),
3177
3196
  /* @__PURE__ */ c(Yt, { className: "absolute bottom-2 right-full mr-2 w-72" }),
3178
- /* @__PURE__ */ c(Xi, { shown: g, className: "wp-room-chrome__floating" })
3197
+ /* @__PURE__ */ c(zi, { shown: g, className: "wp-room-chrome__floating" })
3179
3198
  ] }) : /* @__PURE__ */ _(le, { children: [
3180
3199
  /* @__PURE__ */ c(
3181
3200
  "div",
@@ -3197,7 +3216,7 @@ function bs({
3197
3216
  }
3198
3217
  ),
3199
3218
  /* @__PURE__ */ _("div", { className: "flex items-center gap-1 px-2 py-1.5 border-b border-border", children: [
3200
- /* @__PURE__ */ c(Vi, {}),
3219
+ /* @__PURE__ */ c(Ki, {}),
3201
3220
  /* @__PURE__ */ c("div", { className: "flex-1" }),
3202
3221
  f && /* @__PURE__ */ c(
3203
3222
  "button",
@@ -3219,25 +3238,25 @@ function bs({
3219
3238
  title: "Hide chat",
3220
3239
  "aria-label": "Hide chat",
3221
3240
  "aria-expanded": !0,
3222
- children: /* @__PURE__ */ c(es, {})
3241
+ children: /* @__PURE__ */ c(ts, {})
3223
3242
  }
3224
3243
  )
3225
3244
  ] }),
3226
- /* @__PURE__ */ c(Di, {}),
3227
- /* @__PURE__ */ c(Wi, { commands: [] }),
3245
+ /* @__PURE__ */ c(Oi, {}),
3246
+ /* @__PURE__ */ c(Gi, { commands: [] }),
3228
3247
  /* @__PURE__ */ c(Yt, { className: "absolute bottom-14 left-2 right-2" })
3229
3248
  ] })
3230
3249
  }
3231
3250
  )
3232
3251
  ] }) }) }) });
3233
3252
  }
3234
- function rs(e, t) {
3253
+ function os(e, t) {
3235
3254
  const n = m((g) => g.chromeChatCollapsed) && t, r = m((g) => g.chromeChatWidth), a = m((g) => g.toggleChromeChatCollapsed), i = m((g) => g.setChromeChatWidth), [s, l] = k(null), [d, h] = k(void 0), [f, M] = k(null);
3236
3255
  E(() => {
3237
3256
  if (s)
3238
- return Ji(s, h);
3257
+ return Qi(s, h);
3239
3258
  }, [s]);
3240
- const R = Y(f?.current ?? r, d), D = ee(() => _a(n, R), [n, R]), H = en((g) => e?.(g));
3259
+ const R = Y(f?.current ?? r, d), D = ee(() => wa(n, R), [n, R]), H = en((g) => e?.(g));
3241
3260
  return E(() => {
3242
3261
  H(D);
3243
3262
  }, [D]), {
@@ -3258,12 +3277,12 @@ function rs(e, t) {
3258
3277
  M(null), T !== r && i(T);
3259
3278
  },
3260
3279
  onKeyDown: (g) => {
3261
- const T = va(R, g.key, d);
3280
+ const T = _a(R, g.key, d);
3262
3281
  T !== null && (g.preventDefault(), T !== r && i(T));
3263
3282
  }
3264
3283
  };
3265
3284
  }
3266
3285
  export {
3267
- bs as RoomChrome
3286
+ vs as RoomChrome
3268
3287
  };
3269
3288
  //# sourceMappingURL=room-chrome.js.map