@caisual/kit 0.15.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/overlay.js CHANGED
@@ -118,6 +118,7 @@ var CAMPI = /* @__PURE__ */ new Set([
118
118
  "players",
119
119
  "lobby",
120
120
  "persistent",
121
+ "replays",
121
122
  "spectators",
122
123
  "boards",
123
124
  "roles",
@@ -321,10 +322,8 @@ function validaManifest(valore) {
321
322
  else network.push(value);
322
323
  }
323
324
  }
324
- let isolated = false;
325
325
  if (dati.isolated !== void 0) {
326
326
  if (typeof dati.isolated !== "boolean") errori.push("isolated: must be a boolean.");
327
- else isolated = dati.isolated;
328
327
  }
329
328
  const requires = {
330
329
  webgl2: false,
@@ -358,7 +357,6 @@ function validaManifest(valore) {
358
357
  errori.push("requires.performance: must be light, medium, or heavy.");
359
358
  } else requires.performance = value.performance;
360
359
  }
361
- if (requires.threads && !isolated) errori.push("requires.threads: needs isolated: true.");
362
360
  }
363
361
  }
364
362
  let players = { min: 1, max: 1 };
@@ -387,6 +385,8 @@ function validaManifest(valore) {
387
385
  if (typeof dati.persistent !== "boolean") errori.push("persistent: must be a boolean.");
388
386
  else persistent = dati.persistent;
389
387
  }
388
+ const replays = dati.replays === true;
389
+ if (dati.replays !== void 0 && typeof dati.replays !== "boolean") errori.push("replays: must be a boolean.");
390
390
  let spectators = { delayMs: RITARDO_SPETTATORI_MS };
391
391
  if (dati.spectators === false || dati.spectators === null) spectators = null;
392
392
  else if (dati.spectators !== void 0 && dati.spectators !== true) {
@@ -661,11 +661,11 @@ function validaManifest(valore) {
661
661
  input,
662
662
  visibility,
663
663
  network,
664
- isolated,
665
664
  requires,
666
665
  players,
667
666
  lobby,
668
667
  persistent,
668
+ replays,
669
669
  spectators,
670
670
  boards,
671
671
  roles,
@@ -675,6 +675,13 @@ function validaManifest(valore) {
675
675
  } };
676
676
  }
677
677
 
678
+ // ../contracts/src/replay.ts
679
+ var REPLAY_MAX_BYTES = 10 * 1024 * 1024;
680
+ var REPLAY_MAX_DURATION_MS = 30 * 60 * 1e3;
681
+ var REPLAY_CHUNK_BYTES = 512 * 1024;
682
+ var REPLAY_RETENTION_MS = 30 * 24 * 60 * 60 * 1e3;
683
+ var REPLAY_ID = /^[A-Za-z0-9_-]{22}$/;
684
+
678
685
  // ../contracts/src/overlay.ts
679
686
  var OVERLAY_PANELS = ["home", "room", "invite", "friends", "voice", "boards"];
