@hadoku/watchparty-ui 0.45.83 → 0.45.85

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,25 +1,25 @@
1
- import { jsx as c, jsxs as w, Fragment as se } from "react/jsx-runtime";
2
- import Oe, { useState as P, useRef as G, useMemo as te, useCallback as E, useEffect as A, createContext as ot, useContext as Xt, useSyncExternalStore as zn, useId as Xn, useEffectEvent as Jt } from "react";
3
- import { themePrefs as me, Icon as Jn, THEMES as Qn, useHadokuThemeOptional as Zn } from "@wolffm/themes";
1
+ import { jsx as c, jsxs as _, Fragment as le } from "react/jsx-runtime";
2
+ import Le, { useState as k, useRef as W, useMemo as ee, useCallback as A, useEffect as E, createContext as at, useContext as en, useSyncExternalStore as ir, useId as sr, useEffectEvent as tn } from "react";
3
+ import { themePrefs as fe, Icon as lr, THEMES as cr, useHadokuThemeOptional as dr } from "@wolffm/themes";
4
4
  import { z as o } from "zod";
5
- import { createCdnClient as er, kindOfType as tr, MAX_BYTES as nr, measureImage as rr, filesFromClipboard as or, filesFromDrop as ar, CdnError as Je } from "@wolffm/cdn-client";
6
- import { ensureCosmeticsStyles as ir, cleanWorn as sr, readPictureColour as lr, onPictureColour as cr, pictureColour as dr, decorHtml as ur, messageHtml as mr, nameHtml as fr, finishReveal as pr } from "@wolffm/prefs-client/cosmetics";
7
- import { create as hr } from "zustand";
8
- import { pickAvatar as Qt, resolveIdentityReassert as gr } from "@wolffm/rooms-protocol";
9
- import { createPrefsClient as yr, getDeviceId as br, DEVICE_ID_KEY as vr } from "@wolffm/prefs-client";
10
- import { io as Qe } from "socket.io-client";
11
- import { createAvatarClient as wr, AvatarError as Ct } from "@wolffm/prefs-client/avatar";
12
- import { relayIdentityChanges as Sr } from "@wolffm/task-ui-components/identity-relay";
13
- import { createPortal as _r } from "react-dom";
14
- import { useCatalogueSearch as xr } from "@wolffm/cdn-client/react";
15
- const Zt = "https://cdn.hadoku.me", en = /^[0-9a-f]{64}\.(?:png|jpe?g|gif|webp|avif)$/;
16
- function at(e) {
17
- return typeof e == "string" && en.test(e);
18
- }
19
- const it = 8080, tn = 5173, Cr = "/watchparty/ws", nn = 500, Ir = 1e3, J = 4, rn = typeof process < "u" && process.env ? process.env : {};
20
- rn.PRODUCTION_UI_URL;
21
- rn.PRODUCTION_SERVER_URL;
22
- const Te = o.enum(["S", "A", "B", "C", "D", "F"]), It = 2e4, Tr = 300;
5
+ import { createCdnClient as ur, kindOfType as mr, MAX_BYTES as fr, measureImage as pr, filesFromClipboard as hr, filesFromDrop as gr, CdnError as Ze } from "@wolffm/cdn-client";
6
+ import { ensureCosmeticsStyles as yr, cleanWorn as br, readPictureColour as vr, onPictureColour as _r, pictureColour as wr, decorHtml as Sr, messageHtml as nn, nameHtml as rn, finishReveal as xr } from "@wolffm/prefs-client/cosmetics";
7
+ import { create as Cr } from "zustand";
8
+ import { pickAvatar as on, resolveIdentityReassert as Ir } from "@wolffm/rooms-protocol";
9
+ import { createPrefsClient as Tr, getDeviceId as kr, DEVICE_ID_KEY as Er } from "@wolffm/prefs-client";
10
+ import { io as et } from "socket.io-client";
11
+ import { createAvatarClient as Ar, AvatarError as It } from "@wolffm/prefs-client/avatar";
12
+ import { relayIdentityChanges as Nr } from "@wolffm/task-ui-components/identity-relay";
13
+ import { createPortal as Pr } from "react-dom";
14
+ import { useCatalogueSearch as Rr } from "@wolffm/cdn-client/react";
15
+ const an = "https://cdn.hadoku.me", sn = /^[0-9a-f]{64}\.(?:png|jpe?g|gif|webp|avif)$/;
16
+ function it(e) {
17
+ return typeof e == "string" && sn.test(e);
18
+ }
19
+ const st = 8080, ln = 5173, Dr = "/watchparty/ws", cn = 500, Or = 1e3, J = 4, dn = typeof process < "u" && process.env ? process.env : {};
20
+ dn.PRODUCTION_UI_URL;
21
+ dn.PRODUCTION_SERVER_URL;
22
+ const Ee = o.enum(["S", "A", "B", "C", "D", "F"]), Tt = 2e4, Mr = 300;
23
23
  o.object({
24
24
  name: o.string().min(1).max(32).optional(),
25
25
  sprite: o.string().min(1).max(32).optional(),
@@ -46,7 +46,7 @@ const v = {
46
46
  // 'ready_state' here = playback-readiness gate (distinct from READY_EVENTS.STATE = "ready check" UX feature)
47
47
  READY_STATE: "ready_state",
48
48
  ERROR: "error"
49
- }, kr = o.enum(["play", "pause", "seek", "load", "home"]), Er = o.object({
49
+ }, Lr = o.enum(["play", "pause", "seek", "load", "home"]), jr = o.object({
50
50
  framed: o.boolean(),
51
51
  depth: o.number().int().nonnegative().max(10)
52
52
  });
@@ -54,7 +54,7 @@ o.object({
54
54
  room_key: o.string(),
55
55
  name: o.string().min(1).max(32).optional(),
56
56
  sprite: o.string().min(1).max(32).optional(),
57
- embed: Er.optional(),
57
+ embed: jr.optional(),
58
58
  /** Which media-delivery path this client resolved to ('range' | 'fragment').
59
59
  * Optional so older clients still validate. Reported so a party's logs can be split by
60
60
  * arm — without it an A/B rollout is unmeasurable, exactly as entry path was before
@@ -102,13 +102,13 @@ o.object({
102
102
  });
103
103
  o.object({
104
104
  client_seq: o.number().int().positive(),
105
- kind: kr,
105
+ kind: Lr,
106
106
  to_ms: o.number().int().nonnegative().optional(),
107
107
  media_id: o.string().optional()
108
108
  // leader_id removed - not needed since set_leader control was removed
109
109
  });
110
- const on = o.object({
111
- key: o.string().regex(en, "not a CDN image key"),
110
+ const un = o.object({
111
+ key: o.string().regex(sn, "not a CDN image key"),
112
112
  /**
113
113
  * Intrinsic pixels, or **0 meaning "unknown"**.
114
114
  *
@@ -121,8 +121,8 @@ const on = o.object({
121
121
  * text went with it, with nothing said. Widening is backward compatible —
122
122
  * every message already in history carries positive dimensions.
123
123
  */
124
- w: o.number().int().nonnegative().max(It),
125
- h: o.number().int().nonnegative().max(It),
124
+ w: o.number().int().nonnegative().max(Tt),
125
+ h: o.number().int().nonnegative().max(Tt),
126
126
  /**
127
127
  * Human-readable description, rendered as the `alt` text.
128
128
  *
@@ -136,14 +136,14 @@ const on = o.object({
136
136
  * value only, never as markup. Bounded so one message cannot carry a
137
137
  * paragraph; the library's own titles run well under this.
138
138
  */
139
- title: o.string().max(Tr).optional()
139
+ title: o.string().max(Mr).optional()
140
140
  });
141
141
  o.object({
142
- text: o.string().max(nn),
142
+ text: o.string().max(cn),
143
143
  style: o.string().max(64).optional(),
144
- images: o.array(on).max(J).optional()
144
+ images: o.array(un).max(J).optional()
145
145
  }).refine((e) => e.text.length > 0 || (e.images?.length ?? 0) > 0, { message: "message must carry text or at least one image" });
146
- const Ar = o.enum(["join", "leave", "media_change", "identity_change", "recap"]);
146
+ const Ur = o.enum(["join", "leave", "media_change", "identity_change", "recap"]);
147
147
  o.object({
148
148
  id: o.string(),
149
149
  client_id: o.string(),
@@ -156,16 +156,16 @@ o.object({
156
156
  ts: o.number(),
157
157
  // Optional so a client on an older bundle still validates a message that
158
158
  // has none, and so system messages (which never carry images) stay unchanged.
159
- images: o.array(on).max(J).optional(),
159
+ images: o.array(un).max(J).optional(),
160
160
  isSystem: o.boolean().optional(),
161
- systemType: Ar.optional(),
161
+ systemType: Ur.optional(),
162
162
  /** A system line about a person: its text with `CHAT_NAME_TOKEN` where their
163
163
  * name goes. `text` is that template filled when sent; a client fills it
164
164
  * again with the person's CURRENT name (found by `author`) while they are
165
165
  * here, so a rename reaches lines already on screen. */
166
166
  template: o.string().optional()
167
167
  });
168
- const an = "{name}", Nr = o.object({
168
+ const mn = "{name}", Fr = o.object({
169
169
  avg_download_rate_bps: o.number().nonnegative(),
170
170
  buffered_ahead_ms: o.number().nonnegative(),
171
171
  rtt_ms: o.number().nonnegative(),
@@ -207,7 +207,7 @@ const an = "{name}", Nr = o.object({
207
207
  * socket shows here as a growing number while everything else looks fine. */
208
208
  pong_age_ms: o.number().int().nonnegative().optional(),
209
209
  reported_at: o.number().int().nonnegative()
210
- }), Pr = Nr.extend({
210
+ }), Hr = Fr.extend({
211
211
  client_id: o.string(),
212
212
  name: o.string(),
213
213
  sprite_id: o.string().nullable(),
@@ -218,10 +218,10 @@ const an = "{name}", Nr = o.object({
218
218
  stale_ms: o.number().int().nonnegative().optional()
219
219
  });
220
220
  o.object({
221
- clients: o.array(Pr),
221
+ clients: o.array(Hr),
222
222
  server_ts: o.number().int().nonnegative()
223
223
  });
224
- const Rr = o.object({
224
+ const $r = o.object({
225
225
  client_id: o.string(),
226
226
  sprite_id: o.string().nullable(),
227
227
  name: o.string(),
@@ -239,13 +239,13 @@ const Rr = o.object({
239
239
  video_ready_state: o.number().int().default(-1)
240
240
  });
241
241
  o.object({
242
- clients: o.array(Rr),
242
+ clients: o.array($r),
243
243
  server_ts: o.number().int().nonnegative()
244
244
  });
245
245
  o.object({
246
246
  media_id: o.string()
247
247
  });
248
- const st = o.enum(["super_upvote", "upvote", "mid", "downvote"]), Dr = o.object({
248
+ const lt = o.enum(["super_upvote", "upvote", "mid", "downvote"]), Br = o.object({
249
249
  mediaId: o.string(),
250
250
  displayName: o.string(),
251
251
  // Enrichment fields — present for flat-playlist ingest output, absent for
@@ -256,11 +256,11 @@ const st = o.enum(["super_upvote", "upvote", "mid", "downvote"]), Dr = o.object(
256
256
  durationMs: o.number().optional(),
257
257
  uploadDate: o.string().optional()
258
258
  // YouTube upload date 'YYYY-MM-DD'; drives playlist order
259
- }), Or = o.enum(["basic", "vote"]), sn = o.object({
259
+ }), Gr = o.enum(["basic", "vote"]), fn = o.object({
260
260
  id: o.string(),
261
261
  name: o.string(),
262
- type: Or.default("vote"),
263
- videos: o.array(Dr),
262
+ type: Gr.default("vote"),
263
+ videos: o.array(Br),
264
264
  cover: o.string().optional()
265
265
  // media-relative path to the playlist cover image
266
266
  });
@@ -269,28 +269,28 @@ o.object({ index: o.number().int().min(0) });
269
269
  o.object({
270
270
  playlistId: o.string(),
271
271
  mediaId: o.string(),
272
- vote: st
272
+ vote: lt
273
273
  });
274
274
  o.object({ voterKey: o.string().min(1).max(128) });
275
275
  o.object({ playlistId: o.string(), mediaIds: o.array(o.string()) });
276
276
  o.object({
277
- playlist: sn.nullable(),
277
+ playlist: fn.nullable(),
278
278
  activeIndex: o.number().int().nullable(),
279
- myVotes: o.record(o.string(), st)
279
+ myVotes: o.record(o.string(), lt)
280
280
  // mediaId -> VoteValue
281
281
  });
282
- const Lr = o.object({
282
+ const Wr = o.object({
283
283
  clientId: o.string(),
284
284
  name: o.string(),
285
285
  votedCount: o.number().int().nonnegative(),
286
286
  totalVideos: o.number().int().nonnegative()
287
287
  });
288
288
  o.object({
289
- progress: o.array(Lr)
289
+ progress: o.array(Wr)
290
290
  });
291
291
  o.object({
292
- playlist: sn,
293
- votes: o.record(o.string(), o.record(o.string(), st)),
292
+ playlist: fn,
293
+ votes: o.record(o.string(), o.record(o.string(), lt)),
294
294
  // votes[clientId][mediaId]
295
295
  names: o.record(o.string(), o.string()),
296
296
  // clientId -> display name
@@ -309,37 +309,37 @@ o.object({
309
309
  * reveal is closed ignores it, rather than having the popup reappear. */
310
310
  update: o.boolean().optional()
311
311
  });
312
- const we = {
312
+ const Se = {
313
313
  STATE: "playlist_state",
314
314
  VOTE_PROGRESS: "playlist_vote_progress",
315
315
  RESULTS: "playlist_results",
316
316
  /** Server -> the removed voter: forget the ballot you hold in localStorage. */
317
317
  VOTES_CLEARED: "playlist_votes_cleared"
318
- }, ln = o.object({
318
+ }, pn = o.object({
319
319
  id: o.string(),
320
320
  displayName: o.string(),
321
321
  thumbnail: o.string().optional()
322
322
  });
323
323
  o.object({
324
- items: o.array(ln)
324
+ items: o.array(pn)
325
325
  });
326
- const cn = o.partialRecord(Te, o.array(o.string()));
327
- o.object({ board: cn });
328
- const Mr = o.object({
326
+ const hn = o.partialRecord(Ee, o.array(o.string()));
327
+ o.object({ board: hn });
328
+ const Vr = o.object({
329
329
  mediaId: o.string(),
330
- tier: Te,
331
- absoluteTier: Te,
330
+ tier: Ee,
331
+ absoluteTier: Ee,
332
332
  /** Tier level + within-row position. Integer part is the tier. */
333
333
  score: o.number(),
334
334
  /** The consensus mean that decided the tier. Never the displayed number. */
335
335
  placementScore: o.number(),
336
336
  subRankOffset: o.number(),
337
- votes: o.record(o.string(), Te)
337
+ votes: o.record(o.string(), Ee)
338
338
  // opaque voterId -> the letter they gave
339
339
  });
340
340
  o.object({
341
- items: o.array(ln),
342
- placed: o.array(Mr),
341
+ items: o.array(pn),
342
+ placed: o.array(Vr),
343
343
  unrated: o.array(o.string()),
344
344
  spread: o.number(),
345
345
  nudged: o.boolean(),
@@ -349,9 +349,9 @@ o.object({
349
349
  * browser on a newer bundle still reads an older server's board. */
350
350
  pictures: o.record(o.string(), o.string()).optional(),
351
351
  voterCount: o.number().int().nonnegative(),
352
- myBoard: cn
352
+ myBoard: hn
353
353
  });
354
- const jr = {
354
+ const qr = {
355
355
  /** Broadcast to EVERY connected socket when anyone saves. Carries no board —
356
356
  * it is a "re-fetch" ping, because the shared result is identical for all
357
357
  * viewers but `myBoard` is not, and one payload cannot serve both. */
@@ -364,10 +364,10 @@ o.object({
364
364
  ready: o.array(o.string())
365
365
  // clientIds who have flagged ready
366
366
  });
367
- const Ur = {
367
+ const Kr = {
368
368
  STATE: "ready_check_state"
369
369
  // distinct from buffer-readiness 'ready_state'
370
- }, dn = {
370
+ }, gn = {
371
371
  ACTIVE: "game_active",
372
372
  // server -> room (the open game id; null = none)
373
373
  SYNC: "game_sync"
@@ -379,7 +379,7 @@ o.object({
379
379
  o.object({
380
380
  gameId: o.string().nullable()
381
381
  });
382
- const Hr = [
382
+ const Yr = [
383
383
  {
384
384
  id: "fantasy",
385
385
  characters: [
@@ -423,37 +423,37 @@ const Hr = [
423
423
  { id: "mentor", color: "#e1e0dc" }
424
424
  ]
425
425
  }
426
- ], lt = Hr.flatMap((e) => e.characters), Fe = lt.map((e) => e.id), Fr = Object.fromEntries(lt.map((e) => [e.id, e.color])), $r = Object.fromEntries(lt.map((e) => [e.id, "rev" in e ? e.rev : 1]));
427
- function Br(e) {
428
- const t = $r[e];
426
+ ], ct = Yr.flatMap((e) => e.characters), Be = ct.map((e) => e.id), zr = Object.fromEntries(ct.map((e) => [e.id, e.color])), Xr = Object.fromEntries(ct.map((e) => [e.id, "rev" in e ? e.rev : 1]));
427
+ function Jr(e) {
428
+ const t = Xr[e];
429
429
  return `/media/sprites/square_${e}.png${t > 1 ? `?v=${t}` : ""}`;
430
430
  }
431
- function ct(e) {
432
- return !!e && Fe.includes(e);
431
+ function dt(e) {
432
+ return !!e && Be.includes(e);
433
433
  }
434
- const Gr = 5e3, un = { mode: "off", percent: 0 }, Wr = ["off", "on", "ab"];
435
- function qr(e) {
436
- return typeof e == "string" && Wr.includes(e);
434
+ const Qr = 5e3, yn = { mode: "off", percent: 0 }, Zr = ["off", "on", "ab"];
435
+ function eo(e) {
436
+ return typeof e == "string" && Zr.includes(e);
437
437
  }
438
- function Vr(e) {
439
- const t = e && typeof e == "object" ? e : {}, n = qr(t.mode) ? t.mode : un.mode, r = Number(t.percent), a = Number.isFinite(r) ? Math.min(100, Math.max(0, Math.round(r))) : 0;
438
+ function to(e) {
439
+ const t = e && typeof e == "object" ? e : {}, n = eo(t.mode) ? t.mode : yn.mode, r = Number(t.percent), a = Number.isFinite(r) ? Math.min(100, Math.max(0, Math.round(r))) : 0;
440
440
  return { mode: n, percent: a };
441
441
  }
442
- function Kr(e) {
442
+ function no(e) {
443
443
  let t = 2166136261;
444
444
  for (let n = 0; n < e.length; n++)
445
445
  t ^= e.charCodeAt(n), t = Math.imul(t, 16777619) >>> 0;
446
446
  return t >>> 0;
447
447
  }
448
- function Yr(e, t, n) {
448
+ function ro(e, t, n) {
449
449
  if (n === !0)
450
450
  return "fragment";
451
451
  if (n === !1)
452
452
  return "range";
453
- const r = Vr(e);
454
- return r.mode === "on" ? "fragment" : r.mode === "off" || r.percent <= 0 ? "range" : r.percent >= 100 || t && Kr(t) % 100 < r.percent ? "fragment" : "range";
453
+ const r = to(e);
454
+ return r.mode === "on" ? "fragment" : r.mode === "off" || r.percent <= 0 ? "range" : r.percent >= 100 || t && no(t) % 100 < r.percent ? "fragment" : "range";
455
455
  }
456
- const mn = o.enum(["url", "magnet", "upload"]), zr = o.enum([
456
+ const bn = o.enum(["url", "magnet", "upload"]), oo = o.enum([
457
457
  "pending",
458
458
  "approved",
459
459
  "fetching",
@@ -461,7 +461,7 @@ const mn = o.enum(["url", "magnet", "upload"]), zr = o.enum([
461
461
  "ready",
462
462
  "rejected",
463
463
  "failed"
464
- ]), Tt = {
464
+ ]), kt = {
465
465
  pending: ["approved", "rejected"],
466
466
  approved: ["fetching", "rejected", "failed"],
467
467
  fetching: ["ingesting", "failed"],
@@ -470,12 +470,12 @@ const mn = o.enum(["url", "magnet", "upload"]), zr = o.enum([
470
470
  rejected: [],
471
471
  failed: ["approved"]
472
472
  };
473
- Object.keys(Tt).filter((e) => Tt[e].length === 0);
474
- const Xr = o.object({
473
+ Object.keys(kt).filter((e) => kt[e].length === 0);
474
+ const ao = o.object({
475
475
  id: o.string().min(1),
476
476
  /** Stable userId from whoami. Never the raw `X-User-Key`. */
477
477
  ownerUserId: o.string().min(1),
478
- kind: mn,
478
+ kind: bn,
479
479
  /** The magnet URI, the https URL, or the filetransfer binding id. */
480
480
  source: o.string().min(1),
481
481
  title: o.string().optional(),
@@ -490,7 +490,7 @@ const Xr = o.object({
490
490
  * misroute the copy.
491
491
  */
492
492
  series: o.string().optional(),
493
- state: zr,
493
+ state: oo,
494
494
  createdAt: o.number().int().nonnegative(),
495
495
  updatedAt: o.number().int().nonnegative(),
496
496
  /** Why it failed, or why an operator rejected it. */
@@ -498,19 +498,19 @@ const Xr = o.object({
498
498
  /** Size once known. 0 means "known to be empty"; absent means "not yet known" —
499
499
  * the same distinction `chatImages` draws for image dimensions. */
500
500
  bytes: o.number().int().nonnegative().optional()
501
- }), Jr = 4096, fn = 300, Qr = 100;
501
+ }), io = 4096, vn = 300, so = 100;
502
502
  o.object({
503
- kind: mn,
504
- source: o.string().min(1).max(Jr),
505
- title: o.string().min(1).max(fn).optional(),
503
+ kind: bn,
504
+ source: o.string().min(1).max(io),
505
+ title: o.string().min(1).max(vn).optional(),
506
506
  /** Required for `kind: 'magnet'` by `checkSource`; ignored for `url`/`upload`. */
507
- series: o.string().min(1).max(Qr).optional()
507
+ series: o.string().min(1).max(so).optional()
508
508
  });
509
509
  o.object({
510
- reason: o.string().min(1).max(fn).optional()
510
+ reason: o.string().min(1).max(vn).optional()
511
511
  });
512
512
  o.object({
513
- submissions: o.array(Xr)
513
+ submissions: o.array(ao)
514
514
  });
515
515
  o.object({
516
516
  error: o.literal("submissions/quota_exceeded"),
@@ -519,26 +519,26 @@ o.object({
519
519
  /** The cap that was applied, from the server's config. */
520
520
  capBytes: o.number().int().nonnegative()
521
521
  });
522
- const Zr = /^[a-z0-9][a-z0-9-]{0,31}$/, kt = "https://game-catalog.invalid";
523
- function eo(e) {
522
+ const lo = /^[a-z0-9][a-z0-9-]{0,31}$/, Et = "https://game-catalog.invalid";
523
+ function co(e) {
524
524
  if (!e.startsWith("/") || e.startsWith("//") || /[\\\s]/.test(e) || [...e].some((t) => t.charCodeAt(0) < 32 || t.charCodeAt(0) === 127))
525
525
  return !1;
526
526
  try {
527
- return new URL(e, kt).origin === kt;
527
+ return new URL(e, Et).origin === Et;
528
528
  } catch {
529
529
  return !1;
530
530
  }
531
531
  }
532
- const pn = o.string().min(2).max(512).refine(eo, {
532
+ const _n = o.string().min(2).max(512).refine(co, {
533
533
  message: "must be a root-relative path on the page origin (e.g. /cardtable/embed/x.js)"
534
- }), to = {
535
- id: o.string().regex(Zr),
534
+ }), uo = {
535
+ id: o.string().regex(lo),
536
536
  name: o.string().min(1).max(64),
537
- cover: pn.optional()
538
- }, no = o.object({ ...to, kind: o.literal("module"), url: pn }).strict();
539
- o.array(no).max(32).refine((e) => new Set(e.map((t) => t.id)).size === e.length, { message: "game ids must be unique" });
540
- const dt = o.enum(["anilist", "tmdb"]), ro = o.object({
541
- source: dt,
537
+ cover: _n.optional()
538
+ }, mo = o.object({ ...uo, kind: o.literal("module"), url: _n }).strict();
539
+ o.array(mo).max(32).refine((e) => new Set(e.map((t) => t.id)).size === e.length, { message: "game ids must be unique" });
540
+ const ut = o.enum(["anilist", "tmdb"]), fo = o.object({
541
+ source: ut,
542
542
  /** The provider's own id, as a string (AniList and TMDB both use integers). */
543
543
  id: o.string(),
544
544
  title: o.string(),
@@ -559,11 +559,11 @@ const dt = o.enum(["anilist", "tmdb"]), ro = o.object({
559
559
  addable: o.boolean()
560
560
  });
561
561
  o.object({
562
- results: o.array(ro),
562
+ results: o.array(fo),
563
563
  /** Providers that answered. TMDB is absent when no token is configured. */
564
- sources: o.array(dt)
564
+ sources: o.array(ut)
565
565
  });
566
- const oo = o.object({
566
+ const po = o.object({
567
567
  id: o.string(),
568
568
  url: o.string(),
569
569
  title: o.string(),
@@ -571,35 +571,35 @@ const oo = o.object({
571
571
  durationS: o.number().nullable(),
572
572
  thumb: o.string().nullable()
573
573
  });
574
- o.object({ results: o.array(oo) });
574
+ o.object({ results: o.array(po) });
575
575
  o.object({
576
- source: dt,
576
+ source: ut,
577
577
  id: o.string().regex(/^\d{1,12}$/)
578
578
  });
579
579
  o.object({ series: o.string(), title: o.string() });
580
- let Se = null, hn = Zt;
581
- function ao(e) {
582
- e.cdnBase && (hn = e.cdnBase);
580
+ let xe = null, wn = an;
581
+ function ho(e) {
582
+ e.cdnBase && (wn = e.cdnBase);
583
583
  }
584
- function gn() {
585
- return hn.replace(/\/+$/, "");
584
+ function Sn() {
585
+ return wn.replace(/\/+$/, "");
586
586
  }
587
- function $e() {
588
- const e = gn();
589
- return (!Se || Se.base !== e) && (Se = { base: e, client: er({ cdnBase: e }) }), Se.client;
587
+ function Ge() {
588
+ const e = Sn();
589
+ return (!xe || xe.base !== e) && (xe = { base: e, client: ur({ cdnBase: e }) }), xe.client;
590
590
  }
591
- function Le(e) {
592
- return !at(e) || !gn() ? null : $e().urlFor(e);
591
+ function je(e) {
592
+ return !it(e) || !Sn() ? null : Ge().urlFor(e);
593
593
  }
594
- function io(e) {
594
+ function go(e) {
595
595
  return e.kind === "file";
596
596
  }
597
- class yn extends Error {
597
+ class xn extends Error {
598
598
  constructor(t) {
599
599
  super(t), this.name = "ChatImageUploadError";
600
600
  }
601
601
  }
602
- function ke(e) {
602
+ function Ae(e) {
603
603
  switch (e) {
604
604
  case "unauthenticated":
605
605
  return "Sign in to paste images";
@@ -619,120 +619,120 @@ function ke(e) {
619
619
  return "Image upload failed";
620
620
  }
621
621
  }
622
- function so(e) {
623
- return e instanceof Je ? ke(e.reason) : e instanceof yn ? e.message : "Image upload failed";
622
+ function yo(e) {
623
+ return e instanceof Ze ? Ae(e.reason) : e instanceof xn ? e.message : "Image upload failed";
624
624
  }
625
- function lo(e) {
625
+ function bo(e) {
626
626
  const t = e.type.toLowerCase().split(";")[0].trim();
627
- return t && tr(t) !== "image" ? ke("unsupported-type") : e.size > nr.image ? ke("too-large") : e.size === 0 ? ke("invalid") : null;
627
+ return t && mr(t) !== "image" ? Ae("unsupported-type") : e.size > fr.image ? Ae("too-large") : e.size === 0 ? Ae("invalid") : null;
628
628
  }
629
- function co(e) {
630
- return or(e);
629
+ function vo(e) {
630
+ return hr(e);
631
631
  }
632
- function uo(e) {
633
- return ar(e);
632
+ function _o(e) {
633
+ return gr(e);
634
634
  }
635
- async function mo(e) {
636
- const t = await rr(e);
635
+ async function wo(e) {
636
+ const t = await pr(e);
637
637
  return { w: t?.width ?? 0, h: t?.height ?? 0 };
638
638
  }
639
- async function fo(e, t = {}) {
640
- const n = await $e().upload(e, { signal: t.signal });
641
- if (!at(n.key))
642
- throw new yn("Image upload returned an unusable key");
639
+ async function So(e, t = {}) {
640
+ const n = await Ge().upload(e, { signal: t.signal });
641
+ if (!it(n.key))
642
+ throw new xn("Image upload returned an unusable key");
643
643
  return { key: n.key, deduplicated: n.deduplicated === !0 };
644
644
  }
645
- async function po(e, t = {}) {
645
+ async function xo(e, t = {}) {
646
646
  const n = [];
647
647
  for (const r of e) {
648
648
  if (r.kind === "remote") {
649
649
  n.push({ key: r.key, w: r.w, h: r.h, ...r.title ? { title: r.title } : {} });
650
650
  continue;
651
651
  }
652
- const { key: a } = await fo(r.file, t);
652
+ const { key: a } = await So(r.file, t);
653
653
  n.push({ key: a, w: r.w, h: r.h });
654
654
  }
655
655
  return n;
656
656
  }
657
- function ho(e) {
657
+ function Co(e) {
658
658
  return {
659
659
  error: e instanceof Error ? e.message : String(e),
660
660
  name: e instanceof Error ? e.name : typeof e,
661
- reason: e instanceof Je ? e.reason : void 0,
662
- status: e instanceof Je ? e.status : void 0
661
+ reason: e instanceof Ze ? e.reason : void 0,
662
+ status: e instanceof Ze ? e.status : void 0
663
663
  };
664
664
  }
665
- function ut(e) {
665
+ function mt(e) {
666
666
  return e.key === "Escape" || e.key === "GoBack" || e.key === "BrowserBack" || e.key === "XF86Back" || e.keyCode === 461 || e.keyCode === 10009;
667
667
  }
668
- function go(e) {
668
+ function Io(e) {
669
669
  return `/tv?return=${encodeURIComponent(e.pathname + e.search)}`;
670
670
  }
671
- function yo({ className: e }) {
671
+ function To({ className: e }) {
672
672
  return /* @__PURE__ */ c(
673
673
  "a",
674
674
  {
675
- href: go(window.location),
675
+ href: Io(window.location),
676
676
  className: e,
677
677
  "data-testid": "sign-in-with-code",
678
678
  children: "Sign in with a code"
679
679
  }
680
680
  );
681
681
  }
682
- const Ze = 240, ee = 8, bo = 28, bn = 240;
683
- function vo(e, t, n) {
684
- let r = t.left - Ze - ee;
685
- r < ee && (r = t.right + ee), r = Math.min(r, n.width - Ze - ee), r = Math.max(ee, r);
686
- const a = bn + bo;
682
+ const tt = 240, ne = 8, ko = 28, Cn = 240;
683
+ function Eo(e, t, n) {
684
+ let r = t.left - tt - ne;
685
+ r < ne && (r = t.right + ne), r = Math.min(r, n.width - tt - ne), r = Math.max(ne, r);
686
+ const a = Cn + ko;
687
687
  let i = e.top + e.height / 2 - a / 2;
688
- return i = Math.min(i, n.height - a - ee), i = Math.max(ee, i), { left: r, top: i };
688
+ return i = Math.min(i, n.height - a - ne), i = Math.max(ne, i), { left: r, top: i };
689
689
  }
690
- const vn = "/dataplatform/api/memes", wo = 120;
691
- function So({ onClose: e, onPick: t, onUnavailable: n }) {
692
- const [r, a] = P(""), i = G(null), s = G(null), l = $e(), { items: f, loading: h, error: u, hasMore: L, loadMore: R } = xr(
690
+ const In = "/dataplatform/api/memes", Ao = 120;
691
+ function No({ onClose: e, onPick: t, onUnavailable: n }) {
692
+ const [r, a] = k(""), i = W(null), s = W(null), l = Ge(), { items: d, loading: h, error: f, hasMore: M, loadMore: R } = Rr(
693
693
  l,
694
- vn,
694
+ In,
695
695
  r.trim()
696
- ), D = u?.reason ?? null, U = te(() => {
696
+ ), D = f?.reason ?? null, F = ee(() => {
697
697
  const C = /* @__PURE__ */ new Set();
698
- return f.filter((O) => C.has(O.key) ? !1 : (C.add(O.key), !0));
699
- }, [f]), [p, x] = P(null), S = G(null), y = E(() => {
700
- S.current !== null && (window.clearTimeout(S.current), S.current = null);
701
- }, []), g = E(() => {
698
+ return d.filter((O) => C.has(O.key) ? !1 : (C.add(O.key), !0));
699
+ }, [d]), [p, x] = k(null), w = W(null), y = A(() => {
700
+ w.current !== null && (window.clearTimeout(w.current), w.current = null);
701
+ }, []), g = A(() => {
702
702
  y(), x(null);
703
- }, [y]), T = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(hover: hover)").matches, N = E(
704
- (C, O, k = !1) => {
705
- const oe = i.current;
706
- if (!oe) return;
703
+ }, [y]), T = typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(hover: hover)").matches, N = A(
704
+ (C, O, P = !1) => {
705
+ const H = i.current;
706
+ if (!H) return;
707
707
  const ae = () => x({
708
708
  item: C,
709
- ...vo(O.getBoundingClientRect(), oe.getBoundingClientRect(), {
709
+ ...Eo(O.getBoundingClientRect(), H.getBoundingClientRect(), {
710
710
  width: window.innerWidth,
711
711
  height: window.innerHeight
712
712
  })
713
713
  });
714
- y(), k ? ae() : S.current = window.setTimeout(ae, wo);
714
+ y(), P ? ae() : w.current = window.setTimeout(ae, Ao);
715
715
  },
716
716
  [y]
717
717
  );
718
- A(() => () => y(), [y]), A(() => {
718
+ E(() => () => y(), [y]), E(() => {
719
719
  D === "unavailable" && n?.();
720
- }, [D, n]), A(() => {
720
+ }, [D, n]), E(() => {
721
721
  s.current?.focus();
722
- }, []), A(() => {
723
- const C = (k) => {
724
- ut(k) && (k.stopPropagation(), e());
725
- }, O = (k) => {
726
- i.current && !i.current.contains(k.target) && e();
722
+ }, []), E(() => {
723
+ const C = (P) => {
724
+ mt(P) && (P.stopPropagation(), e());
725
+ }, O = (P) => {
726
+ i.current && !i.current.contains(P.target) && e();
727
727
  };
728
728
  return document.addEventListener("keydown", C), document.addEventListener("mousedown", O), () => {
729
729
  document.removeEventListener("keydown", C), document.removeEventListener("mousedown", O);
730
730
  };
731
731
  }, [e]);
732
- const j = E((C) => {
732
+ const j = A((C) => {
733
733
  t(C), e();
734
- }, [t, e]), H = !h && !u && U.length === 0;
735
- return /* @__PURE__ */ w(
734
+ }, [t, e]), U = !h && !f && F.length === 0;
735
+ return /* @__PURE__ */ _(
736
736
  "div",
737
737
  {
738
738
  ref: i,
@@ -754,28 +754,28 @@ function So({ onClose: e, onPick: t, onUnavailable: n }) {
754
754
  className: "w-full rounded border border-border-light bg-bg-alt px-2 py-1 text-sm text-text placeholder:text-text-secondary focus:outline-none focus:border-primary"
755
755
  }
756
756
  ) }),
757
- /* @__PURE__ */ w(
757
+ /* @__PURE__ */ _(
758
758
  "div",
759
759
  {
760
760
  className: "flex-1 overflow-y-auto p-2",
761
761
  onScroll: g,
762
762
  onMouseLeave: g,
763
763
  children: [
764
- u && /* @__PURE__ */ c(
764
+ f && /* @__PURE__ */ c(
765
765
  "p",
766
766
  {
767
767
  className: "m-2 p-2 text-center text-sm bg-danger-bg text-on-danger-bg rounded",
768
768
  role: "alert",
769
769
  "data-reason": D,
770
- children: D === "unauthenticated" ? /* @__PURE__ */ w(se, { children: [
770
+ children: D === "unauthenticated" ? /* @__PURE__ */ _(le, { children: [
771
771
  "Sign in to browse memes · ",
772
- /* @__PURE__ */ c(yo, { className: "underline text-on-danger-bg" })
772
+ /* @__PURE__ */ c(To, { className: "underline text-on-danger-bg" })
773
773
  ] }) : D === "forbidden" ? "Your account can't browse the meme library" : "Meme library is unavailable"
774
774
  }
775
775
  ),
776
- H && /* @__PURE__ */ c("p", { className: "p-4 text-center text-sm text-text-secondary", children: r.trim() ? `No memes match "${r.trim()}"` : "The meme library is empty" }),
777
- U.length > 0 && /* @__PURE__ */ c("div", { className: "grid grid-cols-3 gap-1.5 sm:grid-cols-4", children: U.map((C) => {
778
- const O = Le(C.key);
776
+ U && /* @__PURE__ */ c("p", { className: "p-4 text-center text-sm text-text-secondary", children: r.trim() ? `No memes match "${r.trim()}"` : "The meme library is empty" }),
777
+ F.length > 0 && /* @__PURE__ */ c("div", { className: "grid grid-cols-3 gap-1.5 sm:grid-cols-4", children: F.map((C) => {
778
+ const O = je(C.key);
779
779
  return O ? /* @__PURE__ */ c(
780
780
  "button",
781
781
  {
@@ -783,11 +783,11 @@ function So({ onClose: e, onPick: t, onUnavailable: n }) {
783
783
  onClick: () => j(C),
784
784
  title: C.title,
785
785
  "data-testid": "meme-result",
786
- onMouseEnter: (k) => {
787
- T && N(C, k.currentTarget);
786
+ onMouseEnter: (P) => {
787
+ T && N(C, P.currentTarget);
788
788
  },
789
789
  onMouseLeave: g,
790
- onFocus: (k) => N(C, k.currentTarget, !0),
790
+ onFocus: (P) => N(C, P.currentTarget, !0),
791
791
  onBlur: g,
792
792
  className: "group relative aspect-square overflow-hidden rounded border border-border-light bg-bg-alt focus:outline-none focus:border-primary hover:border-primary",
793
793
  children: /* @__PURE__ */ c(
@@ -805,7 +805,7 @@ function So({ onClose: e, onPick: t, onUnavailable: n }) {
805
805
  ) : null;
806
806
  }) }),
807
807
  h && /* @__PURE__ */ c("p", { className: "p-2 text-center text-xs text-text-secondary", children: "Loading…" }),
808
- L && !h && /* @__PURE__ */ c(
808
+ M && !h && /* @__PURE__ */ c(
809
809
  "button",
810
810
  {
811
811
  type: "button",
@@ -818,7 +818,7 @@ function So({ onClose: e, onPick: t, onUnavailable: n }) {
818
818
  ]
819
819
  }
820
820
  ),
821
- p && /* @__PURE__ */ w(
821
+ p && /* @__PURE__ */ _(
822
822
  "div",
823
823
  {
824
824
  "data-testid": "meme-preview",
@@ -826,7 +826,7 @@ function So({ onClose: e, onPick: t, onUnavailable: n }) {
826
826
  style: {
827
827
  left: p.left,
828
828
  top: p.top,
829
- width: Ze,
829
+ width: tt,
830
830
  /* The placement maths reserves exactly PREVIEW_PX of width.
831
831
  Without border-box the padding and border sit OUTSIDE that
832
832
  number and the box laps over the panel it is meant to sit
@@ -840,10 +840,10 @@ function So({ onClose: e, onPick: t, onUnavailable: n }) {
840
840
  /* @__PURE__ */ c(
841
841
  "img",
842
842
  {
843
- src: Le(p.item.key) ?? void 0,
843
+ src: je(p.item.key) ?? void 0,
844
844
  alt: "",
845
845
  className: "block w-full rounded bg-bg object-contain",
846
- style: { height: "auto", maxHeight: bn }
846
+ style: { height: "auto", maxHeight: Cn }
847
847
  }
848
848
  ),
849
849
  p.item.title && /* One line. A long title must not change the box height, because
@@ -856,53 +856,53 @@ function So({ onClose: e, onPick: t, onUnavailable: n }) {
856
856
  }
857
857
  );
858
858
  }
859
- function _o({ open: e, ...t }) {
860
- return e ? /* @__PURE__ */ c(So, { ...t }) : null;
859
+ function Po({ open: e, ...t }) {
860
+ return e ? /* @__PURE__ */ c(No, { ...t }) : null;
861
861
  }
862
- const mt = {
863
- serverOrigin: `http://localhost:${it}`,
862
+ const ft = {
863
+ serverOrigin: `http://localhost:${st}`,
864
864
  defaultRoomKey: "dev-room",
865
- cdnBase: Zt
865
+ cdnBase: an
866
866
  };
867
- let Ee = { ...mt };
868
- function xo(e) {
867
+ let Ne = { ...ft };
868
+ function Ro(e) {
869
869
  const t = Object.fromEntries(
870
870
  Object.entries(e).filter(([n, r]) => r !== void 0)
871
871
  );
872
- Ee = { ...Ee, ...t }, ao({ cdnBase: Ee.cdnBase });
872
+ Ne = { ...Ne, ...t }, ho({ cdnBase: Ne.cdnBase });
873
873
  }
874
- function be() {
875
- return Ee;
874
+ function _e() {
875
+ return Ne;
876
876
  }
877
- const Co = ot(mt);
878
- function Io(e) {
877
+ const Do = at(ft);
878
+ function Oo(e) {
879
879
  return e.serverOrigin?.replace(/\/$/, "") || "";
880
880
  }
881
- function wn() {
882
- return Io(be());
881
+ function Tn() {
882
+ return Oo(_e());
883
883
  }
884
- const Sn = ot(null);
885
- function To() {
886
- return Xt(Sn);
884
+ const kn = at(null);
885
+ function Mo() {
886
+ return en(kn);
887
887
  }
888
- const _n = ot(!0);
889
- function ko() {
890
- const e = Xt(_n);
891
- A(() => {
892
- e && ir();
888
+ const En = at(!0);
889
+ function An() {
890
+ const e = en(En);
891
+ E(() => {
892
+ e && yr();
893
893
  }, [e]);
894
894
  }
895
- function Eo(e) {
895
+ function Nn(e) {
896
896
  return e ? { "--hc-base": e } : {};
897
897
  }
898
- const et = Oe.memo(
898
+ const ge = Le.memo(
899
899
  function({ html: t, as: n = "span", className: r, style: a }) {
900
- return Oe.createElement(n, { className: r, style: a, dangerouslySetInnerHTML: { __html: t } });
900
+ return Le.createElement(n, { className: r, style: a, dangerouslySetInnerHTML: { __html: t } });
901
901
  },
902
902
  (e, t) => e.html === t.html && e.as === t.as && e.className === t.className && JSON.stringify(e.style) === JSON.stringify(t.style)
903
903
  );
904
- function Ao(e, t) {
905
- A(() => {
904
+ function Lo(e, t) {
905
+ E(() => {
906
906
  const n = e.current;
907
907
  if (!n || !t || typeof IntersectionObserver > "u") return;
908
908
  const r = new IntersectionObserver(([a]) => {
@@ -913,37 +913,37 @@ function Ao(e, t) {
913
913
  };
914
914
  }, [e, t]);
915
915
  }
916
- const ce = {
916
+ const de = {
917
917
  ANON_KEY: "watchparty_preferences",
918
918
  DEBUG_FLAG: "wp:debug",
919
919
  REPORT_LOGS_FLAG: "wp:reportLogs",
920
920
  voteKey: (e, t, n) => `watchparty_vote:${e}:${t}:${n}`
921
921
  };
922
- function Be() {
922
+ function We() {
923
923
  try {
924
924
  return globalThis.localStorage ?? null;
925
925
  } catch {
926
926
  return null;
927
927
  }
928
928
  }
929
- function B(e) {
929
+ function G(e) {
930
930
  try {
931
- return Be()?.getItem(e) ?? null;
931
+ return We()?.getItem(e) ?? null;
932
932
  } catch {
933
933
  return null;
934
934
  }
935
935
  }
936
- function ft(e, t) {
936
+ function pt(e, t) {
937
937
  try {
938
- const n = Be();
938
+ const n = We();
939
939
  return n ? (n.setItem(e, t), !0) : !1;
940
940
  } catch {
941
941
  return !1;
942
942
  }
943
943
  }
944
- function No() {
944
+ function jo() {
945
945
  try {
946
- const e = Be();
946
+ const e = We();
947
947
  if (!e) return [];
948
948
  const t = [];
949
949
  for (let n = 0; n < e.length; n++) {
@@ -955,51 +955,51 @@ function No() {
955
955
  return [];
956
956
  }
957
957
  }
958
- function Me(e) {
958
+ function Ue(e) {
959
959
  try {
960
- Be()?.removeItem(e);
960
+ We()?.removeItem(e);
961
961
  } catch {
962
962
  }
963
963
  }
964
- function Po(e) {
965
- const t = B(e);
964
+ function Uo(e) {
965
+ const t = G(e);
966
966
  return t === null ? null : t === "true" ? !0 : t === "false" ? !1 : null;
967
967
  }
968
- const xn = /* @__PURE__ */ new Map();
969
- let Cn = !1;
970
- function Ge(e, t) {
971
- xn.set(e, t), Cn && In(e, t);
968
+ const Pn = /* @__PURE__ */ new Map();
969
+ let Rn = !1;
970
+ function Ve(e, t) {
971
+ Pn.set(e, t), Rn && Dn(e, t);
972
972
  }
973
- function Ro() {
974
- Cn = !0;
975
- for (const [e, t] of xn) In(e, t);
973
+ function Fo() {
974
+ Rn = !0;
975
+ for (const [e, t] of Pn) Dn(e, t);
976
976
  }
977
- function In(e, t) {
977
+ function Dn(e, t) {
978
978
  typeof window > "u" || (window[e] = t);
979
979
  }
980
- const fe = [], Do = 500;
981
- let Ae = [], tt = null;
982
- const Oo = 1e3, Lo = 200;
983
- let nt = null;
984
- function Tn(e) {
985
- nt = e;
980
+ const pe = [], Ho = 500;
981
+ let Pe = [], nt = null;
982
+ const $o = 1e3, Bo = 200;
983
+ let rt = null;
984
+ function On(e) {
985
+ rt = e;
986
986
  }
987
- function kn() {
988
- return B(ce.REPORT_LOGS_FLAG) === "true";
987
+ function Mn() {
988
+ return G(de.REPORT_LOGS_FLAG) === "true";
989
989
  }
990
- function Mo() {
990
+ function Go() {
991
991
  if (typeof window > "u") return !1;
992
992
  if (window.__WP_DEBUG__ || new URLSearchParams(window.location.search).get("debug") === "true") return !0;
993
- const t = B(ce.DEBUG_FLAG);
993
+ const t = G(de.DEBUG_FLAG);
994
994
  return t !== null && t !== "false";
995
995
  }
996
- function jo() {
997
- const e = B(ce.DEBUG_FLAG);
996
+ function Wo() {
997
+ const e = G(de.DEBUG_FLAG);
998
998
  if (!e || e === "true") return null;
999
999
  const t = e.split(",").map((n) => n.trim().toLowerCase()).filter(Boolean);
1000
1000
  return t.length > 0 ? new Set(t) : null;
1001
1001
  }
1002
- function Uo() {
1002
+ function Vo() {
1003
1003
  return (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", {
1004
1004
  hour12: !1,
1005
1005
  hour: "2-digit",
@@ -1008,24 +1008,24 @@ function Uo() {
1008
1008
  fractionalSecondDigits: 3
1009
1009
  });
1010
1010
  }
1011
- function Ho(e) {
1012
- fe.push(e), fe.length > Do && fe.shift();
1011
+ function qo(e) {
1012
+ pe.push(e), pe.length > Ho && pe.shift();
1013
1013
  }
1014
- const We = {
1014
+ const qe = {
1015
1015
  debug: "color: #64748b; font-weight: normal;",
1016
1016
  warn: "color: #f59e0b; font-weight: bold;",
1017
1017
  error: "color: #ef4444; font-weight: bold;",
1018
1018
  category: "color: #3b82f6; font-weight: bold;",
1019
1019
  time: "color: #6b7280; font-weight: normal;"
1020
1020
  };
1021
- function Fo(e) {
1021
+ function Ko(e) {
1022
1022
  try {
1023
1023
  return JSON.stringify(e);
1024
1024
  } catch {
1025
1025
  return "[unserializable]";
1026
1026
  }
1027
1027
  }
1028
- function pt(e, t, n, r, a, i, s) {
1028
+ function ht(e, t, n, r, a, i, s) {
1029
1029
  const l = {
1030
1030
  level: e,
1031
1031
  category: a,
@@ -1033,47 +1033,47 @@ function pt(e, t, n, r, a, i, s) {
1033
1033
  data: s,
1034
1034
  timestamp: Date.now()
1035
1035
  };
1036
- if (Ho(l), (n || kn()) && Et(l), !r) {
1037
- if (!Mo()) return;
1038
- const u = jo();
1039
- if (u && !u.has(a.toLowerCase())) return;
1036
+ if (qo(l), (n || Mn()) && At(l), !r) {
1037
+ if (!Go()) return;
1038
+ const f = Wo();
1039
+ if (f && !f.has(a.toLowerCase())) return;
1040
1040
  }
1041
- const f = Uo(), h = s !== void 0 ? " " + Fo(s) : "";
1041
+ const d = Vo(), h = s !== void 0 ? " " + Ko(s) : "";
1042
1042
  t(
1043
- `%c[${f}]%c [${a}]%c ${i}${h}`,
1044
- We.time,
1045
- We.category,
1046
- We[e]
1043
+ `%c[${d}]%c [${a}]%c ${i}${h}`,
1044
+ qe.time,
1045
+ qe.category,
1046
+ qe[e]
1047
1047
  );
1048
1048
  }
1049
- function d(e, t, n) {
1050
- pt("debug", console.log, !1, !1, e, t, n);
1049
+ function u(e, t, n) {
1050
+ ht("debug", console.log, !1, !1, e, t, n);
1051
1051
  }
1052
1052
  function I(e, t, n) {
1053
- pt("warn", console.warn, !0, !1, e, t, n);
1053
+ ht("warn", console.warn, !0, !1, e, t, n);
1054
1054
  }
1055
- function Ne(e, t, n) {
1056
- pt("error", console.error, !0, !0, e, t, n);
1055
+ function Re(e, t, n) {
1056
+ ht("error", console.error, !0, !0, e, t, n);
1057
1057
  }
1058
- function $o() {
1059
- return [...fe];
1058
+ function Yo() {
1059
+ return [...pe];
1060
1060
  }
1061
- function Bo() {
1062
- fe.length = 0;
1061
+ function zo() {
1062
+ pe.length = 0;
1063
1063
  }
1064
- function Go(e) {
1064
+ function Xo(e) {
1065
1065
  const t = e && e.length > 0 ? e.join(",") : "true";
1066
- ft(ce.DEBUG_FLAG, t), console.log("[wp] Debug mode enabled");
1066
+ pt(de.DEBUG_FLAG, t), console.log("[wp] Debug mode enabled");
1067
1067
  }
1068
- function Wo() {
1069
- Me(ce.DEBUG_FLAG), console.log("[wp] Debug mode disabled");
1068
+ function Jo() {
1069
+ Ue(de.DEBUG_FLAG), console.log("[wp] Debug mode disabled");
1070
1070
  }
1071
- const qo = 1024, Vo = 5e4;
1072
- function Ko(e) {
1071
+ const Qo = 1024, Zo = 5e4;
1072
+ function ea(e) {
1073
1073
  if (e == null) return e;
1074
1074
  try {
1075
1075
  const t = JSON.stringify(e);
1076
- if (t.length <= qo) return e;
1076
+ if (t.length <= Qo) return e;
1077
1077
  if (typeof e == "object" && !Array.isArray(e)) {
1078
1078
  const n = {};
1079
1079
  for (const [r, a] of Object.entries(e)) {
@@ -1087,35 +1087,35 @@ function Ko(e) {
1087
1087
  return "[unserializable]";
1088
1088
  }
1089
1089
  }
1090
- async function Yo() {
1091
- if (Ae.length === 0) return;
1092
- const e = Ae;
1093
- Ae = [], tt = null;
1090
+ async function ta() {
1091
+ if (Pe.length === 0) return;
1092
+ const e = Pe;
1093
+ Pe = [], nt = null;
1094
1094
  try {
1095
- let n = be().serverOrigin || "";
1095
+ let n = _e().serverOrigin || "";
1096
1096
  if ((n === "/" || !n) && typeof window < "u") {
1097
1097
  const l = window.location;
1098
- (l.hostname === "localhost" || l.hostname === "127.0.0.1") && l.port === String(tn) ? n = `${l.protocol}//${l.hostname}:${it}` : n = l.origin;
1098
+ (l.hostname === "localhost" || l.hostname === "127.0.0.1") && l.port === String(ln) ? n = `${l.protocol}//${l.hostname}:${st}` : n = l.origin;
1099
1099
  }
1100
1100
  const r = `${n.replace(/\/$/, "")}/api/client-log`, a = e.map((l) => ({
1101
1101
  level: l.level,
1102
1102
  category: l.category,
1103
1103
  message: l.message,
1104
- data: Ko(l.data),
1104
+ data: ea(l.data),
1105
1105
  timestamp: l.timestamp,
1106
1106
  url: typeof window < "u" ? window.location.href : void 0,
1107
1107
  userAgent: typeof navigator < "u" ? navigator.userAgent : void 0,
1108
- room_key: nt?.room_key,
1109
- client_id: nt?.client_id
1108
+ room_key: rt?.room_key,
1109
+ client_id: rt?.client_id
1110
1110
  }));
1111
1111
  let i = [], s = 0;
1112
1112
  for (const l of a) {
1113
- const f = JSON.stringify(l).length + 1;
1114
- s + f > Vo && i.length > 0 && (await fetch(r, {
1113
+ const d = JSON.stringify(l).length + 1;
1114
+ s + d > Zo && i.length > 0 && (await fetch(r, {
1115
1115
  method: "POST",
1116
1116
  headers: { "Content-Type": "application/json" },
1117
1117
  body: JSON.stringify({ logs: i })
1118
- }), i = [], s = 0), i.push(l), s += f;
1118
+ }), i = [], s = 0), i.push(l), s += d;
1119
1119
  }
1120
1120
  i.length > 0 && await fetch(r, {
1121
1121
  method: "POST",
@@ -1123,31 +1123,31 @@ async function Yo() {
1123
1123
  body: JSON.stringify({ logs: i })
1124
1124
  });
1125
1125
  } catch (t) {
1126
- console.warn("[wp] log flush failed (client logs may be lost):", ve(t).error);
1126
+ console.warn("[wp] log flush failed (client logs may be lost):", we(t).error);
1127
1127
  }
1128
1128
  }
1129
- function Et(e) {
1130
- if (Ae.push(e), !tt) {
1131
- const t = kn() ? Lo : Oo;
1132
- tt = setTimeout(() => {
1133
- Yo();
1129
+ function At(e) {
1130
+ if (Pe.push(e), !nt) {
1131
+ const t = Mn() ? Bo : $o;
1132
+ nt = setTimeout(() => {
1133
+ ta();
1134
1134
  }, t);
1135
1135
  }
1136
1136
  }
1137
- function ve(e) {
1137
+ function we(e) {
1138
1138
  return e instanceof Error ? { error: e.message, name: e.name } : { error: String(e), name: typeof e };
1139
1139
  }
1140
- Ge("__wpDebug", {
1141
- enable: Go,
1142
- disable: Wo,
1143
- history: $o,
1144
- clear: Bo
1140
+ Ve("__wpDebug", {
1141
+ enable: Xo,
1142
+ disable: Jo,
1143
+ history: Yo,
1144
+ clear: zo
1145
1145
  });
1146
- const zo = 1280;
1147
- function Xo(e) {
1148
- return e.screenWidth < zo ? !1 : e.noHoverNoPointer || e.anyHoverNone && e.maxTouchPoints === 0;
1146
+ const na = 1280;
1147
+ function ra(e) {
1148
+ return e.screenWidth < na ? !1 : e.noHoverNoPointer || e.anyHoverNone && e.maxTouchPoints === 0;
1149
1149
  }
1150
- function Jo() {
1150
+ function oa() {
1151
1151
  const e = (t) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(t).matches;
1152
1152
  return {
1153
1153
  noHoverNoPointer: e("(hover: none) and (pointer: none)"),
@@ -1156,57 +1156,57 @@ function Jo() {
1156
1156
  screenWidth: typeof screen < "u" ? screen.width : 0
1157
1157
  };
1158
1158
  }
1159
- let At = null;
1160
- function Qo() {
1161
- return At ??= Xo(Jo()), At;
1159
+ let Nt = null;
1160
+ function aa() {
1161
+ return Nt ??= ra(oa()), Nt;
1162
1162
  }
1163
- function Nt() {
1164
- return Qo();
1163
+ function Pt() {
1164
+ return aa();
1165
1165
  }
1166
1166
  const Q = {
1167
1167
  resolved: !1,
1168
1168
  userType: "public",
1169
1169
  accountId: null
1170
1170
  };
1171
- function ht() {
1171
+ function gt() {
1172
1172
  return Q.accountId ? Q.accountId : Q.resolved && Q.userType === "public" ? "anon" : null;
1173
1173
  }
1174
- function Zo(e) {
1174
+ function ia(e) {
1175
1175
  Q.resolved = !0, e.userType && (Q.userType = e.userType), e.userId !== void 0 && (Q.accountId = e.userId && e.userId !== "public" ? e.userId : null);
1176
1176
  }
1177
- function gt() {
1177
+ function yt() {
1178
1178
  return Q.accountId ?? "public";
1179
1179
  }
1180
- function ea() {
1181
- return ht() ?? "unscoped";
1180
+ function sa() {
1181
+ return gt() ?? "unscoped";
1182
1182
  }
1183
- function En(e) {
1184
- return ct(e) ? Fr[e] : "var(--color-neutral-bg)";
1183
+ function Ln(e) {
1184
+ return dt(e) ? zr[e] : "var(--color-neutral-bg)";
1185
1185
  }
1186
- function ta(e) {
1187
- return ct(e) ? `${be().serverOrigin.replace(/\/$/, "")}${Br(e)}` : void 0;
1186
+ function la(e) {
1187
+ return dt(e) ? `${_e().serverOrigin.replace(/\/$/, "")}${Jr(e)}` : void 0;
1188
1188
  }
1189
- let he = null, _e = null;
1190
- function na() {
1191
- return he ? Promise.resolve() : _e || (_e = (async () => {
1189
+ let ye = null, Ce = null;
1190
+ function ca() {
1191
+ return ye ? Promise.resolve() : Ce || (Ce = (async () => {
1192
1192
  try {
1193
- const e = be().serverOrigin.replace(/\/$/, ""), t = await fetch(`${e}/media/sprites/names.json`, { cache: "no-cache" });
1193
+ const e = _e().serverOrigin.replace(/\/$/, ""), t = await fetch(`${e}/media/sprites/names.json`, { cache: "no-cache" });
1194
1194
  if (!t.ok) return;
1195
1195
  const n = await t.json();
1196
- he = n, Ge("__DISPLAY_NAMES__", n), d("characters", "Loaded display names", n);
1196
+ ye = n, Ve("__DISPLAY_NAMES__", n), u("characters", "Loaded display names", n);
1197
1197
  } catch (e) {
1198
- d("characters", "display names fetch failed (degrading to sprite IDs)", ve(e));
1198
+ u("characters", "display names fetch failed (degrading to sprite IDs)", we(e));
1199
1199
  }
1200
- })(), _e);
1200
+ })(), Ce);
1201
1201
  }
1202
- function ge(e) {
1203
- return he?.[e] || e.charAt(0).toUpperCase() + e.slice(1);
1202
+ function be(e) {
1203
+ return ye?.[e] || e.charAt(0).toUpperCase() + e.slice(1);
1204
1204
  }
1205
- function ne(e) {
1205
+ function re(e) {
1206
1206
  const t = e.toLowerCase();
1207
- return Fe.some((n) => n === t) ? !0 : he ? Object.values(he).some((n) => n.toLowerCase() === t) : !1;
1207
+ return Be.some((n) => n === t) ? !0 : ye ? Object.values(ye).some((n) => n.toLowerCase() === t) : !1;
1208
1208
  }
1209
- const ra = o.object({
1209
+ const da = o.object({
1210
1210
  // Identity. There is deliberately NO `name`: a person's name is their
1211
1211
  // hadoku key-registry name, resolved by the server from whoami and renamed
1212
1212
  // through hadoku_site's POST /session/name (operator decision 2026-10-08).
@@ -1231,21 +1231,21 @@ const ra = o.object({
1231
1231
  preferredAudioLang: o.string().optional(),
1232
1232
  subtitlesEnabled: o.boolean().optional(),
1233
1233
  subtitleStyle: o.string().optional()
1234
- }), pe = yr({
1234
+ }), he = Tr({
1235
1235
  appId: "watchparty",
1236
- schema: ra
1237
- }), oa = /* @__PURE__ */ new Set(["theme", "themeMode"]);
1238
- function je(e) {
1239
- const t = ht();
1236
+ schema: da
1237
+ }), ua = /* @__PURE__ */ new Set(["theme", "themeMode"]);
1238
+ function Fe(e) {
1239
+ const t = gt();
1240
1240
  return t ? `prefs-cache:${t}:${e}` : null;
1241
1241
  }
1242
- function aa() {
1243
- return ht() === null;
1242
+ function ma() {
1243
+ return gt() === null;
1244
1244
  }
1245
- function Pt(e) {
1246
- const t = je(e);
1245
+ function Rt(e) {
1246
+ const t = Fe(e);
1247
1247
  if (!t) return {};
1248
- const n = B(t);
1248
+ const n = G(t);
1249
1249
  if (!n) return {};
1250
1250
  try {
1251
1251
  return JSON.parse(n)?.blob ?? {};
@@ -1253,12 +1253,12 @@ function Pt(e) {
1253
1253
  return {};
1254
1254
  }
1255
1255
  }
1256
- function ia() {
1256
+ function fa() {
1257
1257
  let e = 0;
1258
- for (const t of No()) {
1259
- const n = t.startsWith("prefs-cache:") && t.endsWith(":watchparty"), r = t === Ue || t.startsWith(`${Ue}:`) && !t.endsWith(":_serverSynced_v1");
1258
+ for (const t of jo()) {
1259
+ const n = t.startsWith("prefs-cache:") && t.endsWith(":watchparty"), r = t === He || t.startsWith(`${He}:`) && !t.endsWith(":_serverSynced_v1");
1260
1260
  if (!n && !r) continue;
1261
- const a = B(t);
1261
+ const a = G(t);
1262
1262
  if (!a) continue;
1263
1263
  let i;
1264
1264
  try {
@@ -1268,19 +1268,19 @@ function ia() {
1268
1268
  }
1269
1269
  const s = n ? i?.blob : i;
1270
1270
  if (!s || typeof s != "object" || !("name" in s)) continue;
1271
- const { name: l, ...f } = s, h = n ? { ...i, blob: f } : f;
1272
- ft(t, JSON.stringify(h)) && e++;
1271
+ const { name: l, ...d } = s, h = n ? { ...i, blob: d } : d;
1272
+ pt(t, JSON.stringify(h)) && e++;
1273
1273
  }
1274
- return e > 0 && d("preferences", "Stripped retired name from cached prefs rows", { rewritten: e }), e;
1275
- }
1276
- let An = null, Nn = null;
1277
- const Rt = /* @__PURE__ */ new Set();
1278
- function yt() {
1279
- if (aa())
1280
- return d("preferences", "Boot read deferred — session pending, identity unresolved"), {};
1281
- const e = Pt("portfolio"), t = Pt("watchparty"), n = Object.keys(e).length > 0 ? e : An ?? {}, r = Object.keys(t).length > 0 ? t : Nn ?? {}, a = gt() || "public";
1282
- if (Rt.has(a))
1283
- return d("preferences", "Loaded (sync, SDK-only after first read)", {
1274
+ return e > 0 && u("preferences", "Stripped retired name from cached prefs rows", { rewritten: e }), e;
1275
+ }
1276
+ let jn = null, Un = null;
1277
+ const Dt = /* @__PURE__ */ new Set();
1278
+ function bt() {
1279
+ if (ma())
1280
+ return u("preferences", "Boot read deferred — session pending, identity unresolved"), {};
1281
+ const e = Rt("portfolio"), t = Rt("watchparty"), n = Object.keys(e).length > 0 ? e : jn ?? {}, r = Object.keys(t).length > 0 ? t : Un ?? {}, a = yt() || "public";
1282
+ if (Dt.has(a))
1283
+ return u("preferences", "Loaded (sync, SDK-only after first read)", {
1284
1284
  uid: a,
1285
1285
  sdkThemeKeys: Object.keys(n).length,
1286
1286
  sdkAppKeys: Object.keys(r).length,
@@ -1289,9 +1289,9 @@ function yt() {
1289
1289
  themeSource: Object.keys(e).length > 0 ? "cache" : "mem",
1290
1290
  appSource: Object.keys(t).length > 0 ? "cache" : "mem"
1291
1291
  }), { ...r, ...n };
1292
- Rt.add(a);
1293
- const i = Rn() ?? {}, s = { ...i, ...r, ...n };
1294
- return d("preferences", "Loaded (sync, first read — legacy + SDK)", {
1292
+ Dt.add(a);
1293
+ const i = Hn() ?? {}, s = { ...i, ...r, ...n };
1294
+ return u("preferences", "Loaded (sync, first read — legacy + SDK)", {
1295
1295
  uid: a,
1296
1296
  sdkThemeKeys: Object.keys(n).length,
1297
1297
  sdkAppKeys: Object.keys(r).length,
@@ -1300,60 +1300,60 @@ function yt() {
1300
1300
  appSource: Object.keys(t).length > 0 ? "cache" : "mem"
1301
1301
  }), s;
1302
1302
  }
1303
- let Pn = !1;
1304
- function sa() {
1305
- const e = gt();
1303
+ let Fn = !1;
1304
+ function pa() {
1305
+ const e = yt();
1306
1306
  return !e || e === "public";
1307
1307
  }
1308
- function q(e, t) {
1309
- sa() && (Pn = !0), oa.has(e) ? me.save({ [e]: t }, { scope: "device" }).catch((n) => I("preferences", "themePrefs.save failed", { key: e, err: n?.message })) : pe.save({ [e]: t }).catch((n) => I("preferences", "watchpartyPrefs.save failed", { key: e, err: n?.message })), d("preferences", "Saved (via SDK)", { key: e, value: t });
1308
+ function V(e, t) {
1309
+ pa() && (Fn = !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 });
1310
1310
  }
1311
- let xe = null, Dt = !1;
1312
- function la() {
1313
- return xe || (xe = (async () => {
1311
+ let Ie = null, Ot = !1;
1312
+ function ha() {
1313
+ return Ie || (Ie = (async () => {
1314
1314
  if (typeof window > "u") return !1;
1315
1315
  try {
1316
- Dt || (Dt = !0, me.subscribe((s) => {
1317
- An = s, Mt("portfolio", s), jt("theme");
1318
- }), pe.subscribe((s) => {
1319
- Nn = s, Mt("watchparty", s), jt("watchparty");
1316
+ Ot || (Ot = !0, fe.subscribe((s) => {
1317
+ jn = s, jt("portfolio", s), Ut("theme");
1318
+ }), he.subscribe((s) => {
1319
+ Un = s, jt("watchparty", s), Ut("watchparty");
1320
1320
  }));
1321
1321
  const [e, t] = await Promise.all([
1322
- me.read(),
1323
- pe.read()
1322
+ fe.read(),
1323
+ he.read()
1324
1324
  ]);
1325
1325
  try {
1326
- const { useAppStore: s } = await Promise.resolve().then(() => Ln);
1326
+ const { useAppStore: s } = await Promise.resolve().then(() => Gn);
1327
1327
  s.getState().rehydrateFromPrefs();
1328
1328
  } catch (s) {
1329
1329
  I("preferences", "inline rehydrate after SDK read failed", { err: s?.message });
1330
1330
  }
1331
- const n = je("portfolio"), r = je("watchparty"), a = n ? B(n) : null, i = r ? B(r) : null;
1332
- return d("preferences", "sdk.read", {
1331
+ const n = Fe("portfolio"), r = Fe("watchparty"), a = n ? G(n) : null, i = r ? G(r) : null;
1332
+ return u("preferences", "sdk.read", {
1333
1333
  themeKeys: Object.keys(e ?? {}),
1334
1334
  appKeys: Object.keys(t ?? {}),
1335
1335
  // Post-fetch cache state: should be non-zero if SDK wrote it.
1336
1336
  sdkThemeBytesPost: a?.length ?? 0,
1337
1337
  sdkAppBytesPost: i?.length ?? 0
1338
- }), await ca(e, t), Pn ? (d("preferences", "Promoting this load's pre-auth picks to the signed-in user"), await Promise.all([
1339
- me.promoteAnonPrefsToUser().catch(() => {
1338
+ }), await ga(e, t), Fn ? (u("preferences", "Promoting this load's pre-auth picks to the signed-in user"), await Promise.all([
1339
+ fe.promoteAnonPrefsToUser().catch(() => {
1340
1340
  }),
1341
- pe.promoteAnonPrefsToUser().catch(() => {
1341
+ he.promoteAnonPrefsToUser().catch(() => {
1342
1342
  })
1343
- ])) : d("preferences", "Skipping anon promotion — no pre-auth writes this load"), d("preferences", "First-load SDK sync complete"), !0;
1343
+ ])) : u("preferences", "Skipping anon promotion — no pre-auth writes this load"), u("preferences", "First-load SDK sync complete"), !0;
1344
1344
  } catch (e) {
1345
1345
  return I("preferences", "First-load SDK sync failed (non-fatal)", { err: e?.message }), !1;
1346
1346
  }
1347
- })(), xe);
1347
+ })(), Ie);
1348
1348
  }
1349
- const Ue = "watchparty_preferences";
1350
- ia();
1351
- function rt() {
1352
- const e = gt();
1353
- return !e || e === "public" ? Ue : `${Ue}:${e}`;
1349
+ const He = "watchparty_preferences";
1350
+ fa();
1351
+ function ot() {
1352
+ const e = yt();
1353
+ return !e || e === "public" ? He : `${He}:${e}`;
1354
1354
  }
1355
- function Rn() {
1356
- const e = B(rt());
1355
+ function Hn() {
1356
+ const e = G(ot());
1357
1357
  if (!e) return null;
1358
1358
  try {
1359
1359
  const t = JSON.parse(e);
@@ -1362,31 +1362,31 @@ function Rn() {
1362
1362
  return null;
1363
1363
  }
1364
1364
  }
1365
- function Ot() {
1366
- Me(rt()), Me(`${rt()}:_serverSynced_v1`);
1365
+ function Mt() {
1366
+ Ue(ot()), Ue(`${ot()}:_serverSynced_v1`);
1367
1367
  }
1368
- async function ca(e, t) {
1369
- const n = Rn();
1368
+ async function ga(e, t) {
1369
+ const n = Hn();
1370
1370
  if (!n || Object.keys(n).length === 0) return;
1371
1371
  const r = Object.keys(e ?? {}).length > 0, a = Object.keys(t ?? {}).length > 0, i = {}, s = {};
1372
- for (const [h, u] of Object.entries(n))
1373
- r || (h === "theme" && typeof u == "string" ? i.theme = u : h === "themeMode" && (u === "simple" || u === "advanced") && (i.themeMode = u)), a || (h === "chatCollapsed" && typeof u == "boolean" ? s.chatCollapsed = u : h === "floatingChatEnabled" && typeof u == "boolean" ? s.floatingChatEnabled = u : h === "volume" && typeof u == "number" && u >= 0 && u <= 1 ? s.volume = u : h === "muted" && typeof u == "boolean" ? s.muted = u : h === "preferredAudioLang" && typeof u == "string" ? s.preferredAudioLang = u : h === "subtitlesEnabled" && typeof u == "boolean" ? s.subtitlesEnabled = u : h === "subtitleStyle" && typeof u == "string" && (s.subtitleStyle = u));
1374
- const l = Object.keys(i), f = Object.keys(s);
1375
- if (l.length === 0 && f.length === 0) {
1376
- Ot();
1372
+ for (const [h, f] of Object.entries(n))
1373
+ r || (h === "theme" && typeof f == "string" ? i.theme = f : h === "themeMode" && (f === "simple" || f === "advanced") && (i.themeMode = f)), a || (h === "chatCollapsed" && typeof f == "boolean" ? s.chatCollapsed = f : h === "floatingChatEnabled" && typeof f == "boolean" ? s.floatingChatEnabled = f : h === "volume" && typeof f == "number" && f >= 0 && f <= 1 ? s.volume = f : h === "muted" && typeof f == "boolean" ? s.muted = f : h === "preferredAudioLang" && typeof f == "string" ? s.preferredAudioLang = f : h === "subtitlesEnabled" && typeof f == "boolean" ? s.subtitlesEnabled = f : h === "subtitleStyle" && typeof f == "string" && (s.subtitleStyle = f));
1374
+ const l = Object.keys(i), d = Object.keys(s);
1375
+ if (l.length === 0 && d.length === 0) {
1376
+ Mt();
1377
1377
  return;
1378
1378
  }
1379
- d("preferences", "Migrating legacy localStorage prefs to SDK", {
1379
+ u("preferences", "Migrating legacy localStorage prefs to SDK", {
1380
1380
  themeKeys: l,
1381
- appKeys: f,
1381
+ appKeys: d,
1382
1382
  sdkHasTheme: r,
1383
1383
  sdkHasApp: a
1384
1384
  });
1385
1385
  try {
1386
1386
  await Promise.all([
1387
- l.length > 0 ? me.save(i, { scope: "device" }) : Promise.resolve(),
1388
- f.length > 0 ? pe.save(s) : Promise.resolve()
1389
- ]), Ot(), d("preferences", "Legacy migration complete");
1387
+ l.length > 0 ? fe.save(i, { scope: "device" }) : Promise.resolve(),
1388
+ d.length > 0 ? he.save(s) : Promise.resolve()
1389
+ ]), Mt(), u("preferences", "Legacy migration complete");
1390
1390
  } catch (h) {
1391
1391
  I("preferences", "Legacy migration save failed — will retry next load", {
1392
1392
  err: h?.message
@@ -1394,8 +1394,8 @@ async function ca(e, t) {
1394
1394
  }
1395
1395
  }
1396
1396
  let Lt = !1;
1397
- function Mt(e, t) {
1398
- const n = je(e);
1397
+ function jt(e, t) {
1398
+ const n = Fe(e);
1399
1399
  if (n)
1400
1400
  try {
1401
1401
  const r = {
@@ -1413,8 +1413,8 @@ function Mt(e, t) {
1413
1413
  }));
1414
1414
  }
1415
1415
  }
1416
- function jt(e) {
1417
- Promise.resolve().then(() => Ln).then(({ useAppStore: t }) => {
1416
+ function Ut(e) {
1417
+ Promise.resolve().then(() => Gn).then(({ useAppStore: t }) => {
1418
1418
  try {
1419
1419
  t.getState().rehydrateFromPrefs();
1420
1420
  } catch (n) {
@@ -1422,37 +1422,37 @@ function jt(e) {
1422
1422
  }
1423
1423
  }).catch((t) => I("preferences", "store import failed", { reason: e, err: t?.message }));
1424
1424
  }
1425
- const Dn = 320, He = 240, bt = 640, da = 320, ua = 36, Ut = 16;
1425
+ const $n = 320, $e = 240, vt = 640, ya = 320, ba = 36, Ft = 16;
1426
1426
  function Y(e, t) {
1427
- if (!Number.isFinite(e)) return Dn;
1428
- let n = bt;
1429
- return t !== void 0 && Number.isFinite(t) && t > 0 && (n = Math.min(n, t - da)), n = Math.max(n, He), Math.round(Math.min(n, Math.max(He, e)));
1427
+ if (!Number.isFinite(e)) return $n;
1428
+ let n = vt;
1429
+ 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)));
1430
1430
  }
1431
1431
  function Ht(e, t, n, r) {
1432
1432
  return Y(e + (t - n), r);
1433
1433
  }
1434
- function ma(e, t, n) {
1434
+ function va(e, t, n) {
1435
1435
  switch (t) {
1436
1436
  case "ArrowLeft":
1437
- return Y(e + Ut, n);
1437
+ return Y(e + Ft, n);
1438
1438
  case "ArrowRight":
1439
- return Y(e - Ut, n);
1439
+ return Y(e - Ft, n);
1440
1440
  case "Home":
1441
- return Y(He, n);
1441
+ return Y($e, n);
1442
1442
  case "End":
1443
- return Y(bt, n);
1443
+ return Y(vt, n);
1444
1444
  default:
1445
1445
  return null;
1446
1446
  }
1447
1447
  }
1448
- function fa(e, t) {
1449
- return { collapsed: e, width: e ? ua : t };
1448
+ function _a(e, t) {
1449
+ return { collapsed: e, width: e ? ba : t };
1450
1450
  }
1451
- function On(e, t) {
1451
+ function Bn(e, t) {
1452
1452
  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);
1453
1453
  return a.length ? [...t, ...a] : t;
1454
1454
  }
1455
- const V = yt(), m = hr((e, t) => ({
1455
+ const q = bt(), m = Cr((e, t) => ({
1456
1456
  ready: !1,
1457
1457
  name: "",
1458
1458
  sprite: null,
@@ -1460,9 +1460,9 @@ const V = yt(), m = hr((e, t) => ({
1460
1460
  snapshot: { roomId: null, mediaId: null, playheadMs: 0, playing: !1, serverSeq: 0, leaderId: null },
1461
1461
  roster: {},
1462
1462
  chat: [],
1463
- chatCollapsed: V.chatCollapsed ?? !1,
1464
- chromeChatCollapsed: V.chromeChatCollapsed ?? !1,
1465
- chromeChatWidth: Y(V.chromeChatWidth ?? Dn),
1463
+ chatCollapsed: q.chatCollapsed ?? !1,
1464
+ chromeChatCollapsed: q.chromeChatCollapsed ?? !1,
1465
+ chromeChatWidth: Y(q.chromeChatWidth ?? $n),
1466
1466
  // Hardcoded on for everyone — the per-user toggle was removed from the
1467
1467
  // control bar; FloatingChat + toggleFloatingChat code is kept for future
1468
1468
  // re-enablement but the value is no longer user-controllable.
@@ -1474,11 +1474,11 @@ const V = yt(), m = hr((e, t) => ({
1474
1474
  bufferState: { isBuffering: !1, bufferedEndMs: 0 },
1475
1475
  toasts: [],
1476
1476
  mediaPrefs: {
1477
- volume: V.volume ?? 1,
1478
- muted: V.muted ?? !1,
1479
- preferredAudioLang: V.preferredAudioLang || "jpn",
1480
- subtitlesEnabled: V.subtitlesEnabled ?? !0,
1481
- subtitleStyle: ["classic", "cinema", "minimal", "contrast"].includes(V.subtitleStyle) ? V.subtitleStyle : "classic"
1477
+ volume: q.volume ?? 1,
1478
+ muted: q.muted ?? !1,
1479
+ preferredAudioLang: q.preferredAudioLang || "jpn",
1480
+ subtitlesEnabled: q.subtitlesEnabled ?? !0,
1481
+ subtitleStyle: ["classic", "cinema", "minimal", "contrast"].includes(q.subtitleStyle) ? q.subtitleStyle : "classic"
1482
1482
  },
1483
1483
  healthSnapshot: null,
1484
1484
  sidebarTab: "chat",
@@ -1498,33 +1498,33 @@ const V = yt(), m = hr((e, t) => ({
1498
1498
  gameSettings: null,
1499
1499
  roomKeyType: null,
1500
1500
  setReady: () => {
1501
- d("store", "App ready"), e({ ready: !0 });
1501
+ u("store", "App ready"), e({ ready: !0 });
1502
1502
  },
1503
1503
  setSessionIdentity: (n, r) => {
1504
- d("store", "Session identity set (not persisted)", { name: n, sprite: r }), e({ name: n, sprite: r });
1504
+ u("store", "Session identity set (not persisted)", { name: n, sprite: r }), e({ name: n, sprite: r });
1505
1505
  },
1506
1506
  ensureAutoIdentity: () => e((n) => {
1507
1507
  if (n.name) return {};
1508
1508
  if (n.sprite) {
1509
- const i = ge(n.sprite);
1510
- return d("store", "Auto-identity: deriving name from the requested sprite", { name: i, sprite: n.sprite }), { name: i };
1509
+ const i = be(n.sprite);
1510
+ return u("store", "Auto-identity: deriving name from the requested sprite", { name: i, sprite: n.sprite }), { name: i };
1511
1511
  }
1512
- const r = Object.values(n.roster).map((i) => i.sprite), a = Qt(r, void 0, Fe);
1512
+ const r = Object.values(n.roster).map((i) => i.sprite), a = on(r, void 0, Be);
1513
1513
  if (a) {
1514
- const i = ge(a);
1515
- return d("store", "Auto-identity assigned", { name: i, sprite: a }), { name: i, sprite: a };
1514
+ const i = be(a);
1515
+ return u("store", "Auto-identity assigned", { name: i, sprite: a }), { name: i, sprite: a };
1516
1516
  }
1517
1517
  return I("store", "All characters taken, leaving identity unset"), {};
1518
1518
  }),
1519
1519
  ensureMe: (n) => {
1520
- d("store", "Client ID set", { clientId: n }), e((r) => ({ me: { ...r.me, clientId: n } }));
1520
+ u("store", "Client ID set", { clientId: n }), e((r) => ({ me: { ...r.me, clientId: n } }));
1521
1521
  },
1522
1522
  applySnapshot: (n) => e((r) => {
1523
1523
  const a = { ...r.roster };
1524
1524
  if (n.users)
1525
- for (const f of n.users) a[f.clientId] = f;
1525
+ for (const d of n.users) a[d.clientId] = d;
1526
1526
  const i = n.mediaId !== void 0 ? n.mediaId : r.snapshot.mediaId, s = n.leaderId !== void 0 ? n.leaderId : r.snapshot.leaderId;
1527
- d("store", "Snapshot applied", {
1527
+ u("store", "Snapshot applied", {
1528
1528
  mediaId: i,
1529
1529
  playing: n.playing ?? r.snapshot.playing,
1530
1530
  serverSeq: n.serverSeq ?? r.snapshot.serverSeq,
@@ -1549,34 +1549,34 @@ const V = yt(), m = hr((e, t) => ({
1549
1549
  };
1550
1550
  }),
1551
1551
  upsertUser: (n) => {
1552
- d("store", "User upserted", { clientId: n.clientId, name: n.name, isLeader: n.isLeader }), e((r) => ({ roster: { ...r.roster, [n.clientId]: n } }));
1552
+ u("store", "User upserted", { clientId: n.clientId, name: n.name, isLeader: n.isLeader }), e((r) => ({ roster: { ...r.roster, [n.clientId]: n } }));
1553
1553
  },
1554
1554
  removeUser: (n) => {
1555
- d("store", "User removed", { clientId: n }), e((r) => {
1555
+ u("store", "User removed", { clientId: n }), e((r) => {
1556
1556
  const a = { ...r.roster };
1557
1557
  return delete a[n], { roster: a };
1558
1558
  });
1559
1559
  },
1560
1560
  appendChat: (n) => {
1561
- d("chat", "Message appended", { id: n.id, from: n.name, isSystem: n.isSystem }), e((r) => ({ chat: [...r.chat, n].slice(-500) }));
1561
+ u("chat", "Message appended", { id: n.id, from: n.name, isSystem: n.isSystem }), e((r) => ({ chat: [...r.chat, n].slice(-500) }));
1562
1562
  },
1563
- setChat: (n) => e((r) => ({ chat: On(r.chat, n).slice(-500) })),
1563
+ setChat: (n) => e((r) => ({ chat: Bn(r.chat, n).slice(-500) })),
1564
1564
  toggleChatCollapsed: () => e((n) => {
1565
1565
  const r = !n.chatCollapsed;
1566
- return Nt() || q("chatCollapsed", r), { chatCollapsed: r };
1566
+ return Pt() || V("chatCollapsed", r), { chatCollapsed: r };
1567
1567
  }),
1568
1568
  applyTvDefaults: () => e(() => ({ chatCollapsed: !0 })),
1569
1569
  toggleChromeChatCollapsed: () => e((n) => {
1570
1570
  const r = !n.chromeChatCollapsed;
1571
- return q("chromeChatCollapsed", r), { chromeChatCollapsed: r };
1571
+ return V("chromeChatCollapsed", r), { chromeChatCollapsed: r };
1572
1572
  }),
1573
1573
  setChromeChatWidth: (n) => e(() => {
1574
1574
  const r = Y(n);
1575
- return q("chromeChatWidth", r), { chromeChatWidth: r };
1575
+ return V("chromeChatWidth", r), { chromeChatWidth: r };
1576
1576
  }),
1577
1577
  toggleFloatingChat: () => e((n) => {
1578
1578
  const r = !n.floatingChatEnabled;
1579
- return q("floatingChatEnabled", r), { floatingChatEnabled: r };
1579
+ return V("floatingChatEnabled", r), { floatingChatEnabled: r };
1580
1580
  }),
1581
1581
  allocateClientSeq: () => {
1582
1582
  const n = t().me.nextClientSeq;
@@ -1584,7 +1584,7 @@ const V = yt(), m = hr((e, t) => ({
1584
1584
  },
1585
1585
  bumpLoadGeneration: () => e((n) => ({ loadGeneration: n.loadGeneration + 1 })),
1586
1586
  updateControlState: (n) => {
1587
- d("store", "updateControlState called", n), e((r) => ({
1587
+ u("store", "updateControlState called", n), e((r) => ({
1588
1588
  snapshot: { ...r.snapshot, ...n },
1589
1589
  // Always update snapshotReceivedAt — any control_broadcast from the
1590
1590
  // server resets the elapsed-time calculation. The old condition
@@ -1598,24 +1598,24 @@ const V = yt(), m = hr((e, t) => ({
1598
1598
  const s = [...i.drift.rtts, n].slice(-5);
1599
1599
  let l = i.drift.offsetMs;
1600
1600
  if (r && a) {
1601
- const f = a + n / 2;
1602
- l = r - f;
1601
+ const d = a + n / 2;
1602
+ l = r - d;
1603
1603
  }
1604
1604
  return { drift: { rtts: s, offsetMs: l } };
1605
1605
  }),
1606
1606
  pushToast: (n, r) => {
1607
- d("store", "Toast pushed", { kind: n, msg: r }), e((a) => ({ toasts: [...a.toasts, { id: Math.random().toString(36).slice(2), kind: n, msg: r, ts: Date.now() }].slice(-5) }));
1607
+ u("store", "Toast pushed", { kind: n, msg: r }), e((a) => ({ toasts: [...a.toasts, { id: Math.random().toString(36).slice(2), kind: n, msg: r, ts: Date.now() }].slice(-5) }));
1608
1608
  },
1609
1609
  popToast: (n) => e((r) => ({ toasts: r.toasts.filter((a) => a.id !== n) })),
1610
1610
  setReadiness: (n) => e({ readiness: { mediaId: n.mediaId, ready: n.ready, readyCount: n.readyCount, total: n.total } }),
1611
1611
  setBufferState: (n) => e((r) => ({ bufferState: { ...r.bufferState, ...n } })),
1612
1612
  setMutedForAutoplay: (n) => e({ mutedForAutoplay: n }),
1613
1613
  // Media preference actions
1614
- setVolume: (n) => e((r) => (q("volume", n), { mediaPrefs: { ...r.mediaPrefs, volume: n } })),
1615
- setMuted: (n) => e((r) => (q("muted", n), { mediaPrefs: { ...r.mediaPrefs, muted: n } })),
1616
- setPreferredAudioLang: (n) => e((r) => (q("preferredAudioLang", n), { mediaPrefs: { ...r.mediaPrefs, preferredAudioLang: n } })),
1617
- setSubtitlesEnabled: (n) => e((r) => (q("subtitlesEnabled", n), { mediaPrefs: { ...r.mediaPrefs, subtitlesEnabled: n } })),
1618
- setSubtitleStyle: (n) => e((r) => (q("subtitleStyle", n), { mediaPrefs: { ...r.mediaPrefs, subtitleStyle: n } })),
1614
+ setVolume: (n) => e((r) => (V("volume", n), { mediaPrefs: { ...r.mediaPrefs, volume: n } })),
1615
+ setMuted: (n) => e((r) => (V("muted", n), { mediaPrefs: { ...r.mediaPrefs, muted: n } })),
1616
+ setPreferredAudioLang: (n) => e((r) => (V("preferredAudioLang", n), { mediaPrefs: { ...r.mediaPrefs, preferredAudioLang: n } })),
1617
+ setSubtitlesEnabled: (n) => e((r) => (V("subtitlesEnabled", n), { mediaPrefs: { ...r.mediaPrefs, subtitlesEnabled: n } })),
1618
+ setSubtitleStyle: (n) => e((r) => (V("subtitleStyle", n), { mediaPrefs: { ...r.mediaPrefs, subtitleStyle: n } })),
1619
1619
  setHealthSnapshot: (n) => e({ healthSnapshot: n }),
1620
1620
  setBufferStatus: (n) => e({ bufferStatus: n }),
1621
1621
  applyPlaylistState: (n) => e({
@@ -1653,13 +1653,13 @@ const V = yt(), m = hr((e, t) => ({
1653
1653
  */
1654
1654
  moveTierlistItem: (n, r, a) => e((i) => {
1655
1655
  const s = {};
1656
- for (const [l, f] of Object.entries(i.tierlistDraft)) {
1657
- const h = (f ?? []).filter((u) => u !== n);
1656
+ for (const [l, d] of Object.entries(i.tierlistDraft)) {
1657
+ const h = (d ?? []).filter((f) => f !== n);
1658
1658
  h.length > 0 && (s[l] = h);
1659
1659
  }
1660
1660
  if (r !== null) {
1661
- const l = s[r] ?? [], f = Math.max(0, Math.min(a ?? l.length, l.length));
1662
- l.splice(f, 0, n), s[r] = l;
1661
+ const l = s[r] ?? [], d = Math.max(0, Math.min(a ?? l.length, l.length));
1662
+ l.splice(d, 0, n), s[r] = l;
1663
1663
  }
1664
1664
  return { tierlistDraft: s };
1665
1665
  }),
@@ -1668,8 +1668,8 @@ const V = yt(), m = hr((e, t) => ({
1668
1668
  setGameSettings: (n) => e({ gameSettings: n }),
1669
1669
  setRoomKeyType: (n) => e({ roomKeyType: n }),
1670
1670
  rehydrateFromPrefs: () => e((n) => {
1671
- const r = yt(), a = {};
1672
- if (r.chatCollapsed !== void 0 && !Nt() && (a.chatCollapsed = r.chatCollapsed), r.chromeChatCollapsed !== void 0 && (a.chromeChatCollapsed = r.chromeChatCollapsed), r.chromeChatWidth !== void 0 && (a.chromeChatWidth = Y(r.chromeChatWidth)), ["volume", "muted", "preferredAudioLang", "subtitlesEnabled", "subtitleStyle"].some((l) => r[l] !== void 0)) {
1671
+ const r = bt(), a = {};
1672
+ if (r.chatCollapsed !== void 0 && !Pt() && (a.chatCollapsed = r.chatCollapsed), r.chromeChatCollapsed !== void 0 && (a.chromeChatCollapsed = r.chromeChatCollapsed), r.chromeChatWidth !== void 0 && (a.chromeChatWidth = Y(r.chromeChatWidth)), ["volume", "muted", "preferredAudioLang", "subtitlesEnabled", "subtitleStyle"].some((l) => r[l] !== void 0)) {
1673
1673
  const l = { ...n.mediaPrefs };
1674
1674
  r.volume !== void 0 && (l.volume = r.volume), r.muted !== void 0 && (l.muted = r.muted), r.preferredAudioLang !== void 0 && (l.preferredAudioLang = r.preferredAudioLang), r.subtitlesEnabled !== void 0 && (l.subtitlesEnabled = r.subtitlesEnabled), r.subtitleStyle !== void 0 && ["classic", "cinema", "minimal", "contrast"].includes(r.subtitleStyle) && (l.subtitleStyle = r.subtitleStyle), a.mediaPrefs = l;
1675
1675
  }
@@ -1677,51 +1677,51 @@ const V = yt(), m = hr((e, t) => ({
1677
1677
  }),
1678
1678
  setSidebarTab: (n) => e((r) => r.sidebarTab === n && n !== "chat" ? { sidebarTab: "chat" } : { sidebarTab: n, chatCollapsed: !1 })
1679
1679
  }));
1680
- Ge("__ZUSTAND_STORE__", m);
1681
- const Ln = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1680
+ Ve("__ZUSTAND_STORE__", m);
1681
+ const Gn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1682
1682
  __proto__: null,
1683
- mergeHistory: On,
1683
+ mergeHistory: Bn,
1684
1684
  useAppStore: m
1685
1685
  }, Symbol.toStringTag, { value: "Module" }));
1686
- function Mn(e) {
1686
+ function Wn(e) {
1687
1687
  const t = typeof window < "u" ? window.location.href : "http://localhost/", n = new URL(e, t).pathname;
1688
1688
  return `${n.endsWith("/") ? n : `${n}/`}socket.io/`;
1689
1689
  }
1690
- function pa(e) {
1690
+ function wa(e) {
1691
1691
  const t = typeof window < "u" ? window.location.href : "http://localhost/", n = e.namespace ?? "/chat";
1692
1692
  return {
1693
1693
  url: `${new URL(e.origin, t).origin}${n.startsWith("/") ? n : `/${n}`}`,
1694
- path: e.path ?? Mn(e.origin)
1694
+ path: e.path ?? Wn(e.origin)
1695
1695
  };
1696
1696
  }
1697
- let K = null, Z = null, Pe = null;
1698
- function Ft(e) {
1699
- e && K && e.origin === K.origin && e.path === K.path && e.namespace === K.namespace || !e && !K || (jn(), K = e);
1697
+ let K = null, Z = null, De = null;
1698
+ function $t(e) {
1699
+ e && K && e.origin === K.origin && e.path === K.path && e.namespace === K.namespace || !e && !K || (Vn(), K = e);
1700
1700
  }
1701
- function vt() {
1701
+ function _t() {
1702
1702
  return K !== null;
1703
1703
  }
1704
- function ha(e) {
1704
+ function Sa(e) {
1705
1705
  if (K)
1706
- if (Pe = e, Z)
1706
+ if (De = e, Z)
1707
1707
  Z.connected && Z.emit(v.JOIN, e);
1708
1708
  else {
1709
- const { url: t, path: n } = pa(K), r = Qe(t, { path: n, transports: ["websocket", "polling"] });
1710
- Z = r, d("chat", "External chat socket", { url: t, path: n }), Un(r), r.on(v.ERROR, (a) => {
1709
+ const { url: t, path: n } = wa(K), r = et(t, { path: n, transports: ["websocket", "polling"] });
1710
+ Z = r, u("chat", "External chat socket", { url: t, path: n }), qn(r), r.on(v.ERROR, (a) => {
1711
1711
  const i = a?.message || a?.code || "chat error";
1712
1712
  I("chat", `Chat server error: ${i}`, { code: a?.code }), m.getState().pushToast("error", i);
1713
1713
  }), r.on("connect", () => {
1714
- Pe && r.emit(v.JOIN, Pe);
1714
+ De && r.emit(v.JOIN, De);
1715
1715
  }), r.on("connect_error", (a) => I("chat", "Chat connection error", { message: a?.message }));
1716
1716
  }
1717
1717
  }
1718
- function ga(e) {
1718
+ function xa(e) {
1719
1719
  Z?.emit(v.CHAT_SEND, e);
1720
1720
  }
1721
- function jn() {
1722
- Pe = null, Z && (Z.disconnect(), Z = null);
1721
+ function Vn() {
1722
+ De = null, Z && (Z.disconnect(), Z = null);
1723
1723
  }
1724
- function $t(e, t) {
1724
+ function Bt(e, t) {
1725
1725
  return {
1726
1726
  id: String(e.id ?? e.server_seq ?? t ?? `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`),
1727
1727
  clientId: e.client_id,
@@ -1733,109 +1733,109 @@ function $t(e, t) {
1733
1733
  // Attachments arrive from other clients, so the key shape is re-checked
1734
1734
  // here at the boundary rather than trusted at render time. A malformed
1735
1735
  // entry is dropped, not rendered and not allowed near an <img src>.
1736
- images: Array.isArray(e.images) ? e.images.filter((n) => !!n && at(n.key)).slice(0, J) : void 0,
1736
+ images: Array.isArray(e.images) ? e.images.filter((n) => !!n && it(n.key)).slice(0, J) : void 0,
1737
1737
  isSystem: e.isSystem || !1,
1738
1738
  systemType: e.systemType,
1739
- template: e.isSystem && typeof e.template == "string" && e.template.includes(an) ? e.template : void 0
1739
+ template: e.isSystem && typeof e.template == "string" && e.template.includes(mn) ? e.template : void 0
1740
1740
  };
1741
1741
  }
1742
- function Un(e, t = () => !0) {
1742
+ function qn(e, t = () => !0) {
1743
1743
  e.on(v.CHAT_BROADCAST, (n) => {
1744
1744
  if (!t()) return;
1745
- const r = { ...$t(n, n.server_seq), live: !0 };
1746
- m.getState().appendChat(r), d("chat", "Message received", r);
1745
+ const r = { ...Bt(n, n.server_seq), live: !0 };
1746
+ m.getState().appendChat(r), u("chat", "Message received", r);
1747
1747
  }), e.on(v.CHAT_HISTORY, (n) => {
1748
1748
  if (!t() || !n?.messages || !Array.isArray(n.messages)) return;
1749
- const r = n.messages.map((a) => $t(a));
1750
- m.getState().setChat(r), d("chat", "History loaded", { count: r.length });
1749
+ const r = n.messages.map((a) => Bt(a));
1750
+ m.getState().setChat(r), u("chat", "History loaded", { count: r.length });
1751
1751
  });
1752
1752
  }
1753
- let Hn = null;
1754
- function ya(e) {
1755
- Hn = e;
1753
+ let Kn = null;
1754
+ function Ca(e) {
1755
+ Kn = e;
1756
1756
  }
1757
- function ba(e = Hn) {
1757
+ function Ia(e = Kn) {
1758
1758
  if (!e) return null;
1759
1759
  const t = typeof window < "u" ? window.location.href : "http://localhost/", n = e.namespace ?? "/room";
1760
1760
  return {
1761
1761
  url: `${new URL(e.origin, t).origin}${n.startsWith("/") ? n : `/${n}`}`,
1762
- path: e.path ?? Mn(e.origin)
1762
+ path: e.path ?? Wn(e.origin)
1763
1763
  };
1764
1764
  }
1765
- function va(e) {
1766
- return `${wn()}/media/${e}`.replace(/\\/g, "/");
1765
+ function Ta(e) {
1766
+ return `${Tn()}/media/${e}`.replace(/\\/g, "/");
1767
1767
  }
1768
- function wa(e, t) {
1769
- return va(t ?? `${e}/poster.jpg`);
1768
+ function ka(e, t) {
1769
+ return Ta(t ?? `${e}/poster.jpg`);
1770
1770
  }
1771
- function Sa(e) {
1772
- return `${wn()}${e}`.replace(/\\/g, "/");
1771
+ function Ea(e) {
1772
+ return `${Tn()}${e}`.replace(/\\/g, "/");
1773
1773
  }
1774
- async function _a(e) {
1774
+ async function Aa(e) {
1775
1775
  try {
1776
- const t = await fetch(Sa("/api/tierlist"));
1776
+ const t = await fetch(Ea("/api/tierlist"));
1777
1777
  if (!t.ok)
1778
1778
  return I("tierlist", "Board fetch failed", { status: t.status }), null;
1779
1779
  const n = await t.json();
1780
- return m.getState().setTierlistSnapshot(n, e), d("tierlist", "Board loaded", {
1780
+ return m.getState().setTierlistSnapshot(n, e), u("tierlist", "Board loaded", {
1781
1781
  items: n.items.length,
1782
1782
  voters: n.voterCount,
1783
1783
  placed: n.placed.length
1784
1784
  }), n;
1785
1785
  } catch (t) {
1786
- return I("tierlist", "Board fetch threw", ve(t)), null;
1786
+ return I("tierlist", "Board fetch threw", we(t)), null;
1787
1787
  }
1788
1788
  }
1789
- let Bt = !1;
1790
- function xa() {
1791
- if (Bt || typeof Image > "u") return;
1789
+ let Gt = !1;
1790
+ function Na() {
1791
+ if (Gt || typeof Image > "u") return;
1792
1792
  const e = m.getState().tierlist;
1793
1793
  if (!(!e || e.items.length === 0)) {
1794
- Bt = !0;
1794
+ Gt = !0;
1795
1795
  for (const t of e.items) {
1796
1796
  const n = new Image();
1797
- n.decoding = "async", n.src = wa(t.id, t.thumbnail);
1797
+ n.decoding = "async", n.src = ka(t.id, t.thumbnail);
1798
1798
  }
1799
- d("tierlist", "Warming posters", { count: e.items.length });
1799
+ u("tierlist", "Warming posters", { count: e.items.length });
1800
1800
  }
1801
1801
  }
1802
- function Ca() {
1803
- const e = m.getState(), t = Qt(Object.values(e.roster).map((a) => a.sprite), void 0, Fe);
1802
+ function Pa() {
1803
+ const e = m.getState(), t = on(Object.values(e.roster).map((a) => a.sprite), void 0, Be);
1804
1804
  if (!t)
1805
1805
  return I("socket", "sprite_taken: no available sprites to retry with"), null;
1806
- const n = !!e.name && !ne(e.name), r = n ? e.name : ge(t);
1807
- return d("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 };
1806
+ const n = !!e.name && !re(e.name), r = n ? e.name : be(t);
1807
+ 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 };
1808
1808
  }
1809
- function Ia(e) {
1809
+ function Ra(e) {
1810
1810
  const t = m.getState(), n = e ? t.roster[e] : void 0;
1811
1811
  return !n || !!n.sprite && n.sprite === t.sprite;
1812
1812
  }
1813
- const Ta = "hadoku:avatar", ka = "hadoku:name";
1814
- function Fn(e) {
1813
+ const Da = "hadoku:avatar", Oa = "hadoku:name";
1814
+ function Yn(e) {
1815
1815
  const t = e?.sprite ?? e?.avatar?.sprite ?? null;
1816
- return ct(t) ? t : null;
1816
+ return dt(t) ? t : null;
1817
1817
  }
1818
- async function Ea(e = {}) {
1818
+ async function Ma(e = {}) {
1819
1819
  const t = e.fetch ?? (typeof fetch > "u" ? void 0 : fetch), n = typeof window > "u" ? void 0 : window.location?.origin, r = e.baseUrl ?? (n ? `${n}/prefs` : void 0);
1820
1820
  if (!t || !r) return null;
1821
1821
  try {
1822
- const a = await wr({ baseUrl: r, fetch: t }).get(), i = Fn(a);
1823
- return d("avatar", "Requested character from prefs-api", { sprite: i }), i;
1822
+ const a = await Ar({ baseUrl: r, fetch: t }).get(), i = Yn(a);
1823
+ return u("avatar", "Requested character from prefs-api", { sprite: i }), i;
1824
1824
  } catch (a) {
1825
- return a instanceof Ct && (a.status === 401 || a.status === 403 || a.status === 404) ? d("avatar", "No avatar settings here (signed out, or no prefs-api on this origin)", { status: a.status }) : I("avatar", "Avatar settings read failed — keeping the auto-assigned character", {
1826
- status: a instanceof Ct ? a.status : void 0,
1827
- ...ve(a)
1825
+ return a instanceof It && (a.status === 401 || a.status === 403 || a.status === 404) ? u("avatar", "No avatar settings here (signed out, or no prefs-api on this origin)", { status: a.status }) : I("avatar", "Avatar settings read failed — keeping the auto-assigned character", {
1826
+ status: a instanceof It ? a.status : void 0,
1827
+ ...we(a)
1828
1828
  }), null;
1829
1829
  }
1830
1830
  }
1831
- function Gt(e) {
1831
+ function Wt(e) {
1832
1832
  if (!e) return !1;
1833
1833
  const t = m.getState();
1834
1834
  if (t.sprite === e) return !1;
1835
- const r = !!(t.me.clientId && t.roster[t.me.clientId]?.registryName) || !t.name || !ne(t.name) ? t.name : ge(e);
1835
+ const r = !!(t.me.clientId && t.roster[t.me.clientId]?.registryName) || !t.name || !re(t.name) ? t.name : be(e);
1836
1836
  return t.setSessionIdentity(r, e), !0;
1837
1837
  }
1838
- function $n(e, t, n) {
1838
+ function zn(e, t, n) {
1839
1839
  if (!n) return () => {
1840
1840
  };
1841
1841
  const r = (a) => {
@@ -1844,29 +1844,29 @@ function $n(e, t, n) {
1844
1844
  };
1845
1845
  return n.addEventListener(e, r), () => n.removeEventListener(e, r);
1846
1846
  }
1847
- const Bn = () => typeof window > "u" ? void 0 : window;
1848
- function Aa(e, t = Bn()) {
1849
- return $n(Ta, e, t);
1847
+ const Xn = () => typeof window > "u" ? void 0 : window;
1848
+ function La(e, t = Xn()) {
1849
+ return zn(Da, e, t);
1850
1850
  }
1851
- function Na(e, t = Bn()) {
1852
- return $n(ka, (n) => {
1851
+ function ja(e, t = Xn()) {
1852
+ return zn(Oa, (n) => {
1853
1853
  typeof n.name == "string" && n.name.trim() && e(n.name);
1854
1854
  }, t);
1855
1855
  }
1856
- const Pa = 10;
1857
- function Ra(e = typeof window < "u" ? window : void 0) {
1856
+ const Ua = 10;
1857
+ function Fa(e = typeof window < "u" ? window : void 0) {
1858
1858
  if (!e) return { framed: !1, depth: 0 };
1859
1859
  try {
1860
1860
  let t = 0, n = e;
1861
- for (; n !== n.parent && t < Pa; )
1861
+ for (; n !== n.parent && t < Ua; )
1862
1862
  t++, n = n.parent;
1863
1863
  return { framed: e.top ? e.top !== e.self : t > 0, depth: t };
1864
1864
  } catch {
1865
1865
  return { framed: !1, depth: 0 };
1866
1866
  }
1867
1867
  }
1868
- const Da = "watchparty_fragment_delivery";
1869
- function Oa() {
1868
+ const Ha = "watchparty_fragment_delivery";
1869
+ function $a() {
1870
1870
  if (typeof window > "u") return null;
1871
1871
  try {
1872
1872
  const e = new URLSearchParams(window.location.search).get("fragmentDelivery");
@@ -1874,93 +1874,93 @@ function Oa() {
1874
1874
  if (e === "0" || e === "false") return !1;
1875
1875
  } catch {
1876
1876
  }
1877
- return Po(Da);
1877
+ return Uo(Ha);
1878
1878
  }
1879
- let La = { ...un }, qe = null;
1880
- const Wt = "watchparty_delivery_client_id";
1881
- function Ma() {
1882
- const e = B(Wt);
1879
+ let Ba = { ...yn }, Ke = null;
1880
+ const Vt = "watchparty_delivery_client_id";
1881
+ function Ga() {
1882
+ const e = G(Vt);
1883
1883
  if (e) return e;
1884
1884
  const t = globalThis.crypto?.randomUUID?.() ?? `d${Math.random().toString(36).slice(2)}`;
1885
- return ft(Wt, t) ? t : "";
1885
+ return pt(Vt, t) ? t : "";
1886
1886
  }
1887
- function ja() {
1888
- return qe === null && (qe = Yr(La, Ma(), Oa())), qe;
1887
+ function Wa() {
1888
+ return Ke === null && (Ke = ro(Ba, Ga(), $a())), Ke;
1889
1889
  }
1890
- function Ua() {
1891
- return ja();
1890
+ function Va() {
1891
+ return Wa();
1892
1892
  }
1893
- let Re;
1894
- function Gn() {
1895
- return B(vr) || void 0;
1893
+ let Oe;
1894
+ function Jn() {
1895
+ return G(Er) || void 0;
1896
1896
  }
1897
- function Ha() {
1898
- if (Re) return;
1899
- const e = Gn();
1897
+ function qa() {
1898
+ if (Oe) return;
1899
+ const e = Jn();
1900
1900
  if (e) {
1901
- Re = e;
1901
+ Oe = e;
1902
1902
  return;
1903
1903
  }
1904
- br().then((t) => {
1905
- t && (Re = t);
1904
+ kr().then((t) => {
1905
+ t && (Oe = t);
1906
1906
  }).catch(() => {
1907
- d("identity", "device id unavailable — joining without one");
1907
+ u("identity", "device id unavailable — joining without one");
1908
1908
  });
1909
1909
  }
1910
- function Fa() {
1911
- return Re ??= Gn();
1910
+ function Ka() {
1911
+ return Oe ??= Jn();
1912
1912
  }
1913
- function $a(e, t) {
1913
+ function Ya(e, t) {
1914
1914
  let n = 0;
1915
1915
  for (const r of e.videos) {
1916
- const a = ce.voteKey(t, e.id, r.mediaId);
1917
- globalThis.localStorage?.getItem(a) != null && n++, Me(a);
1916
+ const a = de.voteKey(t, e.id, r.mediaId);
1917
+ globalThis.localStorage?.getItem(a) != null && n++, Ue(a);
1918
1918
  }
1919
1919
  return n;
1920
1920
  }
1921
- const Ba = 2e4, Ga = 1e4;
1922
- function Wa() {
1921
+ const za = 2e4, Xa = 1e4;
1922
+ function Ja() {
1923
1923
  return { unansweredSince: null, lastPongAt: null, lastTickAt: null };
1924
1924
  }
1925
- function qa(e, t) {
1925
+ function Qa(e, t) {
1926
1926
  e.lastPongAt = t, e.unansweredSince = null;
1927
1927
  }
1928
- function Va(e, t, n) {
1929
- const r = e.lastTickAt !== null && t - e.lastTickAt > Ga;
1930
- return e.lastTickAt = t, n ? r || e.unansweredSince === null ? (e.unansweredSince = t, !1) : t - e.unansweredSince > Ba : (e.unansweredSince = null, !1);
1928
+ function Za(e, t, n) {
1929
+ const r = e.lastTickAt !== null && t - e.lastTickAt > Xa;
1930
+ return e.lastTickAt = t, n ? r || e.unansweredSince === null ? (e.unansweredSince = t, !1) : t - e.unansweredSince > za : (e.unansweredSince = null, !1);
1931
1931
  }
1932
- function Ka(e, t) {
1932
+ function ei(e, t) {
1933
1933
  return e.lastPongAt === null ? void 0 : Math.max(0, t - e.lastPongAt);
1934
1934
  }
1935
- let _ = null, F = null, De = null, $ = null, z = null;
1936
- const Ya = Ja(), ie = Wa();
1937
- let Ce = null, Ve = null, qt = 0, wt = null, ye = !1, St = !1, ue = !1, Wn = null;
1938
- function za(e) {
1939
- const t = re(), n = m.getState();
1935
+ let S = null, $ = null, Me = null, B = null, z = null;
1936
+ const ti = oi(), se = Ja();
1937
+ let Te = null, Ye = null, qt = 0, wt = null, ve = !1, St = !1, me = !1, Qn = null;
1938
+ function ni(e) {
1939
+ const t = oe(), n = m.getState();
1940
1940
  if (n.me.clientId && n.roster[n.me.clientId])
1941
- return (e.name || e.sprite) && (d("socket", "Identity update (already joined)", { name: e.name, sprite: e.sprite }), t.emit(v.IDENTITY_UPDATE, { name: e.name, sprite: e.sprite })), t;
1942
- const r = Xa(e);
1943
- return z = r, wt = { name: r.name, sprite: r.sprite }, vt() && ha(r), t.connected ? (d("socket", "Emitting join", r), t.emit(v.JOIN, r)) : t.once("connect", () => {
1944
- d("socket", "Emitting join", r), t.emit(v.JOIN, r);
1941
+ 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;
1942
+ const r = ri(e);
1943
+ return z = 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", () => {
1944
+ u("socket", "Emitting join", r), t.emit(v.JOIN, r);
1945
1945
  }), t;
1946
1946
  }
1947
- function Xa(e) {
1947
+ function ri(e) {
1948
1948
  return {
1949
1949
  room_key: e.room_key,
1950
1950
  name: e.name,
1951
1951
  sprite: e.sprite,
1952
1952
  // Entry-path telemetry — see lib/embedContext.ts. Sent on every join AND
1953
1953
  // rejoin (lastJoinPayload carries it), so a reconnect keeps the attribution.
1954
- embed: Ra(),
1955
- delivery_arm: Ua(),
1954
+ embed: Fa(),
1955
+ delivery_arm: Va(),
1956
1956
  // Identity tier input — see lib/deviceId.ts. Sent on every join AND rejoin
1957
1957
  // (lastJoinPayload carries it) so a reconnect lands on the same
1958
1958
  // ParticipantId rather than minting a new person.
1959
- device_id: Fa(),
1960
- tab_id: Ya
1959
+ device_id: Ka(),
1960
+ tab_id: ti
1961
1961
  };
1962
1962
  }
1963
- function Ja() {
1963
+ function oi() {
1964
1964
  const e = globalThis.crypto;
1965
1965
  if (e && typeof e.randomUUID == "function") return e.randomUUID();
1966
1966
  const t = new Uint8Array(16);
@@ -1968,39 +1968,39 @@ function Ja() {
1968
1968
  else for (let n = 0; n < t.length; n++) t[n] = Math.floor(Math.random() * 256);
1969
1969
  return Array.from(t, (n) => n.toString(16).padStart(2, "0")).join("");
1970
1970
  }
1971
- function re() {
1972
- if (!_) {
1973
- let t = be().serverOrigin || "/";
1971
+ function oe() {
1972
+ if (!S) {
1973
+ let t = _e().serverOrigin || "/";
1974
1974
  if (t === "/" && typeof window < "u") {
1975
1975
  const r = window.location;
1976
- (r.hostname === "localhost" || r.hostname === "127.0.0.1") && r.port === String(tn) && (t = `${r.protocol}//${r.hostname}:${it}`, d("socket", "Using dev fallback origin", { origin: t }));
1976
+ (r.hostname === "localhost" || r.hostname === "127.0.0.1") && r.port === String(ln) && (t = `${r.protocol}//${r.hostname}:${st}`, u("socket", "Using dev fallback origin", { origin: t }));
1977
1977
  }
1978
- const n = ba();
1978
+ const n = Ia();
1979
1979
  if (n)
1980
- _ = Qe(n.url, { path: n.path, transports: ["websocket", "polling"] }), d("socket", "Socket initialized on the room origin", n);
1980
+ S = et(n.url, { path: n.path, transports: ["websocket", "polling"] }), u("socket", "Socket initialized on the room origin", n);
1981
1981
  else {
1982
1982
  const r = new URL(t.startsWith("http") ? t : `${window.location.origin}${t}`).origin;
1983
- _ = Qe(r, { path: Cr, transports: ["websocket", "polling"] }), d("socket", "Socket initialized", { origin: t });
1983
+ S = et(r, { path: Dr, transports: ["websocket", "polling"] }), u("socket", "Socket initialized", { origin: t });
1984
1984
  }
1985
- Ge("__SOCKET__", _), $ && (clearTimeout($), $ = null), F = null, De = setInterval(() => {
1986
- if (Va(ie, Date.now(), !!_?.connected)) {
1985
+ Ve("__SOCKET__", S), B && (clearTimeout(B), B = null), $ = null, Me = setInterval(() => {
1986
+ if (Za(se, Date.now(), !!S?.connected)) {
1987
1987
  I("socket", "PONG-WATCHDOG no time_pong for 20s — replacing the connection", {
1988
- sid: _?.id,
1989
- lastPongAgeMs: Ka(ie, Date.now()) ?? null
1990
- }), Ve = "pong-watchdog", ie.unansweredSince = null, _?.io.engine?.close();
1988
+ sid: S?.id,
1989
+ lastPongAgeMs: ei(se, Date.now()) ?? null
1990
+ }), Ye = "pong-watchdog", se.unansweredSince = null, S?.io.engine?.close();
1991
1991
  return;
1992
1992
  }
1993
- li();
1994
- }, Gr), _.on("connect", () => {
1993
+ hi();
1994
+ }, Qr), S.on("connect", () => {
1995
1995
  St = !1;
1996
- const r = _?.id;
1997
- if (d("socket", "Connected", { id: r, isReconnect: ue }), r)
1996
+ const r = S?.id;
1997
+ if (u("socket", "Connected", { id: r, isReconnect: me }), r)
1998
1998
  try {
1999
- m.getState().ensureMe(r), m.setState((a) => ({ me: { ...a.me, nextClientSeq: 1 } })), d("socket", "Reset client sequence for new connection");
1999
+ m.getState().ensureMe(r), m.setState((a) => ({ me: { ...a.me, nextClientSeq: 1 } })), u("socket", "Reset client sequence for new connection");
2000
2000
  } catch (a) {
2001
- Ne("socket", "Failed to initialize store on connect", { error: a.message, sid: r });
2001
+ Re("socket", "Failed to initialize store on connect", { error: a.message, sid: r });
2002
2002
  }
2003
- if (ue && z) {
2003
+ if (me && z) {
2004
2004
  const a = m.getState();
2005
2005
  qt += 1;
2006
2006
  const i = {
@@ -2009,63 +2009,63 @@ function re() {
2009
2009
  sprite: a.sprite,
2010
2010
  reconnect: {
2011
2011
  count: qt,
2012
- reason: (Ce?.reason ?? "unknown").slice(0, 64),
2013
- offline_ms: Ce ? Math.max(0, Date.now() - Ce.at) : 0
2012
+ reason: (Te?.reason ?? "unknown").slice(0, 64),
2013
+ offline_ms: Te ? Math.max(0, Date.now() - Te.at) : 0
2014
2014
  }
2015
- }, s = Wn;
2016
- if (d("socket", "Re-emitting join after reconnect", { room_key: i.room_key, name: i.name, sprite: i.sprite }), s) {
2015
+ }, s = Qn;
2016
+ if (u("socket", "Re-emitting join after reconnect", { room_key: i.room_key, name: i.name, sprite: i.sprite }), s) {
2017
2017
  let l = !1;
2018
- const f = () => {
2019
- l || (l = !0, _.off(v.SNAPSHOT, f), _.emit(v.CLIENT_READY, { media_id: s }), d("socket", "Re-emitted client_ready after reconnect snapshot", { mediaId: s }));
2018
+ const d = () => {
2019
+ l || (l = !0, S.off(v.SNAPSHOT, d), S.emit(v.CLIENT_READY, { media_id: s }), u("socket", "Re-emitted client_ready after reconnect snapshot", { mediaId: s }));
2020
2020
  };
2021
- _.on(v.SNAPSHOT, f), setTimeout(() => {
2022
- l || (l = !0, _.off(v.SNAPSHOT, f), I("socket", "client_ready re-emit timed out waiting for snapshot", { mediaId: s }));
2021
+ S.on(v.SNAPSHOT, d), setTimeout(() => {
2022
+ l || (l = !0, S.off(v.SNAPSHOT, d), I("socket", "client_ready re-emit timed out waiting for snapshot", { mediaId: s }));
2023
2023
  }, 1e4);
2024
2024
  }
2025
- wt = { name: i.name, sprite: i.sprite }, _.emit(v.JOIN, i), window.dispatchEvent(new CustomEvent("watchparty:socket-reconnect"));
2026
- } else ue && I("socket", "Reconnected — no join payload, not re-joining any room");
2027
- ue = !0;
2028
- }), _.on("disconnect", (r) => {
2029
- Tn(null), Ce = { reason: Ve ?? r, at: Date.now() }, Ve = null, d("socket", "Disconnected", { reason: r });
2030
- }), _.on("connect_error", (r) => Ne("socket", "Connection error", { message: r?.message })), _.on("reconnect_attempt", (r) => I("socket", "Reconnect attempt", { attempt: r })), _.on("reconnect_failed", () => Ne("socket", "Reconnect failed")), ii(_);
2025
+ wt = { name: i.name, sprite: i.sprite }, S.emit(v.JOIN, i), window.dispatchEvent(new CustomEvent("watchparty:socket-reconnect"));
2026
+ } else me && I("socket", "Reconnected — no join payload, not re-joining any room");
2027
+ me = !0;
2028
+ }), S.on("disconnect", (r) => {
2029
+ On(null), Te = { reason: Ye ?? r, at: Date.now() }, Ye = null, u("socket", "Disconnected", { reason: r });
2030
+ }), 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")), fi(S);
2031
2031
  }
2032
- return _;
2032
+ return S;
2033
2033
  }
2034
- function Ke(e) {
2034
+ function ze(e) {
2035
2035
  return e.play_state === "playing" || e.playing === !0;
2036
2036
  }
2037
- function Qa(e) {
2037
+ function ai(e) {
2038
2038
  e.on(v.SNAPSHOT, (t) => {
2039
- e.emit(dn.SYNC), m.getState().applySnapshot({
2039
+ e.emit(gn.SYNC), m.getState().applySnapshot({
2040
2040
  roomId: t.room_id ?? null,
2041
2041
  mediaId: t.media_id ?? null,
2042
2042
  playheadMs: t.playhead_ms || 0,
2043
- playing: Ke(t),
2043
+ playing: ze(t),
2044
2044
  serverSeq: t.server_seq || 0,
2045
2045
  leaderId: t.leader_id || null
2046
- }), m.getState().name || d("socket", "Deferring identity to presence event (snapshot carries no roster)");
2047
- const n = m.getState(), r = _?.id, i = (r ? n.roster[r] : void 0) ?? wt, s = gr(
2046
+ }), m.getState().name || u("socket", "Deferring identity to presence event (snapshot carries no roster)");
2047
+ const n = m.getState(), r = S?.id, i = (r ? n.roster[r] : void 0) ?? wt, s = Ir(
2048
2048
  { name: n.name, avatarId: n.sprite },
2049
2049
  i ? { name: i.name, avatarId: i.sprite ?? null } : void 0,
2050
2050
  // A join that carried no name counts as a default one, so a name that
2051
2051
  // landed after the join (prefs) is still asserted.
2052
- (l) => l === "" || ne(l)
2052
+ (l) => l === "" || re(l)
2053
2053
  );
2054
2054
  if (s) {
2055
2055
  const l = {
2056
2056
  ...s.name !== void 0 ? { name: s.name } : {},
2057
2057
  ...s.avatarId !== void 0 && !St ? { sprite: s.avatarId } : {}
2058
2058
  };
2059
- Object.keys(l).length > 0 && (d("socket", "Identity update on snapshot", l), e.emit(v.IDENTITY_UPDATE, l));
2059
+ Object.keys(l).length > 0 && (u("socket", "Identity update on snapshot", l), e.emit(v.IDENTITY_UPDATE, l));
2060
2060
  }
2061
- d("socket", "Received snapshot", {
2061
+ u("socket", "Received snapshot", {
2062
2062
  mediaId: t.media_id ?? null,
2063
2063
  playheadMs: t.playhead_ms || 0,
2064
- playing: Ke(t),
2064
+ playing: ze(t),
2065
2065
  leaderId: t.leader_id || null,
2066
2066
  serverSeq: t.server_seq || 0,
2067
2067
  rosterSize: Object.keys(n.roster).length
2068
- }), z?.room_key && _?.id && Tn({ room_key: z.room_key, client_id: _.id });
2068
+ }), z?.room_key && S?.id && On({ room_key: z.room_key, client_id: S.id });
2069
2069
  }), e.on(v.CONTROL_BROADCAST, (t) => {
2070
2070
  const n = m.getState();
2071
2071
  if (Object.prototype.hasOwnProperty.call(t, "media_id")) {
@@ -2074,10 +2074,10 @@ function Qa(e) {
2074
2074
  }
2075
2075
  n.updateControlState({
2076
2076
  playheadMs: t.playhead_ms,
2077
- playing: Ke(t),
2077
+ playing: ze(t),
2078
2078
  serverSeq: t.server_seq,
2079
2079
  leaderId: t.leader_id ?? n.snapshot.leaderId
2080
- }), d("socket", "Control broadcast received", {
2080
+ }), u("socket", "Control broadcast received", {
2081
2081
  kind: t.kind,
2082
2082
  serverSeq: t.server_seq,
2083
2083
  playheadMs: t.playhead_ms,
@@ -2085,23 +2085,23 @@ function Qa(e) {
2085
2085
  mediaId: t.media_id
2086
2086
  });
2087
2087
  }), e.on(v.CONTROL_ACK, (t) => {
2088
- typeof t?.client_seq == "number" && typeof t?.server_seq == "number" && d("socket", "Control ack received", t);
2088
+ typeof t?.client_seq == "number" && typeof t?.server_seq == "number" && u("socket", "Control ack received", t);
2089
2089
  }), e.on(v.TIME_PONG, (t) => {
2090
- if (qa(ie, Date.now()), F && F.ts) {
2091
- const n = Date.now() - F.ts;
2092
- m.getState().addRttSample(n, t?.server_ts, F.ts), F = null, $ && (clearTimeout($), $ = null), d("socket", "Time sync RTT", { rtt: n, offset: m.getState().drift.offsetMs });
2090
+ if (Qa(se, Date.now()), $ && $.ts) {
2091
+ const n = Date.now() - $.ts;
2092
+ 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 });
2093
2093
  }
2094
2094
  }), e.on(v.READY_STATE, (t) => {
2095
2095
  if (!t) return;
2096
2096
  const n = t.media_id ?? null, r = typeof t.ready_count == "number" ? t.ready_count : 0, a = typeof t.total == "number" ? t.total : 0, i = t.ready === !0;
2097
- m.getState().setReadiness({ mediaId: n, ready: i, readyCount: r, total: a }), d("socket", "Ready state received", { mediaId: n, readyCount: r, total: a, ready: i });
2097
+ m.getState().setReadiness({ mediaId: n, ready: i, readyCount: r, total: a }), u("socket", "Ready state received", { mediaId: n, readyCount: r, total: a, ready: i });
2098
2098
  });
2099
2099
  }
2100
- function Za(e) {
2101
- const t = sr(e);
2100
+ function ii(e) {
2101
+ const t = br(e);
2102
2102
  return t ? { cosmetics: t } : {};
2103
2103
  }
2104
- function ei(e) {
2104
+ function si(e) {
2105
2105
  e.on(v.PRESENCE, (t) => {
2106
2106
  if (!t) return;
2107
2107
  if (Array.isArray(t.users)) {
@@ -2115,91 +2115,91 @@ function ei(e) {
2115
2115
  isLeader: l.is_leader,
2116
2116
  ...l.registry_name ? { registryName: !0 } : {},
2117
2117
  ...l.avatar_url ? { avatarUrl: l.avatar_url } : {},
2118
- ...Za(l.cosmetics)
2118
+ ...ii(l.cosmetics)
2119
2119
  };
2120
- const a = m.getState(), i = _?.id, s = i ? r[i] : void 0;
2120
+ const a = m.getState(), i = S?.id, s = i ? r[i] : void 0;
2121
2121
  if (s?.registryName)
2122
- m.setState({ roster: r }), (s.name !== a.name || s.sprite && s.sprite !== a.sprite) && (d("socket", "Adopting registry name", { from: a.name, to: s.name }), m.getState().setSessionIdentity(s.name, s.sprite ?? a.sprite));
2122
+ m.setState({ roster: r }), (s.name !== a.name || s.sprite && s.sprite !== a.sprite) && (u("socket", "Adopting registry name", { from: a.name, to: s.name }), m.getState().setSessionIdentity(s.name, s.sprite ?? a.sprite));
2123
2123
  else if (i && r[i]) {
2124
- const l = r[i].name, f = r[i].sprite;
2125
- if (a.name && !ne(a.name) && (r[i].name = a.name), m.setState({ roster: r }), f && f !== a.sprite) {
2126
- const h = a.name && !ne(a.name), u = h ? a.name : ge(f);
2127
- d("socket", "Server reassigned sprite", { from: a.sprite, to: f, newName: u, preservingCustomName: h }), m.getState().setSessionIdentity(u, f), u !== l && e.emit(v.IDENTITY_UPDATE, { name: u });
2124
+ const l = r[i].name, d = r[i].sprite;
2125
+ if (a.name && !re(a.name) && (r[i].name = a.name), m.setState({ roster: r }), d && d !== a.sprite) {
2126
+ const h = a.name && !re(a.name), f = h ? a.name : be(d);
2127
+ u("socket", "Server reassigned sprite", { from: a.sprite, to: d, newName: f, preservingCustomName: h }), m.getState().setSessionIdentity(f, d), f !== l && e.emit(v.IDENTITY_UPDATE, { name: f });
2128
2128
  }
2129
2129
  }
2130
2130
  }
2131
- d("socket", "Received presence update", t);
2131
+ u("socket", "Received presence update", t);
2132
2132
  const n = m.getState();
2133
2133
  if (!n.name) {
2134
2134
  n.ensureAutoIdentity?.();
2135
2135
  const r = m.getState();
2136
- r.name && (d("socket", "Auto-assigned identity on presence", { name: r.name, sprite: r.sprite }), e.emit(v.IDENTITY_UPDATE, { name: r.name, sprite: r.sprite || void 0 }));
2136
+ r.name && (u("socket", "Auto-assigned identity on presence", { name: r.name, sprite: r.sprite }), e.emit(v.IDENTITY_UPDATE, { name: r.name, sprite: r.sprite || void 0 }));
2137
2137
  }
2138
2138
  });
2139
2139
  }
2140
- function ti(e) {
2141
- e.on(we.STATE, (t) => {
2140
+ function li(e) {
2141
+ e.on(Se.STATE, (t) => {
2142
2142
  m.getState().applyPlaylistState({
2143
2143
  playlist: t?.playlist ?? null,
2144
2144
  activeIndex: t?.activeIndex ?? null,
2145
2145
  myVotes: t?.myVotes ?? {}
2146
- }), d("playlist", "Playlist state received", { playlistId: t?.playlist?.id ?? null, activeIndex: t?.activeIndex, myVoteCount: Object.keys(t?.myVotes || {}).length });
2147
- }), e.on(we.VOTE_PROGRESS, (t) => {
2148
- m.getState().setVoteProgress(t?.progress ?? []), d("playlist", "Vote progress", { progressCount: t?.progress?.length });
2149
- }), e.on(we.RESULTS, (t) => {
2150
- m.getState().setPlaylistResults(t ?? null), d("playlist", "Results received", { playlistId: t?.playlist?.id, update: t?.update === !0 });
2151
- }), e.on(we.VOTES_CLEARED, (t) => {
2146
+ }), u("playlist", "Playlist state received", { playlistId: t?.playlist?.id ?? null, activeIndex: t?.activeIndex, myVoteCount: Object.keys(t?.myVotes || {}).length });
2147
+ }), e.on(Se.VOTE_PROGRESS, (t) => {
2148
+ m.getState().setVoteProgress(t?.progress ?? []), u("playlist", "Vote progress", { progressCount: t?.progress?.length });
2149
+ }), e.on(Se.RESULTS, (t) => {
2150
+ m.getState().setPlaylistResults(t ?? null), u("playlist", "Results received", { playlistId: t?.playlist?.id, update: t?.update === !0 });
2151
+ }), e.on(Se.VOTES_CLEARED, (t) => {
2152
2152
  if (!t?.playlistId || !Array.isArray(t.mediaIds)) return;
2153
- const n = $a(
2153
+ const n = Ya(
2154
2154
  { id: t.playlistId, videos: t.mediaIds.map((a) => ({ mediaId: a })) },
2155
- ea()
2155
+ sa()
2156
2156
  ), r = m.getState();
2157
- r.playlist?.id === t.playlistId && r.applyPlaylistState({ playlist: r.playlist, activeIndex: r.activePlaylistIndex, myVotes: {} }), d("playlist", "Votes cleared by leader", { playlistId: t.playlistId, removed: n });
2157
+ 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 });
2158
2158
  });
2159
2159
  }
2160
- function ni(e) {
2161
- e.on(jr.UPDATED, () => {
2162
- d("tierlist", "Someone saved — refreshing the board"), _a(!1);
2160
+ function ci(e) {
2161
+ e.on(qr.UPDATED, () => {
2162
+ u("tierlist", "Someone saved — refreshing the board"), Aa(!1);
2163
2163
  });
2164
2164
  }
2165
- function ri(e) {
2166
- e.on(Ur.STATE, (t) => {
2165
+ function di(e) {
2166
+ e.on(Kr.STATE, (t) => {
2167
2167
  if (!t || typeof t.active != "boolean") return;
2168
2168
  const n = Array.isArray(t.ready) ? t.ready.filter((r) => typeof r == "string") : [];
2169
- m.getState().setReadyCheckState({ active: t.active, ready: n }), d("ready-check", "State received", { active: t.active, readyCount: n.length });
2169
+ m.getState().setReadyCheckState({ active: t.active, ready: n }), u("ready-check", "State received", { active: t.active, readyCount: n.length });
2170
2170
  });
2171
2171
  }
2172
- function oi(e) {
2173
- e.on(dn.ACTIVE, (t) => {
2172
+ function ui(e) {
2173
+ e.on(gn.ACTIVE, (t) => {
2174
2174
  const n = typeof t?.gameId == "string" ? t.gameId : null;
2175
- m.getState().setActiveGameId(n), d("game", "game_active", { gameId: n });
2175
+ m.getState().setActiveGameId(n), u("game", "game_active", { gameId: n });
2176
2176
  });
2177
2177
  }
2178
- function ai(e) {
2178
+ function mi(e) {
2179
2179
  e.on(v.HEALTH_SNAPSHOT, (t) => {
2180
2180
  m.getState().setHealthSnapshot(t);
2181
2181
  }), e.on(v.BUFFER_STATUS, (t) => {
2182
2182
  m.getState().setBufferStatus(t);
2183
2183
  });
2184
2184
  }
2185
- function ii(e) {
2186
- Qa(e), ei(e), Un(e, () => !vt()), ai(e), ti(e), ni(e), ri(e), oi(e), e.on(v.ERROR, (t) => {
2185
+ function fi(e) {
2186
+ ai(e), si(e), qn(e, () => !_t()), mi(e), li(e), ci(e), di(e), ui(e), e.on(v.ERROR, (t) => {
2187
2187
  const n = t?.code || "error/unknown";
2188
2188
  if (n === "conflict" && t?.message === "sprite_held_by_you") {
2189
- St = !0, d("socket", "sprite held by this account's other connection: keeping the server-assigned sprite");
2189
+ St = !0, u("socket", "sprite held by this account's other connection: keeping the server-assigned sprite");
2190
2190
  return;
2191
2191
  }
2192
2192
  if (n === "conflict" && t?.message === "sprite_taken") {
2193
- if (Ia(_?.id)) {
2194
- d("socket", "sprite_taken: stale, the server already has our sprite");
2193
+ if (Ra(S?.id)) {
2194
+ u("socket", "sprite_taken: stale, the server already has our sprite");
2195
2195
  return;
2196
2196
  }
2197
- ye = !0;
2197
+ ve = !0;
2198
2198
  let s;
2199
2199
  try {
2200
- s = Ca();
2200
+ s = Pa();
2201
2201
  } finally {
2202
- ye = !1;
2202
+ ve = !1;
2203
2203
  }
2204
2204
  s && e.emit(v.IDENTITY_UPDATE, s);
2205
2205
  return;
@@ -2222,63 +2222,63 @@ function ii(e) {
2222
2222
  "recap/not_found": "No recap available for the previous episode."
2223
2223
  }[n] || n;
2224
2224
  if (n.startsWith("recap/")) {
2225
- d("socket", `recap unavailable: ${a}`, { code: n }), m.getState().pushToast("info", a);
2225
+ u("socket", `recap unavailable: ${a}`, { code: n }), m.getState().pushToast("info", a);
2226
2226
  return;
2227
2227
  }
2228
- (n.startsWith("auth/") ? I : Ne)("socket", `Server error: ${a}`, { code: n, raw: t }), m.getState().pushToast("error", a);
2228
+ (n.startsWith("auth/") ? I : Re)("socket", `Server error: ${a}`, { code: n, raw: t }), m.getState().pushToast("error", a);
2229
2229
  });
2230
2230
  }
2231
- function si(e, t) {
2231
+ function pi(e, t) {
2232
2232
  const n = t?.length ? { text: e, images: t } : { text: e };
2233
- vt() ? ga(n) : re().emit(v.CHAT_SEND, n);
2233
+ _t() ? xa(n) : oe().emit(v.CHAT_SEND, n);
2234
2234
  }
2235
- function li() {
2236
- F || (F = { ts: Date.now() }, re().emit(v.TIME_PING, {}), $ = setTimeout(() => {
2237
- F && (d("socket", "Time ping timed out after 10s, clearing inflight"), F = null), $ = null;
2235
+ function hi() {
2236
+ $ || ($ = { ts: Date.now() }, oe().emit(v.TIME_PING, {}), B = setTimeout(() => {
2237
+ $ && (u("socket", "Time ping timed out after 10s, clearing inflight"), $ = null), B = null;
2238
2238
  }, 1e4));
2239
2239
  }
2240
- function qn(e) {
2240
+ function Zn(e) {
2241
2241
  const t = m.getState(), n = t.me.clientId;
2242
2242
  if (!n || !t.roster[n]) {
2243
- Gt(e), d("socket", "Avatar change before join: the join will carry it", { sprite: e });
2243
+ Wt(e), u("socket", "Avatar change before join: the join will carry it", { sprite: e });
2244
2244
  return;
2245
2245
  }
2246
- ye = !0;
2246
+ ve = !0;
2247
2247
  try {
2248
- Gt(e);
2248
+ Wt(e);
2249
2249
  } finally {
2250
- ye = !1;
2250
+ ve = !1;
2251
2251
  }
2252
2252
  const r = m.getState(), a = { avatar: !0 };
2253
- r.sprite && r.sprite !== t.sprite && (a.sprite = r.sprite), r.name && r.name !== t.name && (a.name = r.name), d("socket", "Sending avatar change", a), re().emit(v.IDENTITY_UPDATE, a);
2253
+ 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);
2254
2254
  }
2255
- function ci(e) {
2256
- m.getState().me.clientId && di(e);
2255
+ function gi(e) {
2256
+ m.getState().me.clientId && yi(e);
2257
2257
  }
2258
- function di(e, t) {
2258
+ function yi(e, t) {
2259
2259
  const n = {};
2260
- e && (n.name = e), !(!n.name && !n.sprite) && (d("socket", "Sending identity update", n), re().emit(v.IDENTITY_UPDATE, n));
2260
+ e && (n.name = e), !(!n.name && !n.sprite) && (u("socket", "Sending identity update", n), oe().emit(v.IDENTITY_UPDATE, n));
2261
2261
  }
2262
- let Ie = { name: "", sprite: "" };
2262
+ let ke = { name: "", sprite: "" };
2263
2263
  m.subscribe((e, t) => {
2264
- if (e.name === t.name && e.sprite === t.sprite || ye) return;
2264
+ if (e.name === t.name && e.sprite === t.sprite || ve) return;
2265
2265
  const n = e.me.clientId;
2266
2266
  if (!n) return;
2267
2267
  const r = e.roster[n];
2268
2268
  if (!r) return;
2269
- const a = !!e.name && !ne(e.name) && e.name !== Ie.name && (ne(r.name || "") || r.name !== e.name), i = !!e.sprite && e.sprite !== Ie.sprite && r.sprite !== e.sprite;
2269
+ const a = !!e.name && !re(e.name) && e.name !== ke.name && (re(r.name || "") || r.name !== e.name), i = !!e.sprite && e.sprite !== ke.sprite && r.sprite !== e.sprite;
2270
2270
  if (!a && !i) return;
2271
2271
  const s = {};
2272
- a && (s.name = e.name, Ie.name = e.name), i && (s.sprite = e.sprite, Ie.sprite = e.sprite), d("socket", "Identity reassert (store change)", s), _?.connected ? _.emit(v.IDENTITY_UPDATE, s) : re().emit(v.IDENTITY_UPDATE, s);
2272
+ 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);
2273
2273
  });
2274
- function ui() {
2275
- De && (clearInterval(De), De = null), $ && (clearTimeout($), $ = null), F = null, ie.unansweredSince = null, ie.lastTickAt = null;
2274
+ function bi() {
2275
+ Me && (clearInterval(Me), Me = null), B && (clearTimeout(B), B = null), $ = null, se.unansweredSince = null, se.lastTickAt = null;
2276
2276
  }
2277
- function mi() {
2278
- d("socket", "clearJoinState called", { hadPayload: z !== null, room_key: z?.room_key }), z = null, ue = !1, Wn = null;
2277
+ function vi() {
2278
+ u("socket", "clearJoinState called", { hadPayload: z !== null, room_key: z?.room_key }), z = null, me = !1, Qn = null;
2279
2279
  }
2280
- function Vt() {
2281
- d("socket", "leaveRoom called", { room_key: z?.room_key }), mi(), ui(), jn(), _ && (_.disconnect(), _ = null), m.setState({
2280
+ function Kt() {
2281
+ u("socket", "leaveRoom called", { room_key: z?.room_key }), vi(), bi(), Vn(), S && (S.disconnect(), S = null), m.setState({
2282
2282
  me: { clientId: null, nextClientSeq: 1 },
2283
2283
  roster: {},
2284
2284
  snapshot: { roomId: null, mediaId: null, playheadMs: 0, playing: !1, serverSeq: 0, leaderId: null },
@@ -2293,31 +2293,31 @@ function Vt() {
2293
2293
  activeGameId: null
2294
2294
  });
2295
2295
  }
2296
- function fi() {
2297
- d("chat", "Emitting recap_request"), re().emit("recap_request");
2296
+ function _i() {
2297
+ u("chat", "Emitting recap_request"), oe().emit("recap_request");
2298
2298
  }
2299
- function pi() {
2300
- A(() => {
2301
- const e = Sr(), t = Aa((r) => {
2302
- const a = Fn(r);
2303
- d("avatar", "Avatar changed in the settings popout", { sprite: a, source: r.avatar?.source }), qn(a);
2304
- }), n = Na((r) => {
2305
- d("avatar", "Renamed in the settings popout", { name: r }), ci(r);
2299
+ function wi() {
2300
+ E(() => {
2301
+ const e = Nr(), t = La((r) => {
2302
+ const a = Yn(r);
2303
+ u("avatar", "Avatar changed in the settings popout", { sprite: a, source: r.avatar?.source }), Zn(a);
2304
+ }), n = ja((r) => {
2305
+ u("avatar", "Renamed in the settings popout", { name: r }), gi(r);
2306
2306
  });
2307
2307
  return () => {
2308
2308
  t(), n(), e();
2309
2309
  };
2310
2310
  }, []);
2311
2311
  }
2312
- function hi(e, t) {
2313
- return (t ? dr(t) : null) ?? En(e);
2312
+ function Si(e, t) {
2313
+ return (t ? wr(t) : null) ?? Ln(e);
2314
2314
  }
2315
- function Vn(e, t) {
2316
- return A(() => {
2317
- t && lr(t);
2318
- }, [t]), zn(cr, () => hi(e, t), () => En(e));
2315
+ function xt(e, t) {
2316
+ return E(() => {
2317
+ t && vr(t);
2318
+ }, [t]), ir(_r, () => Si(e, t), () => Ln(e));
2319
2319
  }
2320
- function gi(e, t) {
2320
+ function xi(e, t) {
2321
2321
  if (t.clientId) {
2322
2322
  const n = e[t.clientId];
2323
2323
  if (n && (!t.author || !n.author || n.author === t.author)) return n;
@@ -2326,8 +2326,8 @@ function gi(e, t) {
2326
2326
  for (const n of Object.values(e)) if (n.author === t.author) return n;
2327
2327
  }
2328
2328
  }
2329
- function yi(e, t, n) {
2330
- const r = gi(e, t);
2329
+ function Ci(e, t, n) {
2330
+ const r = xi(e, t);
2331
2331
  return r ? {
2332
2332
  name: r.name || n.name,
2333
2333
  // A connection briefly without a character (a reconnect waiting for one to
@@ -2338,15 +2338,15 @@ function yi(e, t, n) {
2338
2338
  here: !0
2339
2339
  } : { name: n.name, sprite: n.sprite, pictureUrl: n.pictureUrl, here: !1 };
2340
2340
  }
2341
- function bi(e, t, n) {
2342
- return !t || !n.here ? e : t.split(an).join(n.name);
2341
+ function Ii(e, t, n) {
2342
+ return !t || !n.here ? e : t.split(mn).join(n.name);
2343
2343
  }
2344
- function vi(e, t) {
2345
- const n = m((r) => JSON.stringify(yi(r.roster, e, t)));
2346
- return te(() => JSON.parse(n), [n]);
2344
+ function er(e, t) {
2345
+ const n = m((r) => JSON.stringify(Ci(r.roster, e, t)));
2346
+ return ee(() => JSON.parse(n), [n]);
2347
2347
  }
2348
- function Kn({ sprite: e, url: t, alt: n = "", className: r, style: a, fallback: i }) {
2349
- const [s, l] = P(null);
2348
+ function tr({ sprite: e, url: t, alt: n = "", className: r, style: a, fallback: i }) {
2349
+ const [s, l] = k(null);
2350
2350
  if (t && t !== s)
2351
2351
  return /* @__PURE__ */ c(
2352
2352
  "img",
@@ -2360,13 +2360,13 @@ function Kn({ sprite: e, url: t, alt: n = "", className: r, style: a, fallback:
2360
2360
  onError: () => l(t)
2361
2361
  }
2362
2362
  );
2363
- const f = ta(e);
2364
- return f ? /* @__PURE__ */ c("img", { src: f, alt: n, crossOrigin: "anonymous", className: r, style: a, draggable: !1 }) : /* @__PURE__ */ c(se, { children: i });
2363
+ const d = la(e);
2364
+ return d ? /* @__PURE__ */ c("img", { src: d, alt: n, crossOrigin: "anonymous", className: r, style: a, draggable: !1 }) : /* @__PURE__ */ c(le, { children: i });
2365
2365
  }
2366
- function wi({ sprite: e, url: t, alt: n, worn: r }) {
2367
- return /* @__PURE__ */ w("span", { className: "hc-av", style: { "--hc-sz": "32px" }, children: [
2366
+ function nr({ sprite: e, url: t, alt: n, worn: r }) {
2367
+ return /* @__PURE__ */ _("span", { className: "hc-av", style: { "--hc-sz": "32px" }, children: [
2368
2368
  /* @__PURE__ */ c("span", { className: "hc-pic", children: /* @__PURE__ */ c(
2369
- Kn,
2369
+ tr,
2370
2370
  {
2371
2371
  sprite: e,
2372
2372
  url: t,
@@ -2375,22 +2375,22 @@ function wi({ sprite: e, url: t, alt: n, worn: r }) {
2375
2375
  fallback: /* @__PURE__ */ c("span", { className: "inline-block w-8 h-8 bg-bg-alt/50 rounded-full flex-shrink-0" })
2376
2376
  }
2377
2377
  ) }),
2378
- r?.overlay && /* @__PURE__ */ c(et, { html: ur(r), style: { display: "contents" } })
2378
+ r?.overlay && /* @__PURE__ */ c(ge, { html: Sr(r), style: { display: "contents" } })
2379
2379
  ] });
2380
2380
  }
2381
- function Si(e) {
2381
+ function Ti(e) {
2382
2382
  return !(e.button !== 0 || e.ctrlKey || e.metaKey || e.shiftKey || e.altKey);
2383
2383
  }
2384
- function _i({ src: e, title: t, onClose: n }) {
2385
- A(() => {
2384
+ function ki({ src: e, title: t, onClose: n }) {
2385
+ E(() => {
2386
2386
  const i = (s) => {
2387
- ut(s) && (s.stopPropagation(), n());
2387
+ mt(s) && (s.stopPropagation(), n());
2388
2388
  };
2389
2389
  return document.addEventListener("keydown", i, !0), () => document.removeEventListener("keydown", i, !0);
2390
2390
  }, [n]);
2391
- const r = To(), a = typeof document > "u" ? null : document.fullscreenElement ?? r ?? document.body;
2392
- return a ? _r(
2393
- /* @__PURE__ */ w(
2391
+ const r = Mo(), a = typeof document > "u" ? null : document.fullscreenElement ?? r ?? document.body;
2392
+ return a ? Pr(
2393
+ /* @__PURE__ */ _(
2394
2394
  "div",
2395
2395
  {
2396
2396
  className: "fixed inset-0 z-[10000] flex flex-col items-center justify-center bg-black/85 p-6",
@@ -2427,12 +2427,12 @@ function _i({ src: e, title: t, onClose: n }) {
2427
2427
  a
2428
2428
  ) : null;
2429
2429
  }
2430
- const Ye = 240, xi = 320;
2431
- function Ci({ image: e }) {
2432
- const [t, n] = P(!1), r = Le(e.key);
2430
+ const Xe = 240, Ei = 320;
2431
+ function Ai({ image: e }) {
2432
+ const [t, n] = k(!1), r = je(e.key);
2433
2433
  if (!r) return null;
2434
- const a = e.w > 0 && e.h > 0, i = a ? Math.min(1, xi / e.w, Ye / e.h) : 1;
2435
- return /* @__PURE__ */ w(se, { children: [
2434
+ const a = e.w > 0 && e.h > 0, i = a ? Math.min(1, Ei / e.w, Xe / e.h) : 1;
2435
+ return /* @__PURE__ */ _(le, { children: [
2436
2436
  /* @__PURE__ */ c(
2437
2437
  "a",
2438
2438
  {
@@ -2442,7 +2442,7 @@ function Ci({ image: e }) {
2442
2442
  className: "block max-w-full cursor-zoom-in",
2443
2443
  "data-testid": "chat-image",
2444
2444
  onClick: (s) => {
2445
- Si(s) && (s.preventDefault(), n(!0));
2445
+ Ti(s) && (s.preventDefault(), n(!0));
2446
2446
  },
2447
2447
  children: /* @__PURE__ */ c(
2448
2448
  "img",
@@ -2454,13 +2454,13 @@ function Ci({ image: e }) {
2454
2454
  width: a ? Math.round(e.w * i) : void 0,
2455
2455
  height: a ? Math.round(e.h * i) : void 0,
2456
2456
  className: "rounded border border-border-light object-contain bg-bg-alt/30",
2457
- style: a ? { aspectRatio: `${e.w} / ${e.h}`, maxWidth: "100%", maxHeight: Ye } : { maxWidth: "100%", maxHeight: Ye }
2457
+ style: a ? { aspectRatio: `${e.w} / ${e.h}`, maxWidth: "100%", maxHeight: Xe } : { maxWidth: "100%", maxHeight: Xe }
2458
2458
  }
2459
2459
  )
2460
2460
  }
2461
2461
  ),
2462
2462
  t && /* @__PURE__ */ c(
2463
- _i,
2463
+ ki,
2464
2464
  {
2465
2465
  src: r,
2466
2466
  title: e.title,
@@ -2469,52 +2469,52 @@ function Ci({ image: e }) {
2469
2469
  )
2470
2470
  ] });
2471
2471
  }
2472
- function Ii({ images: e }) {
2473
- 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(Ci, { image: t }, `${t.key}-${n}`)) }) : null;
2472
+ function rr({ images: e }) {
2473
+ 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(Ai, { image: t }, `${t.key}-${n}`)) }) : null;
2474
2474
  }
2475
- function Ti(e, t) {
2475
+ function Ni(e, t) {
2476
2476
  return e.author && t.author ? e.author === t.author : !!t.clientId && e.clientId === t.clientId;
2477
2477
  }
2478
- function ze(e) {
2478
+ function Je(e) {
2479
2479
  return new Date(e).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
2480
2480
  }
2481
- const ki = Oe.memo(function({ message: t }) {
2482
- const n = m((u) => u.me.clientId), r = m((u) => u.me.clientId ? u.roster[u.me.clientId]?.author : void 0), a = Ti(t, { clientId: n, author: r }), i = vi(
2481
+ const Pi = Le.memo(function({ message: t }) {
2482
+ const n = m((f) => f.me.clientId), r = m((f) => f.me.clientId ? f.roster[f.me.clientId]?.author : void 0), a = Ni(t, { clientId: n, author: r }), i = er(
2483
2483
  { clientId: t.clientId, author: t.author },
2484
2484
  { name: t.name, sprite: t.sprite }
2485
- ), s = Vn(i.sprite, i.pictureUrl), l = t.isSystem ? void 0 : i.cosmetics, f = G(null);
2486
- Ao(f, !!l);
2487
- const [h] = P(
2488
- () => t.live && t.text ? mr(t.text, l) : null
2485
+ ), s = xt(i.sprite, i.pictureUrl), l = t.isSystem ? void 0 : i.cosmetics, d = W(null);
2486
+ Lo(d, !!l);
2487
+ const [h] = k(
2488
+ () => t.live && t.text ? nn(t.text, l) : null
2489
2489
  );
2490
- return t.isSystem && t.systemType === "recap" ? /* @__PURE__ */ c("div", { className: "px-2 py-1.5", children: /* @__PURE__ */ w("div", { className: "border-l-2 border-border-light pl-2.5 py-0.5", children: [
2491
- /* @__PURE__ */ w("div", { className: "text-[10px] uppercase tracking-wide text-text-muted mb-0.5", children: [
2490
+ return t.isSystem && t.systemType === "recap" ? /* @__PURE__ */ c("div", { className: "px-2 py-1.5", children: /* @__PURE__ */ _("div", { className: "border-l-2 border-border-light pl-2.5 py-0.5", children: [
2491
+ /* @__PURE__ */ _("div", { className: "text-[10px] uppercase tracking-wide text-text-muted mb-0.5", children: [
2492
2492
  "Recap",
2493
- /* @__PURE__ */ c("span", { className: "ml-1.5 normal-case tracking-normal opacity-60", children: ze(t.ts) })
2493
+ /* @__PURE__ */ c("span", { className: "ml-1.5 normal-case tracking-normal opacity-60", children: Je(t.ts) })
2494
2494
  ] }),
2495
2495
  /* @__PURE__ */ c("p", { className: "text-[13px] text-text-secondary leading-relaxed whitespace-pre-wrap break-words", children: t.text })
2496
- ] }) }) : t.isSystem ? /* @__PURE__ */ w("div", { className: "px-2 py-0.5 text-[11px] text-text-muted italic text-center leading-tight", children: [
2497
- bi(t.text, t.template, i),
2498
- /* @__PURE__ */ c("span", { className: "ml-1 text-[10px] opacity-50", children: ze(t.ts) })
2499
- ] }) : /* @__PURE__ */ w("div", { ref: f, style: Eo(s), className: `flex items-start gap-2 px-2 py-1 hover:bg-bg-card/20 ${a ? "bg-bg-card/30" : ""}`, children: [
2500
- /* @__PURE__ */ c(wi, { sprite: i.sprite, url: i.pictureUrl, alt: i.name, worn: l }),
2501
- /* @__PURE__ */ w("div", { className: "flex-1 min-w-0 -mt-0.5", children: [
2502
- l ? /* @__PURE__ */ c(et, { html: fr(i.name, l), className: "text-[13px]", style: { color: s } }) : /* @__PURE__ */ c("span", { className: "font-medium text-[13px]", style: { color: s }, children: i.name }),
2503
- /* @__PURE__ */ c("span", { className: "text-[10px] text-text-muted opacity-60 ml-1.5", children: ze(t.ts) }),
2504
- t.text && (h ? /* @__PURE__ */ c(et, { as: "p", html: h, className: "text-[13px] text-text break-words leading-snug m-0" }) : /* @__PURE__ */ c("p", { className: "text-[13px] text-text break-words leading-snug m-0", children: t.text })),
2505
- /* @__PURE__ */ c(Ii, { images: t.images })
2496
+ ] }) }) : t.isSystem ? /* @__PURE__ */ _("div", { className: "px-2 py-0.5 text-[11px] text-text-muted italic text-center leading-tight", children: [
2497
+ Ii(t.text, t.template, i),
2498
+ /* @__PURE__ */ c("span", { className: "ml-1 text-[10px] opacity-50", children: Je(t.ts) })
2499
+ ] }) : /* @__PURE__ */ _("div", { ref: d, style: Nn(s), className: `flex items-start gap-2 px-2 py-1 hover:bg-bg-card/20 ${a ? "bg-bg-card/30" : ""}`, children: [
2500
+ /* @__PURE__ */ c(nr, { sprite: i.sprite, url: i.pictureUrl, alt: i.name, worn: l }),
2501
+ /* @__PURE__ */ _("div", { className: "flex-1 min-w-0 -mt-0.5", children: [
2502
+ l ? /* @__PURE__ */ c(ge, { html: rn(i.name, l), className: "text-[13px]", style: { color: s } }) : /* @__PURE__ */ c("span", { className: "font-medium text-[13px]", style: { color: s }, children: i.name }),
2503
+ /* @__PURE__ */ c("span", { className: "text-[10px] text-text-muted opacity-60 ml-1.5", children: Je(t.ts) }),
2504
+ t.text && (h ? /* @__PURE__ */ c(ge, { as: "p", html: h, className: "text-[13px] text-text break-words leading-snug m-0" }) : /* @__PURE__ */ c("p", { className: "text-[13px] text-text break-words leading-snug m-0", children: t.text })),
2505
+ /* @__PURE__ */ c(rr, { images: t.images })
2506
2506
  ] })
2507
2507
  ] });
2508
2508
  });
2509
- function Ei() {
2510
- ko();
2511
- const e = m((a) => a.chat), t = G(null), n = G(!1), r = E(() => {
2509
+ function Ri() {
2510
+ An();
2511
+ const e = m((a) => a.chat), t = W(null), n = W(!1), r = A(() => {
2512
2512
  const a = t.current;
2513
2513
  if (!a) return;
2514
- const { scrollHeight: i, scrollTop: s, clientHeight: l } = a, f = i - s - l;
2515
- n.current = f > 40;
2514
+ const { scrollHeight: i, scrollTop: s, clientHeight: l } = a, d = i - s - l;
2515
+ n.current = d > 40;
2516
2516
  }, []);
2517
- return A(() => {
2517
+ return E(() => {
2518
2518
  const a = t.current;
2519
2519
  a && !n.current && a.scrollTo({ top: a.scrollHeight, behavior: "smooth" });
2520
2520
  }, [e.length]), /* @__PURE__ */ c(
@@ -2523,21 +2523,21 @@ function Ei() {
2523
2523
  ref: t,
2524
2524
  onScroll: r,
2525
2525
  className: "flex-1 overflow-y-auto overflow-x-hidden chat-messages",
2526
- children: e.length === 0 ? /* @__PURE__ */ c("div", { className: "p-4 text-xs text-text-muted text-center", children: "No messages yet. Be the first to say something!" }) : /* @__PURE__ */ c(se, { children: e.map((a, i) => {
2526
+ children: e.length === 0 ? /* @__PURE__ */ c("div", { className: "p-4 text-xs text-text-muted text-center", children: "No messages yet. Be the first to say something!" }) : /* @__PURE__ */ c(le, { children: e.map((a, i) => {
2527
2527
  const s = i > 0 ? e[i - 1] : null, l = s && a.ts - s.ts > 1440 * 60 * 1e3;
2528
- return /* @__PURE__ */ w(Oe.Fragment, { children: [
2529
- l && /* @__PURE__ */ w("div", { className: "flex items-center gap-2 px-4 py-2 my-1", children: [
2528
+ return /* @__PURE__ */ _(Le.Fragment, { children: [
2529
+ l && /* @__PURE__ */ _("div", { className: "flex items-center gap-2 px-4 py-2 my-1", children: [
2530
2530
  /* @__PURE__ */ c("div", { className: "flex-1 h-px bg-border" }),
2531
2531
  /* @__PURE__ */ c("span", { className: "text-[10px] text-text-muted whitespace-nowrap", children: new Date(a.ts).toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" }) }),
2532
2532
  /* @__PURE__ */ c("div", { className: "flex-1 h-px bg-border" })
2533
2533
  ] }),
2534
- /* @__PURE__ */ c(ki, { message: a })
2534
+ /* @__PURE__ */ c(Pi, { message: a })
2535
2535
  ] }, a.id);
2536
2536
  }) })
2537
2537
  }
2538
2538
  );
2539
2539
  }
2540
- const _t = [
2540
+ const Ct = [
2541
2541
  {
2542
2542
  name: "recap",
2543
2543
  description: "Summarise the previous episode of what is loaded",
@@ -2557,13 +2557,13 @@ const _t = [
2557
2557
  usage: "/help",
2558
2558
  scope: "local"
2559
2559
  }
2560
- ], le = "/";
2561
- function Ai(e) {
2562
- if (!e.startsWith(le)) return null;
2563
- const t = e.slice(le.length);
2560
+ ], ce = "/";
2561
+ function Di(e) {
2562
+ if (!e.startsWith(ce)) return null;
2563
+ const t = e.slice(ce.length);
2564
2564
  return /\s/.test(t) ? null : t.toLowerCase();
2565
2565
  }
2566
- function Ni(e, t = _t) {
2566
+ function Oi(e, t = Ct) {
2567
2567
  const n = e.toLowerCase();
2568
2568
  if (!n) return [...t].sort((a, i) => a.name.localeCompare(i.name));
2569
2569
  const r = [];
@@ -2573,23 +2573,23 @@ function Ni(e, t = _t) {
2573
2573
  }
2574
2574
  return r.sort((a, i) => a.rank - i.rank || a.cmd.name.localeCompare(i.cmd.name)).map((a) => a.cmd);
2575
2575
  }
2576
- function Pi(e) {
2577
- return `${le}${e.name} `;
2576
+ function Mi(e) {
2577
+ return `${ce}${e.name} `;
2578
2578
  }
2579
- function Xe(e, t) {
2579
+ function Qe(e, t) {
2580
2580
  return t <= 0 ? 0 : (e % t + t) % t;
2581
2581
  }
2582
- function Ri(e, t = _t) {
2582
+ function Li(e, t = Ct) {
2583
2583
  const n = e.trim();
2584
2584
  if (!n) return null;
2585
- if (!n.startsWith(le)) return { kind: "chat", text: n };
2586
- const r = n.slice(le.length), a = r.search(/\s/), i = (a === -1 ? r : r.slice(0, a)).toLowerCase(), s = a === -1 ? "" : r.slice(a).trim(), l = t.find((f) => f.name.toLowerCase() === i);
2585
+ if (!n.startsWith(ce)) return { kind: "chat", text: n };
2586
+ 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);
2587
2587
  return l ? { kind: "command", command: l, args: s } : { kind: "chat", text: n };
2588
2588
  }
2589
- function Di(e, t) {
2590
- return e.requiresMedia && !t.hasMedia ? `${le}${e.name} needs an episode loaded.` : null;
2589
+ function ji(e, t) {
2590
+ return e.requiresMedia && !t.hasMedia ? `${ce}${e.name} needs an episode loaded.` : null;
2591
2591
  }
2592
- function Oi({
2592
+ function Ui({
2593
2593
  commands: e,
2594
2594
  activeIndex: t,
2595
2595
  hasMedia: n,
@@ -2607,22 +2607,22 @@ function Oi({
2607
2607
  bg-bg-card border border-border-light rounded shadow-lg
2608
2608
  list-none m-0 p-0 py-1 mb-1`,
2609
2609
  children: e.map((s, l) => {
2610
- const f = !!s.requiresMedia && !n, h = l === t;
2611
- return /* @__PURE__ */ w(
2610
+ const d = !!s.requiresMedia && !n, h = l === t;
2611
+ return /* @__PURE__ */ _(
2612
2612
  "li",
2613
2613
  {
2614
2614
  id: `${i}-opt-${s.name}`,
2615
2615
  role: "option",
2616
2616
  "aria-selected": h,
2617
- "aria-disabled": f,
2618
- onMouseDown: (u) => {
2619
- u.preventDefault(), r(s);
2617
+ "aria-disabled": d,
2618
+ onMouseDown: (f) => {
2619
+ f.preventDefault(), r(s);
2620
2620
  },
2621
2621
  onMouseEnter: () => a(l),
2622
- className: `px-3 py-1.5 cursor-pointer flex items-baseline gap-2 ${h ? "bg-bg-alt" : ""} ${f ? "opacity-50" : ""}`,
2622
+ className: `px-3 py-1.5 cursor-pointer flex items-baseline gap-2 ${h ? "bg-bg-alt" : ""} ${d ? "opacity-50" : ""}`,
2623
2623
  children: [
2624
2624
  /* @__PURE__ */ c("span", { className: "text-sm font-semibold text-text shrink-0", children: s.usage }),
2625
- /* @__PURE__ */ c("span", { className: "text-xs text-text-secondary truncate", children: f ? "needs an episode loaded" : s.description })
2625
+ /* @__PURE__ */ c("span", { className: "text-xs text-text-secondary truncate", children: d ? "needs an episode loaded" : s.description })
2626
2626
  ]
2627
2627
  },
2628
2628
  s.name
@@ -2631,12 +2631,12 @@ function Oi({
2631
2631
  }
2632
2632
  );
2633
2633
  }
2634
- function Li({
2634
+ function Fi({
2635
2635
  pending: e,
2636
2636
  uploading: t,
2637
2637
  onRemove: n
2638
2638
  }) {
2639
- return e.length ? /* @__PURE__ */ c("div", { className: "flex flex-wrap gap-1.5 pb-1.5", "data-testid": "chat-attachment-strip", children: e.map((r) => /* @__PURE__ */ w("div", { className: "relative", children: [
2639
+ return e.length ? /* @__PURE__ */ c("div", { className: "flex flex-wrap gap-1.5 pb-1.5", "data-testid": "chat-attachment-strip", children: e.map((r) => /* @__PURE__ */ _("div", { className: "relative", children: [
2640
2640
  /* @__PURE__ */ c(
2641
2641
  "img",
2642
2642
  {
@@ -2658,49 +2658,49 @@ function Li({
2658
2658
  )
2659
2659
  ] }, r.id)) }) : null;
2660
2660
  }
2661
- function Mi() {
2662
- const [e, t] = P([]), [n, r] = P(!1), a = m((p) => p.pushToast), i = G(/* @__PURE__ */ new Set());
2663
- A(() => () => {
2661
+ function Hi() {
2662
+ const [e, t] = k([]), [n, r] = k(!1), a = m((p) => p.pushToast), i = W(/* @__PURE__ */ new Set());
2663
+ E(() => () => {
2664
2664
  for (const p of i.current) URL.revokeObjectURL(p);
2665
2665
  i.current.clear();
2666
2666
  }, []);
2667
- const s = E((p) => {
2668
- io(p) && (URL.revokeObjectURL(p.previewUrl), i.current.delete(p.previewUrl));
2669
- }, []), l = E(async (p) => {
2667
+ const s = A((p) => {
2668
+ go(p) && (URL.revokeObjectURL(p.previewUrl), i.current.delete(p.previewUrl));
2669
+ }, []), l = A(async (p) => {
2670
2670
  if (!p.length) return;
2671
2671
  const x = [];
2672
- for (const S of p) {
2673
- const y = lo(S);
2672
+ for (const w of p) {
2673
+ const y = bo(w);
2674
2674
  if (y) {
2675
2675
  a("error", y);
2676
2676
  continue;
2677
2677
  }
2678
- const { w: g, h: T } = await mo(S), N = URL.createObjectURL(S);
2678
+ const { w: g, h: T } = await wo(w), N = URL.createObjectURL(w);
2679
2679
  i.current.add(N), x.push({
2680
2680
  kind: "file",
2681
2681
  id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
2682
- file: S,
2682
+ file: w,
2683
2683
  previewUrl: N,
2684
2684
  w: g,
2685
2685
  h: T
2686
2686
  });
2687
2687
  }
2688
- x.length && t((S) => {
2689
- const y = J - S.length;
2688
+ x.length && t((w) => {
2689
+ const y = J - w.length;
2690
2690
  if (y <= 0) {
2691
2691
  a("info", `Up to ${J} images per message`);
2692
2692
  for (const g of x) s(g);
2693
- return S;
2693
+ return w;
2694
2694
  }
2695
2695
  if (x.length > y) {
2696
2696
  a("info", `Up to ${J} images per message`);
2697
2697
  for (const g of x.slice(y)) s(g);
2698
2698
  }
2699
- return [...S, ...x.slice(0, y)];
2699
+ return [...w, ...x.slice(0, y)];
2700
2700
  });
2701
- }, [a, s]), f = E((p) => {
2702
- const x = Le(p.key);
2703
- x && (t((S) => S.length >= J ? (a("info", `Up to ${J} images per message`), S) : [...S, {
2701
+ }, [a, s]), d = A((p) => {
2702
+ const x = je(p.key);
2703
+ x && (t((w) => w.length >= J ? (a("info", `Up to ${J} images per message`), w) : [...w, {
2704
2704
  kind: "remote",
2705
2705
  id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
2706
2706
  key: p.key,
@@ -2710,32 +2710,32 @@ function Mi() {
2710
2710
  w: p.width ?? 0,
2711
2711
  h: p.height ?? 0,
2712
2712
  title: p.title || void 0
2713
- }]), $e().catalogue(vn).recordUse(p.key));
2714
- }, [a]), h = E((p) => {
2713
+ }]), Ge().catalogue(In).recordUse(p.key));
2714
+ }, [a]), h = A((p) => {
2715
2715
  t((x) => {
2716
- const S = x.find((y) => y.id === p);
2717
- return S && s(S), x.filter((y) => y.id !== p);
2716
+ const w = x.find((y) => y.id === p);
2717
+ return w && s(w), x.filter((y) => y.id !== p);
2718
2718
  });
2719
- }, [s]), u = E(() => {
2719
+ }, [s]), f = A(() => {
2720
2720
  t((p) => {
2721
2721
  for (const x of p) s(x);
2722
2722
  return [];
2723
2723
  });
2724
- }, [s]), L = E((p) => {
2725
- const x = co(p.clipboardData);
2724
+ }, [s]), M = A((p) => {
2725
+ const x = vo(p.clipboardData);
2726
2726
  x.length && (p.preventDefault(), l(x));
2727
- }, [l]), R = E((p) => {
2728
- const x = uo(p.dataTransfer);
2727
+ }, [l]), R = A((p) => {
2728
+ const x = _o(p.dataTransfer);
2729
2729
  x.length && (p.preventDefault(), l(x));
2730
- }, [l]), D = E((p) => {
2730
+ }, [l]), D = A((p) => {
2731
2731
  p.dataTransfer?.types?.includes("Files") && p.preventDefault();
2732
- }, []), U = E(async () => {
2732
+ }, []), F = A(async () => {
2733
2733
  if (!e.length) return [];
2734
2734
  r(!0);
2735
2735
  try {
2736
- return await po(e);
2736
+ return await xo(e);
2737
2737
  } catch (p) {
2738
- return I("chat", "Image upload failed", ho(p)), a("error", so(p)), null;
2738
+ return I("chat", "Image upload failed", Co(p)), a("error", yo(p)), null;
2739
2739
  } finally {
2740
2740
  r(!1);
2741
2741
  }
@@ -2744,123 +2744,123 @@ function Mi() {
2744
2744
  pending: e,
2745
2745
  uploading: n,
2746
2746
  addFiles: l,
2747
- addMeme: f,
2747
+ addMeme: d,
2748
2748
  remove: h,
2749
- clear: u,
2750
- uploadPending: U,
2751
- onPaste: L,
2749
+ clear: f,
2750
+ uploadPending: F,
2751
+ onPaste: M,
2752
2752
  onDrop: R,
2753
2753
  onDragOver: D
2754
2754
  };
2755
2755
  }
2756
- const Kt = nn, ji = Ir;
2757
- function Ui({ commands: e = _t }) {
2758
- const [t, n] = P(""), [r, a] = P(!1), [i, s] = P({ q: null, i: 0 }), [l, f] = P(!1), h = G(null), u = Xn(), [L, R] = P(!1), [D, U] = P(!1), p = Mi(), x = m((b) => b.snapshot.mediaId), S = m((b) => b.pushToast), y = m((b) => b.setTierlistOpen), g = !!x, T = Ai(t), N = te(
2759
- () => T === null ? [] : Ni(T, e),
2756
+ const Yt = cn, $i = Or;
2757
+ function Bi({ commands: e = Ct }) {
2758
+ const [t, n] = k(""), [r, a] = k(!1), [i, s] = k({ q: null, i: 0 }), [l, d] = k(!1), h = W(null), f = sr(), [M, R] = k(!1), [D, F] = k(!1), p = Hi(), x = m((b) => b.snapshot.mediaId), w = m((b) => b.pushToast), y = m((b) => b.setTierlistOpen), g = !!x, T = Di(t), N = ee(
2759
+ () => T === null ? [] : Oi(T, e),
2760
2760
  [T, e]
2761
- ), j = T !== null && !l && N.length > 0, H = i.q === T ? Xe(i.i, N.length) : 0, C = E(
2761
+ ), j = T !== null && !l && N.length > 0, U = i.q === T ? Qe(i.i, N.length) : 0, C = A(
2762
2762
  (b) => s({ q: T, i: b }),
2763
2763
  [T]
2764
- ), O = E((b, M) => {
2765
- const de = Di(b, { hasMedia: g });
2766
- if (de) {
2767
- S("info", de);
2764
+ ), O = A((b, L) => {
2765
+ const ue = ji(b, { hasMedia: g });
2766
+ if (ue) {
2767
+ w("info", ue);
2768
2768
  return;
2769
2769
  }
2770
2770
  switch (b.name) {
2771
2771
  case "help":
2772
- S("info", e.map((Yn) => Yn.usage).join(" "));
2772
+ w("info", e.map((ar) => ar.usage).join(" "));
2773
2773
  break;
2774
2774
  case "recap":
2775
- fi();
2775
+ _i();
2776
2776
  break;
2777
2777
  case "tierlist":
2778
- xa(), y(!0);
2778
+ Na(), y(!0);
2779
2779
  break;
2780
2780
  default:
2781
- S("info", `${b.usage} is not implemented yet.`);
2781
+ w("info", `${b.usage} is not implemented yet.`);
2782
2782
  }
2783
- }, [g, S, e, y]), k = E((b) => {
2784
- n(Pi(b)), f(!1), h.current?.focus();
2785
- }, []), oe = E(async (b) => {
2783
+ }, [g, w, e, y]), P = A((b) => {
2784
+ n(Mi(b)), d(!1), h.current?.focus();
2785
+ }, []), H = A(async (b) => {
2786
2786
  if (b.preventDefault(), r || p.uploading) return;
2787
- const M = Ri(t, e);
2788
- if (!M && !p.pending.length) return;
2789
- if (M?.kind === "command" && p.pending.length) {
2790
- S("info", "Send images on their own, not with a command.");
2787
+ const L = Li(t, e);
2788
+ if (!L && !p.pending.length) return;
2789
+ if (L?.kind === "command" && p.pending.length) {
2790
+ w("info", "Send images on their own, not with a command.");
2791
2791
  return;
2792
2792
  }
2793
- if (M?.kind === "command") {
2794
- O(M.command, M.args), n(""), !document.hidden && document.hasFocus() && h.current?.focus();
2793
+ if (L?.kind === "command") {
2794
+ O(L.command, L.args), n(""), !document.hidden && document.hasFocus() && h.current?.focus();
2795
2795
  return;
2796
2796
  }
2797
- const de = await p.uploadPending();
2798
- de !== null && (si(M?.text ?? "", de), n(""), p.clear(), a(!0), setTimeout(() => a(!1), ji), !document.hidden && document.hasFocus() && h.current?.focus());
2799
- }, [t, r, O, p, S, e]), ae = E((b) => {
2797
+ const ue = await p.uploadPending();
2798
+ ue !== null && (pi(L?.text ?? "", ue), n(""), p.clear(), a(!0), setTimeout(() => a(!1), $i), !document.hidden && document.hasFocus() && h.current?.focus());
2799
+ }, [t, r, O, p, w, e]), ae = A((b) => {
2800
2800
  if (b.key === "Escape" && j) {
2801
- b.preventDefault(), f(!0);
2801
+ b.preventDefault(), d(!0);
2802
2802
  return;
2803
2803
  }
2804
2804
  if (j) {
2805
2805
  if (b.key === "ArrowDown")
2806
- b.preventDefault(), C(Xe(H + 1, N.length));
2806
+ b.preventDefault(), C(Qe(U + 1, N.length));
2807
2807
  else if (b.key === "ArrowUp")
2808
- b.preventDefault(), C(Xe(H - 1, N.length));
2808
+ b.preventDefault(), C(Qe(U - 1, N.length));
2809
2809
  else if (b.key === "Tab") {
2810
2810
  b.preventDefault();
2811
- const M = N[H];
2812
- M && k(M);
2811
+ const L = N[U];
2812
+ L && P(L);
2813
2813
  } else if (b.key === "Enter") {
2814
2814
  b.preventDefault();
2815
- const M = N[H];
2816
- M && k(M);
2815
+ const L = N[U];
2816
+ L && P(L);
2817
2817
  }
2818
2818
  }
2819
- }, [j, N, H, k, C]);
2820
- A(() => {
2819
+ }, [j, N, U, P, C]);
2820
+ E(() => {
2821
2821
  const b = () => {
2822
2822
  document.hidden || !document.hasFocus() || (h.current?.focus(), h.current?.scrollIntoView({ block: "nearest" }));
2823
2823
  };
2824
2824
  return window.addEventListener("watchparty:focus-chat-input", b), () => window.removeEventListener("watchparty:focus-chat-input", b);
2825
2825
  }, []);
2826
- const W = Kt - t.length, X = W <= 100, xt = j ? N[H] : void 0;
2827
- return /* @__PURE__ */ w(
2826
+ const ie = Yt - t.length, te = ie <= 100, X = j ? N[U] : void 0;
2827
+ return /* @__PURE__ */ _(
2828
2828
  "form",
2829
2829
  {
2830
2830
  onSubmit: (b) => {
2831
- oe(b);
2831
+ H(b);
2832
2832
  },
2833
2833
  onPaste: p.onPaste,
2834
2834
  onDrop: p.onDrop,
2835
2835
  onDragOver: p.onDragOver,
2836
2836
  className: "p-2 border-t border-border",
2837
2837
  children: [
2838
- /* @__PURE__ */ c(Li, { pending: p.pending, uploading: p.uploading, onRemove: p.remove }),
2839
- /* @__PURE__ */ w("div", { className: "relative", children: [
2838
+ /* @__PURE__ */ c(Fi, { pending: p.pending, uploading: p.uploading, onRemove: p.remove }),
2839
+ /* @__PURE__ */ _("div", { className: "relative", children: [
2840
2840
  j && /* @__PURE__ */ c(
2841
- Oi,
2841
+ Ui,
2842
2842
  {
2843
2843
  commands: N,
2844
- activeIndex: H,
2844
+ activeIndex: U,
2845
2845
  hasMedia: g,
2846
- onPick: k,
2846
+ onPick: P,
2847
2847
  onHover: C,
2848
- listboxId: u
2848
+ listboxId: f
2849
2849
  }
2850
2850
  ),
2851
2851
  /* @__PURE__ */ c(
2852
- _o,
2852
+ Po,
2853
2853
  {
2854
- open: L,
2854
+ open: M,
2855
2855
  onClose: () => R(!1),
2856
2856
  onPick: p.addMeme,
2857
2857
  onUnavailable: () => {
2858
- U(!0), R(!1);
2858
+ F(!0), R(!1);
2859
2859
  }
2860
2860
  }
2861
2861
  ),
2862
- /* @__PURE__ */ w("div", { className: "flex items-center gap-1.5", children: [
2863
- /* @__PURE__ */ w("div", { className: "relative flex-1", children: [
2862
+ /* @__PURE__ */ _("div", { className: "flex items-center gap-1.5", children: [
2863
+ /* @__PURE__ */ _("div", { className: "relative flex-1", children: [
2864
2864
  /* @__PURE__ */ c(
2865
2865
  "input",
2866
2866
  {
@@ -2868,20 +2868,20 @@ function Ui({ commands: e = _t }) {
2868
2868
  type: "text",
2869
2869
  value: t,
2870
2870
  onChange: (b) => {
2871
- n(b.target.value), f(!1);
2871
+ n(b.target.value), d(!1);
2872
2872
  },
2873
2873
  onKeyDown: ae,
2874
- maxLength: Kt,
2874
+ maxLength: Yt,
2875
2875
  placeholder: "Send a message",
2876
2876
  role: "combobox",
2877
2877
  "aria-expanded": j,
2878
- "aria-controls": j ? u : void 0,
2879
- "aria-activedescendant": xt ? `${u}-opt-${xt.name}` : void 0,
2878
+ "aria-controls": j ? f : void 0,
2879
+ "aria-activedescendant": X ? `${f}-opt-${X.name}` : void 0,
2880
2880
  "aria-autocomplete": "list",
2881
- className: `w-full bg-bg-card border border-border-light rounded px-3 py-1.5 text-sm focus:outline-none focus:border-text-muted ${X ? "pr-12" : ""}`
2881
+ className: `w-full bg-bg-card border border-border-light rounded px-3 py-1.5 text-sm focus:outline-none focus:border-text-muted ${te ? "pr-12" : ""}`
2882
2882
  }
2883
2883
  ),
2884
- /* @__PURE__ */ c("span", { className: `absolute right-2 top-1/2 -translate-y-1/2 text-[10px] ${W <= 50 ? W <= 0 ? "bg-danger-bg text-on-danger-bg px-1 rounded" : "bg-primary-bg text-on-primary-bg px-1 rounded" : "text-text-muted"}`, children: X && W })
2884
+ /* @__PURE__ */ c("span", { className: `absolute right-2 top-1/2 -translate-y-1/2 text-[10px] ${ie <= 50 ? ie <= 0 ? "bg-danger-bg text-on-danger-bg px-1 rounded" : "bg-primary-bg text-on-primary-bg px-1 rounded" : "text-text-muted"}`, children: te && ie })
2885
2885
  ] }),
2886
2886
  !D && /* @__PURE__ */ c(
2887
2887
  "button",
@@ -2889,11 +2889,11 @@ function Ui({ commands: e = _t }) {
2889
2889
  type: "button",
2890
2890
  onClick: () => R((b) => !b),
2891
2891
  "aria-label": "Add a meme",
2892
- "aria-expanded": L,
2892
+ "aria-expanded": M,
2893
2893
  title: "Add a meme",
2894
2894
  "data-testid": "meme-button",
2895
- className: `shrink-0 rounded border border-border-light px-2 py-1.5 text-sm hover:border-primary ${L ? "text-text border-primary" : "text-text-secondary"}`,
2896
- children: /* @__PURE__ */ c(Jn, { name: "image" })
2895
+ className: `shrink-0 rounded border border-border-light px-2 py-1.5 text-sm hover:border-primary ${M ? "text-text border-primary" : "text-text-secondary"}`,
2896
+ children: /* @__PURE__ */ c(lr, { name: "image" })
2897
2897
  }
2898
2898
  )
2899
2899
  ] })
@@ -2902,15 +2902,15 @@ function Ui({ commands: e = _t }) {
2902
2902
  }
2903
2903
  );
2904
2904
  }
2905
- function Hi() {
2905
+ function Gi() {
2906
2906
  const e = m((n) => n.roster), t = Object.values(e);
2907
- return t.length ? /* @__PURE__ */ c("div", { className: "flex flex-col gap-1", children: t.map((n) => /* @__PURE__ */ c(Fi, { u: n }, n.clientId)) }) : /* @__PURE__ */ c("div", { className: "text-xs text-text-muted", children: "No users online" });
2907
+ return t.length ? /* @__PURE__ */ c("div", { className: "flex flex-col gap-1", children: t.map((n) => /* @__PURE__ */ c(Wi, { u: n }, n.clientId)) }) : /* @__PURE__ */ c("div", { className: "text-xs text-text-muted", children: "No users online" });
2908
2908
  }
2909
- function Fi({ u: e }) {
2910
- const t = Vn(e.sprite, e.avatarUrl);
2911
- return /* @__PURE__ */ w("div", { className: "flex items-center gap-2 py-0.5", children: [
2909
+ function Wi({ u: e }) {
2910
+ const t = xt(e.sprite, e.avatarUrl);
2911
+ return /* @__PURE__ */ _("div", { className: "flex items-center gap-2 py-0.5", children: [
2912
2912
  /* @__PURE__ */ c(
2913
- Kn,
2913
+ tr,
2914
2914
  {
2915
2915
  sprite: e.sprite,
2916
2916
  url: e.avatarUrl,
@@ -2923,28 +2923,28 @@ function Fi({ u: e }) {
2923
2923
  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" })
2924
2924
  ] });
2925
2925
  }
2926
- function $i() {
2927
- const e = m((i) => Object.keys(i.roster).length), [t, n] = P(!1), r = G(null), a = G(null);
2928
- return A(() => {
2926
+ function Vi() {
2927
+ const e = m((i) => Object.keys(i.roster).length), [t, n] = k(!1), r = W(null), a = W(null);
2928
+ return E(() => {
2929
2929
  if (!t) return;
2930
2930
  function i(l) {
2931
2931
  r.current && !r.current.contains(l.target) && n(!1);
2932
2932
  }
2933
2933
  function s(l) {
2934
- ut(l) && (l.stopPropagation(), n(!1), a.current?.focus());
2934
+ mt(l) && (l.stopPropagation(), n(!1), a.current?.focus());
2935
2935
  }
2936
2936
  return document.addEventListener("mousedown", i), document.addEventListener("keydown", s, !0), () => {
2937
2937
  document.removeEventListener("mousedown", i), document.removeEventListener("keydown", s, !0);
2938
2938
  };
2939
- }, [t]), /* @__PURE__ */ w("div", { className: "relative", ref: r, children: [
2940
- /* @__PURE__ */ w(
2939
+ }, [t]), /* @__PURE__ */ _("div", { className: "relative", ref: r, children: [
2940
+ /* @__PURE__ */ _(
2941
2941
  "button",
2942
2942
  {
2943
2943
  ref: a,
2944
2944
  "aria-expanded": t,
2945
2945
  "aria-label": `Users (${e})`,
2946
2946
  onClick: () => {
2947
- d("chat", "User list toggled", { open: !t, userCount: e }), n(!t);
2947
+ u("chat", "User list toggled", { open: !t, userCount: e }), n(!t);
2948
2948
  },
2949
2949
  className: "p-1.5 rounded text-text-secondary hover:text-white hover:bg-bg-alt transition-colors flex items-center gap-1 cursor-pointer",
2950
2950
  title: "Users",
@@ -2954,57 +2954,122 @@ function $i() {
2954
2954
  ]
2955
2955
  }
2956
2956
  ),
2957
- t && /* @__PURE__ */ w("div", { className: "absolute top-full right-0 mt-1 bg-bg-card rounded-lg shadow-xl p-3 max-h-64 overflow-y-auto z-50 w-max min-w-[180px] max-w-[220px]", children: [
2958
- /* @__PURE__ */ w("div", { className: "text-[10px] uppercase tracking-wide text-text-muted mb-2", children: [
2957
+ t && /* @__PURE__ */ _("div", { className: "absolute top-full right-0 mt-1 bg-bg-card rounded-lg shadow-xl p-3 max-h-64 overflow-y-auto z-50 w-max min-w-[180px] max-w-[220px]", children: [
2958
+ /* @__PURE__ */ _("div", { className: "text-[10px] uppercase tracking-wide text-text-muted mb-2", children: [
2959
2959
  e,
2960
2960
  " online"
2961
2961
  ] }),
2962
- /* @__PURE__ */ c(Hi, {})
2962
+ /* @__PURE__ */ c(Gi, {})
2963
2963
  ] })
2964
2964
  ] });
2965
2965
  }
2966
- function Yt({ className: e = "fixed bottom-4 left-1/2 -translate-x-1/2" }) {
2966
+ function zt({ className: e = "fixed bottom-4 left-1/2 -translate-x-1/2" }) {
2967
2967
  const t = m((r) => r.toasts), n = m((r) => r.popToast);
2968
- return A(() => {
2968
+ return E(() => {
2969
2969
  const r = t.map((a) => setTimeout(() => n(a.id), 4e3));
2970
2970
  return () => {
2971
2971
  r.forEach(clearTimeout);
2972
2972
  };
2973
2973
  }, [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)) });
2974
2974
  }
2975
- const zt = (e) => typeof e == "string" && Qn.includes(e);
2976
- function Bi(e, t, n) {
2977
- return e || (zt(t) ? t : zt(n) ? n : "dark");
2975
+ const or = 9e3, Xt = 1500, qi = {
2976
+ 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]",
2977
+ cinema: "drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)]",
2978
+ minimal: "drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)] drop-shadow-[0_0_8px_rgba(0,0,0,0.7)]",
2979
+ contrast: "bg-black/70 px-2 py-0.5 rounded"
2980
+ }, Jt = { WebkitTextStroke: "0.5px black", paintOrder: "stroke fill" }, Qt = {
2981
+ textShadow: "none",
2982
+ filter: "drop-shadow(0 0 1px black) drop-shadow(0 0 1px black)"
2983
+ };
2984
+ function Ki({ message: e, age: t, ccStyle: n }) {
2985
+ const r = or - Xt;
2986
+ let a = 1;
2987
+ t > r && (a = Math.max(0, 1 - (t - r) / Xt));
2988
+ const i = qi[n], s = er(
2989
+ { clientId: e.clientId, author: e.author },
2990
+ { name: e.name, sprite: e.sprite }
2991
+ ), l = xt(s.sprite, s.pictureUrl), d = s.cosmetics, [h] = k(
2992
+ () => e.live && e.text ? nn(e.text, d) : null
2993
+ );
2994
+ return /* @__PURE__ */ _(
2995
+ "div",
2996
+ {
2997
+ className: `flex items-start gap-2 py-1 ${i}`,
2998
+ style: { opacity: a, transition: "opacity 0.15s ease-out", ...Nn(l) },
2999
+ children: [
3000
+ /* @__PURE__ */ c(nr, { sprite: s.sprite, url: s.pictureUrl, worn: d }),
3001
+ /* @__PURE__ */ _("div", { className: "min-w-0 flex-1", children: [
3002
+ d ? /* @__PURE__ */ c(ge, { html: rn(s.name, d), className: "text-sm mr-2", style: { color: l, ...Qt } }) : /* @__PURE__ */ c("span", { className: "font-medium text-sm mr-2", style: { color: l, ...Jt }, children: s.name }),
3003
+ h ? /* @__PURE__ */ c(ge, { html: h, className: "text-sm text-white break-words", style: Qt }) : /* @__PURE__ */ c("span", { className: "text-sm text-white break-words", style: Jt, children: e.text }),
3004
+ /* @__PURE__ */ c(rr, { images: e.images })
3005
+ ] })
3006
+ ]
3007
+ }
3008
+ );
3009
+ }
3010
+ function Yi({ shown: e, className: t }) {
3011
+ An();
3012
+ const n = m((d) => d.chat), r = m((d) => d.mediaPrefs.subtitleStyle), [a, i] = k(() => Date.now()), s = n.length > 0;
3013
+ E(() => {
3014
+ const d = setInterval(() => {
3015
+ s && i(Date.now());
3016
+ }, 200);
3017
+ return () => clearInterval(d);
3018
+ }, [s]);
3019
+ const l = ee(() => {
3020
+ const d = a - or;
3021
+ return n.filter((h) => !h.isSystem && h.ts > d).slice(-12);
3022
+ }, [n, a]);
3023
+ return !e || l.length === 0 ? null : /* @__PURE__ */ c(
3024
+ "div",
3025
+ {
3026
+ className: `wp-floating-chat pointer-events-none flex flex-col ${t}`,
3027
+ "data-testid": "floating-chat",
3028
+ children: l.map((d) => /* @__PURE__ */ c(
3029
+ Ki,
3030
+ {
3031
+ message: d,
3032
+ age: a - d.ts,
3033
+ ccStyle: r
3034
+ },
3035
+ d.id
3036
+ ))
3037
+ }
3038
+ );
3039
+ }
3040
+ const Zt = (e) => typeof e == "string" && cr.includes(e);
3041
+ function zi(e, t, n) {
3042
+ return e || (Zt(t) ? t : Zt(n) ? n : "dark");
2978
3043
  }
2979
- function Gi(e, t) {
3044
+ function Xi(e, t) {
2980
3045
  if (t(e.clientWidth), typeof ResizeObserver > "u") return () => {
2981
3046
  };
2982
3047
  const n = new ResizeObserver(() => t(e.clientWidth));
2983
3048
  return n.observe(e), () => n.disconnect();
2984
3049
  }
2985
- function Wi(e) {
3050
+ function Ji(e) {
2986
3051
  const t = e?.trim() ?? "";
2987
3052
  return t ? { source: "host", name: t } : { source: "auto" };
2988
3053
  }
2989
- function qi(e) {
3054
+ function Qi(e) {
2990
3055
  if (e.source !== "host") return;
2991
3056
  const { setSessionIdentity: t, sprite: n } = m.getState();
2992
3057
  t(e.name, n);
2993
3058
  }
2994
- function Vi({ className: e = "w-4 h-4" }) {
2995
- return /* @__PURE__ */ w("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
3059
+ function Zi({ className: e = "w-4 h-4" }) {
3060
+ return /* @__PURE__ */ _("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
2996
3061
  /* @__PURE__ */ c("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 4v16" }),
2997
3062
  /* @__PURE__ */ c("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15 12l-5 4v-8l5 4z" })
2998
3063
  ] });
2999
3064
  }
3000
- function Ki({ className: e = "w-4 h-4" }) {
3001
- return /* @__PURE__ */ w("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
3065
+ function es({ className: e = "w-4 h-4" }) {
3066
+ return /* @__PURE__ */ _("svg", { className: e, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: [
3002
3067
  /* @__PURE__ */ c("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M20 4v16" }),
3003
3068
  /* @__PURE__ */ c("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9 12l5 4v-8l-5 4z" })
3004
3069
  ] });
3005
3070
  }
3006
- const Yi = 1500;
3007
- function ds({
3071
+ const ts = 1500;
3072
+ function ys({
3008
3073
  roomKey: e,
3009
3074
  serverOrigin: t,
3010
3075
  roomOrigin: n,
@@ -3013,66 +3078,66 @@ function ds({
3013
3078
  chatSocketPath: i,
3014
3079
  userType: s,
3015
3080
  userId: l,
3016
- theme: f,
3081
+ theme: d,
3017
3082
  name: h,
3018
- onLeave: u,
3019
- onLayoutChange: L,
3083
+ onLeave: f,
3084
+ onLayoutChange: M,
3020
3085
  collapsible: R = !0,
3021
3086
  debug: D,
3022
- children: U
3087
+ children: F
3023
3088
  }) {
3024
- const [p, x] = P(null), { setFrame: S, ...y } = zi(L, R), g = Jt(() => h), T = te(() => (Zo({ userType: s, userId: l ?? null }), yt().theme), [s, l]), N = Zn(), j = N?.theme, H = te(
3025
- () => Bi(f, j, T),
3026
- [f, j, T]
3089
+ const [p, x] = k(null), { setFrame: w, ...y } = ns(M, R), g = m((H) => H.floatingChatEnabled), T = tn(() => h), N = ee(() => (ia({ userType: s, userId: l ?? null }), bt().theme), [s, l]), j = dr(), U = j?.theme, C = ee(
3090
+ () => zi(d, U, N),
3091
+ [d, U, N]
3027
3092
  );
3028
- A(() => {
3029
- }, [f, N !== null]);
3030
- const O = te(
3031
- () => ({ ...mt, serverOrigin: t, defaultRoomKey: e }),
3093
+ E(() => {
3094
+ }, [d, j !== null]);
3095
+ const P = ee(
3096
+ () => ({ ...ft, serverOrigin: t, defaultRoomKey: e }),
3032
3097
  [t, e]
3033
3098
  );
3034
- return A(() => {
3035
- D && Ro();
3036
- }, [D]), pi(), A(() => {
3037
- xo({ serverOrigin: t, defaultRoomKey: e }), ya(n ? { origin: n, path: r } : null), Ft(a && !n ? { origin: a, path: i } : null), m.getState().rehydrateFromPrefs(), Ha();
3038
- let k = !1;
3039
- const oe = na();
3099
+ return E(() => {
3100
+ D && Fo();
3101
+ }, [D]), wi(), E(() => {
3102
+ Ro({ serverOrigin: t, defaultRoomKey: e }), Ca(n ? { origin: n, path: r } : null), $t(a && !n ? { origin: a, path: i } : null), m.getState().rehydrateFromPrefs(), qa();
3103
+ let H = !1;
3104
+ const ae = ca();
3040
3105
  return (async () => {
3041
3106
  try {
3042
3107
  await Promise.race([
3043
3108
  Promise.all([
3044
- oe,
3045
- la().then((X) => {
3109
+ ae,
3110
+ ha().then((X) => {
3046
3111
  X && m.getState().rehydrateFromPrefs();
3047
3112
  }),
3048
3113
  // The character chosen in the settings popout (lib/avatar.ts).
3049
- Ea().then(qn)
3114
+ Ma().then(Zn)
3050
3115
  ]),
3051
- new Promise((X) => setTimeout(X, Yi))
3116
+ new Promise((X) => setTimeout(X, ts))
3052
3117
  ]);
3053
3118
  } catch (X) {
3054
- I("room-chrome", "pre-join wait threw, proceeding anyway", ve(X));
3119
+ I("room-chrome", "pre-join wait threw, proceeding anyway", we(X));
3055
3120
  }
3056
- if (k) return;
3057
- const ae = Wi(g());
3058
- m.getState().ensureAutoIdentity(), qi(ae);
3059
- const W = m.getState();
3060
- d("room-chrome", "Joining room", { roomKey: e, name: W.name, sprite: W.sprite }), za({ room_key: e, name: W.name || void 0, sprite: W.sprite || void 0 });
3121
+ if (H) return;
3122
+ const ie = Ji(T());
3123
+ m.getState().ensureAutoIdentity(), Qi(ie);
3124
+ const te = m.getState();
3125
+ u("room-chrome", "Joining room", { roomKey: e, name: te.name, sprite: te.sprite }), ni({ room_key: e, name: te.name || void 0, sprite: te.sprite || void 0 });
3061
3126
  })(), () => {
3062
- k = !0, Vt(), Ft(null);
3127
+ H = !0, Kt(), $t(null);
3063
3128
  };
3064
- }, [e, t, n, r, a, i, s, l]), /* @__PURE__ */ c(Co.Provider, { value: O, children: /* @__PURE__ */ c(_n.Provider, { value: !1, children: /* @__PURE__ */ c(Sn.Provider, { value: p, children: /* @__PURE__ */ w("div", { ref: S, className: "wp-room-chrome-frame", children: [
3065
- /* @__PURE__ */ c("div", { className: "wp-room-chrome-frame__content", children: U }),
3129
+ }, [e, t, n, r, a, i, s, l]), /* @__PURE__ */ c(Do.Provider, { value: P, children: /* @__PURE__ */ c(En.Provider, { value: !1, children: /* @__PURE__ */ c(kn.Provider, { value: p, children: /* @__PURE__ */ _("div", { ref: w, className: "wp-room-chrome-frame", children: [
3130
+ /* @__PURE__ */ c("div", { className: "wp-room-chrome-frame__content", children: F }),
3066
3131
  /* @__PURE__ */ c(
3067
3132
  "aside",
3068
3133
  {
3069
3134
  ref: x,
3070
3135
  className: "wp-room-chrome",
3071
- "data-theme": H,
3136
+ "data-theme": C,
3072
3137
  "data-collapsed": y.collapsed ? "1" : "0",
3073
3138
  style: { "--wp-room-chrome-width": `${y.state.width}px` },
3074
- onAnimationEnd: (k) => pr(k.nativeEvent),
3075
- children: y.collapsed ? /* @__PURE__ */ w(se, { children: [
3139
+ onAnimationEnd: (H) => xr(H.nativeEvent),
3140
+ children: y.collapsed ? /* @__PURE__ */ _(le, { children: [
3076
3141
  /* @__PURE__ */ c(
3077
3142
  "button",
3078
3143
  {
@@ -3081,19 +3146,20 @@ function ds({
3081
3146
  title: "Show chat",
3082
3147
  "aria-label": "Show chat",
3083
3148
  "aria-expanded": !1,
3084
- children: /* @__PURE__ */ c(Ki, {})
3149
+ children: /* @__PURE__ */ c(es, {})
3085
3150
  }
3086
3151
  ),
3087
- /* @__PURE__ */ c(Yt, { className: "absolute bottom-2 right-full mr-2 w-72" })
3088
- ] }) : /* @__PURE__ */ w(se, { children: [
3152
+ /* @__PURE__ */ c(zt, { className: "absolute bottom-2 right-full mr-2 w-72" }),
3153
+ /* @__PURE__ */ c(Yi, { shown: g, className: "wp-room-chrome__floating" })
3154
+ ] }) : /* @__PURE__ */ _(le, { children: [
3089
3155
  /* @__PURE__ */ c(
3090
3156
  "div",
3091
3157
  {
3092
3158
  role: "separator",
3093
3159
  "aria-orientation": "vertical",
3094
3160
  "aria-label": "Resize chat",
3095
- "aria-valuemin": He,
3096
- "aria-valuemax": bt,
3161
+ "aria-valuemin": $e,
3162
+ "aria-valuemax": vt,
3097
3163
  "aria-valuenow": y.state.width,
3098
3164
  tabIndex: 0,
3099
3165
  className: "wp-room-chrome__resize",
@@ -3105,14 +3171,14 @@ function ds({
3105
3171
  onKeyDown: y.onKeyDown
3106
3172
  }
3107
3173
  ),
3108
- /* @__PURE__ */ w("div", { className: "flex items-center gap-1 px-2 py-1.5 border-b border-border", children: [
3109
- /* @__PURE__ */ c($i, {}),
3174
+ /* @__PURE__ */ _("div", { className: "flex items-center gap-1 px-2 py-1.5 border-b border-border", children: [
3175
+ /* @__PURE__ */ c(Vi, {}),
3110
3176
  /* @__PURE__ */ c("div", { className: "flex-1" }),
3111
- u && /* @__PURE__ */ c(
3177
+ f && /* @__PURE__ */ c(
3112
3178
  "button",
3113
3179
  {
3114
3180
  onClick: () => {
3115
- Vt(), u();
3181
+ Kt(), f();
3116
3182
  },
3117
3183
  className: "wp-room-chrome__leave",
3118
3184
  title: "Leave room",
@@ -3128,51 +3194,51 @@ function ds({
3128
3194
  title: "Hide chat",
3129
3195
  "aria-label": "Hide chat",
3130
3196
  "aria-expanded": !0,
3131
- children: /* @__PURE__ */ c(Vi, {})
3197
+ children: /* @__PURE__ */ c(Zi, {})
3132
3198
  }
3133
3199
  )
3134
3200
  ] }),
3135
- /* @__PURE__ */ c(Ei, {}),
3136
- /* @__PURE__ */ c(Ui, { commands: [] }),
3137
- /* @__PURE__ */ c(Yt, { className: "absolute bottom-14 left-2 right-2" })
3201
+ /* @__PURE__ */ c(Ri, {}),
3202
+ /* @__PURE__ */ c(Bi, { commands: [] }),
3203
+ /* @__PURE__ */ c(zt, { className: "absolute bottom-14 left-2 right-2" })
3138
3204
  ] })
3139
3205
  }
3140
3206
  )
3141
3207
  ] }) }) }) });
3142
3208
  }
3143
- function zi(e, t) {
3144
- const n = m((g) => g.chromeChatCollapsed) && t, r = m((g) => g.chromeChatWidth), a = m((g) => g.toggleChromeChatCollapsed), i = m((g) => g.setChromeChatWidth), [s, l] = P(null), [f, h] = P(void 0), [u, L] = P(null);
3145
- A(() => {
3209
+ function ns(e, t) {
3210
+ 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);
3211
+ E(() => {
3146
3212
  if (s)
3147
- return Gi(s, h);
3213
+ return Xi(s, h);
3148
3214
  }, [s]);
3149
- const R = Y(u?.current ?? r, f), D = te(() => fa(n, R), [n, R]), U = Jt((g) => e?.(g));
3150
- return A(() => {
3151
- U(D);
3215
+ const R = Y(f?.current ?? r, d), D = ee(() => _a(n, R), [n, R]), F = tn((g) => e?.(g));
3216
+ return E(() => {
3217
+ F(D);
3152
3218
  }, [D]), {
3153
3219
  setFrame: l,
3154
3220
  collapsed: n,
3155
3221
  state: D,
3156
- dragging: u !== null,
3222
+ dragging: f !== null,
3157
3223
  toggleCollapsed: a,
3158
3224
  onPointerDown: (g) => {
3159
- g.button === 0 && (g.preventDefault(), g.currentTarget.setPointerCapture(g.pointerId), L({ pointerId: g.pointerId, startX: g.clientX, startWidth: R, current: R }));
3225
+ g.button === 0 && (g.preventDefault(), g.currentTarget.setPointerCapture(g.pointerId), M({ pointerId: g.pointerId, startX: g.clientX, startWidth: R, current: R }));
3160
3226
  },
3161
3227
  onPointerMove: (g) => {
3162
- !u || u.pointerId !== g.pointerId || L({ ...u, current: Ht(u.startWidth, u.startX, g.clientX, f) });
3228
+ !f || f.pointerId !== g.pointerId || M({ ...f, current: Ht(f.startWidth, f.startX, g.clientX, d) });
3163
3229
  },
3164
3230
  onPointerEnd: (g) => {
3165
- if (!u || u.pointerId !== g.pointerId) return;
3166
- const T = Ht(u.startWidth, u.startX, g.clientX, f);
3167
- L(null), T !== r && i(T);
3231
+ if (!f || f.pointerId !== g.pointerId) return;
3232
+ const T = Ht(f.startWidth, f.startX, g.clientX, d);
3233
+ M(null), T !== r && i(T);
3168
3234
  },
3169
3235
  onKeyDown: (g) => {
3170
- const T = ma(R, g.key, f);
3236
+ const T = va(R, g.key, d);
3171
3237
  T !== null && (g.preventDefault(), T !== r && i(T));
3172
3238
  }
3173
3239
  };
3174
3240
  }
3175
3241
  export {
3176
- ds as RoomChrome
3242
+ ys as RoomChrome
3177
3243
  };
3178
3244
  //# sourceMappingURL=room-chrome.js.map