680
687
  function overlayConfiguration(manifest, coverUrl = null, invite = null, iconUrl = null) {
@@ -703,6 +710,13 @@ function validOverlayRequest(value) {
703
710
  const keys = (...allowed) => Object.keys(args).every((key) => allowed.includes(key));
704
711
  const text = (key) => typeof args[key] === "string" && args[key].length >= 1 && args[key].length <= 64;
705
712
  switch (message.op) {
713
+ case "replay.play":
714
+ case "replay.pause":
715
+ return keys() && typeof message.sessionId === "string";
716
+ case "replay.seek":
717
+ return keys("positionMs") && typeof message.sessionId === "string" && typeof args.positionMs === "number" && Number.isFinite(args.positionMs) && args.positionMs >= 0 && args.positionMs <= REPLAY_MAX_DURATION_MS;
718
+ case "replay.speed":
719
+ return keys("speed") && typeof message.sessionId === "string" && [0.5, 1, 2, 4].includes(Number(args.speed)) && typeof args.speed === "number";
706
720
  case "local.start":
707
721
  return keys("mode") && text("mode");
708
722
  case "room.create":
@@ -760,7 +774,12 @@ function validOverlaySessionState(value) {
760
774
  if (data.waiting !== null && (!exact(waiting, ["players", "min", "max"]) || !Object.values(waiting).every((v) => Number.isInteger(v) && Number(v) >= 0 && Number(v) <= 24))) return false;
761
775
  if (data.resume !== null && (!exact(resume, ["version", "code", "mode", "updatedAt"]) || resume.version !== 1 || !text(resume.code) || !nullable(resume.mode) || !finite(resume.updatedAt))) return false;
762
776
  if (data.room === null) return true;
763
- if (!exact(room, ["code", "mode", "status", "host", "you", "players", "countdownAt", "connection", "closedCode", "limits", "lobby", "persistent", "delayMs", "requestRole", ..."result" in (room ?? {}) ? ["result"] : [], ..."rematch" in (room ?? {}) ? ["rematch"] : []]) || !room) return false;
777
+ if (!exact(room, ["code", "mode", "status", "host", "you", "players", "countdownAt", "connection", "closedCode", "limits", "lobby", "persistent", "delayMs", "requestRole", ..."replay" in (room ?? {}) ? ["replay"] : [], ..."replayId" in (room ?? {}) ? ["replayId"] : [], ..."result" in (room ?? {}) ? ["result"] : [], ..."rematch" in (room ?? {}) ? ["rematch"] : []]) || !room) return false;
778
+ if (room.replayId !== void 0 && (typeof room.replayId !== "string" || !REPLAY_ID.test(room.replayId))) return false;
779
+ if (room.replay !== void 0) {
780
+ const playback = record(room.replay);
781
+ if (data.kind !== "watch" || !exact(playback, ["positionMs", "durationMs", "paused", "speed", "truncated"]) || !playback || !finite(playback.positionMs) || !finite(playback.durationMs) || Number(playback.positionMs) < 0 || Number(playback.positionMs) > Number(playback.durationMs) || Number(playback.durationMs) > REPLAY_MAX_DURATION_MS || ![0.5, 1, 2, 4].includes(Number(playback.speed)) || typeof playback.speed !== "number" || typeof playback.paused !== "boolean" || typeof playback.truncated !== "boolean") return false;
782
+ }
764
783
  const limits = record(room.limits), rematch = record(room.rematch);
765
784
  if (room.rematch !== void 0 && room.rematch !== null && (!exact(rematch, ["keepSetup", "autoStart"]) || typeof rematch.keepSetup !== "boolean" || typeof rematch.autoStart !== "boolean")) return false;
766
785
  return text(room.code) && nullable(room.mode) && nullable(room.host) && nullable(room.you) && ["lobby", "countdown", "playing", "finished", "ended"].includes(String(room.status)) && ["connecting", "connected", "reconnecting", "disconnected", "ended", "closed", "replaced"].includes(String(room.connection)) && ["countdownAt", "closedCode", "delayMs"].every((key) => room[key] === null || finite(room[key])) && ["lobby", "persistent", "requestRole"].every((key) => typeof room[key] === "boolean") && exact(limits, ["min", "max"]) && Object.values(limits).every((v) => Number.isInteger(v) && Number(v) >= 1 && Number(v) <= 24) && Array.isArray(room.players) && room.players.length <= 24 && room.players.every((value2) => {
@@ -780,6 +799,9 @@ function validOverlayVoice(value) {
780
799
  });
781
800
  }
782
801
 
802
+ // ../contracts/src/room-limits.ts
803
+ var MASSIMO_BYTE_FRAME_STANZA = 64 * 1024;
804
+
783
805
  // ../contracts/src/match-result.ts
784
806
  function readMatchResult(value, playerIds) {
785
807
  const object = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : null;
@@ -945,6 +967,7 @@ function creaPonteOspite(input) {
945
967
  currentPort.start();
946
968
  input.frame.contentWindow?.postMessage({
947
969
  type: "caisual:hello",
970
+ replay: input.replay ?? null,
948
971
  n: input.n,
949
972
  ticket: input.ticket,
950
973
  live: input.origineLive,
@@ -960,6 +983,9 @@ function creaPonteOspite(input) {
960
983
  input.frame.addEventListener?.("load", loaded);
961
984
  poll();
962
985
  return {
986
+ get replay() {
987
+ return input.replay ?? null;
988
+ },
963
989
  get watch() {
964
990
  return input.watch === true;
965
991
  },
@@ -1016,7 +1042,7 @@ function creaPonteOspite(input) {
1016
1042
  requestId: id,
1017
1043
  op,
1018
1044
  args,
1019
- ...["room.ready", "room.role", "room.requestRole", "room.team", "room.start", "room.restart", "session.leave", "session.disconnect", "voice.join", "voice.mute", "voice.leave", "voice.setVolume"].includes(op) ? { sessionId: state?.id ?? null } : {}
1045
+ ...["replay.play", "replay.pause", "replay.seek", "replay.speed", "room.ready", "room.role", "room.requestRole", "room.team", "room.start", "room.restart", "session.leave", "session.disconnect", "voice.join", "voice.mute", "voice.leave", "voice.setVolume"].includes(op) ? { sessionId: state?.id ?? null } : {}
1020
1046
  };
1021
1047
  if (!validOverlayRequest(request)) return Promise.reject(creaErrore("invalid_request", "The overlay request is invalid."));
1022
1048
  return new Promise((resolve, reject) => {
@@ -1174,137 +1200,8 @@ function createBoardController(input) {
1174
1200
  };
1175
1201
  }
1176
1202
 
1177
- // src/overlay/i18n.ts
1178
- var languages = ["en", "it", "es", "fr", "de", "pt"];
1179
- var words = {
1180
- gameUpdated: ["This game was updated", "Questo gioco \xE8 stato aggiornato", "Este juego se ha actualizado", "Ce jeu a \xE9t\xE9 mis \xE0 jour", "Dieses Spiel wurde aktualisiert", "Este jogo foi atualizado"],
1181
- reloadGame: ["Reload game", "Ricarica il gioco", "Recargar el juego", "Recharger le jeu", "Spiel neu laden", "Recarregar o jogo"],
1182
- gameLanguages: ["Game languages", "Lingue del gioco", "Idiomas del juego", "Langues du jeu", "Spielsprachen", "Idiomas do jogo"],
1183
- loading: ["Loading game...", "Caricamento...", "Cargando...", "Chargement...", "Spiel wird geladen...", "Carregando..."],
1184
- loadingSlow: ["This game is taking longer than expected. You can wait a little longer or try again.", "Il gioco ci sta mettendo pi\xF9 del previsto. Puoi aspettare ancora un po\u2019 o riprovare.", "El juego est\xE1 tardando m\xE1s de lo esperado. Puedes esperar un poco m\xE1s o volver a intentarlo.", "Le jeu met plus de temps que pr\xE9vu. Vous pouvez patienter encore un peu ou r\xE9essayer.", "Das Spiel braucht l\xE4nger als erwartet. Du kannst noch etwas warten oder es erneut versuchen.", "O jogo est\xE1 demorando mais do que o esperado. Voc\xEA pode esperar mais um pouco ou tentar novamente."],
1185
- home: ["Play", "Gioca", "Jugar", "Jouer", "Spielen", "Jogar"],
1186
- homeMenu: ["Menu", "Menu", "Men\xFA", "Menu", "Men\xFC", "Menu"],
1187
- mode: ["Mode", "Modalit\xE0", "Modo", "Mode", "Modus", "Modo"],
1188
- play: ["Play", "Gioca", "Jugar", "Jouer", "Spielen", "Jogar"],
1189
- friendsPlay: ["Play with friends", "Gioca con amici", "Jugar con amigos", "Jouer entre amis", "Mit Freunden spielen", "Jogar com amigos"],
1190
- find: ["Find players", "Trova giocatori", "Buscar jugadores", "Trouver des joueurs", "Spieler finden", "Buscar jogadores"],
1191
- join: ["Join with code", "Entra con codice", "Entrar con c\xF3digo", "Rejoindre avec un code", "Mit Code beitreten", "Entrar com c\xF3digo"],
1192
- joinInvite: ["Join this room", "Entra in questa stanza", "Entrar en est\xE1 sala", "Rejoindre cette salle", "Diesem Raum beitreten", "Entrar nest\xE1 sala"],
1193
- watch: ["Watch a room", "Guarda una stanza", "Observar una sala", "Regarder une salle", "Raum ansehen", "Assistir a uma sala"],
1194
- resume: ["Resume", "Riprendi", "Continuar", "Reprendre", "Fortsetzen", "Continuar"],
1195
- room: ["Room", "Stanza", "Sala", "Salle", "Raum", "Sala"],
1196
- code: ["Room code", "Codice stanza", "C\xF3digo de sala", "Code de salle", "Raumcode", "C\xF3digo da sala"],
1197
- copy: ["Copy invite", "Copia invito", "Copiar invitaci\xF3n", "Copier le lien", "Einladung kopieren", "Copiar convite"],
1198
- copied: ["Invite copied", "Invito copiato", "Invitacion copiada", "Lien copi\xE9", "Einladung kopiert", "Convite copiado"],
1199
- copyFailed: ["Copy this link:", "Copia questo link:", "Copia este enlace:", "Copiez ce lien :", "Diesen Link kopieren:", "Copie este link:"],
1200
- joining: ["Joining room...", "Ingresso nella stanza...", "Entrando en la sala...", "Connexion \xE0 la salle...", "Raum wird betreten...", "Entrando na sala..."],
1201
- matching: ["Finding your people...", "Ricerca giocatori...", "Buscando jugadores...", "Recherche de joueurs...", "Spieler werden gesucht...", "Buscando jogadores..."],
1202
- queue: ["{n} / {max} players", "{n} / {max} giocatori", "{n} / {max} jugadores", "{n} / {max} joueurs", "{n} / {max} Spieler", "{n} / {max} jogadores"],
1203
- cancel: ["Cancel", "Annulla", "Cancelar", "Annuler", "Abbrechen", "Cancelar"],
1204
- close: ["Close", "Chiudi", "Cerrar", "Fermer", "Schlie\xDFen", "Fechar"],
1205
- back: ["Back", "Indietro", "Volver", "Retour", "Zur\xFCck", "Voltar"],
1206
- ready: ["Ready", "Pronto", "Listo", "Pr\xEAt", "Bereit", "Pronto"],
1207
- unready: ["Not ready", "Non pronto", "No listo", "Pas pr\xEAt", "Nicht bereit", "N\xE3o pronto"],
1208
- start: ["Start", "Inizia", "Empezar", "Commencer", "Starten", "Come\xE7ar"],
1209
- role: ["Role", "Ruolo", "Rol", "R\xF4le", "Rolle", "Fun\xE7\xE3o"],
1210
- team: ["Team", "Squadra", "Equipo", "\xC9quipe", "Team", "Equipe"],
1211
- host: ["Host", "Host", "Anfitrion", "H\xF4te", "Host", "Anfitri\xE3o"],
1212
- you: ["You", "Tu", "T\xFA", "Vous", "Du", "Voc\xEA"],
1213
- away: ["Away", "Assente", "Ausente", "Absent", "Abwesend", "Ausente"],
1214
- needPlayers: ["Waiting for more players", "In attesa di giocatori", "Esperando m\xE1s jugadores", "En attente de joueurs", "Weitere Spieler fehlen", "Esperando mais jogadores"],
1215
- needReady: ["Everyone needs to be ready", "Tutti devono essere pronti", "Todos deben estar listos", "Tout le monde doit \xEAtre pr\xEAt", "Alle m\xFCssen bereit sein", "Todos precisam estar prontos"],
1216
- needRoles: ["Fill the required roles", "Completa i ruoli richiesti", "Completa los roles", "Compl\xE9tez les r\xF4les", "Ben\xF6tigte Rollen besetzen", "Complete as fun\xE7\xF5es"],
1217
- needTeams: ["Choose the required teams", "Scegli le squadre richieste", "Elige los equipos", "Choisissez les \xE9quipes", "Teams auswahlen", "Escolha as equipes"],
1218
- waitHost: ["Waiting for the host", "In attesa dell'host", "Esperando al anfitrion", "En attente de l\u2019h\xF4te", "Warten auf den Host", "Esperando o anfitri\xE3o"],
1219
- starting: ["Starting in", "Si inizia tra", "Empieza en", "D\xE9but dans", "Start in", "Come\xE7a em"],
1220
- playing: ["Playing", "In partita", "Jugando", "En jeu", "Im Spiel", "Jogando"],
1221
- ended: ["Game finished", "Partita conclusa", "Partida terminada", "Partie termin\xE9e", "Spiel beendet", "Partida encerrada"],
1222
- rematchReady: ["{n}/{max} ready", "{n}/{max} pronti", "{n}/{max} listos", "{n}/{max} pr\xEAts", "{n}/{max} bereit", "{n}/{max} prontos"],
1223
- rematchStart: ["Start rematch", "Avvia rivincita", "Iniciar revancha", "Lancer la revanche", "Revanche starten", "Iniciar revanche"],
1224
- won: ["You won", "Hai vinto", "Has ganado", "Vous avez gagn\xE9", "Du hast gewonnen", "Voc\xEA venceu"],
1225
- lost: ["You lost", "Hai perso", "Has perdido", "Vous avez perdu", "Du hast verloren", "Voc\xEA perdeu"],
1226
- draw: ["Draw", "Pareggio", "Empate", "\xC9galit\xE9", "Unentschieden", "Empate"],
1227
- standings: ["Standings", "Piazzamenti", "Posiciones", "R\xE9sultats", "Platzierungen", "Coloca\xE7\xF5es"],
1228
- points: ["points", "punti", "puntos", "points", "Punkte", "pontos"],
1229
- time: ["time", "tempo", "tiempo", "temps", "Zeit", "tempo"],
1230
- distance: ["distance", "distanza", "distancia", "distance", "Distanz", "dist\xE2ncia"],
1231
- again: ["Play again", "Gioca ancora", "Jugar de nuevo", "Rejouer", "Erneut spielen", "Jogar novamente"],
1232
- newRoom: ["New room. Share the new invite.", "Nuova stanza. Condividi il nuovo invito.", "Nueva sala. Comparte la invitaci\xF3n.", "Nouvelle salle. Partagez le lien.", "Neuer Raum. Neue Einladung teilen.", "Nova sala. Compartilhe o convite."],
1233
- watching: ["Watching", "In osservazione", "Observando", "Spectateur", "Zuschauen", "Assistindo"],
1234
- delay: ["{n}s delay", "Ritardo {n}s", "Retraso de {n}s", "Retard de {n}s", "{n}s Verz\xF6gerung", "Atraso de {n}s"],
1235
- exit: ["Exit", "Esci", "Salir", "Quitter", "Verlassen", "Sair"],
1236
- leaveNow: ["Leave for now", "Esci per ora", "Salir por ahora", "Quitter pour le moment", "Vor\xFCbergehend verlassen", "Sair por enquanto"],
1237
- leaveRoom: ["Leave room", "Lascia la stanza", "Abandonar sala", "Abandonner la salle", "Raum verlassen", "Deixar a sala"],
1238
- leaveHint: ["Your room stays available for Resume.", "La stanza resta disponibile con Riprendi.", "Podr\xE1s volver a est\xE1 sala.", "Vous pourrez reprendre cette salle.", "Du kannst den Raum fortsetzen.", "Voc\xEA pode voltar a est\xE1 sala."],
1239
- temporaryHint: ["The game continues. Rejoining may only be possible briefly.", "La partita continua. Il rientro pu\xF2 essere disponibile solo per poco.", "La partida continua. Volver puede ser posible solo por poco tiempo.", "La partie continue. Le retour peut \xEAtre limit\xE9.", "Das Spiel l\xE4uft weiter. R\xFCckkehr nur kurz m\xF6glich.", "A partida continua. O retorno pode ser limitado."],
1240
- abandonHint: ["Leave room gives up your place.", "Lascia la stanza libera il tuo posto.", "Abandonar libera tu plaza.", "Abandonner lib\xE8re votre place.", "Raum verlassen gibt deinen Platz frei.", "Deixar a sala libera sua vaga."],
1241
- reconnecting: ["Reconnecting...", "Riconnessione...", "Reconectando...", "Reconnexion...", "Verbindung wird erneuert...", "Reconectando..."],
1242
- replaced: ["Opened in another tab", "Aperta in un\u2019altra scheda", "Abierta en otra pest\xE1na", "Ouverte dans un autre onglet", "In anderem Tab ge\xF6ffnet", "Aberta em outra aba"],
1243
- error: ["Something went wrong. Try again.", "Qualcosa non va. Riprova.", "Algo sali\xF3 mal. Reintenta.", "Une erreur est survenue. R\xE9essayez.", "Etwas ist schiefgelaufen. Erneut versuchen.", "Algo deu errado. Tente novamente."],
1244
- noRoom: ["This room is no longer available.", "Questa stanza non \xE8 pi\xF9 disponibile.", "Esta sala ya no est\xE1 disponible.", "Cette salle n'est plus disponible.", "Dieser Raum ist nicht mehr verf\xFCgbar.", "Esta sala n\xE3o est\xE1 mais disponivel."],
1245
- full: ["This room is full.", "La stanza \xE8 piena.", "La sala est\xE1 llena.", "Cette salle est pleine.", "Dieser Raum ist voll.", "Esta sala est\xE1 cheia."],
1246
- noMatch: ["No match this time. Try again.", "Nessun gruppo trovato. Riprova.", "No hay grupo. Reintenta.", "Aucun groupe trouv\xE9. R\xE9essayez.", "Keine Gruppe gefunden. Erneut versuchen.", "Nenhum grupo encontrado. Tente novamente."],
1247
- invalidCode: ["Enter a six-character room code.", "Inserisci un codice di sei caratteri.", "Escribe un c\xF3digo de seis caracteres.", "Entrez un code de six caracteres.", "Sechsstelligen Raumcode eingeben.", "Digite um c\xF3digo de seis caracteres."],
1248
- refused: ["The room did not accept that change.", "La stanza ha rifiutato la modifica.", "La sala rechaz\xF3 el cambio.", "La salle a refus\xE9 ce changement.", "Der Raum hat die \xC4nderung abgelehnt.", "A sala recusou a altera\xE7\xE3o."],
1249
- unavailable: ["Unavailable right now", "Non disponibile ora", "No disponible ahora", "Indisponible pour le moment", "Derzeit nicht verf\xFCgbar", "Indisponivel agora"],
1250
- offline: ["Connection unavailable. Try again.", "Connessione non disponibile. Riprova.", "Sin conexi\xF3n. Reintenta.", "Connexion indisponible. R\xE9essayez.", "Keine Verbindung. Erneut versuchen.", "Sem conex\xE3o. Tente novamente."],
1251
- saveFailed: ["Keep the room code. Resume could not be saved.", "Conserva il codice. Riprendi non \xE8 stato salvato.", "Guarda el c\xF3digo. No se pudo guardar el regreso.", "Gardez le code. La reprise ne peut pas \xEAtre enregistr\xE9e.", "Raumcode aufbewahren. Fortsetzen nicht gespeichert.", "Guarde o c\xF3digo. O retorno n\xE3o foi salvo."],
1252
- boards: ["Leaderboard", "Classifica", "Clasificaci\xF3n", "Classement", "Bestenliste", "Classifica\xE7\xE3o"],
1253
- board: ["Board", "Classifica", "Tabla", "Classement", "Bestenliste", "Tabela"],
1254
- daily: ["Daily", "Giornaliera", "Diaria", "Du jour", "T\xE4glich", "Di\xE1ria"],
1255
- allTime: ["All time", "Di sempre", "Hist\xF3rica", "Tous les temps", "Gesamt", "Geral"],
1256
- accounts: ["Accounts", "Account", "Cuentas", "Comptes", "Konten", "Contas"],
1257
- guests: ["Guests", "Ospiti", "Invitados", "Invit\xE9s", "G\xE4ste", "Visitantes"],
1258
- category: ["Category", "Categoria", "Categoria", "Cat\xE9gorie", "Kategorie", "Categoria"],
1259
- period: ["Period", "Periodo", "Per\xEDodo", "P\xE9riode", "Zeitraum", "Per\xEDodo"],
1260
- rank: ["Rank", "Posizione", "Puesto", "Rang", "Platz", "Posicao"],
1261
- score: ["Score", "Punteggio", "Puntos", "Score", "Punkte", "Pontos"],
1262
- verified: ["Verified", "Verificato", "Verificado", "V\xE9rifi\xE9", "Verifiziert", "Verificado"],
1263
- own: ["Your best", "Il tuo record", "Tu record", "Votre record", "Dein Rekord", "Seu recorde"],
1264
- empty: ["No scores yet", "Nessun punteggio", "A\xFAn no hay puntos", "Aucun score", "Noch keine Punkte", "Ainda sem pontos"],
1265
- saving: ["Saving score...", "Salvataggio punteggio...", "Guardando puntos...", "Enregistrement du score...", "Punkte werden gespeichert...", "Salvando pontos..."],
1266
- saved: ["Your best is on the board", "Il tuo record \xE8 in classifica", "Tu record est\xE1 en la tabla", "Votre record est au classement", "Dein Rekord ist eingetragen", "Seu recorde est\xE1 na tabela"],
1267
- bestAlready: ["Your best is already on the board", "Il tuo record era gi\xE0 in classifica", "Tu record ya estaba en la tabla", "Votre record est d\xE9j\xE0 au classement", "Dein Rekord ist bereits eingetragen", "Seu recorde j\xE1 est\xE1 na tabela"],
1268
- refresh: ["Refresh", "Aggiorna", "Actualizar", "Actualiser", "Aktualisieren", "Atualizar"],
1269
- refreshHint: ["Score not visible yet. Refresh to check.", "Punteggio non ancora visibile. Aggiorna per controllare.", "Puntos a\xFAn no visibles. Actualiza.", "Score pas encore visible. Actualisez.", "Punkte noch nicht sichtbar. Aktualisieren.", "Pontos ainda n\xE3o visiveis. Atualize."],
1270
- friends: ["Friends & party", "Amici e gruppo", "Amigos y grupo", "Amis et groupe", "Freunde & Gruppe", "Amigos e grupo"],
1271
- localCrew: ["Friends and party are unavailable in local preview.", "Amici e gruppo non disponibili in anteprima locale.", "Amigos y grupo no disponibles en la vista local.", "Amis et groupe indisponibles en aper\xE7u local.", "Freunde und Gruppe in lokaler Vorschau nicht verf\xFCgbar.", "Amigos e grupo indispon\xEDveis na pr\xE9via local."],
1272
- loginCrew: ["Sign in on Caisual to use friends and party.", "Accedi a Caisual per amici e gruppo.", "Inicia sesion para amigos y grupo.", "Connectez-vous pour utiliser amis et groupe.", "F\xFCr Freunde und Gruppe bei Caisual anmelden.", "Entre no Caisual para amigos e grupo."],
1273
- online: ["Online", "Online", "En linea", "En ligne", "Online", "Online"],
1274
- noFriends: ["No friends online", "Nessun amico online", "Sin amigos en linea", "Aucun ami en ligne", "Keine Freunde online", "Nenhum amigo online"],
1275
- createParty: ["Create party", "Crea gruppo", "Crear grupo", "Cr\xE9er un groupe", "Gruppe erstellen", "Criar grupo"],
1276
- inviteParty: ["Invite to party", "Invita nel gruppo", "Invitar al grupo", "Inviter au groupe", "In Gruppe einladen", "Convidar para o grupo"],
1277
- leaveParty: ["Leave party", "Lascia gruppo", "Salir del grupo", "Quitter le groupe", "Gruppe verlassen", "Sair do grupo"],
1278
- accept: ["Accept", "Accetta", "Aceptar", "Accepter", "Annehmen", "Aceitar"],
1279
- decline: ["Decline", "Rifiuta", "Rechazar", "Refuser", "Ablehnen", "Recusar"],
1280
- follow: ["Join them", "Raggiungi", "Unirse", "Rejoindre", "Beitreten", "Juntar-se"],
1281
- voice: ["Voice", "Voce", "Voz", "Voix", "Sprache", "Voz"],
1282
- voiceJoin: ["Join voice", "Entra in voce", "Unirse a voz", "Activer la voix", "Sprachchat beitreten", "Entrar na voz"],
1283
- voiceLeave: ["Leave voice", "Esci dalla voce", "Salir de voz", "Quitter la voix", "Sprachchat verlassen", "Sair da voz"],
1284
- voiceMute: ["Mute", "Disattiva microfono", "Silenciar", "Couper le micro", "Stummschalten", "Silenciar"],
1285
- voiceUnmute: ["Unmute", "Attiva microfono", "Activar micr\xF3fono", "Activer le micro", "Mikrofon aktivieren", "Ativar microfone"],
1286
- voiceOff: ["Voice off", "Voce disattivata", "Voz desactivada", "Voix d\xE9sactiv\xE9e", "Sprachchat aus", "Voz desativada"],
1287
- voiceJoining: ["Joining voice...", "Connessione voce...", "Conectando voz...", "Connexion vocale...", "Sprachchat verbindet...", "Conectando voz..."],
1288
- voiceOn: ["Voice connected", "Voce connessa", "Voz conectada", "Voix connect\xE9e", "Sprachchat verbunden", "Voz conectada"],
1289
- voiceMuted: ["Muted", "Microfono disattivato", "Silenciado", "Micro coup\xE9", "Stumm", "Silenciado"],
1290
- voiceMic: ["Mic on", "Microfono attivo", "Micr\xF3fono activo", "Micro actif", "Mikrofon an", "Microfone ativo"],
1291
- voiceListening: ["Listening only", "Solo ascolto", "Solo escucha", "\xC9coute seule", "Nur zuh\xF6ren", "Somente ouvindo"],
1292
- voiceSpeaking: ["Speaking", "Sta parlando", "Hablando", "Parle", "Spricht", "Falando"],
1293
- voicePeers: ["Voice participants", "Partecipanti in voce", "Participantes de voz", "Participants vocaux", "Sprachteilnehmer", "Participantes de voz"],
1294
- voiceEmpty: ["No one else in voice yet.", "Nessun altro in voce per ora.", "A\xFAn no hay nadie m\xE1s en voz.", "Personne d\u2019autre en voix pour le moment.", "Noch niemand im Sprachchat.", "Ningu\xE9m mais na voz ainda."],
1295
- voiceVolume: ["Volume for {name}", "Volume di {name}", "Volumen de {name}", "Volume de {name}", "Lautst\xE4rke f\xFCr {name}", "Volume de {name}"],
1296
- voiceUnavailable: ["Join a room with voice to use these controls.", "Entra in una stanza con voce per usare questi controlli.", "Entra en una sala con voz para usar estos controles.", "Rejoignez une salle vocale pour utiliser ces commandes.", "Diese Steuerung braucht einen Raum mit Sprachchat.", "Entre em uma sala com voz para usar estes controles."],
1297
- voiceWatch: ["Voice is unavailable while watching.", "La voce non e' disponibile in osservazione.", "La voz no est\xE1 disponible al observar.", "La voix est indisponible en observation.", "Beim Zuschauen ist kein Sprachchat verf\xFCgbar.", "A voz n\xE3o est\xE1 dispon\xEDvel ao assistir."],
1298
- voiceDenied: ["Microphone permission denied. Allow it in your browser, then try again.", "Permesso microfono negato. Consenti l'accesso nel browser e riprova.", "Permiso de micr\xF3fono denegado. Act\xEDvalo en el navegador e int\xE9ntalo de nuevo.", "Acc\xE8s au micro refus\xE9. Autorisez-le dans le navigateur, puis r\xE9essayez.", "Mikrofonzugriff verweigert. Im Browser erlauben und erneut versuchen.", "Permiss\xE3o do microfone negada. Permita no navegador e tente novamente."],
1299
- voiceUnsupported: ["Voice is not supported in this browser.", "Questo browser non supporta la voce.", "Este navegador no admite voz.", "Ce navigateur ne prend pas en charge la voix.", "Dieser Browser unterst\xFCtzt keinen Sprachchat.", "Este navegador n\xE3o oferece suporte a voz."],
1300
- voiceFailed: ["Voice could not connect. Try again.", "Connessione voce non riuscita. Riprova.", "No se pudo conectar la voz. Int\xE9ntalo de nuevo.", "Connexion vocale impossible. R\xE9essayez.", "Sprachverbindung fehlgeschlagen. Erneut versuchen.", "N\xE3o foi poss\xEDvel conectar a voz. Tente novamente."],
1301
- voicePeerGone: ["This participant has left voice.", "Questo partecipante e' uscito dalla voce.", "Este participante sali\xF3 de voz.", "Ce participant a quitt\xE9 la voix.", "Diese Person hat den Sprachchat verlassen.", "Este participante saiu da voz."],
1302
- shortcut: ["Shift+Tab shortcut", "Scorciatoia Shift+Tab", "Atajo Shift+Tab", "Raccourci Maj+Tab", "Umschalt+Tab-Kurzbefehl", "Atalho Shift+Tab"],
1303
- menu: ["Caisual menu", "Menu Caisual", "Menu Caisual", "Menu Caisual", "Caisual-Menu", "Menu Caisual"],
1304
- retry: ["Retry", "Riprova", "Reintentar", "R\xE9essayer", "Erneut versuchen", "Tentar novamente"]
1305
- };
1306
- var column = (index) => Object.fromEntries(Object.entries(words).map(([key, row]) => [key, row[index]]));
1307
- var dictionaries = { en: column(0), it: column(1), es: column(2), fr: column(3), de: column(4), pt: column(5) };
1203
+ // src/overlay/locale.ts
1204
+ var languages = ["en", "it", "es", "fr", "de", "pt", "ja"];
1308
1205
  function overlayLanguage(raw) {
1309
1206
  const value = raw?.toLowerCase().split("-")[0];
1310
1207
  return languages.includes(value) ? value : "en";
@@ -1313,6 +1210,149 @@ function overlayLocale(raw) {
1313
1210
  const tag = normalizeLanguage(raw);
1314
1211
  return tag && languages.includes(tag.split("-")[0]) ? tag : "en";
1315
1212
  }
1213
+
1214
+ // src/overlay/i18n.ts
1215
+ var words = {
1216
+ watchReplay: ["Watch replay", "Guarda replay", "Ver repetici\xF3n", "Voir le replay", "Wiederholung ansehen", "Assistir \xE0 repeti\xE7\xE3o", "\u30EA\u30D7\u30EC\u30A4\u3092\u898B\u308B"],
1217
+ copyReplay: ["Copy link", "Copia link", "Copiar enlace", "Copier le lien", "Link kopieren", "Copiar link", "\u30EA\u30F3\u30AF\u3092\u30B3\u30D4\u30FC"],
1218
+ replayCopied: ["Link copied", "Link copiato", "Enlace copiado", "Lien copi\xE9", "Link kopiert", "Link copiado", "\u30EA\u30F3\u30AF\u3092\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F"],
1219
+ replay: ["Replay", "Replay", "Repetici\xF3n", "Replay", "Wiederholung", "Repeti\xE7\xE3o", "\u30EA\u30D7\u30EC\u30A4"],
1220
+ replayPlay: ["Play", "Riproduci", "Reproducir", "Lire", "Abspielen", "Reproduzir", "\u518D\u751F"],
1221
+ replayPause: ["Pause", "Pausa", "Pausar", "Pause", "Pause", "Pausar", "\u4E00\u6642\u505C\u6B62"],
1222
+ replaySeek: ["Position", "Posizione", "Posici\xF3n", "Position", "Position", "Posi\xE7\xE3o", "\u518D\u751F\u4F4D\u7F6E"],
1223
+ replaySpeed: ["Speed", "Velocit\xE0", "Velocidad", "Vitesse", "Geschwindigkeit", "Velocidade", "\u518D\u751F\u901F\u5EA6"],
1224
+ replayTruncated: ["Partial recording", "Registrazione parziale", "Grabaci\xF3n parcial", "Enregistrement partiel", "Teilweise Aufzeichnung", "Grava\xE7\xE3o parcial", "\u4E00\u90E8\u306E\u307F\u306E\u9332\u753B"],
1225
+ gameUpdated: ["This game was updated", "Questo gioco \xE8 stato aggiornato", "Este juego se ha actualizado", "Ce jeu a \xE9t\xE9 mis \xE0 jour", "Dieses Spiel wurde aktualisiert", "Este jogo foi atualizado", "\u30B2\u30FC\u30E0\u304C\u66F4\u65B0\u3055\u308C\u307E\u3057\u305F"],
1226
+ reloadGame: ["Reload game", "Ricarica il gioco", "Recargar el juego", "Recharger le jeu", "Spiel neu laden", "Recarregar o jogo", "\u30B2\u30FC\u30E0\u3092\u518D\u8AAD\u307F\u8FBC\u307F"],
1227
+ gameLanguages: ["Game languages", "Lingue del gioco", "Idiomas del juego", "Langues du jeu", "Spielsprachen", "Idiomas do jogo", "\u30B2\u30FC\u30E0\u306E\u8A00\u8A9E"],
1228
+ loading: ["Loading game...", "Caricamento...", "Cargando...", "Chargement...", "Spiel wird geladen...", "Carregando...", "\u8AAD\u307F\u8FBC\u307F\u4E2D..."],
1229
+ loadingSlow: ["This game is taking longer than expected. You can wait a little longer or try again.", "Il gioco ci sta mettendo pi\xF9 del previsto. Puoi aspettare ancora un po\u2019 o riprovare.", "El juego est\xE1 tardando m\xE1s de lo esperado. Puedes esperar un poco m\xE1s o volver a intentarlo.", "Le jeu met plus de temps que pr\xE9vu. Vous pouvez patienter encore un peu ou r\xE9essayer.", "Das Spiel braucht l\xE4nger als erwartet. Du kannst noch etwas warten oder es erneut versuchen.", "O jogo est\xE1 demorando mais do que o esperado. Voc\xEA pode esperar mais um pouco ou tentar novamente.", "\u8AAD\u307F\u8FBC\u307F\u306B\u6642\u9593\u304C\u304B\u304B\u3063\u3066\u3044\u307E\u3059\u3002\u3057\u3070\u3089\u304F\u5F85\u3064\u304B\u3001\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002"],
1230
+ home: ["Play", "Gioca", "Jugar", "Jouer", "Spielen", "Jogar", "\u30D7\u30EC\u30A4"],
1231
+ homeMenu: ["Menu", "Menu", "Men\xFA", "Menu", "Men\xFC", "Menu", "\u30E1\u30CB\u30E5\u30FC"],
1232
+ mode: ["Mode", "Modalit\xE0", "Modo", "Mode", "Modus", "Modo", "\u30E2\u30FC\u30C9"],
1233
+ singlePlayer: ["Single player", "Giocatore singolo", "Un jugador", "Un joueur", "Einzelspieler", "Um jogador", "\u30B7\u30F3\u30B0\u30EB\u30D7\u30EC\u30A4"],
1234
+ multiplayer: ["Multiplayer", "Multigiocatore", "Multijugador", "Multijoueur", "Mehrspieler", "Multijogador", "\u30DE\u30EB\u30C1\u30D7\u30EC\u30A4"],
1235
+ createRoom: ["Create a room", "Crea una stanza", "Crear una sala", "Cr\xE9er une salle", "Raum erstellen", "Criar uma sala", "\u30EB\u30FC\u30E0\u3092\u4F5C\u6210"],
1236
+ play: ["Play", "Gioca", "Jugar", "Jouer", "Spielen", "Jogar", "\u30D7\u30EC\u30A4"],
1237
+ friendsPlay: ["Play with friends", "Gioca con amici", "Jugar con amigos", "Jouer entre amis", "Mit Freunden spielen", "Jogar com amigos", "\u53CB\u9054\u3068\u30D7\u30EC\u30A4"],
1238
+ find: ["Find a match", "Trova una partita", "Buscar partida", "Trouver une partie", "Partie finden", "Encontrar partida", "\u5BFE\u6226\u3092\u63A2\u3059"],
1239
+ join: ["Join with code", "Entra con codice", "Entrar con c\xF3digo", "Rejoindre avec un code", "Mit Code beitreten", "Entrar com c\xF3digo", "\u30B3\u30FC\u30C9\u3067\u53C2\u52A0"],
1240
+ joinInvite: ["Join this room", "Entra in questa stanza", "Entrar en est\xE1 sala", "Rejoindre cette salle", "Diesem Raum beitreten", "Entrar nest\xE1 sala", "\u3053\u306E\u30EB\u30FC\u30E0\u306B\u53C2\u52A0"],
1241
+ watch: ["Watch a room", "Guarda una stanza", "Observar una sala", "Regarder une salle", "Raum ansehen", "Assistir a uma sala", "\u30EB\u30FC\u30E0\u3092\u89B3\u6226"],
1242
+ resume: ["Resume", "Riprendi", "Continuar", "Reprendre", "Fortsetzen", "Continuar", "\u518D\u958B"],
1243
+ room: ["Room", "Stanza", "Sala", "Salle", "Raum", "Sala", "\u30EB\u30FC\u30E0"],
1244
+ code: ["Room code", "Codice stanza", "C\xF3digo de sala", "Code de salle", "Raumcode", "C\xF3digo da sala", "\u30EB\u30FC\u30E0\u30B3\u30FC\u30C9"],
1245
+ copy: ["Copy invite", "Copia invito", "Copiar invitaci\xF3n", "Copier le lien", "Einladung kopieren", "Copiar convite", "\u62DB\u5F85\u3092\u30B3\u30D4\u30FC"],
1246
+ copied: ["Invite copied", "Invito copiato", "Invitacion copiada", "Lien copi\xE9", "Einladung kopiert", "Convite copiado", "\u62DB\u5F85\u3092\u30B3\u30D4\u30FC\u3057\u307E\u3057\u305F"],
1247
+ copyFailed: ["Copy this link:", "Copia questo link:", "Copia este enlace:", "Copiez ce lien :", "Diesen Link kopieren:", "Copie este link:", "\u3053\u306E\u30EA\u30F3\u30AF\u3092\u30B3\u30D4\u30FC\u3057\u3066\u304F\u3060\u3055\u3044\uFF1A"],
1248
+ joining: ["Joining room...", "Ingresso nella stanza...", "Entrando en la sala...", "Connexion \xE0 la salle...", "Raum wird betreten...", "Entrando na sala...", "\u30EB\u30FC\u30E0\u306B\u53C2\u52A0\u4E2D..."],
1249
+ matching: ["Finding your people...", "Ricerca giocatori...", "Buscando jugadores...", "Recherche de joueurs...", "Spieler werden gesucht...", "Buscando jogadores...", "\u30D7\u30EC\u30A4\u30E4\u30FC\u3092\u691C\u7D22\u4E2D..."],
1250
+ queue: ["{n} / {max} players", "{n} / {max} giocatori", "{n} / {max} jugadores", "{n} / {max} joueurs", "{n} / {max} Spieler", "{n} / {max} jogadores", "{n} / {max} \u4EBA"],
1251
+ cancel: ["Cancel", "Annulla", "Cancelar", "Annuler", "Abbrechen", "Cancelar", "\u30AD\u30E3\u30F3\u30BB\u30EB"],
1252
+ close: ["Close", "Chiudi", "Cerrar", "Fermer", "Schlie\xDFen", "Fechar", "\u9589\u3058\u308B"],
1253
+ back: ["Back", "Indietro", "Volver", "Retour", "Zur\xFCck", "Voltar", "\u623B\u308B"],
1254
+ ready: ["Ready", "Pronto", "Listo", "Pr\xEAt", "Bereit", "Pronto", "\u6E96\u5099\u5B8C\u4E86"],
1255
+ unready: ["Not ready", "Non pronto", "No listo", "Pas pr\xEAt", "Nicht bereit", "N\xE3o pronto", "\u6E96\u5099\u3092\u89E3\u9664"],
1256
+ start: ["Start", "Inizia", "Empezar", "Commencer", "Starten", "Come\xE7ar", "\u958B\u59CB"],
1257
+ role: ["Role", "Ruolo", "Rol", "R\xF4le", "Rolle", "Fun\xE7\xE3o", "\u5F79\u5272"],
1258
+ team: ["Team", "Squadra", "Equipo", "\xC9quipe", "Team", "Equipe", "\u30C1\u30FC\u30E0"],
1259
+ host: ["Host", "Host", "Anfitrion", "H\xF4te", "Host", "Anfitri\xE3o", "\u30DB\u30B9\u30C8"],
1260
+ you: ["You", "Tu", "T\xFA", "Vous", "Du", "Voc\xEA", "\u3042\u306A\u305F"],
1261
+ away: ["Away", "Assente", "Ausente", "Absent", "Abwesend", "Ausente", "\u96E2\u5E2D\u4E2D"],
1262
+ needPlayers: ["Waiting for more players", "In attesa di giocatori", "Esperando m\xE1s jugadores", "En attente de joueurs", "Weitere Spieler fehlen", "Esperando mais jogadores", "\u30D7\u30EC\u30A4\u30E4\u30FC\u3092\u5F85\u3063\u3066\u3044\u307E\u3059"],
1263
+ needReady: ["Everyone needs to be ready", "Tutti devono essere pronti", "Todos deben estar listos", "Tout le monde doit \xEAtre pr\xEAt", "Alle m\xFCssen bereit sein", "Todos precisam estar prontos", "\u5168\u54E1\u306E\u6E96\u5099\u5B8C\u4E86\u3092\u5F85\u3063\u3066\u3044\u307E\u3059"],
1264
+ needRoles: ["Fill the required roles", "Completa i ruoli richiesti", "Completa los roles", "Compl\xE9tez les r\xF4les", "Ben\xF6tigte Rollen besetzen", "Complete as fun\xE7\xF5es", "\u5FC5\u8981\u306A\u5F79\u5272\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044"],
1265
+ needTeams: ["Choose the required teams", "Scegli le squadre richieste", "Elige los equipos", "Choisissez les \xE9quipes", "Teams auswahlen", "Escolha as equipes", "\u5FC5\u8981\u306A\u30C1\u30FC\u30E0\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044"],
1266
+ waitHost: ["Waiting for the host", "In attesa dell'host", "Esperando al anfitrion", "En attente de l\u2019h\xF4te", "Warten auf den Host", "Esperando o anfitri\xE3o", "\u30DB\u30B9\u30C8\u3092\u5F85\u3063\u3066\u3044\u307E\u3059"],
1267
+ starting: ["Starting in", "Si inizia tra", "Empieza en", "D\xE9but dans", "Start in", "Come\xE7a em", "\u958B\u59CB\u307E\u3067"],
1268
+ playing: ["Playing", "In partita", "Jugando", "En jeu", "Im Spiel", "Jogando", "\u30D7\u30EC\u30A4\u4E2D"],
1269
+ ended: ["Game finished", "Partita conclusa", "Partida terminada", "Partie termin\xE9e", "Spiel beendet", "Partida encerrada", "\u8A66\u5408\u7D42\u4E86"],
1270
+ rematchReady: ["{n}/{max} ready", "{n}/{max} pronti", "{n}/{max} listos", "{n}/{max} pr\xEAts", "{n}/{max} bereit", "{n}/{max} prontos", "{n}/{max} \u4EBA\u304C\u6E96\u5099\u5B8C\u4E86"],
1271
+ rematchStart: ["Start rematch", "Avvia rivincita", "Iniciar revancha", "Lancer la revanche", "Revanche starten", "Iniciar revanche", "\u518D\u6226\u3092\u958B\u59CB"],
1272
+ won: ["You won", "Hai vinto", "Has ganado", "Vous avez gagn\xE9", "Du hast gewonnen", "Voc\xEA venceu", "\u52DD\u5229"],
1273
+ lost: ["You lost", "Hai perso", "Has perdido", "Vous avez perdu", "Du hast verloren", "Voc\xEA perdeu", "\u6557\u5317"],
1274
+ draw: ["Draw", "Pareggio", "Empate", "\xC9galit\xE9", "Unentschieden", "Empate", "\u5F15\u304D\u5206\u3051"],
1275
+ standings: ["Standings", "Piazzamenti", "Posiciones", "R\xE9sultats", "Platzierungen", "Coloca\xE7\xF5es", "\u9806\u4F4D"],
1276
+ points: ["points", "punti", "puntos", "points", "Punkte", "pontos", "\u30DD\u30A4\u30F3\u30C8"],
1277
+ time: ["time", "tempo", "tiempo", "temps", "Zeit", "tempo", "\u6642\u9593"],
1278
+ distance: ["distance", "distanza", "distancia", "distance", "Distanz", "dist\xE2ncia", "\u8DDD\u96E2"],
1279
+ again: ["Play again", "Gioca ancora", "Jugar de nuevo", "Rejouer", "Erneut spielen", "Jogar novamente", "\u3082\u3046\u4E00\u5EA6\u30D7\u30EC\u30A4"],
1280
+ newRoom: ["New room. Share the new invite.", "Nuova stanza. Condividi il nuovo invito.", "Nueva sala. Comparte la invitaci\xF3n.", "Nouvelle salle. Partagez le lien.", "Neuer Raum. Neue Einladung teilen.", "Nova sala. Compartilhe o convite.", "\u65B0\u3057\u3044\u30EB\u30FC\u30E0\u3067\u3059\u3002\u65B0\u3057\u3044\u62DB\u5F85\u3092\u5171\u6709\u3057\u3066\u304F\u3060\u3055\u3044\u3002"],
1281
+ watching: ["Watching", "In osservazione", "Observando", "Spectateur", "Zuschauen", "Assistindo", "\u89B3\u6226\u4E2D"],
1282
+ delay: ["{n}s delay", "Ritardo {n}s", "Retraso de {n}s", "Retard de {n}s", "{n}s Verz\xF6gerung", "Atraso de {n}s", "{n}\u79D2\u306E\u9045\u5EF6"],
1283
+ exit: ["Exit", "Esci", "Salir", "Quitter", "Verlassen", "Sair", "\u7D42\u4E86"],
1284
+ leaveNow: ["Leave for now", "Esci per ora", "Salir por ahora", "Quitter pour le moment", "Vor\xFCbergehend verlassen", "Sair por enquanto", "\u4E00\u6642\u9000\u51FA"],
1285
+ leaveRoom: ["Leave room", "Lascia la stanza", "Abandonar sala", "Abandonner la salle", "Raum verlassen", "Deixar a sala", "\u30EB\u30FC\u30E0\u3092\u9000\u51FA"],
1286
+ leaveHint: ["Your room stays available for Resume.", "La stanza resta disponibile con Riprendi.", "Podr\xE1s volver a est\xE1 sala.", "Vous pourrez reprendre cette salle.", "Du kannst den Raum fortsetzen.", "Voc\xEA pode voltar a est\xE1 sala.", "\u30EB\u30FC\u30E0\u306F\u5F8C\u304B\u3089\u518D\u958B\u3067\u304D\u307E\u3059\u3002"],
1287
+ temporaryHint: ["The game continues. Rejoining may only be possible briefly.", "La partita continua. Il rientro pu\xF2 essere disponibile solo per poco.", "La partida continua. Volver puede ser posible solo por poco tiempo.", "La partie continue. Le retour peut \xEAtre limit\xE9.", "Das Spiel l\xE4uft weiter. R\xFCckkehr nur kurz m\xF6glich.", "A partida continua. O retorno pode ser limitado.", "\u30B2\u30FC\u30E0\u306F\u7D9A\u304D\u307E\u3059\u3002\u518D\u53C2\u52A0\u3067\u304D\u308B\u6642\u9593\u306F\u9650\u3089\u308C\u308B\u5834\u5408\u304C\u3042\u308A\u307E\u3059\u3002"],
1288
+ abandonHint: ["Leave room gives up your place.", "Lascia la stanza libera il tuo posto.", "Abandonar libera tu plaza.", "Abandonner lib\xE8re votre place.", "Raum verlassen gibt deinen Platz frei.", "Deixar a sala libera sua vaga.", "\u30EB\u30FC\u30E0\u3092\u9000\u51FA\u3059\u308B\u3068\u53C2\u52A0\u67A0\u3092\u624B\u653E\u3057\u307E\u3059\u3002"],
1289
+ reconnecting: ["Reconnecting...", "Riconnessione...", "Reconectando...", "Reconnexion...", "Verbindung wird erneuert...", "Reconectando...", "\u518D\u63A5\u7D9A\u4E2D..."],
1290
+ replaced: ["Opened in another tab", "Aperta in un\u2019altra scheda", "Abierta en otra pest\xE1na", "Ouverte dans un autre onglet", "In anderem Tab ge\xF6ffnet", "Aberta em outra aba", "\u5225\u306E\u30BF\u30D6\u3067\u958B\u304B\u308C\u307E\u3057\u305F"],
1291
+ error: ["Something went wrong. Try again.", "Qualcosa non va. Riprova.", "Algo sali\xF3 mal. Reintenta.", "Une erreur est survenue. R\xE9essayez.", "Etwas ist schiefgelaufen. Erneut versuchen.", "Algo deu errado. Tente novamente.", "\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002"],
1292
+ noRoom: ["This room is no longer available.", "Questa stanza non \xE8 pi\xF9 disponibile.", "Esta sala ya no est\xE1 disponible.", "Cette salle n'est plus disponible.", "Dieser Raum ist nicht mehr verf\xFCgbar.", "Esta sala n\xE3o est\xE1 mais disponivel.", "\u3053\u306E\u30EB\u30FC\u30E0\u306F\u5229\u7528\u3067\u304D\u307E\u305B\u3093\u3002"],
1293
+ full: ["This room is full.", "La stanza \xE8 piena.", "La sala est\xE1 llena.", "Cette salle est pleine.", "Dieser Raum ist voll.", "Esta sala est\xE1 cheia.", "\u30EB\u30FC\u30E0\u306F\u6E80\u54E1\u3067\u3059\u3002"],
1294
+ noMatch: ["No match this time. Try again.", "Nessun gruppo trovato. Riprova.", "No hay grupo. Reintenta.", "Aucun groupe trouv\xE9. R\xE9essayez.", "Keine Gruppe gefunden. Erneut versuchen.", "Nenhum grupo encontrado. Tente novamente.", "\u76F8\u624B\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002"],
1295
+ invalidCode: ["Enter a six-character room code.", "Inserisci un codice di sei caratteri.", "Escribe un c\xF3digo de seis caracteres.", "Entrez un code de six caracteres.", "Sechsstelligen Raumcode eingeben.", "Digite um c\xF3digo de seis caracteres.", "6\u6587\u5B57\u306E\u30EB\u30FC\u30E0\u30B3\u30FC\u30C9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"],
1296
+ refused: ["The room did not accept that change.", "La stanza ha rifiutato la modifica.", "La sala rechaz\xF3 el cambio.", "La salle a refus\xE9 ce changement.", "Der Raum hat die \xC4nderung abgelehnt.", "A sala recusou a altera\xE7\xE3o.", "\u30EB\u30FC\u30E0\u306F\u5909\u66F4\u3092\u53D7\u3051\u4ED8\u3051\u307E\u305B\u3093\u3067\u3057\u305F\u3002"],
1297
+ unavailable: ["Unavailable right now", "Non disponibile ora", "No disponible ahora", "Indisponible pour le moment", "Derzeit nicht verf\xFCgbar", "Indisponivel agora", "\u73FE\u5728\u5229\u7528\u3067\u304D\u307E\u305B\u3093"],
1298
+ offline: ["Connection unavailable. Try again.", "Connessione non disponibile. Riprova.", "Sin conexi\xF3n. Reintenta.", "Connexion indisponible. R\xE9essayez.", "Keine Verbindung. Erneut versuchen.", "Sem conex\xE3o. Tente novamente.", "\u63A5\u7D9A\u3067\u304D\u307E\u305B\u3093\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002"],
1299
+ saveFailed: ["Keep the room code. Resume could not be saved.", "Conserva il codice. Riprendi non \xE8 stato salvato.", "Guarda el c\xF3digo. No se pudo guardar el regreso.", "Gardez le code. La reprise ne peut pas \xEAtre enregistr\xE9e.", "Raumcode aufbewahren. Fortsetzen nicht gespeichert.", "Guarde o c\xF3digo. O retorno n\xE3o foi salvo.", "\u30EB\u30FC\u30E0\u30B3\u30FC\u30C9\u3092\u63A7\u3048\u3066\u304F\u3060\u3055\u3044\u3002\u518D\u958B\u60C5\u5831\u3092\u4FDD\u5B58\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002"],
1300
+ boards: ["Leaderboard", "Classifica", "Clasificaci\xF3n", "Classement", "Bestenliste", "Classifica\xE7\xE3o", "\u30E9\u30F3\u30AD\u30F3\u30B0"],
1301
+ board: ["Board", "Classifica", "Tabla", "Classement", "Bestenliste", "Tabela", "\u30E9\u30F3\u30AD\u30F3\u30B0"],
1302
+ daily: ["Daily", "Giornaliera", "Diaria", "Du jour", "T\xE4glich", "Di\xE1ria", "\u65E5\u5225"],
1303
+ allTime: ["All time", "Di sempre", "Hist\xF3rica", "Tous les temps", "Gesamt", "Geral", "\u5168\u671F\u9593"],
1304
+ accounts: ["Accounts", "Account", "Cuentas", "Comptes", "Konten", "Contas", "\u30A2\u30AB\u30A6\u30F3\u30C8"],
1305
+ guests: ["Guests", "Ospiti", "Invitados", "Invit\xE9s", "G\xE4ste", "Visitantes", "\u30B2\u30B9\u30C8"],
1306
+ category: ["Category", "Categoria", "Categoria", "Cat\xE9gorie", "Kategorie", "Categoria", "\u533A\u5206"],
1307
+ period: ["Period", "Periodo", "Per\xEDodo", "P\xE9riode", "Zeitraum", "Per\xEDodo", "\u671F\u9593"],
1308
+ rank: ["Rank", "Posizione", "Puesto", "Rang", "Platz", "Posicao", "\u9806\u4F4D"],
1309
+ score: ["Score", "Punteggio", "Puntos", "Score", "Punkte", "Pontos", "\u30B9\u30B3\u30A2"],
1310
+ verified: ["Verified", "Verificato", "Verificado", "V\xE9rifi\xE9", "Verifiziert", "Verificado", "\u78BA\u8A8D\u6E08\u307F"],
1311
+ own: ["Your best", "Il tuo record", "Tu record", "Votre record", "Dein Rekord", "Seu recorde", "\u81EA\u5DF1\u30D9\u30B9\u30C8"],
1312
+ empty: ["No scores yet", "Nessun punteggio", "A\xFAn no hay puntos", "Aucun score", "Noch keine Punkte", "Ainda sem pontos", "\u307E\u3060\u30B9\u30B3\u30A2\u304C\u3042\u308A\u307E\u305B\u3093"],
1313
+ saving: ["Saving score...", "Salvataggio punteggio...", "Guardando puntos...", "Enregistrement du score...", "Punkte werden gespeichert...", "Salvando pontos...", "\u30B9\u30B3\u30A2\u3092\u4FDD\u5B58\u4E2D..."],
1314
+ saved: ["Your best is on the board", "Il tuo record \xE8 in classifica", "Tu record est\xE1 en la tabla", "Votre record est au classement", "Dein Rekord ist eingetragen", "Seu recorde est\xE1 na tabela", "\u81EA\u5DF1\u30D9\u30B9\u30C8\u304C\u30E9\u30F3\u30AD\u30F3\u30B0\u306B\u53CD\u6620\u3055\u308C\u307E\u3057\u305F"],
1315
+ bestAlready: ["Your best is already on the board", "Il tuo record era gi\xE0 in classifica", "Tu record ya estaba en la tabla", "Votre record est d\xE9j\xE0 au classement", "Dein Rekord ist bereits eingetragen", "Seu recorde j\xE1 est\xE1 na tabela", "\u81EA\u5DF1\u30D9\u30B9\u30C8\u306F\u53CD\u6620\u6E08\u307F\u3067\u3059"],
1316
+ refresh: ["Refresh", "Aggiorna", "Actualizar", "Actualiser", "Aktualisieren", "Atualizar", "\u66F4\u65B0"],
1317
+ refreshHint: ["Score not visible yet. Refresh to check.", "Punteggio non ancora visibile. Aggiorna per controllare.", "Puntos a\xFAn no visibles. Actualiza.", "Score pas encore visible. Actualisez.", "Punkte noch nicht sichtbar. Aktualisieren.", "Pontos ainda n\xE3o visiveis. Atualize.", "\u30B9\u30B3\u30A2\u304C\u307E\u3060\u8868\u793A\u3055\u308C\u307E\u305B\u3093\u3002\u66F4\u65B0\u3057\u3066\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\u3002"],
1318
+ friends: ["Friends & party", "Amici e gruppo", "Amigos y grupo", "Amis et groupe", "Freunde & Gruppe", "Amigos e grupo", "\u53CB\u9054\u3068\u30D1\u30FC\u30C6\u30A3\u30FC"],
1319
+ localCrew: ["Friends and party are unavailable in local preview.", "Amici e gruppo non disponibili in anteprima locale.", "Amigos y grupo no disponibles en la vista local.", "Amis et groupe indisponibles en aper\xE7u local.", "Freunde und Gruppe in lokaler Vorschau nicht verf\xFCgbar.", "Amigos e grupo indispon\xEDveis na pr\xE9via local.", "\u30ED\u30FC\u30AB\u30EB\u30D7\u30EC\u30D3\u30E5\u30FC\u3067\u306F\u53CB\u9054\u3068\u30D1\u30FC\u30C6\u30A3\u30FC\u306F\u5229\u7528\u3067\u304D\u307E\u305B\u3093\u3002"],
1320
+ loginCrew: ["Sign in on Caisual to use friends and party.", "Accedi a Caisual per amici e gruppo.", "Inicia sesion para amigos y grupo.", "Connectez-vous pour utiliser amis et groupe.", "F\xFCr Freunde und Gruppe bei Caisual anmelden.", "Entre no Caisual para amigos e grupo.", "\u53CB\u9054\u3068\u30D1\u30FC\u30C6\u30A3\u30FC\u3092\u5229\u7528\u3059\u308B\u306B\u306FCaisual\u306B\u30ED\u30B0\u30A4\u30F3\u3057\u3066\u304F\u3060\u3055\u3044\u3002"],
1321
+ online: ["Online", "Online", "En linea", "En ligne", "Online", "Online", "\u30AA\u30F3\u30E9\u30A4\u30F3"],
1322
+ noFriends: ["No friends online", "Nessun amico online", "Sin amigos en linea", "Aucun ami en ligne", "Keine Freunde online", "Nenhum amigo online", "\u30AA\u30F3\u30E9\u30A4\u30F3\u306E\u53CB\u9054\u306F\u3044\u307E\u305B\u3093"],
1323
+ createParty: ["Create party", "Crea gruppo", "Crear grupo", "Cr\xE9er un groupe", "Gruppe erstellen", "Criar grupo", "\u30D1\u30FC\u30C6\u30A3\u30FC\u3092\u4F5C\u6210"],
1324
+ inviteParty: ["Invite to party", "Invita nel gruppo", "Invitar al grupo", "Inviter au groupe", "In Gruppe einladen", "Convidar para o grupo", "\u30D1\u30FC\u30C6\u30A3\u30FC\u306B\u62DB\u5F85"],
1325
+ leaveParty: ["Leave party", "Lascia gruppo", "Salir del grupo", "Quitter le groupe", "Gruppe verlassen", "Sair do grupo", "\u30D1\u30FC\u30C6\u30A3\u30FC\u3092\u9000\u51FA"],
1326
+ accept: ["Accept", "Accetta", "Aceptar", "Accepter", "Annehmen", "Aceitar", "\u627F\u8AFE"],
1327
+ decline: ["Decline", "Rifiuta", "Rechazar", "Refuser", "Ablehnen", "Recusar", "\u8F9E\u9000"],
1328
+ follow: ["Join them", "Raggiungi", "Unirse", "Rejoindre", "Beitreten", "Juntar-se", "\u4E00\u7DD2\u306B\u53C2\u52A0"],
1329
+ voice: ["Voice", "Voce", "Voz", "Voix", "Sprache", "Voz", "\u30DC\u30A4\u30B9"],
1330
+ voiceJoin: ["Join voice", "Entra in voce", "Unirse a voz", "Activer la voix", "Sprachchat beitreten", "Entrar na voz", "\u30DC\u30A4\u30B9\u306B\u53C2\u52A0"],
1331
+ voiceLeave: ["Leave voice", "Esci dalla voce", "Salir de voz", "Quitter la voix", "Sprachchat verlassen", "Sair da voz", "\u30DC\u30A4\u30B9\u3092\u9000\u51FA"],
1332
+ voiceMute: ["Mute", "Disattiva microfono", "Silenciar", "Couper le micro", "Stummschalten", "Silenciar", "\u30DF\u30E5\u30FC\u30C8"],
1333
+ voiceUnmute: ["Unmute", "Attiva microfono", "Activar micr\xF3fono", "Activer le micro", "Mikrofon aktivieren", "Ativar microfone", "\u30DF\u30E5\u30FC\u30C8\u89E3\u9664"],
1334
+ voiceOff: ["Voice off", "Voce disattivata", "Voz desactivada", "Voix d\xE9sactiv\xE9e", "Sprachchat aus", "Voz desativada", "\u30DC\u30A4\u30B9\u30AA\u30D5"],
1335
+ voiceJoining: ["Joining voice...", "Connessione voce...", "Conectando voz...", "Connexion vocale...", "Sprachchat verbindet...", "Conectando voz...", "\u30DC\u30A4\u30B9\u306B\u63A5\u7D9A\u4E2D..."],
1336
+ voiceOn: ["Voice connected", "Voce connessa", "Voz conectada", "Voix connect\xE9e", "Sprachchat verbunden", "Voz conectada", "\u30DC\u30A4\u30B9\u63A5\u7D9A\u6E08\u307F"],
1337
+ voiceMuted: ["Muted", "Microfono disattivato", "Silenciado", "Micro coup\xE9", "Stumm", "Silenciado", "\u30DF\u30E5\u30FC\u30C8\u4E2D"],
1338
+ voiceMic: ["Mic on", "Microfono attivo", "Micr\xF3fono activo", "Micro actif", "Mikrofon an", "Microfone ativo", "\u30DE\u30A4\u30AF\u30AA\u30F3"],
1339
+ voiceListening: ["Listening only", "Solo ascolto", "Solo escucha", "\xC9coute seule", "Nur zuh\xF6ren", "Somente ouvindo", "\u805E\u304F\u3060\u3051"],
1340
+ voiceSpeaking: ["Speaking", "Sta parlando", "Hablando", "Parle", "Spricht", "Falando", "\u767A\u8A71\u4E2D"],
1341
+ voicePeers: ["Voice participants", "Partecipanti in voce", "Participantes de voz", "Participants vocaux", "Sprachteilnehmer", "Participantes de voz", "\u30DC\u30A4\u30B9\u53C2\u52A0\u8005"],
1342
+ voiceEmpty: ["No one else in voice yet.", "Nessun altro in voce per ora.", "A\xFAn no hay nadie m\xE1s en voz.", "Personne d\u2019autre en voix pour le moment.", "Noch niemand im Sprachchat.", "Ningu\xE9m mais na voz ainda.", "\u4ED6\u306E\u53C2\u52A0\u8005\u306F\u307E\u3060\u3044\u307E\u305B\u3093\u3002"],
1343
+ voiceVolume: ["Volume for {name}", "Volume di {name}", "Volumen de {name}", "Volume de {name}", "Lautst\xE4rke f\xFCr {name}", "Volume de {name}", "{name}\u306E\u97F3\u91CF"],
1344
+ voiceUnavailable: ["Join a room with voice to use these controls.", "Entra in una stanza con voce per usare questi controlli.", "Entra en una sala con voz para usar estos controles.", "Rejoignez une salle vocale pour utiliser ces commandes.", "Diese Steuerung braucht einen Raum mit Sprachchat.", "Entre em uma sala com voz para usar estes controles.", "\u30DC\u30A4\u30B9\u5BFE\u5FDC\u306E\u30EB\u30FC\u30E0\u306B\u53C2\u52A0\u3057\u3066\u304F\u3060\u3055\u3044\u3002"],
1345
+ voiceWatch: ["Voice is unavailable while watching.", "La voce non e' disponibile in osservazione.", "La voz no est\xE1 disponible al observar.", "La voix est indisponible en observation.", "Beim Zuschauen ist kein Sprachchat verf\xFCgbar.", "A voz n\xE3o est\xE1 dispon\xEDvel ao assistir.", "\u89B3\u6226\u4E2D\u306F\u30DC\u30A4\u30B9\u3092\u5229\u7528\u3067\u304D\u307E\u305B\u3093\u3002"],
1346
+ voiceDenied: ["Microphone permission denied. Allow it in your browser, then try again.", "Permesso microfono negato. Consenti l'accesso nel browser e riprova.", "Permiso de micr\xF3fono denegado. Act\xEDvalo en el navegador e int\xE9ntalo de nuevo.", "Acc\xE8s au micro refus\xE9. Autorisez-le dans le navigateur, puis r\xE9essayez.", "Mikrofonzugriff verweigert. Im Browser erlauben und erneut versuchen.", "Permiss\xE3o do microfone negada. Permita no navegador e tente novamente.", "\u30DE\u30A4\u30AF\u304C\u8A31\u53EF\u3055\u308C\u3066\u3044\u307E\u305B\u3093\u3002\u30D6\u30E9\u30A6\u30B6\u3067\u8A31\u53EF\u3057\u3066\u304B\u3089\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002"],
1347
+ voiceUnsupported: ["Voice is not supported in this browser.", "Questo browser non supporta la voce.", "Este navegador no admite voz.", "Ce navigateur ne prend pas en charge la voix.", "Dieser Browser unterst\xFCtzt keinen Sprachchat.", "Este navegador n\xE3o oferece suporte a voz.", "\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u306F\u30DC\u30A4\u30B9\u306B\u5BFE\u5FDC\u3057\u3066\u3044\u307E\u305B\u3093\u3002"],
1348
+ voiceFailed: ["Voice could not connect. Try again.", "Connessione voce non riuscita. Riprova.", "No se pudo conectar la voz. Int\xE9ntalo de nuevo.", "Connexion vocale impossible. R\xE9essayez.", "Sprachverbindung fehlgeschlagen. Erneut versuchen.", "N\xE3o foi poss\xEDvel conectar a voz. Tente novamente.", "\u30DC\u30A4\u30B9\u306B\u63A5\u7D9A\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u3082\u3046\u4E00\u5EA6\u304A\u8A66\u3057\u304F\u3060\u3055\u3044\u3002"],
1349
+ voicePeerGone: ["This participant has left voice.", "Questo partecipante e' uscito dalla voce.", "Este participante sali\xF3 de voz.", "Ce participant a quitt\xE9 la voix.", "Diese Person hat den Sprachchat verlassen.", "Este participante saiu da voz.", "\u3053\u306E\u53C2\u52A0\u8005\u306F\u30DC\u30A4\u30B9\u3092\u9000\u51FA\u3057\u307E\u3057\u305F\u3002"],
1350
+ shortcut: ["Shift+Tab shortcut", "Scorciatoia Shift+Tab", "Atajo Shift+Tab", "Raccourci Maj+Tab", "Umschalt+Tab-Kurzbefehl", "Atalho Shift+Tab", "Shift+Tab\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8"],
1351
+ menu: ["Caisual menu", "Menu Caisual", "Menu Caisual", "Menu Caisual", "Caisual-Menu", "Menu Caisual", "Caisual\u30E1\u30CB\u30E5\u30FC"],
1352
+ retry: ["Retry", "Riprova", "Reintentar", "R\xE9essayer", "Erneut versuchen", "Tentar novamente", "\u518D\u8A66\u884C"]
1353
+ };
1354
+ var column = (index) => Object.fromEntries(Object.entries(words).map(([key, row]) => [key, row[index]]));
1355
+ var dictionaries = { en: column(0), it: column(1), es: column(2), fr: column(3), de: column(4), pt: column(5), ja: column(6) };
1316
1356
  function translator(language) {
1317
1357
  const dictionary = dictionaries[overlayLanguage(language)];
1318
1358
  return (key, values = {}) => dictionary[key].replace(/\{(\w+)\}/g, (_all, name) => String(values[name] ?? ""));
@@ -1350,6 +1390,11 @@ function phase(session) {
1350
1390
  function initialUi(manifest) {
1351
1391
  return { session: null, panel: "auto", mode: manifest.modes[0]?.id ?? "", busy: false, error: null, notice: null, shortcutEnabled: true };
1352
1392
  }
1393
+ function groupModes(manifest) {
1394
+ const groups = { singlePlayer: [], multiplayer: [] };
1395
+ for (const mode of manifest.modes) groups[risolviModalita(manifest, mode.id).players.max === 1 ? "singlePlayer" : "multiplayer"].push(mode);
1396
+ return groups;
1397
+ }
1353
1398
  function reduceUi(model, action) {
1354
1399
  switch (action.type) {
1355
1400
  case "session": {
@@ -1429,10 +1474,11 @@ function matchPresentation(session) {
1429
1474
 
1430
1475
  // src/overlay/styles.ts
1431
1476
  var styles = `
1432
- .game-icon{width:28px;height:28px;aspect-ratio:1;object-fit:contain;border-radius:7px;flex:none;vertical-align:middle}.game-icon-title{width:56px;height:56px;margin-bottom:12px}
1477
+ .game-icon{width:28px;height:28px;aspect-ratio:1;object-fit:contain;border-radius:7px;flex:none;vertical-align:middle}.game-icon-title{width:36px;height:36px;border-radius:10px}
1433
1478
  .safe-area-probe{position:fixed;visibility:hidden;pointer-events:none;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px)}
1434
1479
  :host{all:initial;position:fixed;inset:0;z-index:10000;pointer-events:none;font:15px/1.45 system-ui,sans-serif;color:#f4f4f1;color-scheme:dark;--accent:#a8efc5}
1435
1480
  [data-layout],[data-surface],.sr{pointer-events:none}*{box-sizing:border-box}button,input,select{font:inherit}button,a,input,select{touch-action:manipulation}button,select,input{border:1px solid #ffffff30;background:#25292b;color:inherit;border-radius:12px;min-height:44px;padding:10px 14px}button{cursor:pointer}button:disabled{opacity:.45;cursor:default}button:hover:not(:disabled){background:#343b3a}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid var(--accent);outline-offset:3px}a{color:var(--accent)}.primary{background:var(--accent);color:var(--accent-ink,#11221b);border-color:transparent;font-weight:700}.primary:hover:not(:disabled){filter:brightness(1.1);background:var(--accent)}.quiet{background:transparent}label{display:grid;gap:6px;text-align:left}select,input{width:100%;min-width:0}h1,h2,p{margin:0}h1{font-size:clamp(26px,5vw,42px);line-height:1.1;letter-spacing:-.035em}h2{font-size:20px}small,.muted{color:#bdc5c1}.stack{display:grid;gap:16px}.row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}.row>*{flex:0 1 auto}.row .grow,.grow{flex:1}.split{display:grid;grid-template-columns:1fr 1fr;gap:10px}.pill{position:absolute;top:max(10px,env(safe-area-inset-top));right:max(10px,env(safe-area-inset-right));display:flex;height:44px;border:1px solid #ffffff35;border-radius:24px;background:#171e20eF;box-shadow:0 4px 20px #0004;pointer-events:auto;overflow:hidden}.pill button{border:0;border-radius:0;padding:8px 13px;background:transparent}.pill button:focus-visible{outline-offset:-4px}.pill small{margin-left:8px}.backdrop{position:absolute;inset:0;background:#0b151ce8;backdrop-filter:blur(10px);pointer-events:auto;display:grid;place-items:center;padding:max(16px,env(safe-area-inset-top)) max(16px,env(safe-area-inset-right)) max(16px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));overflow:auto}.backdrop.home{background-color:#142127;background-size:contain;background-repeat:no-repeat;background-position:center}.dialog{position:relative;width:min(100%,540px);max-height:100%;overflow:auto;overscroll-behavior:contain;background:#141b1df5;border:1px solid #ffffff25;border-radius:22px;padding:24px;box-shadow:0 20px 80px #0005}.dialog.wide{width:min(100%,700px)}.top{display:flex;align-items:center;gap:12px;margin-bottom:18px}.top h2{flex:1}.tabs{display:flex;gap:6px;flex-wrap:wrap;border-bottom:1px solid #ffffff25;padding-bottom:12px}.tabs button{min-height:36px;padding:6px 10px}.tabs [aria-current=true]{border-color:var(--accent)}.roster{list-style:none;padding:0;margin:0;display:grid;gap:8px;max-height:32dvh;overflow:auto}.roster li{display:flex;align-items:center;gap:8px;padding:10px;background:#ffffff08;border-radius:10px}.roster .name{flex:1;overflow-wrap:anywhere}.badge{border:1px solid #ffffff30;border-radius:6px;padding:2px 6px;font-size:12px}.code{font-size:24px;letter-spacing:.13em;font-variant-numeric:tabular-nums}.notice,.error{border-radius:10px;padding:10px;background:#a8efc514;overflow-wrap:anywhere}.error{background:#ff8b7720;color:#ffd2c9}.countdown{font-size:88px;line-height:1;text-align:center;font-variant-numeric:tabular-nums}.ended{position:absolute;bottom:max(12px,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);max-width:calc(100% - 24px);width:max-content;background:#171e20f5;pointer-events:auto;border:1px solid #ffffff30;border-radius:16px;padding:10px;display:flex;align-items:center;justify-content:center;gap:8px;flex-wrap:wrap}.ended [data-rematch-players]{max-width:100%;max-height:3.2em;overflow:auto;overflow-wrap:anywhere}.standings{list-style:none;margin:0;padding:0;flex-basis:100%;max-height:20dvh;overflow:auto;font-size:13px}.standings li{display:flex;justify-content:space-between;gap:16px;overflow-wrap:anywhere}.ended{max-height:calc(100dvh - 80px);overflow:auto}.ended strong{padding:0 8px}.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.table-wrap{overflow:auto;max-height:38dvh}table{width:100%;border-collapse:collapse;text-align:left}th,td{padding:9px 6px;border-bottom:1px solid #ffffff20}td:nth-child(3){text-align:right}td small{display:block}.self{background:#ffffff0a}.checkbox{display:flex;align-items:center;gap:8px;font-size:13px}.checkbox input{width:18px;min-height:18px}.full{width:100%}
1481
+ .game-heading{display:flex;align-items:center;gap:12px;min-width:0;flex:1}.game-heading h1{font-size:28px;overflow-wrap:anywhere}.home .top{margin-bottom:12px}.game-description{font-size:13px;line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.experience-tabs{display:grid;grid-template-columns:1fr 1fr;gap:4px;padding:4px;border:1px solid #ffffff18;border-radius:14px;background:#0003}.experience-tabs button{background:transparent;border-color:transparent;font-size:14px;font-weight:600;padding:10px 8px;border-radius:10px;color:#bdc5c1}.experience-tabs [aria-selected=true]{background:#ffffff16;color:#f4f4f1;box-shadow:0 1px 4px #0003}.experience-tabs button:focus-visible{outline-offset:-3px}.home-content{gap:14px;min-width:0}.mode-details{display:grid;gap:6px;min-width:0}.mode-details h2{font-size:16px;font-weight:600}.mode-details label{font-size:13px}.mode-instructions{font-size:12px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.play-actions{gap:8px}.play-actions .primary{min-height:50px;font-size:16px}.home-links{gap:4px}.home-links button{border-color:transparent;font-size:13px}.home-links button:hover:not(:disabled){background:#ffffff0a}.resume-action{gap:4px}.resume-action small{text-align:center}.panel-footer{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-top:18px;padding-top:10px;border-top:1px solid #ffffff18;color:#bdc5c1}.panel-footer .checkbox{font-size:11px;white-space:nowrap;min-height:32px;gap:6px}.panel-footer input{margin:0;accent-color:var(--accent);width:14px;min-height:14px}.panel-footer small{min-width:0;text-align:right;font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-transform:uppercase}
1436
1482
  [hidden]{display:none!important}.voice-peers{list-style:none;margin:0;padding:0;display:grid;gap:10px}.voice-peers li{border:1px solid #ffffff25;border-radius:12px;padding:12px;display:grid;gap:8px}.voice-peers [data-speaking=true]{border-color:var(--accent)}.voice-peers input{width:100%;accent-color:var(--accent);padding:0}.voice-peers label{font-size:13px}.pill .voice-toggle{width:44px;padding:8px}.voice-toggle[data-voice-state=on][data-muted=false]{color:var(--accent)}
1437
1483
  .boot{position:absolute;inset:0;z-index:2;isolation:isolate;display:grid;place-items:center;overflow:auto;overscroll-behavior:contain;padding:max(100px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) max(48px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));background:#0b151c;opacity:1;transition:opacity .4s ease;pointer-events:auto;outline:none}
1438
1484
  .boot::before,.boot::after{content:"";position:fixed;inset:0;pointer-events:none;z-index:-1}.boot::before{background:radial-gradient(ellipse at 50% 38%,color-mix(in srgb,var(--accent),transparent 80%),transparent 65%)}.boot::after{background:radial-gradient(ellipse at 50% 38%,#0b151c20,#0b151cd9 85%),linear-gradient(#0b151c66,#0b151cbf)}
@@ -1442,6 +1488,7 @@ var styles = `
1442
1488
  .boot-progress{width:112px;height:3px;border-radius:12px;background:#ffffff20;overflow:hidden;margin-top:12px}.boot-progress span{display:block;width:44%;height:100%;border-radius:inherit;background:var(--boot-accent);animation:boot-progress 1.8s ease-in-out infinite}.boot-status{max-width:42ch;min-height:3em;font-size:14px;line-height:1.5;color:#d3dad6;text-wrap:balance}.boot-recovery{min-height:44px}.boot-recovery .row{justify-content:center}.boot-leaving{opacity:0;pointer-events:none}
1443
1489
  @keyframes boot-progress{0%{transform:translateX(-110%)}100%{transform:translateX(340%)}}
1444
1490
  @media(max-width:480px){.dialog{padding:18px;border-radius:18px}.split{grid-template-columns:1fr 1fr;gap:8px}.tabs{gap:4px}.tabs button{font-size:13px;padding:6px 8px}.pill button:focus-visible{outline-offset:-4px}.pill small{display:none}.ended{gap:6px}.standings{list-style:none;margin:0;padding:0;flex-basis:100%;max-height:20dvh;overflow:auto;font-size:13px}.standings li{display:flex;justify-content:space-between;gap:16px;overflow-wrap:anywhere}.ended{max-height:calc(100dvh - 80px);overflow:auto}.ended strong{font-size:13px}.ended button{padding:8px 10px;font-size:13px}.roster{max-height:28dvh}}
1491
+ .replay-controls{position:absolute;bottom:max(12px,env(safe-area-inset-bottom));left:12px;right:12px;display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding:12px;background:#141b1df5;border:1px solid #ffffff30;border-radius:16px;pointer-events:auto}.replay-position{flex:1;min-width:100px}.replay-controls label{font-size:12px}.replay-controls span{font-variant-numeric:tabular-nums;font-size:13px}.replay-link{display:inline-flex;align-items:center;min-height:44px;padding:10px 14px;border-radius:12px;text-decoration:none}
1445
1492
  @media(prefers-reduced-motion:reduce){*{scroll-behavior:auto}.boot{transition:none}.boot-progress span{animation:none;transform:translateX(65%)}}
1446
1493
  `;
1447
1494
 
@@ -1517,7 +1564,7 @@ function updateVoicePanel(container, input) {
1517
1564
  var escape = (value) => String(value ?? "").replace(/[&<>"']/g, (c) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c]);
1518
1565
  function mountOverlay(input) {
1519
1566
  const manifest = input.configuration.manifest;
1520
- if (manifest.overlay?.version !== 1) return null;
1567
+ if (manifest.overlay?.version !== 1 && !input.bridge.replay) return null;
1521
1568
  const document = input.container.ownerDocument, win = document.defaultView, t = translator(input.language);
1522
1569
  const host = document.createElement("div");
1523
1570
  host.dataset.caisualOverlay = "";
@@ -1545,7 +1592,7 @@ function mountOverlay(input) {
1545
1592
  const surface = root.querySelector("[data-surface]"), live = root.querySelector("[data-live]");
1546
1593
  surface.style.pointerEvents = "none";
1547
1594
  live.style.pointerEvents = "none";
1548
- const accent = manifest.overlay.accent ?? "#a8efc5";
1595
+ const accent = manifest.overlay?.accent ?? "#a8efc5";
1549
1596
  host.style.setProperty("--accent", accent);
1550
1597
  const rgb = [1, 3, 5].map((i) => parseInt(accent.slice(i, i + 2), 16) / 255).map((v) => v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);
1551
1598
  const luminance = rgb[0] * 0.2126 + rgb[1] * 0.7152 + rgb[2] * 0.0722;
@@ -1565,6 +1612,7 @@ function mountOverlay(input) {
1565
1612
  }
1566
1613
  const boards = input.boards ? createBoardController({ manifest, player: input.player.id, guests: input.player.guest, read: input.boards, changed: () => render() }) : null;
1567
1614
  const stops = [];
1615
+ const modeGroups = groupModes(manifest);
1568
1616
  const selectedMode = () => manifest.modes.find((mode) => mode.id === model.mode);
1569
1617
  const disabled = () => model.busy ? " disabled" : "";
1570
1618
  const button = (action, key, extra = "", off = false) => `<button type="button" data-action="${action}"${extra}${off || model.busy ? " disabled" : ""}>${t(key)}</button>`;
@@ -1640,7 +1688,7 @@ function mountOverlay(input) {
1640
1688
  const announce = (text) => {
1641
1689
  if (live.textContent !== text) live.textContent = text;
1642
1690
  };
1643
- const controls = () => [...root.querySelectorAll('button:not(:disabled),a[href],input:not(:disabled),select:not(:disabled),[tabindex="0"]')].filter((el) => !el.closest("[hidden]"));
1691
+ const controls = () => [...root.querySelectorAll('button:not(:disabled),a[href],input:not(:disabled),select:not(:disabled),[tabindex="0"]')].filter((el) => el.tabIndex !== -1 && !el.closest("[hidden]"));
1644
1692
  const soloMode = (mode) => (mode === null || manifest.modes.some((item) => item.id === mode)) && risolviModalita(manifest, mode).players.max === 1;
1645
1693
  const solo = () => model.session?.room?.limits.max === 1;
1646
1694
  const roomCode = () => solo() ? null : model.session?.room?.code ?? null;
@@ -1661,7 +1709,7 @@ function mountOverlay(input) {
1661
1709
  };
1662
1710
  const toggle = () => {
1663
1711
  if (visiblePanel(model)) close();
1664
- else setPanel(model.session?.room ? "room" : "home");
1712
+ else setPanel(model.session?.room && !model.session.room.replay ? "room" : "home");
1665
1713
  };
1666
1714
  async function perform(op, args, after) {
1667
1715
  const token = ++operation;
@@ -1732,18 +1780,30 @@ function mountOverlay(input) {
1732
1780
  if (voiceEligible(manifest, model.session)) items.push(["voice", "voice"]);
1733
1781
  return `<nav class="tabs" aria-label="Caisual">${items.map(([id, key]) => button(`panel:${id}`, key, ` aria-current="${id === panel}"`)).join("")}</nav>`;
1734
1782
  }
1783
+ function footer() {
1784
+ const languages2 = escape(manifestLanguages(manifest).join(" \xB7 "));
1785
+ return `<footer class="panel-footer"><label class="checkbox" title="${t("shortcut")}"><input type="checkbox" data-control="shortcut" aria-label="${t("shortcut")}"${model.shortcutEnabled ? " checked" : ""}>Shift+Tab</label><small data-game-languages title="${t("gameLanguages")}: ${languages2}" aria-label="${t("gameLanguages")}: ${languages2}">${languages2}</small></footer>`;
1786
+ }
1735
1787
  function home() {
1736
1788
  const selected = selectedMode(), action = primaryAction(manifest, model.mode), session = model.session;
1737
1789
  const description = resolveText(manifest.description, input.language, manifestLanguages(manifest)[0]);
1738
- const hasRooms = manifest.modes.some((mode) => mode.execution === "room" && risolviModalita(manifest, mode.id).players.max > 1);
1739
- return `${input.configuration.iconUrl ? `<img class="game-icon game-icon-title" src="${escape(input.configuration.iconUrl)}" alt="" />` : ""}<h1>${escape(manifest.name)}</h1>${description ? `<p class="muted" data-game-description>${escape(description)}</p>` : ""}<p class="muted" data-game-languages>${t("gameLanguages")}: ${escape(manifestLanguages(manifest).join(" \xB7 "))}</p><label>${t("mode")}<select data-control="mode"${disabled()}>${manifest.modes.map((mode) => `<option value="${escape(mode.id)}"${mode.id === model.mode ? " selected" : ""}>${escape(risolviPresentazione(manifest, mode.id, input.language).label)}</option>`).join("")}</select></label>
1740
- ${selected?.instructions ? `<p class="muted">${escape(resolveText(selected.instructions, input.language, manifestLanguages(manifest)[0]))}</p>` : ""}
1790
+ const singlePlayer = soloMode(model.mode), active = singlePlayer ? "singlePlayer" : "multiplayer";
1791
+ const modes = modeGroups[active], hasTabs = modeGroups.singlePlayer.length > 0 && modeGroups.multiplayer.length > 0;
1792
+ const playKey = singlePlayer ? "play" : input.crew?.getSnapshot().party ? "friendsPlay" : "createRoom";
1793
+ const resume = session?.resume && soloMode(session.resume.mode) === singlePlayer;
1794
+ return `${description ? `<p class="muted game-description" data-game-description title="${escape(description)}">${escape(description)}</p>` : ""}
1741
1795
  ${input.configuration.invite && phase(session) === "home" ? button("join-invite", input.bridge.watch ? "watch" : "joinInvite", ' class="primary"', !session?.ready) : ""}
1742
- ${action ? button("play", action.friends ? "friendsPlay" : "play", ' class="primary"', !session?.ready) : ""}
1743
- ${selected?.matchmaking ? button("match", "find", "", !selected.matchmaking.defaults || !session?.ready) : ""}
1744
- ${session?.resume ? button("resume", "resume", "", !session.ready) + `<small>${escape(solo() || soloMode(session.resume.mode) ? "" : session.resume.code)}</small>` : ""}
1745
- ${hasRooms && !solo() ? `<div class="split">${button("panel:join", "join", "", !session?.ready)}${manifest.spectators ? button("panel:watch", "watch", "", !session?.ready) : ""}</div>` : ""}
1746
- ${solo() ? button("panel:exit", "exit", ' class="quiet"') : ""}${navigation("home")}<label class="checkbox"><input type="checkbox" data-control="shortcut"${model.shortcutEnabled ? " checked" : ""}>${t("shortcut")}</label>`;
1796
+ ${hasTabs ? `<div class="experience-tabs" role="tablist" aria-label="${t("mode")}">${["singlePlayer", "multiplayer"].map((key) => button(`mode:${key}`, key, ` role="tab" id="tab-${key}" aria-selected="${key === active}" aria-controls="experience-panel" tabindex="${key === active ? 0 : -1}" data-mode="${escape(modeGroups[key][0].id)}"`)).join("")}</div>` : ""}
1797
+ <div class="stack home-content"${hasTabs ? ` role="tabpanel" id="experience-panel" aria-labelledby="tab-${active}"` : ""}>
1798
+ <div class="mode-details">${modes.length > 1 ? `<label>${t("mode")}<select data-control="mode"${disabled()}>${modes.map((mode) => `<option value="${escape(mode.id)}"${mode.id === model.mode ? " selected" : ""}>${escape(risolviPresentazione(manifest, mode.id, input.language).label)}</option>`).join("")}</select></label>` : `<h2 data-mode-label>${escape(risolviPresentazione(manifest, model.mode, input.language).label)}</h2>`}
1799
+ ${selected?.instructions ? `<p class="muted mode-instructions" data-mode-instructions title="${escape(resolveText(selected.instructions, input.language, manifestLanguages(manifest)[0]))}">${escape(resolveText(selected.instructions, input.language, manifestLanguages(manifest)[0]))}</p>` : ""}</div>
1800
+ ${resume ? `<div class="stack resume-action">${button("resume", "resume", "", !session.ready)}${singlePlayer ? "" : `<small>${escape(session.resume.code)}</small>`}</div>` : ""}
1801
+ <div class="stack play-actions">${!singlePlayer && selected?.matchmaking ? button("match", "find", ' class="primary"', !selected.matchmaking.defaults || !session?.ready) : ""}
1802
+ ${action ? button("play", playKey, singlePlayer || !selected?.matchmaking ? ' class="primary"' : "", !session?.ready) : ""}</div>
1803
+ ${!singlePlayer ? `<div class="split home-links">${button("panel:join", "join", ' class="quiet"', !session?.ready)}${manifest.spectators ? button("panel:watch", "watch", ' class="quiet"', !session?.ready) : ""}</div>` : ""}
1804
+ ${!singlePlayer || Object.keys(manifest.boards).length ? `<div class="${singlePlayer ? "stack" : "split"} home-links">${!singlePlayer ? button("panel:friends", "friends", ' class="quiet"') : ""}${Object.keys(manifest.boards).length ? button("panel:boards", "boards", ' class="quiet"') : ""}</div>` : ""}
1805
+ ${solo() ? button("panel:exit", "exit", ' class="quiet"') : ""}
1806
+ </div>`;
1747
1807
  }
1748
1808
  function room() {
1749
1809
  const session = model.session, room2 = session?.room;
@@ -1756,7 +1816,7 @@ function mountOverlay(input) {
1756
1816
  ${lobby && manifest.teams ? `<label>${t("team")}<select data-control="team"${disabled()}><option value="" disabled${!own?.team ? " selected" : ""}>${t("team")}</option>${Array.from({ length: manifest.teams.max }, (_, i) => `<option value="${i + 1}"${own?.team === i + 1 ? " selected" : ""}>${t("team")} ${i + 1}</option>`).join("")}</select></label>` : ""}
1757
1817
  ${lobby ? `<div class="row">${button("ready", own?.ready ? "unready" : "ready", ' class="primary"', room2.connection !== "connected")}${room2.host === room2.you ? button("start", "start", "", reason !== null) : ""}</div>${reason ? `<p class="muted" data-start-reason>${t(reason)}</p>` : ""}` : ""}
1758
1818
  ${session?.kind === "watch" ? `<p>${t("watching")} \xB7 ${t("delay", { n: (room2.delayMs ?? 0) / 1e3 })}</p>` : ""}
1759
- ${navigation("room")}<label class="checkbox"><input type="checkbox" data-control="shortcut"${model.shortcutEnabled ? " checked" : ""}>${t("shortcut")}</label>${button("panel:exit", "exit", ' class="quiet"')}`;
1819
+ ${navigation("room")}${button("panel:exit", "exit", ' class="quiet"')}`;
1760
1820
  }
1761
1821
  function crew() {
1762
1822
  const provider = input.crew, state = provider?.getSnapshot();
@@ -1782,6 +1842,7 @@ function mountOverlay(input) {
1782
1842
  function content(panel) {
1783
1843
  switch (panel) {
1784
1844
  case "home":
1845
+ if (model.session?.room?.replay) return `${button("close", "back")}${button("exit-now", "exit")}`;
1785
1846
  return home();
1786
1847
  case "room":
1787
1848
  return room();
@@ -1849,6 +1910,33 @@ function mountOverlay(input) {
1849
1910
  function resize() {
1850
1911
  if (!geometryFrame) geometryFrame = win.requestAnimationFrame(geometry);
1851
1912
  }
1913
+ const replayLink = () => {
1914
+ const id = model.session?.room?.replayId;
1915
+ return manifest.replays && id && input.replayUrl ? input.replayUrl(id) : null;
1916
+ };
1917
+ function replayActions() {
1918
+ const url = replayLink();
1919
+ return url ? `<a class="primary replay-link" href="${escape(url)}">${t("watchReplay")}</a>${button("copy-replay", "copyReplay")}` : "";
1920
+ }
1921
+ const replayTime = (ms) => `${Math.floor(ms / 6e4)}:${String(Math.floor(ms / 1e3) % 60).padStart(2, "0")}`;
1922
+ function updateReplayPosition() {
1923
+ const playback = model.session?.room?.replay;
1924
+ if (!playback) return;
1925
+ const slider = root.querySelector("[data-control=replay-seek]");
1926
+ if (slider && slider.dataset.editing !== "true") slider.value = String(playback.positionMs);
1927
+ const time = root.querySelector("[data-replay-time]");
1928
+ if (time) time.textContent = `${replayTime(playback.positionMs)} / ${replayTime(playback.durationMs)}`;
1929
+ }
1930
+ function replayBar() {
1931
+ const playback = model.session?.room?.replay;
1932
+ if (!playback) return "";
1933
+ return `<div class="replay-controls" data-reserve role="region" aria-label="${t("replay")}">
1934
+ ${button(playback.paused ? "replay-play" : "replay-pause", playback.paused ? "replayPlay" : "replayPause")}
1935
+ <label class="replay-position">${t("replaySeek")}<input type="range" data-control="replay-seek" min="0" max="${playback.durationMs}" step="1" value="${playback.positionMs}" aria-label="${t("replaySeek")}"></label>
1936
+ <span data-replay-time>${replayTime(playback.positionMs)} / ${replayTime(playback.durationMs)}</span>
1937
+ <label>${t("replaySpeed")}<select data-control="replay-speed">${[0.5, 1, 2, 4].map((speed) => `<option value="${speed}"${speed === playback.speed ? " selected" : ""}>${speed}\xD7</option>`).join("")}</select></label>
1938
+ ${playback.truncated ? `<small>${t("replayTruncated")}</small>` : ""}</div>`;
1939
+ }
1852
1940
  function resultBar() {
1853
1941
  const presentation = matchPresentation(model.session);
1854
1942
  if (!presentation) return `<strong>${t("ended")}</strong>`;
@@ -1882,9 +1970,10 @@ function mountOverlay(input) {
1882
1970
  const crewState = input.crew?.getSnapshot(), invitations = (crewState?.invites.length ?? 0) + (crewState?.follow ? 1 : 0);
1883
1971
  const label = current === "watching" ? t("watching") : room2?.connection === "reconnecting" ? t("reconnecting") : solo() ? "Caisual" : room2?.code ?? "Caisual";
1884
1972
  surface.innerHTML = current === "boot" ? "" : `<div class="pill" data-reserve><button type="button" data-action="menu" aria-label="${t("menu")}" aria-expanded="${!!panel}">C<span aria-hidden="true"><small>${escape(label)}</small></span></button>${voiceEligible(manifest, model.session) && model.session?.kind === "room" ? `<button type="button" class="voice-toggle" data-voice-toggle data-action="panel:voice"></button>` : ""}${invitations ? `<button type="button" data-action="panel:friends" aria-label="${t("friends")} (${invitations})">${invitations}</button>` : ""}</div>
1885
- ${current === "ended" && !panel ? `<div class="ended" data-reserve role="region" aria-label="${t("ended")}">${resultBar()}${boards?.state.saving ? `<small role="status" data-saving>${t(boards.state.saving)}</small>` : ""}${canPlayAgain(model.session) ? button("again", "again", ' class="primary"') : model.session?.kind === "room" && room2?.status !== "finished" && !solo() ? `<small>${t("waitHost")}</small>` : ""}${rematchBar()}${Object.keys(manifest.boards).length ? button("panel:boards", "boards") : ""}${button("panel:home", "homeMenu")}</div>` : ""}
1886
- ${panel ? `<div class="backdrop${panel === "home" ? " home" : ""}"><section class="dialog${panel === "boards" || panel === "friends" ? " wide" : ""}" role="dialog" aria-modal="true" aria-labelledby="panel-title" tabindex="-1"><div class="top"><h2 id="panel-title">${title(panel)}</h2><button type="button" data-action="close" aria-label="${t("close")}">\xD7</button></div><div class="stack">${content(panel)}${model.error ? `<p class="error" role="alert" data-error>${t(errorText(model.error))}</p>${model.error === "version_outdated" ? button("reload-game", "reloadGame", ' class="primary"') : ""}` : ""}${model.session?.resumeError ? `<p class="error" role="alert">${t("saveFailed")}</p>` : ""}${model.notice ? `<p class="notice" role="status">${escape(model.notice)}</p>` : ""}</div></section></div>` : ""}`;
1887
- for (const element of surface.querySelectorAll(".pill,.backdrop,.ended")) element.style.pointerEvents = "auto";
1973
+ ${!panel ? replayBar() : ""}
1974
+ ${current === "ended" && !panel && !room2?.replay ? `<div class="ended" data-reserve role="region" aria-label="${t("ended")}">${resultBar()}${replayActions()}${boards?.state.saving ? `<small role="status" data-saving>${t(boards.state.saving)}</small>` : ""}${canPlayAgain(model.session) ? button("again", "again", ' class="primary"') : model.session?.kind === "room" && room2?.status !== "finished" && !solo() ? `<small>${t("waitHost")}</small>` : ""}${rematchBar()}${Object.keys(manifest.boards).length ? button("panel:boards", "boards") : ""}${button("panel:home", "homeMenu")}</div>` : ""}
1975
+ ${panel ? `<div class="backdrop${panel === "home" ? " home" : ""}"><section class="dialog${panel === "boards" || panel === "friends" ? " wide" : ""}" role="dialog" aria-modal="true" aria-labelledby="panel-title" tabindex="-1"><div class="top">${panel === "home" ? `<div class="game-heading">${input.configuration.iconUrl ? `<img class="game-icon game-icon-title" src="${escape(input.configuration.iconUrl)}" alt="" />` : ""}<h1 id="panel-title">${escape(manifest.name)}</h1></div>` : `<h2 id="panel-title">${title(panel)}</h2>`}<button type="button" data-action="close" aria-label="${t("close")}">\xD7</button></div><div class="stack">${content(panel)}${model.error ? `<p class="error" role="alert" data-error>${t(errorText(model.error))}</p>${model.error === "version_outdated" ? button("reload-game", "reloadGame", ' class="primary"') : ""}` : ""}${model.session?.resumeError ? `<p class="error" role="alert">${t("saveFailed")}</p>` : ""}${model.notice ? `<p class="notice" role="status">${escape(model.notice)}</p>` : ""}</div>${panel === "home" || panel === "room" ? footer() : ""}</section></div>` : ""}`;
1976
+ for (const element of surface.querySelectorAll(".pill,.backdrop,.ended,.replay-controls")) element.style.pointerEvents = "auto";
1888
1977
  const backdrop = root.querySelector(".backdrop.home");
1889
1978
  if (backdrop && input.configuration.coverUrl) backdrop.style.backgroundImage = `linear-gradient(#0b151c99,#0b151cee),url(${JSON.stringify(input.configuration.coverUrl)})`;
1890
1979
  host.dataset.phase = current;
@@ -1904,7 +1993,12 @@ function mountOverlay(input) {
1904
1993
  input.frame.contentWindow?.focus();
1905
1994
  } else if (matched && (!panel || focusPanel?.contains(matched)) && !matched.hasAttribute("disabled")) {
1906
1995
  matched.focus({ preventScroll: true });
1907
- if (matched.tagName === "INPUT" && selection?.start !== null && selection?.end !== null && selection) matched.setSelectionRange(selection.start, selection.end);
1996
+ if (matched.tagName === "INPUT" && selection?.start !== null && selection?.end !== null && selection) {
1997
+ try {
1998
+ matched.setSelectionRange(selection.start, selection.end);
1999
+ } catch {
2000
+ }
2001
+ }
1908
2002
  } else if (panel && (!wasModal || focused)) (current === "boot" ? boot : dialog?.querySelector('select,input,button:not([data-action="close"]):not(:disabled)') ?? dialog)?.focus({ preventScroll: true });
1909
2003
  wasModal = !!panel;
1910
2004
  if (lastPhase !== current) {
@@ -1919,11 +2013,31 @@ function mountOverlay(input) {
1919
2013
  if (!target || target.disabled) return;
1920
2014
  const action = target.dataset.action;
1921
2015
  event.stopPropagation();
2016
+ if (action.startsWith("mode:") && target.dataset.mode) {
2017
+ dispatch({ type: "mode", mode: target.dataset.mode });
2018
+ return;
2019
+ }
1922
2020
  if (action.startsWith("panel:")) {
1923
2021
  setPanel(action.slice(6));
1924
2022
  return;
1925
2023
  }
1926
2024
  switch (action) {
2025
+ case "replay-play":
2026
+ void perform("replay.play", {});
2027
+ break;
2028
+ case "replay-pause":
2029
+ void perform("replay.pause", {});
2030
+ break;
2031
+ case "copy-replay": {
2032
+ const url = replayLink();
2033
+ if (url) void Promise.resolve().then(() => win.navigator.clipboard.writeText(url)).then(() => {
2034
+ announce(t("replayCopied"));
2035
+ }, () => {
2036
+ setPanel("home");
2037
+ dispatch({ type: "notice", notice: `${t("copyFailed")} ${url}` });
2038
+ });
2039
+ break;
2040
+ }
1927
2041
  case "menu":
1928
2042
  toggle();
1929
2043
  break;
@@ -2026,6 +2140,15 @@ function mountOverlay(input) {
2026
2140
  };
2027
2141
  const change = (event) => {
2028
2142
  const target = event.target, field = target.dataset.control;
2143
+ if (field === "replay-seek") {
2144
+ delete target.dataset.editing;
2145
+ void perform("replay.seek", { positionMs: Number(target.value) });
2146
+ return;
2147
+ }
2148
+ if (field === "replay-speed") {
2149
+ void perform("replay.speed", { speed: Number(target.value) });
2150
+ return;
2151
+ }
2029
2152
  if (field === "voice-volume") {
2030
2153
  target.dataset.editing = "true";
2031
2154
  void performVoice("voice.setVolume", { playerId: target.dataset.peer, volume: Number(target.value) }).finally(() => {
@@ -2074,6 +2197,18 @@ function mountOverlay(input) {
2074
2197
  };
2075
2198
  const keydown = (event) => {
2076
2199
  const panel = visiblePanel(model);
2200
+ const tab = root.activeElement;
2201
+ if (tab?.getAttribute("role") === "tab" && ["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) {
2202
+ event.preventDefault();
2203
+ event.stopImmediatePropagation();
2204
+ const tabs = [...root.querySelectorAll('[role="tab"]:not(:disabled)')];
2205
+ const next = event.key === "Home" ? tabs[0] : event.key === "End" ? tabs.at(-1) : tabs.find((item) => item !== tab);
2206
+ if (next) {
2207
+ next.focus();
2208
+ next.click();
2209
+ }
2210
+ return;
2211
+ }
2077
2212
  if (panel && event.key === "Escape") {
2078
2213
  event.preventDefault();
2079
2214
  event.stopImmediatePropagation();
@@ -2101,7 +2236,7 @@ function mountOverlay(input) {
2101
2236
  root.addEventListener("input", (event) => {
2102
2237
  const node = event.target;
2103
2238
  if (node.dataset.control === "code") codeDraft = node.value;
2104
- if (node.dataset.control === "voice-volume") node.dataset.editing = "true";
2239
+ if (node.dataset.control === "voice-volume" || node.dataset.control === "replay-seek") node.dataset.editing = "true";
2105
2240
  });
2106
2241
  root.addEventListener("click", click);
2107
2242
  root.addEventListener("change", change);
@@ -2127,7 +2262,11 @@ function mountOverlay(input) {
2127
2262
  operation++;
2128
2263
  model.busy = false;
2129
2264
  }
2130
- if (previous && session && JSON.stringify({ ...previous, voice: null }) === JSON.stringify({ ...session, voice: null })) {
2265
+ const withoutPosition = (state) => state?.room?.replay ? { ...state, room: { ...state.room, replay: { ...state.room.replay, positionMs: 0 } } } : state;
2266
+ if (previous?.room?.replay && session?.room?.replay && JSON.stringify(withoutPosition(previous)) === JSON.stringify(withoutPosition(session))) {
2267
+ model = reduceUi(model, { type: "session", session });
2268
+ updateReplayPosition();
2269
+ } else if (previous && session && JSON.stringify({ ...previous, voice: null }) === JSON.stringify({ ...session, voice: null })) {
2131
2270
  model = reduceUi(model, { type: "session", session });
2132
2271
  updateVoice();
2133
2272
  } else dispatch({ type: "session", session });