From e812a16e688fc5f76ba5858d14a24361d0ad6f37 Mon Sep 17 00:00:00 2001 From: phantomptr Date: Tue, 24 Nov 2026 22:15:50 -0800 Subject: [PATCH 01/12] Fake PS5 games play up to 13.60: the warning moves above 13.60, and the notes say 11.61-13.60 need a kstuff with fake-package support (November 2026) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- FAQ.md | 46 +++++++++++-------- README.md | 6 +-- .../FakeGameFirmwareNotice.test.tsx | 16 +++---- .../src/components/FakeGameFirmwareNotice.tsx | 12 ++--- client/src/i18n/locales/ar.ts | 10 ++-- client/src/i18n/locales/bn.ts | 10 ++-- client/src/i18n/locales/de.ts | 10 ++-- client/src/i18n/locales/en.ts | 10 ++-- client/src/i18n/locales/es.ts | 10 ++-- client/src/i18n/locales/fa.ts | 10 ++-- client/src/i18n/locales/fr.ts | 10 ++-- client/src/i18n/locales/hi.ts | 10 ++-- client/src/i18n/locales/hu.ts | 10 ++-- client/src/i18n/locales/id.ts | 10 ++-- client/src/i18n/locales/it.ts | 10 ++-- client/src/i18n/locales/ja.ts | 10 ++-- client/src/i18n/locales/ko.ts | 10 ++-- client/src/i18n/locales/pl.ts | 10 ++-- client/src/i18n/locales/pt-BR.ts | 10 ++-- client/src/i18n/locales/ru.ts | 10 ++-- client/src/i18n/locales/th.ts | 10 ++-- client/src/i18n/locales/tr.ts | 10 ++-- client/src/i18n/locales/vi.ts | 10 ++-- client/src/i18n/locales/zh-CN.ts | 10 ++-- client/src/i18n/locales/zh-TW.ts | 10 ++-- client/src/lib/launchRefusal.ts | 2 +- client/src/lib/ps5Firmware.test.ts | 14 +++--- client/src/lib/ps5Firmware.ts | 11 +++-- client/src/lib/useGameLaunch.tsx | 2 +- client/src/screens/FpkgConvert/MakeCard.tsx | 10 ++-- client/src/screens/FpkgConvert/cards.test.tsx | 13 ++++-- client/src/screens/FpkgConvert/index.tsx | 2 +- .../src/screens/InstallPackage/FpkgNote.tsx | 13 ++++-- client/src/screens/InstallPackage/index.tsx | 2 +- client/src/screens/Send/index.tsx | 4 +- client/src/state/fpkgConversion.test.ts | 2 +- scripts/i18n-source-hashes.json | 10 ++-- 37 files changed, 197 insertions(+), 178 deletions(-) diff --git a/FAQ.md b/FAQ.md index 6197c46d8..0bdf67940 100644 --- a/FAQ.md +++ b/FAQ.md @@ -87,7 +87,8 @@ connection. After a reboot the payloads are gone, so load them again. Rest mode can stop them too; the PS5Upload helper usually keeps running through it. **Q: Which payloads must be running before I install a package?** -In this order: **kstuff** (the build with PS5 fake-package support), **a53_ppr_install_fast.elf** +In this order: **kstuff** (the build with PS5 fake-package support for your firmware; above 11.60 +that is the November 2026 build or newer), **a53_ppr_install_fast.elf** (needed for PS5 fake packages) and **ShadowMount+**, plus the ps5upload helper. **Upload & Install** shows the same list in its fake-package note at the top. Many setups also run **nanoDNS** (keeps the console away from PSN and update servers) and **ftpsrv-ps5**; send those from **Payloads**. @@ -95,10 +96,11 @@ ps5upload itself does not use ftpsrv-ps5. If an install is refused, first check running. **Q: Which firmware limits apply to what I install?** -- **PS5 fake *game* packages install above firmware 11.60 (including 13.60) but are not - playable.** PS4 fake packages work and PS5 homebrew apps launch. The note at the top of - **Upload & Install** says so before you send anything. See "My - uploaded game won't launch" for the folder-dump route. +- **PS5 fake *game* packages play on firmware up to 13.60.** Above 11.60 (11.61, 12.xx, 13.xx) + they need a kstuff build with fake-package support for that firmware, released in November + 2026; with an older kstuff the package installs, but the game does not start. Above 13.60 they + install but do not start. PS4 fake packages work and PS5 homebrew apps launch. The note at the + top of **Upload & Install** says so before you send anything. - On **13.60**, Stream & install is the dependable route. **Q: Quick start: from a fresh jailbreak to my first upload.** @@ -2062,22 +2064,25 @@ own Settings. This is almost never a bug in ps5upload: the transfer worked, and Sony's side refuses to start the title. Check these in order. -1. **A PS5 fake game on firmware above 11.60.** The package installs, but an - installed PS5 fake package does not start on FW 11.61, 12.xx or 13.60 yet. - **Mount it with Kraken Mount instead:** with Kraken Mount running on the PS5, +1. **A PS5 fake game on firmware above 11.60 with an older kstuff.** An + installed PS5 fake package plays on FW 11.61, 12.xx and 13.xx only with a + kstuff build that supports fake packages on that firmware, released in + November 2026. With an older kstuff the package installs, but the game does + not start: load the newer kstuff, reboot if an older one was running, and + launch again. Above 13.60 an installed PS5 fake package does not start, and + the app warns about that on Install and Convert. You can also mount the + package with Kraken Mount instead: with Kraken Mount running on the PS5, Upload & Install puts the `.pkg` in a folder it scans, and the game plays - straight from the package, with nothing installed (Kraken Mount 0.2.1 or later - keeps its save data and trophies). Full support for installed packages on - these firmware versions, through the A53 patches, is coming. PS4 packages are - fine, and PS5 homebrew apps (Itemzflow and similar) launch. The app shows a - warning for this combination on Install, Convert and when a launch fails. - The folder-dump and image routes below work too. + straight from the package, with nothing installed. PS4 packages are fine, + and PS5 homebrew apps (Itemzflow and similar) launch. The folder-dump and + image routes below work too. 2. **"View product" or "missing base entitlement".** Install the base game before its update or DLC. A package that needs an entitlement the console does not have will always show "View product". A PS5 game installed from a - fake package on firmware above 11.60 (item 1) ends here too: it installs, - then shows "View product". Mount the package with Kraken Mount, or use the - game folder or an image instead. + fake package without a kstuff that supports it on that firmware (item 1) + ends here too: it installs, then shows "View product". Load the newer + kstuff, mount the package with Kraken Mount, or use the game folder or an + image instead. 3. **kstuff or ShadowMount+ is not running.** Launching needs kernel access. **Games** says so above the grid when the helper has none; load kstuff and reconnect. Disc-image titles need ShadowMount+ running. @@ -2278,8 +2283,9 @@ offers the two ways a package can reach the PS5: under **Already on the PS5**, each with **Install**, **Reinstall** and **Delete**. The note at the top of the screen lists the payloads fake packages need, and says that **PS5 -fake packages are not supported on firmware later than 11.60**: they install, but the game does -not start. PS4 fake packages are fine. What is installing or waiting shows in the screen's queue +fake games play on firmware up to 13.60, and above 11.60 only with a kstuff build that supports +fake packages there** (November 2026 or newer); with an older one the package installs, but the +game does not start. PS4 fake packages are fine. What is installing or waiting shows in the screen's queue and in the progress bar, and keeps going when you open another screen. Installs from a link or an archive (**From a Link or an Archive**) and from the PS5 or a USB drive (**Already on the PS5**) are in the small "Or install a package" row under the drop zone. @@ -2730,7 +2736,7 @@ The routes: | Content | Stream & install | Upload & install | Folder dump + ShadowMount+ | exFAT image + ShadowMount+ | |---|---|---|---|---| | **PS4 package** (base game) | Works. The most reliable route; PS4 fake packages play on every firmware. | Works on FW 13.60 from 6.3.1 (a 3.6 GiB base installed over itself on both of our consoles). Before 6.3.1 Sony refused it with `0x80B2116F`; see the firmware note below. | Works (PS4 folder dumps). | Works. | -| **PS5 package** (fake / FPKG game) | Installs. **On firmware above 11.60 the installed game doesn't start yet: mount the package with Kraken Mount instead** (full support through the A53 patches is coming). | Same as Stream. | Works for a decrypted PS5 dump — the route people use on 13.60. | Works — also the route used on 13.60. | +| **PS5 package** (fake / FPKG game) | Installs. **Plays on firmware up to 13.60; above 11.60 it needs a kstuff build with fake-package support for that firmware (November 2026 or newer).** Kraken Mount can mount the package instead. | Same as Stream. | Works for a decrypted PS5 dump — the route people use on 13.60. | Works — also the route used on 13.60. | | **PS5 homebrew app** (for example Itemzflow, `IV0002-ITEM00001`) | Works and launches, including on FW 13.60. | Works. | n/a | n/a | | **Patch / update** | Works (verified: a PS4 base plus its patch, streamed). Install the base first. | Works on FW 13.60 from 6.3.1 (a PS4 1.00 base took its 1.04 patch this way). Install the base first. | n/a — copy the update into the game folder. | n/a | | **DLC** | Works after its base is installed. | Works after its base is installed. | n/a | n/a | diff --git a/README.md b/README.md index 36397b42e..7bf0c2cb3 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ archives and any other file, and works out what each is. PS4 `.pkg` and PS5 fake packages (base, update, DLC) install from your computer (**Stream & install** or **Upload & install**), a NAS/SMB share, a USB drive or a link. If the PS5 refuses one route, the app offers another. - On firmware above 11.60 an installed PS5 fake package does not start yet: mount it with - **Kraken Mount** instead (Upload & Install offers it when Kraken Mount runs), and full support - for installed packages there, through the A53 patches, is coming. PS4 fake packages are fine. + An installed PS5 fake package plays on firmware up to 13.60; above 11.60 it needs a kstuff build + with fake-package support for that firmware (November 2026 or newer). **Kraken Mount** can mount + the package instead (Upload & Install offers it when Kraken Mount runs). PS4 fake packages are fine. - **Games.** One grid with every game once: your copies in your folders (including folders on a NAS, scanned in place) grouped with their updates and DLC, what each PS5 has installed, and the games on its drives. Play (or close) an installed game right from its card. Each game's diff --git a/client/src/components/FakeGameFirmwareNotice.test.tsx b/client/src/components/FakeGameFirmwareNotice.test.tsx index 9d095c05a..0652a0e91 100644 --- a/client/src/components/FakeGameFirmwareNotice.test.tsx +++ b/client/src/components/FakeGameFirmwareNotice.test.tsx @@ -18,18 +18,18 @@ const html = (kernel: string | null, id: string | null, compact = false) => renderToStaticMarkup(); describe("FakeGameFirmwareNotice", () => { - it("says it installs but isn't playable, for a PS5 game on 13.60", () => { - const out = html(K("13.60"), PS5_GAME); - expect(out).toContain("Installed, this PS5 game won't start on FW 13.60"); - expect(out).toContain("PS5 fake packages install on firmware above 11.60 but don't start"); - expect(out).toContain("Kraken Mount"); - expect(out).toContain("A53"); + it("says it installs but isn't playable, for a PS5 game above 13.60", () => { + const out = html(K("14.00"), PS5_GAME); + expect(out).toContain("Installed, this PS5 game won't start on FW 14.00"); + expect(out).toContain("PS5 fake packages play on firmware up to 13.60"); expect(out).toContain("PS4 packages and PS5 homebrew apps are fine"); }); it("renders the one-line form for a list row", () => { - expect(html(K("11.61"), PS5_GAME, true)).toContain("above 11.60"); + expect(html(K("13.61"), PS5_GAME, true)).toContain("up to 13.60"); }); - it("renders nothing for 11.60, PS4, homebrew or an unknown firmware", () => { + it("renders nothing up to 13.60 (fake-package kstuff, November 2026), PS4, homebrew or an unknown firmware", () => { + expect(html(K("13.60"), PS5_GAME)).toBe(""); + expect(html(K("12.00"), PS5_GAME)).toBe(""); expect(html(K("11.60"), PS5_GAME)).toBe(""); expect(html(K("13.60"), "UP9000-CUSA00207_00-BLOODBORNE000000")).toBe(""); expect(html(K("13.60"), "IV0002-ITEM00001_00-ITEMZFLOWIV00000")).toBe(""); diff --git a/client/src/components/FakeGameFirmwareNotice.tsx b/client/src/components/FakeGameFirmwareNotice.tsx index 3f01bb467..40db85e93 100644 --- a/client/src/components/FakeGameFirmwareNotice.tsx +++ b/client/src/components/FakeGameFirmwareNotice.tsx @@ -6,10 +6,10 @@ import { useTr } from "../state/lang"; import { Callout } from "./Callout"; /** - * A fake PS5 game package on firmware above 11.60 installs but does not start: Kraken Mount - * mounts it instead, and support for installed packages there (the A53 patches) is coming. Renders nothing for a PS4 package, for PS5 homebrew (IV…/ITEM…), for - * 11.60 and older, or when the firmware can't be read: the warning needs a - * PS5 game id AND a known firmware above the line. + * A fake PS5 game package on firmware above LAST_PS5_FAKE_GAME_FIRMWARE installs but does not + * start. Renders nothing for a PS4 package, for PS5 homebrew (IV…/ITEM…), for that firmware and + * older, or when the firmware can't be read: the warning needs a PS5 game id AND a known + * firmware above the line. */ export function FakeGameFirmwareNotice({ kernel, @@ -30,9 +30,9 @@ export function FakeGameFirmwareNotice({ const fw = ps5FakeGameUnplayableFirmware(kernel, contentId); if (!fw) return null; const body = tr( - "fakegame.fw.body_v2", + "fakegame.fw.body_v3", { fw, last: LAST_PS5_FAKE_GAME_FIRMWARE }, - `PS5 fake packages install on firmware above ${LAST_PS5_FAKE_GAME_FIRMWARE} but don't start. Mount the package with Kraken Mount instead: the game plays straight from the .pkg, nothing installed. Full support for installed packages on newer firmware (through the A53 patches) is coming. PS4 packages and PS5 homebrew apps are fine.`, + `PS5 fake packages play on firmware up to ${LAST_PS5_FAKE_GAME_FIRMWARE}. On FW ${fw} the package installs, but the game doesn't start. PS4 packages and PS5 homebrew apps are fine.`, ); const help = inRouter ? ( { const PS4_GAME = "UP9000-CUSA00207_00-BLOODBORNE000000"; const HOMEBREW = "IV0002-ITEM00001_00-ITEMZFLOWIV00000"; - it("warns for a PS5 game above 11.60 (11.61, 12.xx, 13.60)", () => { - expect(ps5FakeGameUnplayableFirmware(K("13.60"), PS5_GAME)).toBe("13.60"); - expect(ps5FakeGameUnplayableFirmware(K("11.61"), PS5_GAME)).toBe("11.61"); - expect(ps5FakeGameUnplayableFirmware(K("12.00"), PS5_GAME)).toBe("12.00"); + it("warns for a PS5 game above 13.60", () => { + expect(ps5FakeGameUnplayableFirmware(K("13.61"), PS5_GAME)).toBe("13.61"); + expect(ps5FakeGameUnplayableFirmware(K("14.00"), PS5_GAME)).toBe("14.00"); }); - it("is silent at 11.60 and below", () => { + it("is silent at 13.60 and below: a kstuff with fake-package support covers 11.61 to 13.60", () => { + expect(ps5FakeGameUnplayableFirmware(K("13.60"), PS5_GAME)).toBeNull(); + expect(ps5FakeGameUnplayableFirmware(K("12.00"), PS5_GAME)).toBeNull(); + expect(ps5FakeGameUnplayableFirmware(K("11.61"), PS5_GAME)).toBeNull(); expect(ps5FakeGameUnplayableFirmware(K("11.60"), PS5_GAME)).toBeNull(); expect(ps5FakeGameUnplayableFirmware(K("09.60"), PS5_GAME)).toBeNull(); expect(ps5FakeGameUnplayableFirmware(K("05.10"), PS5_GAME)).toBeNull(); @@ -63,7 +65,7 @@ describe("ps5FakeGameUnplayableFirmware", () => { expect(ps5FakeGameUnplayableFirmware(K("13.60"), "ITEM00001")).toBeNull(); }); it("accepts a bare PPSA title id", () => { - expect(ps5FakeGameUnplayableFirmware(K("13.60"), "PPSA17221")).toBe("13.60"); + expect(ps5FakeGameUnplayableFirmware(K("14.00"), "PPSA17221")).toBe("14.00"); }); it("never warns when the firmware or the id is unknown", () => { expect(ps5FakeGameUnplayableFirmware(null, PS5_GAME)).toBeNull(); diff --git a/client/src/lib/ps5Firmware.ts b/client/src/lib/ps5Firmware.ts index 565f59658..b1dd97f98 100644 --- a/client/src/lib/ps5Firmware.ts +++ b/client/src/lib/ps5Firmware.ts @@ -42,10 +42,11 @@ export function parsePS5Firmware(kernel: string | null | undefined): string | nu } /** The newest firmware on which a PS5 fake (FPKG) GAME is playable. Above it - * the package still installs, but the game does not start. Measured by the - * maintainer on real hardware. PS4 fake packages and PS5 homebrew apps are - * not affected. */ -export const LAST_PS5_FAKE_GAME_FIRMWARE = "11.60"; + * the package still installs, but the game does not start. 11.60 until November 2026, when a + * kstuff build with fake-package support up to 13.60 was released (11.61 to 13.60 need that + * build; the fake-package note says so). PS4 fake packages and PS5 homebrew apps are not + * affected. */ +export const LAST_PS5_FAKE_GAME_FIRMWARE = "13.60"; /** True when `id` (a content id such as `UP4433-PPSA17221_00-MINECRAFTPS50000` * or a bare title id) names a PS5 GAME: it carries a `PPSAnnnnn` title id. @@ -59,7 +60,7 @@ export function isPs5GameId(id: string | null | undefined): boolean { /** The console's firmware ("13.60") when a PS5 fake GAME package with this id * would install but not be playable there, else null. That needs all of: * a PS5 game id (not PS4, not homebrew) AND a parseable firmware strictly - * above 11.60. An unparseable kernel string never produces a warning. */ + * above LAST_PS5_FAKE_GAME_FIRMWARE. An unparseable kernel string never produces a warning. */ export function ps5FakeGameUnplayableFirmware( kernel: string | null | undefined, contentOrTitleId: string | null | undefined, diff --git a/client/src/lib/useGameLaunch.tsx b/client/src/lib/useGameLaunch.tsx index 23d28b64a..cddbc2e1d 100644 --- a/client/src/lib/useGameLaunch.tsx +++ b/client/src/lib/useGameLaunch.tsx @@ -172,7 +172,7 @@ export function useGameLaunch( } catch (e) { if (probe.isStale()) return; if (e instanceof HomebrewRefused) { - // Not this game's fault and not the 11.60 fake-package limit: the console is + // Not this game's fault and not the fake-package firmware limit: the console is // refusing every non-Sony title, so name the cause instead. pushNotification( "error", diff --git a/client/src/screens/FpkgConvert/MakeCard.tsx b/client/src/screens/FpkgConvert/MakeCard.tsx index 0b52c1ec3..369023f2e 100644 --- a/client/src/screens/FpkgConvert/MakeCard.tsx +++ b/client/src/screens/FpkgConvert/MakeCard.tsx @@ -23,7 +23,7 @@ export function NextGameNote() { * ② What to make: a package the PS5 installs, a game image ShadowMount+ mounts, or (#469) the * game's files back as a plain folder. They are explained side by side, and the one of the * first two that suits the game on the connected console is marked: a PS5 game on firmware - * above 11.60 installs as a package but will not play, so the image is the way; otherwise the + * above 13.60 installs as a package but will not play, so the image is the way; otherwise the * package is the ordinary choice. The folder is never marked: it is a way back, not a way in. * For a PS4 game the package is a PS4 fake package, which the engine writes from the game. */ @@ -87,14 +87,14 @@ export function MakeCard({ title: tr("fpkg.make.pkg_title", undefined, "A package (.pkg)"), body: kraken ? tr( - "fpkg.make.pkg_body_kraken", + "fpkg.make.pkg_body_kraken_v2", undefined, - "Kraken Mount, running on this PS5, mounts it from a drive's homebrew folder and shows it on the home screen: nothing is installed, and it plays where an installed PS5 package does not. It can still be installed instead.", + "Kraken Mount, running on this PS5, mounts it from a drive's homebrew folder and shows it on the home screen, with nothing installed. It can still be installed instead.", ) : tr( - "fpkg.make.pkg_body_v2", + "fpkg.make.pkg_body_v3", undefined, - "Installs on the PS5 like a game from the store, streamed from here or uploaded first. PS4 games play on any firmware. An installed PS5 game plays on 11.60 and below; on newer firmware mount it with Kraken Mount (support for installing there is coming).", + "Installs on the PS5 like a game from the store, streamed from here or uploaded first. PS4 games play on any firmware. An installed PS5 game plays on firmware up to 13.60; above 11.60 it needs a kstuff build with fake-package support for that firmware (November 2026 or newer).", ), }, { diff --git a/client/src/screens/FpkgConvert/cards.test.tsx b/client/src/screens/FpkgConvert/cards.test.tsx index 681e9b5a2..a5adf7221 100644 --- a/client/src/screens/FpkgConvert/cards.test.tsx +++ b/client/src/screens/FpkgConvert/cards.test.tsx @@ -78,12 +78,19 @@ describe("MakeCard", () => { it("explains both, and marks the image for a PS5 game the firmware will not play as a package", () => { const fw = renderToStaticMarkup( - {}} kernel="r229358/releases/13.60" contentId="UP9000-PPSA03671_00-X" checked />, + {}} kernel="r229358/releases/14.00" contentId="UP9000-PPSA03671_00-X" checked />, ); expect(fw).toContain("A package (.pkg)"); expect(fw).toContain("A game image"); - expect(fw).toContain("Recommended on FW 13.60"); - expect(fw).toContain("not play on FW 13.60"); + expect(fw).toContain("Recommended on FW 14.00"); + expect(fw).toContain("not play on FW 14.00"); + // Up to 13.60 an installed PS5 package plays (with a fake-package kstuff): the package is the + // ordinary choice, not the image. + const fw1360 = renderToStaticMarkup( + {}} kernel="r229358/releases/13.60" contentId="UP9000-PPSA03671_00-X" checked />, + ); + expect(fw1360).not.toContain("Recommended on FW"); + expect(fw1360).toContain("plays on firmware up to 13.60"); const ps4 = renderToStaticMarkup( {}} kernel="r229358/releases/13.60" contentId="UP9000-CUSA01234_00-X" checked />, ); diff --git a/client/src/screens/FpkgConvert/index.tsx b/client/src/screens/FpkgConvert/index.tsx index a958d2546..a2c2b87a0 100644 --- a/client/src/screens/FpkgConvert/index.tsx +++ b/client/src/screens/FpkgConvert/index.tsx @@ -1186,7 +1186,7 @@ export default function WorkshopScreen() { /> {/* Building still works (it runs on this computer), but a PS5 fake GAME - installs and then can't be played on firmware above 11.60. Said + installs and then can't be played on firmware above 13.60. Said before the user spends an hour converting; silent for PS4, for homebrew and when the firmware is unknown. */} diff --git a/client/src/screens/InstallPackage/FpkgNote.tsx b/client/src/screens/InstallPackage/FpkgNote.tsx index 01863b3f1..897dfd7b9 100644 --- a/client/src/screens/InstallPackage/FpkgNote.tsx +++ b/client/src/screens/InstallPackage/FpkgNote.tsx @@ -8,8 +8,8 @@ import { useTr } from "../../state/lang"; * What a fake package (FPKG) needs, stated rather than detected: no header marker separates a * fake package from a retail one, so the note names the requirement and lets the reader decide * whether it applies. The firmware limit is on the folded line, so it is read before anyone - * installs: PS5 fake packages install on firmware later than 11.60 but do not run there yet; - * PS4 fake packages are fine. The load order is behind the fold. + * installs: PS5 fake games play up to 13.60, and above 11.60 only with a kstuff build that + * supports fake packages there (November 2026); PS4 fake packages are fine. The load order is behind the fold. */ export function FpkgNote({ className = "mb-4" }: { className?: string }) { const tr = useTr(); @@ -26,8 +26,8 @@ export function FpkgNote({ className = "mb-4" }: { className?: string }) { {tr( - "pkglib.fpkgsupport.firmware_v2", - "PS5 fake packages install on firmware above 11.60 but don't start yet. Mount them with Kraken Mount instead; full support for installing them there (through the A53 patches) is coming. PS4 fake packages are fine.", + "pkglib.fpkgsupport.firmware_v3", + "PS5 fake packages play on firmware up to 13.60. Above 11.60 they need a kstuff build with fake-package support for that firmware (released November 2026): with an older kstuff the package installs, but the game doesn't start. PS4 fake packages are fine.", )} @@ -47,7 +47,10 @@ export function FpkgNote({ className = "mb-4" }: { className?: string }) {
  1. kstuff{" "} - {tr("pkglib.fpkgsupport.kstuff", "— the build with PS5 fake-package support")} + {tr( + "pkglib.fpkgsupport.kstuff_v2", + "— the build with PS5 fake-package support for your firmware (above 11.60: the November 2026 build or newer)", + )}
  2. a53_ppr_install_fast.elf{" "} diff --git a/client/src/screens/InstallPackage/index.tsx b/client/src/screens/InstallPackage/index.tsx index 6419a156d..6eadc8838 100644 --- a/client/src/screens/InstallPackage/index.tsx +++ b/client/src/screens/InstallPackage/index.tsx @@ -588,7 +588,7 @@ function PkgRow({ {!busy && !entry.lastResult?.ok && entry.lastResult?.netDiag && ( )} - {/* A fake PS5 GAME on firmware above 11.60 installs but cannot be + {/* A fake PS5 GAME on firmware above 13.60 installs but cannot be played. Not shown for a retail-signed package, PS4, or homebrew. */} {!installed && entry.authenticity !== "retail" && ( { const { pushNotification } = await import("./notifications"); vi.mocked(pushNotification).mockClear(); const was = (conn as { ps5Kernel?: string | null }).ps5Kernel; - (conn as { ps5Kernel?: string | null }).ps5Kernel = "r229358/releases/13.60"; + (conn as { ps5Kernel?: string | null }).ps5Kernel = "r229358/releases/14.00"; inspect.mockResolvedValueOnce({ content_id: "UP9000-PPSA03671_00-X" }); jobStatus .mockResolvedValueOnce({ status: "done", dest: "/out/.ps5upload-extract-x2/G", bytes_sent: 1 }) diff --git a/scripts/i18n-source-hashes.json b/scripts/i18n-source-hashes.json index a280e892e..2f6a02ba5 100644 --- a/scripts/i18n-source-hashes.json +++ b/scripts/i18n-source-hashes.json @@ -3182,7 +3182,7 @@ "eta_h_min": "99422830 i3ZohyogvmUIlMOmUIhyquLyrwPmUIBpAFbUGcYmUICKmfi304W3Ip-x35v1", "eta_min": "913185ba yCJp5Xhs0kTGU-tkTGFCRHk1XwWkTGuJ7S5okTGkTGH8F804rGjfurisqN_L", "eta_sec": "2e304898 dsBbjAzVpjm3sPKjm3kD3EXXUr3jm3RnnMgMjm3jm3_6XV13-BCvRHRnnRnn", - "fakegame.fw.body_v2": "01413705 xP97IXfVNgW902thHKfrVweSJAhd7QGcVMzaBdEtR2vG1mWMzBrgaOx8eyf6", + "fakegame.fw.body_v3": "9accb442 ePdWD74ZJ7H1bt2B0peynL09hcVkzu5HbzR4nG7stpIJUlfST0LgndG2pBYV", "fakegame.fw.launch_v2": "454ae8aa ampeV75g0dWR-5OuE-a55Y7XhhagNQtNLRENm2jug566qUgTVJO05l2GN9OI", "fakegame.fw.more": "5d8a995a EqE7Y_DM7_lUEw53ehwGWOTgXo0d2KbJiZB2tLOAsfATMXi9QnLP2R7iFsTl", "fakegame.fw.title_v2": "bf62ad5a h22Wlmp3gW-asxgobZf_lIOPmC3E_YzLFpcKgnpTGI6XDM2BT4NREsmu3h50", @@ -3465,8 +3465,8 @@ "fpkg.make.image_body_kraken": "519ec2b5 Jy3N0v33DfycwWTE2clQnCTzd0MSryllaLsc1dW038xMzKhnVwuwwHbLERfT", "fpkg.make.image_title": "2463a9fb w_inKXmcC6_FeftC2QPytfH5tsHmRPeW-1J0WgibNcYlAVUr8DWwTRKy44-D", "fpkg.make.pick_game": "d10a603a XqXcbOT-qTHDsmeUAzM8PZZgXgg3envNjczM2xhJf9LfF9WXL9TTg9BvVTzL", - "fpkg.make.pkg_body_kraken": "cec4eb04 FCvD5UfuoKl90ZUViBWEMTcB44b_QAKuOfpFIrnMNh1QigtNkhYpki0BhC_G", - "fpkg.make.pkg_body_v2": "373d77b5 tX1m0HNDyCmXkVFhd9YO_iDqAQpn1yoXO-ayNakvAzpUYrlPrrZ-yzleYQYZ", + "fpkg.make.pkg_body_kraken_v2": "d94b3983 GU5c8SL2eTKkDbKVVb_wkrF20c4SEKLBRoPz-bEnnzp0d2yK0bHgfXJtcNnX", + "fpkg.make.pkg_body_v3": "c2d14ccd Rh0v_gcC4Wb0WPDsUCUrOlAv5ASRgdQLm4f8Sq3_seN2XlJWlaHtwFV2UbWt", "fpkg.make.pkg_title": "c2027abb Y4-LvjqmtqqvATqjFfYboRrGGtX3t8GRCKSKgnC6lWJDvadT18WlcnE1rE1r", "fpkg.make.ps4_pkg_body": "f070e4f9 Orx3tKagukEgn-g-_j_OXtTfwFtFLoivTfdjRWNKw9mSHXv0Bv35PkiBqxIn", "fpkg.make.ps4_pkg_title": "7a99e310 _GfKucG0m66tLLNWSYgHwYF1GWAesZFJU2qXZ-mtDUYjZxwGmPjOmfKUWKUW", @@ -6031,8 +6031,8 @@ "pkglib.external.title": "9819a63f DgqbKSQzOX27n7g0GUp8g1v-vgwWrEAq6VcnGf4YeqR9gVNofcssju3h9Bza", "pkglib.footer.count": "d547bf5b 2Onk5MjuoyGiZohPr_Z7x21PgxQgF_WiqWm7d_LRc2IBpgcAgxQdlFtq7l69", "pkglib.footer.size": "477cdf4e 1EXXgUvegreg-tO35MnOOtl8xzf_XzTy8sWIq4RTVZWtEpE-ii69yk6uqhMY", - "pkglib.fpkgsupport.firmware_v2": "4e840782 9PmgQ51gMQvoOcbzqckTKmGS0ZVVS40yFCLrOh6fJQIOQqOWaKMKEfxiWL9w", - "pkglib.fpkgsupport.kstuff": "603b2ef6 9XTvCw1WHPmgf_TK5Wvu1nvUFTzRqfIGmpMutDfajca8Eips0JI_cHGSmFSt", + "pkglib.fpkgsupport.firmware_v3": "5ce20e0e d6yOMWkYRX5zHYzfRgvpPv4zYge1IeXdgdM0VAZ-PphQJNBxau8V3Hdziufl", + "pkglib.fpkgsupport.kstuff_v2": "7505faf5 2UJIn28xhRnEQV-s4DbNDT_fZGxMAWkM9PO4a5hwPIqDXeYDjqWJ0TEQ1j0z", "pkglib.fpkgsupport.lead": "96a7b193 6Pw8RqkaDaOvqmN8-s1bdaa351Div1NLXn6PVs7ykQxQpA8uR__3h7osy8GN", "pkglib.fpkgsupport.ppr": "d23b99e4 CEoHAhECEhq5Lk2q2CiVHqXuOKWuONN5t7t8ByXIWC6U8HMBxrrT_VjlXmje", "pkglib.fpkgsupport.ppr_where": "1d3a3fca TaMeQeYPoxF8YBFVzFV-OFZz25BZfZxPWHX0rLSoa_Fm0ljHPpBXfmCWmghH", From 9e56801163b5024c7cb0875ca8cdc9033aead464 Mon Sep 17 00:00:00 2001 From: phantomptr Date: Tue, 24 Nov 2026 22:14:09 -0800 Subject: [PATCH 02/12] Saves: show backup times in the device's time zone (#928) Backup stamps are UTC names from the engine; the backups list, restore confirm, restored notice and copy-to-user dialog printed them as-is with "UTC". Parse the stamp as UTC and format it with the app's date helper in local time. Stored names and restore keys are unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- .../src/screens/GameHub/SaveBackupsList.tsx | 13 ++++--- client/src/screens/GameHub/stampLabel.test.ts | 35 +++++++++++++++++++ client/src/state/autoSaveBackup.test.ts | 6 ---- 3 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 client/src/screens/GameHub/stampLabel.test.ts diff --git a/client/src/screens/GameHub/SaveBackupsList.tsx b/client/src/screens/GameHub/SaveBackupsList.tsx index 98e24d66f..5735dddfd 100644 --- a/client/src/screens/GameHub/SaveBackupsList.tsx +++ b/client/src/screens/GameHub/SaveBackupsList.tsx @@ -10,6 +10,8 @@ import CopyToUserDialog, { targetName } from "../Saves/CopyToUserDialog"; import { partMissingText } from "../Saves/partMissing"; import { copyTargets, type CopyTarget } from "../Saves/copyTargets"; import { formatBytes } from "../../lib/format"; +import { formatDate } from "../../lib/formatDate"; +import { stampMs } from "../Saves/backupStatus"; import { hostOf } from "../../lib/addr"; import { pushNotification } from "../../state/notifications"; import { useAutoSaveBackupStore } from "../../state/autoSaveBackup"; @@ -19,10 +21,13 @@ import { useTr } from "../../state/lang"; /** How many versions a save shows before "show all". */ const SHOWN = 3; -/** `2026-10-24_101500` → `2026-10-24 10:15 UTC` (a snapshot's `_snap` after it is dropped). */ -export function stampLabel(stamp: string): string { - const m = /^(\d{4}-\d{2}-\d{2})_(\d{2})(\d{2})\d{2}(?:_[a-z]+)?$/.exec(stamp); - return m ? `${m[1]} ${m[2]}:${m[3]} UTC` : stamp; +/** A backup stamp (`2026-10-24_101500`, UTC as the engine names it; a snapshot's `_snap` is + * ignored) as a date and time in this device's time zone and the app's language (#928). + * The stamp itself is the backup's name and is never changed; anything else shows as is. */ +export function stampLabel(stamp: string, lang?: string): string { + if (!/^\d{4}-\d{2}-\d{2}_\d{6}(?:_[a-z]+)?$/.test(stamp)) return stamp; + const ms = stampMs(stamp); + return ms === null ? stamp : formatDate(ms, "datetime", lang) || stamp; } /** A backup in this computer's backup folder, on the network share (#592), or the copy on the diff --git a/client/src/screens/GameHub/stampLabel.test.ts b/client/src/screens/GameHub/stampLabel.test.ts new file mode 100644 index 000000000..ff7caebc4 --- /dev/null +++ b/client/src/screens/GameHub/stampLabel.test.ts @@ -0,0 +1,35 @@ +// #928: backup stamps are UTC names; the label shows the device's local time. +// UTC-3 with no daylight saving (Brazil since 2019). Set before any Date use. +(globalThis as unknown as { process: { env: Record } }).process.env.TZ = "America/Sao_Paulo"; + +import { describe, expect, it } from "vitest"; + +import { stampLabel } from "./SaveBackupsList"; +import { stampDate } from "../Saves/FolderBackupChoice"; + +describe("backup times in the device's time zone (#928)", () => { + it("shows 03:08 UTC as 00:08 local", () => { + expect(new Date(Date.UTC(2026, 10, 25)).getTimezoneOffset()).toBe(180); + const label = stampLabel("2026-11-25_030800", "en"); + expect(label).toBe("Nov 25, 2026, 12:08 AM"); + expect(label).not.toContain("UTC"); + }); + + it("moves to the previous day when local midnight hasn't passed", () => { + expect(stampLabel("2026-11-25_020000", "en")).toBe("Nov 24, 2026, 11:00 PM"); + }); + + it("drops a snapshot suffix and uses the app's language", () => { + expect(stampLabel("2026-11-25_030800_snap", "en")).toBe("Nov 25, 2026, 12:08 AM"); + expect(stampLabel("2026-11-25_150800", "de")).toBe("25. Nov. 2026, 12:08"); + }); + + it("parses the stamp as UTC for the folder backups list too", () => { + expect(stampDate("2026-11-25_030800")?.toISOString()).toBe("2026-11-25T03:08:00.000Z"); + }); + + it("leaves anything that isn't a stamp as is", () => { + expect(stampLabel("odd")).toBe("odd"); + expect(stampLabel("2026-11-25_0308")).toBe("2026-11-25_0308"); + }); +}); diff --git a/client/src/state/autoSaveBackup.test.ts b/client/src/state/autoSaveBackup.test.ts index aeb1aa90e..00bb62b92 100644 --- a/client/src/state/autoSaveBackup.test.ts +++ b/client/src/state/autoSaveBackup.test.ts @@ -8,7 +8,6 @@ vi.mock("../api/saveBackup", async (importOriginal) => ({ import { backupHosts, clampKeep, legacySettings, numberBoxLeft, startSaveBackupSync } from "./autoSaveBackup"; import { useRosterStore } from "./roster"; -import { stampLabel } from "../screens/GameHub/SaveBackupsList"; describe("automatic save backup (engine-run)", () => { it("hands over an older version's settings only when a folder was set", () => { @@ -48,11 +47,6 @@ describe("automatic save backup (engine-run)", () => { expect(numberBoxLeft("999", 5, clampKeep)).toEqual({ save: 50, show: "50" }); expect(numberBoxLeft("0", 5, clampKeep)).toEqual({ save: 1, show: "1" }); }); - - it("labels a backup's time in UTC", () => { - expect(stampLabel("2026-10-24_101530")).toBe("2026-10-24 10:15 UTC"); - expect(stampLabel("odd")).toBe("odd"); - }); }); describe("giving the engine the console list", () => { From 16e951c22532ab5ba7b2c89e2bd8d912d11f3be3 Mon Sep 17 00:00:00 2001 From: phantomptr Date: Tue, 24 Nov 2026 22:16:08 -0800 Subject: [PATCH 03/12] e2e: save-copy pins a time zone and expects local backup times (#928) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- client/e2e/save-copy.spec.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/e2e/save-copy.spec.ts b/client/e2e/save-copy.spec.ts index 381d09b51..295f28f28 100644 --- a/client/e2e/save-copy.spec.ts +++ b/client/e2e/save-copy.spec.ts @@ -12,6 +12,10 @@ const CY = 0x30000000; const folder = (u: number) => `/user/home/${u.toString(16)}/savedata_prospero/${T}`; const BACKUP = `${T}_user10000000_2026-10-30_120000.zip`; +// Backup times show in the device's own time zone (#928): pin one so the text is known. +// 12:00 UTC is 09:00 in São Paulo (UTC-3, no daylight saving). +test.use({ timezoneId: "America/Sao_Paulo", locale: "en-US" }); + function mockEngine() { const calls = { copyConsole: [] as unknown[], copy: [] as unknown[], restoreTo: [] as unknown[], now: [] as unknown[], open: [] as unknown[] }; let backedUp = false; @@ -158,11 +162,11 @@ test("Copy to another user, Back up now, then Restore to another user", async ({ // Restore… lists that backup as one row, with Restore to another user. await ann.getByTestId("save-restore-pick").click(); const dialog = page.getByTestId("save-restore-dialog"); - await expect(dialog.getByText(/2026-10-30 12:00 UTC/)).toHaveCount(1); + await expect(dialog.getByText(/Oct 30, 2026, 9:00\sAM/)).toHaveCount(1); await dialog.getByTestId("save-backup-restore-to-user").click(); await page.locator('[data-testid="copy-user-target"][data-has-save="true"]').click(); await page.getByTestId("copy-user-replace").click(); - await expect(page.getByTestId("copy-user-done")).toContainText("now has the backup from 2026-10-30 12:00 UTC"); + await expect(page.getByTestId("copy-user-done")).toContainText(/now has the backup from Oct 30, 2026, 9:00\sAM/); expect(calls.restoreTo).toEqual([{ addr: HOST, title_id: T, file: BACKUP, to_user: BEN, server: false }]); }); From f7b3e5bc49800fa432c1b2a0637428f1e9529817 Mon Sep 17 00:00:00 2001 From: Enrique Wood Date: Tue, 24 Nov 2026 21:17:55 -0300 Subject: [PATCH 04/12] feat(saves): include EglantinePS5 in automatic backups --- FAQ.md | 10 + client/e2e/switch-saves.spec.ts | 26 +++ client/src/api/saveBackup.ts | 10 +- client/src/i18n/locales/ar.ts | 6 +- client/src/i18n/locales/bn.ts | 6 +- client/src/i18n/locales/de.ts | 6 +- client/src/i18n/locales/en.ts | 6 +- client/src/i18n/locales/es.ts | 6 +- client/src/i18n/locales/fa.ts | 6 +- client/src/i18n/locales/fr.ts | 6 +- client/src/i18n/locales/hi.ts | 6 +- client/src/i18n/locales/hu.ts | 6 +- client/src/i18n/locales/id.ts | 6 +- client/src/i18n/locales/it.ts | 6 +- client/src/i18n/locales/ja.ts | 6 +- client/src/i18n/locales/ko.ts | 6 +- client/src/i18n/locales/pl.ts | 6 +- client/src/i18n/locales/pt-BR.ts | 6 +- client/src/i18n/locales/ru.ts | 6 +- client/src/i18n/locales/th.ts | 6 +- client/src/i18n/locales/tr.ts | 6 +- client/src/i18n/locales/vi.ts | 6 +- client/src/i18n/locales/zh-CN.ts | 6 +- client/src/i18n/locales/zh-TW.ts | 6 +- client/src/screens/Saves/SwitchSaves.tsx | 38 +++- .../ps5upload-engine/src/emulator_saves.rs | 194 +++++++++++++++--- .../ps5upload-engine/src/save_backup.rs | 43 +++- .../src/save_backup_server.rs | 46 +++++ scripts/i18n-source-hashes.json | 6 +- 29 files changed, 390 insertions(+), 109 deletions(-) diff --git a/FAQ.md b/FAQ.md index 0bdf67940..aa48e212d 100644 --- a/FAQ.md +++ b/FAQ.md @@ -699,6 +699,16 @@ known), per profile ("Console" is the console's own save), with Back up now and put one back, close ProsperoEden and press Restore on the version you want; the save there now is backed up first. A restore is refused while ProsperoEden runs. +EglantinePS5 (PPSA98515) is included too. Its saves stay in +`/data/eglantineps5/user/nand/user/save/0000000000000000///`, +regardless of where its games are kept. Each profile and game's folder is backed up by the same +local, console-drive and server passes, including after EglantinePS5 closes. Save Data lists them +in their own “Switch games (EglantinePS5)” group. A restore waits for EglantinePS5 to close and +backs up the save there first. Its backups have their own profile numbers, so +copies of the same game and profile in ProsperoEden stay separate, including retention. The +profile label still shows the emulator's profile, and older ProsperoEden backup names stay valid. + + The saves of the PS2 emulators Crux2 (PPSA99249) and PS5SX2 (PPSA99203) are backed up the same way, after the emulator closes: its memory cards folder and its saved states folder, each as one save under the emulator's own title ID (user 0 the cards, user 1 the saved states). Crux2 keeps diff --git a/client/e2e/switch-saves.spec.ts b/client/e2e/switch-saves.spec.ts index d5278719a..c64de72f5 100644 --- a/client/e2e/switch-saves.spec.ts +++ b/client/e2e/switch-saves.spec.ts @@ -129,3 +129,29 @@ test("Saves shows no Switch group when ProsperoEden has no saves", async ({ page await expect(page.locator('[data-title-id="PPSA01234"]')).toBeVisible({ timeout: 30_000 }); await expect(page.getByTestId("switch-saves")).toHaveCount(0); }); + + +test("Eglantine and Eden show independent groups and backup histories", async ({ page }) => { + const eglantineRoot = "/data/eglantineps5/user/nand/user/save/0000000000000000"; + const saves = [ + { title_id: GAME, user_id: 0x01f1e1d1, path: `${ROOT}/${PROFILE}/${GAME}`, size: 17, mtime: 1761800000, kind: "switch", emulator: "ProsperoEden", running: true }, + { title_id: GAME, user_id: 0x11f1e1d1, path: `${eglantineRoot}/${PROFILE}/${GAME}`, size: 20, mtime: 1761800000, kind: "switch", emulator: "EglantinePS5", running: false }, + { title_id: GAME, user_id: 0x10000000, path: `${eglantineRoot}/${"0".repeat(32)}/${GAME}`, size: 3, mtime: 1761800000, kind: "switch", emulator: "EglantinePS5", running: false }, + ]; + const { handler } = mockEngine(saves, true); + await page.addInitScript((h) => window.localStorage.setItem("ps5upload.host", h), HOST); + await page.route((url) => url.pathname.startsWith("/api/"), handler); + await page.goto("/saves", { waitUntil: "domcontentloaded" }); + const eden = page.locator('[data-testid="switch-saves"][data-emulator="ProsperoEden"]'); + const eglantine = page.locator('[data-testid="switch-saves"][data-emulator="EglantinePS5"]'); + await expect(eglantine.getByRole("heading", { name: "Switch games (EglantinePS5)" })).toBeVisible({ timeout: 30_000 }); + await expect(eden.getByTestId("switch-saves-note")).toHaveText("ProsperoEden is running. Close it before restoring."); + await expect(eglantine.getByTestId("switch-saves-note")).toHaveText("Close EglantinePS5 before restoring."); + const rows = eglantine.getByTestId("switch-save"); + await expect(rows.nth(0)).toContainText("Profile 1F1E1D1"); + await expect(rows.nth(1)).toContainText("Console"); + // Eden's backup of the exact same game and profile must not appear under Eglantine. + await expect(eden.getByRole("button", { name: "Restore", exact: true })).toHaveCount(1); + await expect(eglantine.getByRole("button", { name: "Restore", exact: true })).toHaveCount(0); + await expect(rows.nth(0)).toContainText("No backups yet."); +}); diff --git a/client/src/api/saveBackup.ts b/client/src/api/saveBackup.ts index ee6d09956..55b75f5de 100644 --- a/client/src/api/saveBackup.ts +++ b/client/src/api/saveBackup.ts @@ -322,8 +322,8 @@ export const saveFoldersApi = { call<{ ok: boolean }>("/folders/restore", { ...LONG, method: "POST", body: JSON.stringify(req) }), }; -/** A save of ProsperoEden, the Switch emulator (PPSA99008): `title_id` is the game's 16-hex-digit - * title ID and `user_id` its profile's first 7 hex digits (0 for the console's own save). */ +/** A Switch emulator's per-game save. `user_id` keeps the profile's first 7 hex digits + * in its lower 28 bits; bit 28 separates EglantinePS5 backups from ProsperoEden. */ export interface SwitchSave { title_id: string; user_id: number; @@ -331,7 +331,9 @@ export interface SwitchSave { size: number; mtime: number; kind: "switch"; - /** ProsperoEden runs now; null when the console did not say. */ + /** Omitted by engines that only know ProsperoEden. */ + emulator?: string; + /** This save's emulator runs now; null when the console did not say. */ running: boolean | null; } @@ -405,7 +407,7 @@ export const saveBackupApi = { /** The newest backup of each game and user in the backup folder. */ latest: async () => (await call<{ latest: Array<{ title_id: string; user_id: number; stamp: string }> }>("/latest")).latest, - /** ProsperoEden's saves on a console (bare IP): none when it is not installed. */ + /** Switch emulators' saves on a console (bare IP): none when neither has saved. */ switchSaves: (addr: string) => call<{ saves: SwitchSave[]; running: boolean | null }>(`/switch?addr=${encodeURIComponent(addr)}`), /** The PlayStation 2 emulators' and PSSwanStation's cards and saved states on a console (bare diff --git a/client/src/i18n/locales/ar.ts b/client/src/i18n/locales/ar.ts index 590642f52..fad7ef27b 100644 --- a/client/src/i18n/locales/ar.ts +++ b/client/src/i18n/locales/ar.ts @@ -7696,9 +7696,9 @@ helper_copies_failed_body: "لا يزال المساعد القديم: {list}. "rp_keyboard_hint": "Enter: تم. Esc: إلغاء. أثناء الكتابة هنا لا تصل أي مفاتيح أو ضغطات من وحدة التحكم إلى اللعبة.", "rp_settings_paused": "لا تصل أي مفاتيح أو ضغطات من وحدة التحكم إلى اللعبة ما دامت الإعدادات مفتوحة.", "rp_picture_tools": "أدوات الصورة", - "saves_switch_title": "ألعاب Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden يعمل. أغلقه قبل الاستعادة.", - "saves_switch_close_note": "أغلق ProsperoEden قبل الاستعادة.", + "saves_switch_title": "ألعاب Switch ({emulator})", + "saves_switch_running": "{emulator} يعمل. أغلقه قبل الاستعادة.", + "saves_switch_close_note": "أغلق {emulator} قبل الاستعادة.", "saves_switch_badge": "Switch", "saves_switch_console": "الجهاز", "saves_switch_profile": "الملف الشخصي {id}", diff --git a/client/src/i18n/locales/bn.ts b/client/src/i18n/locales/bn.ts index 1a7c5459e..fa2ce079c 100644 --- a/client/src/i18n/locales/bn.ts +++ b/client/src/i18n/locales/bn.ts @@ -7696,9 +7696,9 @@ helper_copies_failed_body: "এখনও পুরোনো হেল্পা "rp_keyboard_hint": "Enter: হয়ে গেছে। Esc: বাতিল। আপনি এখানে টাইপ করার সময় গেম কোনো কী বা কন্ট্রোলার চাপ পায় না।", "rp_settings_paused": "সেটিংস খোলা থাকাকালীন গেম কোনো কী বা কন্ট্রোলারের চাপ পায় না।", "rp_picture_tools": "ছবির টুল", - "saves_switch_title": "Switch গেম (ProsperoEden)", - "saves_switch_running": "ProsperoEden চলছে। রিস্টোর করার আগে এটি বন্ধ করুন।", - "saves_switch_close_note": "রিস্টোর করার আগে ProsperoEden বন্ধ করুন।", + "saves_switch_title": "Switch গেম ({emulator})", + "saves_switch_running": "{emulator} চলছে। রিস্টোর করার আগে এটি বন্ধ করুন।", + "saves_switch_close_note": "রিস্টোর করার আগে {emulator} বন্ধ করুন।", "saves_switch_badge": "Switch", "saves_switch_console": "কনসোল", "saves_switch_profile": "প্রোফাইল {id}", diff --git a/client/src/i18n/locales/de.ts b/client/src/i18n/locales/de.ts index 0efc2a0b7..3e6a685aa 100644 --- a/client/src/i18n/locales/de.ts +++ b/client/src/i18n/locales/de.ts @@ -7704,9 +7704,9 @@ helper_copies_failed_body: "Weiterhin der alte Helfer: {list}. Die PS5 startet i "rp_keyboard_hint": "Enter: fertig. Esc: abbrechen. Während du hier tippst, bekommt das Spiel keine Tasten und keine Controller-Eingaben.", "rp_settings_paused": "Solange die Einstellungen offen sind, bekommt das Spiel keine Tasten und keine Controller-Eingaben.", "rp_picture_tools": "Bildwerkzeuge", - "saves_switch_title": "Switch-Spiele (ProsperoEden)", - "saves_switch_running": "ProsperoEden läuft. Schließe es vor dem Wiederherstellen.", - "saves_switch_close_note": "Schließe ProsperoEden vor dem Wiederherstellen.", + "saves_switch_title": "Switch-Spiele ({emulator})", + "saves_switch_running": "{emulator} läuft. Schließe es vor dem Wiederherstellen.", + "saves_switch_close_note": "Schließe {emulator} vor dem Wiederherstellen.", "saves_switch_badge": "Switch", "saves_switch_console": "Konsole", "saves_switch_profile": "Profil {id}", diff --git a/client/src/i18n/locales/en.ts b/client/src/i18n/locales/en.ts index 48b5bc71b..c83e17766 100644 --- a/client/src/i18n/locales/en.ts +++ b/client/src/i18n/locales/en.ts @@ -8005,9 +8005,9 @@ helper_copies_failed_body: "Still the old helper: {list}. The PS5 starts it agai "rp_keyboard_hint": "Enter: done. Esc: cancel. While you type here, the game gets no keys or controller presses.", "rp_settings_paused": "The game gets no keys or controller presses while Settings is open.", "rp_picture_tools": "Picture tools", - "saves_switch_title": "Switch games (ProsperoEden)", - "saves_switch_running": "ProsperoEden is running. Close it before restoring.", - "saves_switch_close_note": "Close ProsperoEden before restoring.", + "saves_switch_title": "Switch games ({emulator})", + "saves_switch_running": "{emulator} is running. Close it before restoring.", + "saves_switch_close_note": "Close {emulator} before restoring.", "saves_switch_badge": "Switch", "saves_switch_console": "Console", "saves_switch_profile": "Profile {id}", diff --git a/client/src/i18n/locales/es.ts b/client/src/i18n/locales/es.ts index 793df80bb..7e6112ce6 100644 --- a/client/src/i18n/locales/es.ts +++ b/client/src/i18n/locales/es.ts @@ -7649,9 +7649,9 @@ helper_copies_failed_body: "Sigue siendo el ayudante antiguo: {list}. La PS5 lo "rp_keyboard_hint": "Intro: listo. Esc: cancelar. Mientras escribes aquí, el juego no recibe teclas ni pulsaciones del mando.", "rp_settings_paused": "El juego no recibe teclas ni pulsaciones del mando mientras los ajustes están abiertos.", "rp_picture_tools": "Herramientas de imagen", - "saves_switch_title": "Juegos de Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden está abierto. Ciérralo antes de restaurar.", - "saves_switch_close_note": "Cierra ProsperoEden antes de restaurar.", + "saves_switch_title": "Juegos de Switch ({emulator})", + "saves_switch_running": "{emulator} está abierto. Ciérralo antes de restaurar.", + "saves_switch_close_note": "Cierra {emulator} antes de restaurar.", "saves_switch_badge": "Switch", "saves_switch_console": "Consola", "saves_switch_profile": "Perfil {id}", diff --git a/client/src/i18n/locales/fa.ts b/client/src/i18n/locales/fa.ts index efb9e6bd6..2aa60dae4 100644 --- a/client/src/i18n/locales/fa.ts +++ b/client/src/i18n/locales/fa.ts @@ -7974,9 +7974,9 @@ helper_copies_failed_body: "هنوز کمک‌یار قدیمی است: {list}. "rp_keyboard_hint": "Enter: تمام. Esc: لغو. تا وقتی اینجا تایپ می‌کنید، بازی هیچ کلید یا فشار دسته‌ای دریافت نمی‌کند.", "rp_settings_paused": "تا وقتی تنظیمات باز است، بازی هیچ کلید یا فشار دسته‌ای دریافت نمی‌کند.", "rp_picture_tools": "ابزارهای تصویر", - "saves_switch_title": "بازی‌های Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden در حال اجراست. پیش از بازیابی آن را ببندید.", - "saves_switch_close_note": "پیش از بازیابی ProsperoEden را ببندید.", + "saves_switch_title": "بازی‌های Switch ({emulator})", + "saves_switch_running": "{emulator} در حال اجراست. پیش از بازیابی آن را ببندید.", + "saves_switch_close_note": "پیش از بازیابی {emulator} را ببندید.", "saves_switch_badge": "Switch", "saves_switch_console": "کنسول", "saves_switch_profile": "پروفایل {id}", diff --git a/client/src/i18n/locales/fr.ts b/client/src/i18n/locales/fr.ts index 4571a4a28..21737c0f0 100644 --- a/client/src/i18n/locales/fr.ts +++ b/client/src/i18n/locales/fr.ts @@ -7712,9 +7712,9 @@ helper_copies_failed_body: "Toujours l'ancien assistant : {list}. La PS5 le rela "rp_keyboard_hint": "Entrée : terminé. Échap : annuler. Pendant la saisie ici, le jeu ne reçoit ni touches ni appuis de manette.", "rp_settings_paused": "Le jeu ne reçoit ni touches ni appuis de manette tant que les réglages sont ouverts.", "rp_picture_tools": "Outils d'image", - "saves_switch_title": "Jeux Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden est ouvert. Fermez-le avant de restaurer.", - "saves_switch_close_note": "Fermez ProsperoEden avant de restaurer.", + "saves_switch_title": "Jeux Switch ({emulator})", + "saves_switch_running": "{emulator} est ouvert. Fermez-le avant de restaurer.", + "saves_switch_close_note": "Fermez {emulator} avant de restaurer.", "saves_switch_badge": "Switch", "saves_switch_console": "Console", "saves_switch_profile": "Profil {id}", diff --git a/client/src/i18n/locales/hi.ts b/client/src/i18n/locales/hi.ts index 4ad50b2f2..be1ab53a4 100644 --- a/client/src/i18n/locales/hi.ts +++ b/client/src/i18n/locales/hi.ts @@ -7710,9 +7710,9 @@ helper_copies_failed_body: "अब भी पुराना हेल्पर: "rp_keyboard_hint": "Enter: हो गया। Esc: रद्द करें। जब तक आप यहाँ टाइप करते हैं, गेम को कोई कुंजी या कंट्रोलर दबाव नहीं मिलता।", "rp_settings_paused": "सेटिंग्स खुली रहने तक गेम को कोई कुंजी या कंट्रोलर का दबाव नहीं मिलता।", "rp_picture_tools": "चित्र के टूल", - "saves_switch_title": "Switch गेम (ProsperoEden)", - "saves_switch_running": "ProsperoEden चल रहा है। रीस्टोर करने से पहले इसे बंद करें।", - "saves_switch_close_note": "रीस्टोर करने से पहले ProsperoEden बंद करें।", + "saves_switch_title": "Switch गेम ({emulator})", + "saves_switch_running": "{emulator} चल रहा है। रीस्टोर करने से पहले इसे बंद करें।", + "saves_switch_close_note": "रीस्टोर करने से पहले {emulator} बंद करें।", "saves_switch_badge": "Switch", "saves_switch_console": "कंसोल", "saves_switch_profile": "प्रोफ़ाइल {id}", diff --git a/client/src/i18n/locales/hu.ts b/client/src/i18n/locales/hu.ts index a577546ae..ebc683985 100644 --- a/client/src/i18n/locales/hu.ts +++ b/client/src/i18n/locales/hu.ts @@ -7988,9 +7988,9 @@ helper_copies_failed_body: "Még mindig a régi segédprogram: {list}. A PS5 min "rp_keyboard_hint": "Enter: kész. Esc: mégse. Amíg itt gépelsz, a játék nem kap billentyűt és kontrollergombot.", "rp_settings_paused": "Amíg a Beállítások nyitva vannak, a játék nem kap billentyűt és kontrollergombot.", "rp_picture_tools": "Képeszközök", - "saves_switch_title": "Switch-játékok (ProsperoEden)", - "saves_switch_running": "A ProsperoEden fut. Zárd be visszaállítás előtt.", - "saves_switch_close_note": "Zárd be a ProsperoEdent visszaállítás előtt.", + "saves_switch_title": "Switch-játékok ({emulator})", + "saves_switch_running": "A {emulator} fut. Zárd be visszaállítás előtt.", + "saves_switch_close_note": "Zárd be a {emulator}t visszaállítás előtt.", "saves_switch_badge": "Switch", "saves_switch_console": "Konzol", "saves_switch_profile": "{id} profil", diff --git a/client/src/i18n/locales/id.ts b/client/src/i18n/locales/id.ts index 640cc78d9..a3b92c09d 100644 --- a/client/src/i18n/locales/id.ts +++ b/client/src/i18n/locales/id.ts @@ -7705,9 +7705,9 @@ helper_copies_failed_body: "Masih helper lama: {list}. PS5 menjalankannya lagi s "rp_keyboard_hint": "Enter: selesai. Esc: batal. Selama Anda mengetik di sini, game tidak menerima tombol keyboard atau kontroler.", "rp_settings_paused": "Game tidak menerima tombol keyboard atau kontroler selama Pengaturan terbuka.", "rp_picture_tools": "Alat gambar", - "saves_switch_title": "Game Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden sedang berjalan. Tutup sebelum memulihkan.", - "saves_switch_close_note": "Tutup ProsperoEden sebelum memulihkan.", + "saves_switch_title": "Game Switch ({emulator})", + "saves_switch_running": "{emulator} sedang berjalan. Tutup sebelum memulihkan.", + "saves_switch_close_note": "Tutup {emulator} sebelum memulihkan.", "saves_switch_badge": "Switch", "saves_switch_console": "Konsol", "saves_switch_profile": "Profil {id}", diff --git a/client/src/i18n/locales/it.ts b/client/src/i18n/locales/it.ts index 4d7236bfe..0449c079a 100644 --- a/client/src/i18n/locales/it.ts +++ b/client/src/i18n/locales/it.ts @@ -7649,9 +7649,9 @@ helper_copies_failed_body: "Ancora il vecchio helper: {list}. La PS5 lo riavvia "rp_keyboard_hint": "Invio: fatto. Esc: annulla. Mentre scrivi qui, il gioco non riceve tasti né pressioni del controller.", "rp_settings_paused": "Mentre le Impostazioni sono aperte il gioco non riceve tasti né pressioni del controller.", "rp_picture_tools": "Strumenti immagine", - "saves_switch_title": "Giochi Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden è aperto. Chiudilo prima di ripristinare.", - "saves_switch_close_note": "Chiudi ProsperoEden prima di ripristinare.", + "saves_switch_title": "Giochi Switch ({emulator})", + "saves_switch_running": "{emulator} è aperto. Chiudilo prima di ripristinare.", + "saves_switch_close_note": "Chiudi {emulator} prima di ripristinare.", "saves_switch_badge": "Switch", "saves_switch_console": "Console", "saves_switch_profile": "Profilo {id}", diff --git a/client/src/i18n/locales/ja.ts b/client/src/i18n/locales/ja.ts index fcf3d6e8b..a1a7c9238 100644 --- a/client/src/i18n/locales/ja.ts +++ b/client/src/i18n/locales/ja.ts @@ -7715,9 +7715,9 @@ helper_copies_failed_body: "古いヘルパーのままです: {list}。PS5 は "rp_keyboard_hint": "Enter で完了、Esc でキャンセル。ここで入力している間、キーやコントローラーの入力はゲームに送られません。", "rp_settings_paused": "設定を開いている間、キーやコントローラーの入力はゲームに送られません。", "rp_picture_tools": "映像ツール", - "saves_switch_title": "Switch のゲーム (ProsperoEden)", - "saves_switch_running": "ProsperoEden が起動中です。復元する前に閉じてください。", - "saves_switch_close_note": "復元する前に ProsperoEden を閉じてください。", + "saves_switch_title": "Switch のゲーム ({emulator})", + "saves_switch_running": "{emulator} が起動中です。復元する前に閉じてください。", + "saves_switch_close_note": "復元する前に {emulator} を閉じてください。", "saves_switch_badge": "Switch", "saves_switch_console": "本体", "saves_switch_profile": "プロファイル {id}", diff --git a/client/src/i18n/locales/ko.ts b/client/src/i18n/locales/ko.ts index 534c0e80b..51abde740 100644 --- a/client/src/i18n/locales/ko.ts +++ b/client/src/i18n/locales/ko.ts @@ -7713,9 +7713,9 @@ helper_copies_failed_body: "여전히 이전 헬퍼입니다: {list}. PS5는 재 "rp_keyboard_hint": "Enter: 완료, Esc: 취소. 여기에 입력하는 동안 게임에는 키나 컨트롤러 입력이 전달되지 않습니다.", "rp_settings_paused": "설정이 열려 있는 동안에는 키와 컨트롤러 입력이 게임에 전달되지 않습니다.", "rp_picture_tools": "화면 도구", - "saves_switch_title": "Switch 게임 (ProsperoEden)", - "saves_switch_running": "ProsperoEden이 실행 중입니다. 복원하기 전에 닫으세요.", - "saves_switch_close_note": "복원하기 전에 ProsperoEden을 닫으세요.", + "saves_switch_title": "Switch 게임 ({emulator})", + "saves_switch_running": "{emulator}이 실행 중입니다. 복원하기 전에 닫으세요.", + "saves_switch_close_note": "복원하기 전에 {emulator}을 닫으세요.", "saves_switch_badge": "Switch", "saves_switch_console": "본체", "saves_switch_profile": "프로필 {id}", diff --git a/client/src/i18n/locales/pl.ts b/client/src/i18n/locales/pl.ts index fa49fecb8..d2cb72a17 100644 --- a/client/src/i18n/locales/pl.ts +++ b/client/src/i18n/locales/pl.ts @@ -7933,9 +7933,9 @@ helper_copies_failed_body: "Nadal stary pomocnik: {list}. PS5 uruchamia go ponow "rp_keyboard_hint": "Enter: gotowe. Esc: anuluj. Gdy piszesz tutaj, gra nie dostaje klawiszy ani naciśnięć kontrolera.", "rp_settings_paused": "Gdy Ustawienia są otwarte, gra nie dostaje klawiszy ani przycisków kontrolera.", "rp_picture_tools": "Narzędzia obrazu", - "saves_switch_title": "Gry Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden jest uruchomiony. Zamknij go przed przywróceniem.", - "saves_switch_close_note": "Zamknij ProsperoEden przed przywróceniem.", + "saves_switch_title": "Gry Switch ({emulator})", + "saves_switch_running": "{emulator} jest uruchomiony. Zamknij go przed przywróceniem.", + "saves_switch_close_note": "Zamknij {emulator} przed przywróceniem.", "saves_switch_badge": "Switch", "saves_switch_console": "Konsola", "saves_switch_profile": "Profil {id}", diff --git a/client/src/i18n/locales/pt-BR.ts b/client/src/i18n/locales/pt-BR.ts index 191d64f52..71f63929c 100644 --- a/client/src/i18n/locales/pt-BR.ts +++ b/client/src/i18n/locales/pt-BR.ts @@ -7711,9 +7711,9 @@ helper_copies_failed_body: "Ainda é o auxiliar antigo: {list}. O PS5 o inicia d "rp_keyboard_hint": "Enter: concluir. Esc: cancelar. Enquanto você digita aqui, o jogo não recebe teclas nem botões do controle.", "rp_settings_paused": "O jogo não recebe teclas nem botões do controle enquanto as Configurações estão abertas.", "rp_picture_tools": "Ferramentas de imagem", - "saves_switch_title": "Jogos de Switch (ProsperoEden)", - "saves_switch_running": "O ProsperoEden está aberto. Feche-o antes de restaurar.", - "saves_switch_close_note": "Feche o ProsperoEden antes de restaurar.", + "saves_switch_title": "Jogos de Switch ({emulator})", + "saves_switch_running": "O {emulator} está aberto. Feche-o antes de restaurar.", + "saves_switch_close_note": "Feche o {emulator} antes de restaurar.", "saves_switch_badge": "Switch", "saves_switch_console": "Console", "saves_switch_profile": "Perfil {id}", diff --git a/client/src/i18n/locales/ru.ts b/client/src/i18n/locales/ru.ts index 768e02fd4..e403ececf 100644 --- a/client/src/i18n/locales/ru.ts +++ b/client/src/i18n/locales/ru.ts @@ -7649,9 +7649,9 @@ helper_copies_failed_body: "По-прежнему старый помощник: "rp_keyboard_hint": "Enter — готово. Esc — отмена. Пока вы печатаете здесь, игра не получает ни клавиш, ни нажатий контроллера.", "rp_settings_paused": "Пока открыты настройки, игра не получает нажатий клавиш и контроллера.", "rp_picture_tools": "Инструменты изображения", - "saves_switch_title": "Игры Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden запущен. Закройте его перед восстановлением.", - "saves_switch_close_note": "Закройте ProsperoEden перед восстановлением.", + "saves_switch_title": "Игры Switch ({emulator})", + "saves_switch_running": "{emulator} запущен. Закройте его перед восстановлением.", + "saves_switch_close_note": "Закройте {emulator} перед восстановлением.", "saves_switch_badge": "Switch", "saves_switch_console": "Консоль", "saves_switch_profile": "Профиль {id}", diff --git a/client/src/i18n/locales/th.ts b/client/src/i18n/locales/th.ts index 936a345dc..f96f97d40 100644 --- a/client/src/i18n/locales/th.ts +++ b/client/src/i18n/locales/th.ts @@ -7703,9 +7703,9 @@ helper_copies_failed_body: "ยังเป็นตัวช่วยเก่ "rp_keyboard_hint": "Enter: เสร็จ Esc: ยกเลิก ระหว่างที่พิมพ์ตรงนี้ เกมจะไม่ได้รับปุ่มคีย์บอร์ดหรือการกดจอย", "rp_settings_paused": "ขณะเปิดการตั้งค่า เกมจะไม่ได้รับการกดปุ่มคีย์บอร์ดหรือคอนโทรลเลอร์", "rp_picture_tools": "เครื่องมือภาพ", - "saves_switch_title": "เกม Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden กำลังทำงาน ปิดก่อนกู้คืน", - "saves_switch_close_note": "ปิด ProsperoEden ก่อนกู้คืน", + "saves_switch_title": "เกม Switch ({emulator})", + "saves_switch_running": "{emulator} กำลังทำงาน ปิดก่อนกู้คืน", + "saves_switch_close_note": "ปิด {emulator} ก่อนกู้คืน", "saves_switch_badge": "Switch", "saves_switch_console": "เครื่อง", "saves_switch_profile": "โปรไฟล์ {id}", diff --git a/client/src/i18n/locales/tr.ts b/client/src/i18n/locales/tr.ts index 1b212a51c..991f14d6d 100644 --- a/client/src/i18n/locales/tr.ts +++ b/client/src/i18n/locales/tr.ts @@ -7703,9 +7703,9 @@ helper_copies_failed_body: "Hâlâ eski yardımcı: {list}. PS5 her yeniden baş "rp_keyboard_hint": "Enter: bitti. Esc: iptal. Burada yazarken oyun tuş veya kumanda basışı almaz.", "rp_settings_paused": "Ayarlar açıkken oyun hiçbir tuş ya da kumanda basışı almaz.", "rp_picture_tools": "Görüntü araçları", - "saves_switch_title": "Switch oyunları (ProsperoEden)", - "saves_switch_running": "ProsperoEden açık. Geri yüklemeden önce kapatın.", - "saves_switch_close_note": "Geri yüklemeden önce ProsperoEden'i kapatın.", + "saves_switch_title": "Switch oyunları ({emulator})", + "saves_switch_running": "{emulator} açık. Geri yüklemeden önce kapatın.", + "saves_switch_close_note": "Geri yüklemeden önce {emulator}'i kapatın.", "saves_switch_badge": "Switch", "saves_switch_console": "Konsol", "saves_switch_profile": "Profil {id}", diff --git a/client/src/i18n/locales/vi.ts b/client/src/i18n/locales/vi.ts index 0928492e5..aba27e104 100644 --- a/client/src/i18n/locales/vi.ts +++ b/client/src/i18n/locales/vi.ts @@ -7698,9 +7698,9 @@ helper_copies_failed_body: "Vẫn là trình trợ giúp cũ: {list}. PS5 sẽ c "rp_keyboard_hint": "Enter: xong. Esc: hủy. Khi bạn gõ ở đây, trò chơi không nhận phím hay nút tay cầm.", "rp_settings_paused": "Khi Cài đặt đang mở, trò chơi không nhận phím hay nút tay cầm nào.", "rp_picture_tools": "Công cụ hình ảnh", - "saves_switch_title": "Game Switch (ProsperoEden)", - "saves_switch_running": "ProsperoEden đang chạy. Hãy đóng nó trước khi khôi phục.", - "saves_switch_close_note": "Đóng ProsperoEden trước khi khôi phục.", + "saves_switch_title": "Game Switch ({emulator})", + "saves_switch_running": "{emulator} đang chạy. Hãy đóng nó trước khi khôi phục.", + "saves_switch_close_note": "Đóng {emulator} trước khi khôi phục.", "saves_switch_badge": "Switch", "saves_switch_console": "Máy", "saves_switch_profile": "Hồ sơ {id}", diff --git a/client/src/i18n/locales/zh-CN.ts b/client/src/i18n/locales/zh-CN.ts index 79b2bf599..3297a7b11 100644 --- a/client/src/i18n/locales/zh-CN.ts +++ b/client/src/i18n/locales/zh-CN.ts @@ -7655,9 +7655,9 @@ helper_copies_failed_body: "仍是旧助手:{list}。PS5 每次重启后都会 "rp_keyboard_hint": "Enter:完成。Esc:取消。在这里输入时,游戏收不到按键或手柄操作。", "rp_settings_paused": "设置打开时,游戏不会收到任何按键或手柄输入。", "rp_picture_tools": "画面工具", - "saves_switch_title": "Switch 游戏(ProsperoEden)", - "saves_switch_running": "ProsperoEden 正在运行。恢复前请先关闭它。", - "saves_switch_close_note": "恢复前请先关闭 ProsperoEden。", + "saves_switch_title": "Switch 游戏({emulator})", + "saves_switch_running": "{emulator} 正在运行。恢复前请先关闭它。", + "saves_switch_close_note": "恢复前请先关闭 {emulator}。", "saves_switch_badge": "Switch", "saves_switch_console": "主机", "saves_switch_profile": "配置文件 {id}", diff --git a/client/src/i18n/locales/zh-TW.ts b/client/src/i18n/locales/zh-TW.ts index 8a700f739..f63c9553f 100644 --- a/client/src/i18n/locales/zh-TW.ts +++ b/client/src/i18n/locales/zh-TW.ts @@ -7649,9 +7649,9 @@ helper_copies_failed_body: "仍是舊助手:{list}。PS5 每次重新啟動後 "rp_keyboard_hint": "Enter:完成。Esc:取消。在這裡輸入時,遊戲收不到按鍵或控制器操作。", "rp_settings_paused": "設定開啟時,遊戲不會收到任何按鍵或控制器輸入。", "rp_picture_tools": "畫面工具", - "saves_switch_title": "Switch 遊戲(ProsperoEden)", - "saves_switch_running": "ProsperoEden 正在執行。還原前請先關閉它。", - "saves_switch_close_note": "還原前請先關閉 ProsperoEden。", + "saves_switch_title": "Switch 遊戲({emulator})", + "saves_switch_running": "{emulator} 正在執行。還原前請先關閉它。", + "saves_switch_close_note": "還原前請先關閉 {emulator}。", "saves_switch_badge": "Switch", "saves_switch_console": "主機", "saves_switch_profile": "設定檔 {id}", diff --git a/client/src/screens/Saves/SwitchSaves.tsx b/client/src/screens/Saves/SwitchSaves.tsx index f2ae9f2bb..dfee20578 100644 --- a/client/src/screens/Saves/SwitchSaves.tsx +++ b/client/src/screens/Saves/SwitchSaves.tsx @@ -19,13 +19,12 @@ import { humanizeCaught } from "../../lib/humanizeError"; /** The profile folder's number as the engine gives it (its first 7 hex digits; 0 for the * console's own save), as a label's id. */ export function profileHex(userId: number): string { - return (userId >>> 0).toString(16).toUpperCase().padStart(7, "0"); + return (userId & 0x0fffffff).toString(16).toUpperCase().padStart(7, "0"); } -/** The Switch games' saves of ProsperoEden (PPSA99008), with their backups: shown only when the +/** The Switch emulators' per-game saves, grouped by their writer: shown only when the * console has one. No game names are known, so each shows its 16-hex-digit title ID. */ export default function SwitchSaves({ host, refreshKey }: { host: string; refreshKey: number }) { - const tr = useTr(); const [saves, setSaves] = useState<SwitchSave[]>([]); useEffect(() => { @@ -42,15 +41,36 @@ export default function SwitchSaves({ host, refreshKey }: { host: string; refres }, [host, refreshKey]); if (saves.length === 0) return null; + const emulators = [...new Set(saves.map((s) => s.emulator || "ProsperoEden"))]; + return ( + <> + {emulators.map((emulator) => ( + <SwitchSaveGroup + key={emulator} + host={host} + emulator={emulator} + saves={saves.filter((s) => (s.emulator || "ProsperoEden") === emulator)} + /> + ))} + </> + ); +} + +function SwitchSaveGroup({ host, saves, emulator }: { + host: string; + saves: SwitchSave[]; + emulator: string; +}) { + const tr = useTr(); const running = saves.some((s) => s.running === true); const games = [...new Set(saves.map((s) => s.title_id))].sort(); return ( - <section className="surface-panel mt-3 p-5" data-testid="switch-saves"> + <section className="surface-panel mt-3 p-5" data-testid="switch-saves" data-emulator={emulator}> <header className="mb-1 flex items-center gap-2"> <Gamepad2 size={16} aria-hidden /> <h3 className="text-sm font-semibold"> - {tr("saves_switch_title", undefined, "Switch games (ProsperoEden)")} + {tr("saves_switch_title", { emulator }, "Switch games ({emulator})")} </h3> </header> <p @@ -63,10 +83,10 @@ export default function SwitchSaves({ host, refreshKey }: { host: string; refres {running ? tr( "saves_switch_running", - undefined, - "ProsperoEden is running. Close it before restoring.", + { emulator }, + "{emulator} is running. Close it before restoring.", ) - : tr("saves_switch_close_note", undefined, "Close ProsperoEden before restoring.")} + : tr("saves_switch_close_note", { emulator }, "Close {emulator} before restoring.")} </p> <div className="space-y-3"> {games.map((game) => ( @@ -106,7 +126,7 @@ function SwitchSaveRow({ host, save }: { host: string; save: SwitchSave }) { kind: save.kind, }; const profile = - save.user_id === 0 + (save.user_id & 0x0fffffff) === 0 ? tr("saves_switch_console", undefined, "Console") : tr("saves_switch_profile", { id: profileHex(save.user_id) }, "Profile {id}"); diff --git a/engine/crates/ps5upload-engine/src/emulator_saves.rs b/engine/crates/ps5upload-engine/src/emulator_saves.rs index 795282d69..a9c21f559 100644 --- a/engine/crates/ps5upload-engine/src/emulator_saves.rs +++ b/engine/crates/ps5upload-engine/src/emulator_saves.rs @@ -1,10 +1,10 @@ -//! The saves of ProsperoEden, the Switch emulator for the PS5 (PPSA99008, or PPSA99016 for its -//! mirror), for the automatic save backups. The emulator keeps them as plain files, not as PS5 -//! save images, one folder per profile and game: -//! `/data/prosperoeden/user/nand/user/save/0000000000000000/<profile>/<game>/`, the -//! profile as 32 hex digits (all zeros: a game's save for the whole console) and the game as its -//! 16-hex-digit title ID. That place is fixed in the emulator: the game files folder chosen in its -//! settings moves the games, keys and firmware, never the saves. +//! The saves of the Switch emulators ProsperoEden (PPSA99008, or PPSA99016 for its mirror) +//! and EglantinePS5 (PPSA98515), for the automatic save backups. Both keep plain files rather +//! than PS5 save images, one folder per profile and game: +//! `/data/prosperoeden/user/nand/user/save/0000000000000000/<profile>/<game>/`, with +//! the same layout under `/data/eglantineps5` for EglantinePS5. A profile is 32 hex digits +//! (all zeros for a game's console-wide save); a game is its 16-hex-digit title ID. These +//! locations are fixed: the game files setting moves games, keys and firmware, never saves. //! //! Each such folder that holds a file is listed among a console's saves (`kind` "switch", //! `title_id` the game's), so it is backed up, kept and restored as a PS5 save is, with two @@ -33,6 +33,48 @@ pub const MIRROR: &str = "PPSA99016"; pub const KIND: &str = "switch"; /// Where it keeps every profile's saves. pub const ROOT: &str = "/data/prosperoeden/user/nand/user/save/0000000000000000"; +/// EglantinePS5 keeps the same save layout in its own data folder. +pub const EGLANTINE_APP: &str = "PPSA98515"; +pub const EGLANTINE_ROOT: &str = "/data/eglantineps5/user/nand/user/save/0000000000000000"; +/// The lower 28 bits keep the existing profile number. Bit 28 separates Eglantine's backups +/// (names, retention and listings) from ProsperoEden's, even for the same profile and game. +const EGLANTINE_USER: i32 = 0x1000_0000; + +#[derive(Clone, Copy)] +pub(crate) struct Emulator { + pub app: &'static str, + pub name: &'static str, + root: &'static str, + user_namespace: i32, +} + +const EMULATORS: [Emulator; 2] = [ + Emulator { + app: APP, + name: "ProsperoEden", + root: ROOT, + user_namespace: 0, + }, + Emulator { + app: EGLANTINE_APP, + name: "EglantinePS5", + root: EGLANTINE_ROOT, + user_namespace: EGLANTINE_USER, + }, +]; + +/// An exact per-game save path, its writer, and its backup user number. +pub(crate) fn place_of(path: &str) -> Option<(Emulator, i32)> { + EMULATORS.iter().find_map(|emulator| { + let (profile, game) = path + .strip_prefix(emulator.root)? + .strip_prefix('/')? + .split_once('/')?; + (is_profile(profile) && is_game(game)) + .then(|| (*emulator, user_of(profile) | emulator.user_namespace)) + }) +} + /// How many folders down a game's save is looked into for its newest file. pub const DEPTH: u32 = 4; @@ -56,12 +98,9 @@ pub fn is_emulator_save(e: &SaveEntry) -> bool { e.kind == KIND || crate::ps2_saves::is_kind(&e.kind) } -/// `path` is a save folder of the emulator, `ROOT/<profile>/<game>`, and nothing past it. +/// `path` is exactly a per-game save folder under either emulator's root. pub fn is_save_path(path: &str) -> bool { - path.strip_prefix(ROOT) - .and_then(|rest| rest.strip_prefix('/')) - .and_then(|rest| rest.split_once('/')) - .is_some_and(|(profile, game)| is_profile(profile) && is_game(game)) + place_of(path).is_some() } /// The kind of emulator's save `path` is the folder of; None for a PS5 save's. @@ -73,11 +112,11 @@ pub fn kind_of_path(path: &str) -> Option<&'static str> { } } -/// The app that writes the save: ProsperoEden for its saves, the game itself for a PS5 one. (A +/// The app that writes the save: its Switch emulator, or the game itself for a PS5 save. (A /// PlayStation or PlayStation 2 emulator's saves are under its own title already.) pub fn app_of(e: &SaveEntry) -> &str { if e.kind == KIND { - APP + place_of(&e.path).map_or(APP, |(emulator, _)| emulator.app) } else { &e.title_id } @@ -144,19 +183,30 @@ fn all_pages(page: &dyn Fn(u64) -> Result<DirListing, String>) -> Result<Vec<Dir /// [`list`], with `ls` giving the entries of a folder on the console. pub fn saves_in(ls: &dyn Fn(&str) -> Result<Vec<DirEntry>, String>) -> Vec<SaveEntry> { + EMULATORS + .iter() + .flat_map(|emulator| saves_at(ls, *emulator)) + .collect() +} + +fn saves_at( + ls: &dyn Fn(&str) -> Result<Vec<DirEntry>, String>, + emulator: Emulator, +) -> Vec<SaveEntry> { let mut out = Vec::new(); - let Ok(profiles) = ls(ROOT) else { + let root = emulator.root; + let Ok(profiles) = ls(root) else { return out; }; for p in profiles .iter() .filter(|p| p.kind == "dir" && is_profile(&p.name)) { - let Ok(games) = ls(&format!("{ROOT}/{}", p.name)) else { + let Ok(games) = ls(&format!("{root}/{}", p.name)) else { continue; }; for g in games.iter().filter(|g| g.kind == "dir" && is_game(&g.name)) { - let path = format!("{ROOT}/{}/{}", p.name, g.name); + let path = format!("{root}/{}/{}", p.name, g.name); // A folder not read whole waits for the next look: its newest time could miss the // file the game wrote. let Ok((size, mtime, files)) = measure(ls, &path, g.mtime, DEPTH) else { @@ -169,7 +219,7 @@ pub fn saves_in(ls: &dyn Fn(&str) -> Result<Vec<DirEntry>, String>) -> Vec<SaveE } out.push(SaveEntry { title_id: g.name.clone(), - user_id: user_of(&p.name), + user_id: user_of(&p.name) | emulator.user_namespace, path, size: size as i64, mtime, @@ -225,6 +275,8 @@ pub struct SwitchQuery { pub struct SwitchSave { #[serde(flatten)] pub save: SaveEntry, + /// The emulator that owns this save folder. + pub emulator: &'static str, /// The emulator runs now (its saves cannot be restored meanwhile); None when the console did /// not say. pub running: Option<bool>, @@ -240,24 +292,36 @@ pub async fn get_switch(Query(q): Query<SwitchQuery>) -> Response { } let r = tokio::task::spawn_blocking(move || { let saves = list(&host); - // Only asked when there is something to restore. - let running = if saves.is_empty() { + // Asked once for each emulator that has saves, independently of the other emulator. + let mut running = std::collections::BTreeMap::new(); + let saves = saves + .into_iter() + .map(|save| { + let (emulator, _) = place_of(&save.path).expect("listed Switch save path"); + let run = *running.entry(emulator.app).or_insert_with(|| { + crate::save_backup::running_of(&host, &titles_of(emulator.app)) + .map(|t| t.is_some()) + .ok() + }); + SwitchSave { + save, + emulator: emulator.name, + running: run, + } + }) + .collect::<Vec<_>>(); + let any_running = if saves.is_empty() || saves.iter().any(|s| s.running.is_none()) { None } else { - crate::save_backup::running_of(&host, &titles_of(APP)) - .map(|t| t.is_some()) - .ok() + Some(saves.iter().any(|s| s.running == Some(true))) }; - (saves, running) + (saves, any_running) }) .await; match r { Ok((saves, running)) => Json(json!({ "running": running, "saves": saves - .into_iter() - .map(|save| SwitchSave { save, running }) - .collect::<Vec<_>>(), })) .into_response(), Err(e) => crate::save_backup::json_error(StatusCode::INTERNAL_SERVER_ERROR, e.to_string()), @@ -379,6 +443,7 @@ mod tests { let save = saves_in(&ls_of(&fs)).remove(0); let v = serde_json::to_value(SwitchSave { save, + emulator: "ProsperoEden", running: Some(true), }) .unwrap(); @@ -388,6 +453,81 @@ mod tests { assert_eq!(v["running"], true); } + #[test] + fn eglantine_and_eden_keep_the_same_game_and_profile_separate() { + let mut fs = console(); + for (path, entries) in console() { + fs.insert(path.replacen(ROOT, EGLANTINE_ROOT, 1), entries); + } + let saves = saves_in(&ls_of(&fs)); + assert_eq!(saves.len(), 4); + let eden = &saves[0]; + let eglantine = &saves[2]; + assert_eq!(eglantine.title_id, eden.title_id); + assert_eq!(eglantine.size, eden.size); + assert_eq!(eglantine.mtime, 500); + assert_eq!(eglantine.user_id, eden.user_id | EGLANTINE_USER); + assert_eq!(saves[3].user_id, EGLANTINE_USER); // console-wide save + assert_eq!(app_of(eglantine), EGLANTINE_APP); + assert_eq!(titles_of(app_of(eglantine)), [EGLANTINE_APP]); + assert_eq!(titles_of(app_of(eden)), [APP, MIRROR]); + let name = |save: &SaveEntry| { + ps5upload_core::save_archive::auto_backup_stem(&save.title_id, save.user_id as u32) + }; + assert_ne!(name(eden), name(eglantine)); + // The keep limit must never prune the other emulator's version of this profile. + let files: Vec<_> = [eden, eglantine] + .into_iter() + .flat_map(|save| { + ["2026-11-01_000000", "2026-11-02_000000"].map(|stamp| crate::save_layout::Found { + dir: GAME.into(), + name: format!("{}{stamp}.zip", name(save)), + size: 1, + }) + }) + .collect(); + for save in [eden, eglantine] { + let old = crate::save_layout::to_prune(&files, GAME, save.user_id as u32, None, 1); + assert_eq!(old.len(), 1); + assert_eq!(old[0].name, format!("{}2026-11-01_000000.zip", name(save))); + } + + assert!(saves + .iter() + .all(|s| is_save_path(&s.path) && kind_of_path(&s.path) == Some(KIND))); + let json = serde_json::to_value(SwitchSave { + save: eglantine.clone(), + emulator: "EglantinePS5", + running: Some(false), + }) + .unwrap(); + assert_eq!(json["emulator"], "EglantinePS5"); + assert_eq!(json["running"], false); + } + + #[test] + fn eglantine_is_optional_and_its_paths_are_exact() { + let mut fs: BTreeMap<_, _> = console() + .into_iter() + .map(|(p, e)| (p.replacen(ROOT, EGLANTINE_ROOT, 1), e)) + .collect(); + assert_eq!(saves_in(&ls_of(&fs)).len(), 2); + let path = format!("{EGLANTINE_ROOT}/{P1}/{GAME}"); + for bad in [ + format!("{path}/slot_00"), + format!("{path}.backup-20261124"), + format!("{EGLANTINE_ROOT}/{P1}/../{GAME}"), + path.replacen("/data/eglantineps5/", "/data/eglantineps5-other/", 1), + ] { + assert!(place_of(&bad).is_none(), "{bad}"); + } + fs.insert(path.clone(), vec![]); + assert_eq!(saves_in(&ls_of(&fs)).len(), 1); + fs.insert(path.clone(), vec![entry("slots", "dir", 0, 500)]); + fs.remove(&format!("{path}/slots")); + assert_eq!(saves_in(&ls_of(&fs)).len(), 1); // unreadable subfolder + } + #[test] fn a_big_folder_is_read_page_by_page() { let all: Vec<DirEntry> = (0..300) diff --git a/engine/crates/ps5upload-engine/src/save_backup.rs b/engine/crates/ps5upload-engine/src/save_backup.rs index f5b81d86b..512d0fab7 100644 --- a/engine/crates/ps5upload-engine/src/save_backup.rs +++ b/engine/crates/ps5upload-engine/src/save_backup.rs @@ -1741,8 +1741,15 @@ pub(crate) fn save_writer<'a>( user_id: u32, ) -> Result<Writer<'a>, String> { let ps2 = crate::ps2_saves::place_of(save_path); + let switch = crate::emulator_saves::place_of(save_path); let fits = match &ps2 { Some(p) => p.emulator.app == title_id && p.user as u32 == user_id, + None if switch.is_some() => { + save_path.ends_with(&format!("/{title_id}")) + && switch + .as_ref() + .is_some_and(|(_, user)| *user as u32 == user_id) + } None => save_path.ends_with(&format!("/{title_id}")), }; if !fits { @@ -1753,10 +1760,10 @@ pub(crate) fn save_writer<'a>( app: p.emulator.app, emulator: Some(p.emulator.name), } - } else if crate::emulator_saves::is_save_path(save_path) { + } else if let Some((emulator, _)) = switch { Writer { - app: crate::emulator_saves::APP, - emulator: Some("ProsperoEden"), + app: emulator.app, + emulator: Some(emulator.name), } } else { Writer { @@ -3462,6 +3469,36 @@ mod tests { ); } + #[test] + fn eglantine_waits_for_its_own_writer_and_restores_only_its_profile() { + let path = "/data/eglantineps5/user/nand/user/save/0000000000000000/1F1E1D1C1B1A19181716151413121110/0100F2C0115B6000"; + let entry = SaveEntry { + title_id: "0100F2C0115B6000".into(), + user_id: 0x11f1_e1d1, + path: path.into(), + size: 17, + mtime: 1000, + kind: "switch".into(), + }; + let writer = save_writer(path, &entry.title_id, entry.user_id as u32).unwrap(); + assert_eq!( + (writer.app, writer.emulator), + (crate::emulator_saves::EGLANTINE_APP, Some("EglantinePS5")) + ); + assert!(save_writer(path, &entry.title_id, 0x01f1_e1d1).is_err()); + assert!(save_writer(path, "0100000000000000", entry.user_id as u32).is_err()); + let saves = [entry]; + let busy = [crate::emulator_saves::EGLANTINE_APP.to_string()].into(); + assert!(needing_backup("h", &saves, &Done::new(), 2000, &busy).is_empty()); + for app in [crate::emulator_saves::APP, crate::emulator_saves::MIRROR] { + let busy = [app.to_string()].into(); + assert_eq!( + needing_backup("h", &saves, &Done::new(), 2000, &busy).len(), + 1 + ); + } + } + #[test] fn the_ps2_emulators_cards_and_states_are_backed_up_too() { use crate::ps2_saves::{CARDS_USER, CRUX2, KIND, STATES_USER}; diff --git a/engine/crates/ps5upload-engine/src/save_backup_server.rs b/engine/crates/ps5upload-engine/src/save_backup_server.rs index 1b006454c..a66135d13 100644 --- a/engine/crates/ps5upload-engine/src/save_backup_server.rs +++ b/engine/crates/ps5upload-engine/src/save_backup_server.rs @@ -1709,6 +1709,52 @@ mod tests { assert!(due_saves("h", &[odd], &Done::new(), 2000, &all).is_empty()); } + #[test] + fn eglantine_close_and_running_do_not_select_edens_saves() { + let profile = "1F1E1D1C1B1A19181716151413121110"; + let game = "0100F2C0115B6000"; + let saves = [emulator_saves::ROOT, emulator_saves::EGLANTINE_ROOT].map(|root| SaveEntry { + kind: emulator_saves::KIND.into(), + ..save(&format!("{root}/{profile}/{game}"), game, 1, 1000) + }); + let none = BTreeSet::new(); + let pick = Pick { + users: &[1], + title: Some(emulator_saves::EGLANTINE_APP), + settle: false, + running: &none, + drive_done: None, + }; + let due = due_saves("h", &saves, &Done::new(), 2000, &pick); + assert_eq!(due.len(), 1); + assert_eq!(due[0].path, saves[1].path); + let running = [emulator_saves::EGLANTINE_APP.to_string()].into(); + assert!(due_saves( + "h", + &saves, + &Done::new(), + 2000, + &Pick { + running: &running, + ..pick + } + ) + .is_empty()); + let due = due_saves( + "h", + &saves, + &Done::new(), + 2000, + &Pick { + title: None, + running: &running, + ..pick + }, + ); + assert_eq!(due.len(), 1); + assert_eq!(due[0].path, saves[0].path); + } + #[test] fn ps2_saves_go_with_their_emulator() { let ps2 = |path: &str, user| SaveEntry { diff --git a/scripts/i18n-source-hashes.json b/scripts/i18n-source-hashes.json index 2f6a02ba5..7d468372b 100644 --- a/scripts/i18n-source-hashes.json +++ b/scripts/i18n-source-hashes.json @@ -7795,13 +7795,13 @@ "saves_switch_backup_now": "02a2840b -Baq7z8pr8-Mj8mrd9pmQXjPeuS1BrvhT_dwz_dqg9Wj_0bsVgeg_f5cYowT", "saves_switch_badge": "39921a74 OZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZI", "saves_switch_changed": "3e627bb7 acs2ffr4WUULlfgu53uFqR3uMd-Y0fcCtRK3Mj74A3mME4mWtfHkMXqB9W0Y", - "saves_switch_close_note": "1c9caed6 H4C76L4Ql7B4_g3b7jtzc-Qnq_7p4_mbVhyimvEQQiGjA87wOLUn70k60XRB", + "saves_switch_close_note": "aaf6f564 Gh39vyhtashHMnXzGBo0tUM5dC0ltO7KEsxKFkOyClMis6Kin4rnPEO4Hlmw", "saves_switch_console": "29a40861 vT7MFJGgS4CNodiKaQpUpYA5vdPKaQ5yXKeX0zZKaQpY9CYAvdPD4P6H2yqN", "saves_switch_need_dir": "6fa9a703 3TwXXJ5T-Wy9XZjiUYk5XmsKKonQa5TJb4jE0WZh9ugbVFxXBN42GoQSSJIJ", "saves_switch_no_backups": "0d123d0d I3iK94NHcVHXrjnYWZVnfmG_IHt-D8ldv9BhtNbxQLw9LTW0SxL0HIr5mcGH", "saves_switch_profile": "fa9c0562 AHE7vx8tEd3BvFt8tEEs1I6v8tEqfhMUfXgh8tEd3BtVixFr8tEjabno26xe", - "saves_switch_running": "5b1c6581 B_8Lme1arslIV4QS3IOJnOQdsY2DCSR-vnfGthVUc59Om5LTvYdFVHpdCQq9", - "saves_switch_title": "36e30a9f Bpt5IwF4MDaS-nc_ZeeP9kZNqrBOB-Ro8o7yBjoo6m_pZYl0pz5qrBMT_3zR", + "saves_switch_running": "9e40f6e3 lGvF_AAG78FGNrv6JMilY0exjFdGMo2vGiwH5XptIoNzE5uYhQegsVulqUTL", + "saves_switch_title": "5fcd0fb1 rppeWY4DCh9So9FAXdvTTk5qUelgheI1uEYXBZM64WrN3vT9k4GUel1wZigT", "saves_sync_add": "98af618b V7ICCESYV02-jLA5yw_XvZlC6-RjmCV74ON95FSahdzBpPU0PTPGc4PMbPMb", "saves_sync_add_another": "d7246da5 ZIsCLuXJv7QwSaT9_0CCoGci6qoj0TjrkuLccVYWq1GUb1IXtPIkLZqAP_OF", "saves_sync_both_changed": "b456b0eb vfyIY-RwD2IR2q_t3inOjFom5FC_xc_7fWO3-6IYa-_5dGexg2HDUNe1XS4-", From 4da2c31132de7d22d0c0343b093782dc6dffbc7c Mon Sep 17 00:00:00 2001 From: Enrique Wood <ewoodg@hotmail.com> Date: Tue, 24 Nov 2026 21:29:35 -0300 Subject: [PATCH 05/12] fix(saves): label Eglantine as Switch and Switch 2 --- FAQ.md | 2 +- client/e2e/switch-saves.spec.ts | 3 ++- client/src/i18n/locales/ar.ts | 4 ++-- client/src/i18n/locales/bn.ts | 4 ++-- client/src/i18n/locales/de.ts | 4 ++-- client/src/i18n/locales/en.ts | 4 ++-- client/src/i18n/locales/es.ts | 4 ++-- client/src/i18n/locales/fa.ts | 4 ++-- client/src/i18n/locales/fr.ts | 4 ++-- client/src/i18n/locales/hi.ts | 4 ++-- client/src/i18n/locales/hu.ts | 4 ++-- client/src/i18n/locales/id.ts | 4 ++-- client/src/i18n/locales/it.ts | 4 ++-- client/src/i18n/locales/ja.ts | 4 ++-- client/src/i18n/locales/ko.ts | 4 ++-- client/src/i18n/locales/pl.ts | 4 ++-- client/src/i18n/locales/pt-BR.ts | 4 ++-- client/src/i18n/locales/ru.ts | 4 ++-- client/src/i18n/locales/th.ts | 4 ++-- client/src/i18n/locales/tr.ts | 4 ++-- client/src/i18n/locales/vi.ts | 4 ++-- client/src/i18n/locales/zh-CN.ts | 4 ++-- client/src/i18n/locales/zh-TW.ts | 4 ++-- client/src/screens/Saves/SwitchSaves.tsx | 5 +++-- scripts/i18n-source-hashes.json | 4 ++-- 25 files changed, 50 insertions(+), 48 deletions(-) diff --git a/FAQ.md b/FAQ.md index aa48e212d..0a12579eb 100644 --- a/FAQ.md +++ b/FAQ.md @@ -703,7 +703,7 @@ EglantinePS5 (PPSA98515) is included too. Its saves stay in `/data/eglantineps5/user/nand/user/save/0000000000000000/<profile>/<title ID>/`, regardless of where its games are kept. Each profile and game's folder is backed up by the same local, console-drive and server passes, including after EglantinePS5 closes. Save Data lists them -in their own “Switch games (EglantinePS5)” group. A restore waits for EglantinePS5 to close and +in their own “Switch / Switch 2 games (EglantinePS5)” group. A restore waits for EglantinePS5 to close and backs up the save there first. Its backups have their own profile numbers, so copies of the same game and profile in ProsperoEden stay separate, including retention. The profile label still shows the emulator's profile, and older ProsperoEden backup names stay valid. diff --git a/client/e2e/switch-saves.spec.ts b/client/e2e/switch-saves.spec.ts index c64de72f5..f1ad95841 100644 --- a/client/e2e/switch-saves.spec.ts +++ b/client/e2e/switch-saves.spec.ts @@ -144,7 +144,8 @@ test("Eglantine and Eden show independent groups and backup histories", async ({ await page.goto("/saves", { waitUntil: "domcontentloaded" }); const eden = page.locator('[data-testid="switch-saves"][data-emulator="ProsperoEden"]'); const eglantine = page.locator('[data-testid="switch-saves"][data-emulator="EglantinePS5"]'); - await expect(eglantine.getByRole("heading", { name: "Switch games (EglantinePS5)" })).toBeVisible({ timeout: 30_000 }); + await expect(eglantine.getByRole("heading", { name: "Switch / Switch 2 games (EglantinePS5)" })).toBeVisible({ timeout: 30_000 }); + await expect(eglantine.getByText("Switch / Switch 2", { exact: true })).toBeVisible(); await expect(eden.getByTestId("switch-saves-note")).toHaveText("ProsperoEden is running. Close it before restoring."); await expect(eglantine.getByTestId("switch-saves-note")).toHaveText("Close EglantinePS5 before restoring."); const rows = eglantine.getByTestId("switch-save"); diff --git a/client/src/i18n/locales/ar.ts b/client/src/i18n/locales/ar.ts index fad7ef27b..6f56ab6f0 100644 --- a/client/src/i18n/locales/ar.ts +++ b/client/src/i18n/locales/ar.ts @@ -7696,10 +7696,10 @@ helper_copies_failed_body: "لا يزال المساعد القديم: {list}. "rp_keyboard_hint": "Enter: تم. Esc: إلغاء. أثناء الكتابة هنا لا تصل أي مفاتيح أو ضغطات من وحدة التحكم إلى اللعبة.", "rp_settings_paused": "لا تصل أي مفاتيح أو ضغطات من وحدة التحكم إلى اللعبة ما دامت الإعدادات مفتوحة.", "rp_picture_tools": "أدوات الصورة", - "saves_switch_title": "ألعاب Switch ({emulator})", + "saves_switch_title": "ألعاب {platform} ({emulator})", "saves_switch_running": "{emulator} يعمل. أغلقه قبل الاستعادة.", "saves_switch_close_note": "أغلق {emulator} قبل الاستعادة.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "الجهاز", "saves_switch_profile": "الملف الشخصي {id}", "saves_switch_changed": "آخر تغيير {when}", diff --git a/client/src/i18n/locales/bn.ts b/client/src/i18n/locales/bn.ts index fa2ce079c..e4f9bcbea 100644 --- a/client/src/i18n/locales/bn.ts +++ b/client/src/i18n/locales/bn.ts @@ -7696,10 +7696,10 @@ helper_copies_failed_body: "এখনও পুরোনো হেল্পা "rp_keyboard_hint": "Enter: হয়ে গেছে। Esc: বাতিল। আপনি এখানে টাইপ করার সময় গেম কোনো কী বা কন্ট্রোলার চাপ পায় না।", "rp_settings_paused": "সেটিংস খোলা থাকাকালীন গেম কোনো কী বা কন্ট্রোলারের চাপ পায় না।", "rp_picture_tools": "ছবির টুল", - "saves_switch_title": "Switch গেম ({emulator})", + "saves_switch_title": "{platform} গেম ({emulator})", "saves_switch_running": "{emulator} চলছে। রিস্টোর করার আগে এটি বন্ধ করুন।", "saves_switch_close_note": "রিস্টোর করার আগে {emulator} বন্ধ করুন।", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "কনসোল", "saves_switch_profile": "প্রোফাইল {id}", "saves_switch_changed": "শেষ পরিবর্তন {when}", diff --git a/client/src/i18n/locales/de.ts b/client/src/i18n/locales/de.ts index 3e6a685aa..d72dfb4ef 100644 --- a/client/src/i18n/locales/de.ts +++ b/client/src/i18n/locales/de.ts @@ -7704,10 +7704,10 @@ helper_copies_failed_body: "Weiterhin der alte Helfer: {list}. Die PS5 startet i "rp_keyboard_hint": "Enter: fertig. Esc: abbrechen. Während du hier tippst, bekommt das Spiel keine Tasten und keine Controller-Eingaben.", "rp_settings_paused": "Solange die Einstellungen offen sind, bekommt das Spiel keine Tasten und keine Controller-Eingaben.", "rp_picture_tools": "Bildwerkzeuge", - "saves_switch_title": "Switch-Spiele ({emulator})", + "saves_switch_title": "{platform}-Spiele ({emulator})", "saves_switch_running": "{emulator} läuft. Schließe es vor dem Wiederherstellen.", "saves_switch_close_note": "Schließe {emulator} vor dem Wiederherstellen.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konsole", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Zuletzt geändert {when}", diff --git a/client/src/i18n/locales/en.ts b/client/src/i18n/locales/en.ts index c83e17766..4e5a2687b 100644 --- a/client/src/i18n/locales/en.ts +++ b/client/src/i18n/locales/en.ts @@ -8005,10 +8005,10 @@ helper_copies_failed_body: "Still the old helper: {list}. The PS5 starts it agai "rp_keyboard_hint": "Enter: done. Esc: cancel. While you type here, the game gets no keys or controller presses.", "rp_settings_paused": "The game gets no keys or controller presses while Settings is open.", "rp_picture_tools": "Picture tools", - "saves_switch_title": "Switch games ({emulator})", + "saves_switch_title": "{platform} games ({emulator})", "saves_switch_running": "{emulator} is running. Close it before restoring.", "saves_switch_close_note": "Close {emulator} before restoring.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Console", "saves_switch_profile": "Profile {id}", "saves_switch_changed": "Last changed {when}", diff --git a/client/src/i18n/locales/es.ts b/client/src/i18n/locales/es.ts index 7e6112ce6..b506f8980 100644 --- a/client/src/i18n/locales/es.ts +++ b/client/src/i18n/locales/es.ts @@ -7649,10 +7649,10 @@ helper_copies_failed_body: "Sigue siendo el ayudante antiguo: {list}. La PS5 lo "rp_keyboard_hint": "Intro: listo. Esc: cancelar. Mientras escribes aquí, el juego no recibe teclas ni pulsaciones del mando.", "rp_settings_paused": "El juego no recibe teclas ni pulsaciones del mando mientras los ajustes están abiertos.", "rp_picture_tools": "Herramientas de imagen", - "saves_switch_title": "Juegos de Switch ({emulator})", + "saves_switch_title": "Juegos de {platform} ({emulator})", "saves_switch_running": "{emulator} está abierto. Ciérralo antes de restaurar.", "saves_switch_close_note": "Cierra {emulator} antes de restaurar.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Consola", "saves_switch_profile": "Perfil {id}", "saves_switch_changed": "Último cambio {when}", diff --git a/client/src/i18n/locales/fa.ts b/client/src/i18n/locales/fa.ts index 2aa60dae4..f62de79af 100644 --- a/client/src/i18n/locales/fa.ts +++ b/client/src/i18n/locales/fa.ts @@ -7974,10 +7974,10 @@ helper_copies_failed_body: "هنوز کمک‌یار قدیمی است: {list}. "rp_keyboard_hint": "Enter: تمام. Esc: لغو. تا وقتی اینجا تایپ می‌کنید، بازی هیچ کلید یا فشار دسته‌ای دریافت نمی‌کند.", "rp_settings_paused": "تا وقتی تنظیمات باز است، بازی هیچ کلید یا فشار دسته‌ای دریافت نمی‌کند.", "rp_picture_tools": "ابزارهای تصویر", - "saves_switch_title": "بازی‌های Switch ({emulator})", + "saves_switch_title": "بازی‌های {platform} ({emulator})", "saves_switch_running": "{emulator} در حال اجراست. پیش از بازیابی آن را ببندید.", "saves_switch_close_note": "پیش از بازیابی {emulator} را ببندید.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "کنسول", "saves_switch_profile": "پروفایل {id}", "saves_switch_changed": "آخرین تغییر {when}", diff --git a/client/src/i18n/locales/fr.ts b/client/src/i18n/locales/fr.ts index 21737c0f0..8e98cba9c 100644 --- a/client/src/i18n/locales/fr.ts +++ b/client/src/i18n/locales/fr.ts @@ -7712,10 +7712,10 @@ helper_copies_failed_body: "Toujours l'ancien assistant : {list}. La PS5 le rela "rp_keyboard_hint": "Entrée : terminé. Échap : annuler. Pendant la saisie ici, le jeu ne reçoit ni touches ni appuis de manette.", "rp_settings_paused": "Le jeu ne reçoit ni touches ni appuis de manette tant que les réglages sont ouverts.", "rp_picture_tools": "Outils d'image", - "saves_switch_title": "Jeux Switch ({emulator})", + "saves_switch_title": "Jeux {platform} ({emulator})", "saves_switch_running": "{emulator} est ouvert. Fermez-le avant de restaurer.", "saves_switch_close_note": "Fermez {emulator} avant de restaurer.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Console", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Modifié le {when}", diff --git a/client/src/i18n/locales/hi.ts b/client/src/i18n/locales/hi.ts index be1ab53a4..ed67ce1ee 100644 --- a/client/src/i18n/locales/hi.ts +++ b/client/src/i18n/locales/hi.ts @@ -7710,10 +7710,10 @@ helper_copies_failed_body: "अब भी पुराना हेल्पर: "rp_keyboard_hint": "Enter: हो गया। Esc: रद्द करें। जब तक आप यहाँ टाइप करते हैं, गेम को कोई कुंजी या कंट्रोलर दबाव नहीं मिलता।", "rp_settings_paused": "सेटिंग्स खुली रहने तक गेम को कोई कुंजी या कंट्रोलर का दबाव नहीं मिलता।", "rp_picture_tools": "चित्र के टूल", - "saves_switch_title": "Switch गेम ({emulator})", + "saves_switch_title": "{platform} गेम ({emulator})", "saves_switch_running": "{emulator} चल रहा है। रीस्टोर करने से पहले इसे बंद करें।", "saves_switch_close_note": "रीस्टोर करने से पहले {emulator} बंद करें।", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "कंसोल", "saves_switch_profile": "प्रोफ़ाइल {id}", "saves_switch_changed": "आख़िरी बदलाव {when}", diff --git a/client/src/i18n/locales/hu.ts b/client/src/i18n/locales/hu.ts index ebc683985..0c25afbc2 100644 --- a/client/src/i18n/locales/hu.ts +++ b/client/src/i18n/locales/hu.ts @@ -7988,10 +7988,10 @@ helper_copies_failed_body: "Még mindig a régi segédprogram: {list}. A PS5 min "rp_keyboard_hint": "Enter: kész. Esc: mégse. Amíg itt gépelsz, a játék nem kap billentyűt és kontrollergombot.", "rp_settings_paused": "Amíg a Beállítások nyitva vannak, a játék nem kap billentyűt és kontrollergombot.", "rp_picture_tools": "Képeszközök", - "saves_switch_title": "Switch-játékok ({emulator})", + "saves_switch_title": "{platform}-játékok ({emulator})", "saves_switch_running": "A {emulator} fut. Zárd be visszaállítás előtt.", "saves_switch_close_note": "Zárd be a {emulator}t visszaállítás előtt.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konzol", "saves_switch_profile": "{id} profil", "saves_switch_changed": "Utolsó módosítás: {when}", diff --git a/client/src/i18n/locales/id.ts b/client/src/i18n/locales/id.ts index a3b92c09d..f2158f3d4 100644 --- a/client/src/i18n/locales/id.ts +++ b/client/src/i18n/locales/id.ts @@ -7705,10 +7705,10 @@ helper_copies_failed_body: "Masih helper lama: {list}. PS5 menjalankannya lagi s "rp_keyboard_hint": "Enter: selesai. Esc: batal. Selama Anda mengetik di sini, game tidak menerima tombol keyboard atau kontroler.", "rp_settings_paused": "Game tidak menerima tombol keyboard atau kontroler selama Pengaturan terbuka.", "rp_picture_tools": "Alat gambar", - "saves_switch_title": "Game Switch ({emulator})", + "saves_switch_title": "Game {platform} ({emulator})", "saves_switch_running": "{emulator} sedang berjalan. Tutup sebelum memulihkan.", "saves_switch_close_note": "Tutup {emulator} sebelum memulihkan.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konsol", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Terakhir diubah {when}", diff --git a/client/src/i18n/locales/it.ts b/client/src/i18n/locales/it.ts index 0449c079a..e121922d9 100644 --- a/client/src/i18n/locales/it.ts +++ b/client/src/i18n/locales/it.ts @@ -7649,10 +7649,10 @@ helper_copies_failed_body: "Ancora il vecchio helper: {list}. La PS5 lo riavvia "rp_keyboard_hint": "Invio: fatto. Esc: annulla. Mentre scrivi qui, il gioco non riceve tasti né pressioni del controller.", "rp_settings_paused": "Mentre le Impostazioni sono aperte il gioco non riceve tasti né pressioni del controller.", "rp_picture_tools": "Strumenti immagine", - "saves_switch_title": "Giochi Switch ({emulator})", + "saves_switch_title": "Giochi {platform} ({emulator})", "saves_switch_running": "{emulator} è aperto. Chiudilo prima di ripristinare.", "saves_switch_close_note": "Chiudi {emulator} prima di ripristinare.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Console", "saves_switch_profile": "Profilo {id}", "saves_switch_changed": "Ultima modifica {when}", diff --git a/client/src/i18n/locales/ja.ts b/client/src/i18n/locales/ja.ts index a1a7c9238..e9b3fe378 100644 --- a/client/src/i18n/locales/ja.ts +++ b/client/src/i18n/locales/ja.ts @@ -7715,10 +7715,10 @@ helper_copies_failed_body: "古いヘルパーのままです: {list}。PS5 は "rp_keyboard_hint": "Enter で完了、Esc でキャンセル。ここで入力している間、キーやコントローラーの入力はゲームに送られません。", "rp_settings_paused": "設定を開いている間、キーやコントローラーの入力はゲームに送られません。", "rp_picture_tools": "映像ツール", - "saves_switch_title": "Switch のゲーム ({emulator})", + "saves_switch_title": "{platform} のゲーム ({emulator})", "saves_switch_running": "{emulator} が起動中です。復元する前に閉じてください。", "saves_switch_close_note": "復元する前に {emulator} を閉じてください。", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "本体", "saves_switch_profile": "プロファイル {id}", "saves_switch_changed": "最終更新 {when}", diff --git a/client/src/i18n/locales/ko.ts b/client/src/i18n/locales/ko.ts index 51abde740..b367da5ef 100644 --- a/client/src/i18n/locales/ko.ts +++ b/client/src/i18n/locales/ko.ts @@ -7713,10 +7713,10 @@ helper_copies_failed_body: "여전히 이전 헬퍼입니다: {list}. PS5는 재 "rp_keyboard_hint": "Enter: 완료, Esc: 취소. 여기에 입력하는 동안 게임에는 키나 컨트롤러 입력이 전달되지 않습니다.", "rp_settings_paused": "설정이 열려 있는 동안에는 키와 컨트롤러 입력이 게임에 전달되지 않습니다.", "rp_picture_tools": "화면 도구", - "saves_switch_title": "Switch 게임 ({emulator})", + "saves_switch_title": "{platform} 게임 ({emulator})", "saves_switch_running": "{emulator}이 실행 중입니다. 복원하기 전에 닫으세요.", "saves_switch_close_note": "복원하기 전에 {emulator}을 닫으세요.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "본체", "saves_switch_profile": "프로필 {id}", "saves_switch_changed": "마지막 변경 {when}", diff --git a/client/src/i18n/locales/pl.ts b/client/src/i18n/locales/pl.ts index d2cb72a17..84e3d6c9a 100644 --- a/client/src/i18n/locales/pl.ts +++ b/client/src/i18n/locales/pl.ts @@ -7933,10 +7933,10 @@ helper_copies_failed_body: "Nadal stary pomocnik: {list}. PS5 uruchamia go ponow "rp_keyboard_hint": "Enter: gotowe. Esc: anuluj. Gdy piszesz tutaj, gra nie dostaje klawiszy ani naciśnięć kontrolera.", "rp_settings_paused": "Gdy Ustawienia są otwarte, gra nie dostaje klawiszy ani przycisków kontrolera.", "rp_picture_tools": "Narzędzia obrazu", - "saves_switch_title": "Gry Switch ({emulator})", + "saves_switch_title": "Gry {platform} ({emulator})", "saves_switch_running": "{emulator} jest uruchomiony. Zamknij go przed przywróceniem.", "saves_switch_close_note": "Zamknij {emulator} przed przywróceniem.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konsola", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Ostatnia zmiana {when}", diff --git a/client/src/i18n/locales/pt-BR.ts b/client/src/i18n/locales/pt-BR.ts index 71f63929c..c8c133727 100644 --- a/client/src/i18n/locales/pt-BR.ts +++ b/client/src/i18n/locales/pt-BR.ts @@ -7711,10 +7711,10 @@ helper_copies_failed_body: "Ainda é o auxiliar antigo: {list}. O PS5 o inicia d "rp_keyboard_hint": "Enter: concluir. Esc: cancelar. Enquanto você digita aqui, o jogo não recebe teclas nem botões do controle.", "rp_settings_paused": "O jogo não recebe teclas nem botões do controle enquanto as Configurações estão abertas.", "rp_picture_tools": "Ferramentas de imagem", - "saves_switch_title": "Jogos de Switch ({emulator})", + "saves_switch_title": "Jogos de {platform} ({emulator})", "saves_switch_running": "O {emulator} está aberto. Feche-o antes de restaurar.", "saves_switch_close_note": "Feche o {emulator} antes de restaurar.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Console", "saves_switch_profile": "Perfil {id}", "saves_switch_changed": "Última alteração {when}", diff --git a/client/src/i18n/locales/ru.ts b/client/src/i18n/locales/ru.ts index e403ececf..21b127eec 100644 --- a/client/src/i18n/locales/ru.ts +++ b/client/src/i18n/locales/ru.ts @@ -7649,10 +7649,10 @@ helper_copies_failed_body: "По-прежнему старый помощник: "rp_keyboard_hint": "Enter — готово. Esc — отмена. Пока вы печатаете здесь, игра не получает ни клавиш, ни нажатий контроллера.", "rp_settings_paused": "Пока открыты настройки, игра не получает нажатий клавиш и контроллера.", "rp_picture_tools": "Инструменты изображения", - "saves_switch_title": "Игры Switch ({emulator})", + "saves_switch_title": "Игры {platform} ({emulator})", "saves_switch_running": "{emulator} запущен. Закройте его перед восстановлением.", "saves_switch_close_note": "Закройте {emulator} перед восстановлением.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Консоль", "saves_switch_profile": "Профиль {id}", "saves_switch_changed": "Изменено {when}", diff --git a/client/src/i18n/locales/th.ts b/client/src/i18n/locales/th.ts index f96f97d40..f3506c7ff 100644 --- a/client/src/i18n/locales/th.ts +++ b/client/src/i18n/locales/th.ts @@ -7703,10 +7703,10 @@ helper_copies_failed_body: "ยังเป็นตัวช่วยเก่ "rp_keyboard_hint": "Enter: เสร็จ Esc: ยกเลิก ระหว่างที่พิมพ์ตรงนี้ เกมจะไม่ได้รับปุ่มคีย์บอร์ดหรือการกดจอย", "rp_settings_paused": "ขณะเปิดการตั้งค่า เกมจะไม่ได้รับการกดปุ่มคีย์บอร์ดหรือคอนโทรลเลอร์", "rp_picture_tools": "เครื่องมือภาพ", - "saves_switch_title": "เกม Switch ({emulator})", + "saves_switch_title": "เกม {platform} ({emulator})", "saves_switch_running": "{emulator} กำลังทำงาน ปิดก่อนกู้คืน", "saves_switch_close_note": "ปิด {emulator} ก่อนกู้คืน", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "เครื่อง", "saves_switch_profile": "โปรไฟล์ {id}", "saves_switch_changed": "เปลี่ยนล่าสุด {when}", diff --git a/client/src/i18n/locales/tr.ts b/client/src/i18n/locales/tr.ts index 991f14d6d..e733b6b58 100644 --- a/client/src/i18n/locales/tr.ts +++ b/client/src/i18n/locales/tr.ts @@ -7703,10 +7703,10 @@ helper_copies_failed_body: "Hâlâ eski yardımcı: {list}. PS5 her yeniden baş "rp_keyboard_hint": "Enter: bitti. Esc: iptal. Burada yazarken oyun tuş veya kumanda basışı almaz.", "rp_settings_paused": "Ayarlar açıkken oyun hiçbir tuş ya da kumanda basışı almaz.", "rp_picture_tools": "Görüntü araçları", - "saves_switch_title": "Switch oyunları ({emulator})", + "saves_switch_title": "{platform} oyunları ({emulator})", "saves_switch_running": "{emulator} açık. Geri yüklemeden önce kapatın.", "saves_switch_close_note": "Geri yüklemeden önce {emulator}'i kapatın.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Konsol", "saves_switch_profile": "Profil {id}", "saves_switch_changed": "Son değişiklik {when}", diff --git a/client/src/i18n/locales/vi.ts b/client/src/i18n/locales/vi.ts index aba27e104..0591cd0f7 100644 --- a/client/src/i18n/locales/vi.ts +++ b/client/src/i18n/locales/vi.ts @@ -7698,10 +7698,10 @@ helper_copies_failed_body: "Vẫn là trình trợ giúp cũ: {list}. PS5 sẽ c "rp_keyboard_hint": "Enter: xong. Esc: hủy. Khi bạn gõ ở đây, trò chơi không nhận phím hay nút tay cầm.", "rp_settings_paused": "Khi Cài đặt đang mở, trò chơi không nhận phím hay nút tay cầm nào.", "rp_picture_tools": "Công cụ hình ảnh", - "saves_switch_title": "Game Switch ({emulator})", + "saves_switch_title": "Game {platform} ({emulator})", "saves_switch_running": "{emulator} đang chạy. Hãy đóng nó trước khi khôi phục.", "saves_switch_close_note": "Đóng {emulator} trước khi khôi phục.", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "Máy", "saves_switch_profile": "Hồ sơ {id}", "saves_switch_changed": "Thay đổi lần cuối {when}", diff --git a/client/src/i18n/locales/zh-CN.ts b/client/src/i18n/locales/zh-CN.ts index 3297a7b11..0a6ecbdb2 100644 --- a/client/src/i18n/locales/zh-CN.ts +++ b/client/src/i18n/locales/zh-CN.ts @@ -7655,10 +7655,10 @@ helper_copies_failed_body: "仍是旧助手:{list}。PS5 每次重启后都会 "rp_keyboard_hint": "Enter:完成。Esc:取消。在这里输入时,游戏收不到按键或手柄操作。", "rp_settings_paused": "设置打开时,游戏不会收到任何按键或手柄输入。", "rp_picture_tools": "画面工具", - "saves_switch_title": "Switch 游戏({emulator})", + "saves_switch_title": "{platform} 游戏({emulator})", "saves_switch_running": "{emulator} 正在运行。恢复前请先关闭它。", "saves_switch_close_note": "恢复前请先关闭 {emulator}。", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "主机", "saves_switch_profile": "配置文件 {id}", "saves_switch_changed": "最后更改 {when}", diff --git a/client/src/i18n/locales/zh-TW.ts b/client/src/i18n/locales/zh-TW.ts index f63c9553f..b0f7d3b16 100644 --- a/client/src/i18n/locales/zh-TW.ts +++ b/client/src/i18n/locales/zh-TW.ts @@ -7649,10 +7649,10 @@ helper_copies_failed_body: "仍是舊助手:{list}。PS5 每次重新啟動後 "rp_keyboard_hint": "Enter:完成。Esc:取消。在這裡輸入時,遊戲收不到按鍵或控制器操作。", "rp_settings_paused": "設定開啟時,遊戲不會收到任何按鍵或控制器輸入。", "rp_picture_tools": "畫面工具", - "saves_switch_title": "Switch 遊戲({emulator})", + "saves_switch_title": "{platform} 遊戲({emulator})", "saves_switch_running": "{emulator} 正在執行。還原前請先關閉它。", "saves_switch_close_note": "還原前請先關閉 {emulator}。", - "saves_switch_badge": "Switch", + "saves_switch_badge": "{platform}", "saves_switch_console": "主機", "saves_switch_profile": "設定檔 {id}", "saves_switch_changed": "最後變更 {when}", diff --git a/client/src/screens/Saves/SwitchSaves.tsx b/client/src/screens/Saves/SwitchSaves.tsx index dfee20578..d8fb4db15 100644 --- a/client/src/screens/Saves/SwitchSaves.tsx +++ b/client/src/screens/Saves/SwitchSaves.tsx @@ -62,6 +62,7 @@ function SwitchSaveGroup({ host, saves, emulator }: { emulator: string; }) { const tr = useTr(); + const platform = emulator === "EglantinePS5" ? "Switch / Switch 2" : "Switch"; const running = saves.some((s) => s.running === true); const games = [...new Set(saves.map((s) => s.title_id))].sort(); @@ -70,7 +71,7 @@ function SwitchSaveGroup({ host, saves, emulator }: { <header className="mb-1 flex items-center gap-2"> <Gamepad2 size={16} aria-hidden /> <h3 className="text-sm font-semibold"> - {tr("saves_switch_title", { emulator }, "Switch games ({emulator})")} + {tr("saves_switch_title", { emulator, platform }, "{platform} games ({emulator})")} </h3> </header> <p @@ -94,7 +95,7 @@ function SwitchSaveGroup({ host, saves, emulator }: { <div className="mb-1 flex items-center gap-2"> <code className="text-sm font-semibold">{game}</code> <span className="rounded bg-[var(--color-surface-3)] px-1.5 py-0.5 text-xs"> - {tr("saves_switch_badge", undefined, "Switch")} + {tr("saves_switch_badge", { platform }, "{platform}")} </span> </div> <ul className="space-y-2"> diff --git a/scripts/i18n-source-hashes.json b/scripts/i18n-source-hashes.json index 7d468372b..ff72fce2a 100644 --- a/scripts/i18n-source-hashes.json +++ b/scripts/i18n-source-hashes.json @@ -7793,7 +7793,7 @@ "saves_switch_backup_failed": "f8420160 RehwYKh4x_LbpAm7Gam6zuslIVJnWqU85AVnHwrTcBIWF8wblXn0pfJkqHEH", "saves_switch_backup_hint": "e226a567 gEds--X6ut7O8ryrHLfTg7XBYAN9yLJQpYaPZIJIexLk1qzj8znEK-TkY8UN", "saves_switch_backup_now": "02a2840b -Baq7z8pr8-Mj8mrd9pmQXjPeuS1BrvhT_dwz_dqg9Wj_0bsVgeg_f5cYowT", - "saves_switch_badge": "39921a74 OZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZIOZI", + "saves_switch_badge": "168dcb70 Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3Fo3", "saves_switch_changed": "3e627bb7 acs2ffr4WUULlfgu53uFqR3uMd-Y0fcCtRK3Mj74A3mME4mWtfHkMXqB9W0Y", "saves_switch_close_note": "aaf6f564 Gh39vyhtashHMnXzGBo0tUM5dC0ltO7KEsxKFkOyClMis6Kin4rnPEO4Hlmw", "saves_switch_console": "29a40861 vT7MFJGgS4CNodiKaQpUpYA5vdPKaQ5yXKeX0zZKaQpY9CYAvdPD4P6H2yqN", @@ -7801,7 +7801,7 @@ "saves_switch_no_backups": "0d123d0d I3iK94NHcVHXrjnYWZVnfmG_IHt-D8ldv9BhtNbxQLw9LTW0SxL0HIr5mcGH", "saves_switch_profile": "fa9c0562 AHE7vx8tEd3BvFt8tEEs1I6v8tEqfhMUfXgh8tEd3BtVixFr8tEjabno26xe", "saves_switch_running": "9e40f6e3 lGvF_AAG78FGNrv6JMilY0exjFdGMo2vGiwH5XptIoNzE5uYhQegsVulqUTL", - "saves_switch_title": "5fcd0fb1 rppeWY4DCh9So9FAXdvTTk5qUelgheI1uEYXBZM64WrN3vT9k4GUel1wZigT", + "saves_switch_title": "8fcff65f fQQgKKTwXYEFsEBZRMi7HYcB154qZFkg_butUNYsiK14WpA_W9g154eTdyvY", "saves_sync_add": "98af618b V7ICCESYV02-jLA5yw_XvZlC6-RjmCV74ON95FSahdzBpPU0PTPGc4PMbPMb", "saves_sync_add_another": "d7246da5 ZIsCLuXJv7QwSaT9_0CCoGci6qoj0TjrkuLccVYWq1GUb1IXtPIkLZqAP_OF", "saves_sync_both_changed": "b456b0eb vfyIY-RwD2IR2q_t3inOjFom5FC_xc_7fWO3-6IYa-_5dGexg2HDUNe1XS4-", From cdd136e63191db5c6eeb4b8cf4d979b1c7b5bdaa Mon Sep 17 00:00:00 2001 From: phantomptr <phantomptr@gmail.com> Date: Tue, 24 Nov 2026 22:21:38 -0800 Subject: [PATCH 06/12] Save sync: EglantinePS5 saves get their own key, so two Switch emulators' saves of one game never sync over each other (#927) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- .../crates/ps5upload-engine/src/save_sync.rs | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/engine/crates/ps5upload-engine/src/save_sync.rs b/engine/crates/ps5upload-engine/src/save_sync.rs index 3b23291d9..11afd7e1c 100644 --- a/engine/crates/ps5upload-engine/src/save_sync.rs +++ b/engine/crates/ps5upload-engine/src/save_sync.rs @@ -312,7 +312,15 @@ pub fn items_of(saves: &[SaveEntry], user: u32) -> BTreeMap<String, SaveEntry> { for e in sorted { let key = if crate::emulator_saves::is_emulator_save(e) { if e.kind == crate::emulator_saves::KIND { - format!("{}:{}", e.kind, e.title_id) + // Two Switch emulators keep saves of the same game apart: ProsperoEden's keep the + // key they always had (so existing sync records still match), the others carry + // their app, so one emulator's save is never copied over another's. + match crate::emulator_saves::place_of(&e.path) { + Some((emu, _)) if emu.app != crate::emulator_saves::APP => { + format!("{}:{}:{}", e.kind, emu.app, e.title_id) + } + _ => format!("{}:{}", e.kind, e.title_id), + } } else { format!("{}:{}:{}", e.kind, e.title_id, e.user_id) } @@ -1623,6 +1631,33 @@ mod tests { assert_eq!(items["PPSA01234"].kind, "ps5"); } + #[test] + fn two_switch_emulators_with_the_same_game_sync_apart() { + let mut eden = save("0100000000010000", 0x0123456, "switch", 5); + eden.path = format!( + "{}/0123456789abcdef0123456789abcdef/0100000000010000", + crate::emulator_saves::ROOT + ); + let mut egl = save("0100000000010000", 0x1012_3456, "switch", 5); + egl.path = format!( + "{}/0123456789abcdef0123456789abcdef/0100000000010000", + crate::emulator_saves::EGLANTINE_ROOT + ); + let both = items_of(&[eden.clone(), egl.clone()], 1); + assert_eq!( + both.keys().cloned().collect::<Vec<_>>(), + [ + "switch:0100000000010000", + "switch:PPSA98515:0100000000010000" + ] + ); + assert_eq!(both["switch:0100000000010000"].path, eden.path); + // One emulator on each console: never paired with each other. + let a = items_of(&[eden], 1); + let b = items_of(&[egl], 1); + assert!(a.keys().all(|k| !b.contains_key(k))); + } + #[test] fn a_game_closed_with_a_change_is_suggested_and_waits_for_an_off_console() { let f = fake(&["PPSA01234"], &["PPSA01234"]); From 2384ed212532b45290929562ca9c4024d83159fc Mon Sep 17 00:00:00 2001 From: phantomptr <phantomptr@gmail.com> Date: Tue, 24 Nov 2026 22:18:14 -0800 Subject: [PATCH 07/12] Play Together: a friend sees the whole picture (#929) The friend's player drew what the decoder said: Chromium's hardware decoder on Windows (the Windows app's WebView2) reports a 1080p frame as showing only its top-left part, so that part was drawn enlarged and cut off. The host's player already puts this right from the stream's SPS (#538/#575); the friend's player now does the same, and starts the decoder over in software when the frame itself is cut down. In the app, the friend's picture box is also kept within the window's height (it was 16:9 at full width, its bottom below a 1080p window). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- client/e2e/play-together-picture.spec.ts | 190 +++++++++++++++++++++++ client/src/join/JoinView.tsx | 8 +- client/src/pad/watchPlayer.ts | 56 ++++++- 3 files changed, 250 insertions(+), 4 deletions(-) create mode 100644 client/e2e/play-together-picture.spec.ts diff --git a/client/e2e/play-together-picture.spec.ts b/client/e2e/play-together-picture.spec.ts new file mode 100644 index 000000000..c9f7e548a --- /dev/null +++ b/client/e2e/play-together-picture.spec.ts @@ -0,0 +1,190 @@ +import { readFileSync } from "node:fs"; +import { fileURLToPath } from "node:url"; +import { expect, test, type Page } from "@playwright/test"; +import { routeEngine, seedConsole } from "./fixtures/engine"; + +// #929: a friend in Play Together (the app, joined from an invite) saw the host's 1080p picture +// enlarged from its top-left corner and cut off on the right, on a Windows PC. Chromium's +// hardware decoder on Windows reports a smaller visible picture than the stream's (#538/#575); +// the host's player puts that right from the stream's SPS, the friend's player drew what the +// decoder said. A real 1080p frame (a marker in each corner, as remote-play-picture.spec.ts) +// goes through the friend's decode and draw path, with the decoder acting out that bug, and the +// whole picture has to be in the window, 16:9, every corner where it should be. + +const INVITE = "00112233445566778899aabbccddeeff"; +const LINK = `http://192.168.1.9:19113/join#i=${INVITE}&n=Ann`; + +const fixture = (name: string) => + new Uint8Array(readFileSync(fileURLToPath(new URL(`./fixtures/remote-play/${name}`, import.meta.url)))); + +/** The H.264 stream's parameter sets (the video header) and its picture. */ +function split(stream: Uint8Array): { header: Uint8Array; au: Uint8Array } { + for (let i = 0; i + 3 < stream.length; i++) { + if (stream[i] !== 0 || stream[i + 1] !== 0 || stream[i + 2] !== 1) continue; + const t = stream[i + 3] & 0x1f; + if (t < 1 || t > 5) continue; + const start = i > 0 && stream[i - 1] === 0 ? i - 1 : i; + return { header: stream.slice(0, start), au: stream.slice(start) }; + } + throw new Error("no picture in the fixture"); +} + +const record = (kind: number, payload: Uint8Array) => { + const b = Buffer.alloc(payload.length + 1); + b[0] = kind; + b.set(payload, 1); + return b; +}; + +const MARKERS = [ + { name: "top-left", fx: 0, fy: 0, rgb: [255, 0, 0] }, + { name: "top-right", fx: 1, fy: 0, rgb: [0, 255, 0] }, + { name: "bottom-left", fx: 0, fy: 1, rgb: [0, 0, 255] }, + { name: "bottom-right", fx: 1, fy: 1, rgb: [255, 255, 255] }, +] as const; +const near = (a: number[], b: readonly number[]) => a.every((v, i) => Math.abs(v - b[i]) <= 48); + +/** How the decoder acts: "edge" says each frame shows only its top-left 1280x720; "crops" (in + * hardware only) hands out just that part as a frame of its own, nothing to put right. */ +type Decoder = "plain" | "edge" | "crops"; + +/** The friend's app at the reporter's window size, joined to Ann's game. */ +async function joined(page: Page, mode: Decoder) { + await seedConsole(page); + await page.addInitScript( + ({ mode }) => { + window.localStorage.setItem("ps5upload.join.name", "Ben"); + window.localStorage.setItem("ps5upload.join.guided", "1"); + const w = window as unknown as { VideoDecoder: typeof VideoDecoder; __accel: string[] }; + w.__accel = []; + if (mode === "plain" || typeof VideoDecoder === "undefined") return; + const Real = VideoDecoder; + class WindowsDecoder extends Real { + private hw = true; + constructor(init: VideoDecoderInit) { + super({ + ...init, + output: (f: VideoFrame) => { + if (mode === "edge") { + const small = new VideoFrame(f, { + visibleRect: { x: 0, y: 0, width: 1280, height: 720 }, + displayWidth: 1280, + displayHeight: 720, + }); + f.close(); + init.output(small); + } else if (this.hw) { + const c = new OffscreenCanvas(1280, 720); + c.getContext("2d")!.drawImage(f, 0, 0, 1280, 720, 0, 0, 1280, 720); + const small = new VideoFrame(c, { timestamp: f.timestamp }); + f.close(); + init.output(small); + } else init.output(f); + }, + }); + } + configure(cfg: VideoDecoderConfig) { + w.__accel.push(cfg.hardwareAcceleration ?? "no-preference"); + this.hw = cfg.hardwareAcceleration !== "prefer-software"; + super.configure(cfg); + } + } + w.VideoDecoder = WindowsDecoder; + }, + { mode }, + ); + await routeEngine(page, (path) => { + if (path === "/api/version") return { version: "12.6.27", caps: {} }; + if (path === "/api/ps5/rp/session") return { host: null }; + return {}; + }); + const { header, au } = split(fixture("h264_1920x1080.h264")); + await page.routeWebSocket(/\/api\/join\/relay/, (ws) => { + ws.onMessage((m) => { + if (typeof m !== "string") return; + const v = JSON.parse(m) as { hello?: unknown; ping?: number; keyframe?: boolean }; + if (v.ping !== undefined) ws.send(JSON.stringify({ pong: v.ping })); + if (v.keyframe) for (let i = 0; i < 4; i++) ws.send(record(1, au)); + if (!v.hello) return; + ws.send(JSON.stringify({ stage: "joined", player: 2, token: "APP", hevc: false })); + ws.send(JSON.stringify({ status: { player: 2, state: "playing", rtt_ms: 12, host: "Ann" } })); + // The picture a moment later, once the view is up; the same keyframe a few times (a decoder + // may hold the first one back). + setTimeout(() => { + ws.send(record(0, header)); + for (let i = 0; i < 6; i++) ws.send(record(1, au)); + }, 500); + }); + }); + await page.goto(`/play?join=${encodeURIComponent(LINK)}`, { waitUntil: "domcontentloaded" }); + await page.getByTestId("join-invite-go").click({ timeout: 30_000 }); + await expect(page.getByTestId("join-player")).toHaveText("Playing at Ann's · You are Player 2", { timeout: 30_000 }); +} + +/** The whole picture, inside the window and the stage, 16:9, each corner marker in its place. */ +async function wholePicture(page: Page) { + const canvas = page.getByTestId("watch-canvas"); + await expect + .poll(() => canvas.evaluate((c: HTMLCanvasElement) => `${c.width}x${c.height}`), { timeout: 20_000 }) + .toBe("1920x1080"); + // Nothing drawn over the picture while it is measured. + await page.addStyleTag({ content: '[data-testid="join-stage-view"] > :not(:first-child) { visibility: hidden !important; }' }); + const vp = page.viewportSize()!; + const stage = (await page.getByTestId("join-stage-view").boundingBox())!; + const cb = (await canvas.boundingBox())!; + for (const box of [stage, { x: 0, y: 0, width: vp.width, height: vp.height }]) { + expect(cb.x).toBeGreaterThanOrEqual(box.x - 1); + expect(cb.y).toBeGreaterThanOrEqual(box.y - 1); + expect(cb.x + cb.width).toBeLessThanOrEqual(box.x + box.width + 1); + expect(cb.y + cb.height).toBeLessThanOrEqual(box.y + box.height + 1); + } + // object-contain inside the canvas box: the picture is the box's 16:9 middle. + const s = Math.min(cb.width / 1920, cb.height / 1080); + const px = cb.x + (cb.width - 1920 * s) / 2; + const py = cb.y + (cb.height - 1080 * s) / 2; + const m = 1080 / 8; + const pts = MARKERS.map(({ fx, fy }) => [px + (fx ? 1920 - m / 2 : m / 2) * s, py + (fy ? 1080 - m / 2 : m / 2) * s]); + const shot = await page.screenshot({ animations: "disabled" }); + const got = await page.evaluate( + async ({ b64, w, pts }) => { + const img = new Image(); + img.src = `data:image/png;base64,${b64}`; + await img.decode(); + const k = img.naturalWidth / w; + const cv = document.createElement("canvas"); + cv.width = img.naturalWidth; + cv.height = img.naturalHeight; + const g = cv.getContext("2d")!; + g.drawImage(img, 0, 0); + return pts.map(([x, y]) => Array.from(g.getImageData(Math.floor(x * k), Math.floor(y * k), 1, 1).data.slice(0, 3))); + }, + { b64: shot.toString("base64"), w: vp.width, pts }, + ); + MARKERS.forEach((mk, i) => expect(near(got[i], mk.rgb), `${mk.name} marker at ${pts[i]} is ${got[i]}`).toBe(true)); +} + +test.describe("a friend's picture in the app (#929)", () => { + test.use({ viewport: { width: 1892, height: 1003 } }); + + for (const edge of [false, true]) + test(`the whole 1080p picture fits the window${edge ? ", when the decoder reports a smaller one" : ""}`, async ({ page }) => { + await joined(page, edge ? "edge" : "plain"); + await wholePicture(page); + }); + + test("the decoder starts over in software when its picture cannot be put right", async ({ page }) => { + await joined(page, "crops"); + await wholePicture(page); + const accel = await page.evaluate(() => (window as unknown as { __accel: string[] }).__accel); + expect(accel[0]).not.toBe("prefer-software"); + expect(accel.at(-1)).toBe("prefer-software"); + }); + + test("the whole picture fits in full screen, when the decoder reports a smaller one", async ({ page }) => { + await joined(page, "edge"); + await page.getByTestId("join-stage-view").hover(); + await page.getByRole("button", { name: "Full screen" }).first().click(); + await expect(page.getByTestId("join-stage-view")).toHaveClass(/fixed/); + await wholePicture(page); + }); +}); diff --git a/client/src/join/JoinView.tsx b/client/src/join/JoinView.tsx index 40a07be29..404f5f86c 100644 --- a/client/src/join/JoinView.tsx +++ b/client/src/join/JoinView.tsx @@ -642,7 +642,13 @@ export function JoinView({ onPointerLeave: () => setBarHover(false), }; - const box = full || !inApp ? "fixed inset-0 z-[200] bg-black" : "relative aspect-video w-full overflow-hidden rounded-[var(--radius-card)] bg-black shadow-[var(--shadow-2)]"; + // In the app's Play screen the box is 16:9 and no taller than the window leaves under the + // page's header (#929: a 1080p window had the picture's bottom below the window), as the host's + // own picture box (StreamPanel), never under 20rem wide. + const box = + full || !inApp + ? "fixed inset-0 z-[200] bg-black" + : "relative mx-auto aspect-video w-full max-w-[max(20rem,calc((100dvh_-_22rem)*16/9))] overflow-hidden rounded-[var(--radius-card)] bg-black shadow-[var(--shadow-2)]"; return ( <div className="space-y-2"> diff --git a/client/src/pad/watchPlayer.ts b/client/src/pad/watchPlayer.ts index 4f1cd64bb..fdcbcfa92 100644 --- a/client/src/pad/watchPlayer.ts +++ b/client/src/pad/watchPlayer.ts @@ -7,7 +7,7 @@ import { avcDescription, lengthPrefixed, opusInit, opusSamples, opusSegment, vid import { avcCodecString, isKeyframe, supportedHevc } from "../lib/rpCodec"; import { type AudioCodecs, OpusPipe } from "../lib/rpAudioPipe"; import { wasmOpusCodecs } from "../lib/rpOpusWasm"; -import { hevcCodecString, spsVisibleRect } from "../lib/rpSps"; +import { hevcCodecString, spsVisibleRect, visibleFix, type VisibleRect } from "../lib/rpSps"; export type WatchProblem = "no_hevc" | "decode"; @@ -344,6 +344,11 @@ export class WatchPlayer { private ctx = this.canvas.getContext("2d", { alpha: false }); private hevc = false; private header: Uint8Array | null = null; + /** The visible picture the stream's SPS describes, to put right a decoder that reports a + * smaller one (rpSps.ts visibleFix; the host's player does the same, #538/#575). */ + private spsRect: VisibleRect | null = null; + /** The hardware decoder gave a picture that could not be put right: software from now on. */ + private software = false; private video: VideoDecoder | null = null; private opening = false; private sawKey = false; @@ -402,6 +407,7 @@ export class WatchPlayer { /** The engine said which codec the session uses. */ setHevc(hevc: boolean): void { this.hevc = hevc; + if (this.header) this.spsRect = spsVisibleRect(this.header, hevc); this.mse?.setHevc(hevc); } @@ -536,6 +542,7 @@ export class WatchPlayer { private async openVideo(header: Uint8Array): Promise<void> { this.header = header; + this.spsRect = spsVisibleRect(header, this.hevc); if (this.opening) return; this.opening = true; try { @@ -556,7 +563,8 @@ export class WatchPlayer { // Already closed. } const v = new VideoDecoder({ - output: (frame) => { + output: (decoded) => { + const frame = this.realVisible(decoded); const c = this.canvas; if (c.width !== frame.displayWidth || c.height !== frame.displayHeight) { c.width = frame.displayWidth; @@ -577,7 +585,10 @@ export class WatchPlayer { if (!this.decodeFailed()) this.rebuild(); }, }); - v.configure(description ? { codec, description, optimizeForLatency: true } : { codec, optimizeForLatency: true }); + const cfg: VideoDecoderConfig = { codec, optimizeForLatency: true }; + if (description) cfg.description = description; + if (this.software) cfg.hardwareAcceleration = "prefer-software"; + v.configure(cfg); this.video = v; this.sawKey = false; } catch { @@ -590,6 +601,45 @@ export class WatchPlayer { } } + /** The frame with the stream's own visible picture where the decoder reported a smaller one: + * Chromium's hardware decoder on Windows (the Windows app's WebView2, Edge) says a 1080p + * frame shows only its top-left part, which was drawn enlarged and cut off (#929, as #538 on + * the host). The new frame shares the decoded pixels; the original is closed. Where the coded + * frame is small too (nothing to put right), the decoder starts over in software. */ + private realVisible(frame: VideoFrame): VideoFrame { + const sps = this.spsRect; + const fix = visibleFix(frame, sps); + if (fix) { + try { + const fixed = new VideoFrame(frame, { + visibleRect: { x: fix.x, y: fix.y, width: fix.w, height: fix.h }, + displayWidth: fix.w, + displayHeight: fix.h, + }); + frame.close(); + return fixed; + } catch { + return frame; + } + } + const r = frame.visibleRect; + if (sps && r && !this.software && (r.width < sps.w - 16 || r.height < sps.h - 16)) { + this.software = true; + const bad = this.video; + queueMicrotask(() => { + if (this.video !== bad) return; + try { + bad?.close(); + } catch { + // Already closed. + } + this.rebuild(); + this.onNeedKey?.(); + }); + } + return frame; + } + /** The decoder failed, or the browser took it back (a hidden page's hardware decoder): a new one * from the header, and the next keyframe. Without this the picture stays frozen for good. */ private rebuild(): void { From 3ec81c08c18a2cae8a130de451ae88865f254ca2 Mon Sep 17 00:00:00 2001 From: phantomptr <phantomptr@gmail.com> Date: Tue, 24 Nov 2026 22:25:52 -0800 Subject: [PATCH 08/12] Launch: a PS5 game that won't start on 11.61-13.60 says a fake package needs the November 2026 kstuff; the above-13.60 hint drops the old A53 promise Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- client/src/i18n/locales/ar.ts | 3 ++- client/src/i18n/locales/bn.ts | 3 ++- client/src/i18n/locales/de.ts | 3 ++- client/src/i18n/locales/en.ts | 3 ++- client/src/i18n/locales/es.ts | 3 ++- client/src/i18n/locales/fa.ts | 3 ++- client/src/i18n/locales/fr.ts | 3 ++- client/src/i18n/locales/hi.ts | 3 ++- client/src/i18n/locales/hu.ts | 3 ++- client/src/i18n/locales/id.ts | 3 ++- client/src/i18n/locales/it.ts | 3 ++- client/src/i18n/locales/ja.ts | 3 ++- client/src/i18n/locales/ko.ts | 3 ++- client/src/i18n/locales/pl.ts | 3 ++- client/src/i18n/locales/pt-BR.ts | 3 ++- client/src/i18n/locales/ru.ts | 3 ++- client/src/i18n/locales/th.ts | 3 ++- client/src/i18n/locales/tr.ts | 3 ++- client/src/i18n/locales/vi.ts | 3 ++- client/src/i18n/locales/zh-CN.ts | 3 ++- client/src/i18n/locales/zh-TW.ts | 3 ++- client/src/lib/ps5Firmware.test.ts | 19 ++++++++++++++++++- client/src/lib/ps5Firmware.ts | 25 +++++++++++++++++++++++++ client/src/lib/useGameLaunch.tsx | 18 ++++++++++++++---- scripts/i18n-source-hashes.json | 3 ++- 25 files changed, 101 insertions(+), 27 deletions(-) diff --git a/client/src/i18n/locales/ar.ts b/client/src/i18n/locales/ar.ts index 6f56ab6f0..40438ee7b 100644 --- a/client/src/i18n/locales/ar.ts +++ b/client/src/i18n/locales/ar.ts @@ -5228,7 +5228,6 @@ cheats_toast_loaded: "تم تحميل أكواد الغش لـ {name}", engine_job_files_done: "{done} من {total} ملف", engine_job_running_title: "لا يزال نقل قيد التشغيل على المحرك", err_launch_homebrew_refused: "رفض جهاز PS5 تشغيل هذا العنوان (0x80940033). الجهاز لا يشغّل حاليًا تطبيقات homebrew أو ألعاب الحزم المزيفة: حمّل kstuff (أو أعد التشغيل وشغّل كسر الحماية مرة أخرى)، ثم حاول مجددًا.", -"fakegame.fw.launch_v2": "على البرامج الثابتة الأحدث من {last} (هذه الوحدة على {fw}) لا تعمل لعبة PS5 المثبتة من حزمة مزيفة. ركّب الحزمة باستخدام Kraken Mount بدلًا من ذلك؛ دعم الحزم المثبتة على البرامج الأحدث قادم. حزم PS4 تعمل.", "fakegame.fw.more": "لماذا؟", "fakegame.fw.title_v2": "بعد تثبيتها، لن تعمل لعبة PS5 هذه على FW {fw}", "fakegame.fw.body_v3": "تعمل حزم PS5 المزيفة على البرامج الثابتة حتى {last}. على FW {fw} تُثبَّت الحزمة، لكن اللعبة لا تبدأ. حزم PS4 وتطبيقات PS5 المنزلية لا مشكلة فيها.", @@ -5258,6 +5257,8 @@ install_path_fallback_label: "التثبيت عبر مسار الملف عندم "installed_fix_permissions_done": "تم إصلاح الأذونات: كل ملف في مجلد هذه اللعبة أصبح الآن 0777. اضغط تشغيل.", "installed_fix_permissions_short": "إصلاح الأذونات", "installed_launch_homebrew_refused": "رفض جهاز PS5 تشغيل هذه اللعبة (0x80940033). الجهاز لا يشغّل حاليًا تطبيقات homebrew أو ألعاب الحزم المزيفة: أعد تحميل kstuff (أو أعد التشغيل وشغّل كسر الحماية مرة أخرى)، ثم اضغط تشغيل مجددًا.", +"fakegame.fw.launch_v3": "على البرامج الثابتة الأحدث من {last} (هذا الجهاز على {fw}) لا تبدأ لعبة PS5 المثبتة من حزمة مزيفة. حزم PS4 لا مشكلة فيها.", +"fakegame.fw.launch_kstuff": "إذا ثُبّتت هذه اللعبة من حزمة مزيفة: على FW {fw} لا تبدأ إلا مع إصدار kstuff يدعم الحزم المزيفة هناك (نوفمبر 2026 أو أحدث). حمّل ذلك الـ kstuff ثم اضغط تشغيل مرة أخرى.", "installed_launch_no_kstuff": "رفض جهاز PS5 تشغيل هذه اللعبة (0x80940033) لأن kstuff لا يعمل. من دونه لا يشغّل الجهاز أي تطبيق homebrew أو لعبة من حزمة مزيفة. حمّل kstuff (المحمّل التلقائي لديك، أو الاتصال → إعداد) ثم اضغط تشغيل مجددًا.", job_why_lanes: "الاتصالات: {avg} في المتوسط، و{max} كحد أقصى؛ الجزء {chunk}", job_why_loading: "جارٍ التحميل…", diff --git a/client/src/i18n/locales/bn.ts b/client/src/i18n/locales/bn.ts index e4f9bcbea..ccae33734 100644 --- a/client/src/i18n/locales/bn.ts +++ b/client/src/i18n/locales/bn.ts @@ -5228,7 +5228,6 @@ cheats_toast_loaded: "{name}-এর জন্য চিট লোড হয় engine_job_files_done: "{total}টির মধ্যে {done}টি ফাইল", engine_job_running_title: "ইঞ্জিনে একটি ট্রান্সফার এখনও চলছে", err_launch_homebrew_refused: "PS5 এই টাইটেলটি চালু করতে অস্বীকার করেছে (0x80940033)। কনসোল এখন homebrew বা নকল-প্যাকেজ গেম চালু করছে না: kstuff লোড করুন (অথবা রিবুট করে আবার জেলব্রেক চালান), তারপর আবার চেষ্টা করুন।", -"fakegame.fw.launch_v2": "{last}-এর চেয়ে নতুন ফার্মওয়্যারে (এই কনসোল {fw}-এ) ফেক প্যাকেজ থেকে ইনস্টল করা PS5 গেম চালু হয় না। এর বদলে Kraken Mount দিয়ে প্যাকেজটি মাউন্ট করুন; নতুন ফার্মওয়্যারে ইনস্টল করা প্যাকেজের সমর্থন আসছে। PS4 প্যাকেজ ঠিকঠাক চলে।", "fakegame.fw.more": "কেন?", "fakegame.fw.title_v2": "ইনস্টল করলে এই PS5 গেম FW {fw}-এ চালু হবে না", "fakegame.fw.body_v3": "PS5 ফেক প্যাকেজ {last} পর্যন্ত ফার্মওয়্যারে চলে। FW {fw}-এ প্যাকেজ ইনস্টল হয়, কিন্তু গেম চালু হয় না। PS4 প্যাকেজ ও PS5 হোমব্রু অ্যাপে সমস্যা নেই।", @@ -5258,6 +5257,8 @@ install_path_fallback_label: "PS5 এই কম্পিউটারে পৌ "installed_fix_permissions_done": "অনুমতি ঠিক করা হয়েছে: এই গেমের ফোল্ডারের প্রতিটি ফাইল এখন 0777। চালান চাপুন।", "installed_fix_permissions_short": "অনুমতি ঠিক করুন", "installed_launch_homebrew_refused": "PS5 এই গেমটি চালু করতে অস্বীকার করেছে (0x80940033)। কনসোল এখন homebrew বা নকল-প্যাকেজ গেম চালু করছে না: kstuff আবার লোড করুন (অথবা রিবুট করে আবার জেলব্রেক চালান), তারপর আবার চালান চাপুন।", +"fakegame.fw.launch_v3": "{last}-এর চেয়ে নতুন ফার্মওয়্যারে (এই কনসোল {fw}-এ) ফেক প্যাকেজ থেকে ইনস্টল করা PS5 গেম চালু হয় না। PS4 প্যাকেজে সমস্যা নেই।", +"fakegame.fw.launch_kstuff": "এই গেমটি ফেক প্যাকেজ থেকে ইনস্টল হলে: FW {fw}-এ এটি শুধু সেখানে ফেক প্যাকেজ সাপোর্ট করা kstuff বিল্ডে চালু হয় (নভেম্বর 2026 বা নতুন)। সেই kstuff লোড করে আবার Play চাপুন।", "installed_launch_no_kstuff": "kstuff চলছে না বলে PS5 এই গেমটি চালু করতে অস্বীকার করেছে (0x80940033)। এটি ছাড়া কনসোল কোনো homebrew বা নকল-প্যাকেজ গেম চালু করে না। kstuff লোড করুন (আপনার autoloader, অথবা সংযোগ → সেট আপ) এবং আবার চালান চাপুন।", job_why_lanes: "সংযোগ: গড়ে {avg}, সর্বোচ্চ {max}; চাঙ্ক {chunk}", job_why_loading: "লোড হচ্ছে…", diff --git a/client/src/i18n/locales/de.ts b/client/src/i18n/locales/de.ts index d72dfb4ef..51008214a 100644 --- a/client/src/i18n/locales/de.ts +++ b/client/src/i18n/locales/de.ts @@ -5236,7 +5236,6 @@ cheats_toast_loaded: "Cheats für {name} geladen", engine_job_files_done: "{done} von {total} Dateien", engine_job_running_title: "Auf der Engine läuft noch eine Übertragung", err_launch_homebrew_refused: "Die PS5 hat den Start dieses Titels abgelehnt (0x80940033). Die Konsole startet gerade keine Homebrew- oder Fake-Paket-Spiele: Lade kstuff (oder starte neu und führe den Jailbreak erneut aus) und versuche es dann noch einmal.", -"fakegame.fw.launch_v2": "Auf Firmware über {last} (diese Konsole hat {fw}) startet ein PS5-Spiel aus einem Fake-Paket installiert nicht. Hänge das Paket stattdessen mit Kraken Mount ein; Unterstützung für installierte Pakete auf neuerer Firmware kommt. PS4-Pakete funktionieren.", "fakegame.fw.more": "Warum?", "fakegame.fw.title_v2": "Installiert startet dieses PS5-Spiel auf FW {fw} nicht", "fakegame.fw.body_v3": "PS5-Fake-Pakete laufen auf Firmware bis {last}. Auf FW {fw} wird das Paket installiert, aber das Spiel startet nicht. PS4-Pakete und PS5-Homebrew-Apps funktionieren.", @@ -5266,6 +5265,8 @@ install_path_fallback_label: "Über den Dateipfad installieren, wenn die PS5 die "installed_fix_permissions_done": "Berechtigungen repariert: Jede Datei im Ordner dieses Spiels ist jetzt 0777. Drücke auf Spielen.", "installed_fix_permissions_short": "Berechtigungen reparieren", "installed_launch_homebrew_refused": "Die PS5 hat den Start dieses Spiels abgelehnt (0x80940033). Die Konsole startet gerade keine Homebrew- oder Fake-Paket-Spiele: Lade kstuff neu (oder starte neu und führe den Jailbreak erneut aus) und drücke dann erneut auf Spielen.", +"fakegame.fw.launch_v3": "Auf Firmware über {last} (diese Konsole hat {fw}) startet ein PS5-Spiel, das aus einem Fake-Paket installiert wurde, nicht. PS4-Pakete funktionieren.", +"fakegame.fw.launch_kstuff": "Falls dieses Spiel aus einem Fake-Paket installiert wurde: Auf FW {fw} startet es nur mit einem kstuff-Build, der dort Fake-Pakete unterstützt (November 2026 oder neuer). Lade diesen kstuff und drücke dann erneut auf Spielen.", "installed_launch_no_kstuff": "Die PS5 hat den Start dieses Spiels abgelehnt (0x80940033), weil kstuff nicht läuft. Ohne kstuff startet die Konsole keine Homebrew- oder Fake-Paket-Spiele. Lade kstuff (über deinen Autoloader oder Verbindung → Einrichten) und drücke erneut auf Spielen.", job_why_lanes: "Verbindungen: {avg} im Schnitt, höchstens {max}; Block {chunk}", job_why_loading: "Wird geladen…", diff --git a/client/src/i18n/locales/en.ts b/client/src/i18n/locales/en.ts index 4e5a2687b..d6efa1404 100644 --- a/client/src/i18n/locales/en.ts +++ b/client/src/i18n/locales/en.ts @@ -4361,7 +4361,8 @@ install_hint_setup_exe: "The installer has opened: follow it, and it updates PS5 "installed_fix_permissions_done": "Permissions fixed: every file in this game's folder is now 0777. Press Play.", "installed_launch_no_kstuff": "The PS5 refused to start this game (0x80940033) because kstuff isn't running. Without it the console starts no homebrew or fake-package game. Load kstuff (your autoloader, or Connection → Set up) and press Play again.", "installed_launch_homebrew_refused": "The PS5 refused to start this game (0x80940033). The console isn't starting homebrew or fake-package games right now: reload kstuff (or reboot and run the jailbreak again), then press Play again.", -"fakegame.fw.launch_v2": "On firmware above {last} (this console is on {fw}) a PS5 game installed from a fake package doesn't start. Mount the package with Kraken Mount instead; support for installed packages on newer firmware is coming. PS4 packages are fine.", +"fakegame.fw.launch_v3": "On firmware above {last} (this console is on {fw}) a PS5 game installed from a fake package doesn't start. PS4 packages are fine.", +"fakegame.fw.launch_kstuff": "If this game was installed from a fake package: on FW {fw} it starts only with a kstuff build that supports fake packages there (November 2026 or newer). Load that kstuff, then press Play again.", "fakegame.fw.more": "Why?", "install_help_wont_launch": "Game won't launch?", "install_help_what_means": "What does this mean?", diff --git a/client/src/i18n/locales/es.ts b/client/src/i18n/locales/es.ts index b506f8980..6c031db9f 100644 --- a/client/src/i18n/locales/es.ts +++ b/client/src/i18n/locales/es.ts @@ -5181,7 +5181,6 @@ cheats_toast_loaded: "Trucos cargados para {name}", engine_job_files_done: "{done} de {total} archivos", engine_job_running_title: "Todavía hay una transferencia en curso en el motor", err_launch_homebrew_refused: "La PS5 se negó a iniciar este título (0x80940033). La consola no está iniciando homebrew ni juegos de paquetes falsos en este momento: carga kstuff (o reinicia y vuelve a ejecutar el jailbreak) y vuelve a intentarlo.", -"fakegame.fw.launch_v2": "Con firmware superior a {last} (esta consola tiene {fw}) un juego de PS5 instalado desde un paquete falso no arranca. Monta el paquete con Kraken Mount; llegará soporte para paquetes instalados en firmware más reciente. Los paquetes de PS4 funcionan.", "fakegame.fw.more": "¿Por qué?", "fakegame.fw.title_v2": "Instalado, este juego de PS5 no arranca con FW {fw}", "fakegame.fw.body_v3": "Los paquetes falsos de PS5 funcionan en firmware hasta {last}. En el FW {fw} el paquete se instala, pero el juego no arranca. Los paquetes de PS4 y las apps homebrew de PS5 funcionan.", @@ -5211,6 +5210,8 @@ install_path_fallback_label: "Instalar por ruta de archivo cuando la PS5 no pued "installed_fix_permissions_done": "Permisos corregidos: todos los archivos de la carpeta de este juego son ahora 0777. Pulsa Jugar.", "installed_fix_permissions_short": "Corregir permisos", "installed_launch_homebrew_refused": "La PS5 se negó a iniciar este juego (0x80940033). La consola no está iniciando homebrew ni juegos de paquetes falsos en este momento: vuelve a cargar kstuff (o reinicia y vuelve a ejecutar el jailbreak) y pulsa Jugar de nuevo.", +"fakegame.fw.launch_v3": "En firmware superior a {last} (esta consola tiene {fw}) un juego de PS5 instalado desde un paquete falso no arranca. Los paquetes de PS4 funcionan.", +"fakegame.fw.launch_kstuff": "Si este juego se instaló desde un paquete falso: en el FW {fw} solo arranca con una versión de kstuff compatible con paquetes falsos ahí (noviembre de 2026 o posterior). Carga ese kstuff y vuelve a pulsar Jugar.", "installed_launch_no_kstuff": "La PS5 se negó a iniciar este juego (0x80940033) porque kstuff no se está ejecutando. Sin él, la consola no inicia ningún homebrew ni juego de paquete falso. Carga kstuff (tu autoloader, o Conexión → Configurar) y pulsa Jugar de nuevo.", job_why_lanes: "Conexiones: {avg} de media, {max} como máximo; bloque {chunk}", job_why_loading: "Cargando…", diff --git a/client/src/i18n/locales/fa.ts b/client/src/i18n/locales/fa.ts index f62de79af..358c3bd5d 100644 --- a/client/src/i18n/locales/fa.ts +++ b/client/src/i18n/locales/fa.ts @@ -4030,7 +4030,6 @@ notif_first_run_ready_body: "ps5upload روی {host} در حال اجراست.", "install_hint_setup_exe": "نصب‌کننده باز شد: از آن پیروی کنید تا PS5Upload را در جا به‌روزرسانی کند.", "fakegame.fw.title_v2": "پس از نصب، این بازی PS5 روی FW {fw} اجرا نمی‌شود", "fakegame.fw.body_v3": "بسته‌های جعلی PS5 روی فریمور تا {last} اجرا می‌شوند. روی FW {fw} بسته نصب می‌شود، اما بازی اجرا نمی‌شود. بسته‌های PS4 و برنامه‌های هوم‌بروی PS5 مشکلی ندارند.", -"fakegame.fw.launch_v2": "روی فریمور بالاتر از {last} (این کنسول {fw} است) بازی PS5 نصب‌شده از بسته‌ی جعلی اجرا نمی‌شود. به‌جای آن بسته را با Kraken Mount سوار کنید؛ پشتیبانی از بسته‌های نصب‌شده روی فریمورهای جدیدتر در راه است. بسته‌های PS4 کار می‌کنند.", "fakegame.fw.more": "چرا؟", "install_help_wont_launch": "بازی اجرا نمی‌شود؟", "install_help_what_means": "این یعنی چه؟", @@ -5558,6 +5557,8 @@ install_path_fallback_label: "نصب از طریق مسیر فایل وقتی PS "installed_fix_permissions_done": "مجوزها اصلاح شد: همه‌ی فایل‌های پوشه‌ی این بازی اکنون 0777 هستند. بازی را بزنید.", "installed_fix_permissions_short": "اصلاح مجوزها", "installed_launch_homebrew_refused": "PS5 از اجرای این بازی خودداری کرد (0x80940033). کنسول در حال حاضر برنامه‌های homebrew یا بازی‌های بسته‌ی جعلی را اجرا نمی‌کند: kstuff را دوباره بارگذاری کنید (یا راه‌اندازی مجدد کنید و جیلبریک را دوباره اجرا کنید)، سپس دوباره بازی را بزنید.", +"fakegame.fw.launch_v3": "روی فریمور بالاتر از {last} (این کنسول روی {fw} است) بازی PS5 نصب‌شده از بسته جعلی اجرا نمی‌شود. بسته‌های PS4 مشکلی ندارند.", +"fakegame.fw.launch_kstuff": "اگر این بازی از بسته جعلی نصب شده: روی FW {fw} فقط با نسخه‌ای از kstuff اجرا می‌شود که آنجا از بسته جعلی پشتیبانی کند (نوامبر 2026 یا جدیدتر). آن kstuff را بارگذاری کنید و دوباره اجرا را بزنید.", "installed_launch_no_kstuff": "PS5 از اجرای این بازی خودداری کرد (0x80940033) چون kstuff در حال اجرا نیست. بدون آن کنسول هیچ برنامه‌ی homebrew یا بازی بسته‌ی جعلی را اجرا نمی‌کند. kstuff را بارگذاری کنید (autoloader خودتان، یا اتصال → راه‌اندازی) و دوباره بازی را بزنید.", job_why_window_full: "پنجره‌ی دریافت پر {pct} %: داده سریع‌تر از آنچه کنسول تأیید می‌کرد ارسال شد، در حالی که کنسول نه درایو و نه کارگرهایش را محدودیت گزارش کرد. این معمولاً یعنی اتصال شبکه کند است (Wi-Fi، سیگنال ضعیف یا شبکه‌ی شلوغ)؛ راه‌حل معمول اتصال سیمی است.", "linkdl.cancel": "لغو", diff --git a/client/src/i18n/locales/fr.ts b/client/src/i18n/locales/fr.ts index 8e98cba9c..fe3f53456 100644 --- a/client/src/i18n/locales/fr.ts +++ b/client/src/i18n/locales/fr.ts @@ -5244,7 +5244,6 @@ cheats_toast_loaded: "Codes chargés pour {name}", engine_job_files_done: "{done} fichiers sur {total}", engine_job_running_title: "Un transfert est toujours en cours sur le moteur", err_launch_homebrew_refused: "La PS5 a refusé de lancer ce titre (0x80940033). La console ne lance pas de homebrew ni de jeux en faux paquet pour le moment : charge kstuff (ou redémarre et relance le jailbreak), puis réessaie.", -"fakegame.fw.launch_v2": "Sur un firmware au-delà de {last} (cette console est en {fw}), un jeu PS5 installé depuis un faux paquet ne démarre pas. Montez plutôt le paquet avec Kraken Mount ; la prise en charge des paquets installés sur les firmwares récents arrive. Les paquets PS4 fonctionnent.", "fakegame.fw.more": "Pourquoi ?", "fakegame.fw.title_v2": "Installé, ce jeu PS5 ne démarre pas sur le FW {fw}", "fakegame.fw.body_v3": "Les faux paquets PS5 fonctionnent sur les firmwares jusqu'à {last}. Sur le FW {fw}, le paquet s'installe, mais le jeu ne démarre pas. Les paquets PS4 et les applis homebrew PS5 fonctionnent.", @@ -5274,6 +5273,8 @@ install_path_fallback_label: "Installer par chemin de fichier quand la PS5 ne pe "installed_fix_permissions_done": "Permissions corrigées : chaque fichier du dossier de ce jeu est maintenant en 0777. Appuie sur Jouer.", "installed_fix_permissions_short": "Corriger les permissions", "installed_launch_homebrew_refused": "La PS5 a refusé de lancer ce jeu (0x80940033). La console ne lance pas de homebrew ni de jeux en faux paquet pour le moment : recharge kstuff (ou redémarre et relance le jailbreak), puis appuie à nouveau sur Jouer.", +"fakegame.fw.launch_v3": "Sur un firmware au-delà de {last} (cette console est en {fw}), un jeu PS5 installé depuis un faux paquet ne démarre pas. Les paquets PS4 fonctionnent.", +"fakegame.fw.launch_kstuff": "Si ce jeu a été installé depuis un faux paquet : sur le FW {fw}, il ne démarre qu'avec une version de kstuff qui y prend en charge les faux paquets (novembre 2026 ou plus récente). Chargez ce kstuff, puis appuyez de nouveau sur Jouer.", "installed_launch_no_kstuff": "La PS5 a refusé de lancer ce jeu (0x80940033) car kstuff n'est pas en cours d'exécution. Sans lui, la console ne lance aucun homebrew ni jeu en faux paquet. Charge kstuff (ton autoloader, ou Connexion → Configurer) et appuie à nouveau sur Jouer.", job_why_lanes: "Connexions : {avg} en moyenne, {max} au maximum ; bloc {chunk}", job_why_loading: "Chargement…", diff --git a/client/src/i18n/locales/hi.ts b/client/src/i18n/locales/hi.ts index ed67ce1ee..a2ee933d6 100644 --- a/client/src/i18n/locales/hi.ts +++ b/client/src/i18n/locales/hi.ts @@ -5242,7 +5242,6 @@ cheats_toast_loaded: "{name} के लिए चीट लोड किए ग engine_job_files_done: "{total} में से {done} फ़ाइलें", engine_job_running_title: "इंजन पर एक ट्रांसफ़र अभी भी चल रहा है", err_launch_homebrew_refused: "PS5 ने यह टाइटल शुरू करने से मना कर दिया (0x80940033)। कंसोल अभी homebrew या नकली-पैकेज गेम शुरू नहीं कर रहा है: kstuff लोड करें (या रीबूट करके फिर से जेलब्रेक चलाएँ), फिर दोबारा कोशिश करें।", -"fakegame.fw.launch_v2": "{last} से नए फ़र्मवेयर (यह कंसोल {fw} पर है) पर फ़ेक पैकेज से इंस्टॉल किया PS5 गेम शुरू नहीं होता। इसके बजाय पैकेज को Kraken Mount से माउंट करें; नए फ़र्मवेयर पर इंस्टॉल किए पैकेज का समर्थन आ रहा है। PS4 पैकेज ठीक चलते हैं।", "fakegame.fw.more": "क्यों?", "fakegame.fw.title_v2": "इंस्टॉल होने पर यह PS5 गेम FW {fw} पर शुरू नहीं होगा", "fakegame.fw.body_v3": "PS5 फ़ेक पैकेज {last} तक के फ़र्मवेयर पर चलते हैं। FW {fw} पर पैकेज इंस्टॉल हो जाता है, पर गेम शुरू नहीं होता। PS4 पैकेज और PS5 होमब्रू ऐप ठीक हैं।", @@ -5272,6 +5271,8 @@ install_path_fallback_label: "जब PS5 इस कंप्यूटर तक "installed_fix_permissions_done": "अनुमतियाँ ठीक कर दी गईं: इस गेम के फ़ोल्डर की हर फ़ाइल अब 0777 है। चलाएँ दबाएँ।", "installed_fix_permissions_short": "अनुमतियाँ ठीक करें", "installed_launch_homebrew_refused": "PS5 ने यह गेम शुरू करने से मना कर दिया (0x80940033)। कंसोल अभी homebrew या नकली-पैकेज गेम शुरू नहीं कर रहा है: kstuff दोबारा लोड करें (या रीबूट करके फिर से जेलब्रेक चलाएँ), फिर दोबारा चलाएँ दबाएँ।", +"fakegame.fw.launch_v3": "{last} से ऊपर के फ़र्मवेयर पर (यह कंसोल {fw} पर है) फ़ेक पैकेज से इंस्टॉल किया PS5 गेम शुरू नहीं होता। PS4 पैकेज ठीक हैं।", +"fakegame.fw.launch_kstuff": "अगर यह गेम फ़ेक पैकेज से इंस्टॉल हुआ है: FW {fw} पर यह सिर्फ़ उस kstuff बिल्ड से शुरू होता है जो वहाँ फ़ेक पैकेज सपोर्ट करता है (नवंबर 2026 या नया)। वह kstuff लोड करें, फिर दोबारा Play दबाएँ।", "installed_launch_no_kstuff": "PS5 ने यह गेम शुरू करने से मना कर दिया (0x80940033) क्योंकि kstuff नहीं चल रहा है। इसके बिना कंसोल कोई homebrew या नकली-पैकेज गेम शुरू नहीं करता। kstuff लोड करें (आपका autoloader, या कनेक्शन → सेट करें) और दोबारा चलाएँ दबाएँ।", job_why_lanes: "कनेक्शन: औसतन {avg}, अधिकतम {max}; चंक {chunk}", job_why_loading: "लोड हो रहा है…", diff --git a/client/src/i18n/locales/hu.ts b/client/src/i18n/locales/hu.ts index 0c25afbc2..6d58af5a2 100644 --- a/client/src/i18n/locales/hu.ts +++ b/client/src/i18n/locales/hu.ts @@ -5520,7 +5520,6 @@ cheats_toast_loaded: "Csalások betöltve ehhez: {name}", engine_job_files_done: "{done} / {total} fájl", engine_job_running_title: "A motoron még fut egy átvitel", err_launch_homebrew_refused: "A PS5 megtagadta a cím indítását (0x80940033). A konzol most nem indít homebrew-t és hamis csomagos játékot: töltsd be a kstuffot (vagy indítsd újra, és futtasd újra a jailbreaket), majd próbáld újra.", -"fakegame.fw.launch_v2": "{last} feletti firmware-en (ezen a konzolon {fw}) a hamis csomagból telepített PS5-játék nem indul el. Csatold inkább a csomagot a Kraken Mounttal; az újabb firmware-en telepített csomagok támogatása hamarosan jön. A PS4-csomagok működnek.", "fakegame.fw.more": "Miért?", "fakegame.fw.title_v2": "Telepítve ez a PS5-játék nem indul el a(z) {fw} firmware-en", "fakegame.fw.body_v3": "A PS5 hamis csomagok {last} firmware-ig futnak. FW {fw} alatt a csomag települ, de a játék nem indul el. A PS4 csomagok és a PS5 homebrew alkalmazások rendben vannak.", @@ -5550,6 +5549,8 @@ install_path_fallback_label: "Telepítés fájlútvonal alapján, ha a PS5 nem "installed_fix_permissions_done": "Jogosultságok javítva: a játék mappájában minden fájl most 0777. Nyomd meg a Játék gombot.", "installed_fix_permissions_short": "Jogosultságok javítása", "installed_launch_homebrew_refused": "A PS5 megtagadta a játék indítását (0x80940033). A konzol most nem indít homebrew-t és hamis csomagos játékot: töltsd be újra a kstuffot (vagy indítsd újra, és futtasd újra a jailbreaket), majd nyomd meg újra a Játék gombot.", +"fakegame.fw.launch_v3": "{last} feletti firmware-en (ez a konzol {fw}) a hamis csomagból telepített PS5 játék nem indul el. A PS4 csomagok rendben vannak.", +"fakegame.fw.launch_kstuff": "Ha ez a játék hamis csomagból települt: FW {fw} alatt csak olyan kstuff-fal indul, amely ott támogatja a hamis csomagokat (2026. novemberi vagy újabb). Töltsd be azt a kstuff-ot, majd nyomd meg újra a Játék gombot.", "installed_launch_no_kstuff": "A PS5 megtagadta a játék indítását (0x80940033), mert a kstuff nem fut. Nélküle a konzol semmilyen homebrew-t vagy hamis csomagos játékot nem indít. Töltsd be a kstuffot (az autoloadereddel vagy a Kapcsolat → Beállítás menüben), és nyomd meg újra a Játék gombot.", job_why_lanes: "Kapcsolatok: átlagosan {avg}, legfeljebb {max}; blokk {chunk}", job_why_loading: "Betöltés…", diff --git a/client/src/i18n/locales/id.ts b/client/src/i18n/locales/id.ts index f2158f3d4..b99729856 100644 --- a/client/src/i18n/locales/id.ts +++ b/client/src/i18n/locales/id.ts @@ -5237,7 +5237,6 @@ cheats_toast_loaded: "Cheat dimuat untuk {name}", engine_job_files_done: "{done} dari {total} file", engine_job_running_title: "Sebuah transfer masih berjalan di engine", err_launch_homebrew_refused: "PS5 menolak menjalankan judul ini (0x80940033). Konsol sedang tidak menjalankan homebrew atau game paket palsu: muat kstuff (atau reboot dan jalankan jailbreak lagi), lalu coba lagi.", -"fakegame.fw.launch_v2": "Di firmware di atas {last} (konsol ini {fw}) game PS5 yang dipasang dari paket palsu tidak mau mulai. Mount paketnya dengan Kraken Mount saja; dukungan untuk paket terpasang di firmware lebih baru segera hadir. Paket PS4 berjalan normal.", "fakegame.fw.more": "Kenapa?", "fakegame.fw.title_v2": "Saat terpasang, game PS5 ini tidak mau mulai di FW {fw}", "fakegame.fw.body_v3": "Paket palsu PS5 berjalan di firmware hingga {last}. Di FW {fw} paket terpasang, tetapi game tidak mau mulai. Paket PS4 dan aplikasi homebrew PS5 tidak terpengaruh.", @@ -5267,6 +5266,8 @@ install_path_fallback_label: "Pasang lewat path file saat PS5 tidak bisa menjang "installed_fix_permissions_done": "Izin diperbaiki: setiap file di folder game ini sekarang 0777. Tekan Mainkan.", "installed_fix_permissions_short": "Perbaiki izin", "installed_launch_homebrew_refused": "PS5 menolak menjalankan game ini (0x80940033). Konsol sedang tidak menjalankan homebrew atau game paket palsu: muat ulang kstuff (atau reboot dan jalankan jailbreak lagi), lalu tekan Mainkan lagi.", +"fakegame.fw.launch_v3": "Di firmware di atas {last} (konsol ini di {fw}) game PS5 yang dipasang dari paket palsu tidak mau mulai. Paket PS4 tidak terpengaruh.", +"fakegame.fw.launch_kstuff": "Jika game ini dipasang dari paket palsu: di FW {fw} game hanya mulai dengan build kstuff yang mendukung paket palsu di sana (November 2026 atau lebih baru). Muat kstuff itu, lalu tekan Main lagi.", "installed_launch_no_kstuff": "PS5 menolak menjalankan game ini (0x80940033) karena kstuff tidak berjalan. Tanpanya, konsol tidak menjalankan homebrew atau game paket palsu apa pun. Muat kstuff (autoloader-mu, atau Koneksi → Siapkan) lalu tekan Mainkan lagi.", job_why_lanes: "Koneksi: rata-rata {avg}, paling banyak {max}; chunk {chunk}", job_why_loading: "Memuat…", diff --git a/client/src/i18n/locales/it.ts b/client/src/i18n/locales/it.ts index e121922d9..d5ad9a653 100644 --- a/client/src/i18n/locales/it.ts +++ b/client/src/i18n/locales/it.ts @@ -5181,7 +5181,6 @@ cheats_toast_loaded: "Trucchi caricati per {name}", engine_job_files_done: "{done} di {total} file", engine_job_running_title: "Un trasferimento è ancora in corso sul motore", err_launch_homebrew_refused: "La PS5 ha rifiutato di avviare questo titolo (0x80940033). Al momento la console non avvia homebrew né giochi da pacchetti fake: carica kstuff (oppure riavvia ed esegui di nuovo il jailbreak), poi riprova.", -"fakegame.fw.launch_v2": "Su firmware oltre {last} (questa console ha {fw}) un gioco PS5 installato da un pacchetto fake non si avvia. Monta invece il pacchetto con Kraken Mount; il supporto per i pacchetti installati sui firmware più recenti è in arrivo. I pacchetti PS4 funzionano.", "fakegame.fw.more": "Perché?", "fakegame.fw.title_v2": "Installato, questo gioco PS5 non si avvia con il FW {fw}", "fakegame.fw.body_v3": "I pacchetti fake PS5 funzionano sui firmware fino al {last}. Sul FW {fw} il pacchetto si installa, ma il gioco non parte. I pacchetti PS4 e le app homebrew PS5 funzionano.", @@ -5211,6 +5210,8 @@ install_path_fallback_label: "Installa tramite percorso del file quando la PS5 n "installed_fix_permissions_done": "Permessi corretti: ogni file nella cartella di questo gioco ora è 0777. Premi Gioca.", "installed_fix_permissions_short": "Correggi permessi", "installed_launch_homebrew_refused": "La PS5 ha rifiutato di avviare questo gioco (0x80940033). Al momento la console non avvia homebrew né giochi da pacchetti fake: ricarica kstuff (oppure riavvia ed esegui di nuovo il jailbreak), poi premi di nuovo Gioca.", +"fakegame.fw.launch_v3": "Sui firmware oltre il {last} (questa console è al {fw}) un gioco PS5 installato da un pacchetto fake non parte. I pacchetti PS4 funzionano.", +"fakegame.fw.launch_kstuff": "Se questo gioco è stato installato da un pacchetto fake: sul FW {fw} parte solo con una build di kstuff che lì supporta i pacchetti fake (novembre 2026 o più recente). Carica quel kstuff, poi premi di nuovo Gioca.", "installed_launch_no_kstuff": "La PS5 ha rifiutato di avviare questo gioco (0x80940033) perché kstuff non è in esecuzione. Senza di esso la console non avvia homebrew né giochi da pacchetti fake. Carica kstuff (con il tuo autoloader, oppure Connessione → Configura) e premi di nuovo Gioca.", job_why_lanes: "Connessioni: {avg} in media, {max} al massimo; blocco {chunk}", job_why_loading: "Caricamento…", diff --git a/client/src/i18n/locales/ja.ts b/client/src/i18n/locales/ja.ts index e9b3fe378..cd7e2ccd5 100644 --- a/client/src/i18n/locales/ja.ts +++ b/client/src/i18n/locales/ja.ts @@ -5247,7 +5247,6 @@ cheats_toast_loaded: "{name} のチートを読み込みました", engine_job_files_done: "{done} / {total} ファイル", engine_job_running_title: "エンジンで転送がまだ実行中です", err_launch_homebrew_refused: "PS5 がこのタイトルの起動を拒否しました(0x80940033)。本体は現在、自作アプリやフェイクパッケージのゲームを起動しない状態です。kstuff を読み込んで(または再起動してもう一度脱獄して)から、再試行してください。", -"fakegame.fw.launch_v2": "{last} より新しいファームウェア(このコンソールは {fw})では、フェイクパッケージからインストールした PS5 ゲームは起動しません。代わりに Kraken Mount でパッケージをマウントしてください。新しいファームウェアでのインストール済みパッケージ対応は近日予定です。PS4 パッケージは問題ありません。", "fakegame.fw.more": "なぜ?", "fakegame.fw.title_v2": "インストールしても、この PS5 ゲームは FW {fw} では起動しません", "fakegame.fw.body_v3": "PS5 のフェイクパッケージはファームウェア {last} まで動作します。FW {fw} ではパッケージはインストールされますが、ゲームは起動しません。PS4 パッケージと PS5 の自作アプリは問題ありません。", @@ -5277,6 +5276,8 @@ install_path_fallback_label: "PS5 がこのコンピューターに接続でき "installed_fix_permissions_done": "権限を修正しました。このゲームのフォルダー内のすべてのファイルが 0777 になりました。プレイを押してください。", "installed_fix_permissions_short": "権限を修正", "installed_launch_homebrew_refused": "PS5 がこのゲームの起動を拒否しました(0x80940033)。本体は現在、自作アプリやフェイクパッケージのゲームを起動しない状態です。kstuff を読み込み直して(または再起動してもう一度脱獄して)から、もう一度プレイを押してください。", +"fakegame.fw.launch_v3": "{last} より新しいファームウェア(この本体は {fw})では、フェイクパッケージからインストールした PS5 ゲームは起動しません。PS4 パッケージは問題ありません。", +"fakegame.fw.launch_kstuff": "このゲームをフェイクパッケージからインストールした場合:FW {fw} では、そこでフェイクパッケージに対応した kstuff(2026 年 11 月以降)でしか起動しません。その kstuff を読み込んでから、もう一度プレイを押してください。", "installed_launch_no_kstuff": "kstuff が実行されていないため、PS5 がこのゲームの起動を拒否しました(0x80940033)。kstuff がないと、本体は自作アプリやフェイクパッケージのゲームを起動しません。kstuff を読み込んで(オートローダー、または 接続 → セットアップ)、もう一度プレイを押してください。", job_why_lanes: "接続数: 平均 {avg}、最大 {max}。チャンク {chunk}", job_why_loading: "読み込み中…", diff --git a/client/src/i18n/locales/ko.ts b/client/src/i18n/locales/ko.ts index b367da5ef..e3b9f99f5 100644 --- a/client/src/i18n/locales/ko.ts +++ b/client/src/i18n/locales/ko.ts @@ -5245,7 +5245,6 @@ cheats_toast_loaded: "{name}의 치트를 불러왔습니다", engine_job_files_done: "파일 {total}개 중 {done}개", engine_job_running_title: "엔진에서 전송이 아직 실행 중입니다", err_launch_homebrew_refused: "PS5가 이 타이틀의 시작을 거부했습니다(0x80940033). 지금 본체가 홈브루나 가짜 패키지 게임을 시작하지 않는 상태입니다. kstuff를 로드한 다음(또는 재부팅 후 탈옥을 다시 실행한 다음) 다시 시도하세요.", -"fakegame.fw.launch_v2": "{last}보다 높은 펌웨어(이 콘솔은 {fw})에서는 가짜 패키지로 설치한 PS5 게임이 시작되지 않습니다. 대신 Kraken Mount로 패키지를 마운트하세요. 최신 펌웨어에서 설치된 패키지 지원은 곧 제공됩니다. PS4 패키지는 문제없습니다.", "fakegame.fw.more": "왜 그런가요?", "fakegame.fw.title_v2": "설치하면 이 PS5 게임은 FW {fw}에서 시작되지 않습니다", "fakegame.fw.body_v3": "PS5 페이크 패키지는 펌웨어 {last}까지 실행됩니다. FW {fw}에서는 패키지가 설치되지만 게임이 시작되지 않습니다. PS4 패키지와 PS5 홈브루 앱은 문제없습니다.", @@ -5275,6 +5274,8 @@ install_path_fallback_label: "PS5가 이 컴퓨터에 연결할 수 없을 때 "installed_fix_permissions_done": "권한이 수정되었습니다. 이 게임 폴더의 모든 파일이 이제 0777입니다. 실행을 누르세요.", "installed_fix_permissions_short": "권한 수정", "installed_launch_homebrew_refused": "PS5가 이 게임의 시작을 거부했습니다(0x80940033). 지금 본체가 홈브루나 가짜 패키지 게임을 시작하지 않는 상태입니다. kstuff를 다시 로드한 다음(또는 재부팅 후 탈옥을 다시 실행한 다음) 실행을 다시 누르세요.", +"fakegame.fw.launch_v3": "{last}보다 높은 펌웨어(이 콘솔은 {fw})에서는 페이크 패키지로 설치한 PS5 게임이 시작되지 않습니다. PS4 패키지는 문제없습니다.", +"fakegame.fw.launch_kstuff": "이 게임을 페이크 패키지로 설치했다면: FW {fw}에서는 그 펌웨어의 페이크 패키지를 지원하는 kstuff 빌드(2026년 11월 이후)로만 시작됩니다. 그 kstuff를 불러온 뒤 다시 플레이를 누르세요.", "installed_launch_no_kstuff": "kstuff가 실행 중이 아니어서 PS5가 이 게임의 시작을 거부했습니다(0x80940033). kstuff가 없으면 본체는 홈브루나 가짜 패키지 게임을 시작하지 않습니다. kstuff를 로드하고(오토로더, 또는 연결 → 설정) 실행을 다시 누르세요.", job_why_lanes: "연결: 평균 {avg}개, 최대 {max}개, 청크 {chunk}", job_why_loading: "불러오는 중…", diff --git a/client/src/i18n/locales/pl.ts b/client/src/i18n/locales/pl.ts index 84e3d6c9a..db9753862 100644 --- a/client/src/i18n/locales/pl.ts +++ b/client/src/i18n/locales/pl.ts @@ -5465,7 +5465,6 @@ cheats_toast_loaded: "Wczytano kody dla {name}", engine_job_files_done: "{done} z {total} plików", engine_job_running_title: "Na silniku nadal trwa transfer", err_launch_homebrew_refused: "PS5 odmówiła uruchomienia tego tytułu (0x80940033). Konsola nie uruchamia teraz homebrew ani gier z fałszywych pakietów: wczytaj kstuff (albo uruchom ponownie i wykonaj jailbreak jeszcze raz), a potem spróbuj ponownie.", -"fakegame.fw.launch_v2": "Na firmware powyżej {last} (ta konsola ma {fw}) gra PS5 zainstalowana z fałszywej paczki się nie uruchamia. Zamontuj paczkę przez Kraken Mount; obsługa zainstalowanych paczek na nowszym firmware jest w drodze. Paczki PS4 działają.", "fakegame.fw.more": "Dlaczego?", "fakegame.fw.title_v2": "Zainstalowana, ta gra PS5 nie uruchomi się na FW {fw}", "fakegame.fw.body_v3": "Fałszywe pakiety PS5 działają na oprogramowaniu do {last}. Na FW {fw} pakiet się instaluje, ale gra się nie uruchamia. Pakiety PS4 i aplikacje homebrew PS5 działają.", @@ -5495,6 +5494,8 @@ install_path_fallback_label: "Instaluj według ścieżki pliku, gdy PS5 nie moż "installed_fix_permissions_done": "Uprawnienia naprawione: każdy plik w folderze tej gry ma teraz 0777. Naciśnij Graj.", "installed_fix_permissions_short": "Napraw uprawnienia", "installed_launch_homebrew_refused": "PS5 odmówiła uruchomienia tej gry (0x80940033). Konsola nie uruchamia teraz homebrew ani gier z fałszywych pakietów: wczytaj ponownie kstuff (albo uruchom ponownie i wykonaj jailbreak jeszcze raz), a potem znów naciśnij Graj.", +"fakegame.fw.launch_v3": "Na oprogramowaniu nowszym niż {last} (ta konsola ma {fw}) gra PS5 zainstalowana z fałszywego pakietu się nie uruchamia. Pakiety PS4 działają.", +"fakegame.fw.launch_kstuff": "Jeśli ta gra została zainstalowana z fałszywego pakietu: na FW {fw} uruchamia się tylko z wersją kstuff obsługującą tam fałszywe pakiety (z listopada 2026 lub nowszą). Załaduj ten kstuff i ponownie naciśnij Graj.", "installed_launch_no_kstuff": "PS5 odmówiła uruchomienia tej gry (0x80940033), bo kstuff nie działa. Bez niego konsola nie uruchamia żadnego homebrew ani gry z fałszywego pakietu. Wczytaj kstuff (autoloaderem albo przez Połączenie → Skonfiguruj) i znów naciśnij Graj.", job_why_lanes: "Połączenia: średnio {avg}, maksymalnie {max}; blok {chunk}", job_why_loading: "Wczytywanie…", diff --git a/client/src/i18n/locales/pt-BR.ts b/client/src/i18n/locales/pt-BR.ts index c8c133727..5e1f94dbb 100644 --- a/client/src/i18n/locales/pt-BR.ts +++ b/client/src/i18n/locales/pt-BR.ts @@ -5243,7 +5243,6 @@ cheats_toast_loaded: "Truques carregados para {name}", engine_job_files_done: "{done} de {total} arquivos", engine_job_running_title: "Uma transferência ainda está em andamento no motor", err_launch_homebrew_refused: "O PS5 se recusou a iniciar este título (0x80940033). O console não está iniciando homebrew nem jogos de pacotes falsos no momento: carregue o kstuff (ou reinicie e execute o jailbreak novamente) e tente de novo.", -"fakegame.fw.launch_v2": "Em firmware acima de {last} (este console está no {fw}) um jogo de PS5 instalado de um pacote fake não inicia. Monte o pacote com o Kraken Mount; suporte a pacotes instalados em firmware mais novo está chegando. Pacotes de PS4 funcionam.", "fakegame.fw.more": "Por quê?", "fakegame.fw.title_v2": "Instalado, este jogo de PS5 não inicia no FW {fw}", "fakegame.fw.body_v3": "Pacotes fake de PS5 rodam em firmware até {last}. No FW {fw} o pacote instala, mas o jogo não abre. Pacotes de PS4 e apps homebrew de PS5 funcionam.", @@ -5273,6 +5272,8 @@ install_path_fallback_label: "Instalar pelo caminho do arquivo quando o PS5 não "installed_fix_permissions_done": "Permissões corrigidas: todos os arquivos na pasta deste jogo agora são 0777. Pressione Jogar.", "installed_fix_permissions_short": "Corrigir permissões", "installed_launch_homebrew_refused": "O PS5 se recusou a iniciar este jogo (0x80940033). O console não está iniciando homebrew nem jogos de pacotes falsos no momento: recarregue o kstuff (ou reinicie e execute o jailbreak novamente) e pressione Jogar de novo.", +"fakegame.fw.launch_v3": "Em firmware acima de {last} (este console está no {fw}) um jogo de PS5 instalado de um pacote fake não abre. Pacotes de PS4 funcionam.", +"fakegame.fw.launch_kstuff": "Se este jogo foi instalado de um pacote fake: no FW {fw} ele só abre com uma versão do kstuff que suporte pacotes fake ali (de novembro de 2026 ou mais nova). Carregue esse kstuff e toque em Jogar de novo.", "installed_launch_no_kstuff": "O PS5 se recusou a iniciar este jogo (0x80940033) porque o kstuff não está em execução. Sem ele, o console não inicia nenhum homebrew nem jogo de pacote falso. Carregue o kstuff (seu autoloader, ou Conexão → Configurar) e pressione Jogar de novo.", job_why_lanes: "Conexões: {avg} em média, {max} no máximo; bloco {chunk}", job_why_loading: "Carregando…", diff --git a/client/src/i18n/locales/ru.ts b/client/src/i18n/locales/ru.ts index 21b127eec..724e3a5ee 100644 --- a/client/src/i18n/locales/ru.ts +++ b/client/src/i18n/locales/ru.ts @@ -5181,7 +5181,6 @@ cheats_toast_loaded: "Читы для {name} загружены", engine_job_files_done: "{done} из {total} файлов", engine_job_running_title: "На движке ещё идёт передача", err_launch_homebrew_refused: "PS5 отказалась запускать этот тайтл (0x80940033). Сейчас консоль не запускает homebrew и игры из фейковых пакетов: загрузите kstuff (или перезагрузитесь и снова выполните джейлбрейк), затем повторите попытку.", -"fakegame.fw.launch_v2": "На прошивке выше {last} (на этой консоли {fw}) игра PS5, установленная из фейкового пакета, не запускается. Смонтируйте пакет через Kraken Mount; поддержка установленных пакетов на новых прошивках скоро появится. Пакеты PS4 работают.", "fakegame.fw.more": "Почему?", "fakegame.fw.title_v2": "Установленная, эта игра PS5 не запустится на прошивке {fw}", "fakegame.fw.body_v3": "Фейковые пакеты PS5 работают на прошивке до {last}. На FW {fw} пакет устанавливается, но игра не запускается. Пакеты PS4 и homebrew-приложения PS5 работают.", @@ -5211,6 +5210,8 @@ install_path_fallback_label: "Устанавливать по пути к фай "installed_fix_permissions_done": "Права исправлены: у каждого файла в папке этой игры теперь 0777. Нажмите «Играть».", "installed_fix_permissions_short": "Исправить права", "installed_launch_homebrew_refused": "PS5 отказалась запускать эту игру (0x80940033). Сейчас консоль не запускает homebrew и игры из фейковых пакетов: перезагрузите kstuff (или перезагрузите консоль и снова выполните джейлбрейк), затем снова нажмите «Играть».", +"fakegame.fw.launch_v3": "На прошивке выше {last} (эта консоль на {fw}) игра PS5, установленная из фейкового пакета, не запускается. Пакеты PS4 работают.", +"fakegame.fw.launch_kstuff": "Если игра установлена из фейкового пакета: на FW {fw} она запускается только со сборкой kstuff, поддерживающей там фейковые пакеты (ноябрь 2026 или новее). Загрузите этот kstuff и снова нажмите «Играть».", "installed_launch_no_kstuff": "PS5 отказалась запускать эту игру (0x80940033), потому что kstuff не запущен. Без него консоль не запускает ни homebrew, ни игры из фейковых пакетов. Загрузите kstuff (автозагрузчиком или через Подключение → Настроить) и снова нажмите «Играть».", job_why_lanes: "Соединения: в среднем {avg}, максимум {max}; блок {chunk}", job_why_loading: "Загрузка…", diff --git a/client/src/i18n/locales/th.ts b/client/src/i18n/locales/th.ts index f3506c7ff..3b390be84 100644 --- a/client/src/i18n/locales/th.ts +++ b/client/src/i18n/locales/th.ts @@ -5235,7 +5235,6 @@ cheats_toast_loaded: "โหลดสูตรโกงของ {name} แล engine_job_files_done: "{done} จาก {total} ไฟล์", engine_job_running_title: "ยังมีการถ่ายโอนทำงานอยู่บนเอนจิน", err_launch_homebrew_refused: "PS5 ปฏิเสธการเริ่มเกมนี้ (0x80940033) ขณะนี้เครื่องไม่ยอมเริ่ม homebrew หรือเกมจากแพ็กเกจปลอม: โหลด kstuff (หรือรีบูตแล้วรันเจลเบรกอีกครั้ง) แล้วลองใหม่", -"fakegame.fw.launch_v2": "บนเฟิร์มแวร์ที่ใหม่กว่า {last} (คอนโซลนี้เป็น {fw}) เกม PS5 ที่ติดตั้งจากแพ็กเกจปลอมจะไม่เริ่ม ให้เมานต์แพ็กเกจด้วย Kraken Mount แทน การรองรับแพ็กเกจที่ติดตั้งบนเฟิร์มแวร์ใหม่กำลังจะมา แพ็กเกจ PS4 ใช้ได้ปกติ", "fakegame.fw.more": "ทำไม?", "fakegame.fw.title_v2": "เมื่อติดตั้งแล้ว เกม PS5 นี้จะไม่เริ่มบน FW {fw}", "fakegame.fw.body_v3": "แพ็กเกจปลอมของ PS5 เล่นได้บนเฟิร์มแวร์ถึง {last} บน FW {fw} แพ็กเกจติดตั้งได้ แต่เกมไม่เริ่ม แพ็กเกจ PS4 และแอปโฮมบรูว์ PS5 ใช้ได้ปกติ", @@ -5265,6 +5264,8 @@ install_path_fallback_label: "ติดตั้งด้วยพาธไฟ "installed_fix_permissions_done": "แก้ไขสิทธิ์แล้ว: ทุกไฟล์ในโฟลเดอร์ของเกมนี้เป็น 0777 แล้ว กดเล่น", "installed_fix_permissions_short": "แก้ไขสิทธิ์", "installed_launch_homebrew_refused": "PS5 ปฏิเสธการเริ่มเกมนี้ (0x80940033) ขณะนี้เครื่องไม่ยอมเริ่ม homebrew หรือเกมจากแพ็กเกจปลอม: โหลด kstuff ใหม่ (หรือรีบูตแล้วรันเจลเบรกอีกครั้ง) แล้วกดเล่นอีกครั้ง", +"fakegame.fw.launch_v3": "บนเฟิร์มแวร์ที่สูงกว่า {last} (เครื่องนี้ใช้ {fw}) เกม PS5 ที่ติดตั้งจากแพ็กเกจปลอมจะไม่เริ่ม แพ็กเกจ PS4 ใช้ได้ปกติ", +"fakegame.fw.launch_kstuff": "หากเกมนี้ติดตั้งจากแพ็กเกจปลอม: บน FW {fw} เกมจะเริ่มได้เฉพาะกับ kstuff รุ่นที่รองรับแพ็กเกจปลอมบนเฟิร์มแวร์นั้น (พฤศจิกายน 2026 หรือใหม่กว่า) โหลด kstuff นั้นแล้วกดเล่นอีกครั้ง", "installed_launch_no_kstuff": "PS5 ปฏิเสธการเริ่มเกมนี้ (0x80940033) เพราะ kstuff ไม่ได้ทำงานอยู่ หากไม่มี kstuff เครื่องจะไม่เริ่ม homebrew หรือเกมจากแพ็กเกจปลอมใด ๆ โหลด kstuff (ตัวโหลดอัตโนมัติของคุณ หรือ การเชื่อมต่อ → ตั้งค่า) แล้วกดเล่นอีกครั้ง", job_why_lanes: "การเชื่อมต่อ: เฉลี่ย {avg} สูงสุด {max}; ชังก์ {chunk}", job_why_loading: "กำลังโหลด…", diff --git a/client/src/i18n/locales/tr.ts b/client/src/i18n/locales/tr.ts index e733b6b58..4460485f9 100644 --- a/client/src/i18n/locales/tr.ts +++ b/client/src/i18n/locales/tr.ts @@ -5235,7 +5235,6 @@ cheats_toast_loaded: "{name} için hileler yüklendi", engine_job_files_done: "{done}/{total} dosya", engine_job_running_title: "Motorda hâlâ bir aktarım sürüyor", err_launch_homebrew_refused: "PS5 bu başlığı başlatmayı reddetti (0x80940033). Konsol şu anda homebrew ya da sahte paket oyunlarını başlatmıyor: kstuff'ı yükle (ya da yeniden başlatıp jailbreak'i tekrar çalıştır), sonra yeniden dene.", -"fakegame.fw.launch_v2": "{last} üstü yazılımda (bu konsol {fw}) sahte paketten kurulan bir PS5 oyunu başlamaz. Bunun yerine paketi Kraken Mount ile bağlayın; yeni yazılımlarda kurulu paket desteği geliyor. PS4 paketleri sorunsuz.", "fakegame.fw.more": "Neden?", "fakegame.fw.title_v2": "Kurulu hâlde bu PS5 oyunu FW {fw} üzerinde başlamaz", "fakegame.fw.body_v3": "PS5 sahte paketleri {last} sürümüne kadar olan yazılımlarda çalışır. FW {fw} üzerinde paket yüklenir ama oyun başlamaz. PS4 paketleri ve PS5 homebrew uygulamaları sorunsuzdur.", @@ -5265,6 +5264,8 @@ install_path_fallback_label: "PS5 bu bilgisayara ulaşamadığında dosya yoluyl "installed_fix_permissions_done": "İzinler düzeltildi: bu oyunun klasöründeki her dosya artık 0777. Oyna'ya bas.", "installed_fix_permissions_short": "İzinleri düzelt", "installed_launch_homebrew_refused": "PS5 bu oyunu başlatmayı reddetti (0x80940033). Konsol şu anda homebrew ya da sahte paket oyunlarını başlatmıyor: kstuff'ı yeniden yükle (ya da yeniden başlatıp jailbreak'i tekrar çalıştır), sonra yeniden Oyna'ya bas.", +"fakegame.fw.launch_v3": "{last} sürümünden yeni yazılımlarda (bu konsol {fw}) sahte paketten yüklenen bir PS5 oyunu başlamaz. PS4 paketleri sorunsuzdur.", +"fakegame.fw.launch_kstuff": "Bu oyun sahte paketten yüklendiyse: FW {fw} üzerinde yalnızca orada sahte paketleri destekleyen bir kstuff sürümüyle başlar (Kasım 2026 veya daha yeni). O kstuff'ı yükleyin, sonra yeniden Oyna'ya basın.", "installed_launch_no_kstuff": "PS5 bu oyunu başlatmayı reddetti (0x80940033), çünkü kstuff çalışmıyor. O olmadan konsol hiçbir homebrew ya da sahte paket oyununu başlatmaz. kstuff'ı yükle (autoloader'ınla ya da Bağlantı → Kur ile) ve yeniden Oyna'ya bas.", job_why_lanes: "Bağlantılar: ortalama {avg}, en fazla {max}; blok {chunk}", job_why_loading: "Yükleniyor…", diff --git a/client/src/i18n/locales/vi.ts b/client/src/i18n/locales/vi.ts index 0591cd0f7..3553241c1 100644 --- a/client/src/i18n/locales/vi.ts +++ b/client/src/i18n/locales/vi.ts @@ -5230,7 +5230,6 @@ cheats_toast_loaded: "Đã tải mã gian lận cho {name}", engine_job_files_done: "{done} / {total} tệp", engine_job_running_title: "Một lần truyền vẫn đang chạy trên engine", err_launch_homebrew_refused: "PS5 đã từ chối khởi chạy tựa này (0x80940033). Hiện tại máy không khởi chạy homebrew hay trò chơi từ gói giả: hãy tải kstuff (hoặc khởi động lại và chạy jailbreak lần nữa), rồi thử lại.", -"fakegame.fw.launch_v2": "Trên firmware cao hơn {last} (máy này đang {fw}) game PS5 cài từ gói giả không chạy. Hãy gắn gói bằng Kraken Mount thay vào đó; hỗ trợ gói đã cài trên firmware mới hơn sắp có. Gói PS4 vẫn chạy bình thường.", "fakegame.fw.more": "Vì sao?", "fakegame.fw.title_v2": "Khi đã cài, game PS5 này không chạy trên FW {fw}", "fakegame.fw.body_v3": "Gói giả PS5 chạy trên firmware đến {last}. Trên FW {fw}, gói vẫn cài được nhưng game không khởi động. Gói PS4 và ứng dụng homebrew PS5 vẫn dùng bình thường.", @@ -5260,6 +5259,8 @@ install_path_fallback_label: "Cài theo đường dẫn tệp khi PS5 không k "installed_fix_permissions_done": "Đã sửa quyền: mọi tệp trong thư mục của trò chơi này giờ là 0777. Nhấn Chơi.", "installed_fix_permissions_short": "Sửa quyền", "installed_launch_homebrew_refused": "PS5 đã từ chối khởi chạy trò chơi này (0x80940033). Hiện tại máy không khởi chạy homebrew hay trò chơi từ gói giả: hãy tải lại kstuff (hoặc khởi động lại và chạy jailbreak lần nữa), rồi nhấn Chơi lần nữa.", +"fakegame.fw.launch_v3": "Trên firmware cao hơn {last} (máy này đang ở {fw}), game PS5 cài từ gói giả không khởi động. Gói PS4 vẫn dùng bình thường.", +"fakegame.fw.launch_kstuff": "Nếu game này được cài từ gói giả: trên FW {fw} game chỉ khởi động với bản kstuff hỗ trợ gói giả ở đó (tháng 11/2026 hoặc mới hơn). Hãy nạp kstuff đó rồi bấm Chơi lại.", "installed_launch_no_kstuff": "PS5 đã từ chối khởi chạy trò chơi này (0x80940033) vì kstuff không chạy. Không có nó, máy không khởi chạy homebrew hay trò chơi từ gói giả nào. Hãy tải kstuff (bằng autoloader của bạn, hoặc Kết nối → Thiết lập) rồi nhấn Chơi lần nữa.", job_why_lanes: "Kết nối: trung bình {avg}, tối đa {max}; khối {chunk}", job_why_loading: "Đang tải…", diff --git a/client/src/i18n/locales/zh-CN.ts b/client/src/i18n/locales/zh-CN.ts index 0a6ecbdb2..127d09331 100644 --- a/client/src/i18n/locales/zh-CN.ts +++ b/client/src/i18n/locales/zh-CN.ts @@ -5187,7 +5187,6 @@ cheats_toast_loaded: "已加载 {name} 的金手指", engine_job_files_done: "{done} / {total} 个文件", engine_job_running_title: "引擎上仍有传输在运行", err_launch_homebrew_refused: "PS5 拒绝启动此标题(0x80940033)。主机当前不会启动自制程序或伪造软件包游戏:请加载 kstuff(或重启后再次运行越狱),然后重试。", -"fakegame.fw.launch_v2": "在高于 {last} 的固件上(此主机为 {fw}),从假包安装的 PS5 游戏无法启动。请改用 Kraken Mount 挂载此包;新固件上已安装包的支持即将推出。PS4 包不受影响。", "fakegame.fw.more": "为什么?", "fakegame.fw.title_v2": "安装后,这款 PS5 游戏在 FW {fw} 上无法启动", "fakegame.fw.body_v3": "PS5 伪造包可在 {last} 及以下固件上运行。在 FW {fw} 上,包可以安装,但游戏无法启动。PS4 包和 PS5 自制应用不受影响。", @@ -5217,6 +5216,8 @@ install_path_fallback_label: "当 PS5 无法连接到这台电脑时,按文件 "installed_fix_permissions_done": "权限已修复:此游戏文件夹中的所有文件现在都是 0777。请按运行。", "installed_fix_permissions_short": "修复权限", "installed_launch_homebrew_refused": "PS5 拒绝启动这款游戏(0x80940033)。主机当前不会启动自制程序或伪造软件包游戏:请重新加载 kstuff(或重启后再次运行越狱),然后再次按运行。", +"fakegame.fw.launch_v3": "在高于 {last} 的固件上(这台主机为 {fw}),从伪造包安装的 PS5 游戏无法启动。PS4 包不受影响。", +"fakegame.fw.launch_kstuff": "如果此游戏是从伪造包安装的:在 FW {fw} 上,只有支持该固件伪造包的 kstuff 版本(2026 年 11 月或更新)才能启动它。请加载该 kstuff,然后再次点击“游玩”。", "installed_launch_no_kstuff": "由于 kstuff 没有运行,PS5 拒绝启动这款游戏(0x80940033)。没有它,主机不会启动任何自制程序或伪造软件包游戏。请加载 kstuff(你的自动加载器,或 连接 → 设置),然后再次按运行。", job_why_lanes: "连接数:平均 {avg},最多 {max};分块 {chunk}", job_why_loading: "正在加载…", diff --git a/client/src/i18n/locales/zh-TW.ts b/client/src/i18n/locales/zh-TW.ts index b0f7d3b16..4af92db66 100644 --- a/client/src/i18n/locales/zh-TW.ts +++ b/client/src/i18n/locales/zh-TW.ts @@ -5181,7 +5181,6 @@ cheats_toast_loaded: "已載入 {name} 的金手指", engine_job_files_done: "{done} / {total} 個檔案", engine_job_running_title: "引擎上仍有傳輸在執行", err_launch_homebrew_refused: "PS5 拒絕啟動此標題(0x80940033)。主機目前不會啟動自製程式或偽造套件遊戲:請載入 kstuff(或重新開機後再次執行越獄),然後再試一次。", -"fakegame.fw.launch_v2": "在高於 {last} 的韌體上(此主機為 {fw}),從假套件安裝的 PS5 遊戲無法啟動。請改用 Kraken Mount 掛載此套件;新韌體上已安裝套件的支援即將推出。PS4 套件不受影響。", "fakegame.fw.more": "為什麼?", "fakegame.fw.title_v2": "安裝後,這款 PS5 遊戲在 FW {fw} 上無法啟動", "fakegame.fw.body_v3": "PS5 偽造套件可在 {last} 以下的韌體上執行。在 FW {fw} 上,套件可以安裝,但遊戲無法啟動。PS4 套件和 PS5 自製應用程式不受影響。", @@ -5211,6 +5210,8 @@ install_path_fallback_label: "當 PS5 無法連線到這台電腦時,依檔案 "installed_fix_permissions_done": "權限已修正:此遊戲資料夾中的所有檔案現在都是 0777。請按執行。", "installed_fix_permissions_short": "修正權限", "installed_launch_homebrew_refused": "PS5 拒絕啟動這款遊戲(0x80940033)。主機目前不會啟動自製程式或偽造套件遊戲:請重新載入 kstuff(或重新開機後再次執行越獄),然後再按一次執行。", +"fakegame.fw.launch_v3": "在高於 {last} 的韌體上(這台主機為 {fw}),從偽造套件安裝的 PS5 遊戲無法啟動。PS4 套件不受影響。", +"fakegame.fw.launch_kstuff": "如果此遊戲是從偽造套件安裝的:在 FW {fw} 上,只有支援該韌體偽造套件的 kstuff 版本(2026 年 11 月或更新)才能啟動它。請載入該 kstuff,然後再按一次「遊玩」。", "installed_launch_no_kstuff": "由於 kstuff 沒有在執行,PS5 拒絕啟動這款遊戲(0x80940033)。沒有它,主機不會啟動任何自製程式或偽造套件遊戲。請載入 kstuff(你的自動載入器,或 連線 → 設定),然後再按一次執行。", job_why_lanes: "連線數:平均 {avg},最多 {max};區塊 {chunk}", job_why_loading: "正在載入…", diff --git a/client/src/lib/ps5Firmware.test.ts b/client/src/lib/ps5Firmware.test.ts index a7d47a8c1..a39b79054 100644 --- a/client/src/lib/ps5Firmware.test.ts +++ b/client/src/lib/ps5Firmware.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from "vitest"; -import { parsePS5Firmware, ps5FakeGameUnplayableFirmware } from "./ps5Firmware"; +import { parsePS5Firmware, ps5FakeGameNeedsNewKstuff, ps5FakeGameUnplayableFirmware } from "./ps5Firmware"; describe("parsePS5Firmware", () => { it("extracts from 'releases/09.60' kernel string", () => { @@ -75,3 +75,20 @@ describe("ps5FakeGameUnplayableFirmware", () => { expect(ps5FakeGameUnplayableFirmware(K("13.60"), "something-else")).toBeNull(); }); }); + +describe("ps5FakeGameNeedsNewKstuff", () => { + const K = (fw: string) => `FreeBSD 11.0-RELEASE-p0 #1 r229358/releases/${fw} Jul 17 2026`; + const PS5_GAME = "UP4433-PPSA17221_00-MINECRAFTPS50000"; + it("names 11.61 to 13.60, where a fake PS5 game needs the November 2026 kstuff", () => { + expect(ps5FakeGameNeedsNewKstuff(K("11.61"), PS5_GAME)).toBe("11.61"); + expect(ps5FakeGameNeedsNewKstuff(K("12.70"), PS5_GAME)).toBe("12.70"); + expect(ps5FakeGameNeedsNewKstuff(K("13.60"), "PPSA17221")).toBe("13.60"); + }); + it("is null at 11.60 and below, above 13.60, for PS4 or homebrew, and for an unknown firmware", () => { + expect(ps5FakeGameNeedsNewKstuff(K("11.60"), PS5_GAME)).toBeNull(); + expect(ps5FakeGameNeedsNewKstuff(K("14.00"), PS5_GAME)).toBeNull(); + expect(ps5FakeGameNeedsNewKstuff(K("13.60"), "CUSA00207")).toBeNull(); + expect(ps5FakeGameNeedsNewKstuff(K("13.60"), "IV0002-ITEM00001_00-ITEMZFLOWIV00000")).toBeNull(); + expect(ps5FakeGameNeedsNewKstuff(null, PS5_GAME)).toBeNull(); + }); +}); diff --git a/client/src/lib/ps5Firmware.ts b/client/src/lib/ps5Firmware.ts index b1dd97f98..f30d30b4f 100644 --- a/client/src/lib/ps5Firmware.ts +++ b/client/src/lib/ps5Firmware.ts @@ -74,3 +74,28 @@ export function ps5FakeGameUnplayableFirmware( }; return toNum(fw) > toNum(LAST_PS5_FAKE_GAME_FIRMWARE) ? fw : null; } + +/** The newest firmware where a PS5 fake GAME played with any kstuff that loads fake packages. + * Above it, up to LAST_PS5_FAKE_GAME_FIRMWARE, the game starts only with a kstuff build that + * supports fake packages on that firmware (released November 2026). */ +export const LAST_PS5_FAKE_GAME_FIRMWARE_OLD_KSTUFF = "11.60"; + +/** The console's firmware when a PS5 fake GAME there needs the November 2026 (or newer) kstuff + * to start: a PS5 game id and a firmware above 11.60, up to LAST_PS5_FAKE_GAME_FIRMWARE. Else + * null (also for an unknown firmware). Used to explain a launch that failed. */ +export function ps5FakeGameNeedsNewKstuff( + kernel: string | null | undefined, + contentOrTitleId: string | null | undefined, +): string | null { + if (!isPs5GameId(contentOrTitleId)) return null; + const fw = parsePS5Firmware(kernel); + if (!fw) return null; + const toNum = (v: string) => { + const [maj, min] = v.split("."); + return Number(maj) * 100 + Number(min); + }; + const n = toNum(fw); + return n > toNum(LAST_PS5_FAKE_GAME_FIRMWARE_OLD_KSTUFF) && n <= toNum(LAST_PS5_FAKE_GAME_FIRMWARE) + ? fw + : null; +} diff --git a/client/src/lib/useGameLaunch.tsx b/client/src/lib/useGameLaunch.tsx index cddbc2e1d..be51825eb 100644 --- a/client/src/lib/useGameLaunch.tsx +++ b/client/src/lib/useGameLaunch.tsx @@ -14,6 +14,7 @@ import { } from "./launchRefusal"; import { LAST_PS5_FAKE_GAME_FIRMWARE, + ps5FakeGameNeedsNewKstuff, ps5FakeGameUnplayableFirmware, } from "./ps5Firmware"; import { fetchRunningGames, type RunningGame } from "./runningGames"; @@ -89,11 +90,20 @@ export function useGameLaunch( useConnectionStore.getState().runtimeByHost[hostOf(launchHost)] ?.ps5Kernel; const fw = ps5FakeGameUnplayableFirmware(kernel, titleId); - if (!fw) return body; + if (fw) { + return `${body} ${tr( + "fakegame.fw.launch_v3", + { fw, last: LAST_PS5_FAKE_GAME_FIRMWARE }, + `On firmware above ${LAST_PS5_FAKE_GAME_FIRMWARE} (this console is on ${fw}) a PS5 game installed from a fake package doesn't start. PS4 packages are fine.`, + )}`; + } + // 11.61 to 13.60: a fake PS5 game starts only with the newer kstuff (November 2026). + const kfw = ps5FakeGameNeedsNewKstuff(kernel, titleId); + if (!kfw) return body; return `${body} ${tr( - "fakegame.fw.launch_v2", - { fw, last: LAST_PS5_FAKE_GAME_FIRMWARE }, - `On firmware above ${LAST_PS5_FAKE_GAME_FIRMWARE} (this console is on ${fw}) a PS5 game installed from a fake package doesn't start. Mount the package with Kraken Mount instead; support for installed packages on newer firmware is coming. PS4 packages are fine.`, + "fakegame.fw.launch_kstuff", + { fw: kfw }, + `If this game was installed from a fake package: on FW ${kfw} it starts only with a kstuff build that supports fake packages there (November 2026 or newer). Load that kstuff, then press Play again.`, )}`; }, [tr], diff --git a/scripts/i18n-source-hashes.json b/scripts/i18n-source-hashes.json index ff72fce2a..6f1d391f8 100644 --- a/scripts/i18n-source-hashes.json +++ b/scripts/i18n-source-hashes.json @@ -3183,7 +3183,8 @@ "eta_min": "913185ba yCJp5Xhs0kTGU-tkTGFCRHk1XwWkTGuJ7S5okTGkTGH8F804rGjfurisqN_L", "eta_sec": "2e304898 dsBbjAzVpjm3sPKjm3kD3EXXUr3jm3RnnMgMjm3jm3_6XV13-BCvRHRnnRnn", "fakegame.fw.body_v3": "9accb442 ePdWD74ZJ7H1bt2B0peynL09hcVkzu5HbzR4nG7stpIJUlfST0LgndG2pBYV", - "fakegame.fw.launch_v2": "454ae8aa ampeV75g0dWR-5OuE-a55Y7XhhagNQtNLRENm2jug566qUgTVJO05l2GN9OI", + "fakegame.fw.launch_kstuff": "6d7d6fc7 3aaqNXAUK1fEEPYvcotOFgXDbfO8m4z2gKNkYGxrMKA-Kl90AL3dj20lXPlb", + "fakegame.fw.launch_v3": "bee6f22a hx-ailtflUgs7WbWBsKqR7hoPotVmIMT8lY9bLA__RUUucDHX6by9-wGXGOS", "fakegame.fw.more": "5d8a995a EqE7Y_DM7_lUEw53ehwGWOTgXo0d2KbJiZB2tLOAsfATMXi9QnLP2R7iFsTl", "fakegame.fw.title_v2": "bf62ad5a h22Wlmp3gW-asxgobZf_lIOPmC3E_YzLFpcKgnpTGI6XDM2BT4NREsmu3h50", "fakelibs_action_failed": "57b25b95 qk7dLA37_hGtDBxvlLLrMZ0lLS6nxzzhTE5egUaoXoWlomzvdMYx-0G2JG2J", From f8c74e3b5248b8ce133c2ffe185d75f0fd76ec4b Mon Sep 17 00:00:00 2001 From: phantomptr <phantomptr@gmail.com> Date: Tue, 24 Nov 2026 22:27:49 -0800 Subject: [PATCH 09/12] e2e: Upload & Install note gives the 13.60 rule Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- client/e2e/upload-install.spec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/e2e/upload-install.spec.ts b/client/e2e/upload-install.spec.ts index f5f779ca1..8b00c388f 100644 --- a/client/e2e/upload-install.spec.ts +++ b/client/e2e/upload-install.spec.ts @@ -16,9 +16,9 @@ test("Upload & Install opens with the FPKG note and one drop zone", async ({ pag await page.goto("/send", { waitUntil: "domcontentloaded" }); await expect(page.getByRole("heading", { name: "Upload & Install" })).toBeVisible({ timeout: 30_000 }); - // The FPKG note comes before the drop zone and points to Kraken Mount without opening. + // The FPKG note comes before the drop zone and gives the firmware rule without opening. const note = page.getByTestId("fpkg-note"); - await expect(note).toContainText("Mount them with Kraken Mount instead"); + await expect(note).toContainText("PS5 fake packages play on firmware up to 13.60"); await expect(note).toContainText("PS4 fake packages are fine"); const drop = page.getByTestId("send-drop"); const [noteBox, dropBox] = [await note.boundingBox(), await drop.boundingBox()]; From d3f70b459bba2086d8315deff11d0bbaeddc4a68 Mon Sep 17 00:00:00 2001 From: phantomptr <phantomptr@gmail.com> Date: Tue, 24 Nov 2026 22:29:40 -0800 Subject: [PATCH 10/12] Payloads: kstuff-lite covers 1.00-13.60; fake PS5 games above 11.60 need the November 2026 build Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- client/src/i18n/locales/ar.ts | 2 +- client/src/i18n/locales/bn.ts | 2 +- client/src/i18n/locales/de.ts | 2 +- client/src/i18n/locales/en.ts | 2 +- client/src/i18n/locales/es.ts | 2 +- client/src/i18n/locales/fa.ts | 2 +- client/src/i18n/locales/fr.ts | 2 +- client/src/i18n/locales/hi.ts | 2 +- client/src/i18n/locales/hu.ts | 2 +- client/src/i18n/locales/id.ts | 2 +- client/src/i18n/locales/it.ts | 2 +- client/src/i18n/locales/ja.ts | 2 +- client/src/i18n/locales/ko.ts | 2 +- client/src/i18n/locales/pl.ts | 2 +- client/src/i18n/locales/pt-BR.ts | 2 +- client/src/i18n/locales/ru.ts | 2 +- client/src/i18n/locales/th.ts | 2 +- client/src/i18n/locales/tr.ts | 2 +- client/src/i18n/locales/vi.ts | 2 +- client/src/i18n/locales/zh-CN.ts | 2 +- client/src/i18n/locales/zh-TW.ts | 2 +- client/src/lib/payloadCatalogText.ts | 2 +- engine/crates/ps5upload-core/src/payload_library/catalogue.rs | 4 ++-- scripts/i18n-source-hashes.json | 2 +- 24 files changed, 25 insertions(+), 25 deletions(-) diff --git a/client/src/i18n/locales/ar.ts b/client/src/i18n/locales/ar.ts index 40438ee7b..050aaa9de 100644 --- a/client/src/i18n/locales/ar.ts +++ b/client/src/i18n/locales/ar.ts @@ -1129,7 +1129,7 @@ ok: "موافق", payload_role_elfldr: "محمّل ELF، يُحمَّل قبل مساعد PS5Upload", payload_desc_elfldr: "المحمّل الذي يستقبل الحمولات. حمّله عبر كسر الحماية أو المحمّل التلقائي قبل مساعد PS5Upload. يتطلب إرساله محمّلًا يعمل بالفعل: فهو لا يفتح منفذًا مغلقًا. بعد اتصال المساعد، يمكن لـ PS5Upload استبدال المحمّل القياسي العامل بنسخته المعدّلة.", payload_role_kstuff_echostretch: "ثغرة نواة مع صلاحية قراءة وكتابة", -payload_desc_kstuff_echostretch: "مُعدِّل للنواة للبرامج الثابتة من 1.00 إلى 12.x. يحتاجه ShadowMount+ ومعظم الحمولات ذات الصلاحيات. حمّله أولًا.", +payload_desc_kstuff_echostretch_v2: "مُرقّع النواة للبرامج الثابتة من 1.00 إلى 13.60. يحتاجه ShadowMount+ ومعظم الحمولات الأخرى ذات الصلاحيات. حمّله أولاً. لألعاب PS5 المزيفة على البرامج الثابتة فوق 11.60 استخدم إصدار نوفمبر 2026 أو أحدث.", payload_role_kstuff_lite_drakmor: "ثغرة نواة، تركّب صور الألعاب أسرع", payload_desc_kstuff_lite_drakmor: "نسخة متفرعة من kstuff-lite تركّب صور .ffpkg و PFS أسرع. تدعم الإصدارات الحديثة البرامج الثابتة حتى 12.xx؛ راجع ملاحظات الإصدار لنسختك. يمكنها إيقاف التركيب التلقائي (noautomount). الأفضل إذا كنت تستخدم غالبًا ShadowMount+ مع صور الألعاب. حمّلها قبل ShadowMount+ و PS5Upload.", payload_role_shadowmountplus: "يركّب نسخ الألعاب الاحتياطية ويسجلها تلقائيًا", diff --git a/client/src/i18n/locales/bn.ts b/client/src/i18n/locales/bn.ts index ccae33734..6d9972e6a 100644 --- a/client/src/i18n/locales/bn.ts +++ b/client/src/i18n/locales/bn.ts @@ -1129,7 +1129,7 @@ ok: "ঠিক আছে", payload_role_elfldr: "ELF লোডার, PS5Upload হেল্পারের আগে লোড হয়", payload_desc_elfldr: "যে লোডার পেলোড গ্রহণ করে। PS5Upload হেল্পারের আগে জেলব্রেক বা অটোলোডার দিয়ে এটি লোড করুন। এটি পাঠাতে আগে থেকে চালু লোডার লাগে: এটি বন্ধ পোর্ট খুলতে পারে না। হেল্পার সংযুক্ত হলে PS5Upload চলমান স্ট্যান্ডার্ড লোডারকে নিজের প্যাচ করা সংস্করণ দিয়ে বদলাতে পারে।", payload_role_kstuff_echostretch: "পড়া ও লেখার অধিকারসহ কার্নেল এক্সপ্লয়েট", -payload_desc_kstuff_echostretch: "ফার্মওয়্যার 1.00 থেকে 12.x-এর কার্নেল প্যাচার। ShadowMount+ এবং বেশিরভাগ বিশেষাধিকারপ্রাপ্ত পেলোডের এটি দরকার। এটি প্রথমে লোড করুন।", +payload_desc_kstuff_echostretch_v2: "1.00 থেকে 13.60 ফার্মওয়্যারের জন্য কার্নেল প্যাচার। ShadowMount+ ও বেশিরভাগ বিশেষাধিকারপ্রাপ্ত পেলোডের এটি লাগে। আগে এটি লোড করুন। 11.60-এর ওপরের ফার্মওয়্যারে PS5 ফেক গেমের জন্য নভেম্বর 2026-এর বা নতুন বিল্ড ব্যবহার করুন।", payload_role_kstuff_lite_drakmor: "কার্নেল এক্সপ্লয়েট, গেম ইমেজ দ্রুত মাউন্ট করে", payload_desc_kstuff_lite_drakmor: "kstuff-lite-এর একটি ফর্ক, যা .ffpkg ও PFS ইমেজ দ্রুত মাউন্ট করে। নতুন বিল্ড 12.xx পর্যন্ত ফার্মওয়্যারে চলে; আপনারটির জন্য রিলিজ নোট দেখুন। এটি স্বয়ংক্রিয় মাউন্ট বন্ধ করতে পারে (noautomount)। আপনি মূলত গেম ইমেজের সঙ্গে ShadowMount+ ব্যবহার করলে এটি সেরা। ShadowMount+ ও PS5Upload-এর আগে লোড করুন।", payload_role_shadowmountplus: "গেম ব্যাকআপ নিজে মাউন্ট ও নিবন্ধন করে", diff --git a/client/src/i18n/locales/de.ts b/client/src/i18n/locales/de.ts index 51008214a..505781409 100644 --- a/client/src/i18n/locales/de.ts +++ b/client/src/i18n/locales/de.ts @@ -1130,7 +1130,7 @@ ok: "OK", payload_role_elfldr: "ELF-Loader, wird vor dem PS5Upload-Helper geladen", payload_desc_elfldr: "Der Loader, der Payloads empfängt. Lade ihn über deinen Jailbreak oder Autoloader vor dem PS5Upload-Helper. Zum Senden braucht es einen Loader, der schon läuft: Ein geschlossener Port lässt sich damit nicht öffnen. Sobald der Helper verbunden ist, kann PS5Upload einen laufenden Standard-Loader durch seine gepatchte Version ersetzen.", payload_role_kstuff_echostretch: "Kernel-Exploit mit Lese- und Schreibzugriff", -payload_desc_kstuff_echostretch: "Kernel-Patcher für Firmware 1.00 bis 12.x. ShadowMount+ und die meisten anderen privilegierten Payloads brauchen ihn. Lade ihn zuerst.", +payload_desc_kstuff_echostretch_v2: "Kernel-Patcher für Firmware 1.00 bis 13.60. ShadowMount+ und die meisten anderen privilegierten Payloads brauchen ihn. Zuerst laden. Für PS5-Fake-Spiele auf Firmware über 11.60 den Build vom November 2026 oder neuer verwenden.", payload_role_kstuff_lite_drakmor: "Kernel-Exploit, hängt Spielabbilder schneller ein", payload_desc_kstuff_lite_drakmor: "Ein Fork von kstuff-lite, der .ffpkg- und PFS-Abbilder schneller einhängt. Neuere Versionen decken Firmware bis 12.xx ab; prüfe die Release-Notes für deine. Automatisches Einhängen lässt sich abschalten (noautomount). Am besten, wenn du vor allem ShadowMount+ mit Spielabbildern nutzt. Lade ihn vor ShadowMount+ und PS5Upload.", payload_role_shadowmountplus: "Hängt Spiel-Backups selbst ein und registriert sie", diff --git a/client/src/i18n/locales/en.ts b/client/src/i18n/locales/en.ts index d6efa1404..7b8244eb8 100644 --- a/client/src/i18n/locales/en.ts +++ b/client/src/i18n/locales/en.ts @@ -1704,7 +1704,7 @@ ok: "OK", payload_role_elfldr: "ELF loader, loaded before the PS5Upload helper", payload_desc_elfldr: "The loader that receives payloads. Load it through your jailbreak or autoloader before the PS5Upload helper. Sending it needs a loader that already works: it can't open a closed port. Once the helper is connected, PS5Upload can replace a running standard loader with its own patched build.", payload_role_kstuff_echostretch: "Kernel exploit with read and write access", -payload_desc_kstuff_echostretch: "Kernel patcher for firmware 1.00 to 12.x. ShadowMount+ and most other privileged payloads need it. Load this first.", +payload_desc_kstuff_echostretch_v2: "Kernel patcher for firmware 1.00 to 13.60. ShadowMount+ and most other privileged payloads need it. Load this first. For fake PS5 games on firmware above 11.60, use the November 2026 build or newer.", payload_role_kstuff_lite_drakmor: "Kernel exploit, faster at mounting game images", payload_desc_kstuff_lite_drakmor: "A fork of kstuff-lite that mounts .ffpkg and PFS images faster. Recent builds cover firmware up to 12.xx; check the release notes for yours. It can turn off automatic mounting (noautomount). Best when you mostly use ShadowMount+ with game images. Load it before ShadowMount+ and PS5Upload.", payload_role_shadowmountplus: "Mounts and registers game backups by itself", diff --git a/client/src/i18n/locales/es.ts b/client/src/i18n/locales/es.ts index 6c031db9f..b1ea91cb7 100644 --- a/client/src/i18n/locales/es.ts +++ b/client/src/i18n/locales/es.ts @@ -1129,7 +1129,7 @@ ok: "OK", payload_role_elfldr: "Cargador ELF, se carga antes del helper de PS5Upload", payload_desc_elfldr: "El cargador que recibe los payloads. Cárgalo con tu jailbreak o autoloader antes del helper de PS5Upload. Para enviarlo hace falta un cargador que ya funcione: no puede abrir un puerto cerrado. Cuando el helper está conectado, PS5Upload puede sustituir un cargador estándar en ejecución por su versión parcheada.", payload_role_kstuff_echostretch: "Exploit del kernel con acceso de lectura y escritura", -payload_desc_kstuff_echostretch: "Parcheador del kernel para firmware 1.00 a 12.x. ShadowMount+ y la mayoría de los payloads con privilegios lo necesitan. Cárgalo primero.", +payload_desc_kstuff_echostretch_v2: "Parcheador del kernel para firmware 1.00 a 13.60. ShadowMount+ y la mayoría de payloads con privilegios lo necesitan. Cárgalo primero. Para juegos falsos de PS5 en firmware superior a 11.60, usa la versión de noviembre de 2026 o posterior.", payload_role_kstuff_lite_drakmor: "Exploit del kernel, monta imágenes de juegos más rápido", payload_desc_kstuff_lite_drakmor: "Un fork de kstuff-lite que monta imágenes .ffpkg y PFS más rápido. Las versiones recientes cubren firmware hasta 12.xx; consulta las notas de la versión para el tuyo. Puede desactivar el montaje automático (noautomount). Es la mejor opción si usas sobre todo ShadowMount+ con imágenes de juegos. Cárgalo antes de ShadowMount+ y PS5Upload.", payload_role_shadowmountplus: "Monta y registra copias de juegos por sí solo", diff --git a/client/src/i18n/locales/fa.ts b/client/src/i18n/locales/fa.ts index 358c3bd5d..641d7629d 100644 --- a/client/src/i18n/locales/fa.ts +++ b/client/src/i18n/locales/fa.ts @@ -1607,7 +1607,7 @@ ok: "تأیید", payload_role_elfldr: "بارگذار ELF، پیش از helper برنامه PS5Upload بارگذاری می‌شود", payload_desc_elfldr: "بارگذاری که payloadها را دریافت می‌کند. آن را پیش از helper برنامه PS5Upload با جیلبریک یا autoloader بارگذاری کنید. ارسال آن به بارگذاری نیاز دارد که از قبل کار می‌کند: نمی‌تواند پورت بسته را باز کند. پس از اتصال helper، PS5Upload می‌تواند بارگذار استاندارد در حال اجرا را با نسخهٔ وصله‌شدهٔ خود جایگزین کند.", payload_role_kstuff_echostretch: "اکسپلویت کرنل با دسترسی خواندن و نوشتن", -payload_desc_kstuff_echostretch: "وصله‌کنندهٔ کرنل برای فریمور 1.00 تا 12.x. ShadowMount+ و بیشتر payloadهای دارای دسترسی ویژه به آن نیاز دارند. اول این را بارگذاری کنید.", +payload_desc_kstuff_echostretch_v2: "وصله‌گر هسته برای فریمور 1.00 تا 13.60. ShadowMount+ و بیشتر پی‌لودهای دارای دسترسی به آن نیاز دارند. اول آن را بارگذاری کنید. برای بازی‌های جعلی PS5 روی فریمور بالاتر از 11.60 از نسخه نوامبر 2026 یا جدیدتر استفاده کنید.", payload_role_kstuff_lite_drakmor: "اکسپلویت کرنل، ایمیج بازی‌ها را سریع‌تر متصل می‌کند", payload_desc_kstuff_lite_drakmor: "انشعابی از kstuff-lite که ایمیج‌های .ffpkg و PFS را سریع‌تر متصل می‌کند. نسخه‌های جدید تا فریمور 12.xx را پوشش می‌دهند؛ برای فریمور خود یادداشت انتشار را ببینید. می‌تواند اتصال خودکار را خاموش کند (noautomount). اگر بیشتر از ShadowMount+ با ایمیج بازی استفاده می‌کنید بهترین گزینه است. آن را پیش از ShadowMount+ و PS5Upload بارگذاری کنید.", payload_role_shadowmountplus: "نسخه‌های پشتیبان بازی را خودکار متصل و ثبت می‌کند", diff --git a/client/src/i18n/locales/fr.ts b/client/src/i18n/locales/fr.ts index fe3f53456..99b263fbb 100644 --- a/client/src/i18n/locales/fr.ts +++ b/client/src/i18n/locales/fr.ts @@ -1129,7 +1129,7 @@ ok: "OK", payload_role_elfldr: "Chargeur ELF, chargé avant le helper PS5Upload", payload_desc_elfldr: "Le chargeur qui reçoit les payloads. Chargez-le via votre jailbreak ou autoloader avant le helper PS5Upload. Pour l'envoyer, il faut un chargeur déjà actif : il ne peut pas ouvrir un port fermé. Une fois le helper connecté, PS5Upload peut remplacer un chargeur standard actif par sa version patchée.", payload_role_kstuff_echostretch: "Exploit noyau avec accès en lecture et en écriture", -payload_desc_kstuff_echostretch: "Patcheur du noyau pour les firmwares 1.00 à 12.x. ShadowMount+ et la plupart des payloads privilégiés en ont besoin. Chargez-le en premier.", +payload_desc_kstuff_echostretch_v2: "Patcheur du noyau pour les firmwares 1.00 à 13.60. ShadowMount+ et la plupart des autres payloads privilégiés en ont besoin. À charger en premier. Pour les faux jeux PS5 sur un firmware au-delà de 11.60, utilisez la version de novembre 2026 ou plus récente.", payload_role_kstuff_lite_drakmor: "Exploit noyau, monte plus vite les images de jeux", payload_desc_kstuff_lite_drakmor: "Un fork de kstuff-lite qui monte plus vite les images .ffpkg et PFS. Les versions récentes couvrent les firmwares jusqu'à 12.xx ; vérifiez les notes de version pour le vôtre. Il peut désactiver le montage automatique (noautomount). Idéal si vous utilisez surtout ShadowMount+ avec des images de jeux. Chargez-le avant ShadowMount+ et PS5Upload.", payload_role_shadowmountplus: "Monte et enregistre seul les sauvegardes de jeux", diff --git a/client/src/i18n/locales/hi.ts b/client/src/i18n/locales/hi.ts index a2ee933d6..4431dfc3f 100644 --- a/client/src/i18n/locales/hi.ts +++ b/client/src/i18n/locales/hi.ts @@ -1130,7 +1130,7 @@ ok: "ठीक है", payload_role_elfldr: "ELF लोडर, PS5Upload हेल्पर से पहले लोड होता है", payload_desc_elfldr: "पेलोड लेने वाला लोडर। इसे PS5Upload हेल्पर से पहले जेलब्रेक या ऑटोलोडर से लोड करें। इसे भेजने के लिए पहले से चल रहा लोडर चाहिए: यह बंद पोर्ट नहीं खोल सकता। हेल्पर जुड़ने के बाद PS5Upload चल रहे मानक लोडर को अपने पैच किए संस्करण से बदल सकता है।", payload_role_kstuff_echostretch: "पढ़ने और लिखने की पहुँच वाला कर्नेल एक्सप्लॉइट", -payload_desc_kstuff_echostretch: "फ़र्मवेयर 1.00 से 12.x के लिए कर्नेल पैचर। ShadowMount+ और ज़्यादातर विशेषाधिकार वाले पेलोड को इसकी ज़रूरत है। इसे सबसे पहले लोड करें।", +payload_desc_kstuff_echostretch_v2: "1.00 से 13.60 फ़र्मवेयर के लिए कर्नेल पैचर। ShadowMount+ और ज़्यादातर विशेषाधिकार वाले पेलोड को इसकी ज़रूरत है। इसे पहले लोड करें। 11.60 से ऊपर के फ़र्मवेयर पर PS5 फ़ेक गेम के लिए नवंबर 2026 का या नया बिल्ड इस्तेमाल करें।", payload_role_kstuff_lite_drakmor: "कर्नेल एक्सप्लॉइट, गेम इमेज तेज़ी से माउंट करता है", payload_desc_kstuff_lite_drakmor: "kstuff-lite का फ़ोर्क जो .ffpkg और PFS इमेज तेज़ी से माउंट करता है। नए बिल्ड 12.xx तक के फ़र्मवेयर पर चलते हैं; अपने फ़र्मवेयर के लिए रिलीज़ नोट देखें। यह अपने आप माउंट होना बंद कर सकता है (noautomount)। अगर आप ज़्यादातर गेम इमेज के साथ ShadowMount+ इस्तेमाल करते हैं तो यह सबसे अच्छा है। इसे ShadowMount+ और PS5Upload से पहले लोड करें।", payload_role_shadowmountplus: "गेम बैकअप खुद माउंट और रजिस्टर करता है", diff --git a/client/src/i18n/locales/hu.ts b/client/src/i18n/locales/hu.ts index 6d58af5a2..31670ec85 100644 --- a/client/src/i18n/locales/hu.ts +++ b/client/src/i18n/locales/hu.ts @@ -1429,7 +1429,7 @@ ok: "OK", payload_role_elfldr: "ELF-betöltő, a PS5Upload helper előtt töltődik be", payload_desc_elfldr: "A payloadokat fogadó betöltő. Töltsd be a jailbreakkel vagy autoloaderrel a PS5Upload helper előtt. Elküldéséhez már működő betöltő kell: zárt portot nem tud megnyitni. Ha a helper csatlakozott, a PS5Upload a futó szabványos betöltőt lecserélheti a saját javított változatára.", payload_role_kstuff_echostretch: "Kernel exploit olvasási és írási hozzáféréssel", -payload_desc_kstuff_echostretch: "Kernel-javító az 1.00–12.x firmware-ekhez. A ShadowMount+-nak és a legtöbb kiemelt jogú payloadnak szüksége van rá. Ezt töltsd be először.", +payload_desc_kstuff_echostretch_v2: "Kernelpatcher 1.00 és 13.60 közötti firmware-hez. A ShadowMount+-nak és a legtöbb jogosultságot igénylő payloadnak kell. Ezt töltsd be először. 11.60 feletti firmware-en a PS5 hamis játékokhoz a 2026. novemberi vagy újabb változatot használd.", payload_role_kstuff_lite_drakmor: "Kernel exploit, gyorsabban csatolja a játékképfájlokat", payload_desc_kstuff_lite_drakmor: "A kstuff-lite elágazása, amely gyorsabban csatolja a .ffpkg és PFS képfájlokat. Az újabb kiadások 12.xx-ig támogatják a firmware-t; nézd meg a kiadási megjegyzéseket. Az automatikus csatolás kikapcsolható (noautomount). Akkor a legjobb, ha főleg ShadowMount+-szal és képfájlokkal dolgozol. Töltsd be a ShadowMount+ és a PS5Upload előtt.", payload_role_shadowmountplus: "Magától csatolja és regisztrálja a játékmentéseket", diff --git a/client/src/i18n/locales/id.ts b/client/src/i18n/locales/id.ts index b99729856..7c272ad78 100644 --- a/client/src/i18n/locales/id.ts +++ b/client/src/i18n/locales/id.ts @@ -1129,7 +1129,7 @@ ok: "OK", payload_role_elfldr: "Pemuat ELF, dimuat sebelum helper PS5Upload", payload_desc_elfldr: "Pemuat yang menerima payload. Muat lewat jailbreak atau autoloader sebelum helper PS5Upload. Mengirimnya butuh pemuat yang sudah berjalan: ia tidak bisa membuka port yang tertutup. Setelah helper terhubung, PS5Upload dapat mengganti pemuat standar yang berjalan dengan versi tambalannya.", payload_role_kstuff_echostretch: "Exploit kernel dengan akses baca dan tulis", -payload_desc_kstuff_echostretch: "Penambal kernel untuk firmware 1.00 sampai 12.x. ShadowMount+ dan sebagian besar payload berhak istimewa membutuhkannya. Muat ini dulu.", +payload_desc_kstuff_echostretch_v2: "Patcher kernel untuk firmware 1.00 hingga 13.60. ShadowMount+ dan sebagian besar payload berhak istimewa lainnya membutuhkannya. Muat ini lebih dulu. Untuk game palsu PS5 di firmware di atas 11.60, gunakan build November 2026 atau lebih baru.", payload_role_kstuff_lite_drakmor: "Exploit kernel, lebih cepat me-mount image game", payload_desc_kstuff_lite_drakmor: "Fork kstuff-lite yang me-mount image .ffpkg dan PFS lebih cepat. Build terbaru mencakup firmware sampai 12.xx; periksa catatan rilis untuk firmware Anda. Mount otomatis bisa dimatikan (noautomount). Paling cocok jika Anda terutama memakai ShadowMount+ dengan image game. Muat sebelum ShadowMount+ dan PS5Upload.", payload_role_shadowmountplus: "Me-mount dan mendaftarkan cadangan game sendiri", diff --git a/client/src/i18n/locales/it.ts b/client/src/i18n/locales/it.ts index d5ad9a653..ab65ef6ee 100644 --- a/client/src/i18n/locales/it.ts +++ b/client/src/i18n/locales/it.ts @@ -1129,7 +1129,7 @@ ok: "OK", payload_role_elfldr: "Loader ELF, caricato prima dell'helper di PS5Upload", payload_desc_elfldr: "Il loader che riceve i payload. Caricalo con il tuo jailbreak o autoloader prima dell'helper di PS5Upload. Per inviarlo serve un loader già attivo: non può aprire una porta chiusa. Con l'helper connesso, PS5Upload può sostituire un loader standard in esecuzione con la sua versione modificata.", payload_role_kstuff_echostretch: "Exploit del kernel con accesso in lettura e scrittura", -payload_desc_kstuff_echostretch: "Patcher del kernel per firmware da 1.00 a 12.x. ShadowMount+ e la maggior parte dei payload privilegiati ne hanno bisogno. Caricalo per primo.", +payload_desc_kstuff_echostretch_v2: "Patcher del kernel per i firmware dall'1.00 al 13.60. Serve a ShadowMount+ e alla maggior parte degli altri payload privilegiati. Caricalo per primo. Per i giochi fake PS5 sui firmware oltre l'11.60, usa la build di novembre 2026 o più recente.", payload_role_kstuff_lite_drakmor: "Exploit del kernel, monta più in fretta le immagini dei giochi", payload_desc_kstuff_lite_drakmor: "Un fork di kstuff-lite che monta più in fretta le immagini .ffpkg e PFS. Le versioni recenti coprono i firmware fino a 12.xx; controlla le note di rilascio per il tuo. Può disattivare il montaggio automatico (noautomount). Ideale se usi soprattutto ShadowMount+ con immagini di giochi. Caricalo prima di ShadowMount+ e PS5Upload.", payload_role_shadowmountplus: "Monta e registra da solo i backup dei giochi", diff --git a/client/src/i18n/locales/ja.ts b/client/src/i18n/locales/ja.ts index cd7e2ccd5..3db7ae5fa 100644 --- a/client/src/i18n/locales/ja.ts +++ b/client/src/i18n/locales/ja.ts @@ -1130,7 +1130,7 @@ ok: "OK", payload_role_elfldr: "ELF ローダー。PS5Upload ヘルパーより先に読み込みます", payload_desc_elfldr: "ペイロードを受け取るローダーです。PS5Upload ヘルパーより先に、ジェイルブレイクまたはオートローダーで読み込んでください。送信には動作中のローダーが必要で、閉じたポートは開けません。ヘルパーの接続後は、動作中の標準ローダーを PS5Upload のパッチ版に置き換えられます。", payload_role_kstuff_echostretch: "読み書きアクセス付きのカーネルエクスプロイト", -payload_desc_kstuff_echostretch: "ファームウェア 1.00〜12.x 用のカーネルパッチャーです。ShadowMount+ と多くの特権ペイロードに必要です。最初に読み込んでください。", +payload_desc_kstuff_echostretch_v2: "ファームウェア 1.00〜13.60 用のカーネルパッチャー。ShadowMount+ をはじめ、権限が必要なほとんどのペイロードに必要です。最初に読み込んでください。11.60 より上のファームウェアで PS5 のフェイクゲームを使うには、2026 年 11 月以降のビルドを使ってください。", payload_role_kstuff_lite_drakmor: "ゲームイメージのマウントが速いカーネルエクスプロイト", payload_desc_kstuff_lite_drakmor: "kstuff-lite のフォークで、.ffpkg と PFS イメージを速くマウントします。最近のビルドは 12.xx まで対応しています。お使いのファームウェアはリリースノートで確認してください。自動マウントは無効にできます(noautomount)。主に ShadowMount+ とゲームイメージを使う場合に最適です。ShadowMount+ と PS5Upload より先に読み込んでください。", payload_role_shadowmountplus: "ゲームバックアップを自動でマウントして登録", diff --git a/client/src/i18n/locales/ko.ts b/client/src/i18n/locales/ko.ts index e3b9f99f5..05a8f2f2a 100644 --- a/client/src/i18n/locales/ko.ts +++ b/client/src/i18n/locales/ko.ts @@ -1130,7 +1130,7 @@ ok: "확인", payload_role_elfldr: "ELF 로더, PS5Upload 헬퍼보다 먼저 로드", payload_desc_elfldr: "페이로드를 받는 로더입니다. PS5Upload 헬퍼보다 먼저 탈옥 또는 오토로더로 로드하세요. 전송하려면 이미 작동 중인 로더가 필요하며, 닫힌 포트를 열 수는 없습니다. 헬퍼가 연결되면 PS5Upload가 실행 중인 표준 로더를 자체 패치 버전으로 교체할 수 있습니다.", payload_role_kstuff_echostretch: "읽기 및 쓰기 권한이 있는 커널 익스플로잇", -payload_desc_kstuff_echostretch: "펌웨어 1.00~12.x용 커널 패처입니다. ShadowMount+와 대부분의 특권 페이로드에 필요합니다. 가장 먼저 로드하세요.", +payload_desc_kstuff_echostretch_v2: "펌웨어 1.00~13.60용 커널 패처. ShadowMount+와 대부분의 권한이 필요한 페이로드에 필요합니다. 가장 먼저 불러오세요. 11.60보다 높은 펌웨어에서 PS5 페이크 게임을 쓰려면 2026년 11월 이후 빌드를 사용하세요.", payload_role_kstuff_lite_drakmor: "게임 이미지를 더 빨리 마운트하는 커널 익스플로잇", payload_desc_kstuff_lite_drakmor: ".ffpkg와 PFS 이미지를 더 빨리 마운트하는 kstuff-lite 포크입니다. 최신 빌드는 12.xx까지 지원합니다. 사용 중인 펌웨어는 릴리스 노트에서 확인하세요. 자동 마운트를 끌 수 있습니다(noautomount). 주로 ShadowMount+와 게임 이미지를 쓴다면 가장 좋습니다. ShadowMount+와 PS5Upload보다 먼저 로드하세요.", payload_role_shadowmountplus: "게임 백업을 스스로 마운트하고 등록", diff --git a/client/src/i18n/locales/pl.ts b/client/src/i18n/locales/pl.ts index db9753862..c961ff642 100644 --- a/client/src/i18n/locales/pl.ts +++ b/client/src/i18n/locales/pl.ts @@ -1382,7 +1382,7 @@ ok: "OK", payload_role_elfldr: "Loader ELF, ładowany przed helperem PS5Upload", payload_desc_elfldr: "Loader odbierający payloady. Załaduj go przez jailbreak lub autoloader przed helperem PS5Upload. Do wysłania potrzebny jest działający już loader: nie otworzy zamkniętego portu. Gdy helper jest połączony, PS5Upload może zastąpić działający standardowy loader swoją poprawioną wersją.", payload_role_kstuff_echostretch: "Exploit jądra z dostępem do odczytu i zapisu", -payload_desc_kstuff_echostretch: "Patcher jądra dla firmware'u od 1.00 do 12.x. Potrzebują go ShadowMount+ i większość uprzywilejowanych payloadów. Załaduj go najpierw.", +payload_desc_kstuff_echostretch_v2: "Patcher jądra dla oprogramowania od 1.00 do 13.60. Potrzebuje go ShadowMount+ i większość innych uprzywilejowanych payloadów. Załaduj go jako pierwszy. Dla fałszywych gier PS5 na oprogramowaniu powyżej 11.60 użyj wersji z listopada 2026 lub nowszej.", payload_role_kstuff_lite_drakmor: "Exploit jądra, szybciej montuje obrazy gier", payload_desc_kstuff_lite_drakmor: "Fork kstuff-lite, który szybciej montuje obrazy .ffpkg i PFS. Nowsze wersje obejmują firmware do 12.xx; sprawdź informacje o wydaniu dla swojego. Można wyłączyć automatyczne montowanie (noautomount). Najlepszy, jeśli używasz głównie ShadowMount+ z obrazami gier. Załaduj go przed ShadowMount+ i PS5Upload.", payload_role_shadowmountplus: "Sam montuje i rejestruje kopie gier", diff --git a/client/src/i18n/locales/pt-BR.ts b/client/src/i18n/locales/pt-BR.ts index 5e1f94dbb..52a3dd55e 100644 --- a/client/src/i18n/locales/pt-BR.ts +++ b/client/src/i18n/locales/pt-BR.ts @@ -1129,7 +1129,7 @@ ok: "OK", payload_role_elfldr: "Carregador ELF, carregado antes do helper do PS5Upload", payload_desc_elfldr: "O carregador que recebe os payloads. Carregue-o pelo seu jailbreak ou autoloader antes do helper do PS5Upload. Para enviá-lo é preciso um carregador já ativo: ele não abre uma porta fechada. Com o helper conectado, o PS5Upload pode trocar um carregador padrão em execução pela sua versão modificada.", payload_role_kstuff_echostretch: "Exploit de kernel com acesso de leitura e escrita", -payload_desc_kstuff_echostretch: "Patcher de kernel para firmware 1.00 a 12.x. O ShadowMount+ e a maioria dos payloads com privilégios precisam dele. Carregue-o primeiro.", +payload_desc_kstuff_echostretch_v2: "Patcher do kernel para firmware 1.00 a 13.60. O ShadowMount+ e a maioria dos outros payloads com privilégios precisam dele. Carregue-o primeiro. Para jogos fake de PS5 em firmware acima de 11.60, use a versão de novembro de 2026 ou mais nova.", payload_role_kstuff_lite_drakmor: "Exploit de kernel, monta imagens de jogos mais rápido", payload_desc_kstuff_lite_drakmor: "Um fork do kstuff-lite que monta imagens .ffpkg e PFS mais rápido. Versões recentes cobrem firmware até 12.xx; veja as notas da versão para o seu. Pode desligar a montagem automática (noautomount). Melhor se você usa principalmente o ShadowMount+ com imagens de jogos. Carregue-o antes do ShadowMount+ e do PS5Upload.", payload_role_shadowmountplus: "Monta e registra backups de jogos sozinho", diff --git a/client/src/i18n/locales/ru.ts b/client/src/i18n/locales/ru.ts index 724e3a5ee..1362c29a2 100644 --- a/client/src/i18n/locales/ru.ts +++ b/client/src/i18n/locales/ru.ts @@ -1129,7 +1129,7 @@ ok: "OK", payload_role_elfldr: "Загрузчик ELF, загружается перед хелпером PS5Upload", payload_desc_elfldr: "Загрузчик, принимающий пейлоады. Загрузите его через джейлбрейк или автозагрузчик перед хелпером PS5Upload. Для отправки нужен уже работающий загрузчик: закрытый порт он открыть не может. Когда хелпер подключён, PS5Upload может заменить работающий стандартный загрузчик своей исправленной версией.", payload_role_kstuff_echostretch: "Эксплойт ядра с доступом на чтение и запись", -payload_desc_kstuff_echostretch: "Патчер ядра для прошивок от 1.00 до 12.x. Он нужен ShadowMount+ и большинству привилегированных пейлоадов. Загружайте его первым.", +payload_desc_kstuff_echostretch_v2: "Патчер ядра для прошивок 1.00–13.60. Он нужен ShadowMount+ и большинству других привилегированных пейлоадов. Загружайте его первым. Для фейковых игр PS5 на прошивке выше 11.60 используйте сборку ноября 2026 или новее.", payload_role_kstuff_lite_drakmor: "Эксплойт ядра, быстрее монтирует образы игр", payload_desc_kstuff_lite_drakmor: "Форк kstuff-lite, который быстрее монтирует образы .ffpkg и PFS. Новые сборки поддерживают прошивки до 12.xx; проверьте свою в примечаниях к выпуску. Автомонтирование можно отключить (noautomount). Лучший выбор, если вы в основном используете ShadowMount+ с образами игр. Загружайте его перед ShadowMount+ и PS5Upload.", payload_role_shadowmountplus: "Сам монтирует и регистрирует резервные копии игр", diff --git a/client/src/i18n/locales/th.ts b/client/src/i18n/locales/th.ts index 3b390be84..ab8103eca 100644 --- a/client/src/i18n/locales/th.ts +++ b/client/src/i18n/locales/th.ts @@ -1129,7 +1129,7 @@ ok: "ตกลง", payload_role_elfldr: "ตัวโหลด ELF โหลดก่อนตัวช่วย PS5Upload", payload_desc_elfldr: "ตัวโหลดที่รับเพย์โหลด โหลดผ่านการเจลเบรกหรือออโตโหลดเดอร์ก่อนตัวช่วย PS5Upload การส่งต้องมีตัวโหลดที่ทำงานอยู่แล้ว เพราะเปิดพอร์ตที่ปิดอยู่ไม่ได้ เมื่อตัวช่วยเชื่อมต่อแล้ว PS5Upload สามารถแทนที่ตัวโหลดมาตรฐานที่ทำงานอยู่ด้วยรุ่นที่แพตช์ของตัวเอง", payload_role_kstuff_echostretch: "ช่องโหว่เคอร์เนลพร้อมสิทธิ์อ่านและเขียน", -payload_desc_kstuff_echostretch: "ตัวแพตช์เคอร์เนลสำหรับเฟิร์มแวร์ 1.00 ถึง 12.x ShadowMount+ และเพย์โหลดสิทธิ์สูงส่วนใหญ่ต้องใช้ โหลดตัวนี้ก่อน", +payload_desc_kstuff_echostretch_v2: "ตัวแพตช์เคอร์เนลสำหรับเฟิร์มแวร์ 1.00 ถึง 13.60 ShadowMount+ และเพย์โหลดที่ต้องใช้สิทธิ์ส่วนใหญ่ต้องใช้ โหลดตัวนี้ก่อน สำหรับเกมปลอม PS5 บนเฟิร์มแวร์ที่สูงกว่า 11.60 ให้ใช้รุ่นพฤศจิกายน 2026 หรือใหม่กว่า", payload_role_kstuff_lite_drakmor: "ช่องโหว่เคอร์เนล เมานต์อิมเมจเกมได้เร็วกว่า", payload_desc_kstuff_lite_drakmor: "ฟอร์กของ kstuff-lite ที่เมานต์อิมเมจ .ffpkg และ PFS ได้เร็วกว่า รุ่นใหม่รองรับเฟิร์มแวร์ถึง 12.xx ตรวจสอบบันทึกประจำรุ่นสำหรับเครื่องของคุณ ปิดการเมานต์อัตโนมัติได้ (noautomount) เหมาะที่สุดเมื่อใช้ ShadowMount+ กับอิมเมจเกมเป็นหลัก โหลดก่อน ShadowMount+ และ PS5Upload", payload_role_shadowmountplus: "เมานต์และลงทะเบียนไฟล์สำรองเกมเอง", diff --git a/client/src/i18n/locales/tr.ts b/client/src/i18n/locales/tr.ts index 4460485f9..9e9dec841 100644 --- a/client/src/i18n/locales/tr.ts +++ b/client/src/i18n/locales/tr.ts @@ -1129,7 +1129,7 @@ ok: "Tamam", payload_role_elfldr: "ELF yükleyici, PS5Upload yardımcısından önce yüklenir", payload_desc_elfldr: "Yükleri alan yükleyici. PS5Upload yardımcısından önce jailbreak veya otomatik yükleyicinle yükle. Göndermek için zaten çalışan bir yükleyici gerekir: kapalı bir bağlantı noktasını açamaz. Yardımcı bağlanınca PS5Upload çalışan standart yükleyiciyi kendi yamalı sürümüyle değiştirebilir.", payload_role_kstuff_echostretch: "Okuma ve yazma erişimli çekirdek açığı", -payload_desc_kstuff_echostretch: "1.00 ile 12.x arası yazılımlar için çekirdek yamacısı. ShadowMount+ ve yetkili yüklerin çoğu buna ihtiyaç duyar. İlk bunu yükle.", +payload_desc_kstuff_echostretch_v2: "1.00 ile 13.60 arası yazılımlar için çekirdek yamacısı. ShadowMount+ ve ayrıcalık gerektiren çoğu payload buna ihtiyaç duyar. Önce bunu yükleyin. 11.60 üzerindeki yazılımlarda PS5 sahte oyunları için Kasım 2026 veya daha yeni sürümü kullanın.", payload_role_kstuff_lite_drakmor: "Çekirdek açığı, oyun kalıplarını daha hızlı bağlar", payload_desc_kstuff_lite_drakmor: "kstuff-lite'ın .ffpkg ve PFS kalıplarını daha hızlı bağlayan bir çatalı. Yeni sürümler 12.xx'e kadar yazılımları kapsar; kendininki için sürüm notlarına bak. Otomatik bağlamayı kapatabilir (noautomount). Çoğunlukla ShadowMount+ ve oyun kalıpları kullanıyorsan en iyisi budur. ShadowMount+ ve PS5Upload'dan önce yükle.", payload_role_shadowmountplus: "Oyun yedeklerini kendiliğinden bağlar ve kaydeder", diff --git a/client/src/i18n/locales/vi.ts b/client/src/i18n/locales/vi.ts index 3553241c1..b500427d9 100644 --- a/client/src/i18n/locales/vi.ts +++ b/client/src/i18n/locales/vi.ts @@ -1131,7 +1131,7 @@ ok: "OK", payload_role_elfldr: "Trình tải ELF, tải trước helper của PS5Upload", payload_desc_elfldr: "Trình tải nhận payload. Hãy tải nó qua jailbreak hoặc autoloader trước helper của PS5Upload. Muốn gửi nó phải có trình tải đang chạy: nó không mở được cổng đang đóng. Khi helper đã kết nối, PS5Upload có thể thay trình tải chuẩn đang chạy bằng bản đã vá của mình.", payload_role_kstuff_echostretch: "Khai thác kernel có quyền đọc và ghi", -payload_desc_kstuff_echostretch: "Trình vá kernel cho firmware 1.00 đến 12.x. ShadowMount+ và hầu hết payload đặc quyền đều cần nó. Hãy tải nó trước.", +payload_desc_kstuff_echostretch_v2: "Bộ vá kernel cho firmware 1.00 đến 13.60. ShadowMount+ và hầu hết payload cần đặc quyền khác đều cần nó. Hãy nạp nó trước. Với game giả PS5 trên firmware cao hơn 11.60, hãy dùng bản tháng 11/2026 hoặc mới hơn.", payload_role_kstuff_lite_drakmor: "Khai thác kernel, gắn ảnh game nhanh hơn", payload_desc_kstuff_lite_drakmor: "Một nhánh của kstuff-lite gắn ảnh .ffpkg và PFS nhanh hơn. Các bản mới hỗ trợ firmware đến 12.xx; xem ghi chú phát hành cho máy của bạn. Có thể tắt gắn tự động (noautomount). Phù hợp nhất nếu bạn chủ yếu dùng ShadowMount+ với ảnh game. Tải nó trước ShadowMount+ và PS5Upload.", payload_role_shadowmountplus: "Tự gắn và đăng ký bản sao lưu game", diff --git a/client/src/i18n/locales/zh-CN.ts b/client/src/i18n/locales/zh-CN.ts index 127d09331..d4a438c6e 100644 --- a/client/src/i18n/locales/zh-CN.ts +++ b/client/src/i18n/locales/zh-CN.ts @@ -1136,7 +1136,7 @@ ok: "确定", payload_role_elfldr: "ELF 加载器,在 PS5Upload 助手之前加载", payload_desc_elfldr: "接收 payload 的加载器。请在 PS5Upload 助手之前,通过越狱或自动加载器加载它。发送它需要已在运行的加载器:它无法打开已关闭的端口。助手连接后,PS5Upload 可以用自己的修补版替换正在运行的标准加载器。", payload_role_kstuff_echostretch: "带读写权限的内核漏洞利用", -payload_desc_kstuff_echostretch: "适用于固件 1.00 到 12.x 的内核补丁程序。ShadowMount+ 和大多数特权 payload 都需要它。请最先加载。", +payload_desc_kstuff_echostretch_v2: "适用于 1.00 至 13.60 固件的内核补丁程序。ShadowMount+ 和大多数其他需要权限的载荷都依赖它。请先加载它。在高于 11.60 的固件上运行 PS5 伪造游戏,请使用 2026 年 11 月或更新的版本。", payload_role_kstuff_lite_drakmor: "内核漏洞利用,挂载游戏镜像更快", payload_desc_kstuff_lite_drakmor: "kstuff-lite 的分支,挂载 .ffpkg 和 PFS 镜像更快。较新的版本支持到固件 12.xx;请在发行说明中确认你的固件。可以关闭自动挂载(noautomount)。如果你主要用 ShadowMount+ 和游戏镜像,它最合适。请在 ShadowMount+ 和 PS5Upload 之前加载。", payload_role_shadowmountplus: "自动挂载并注册游戏备份", diff --git a/client/src/i18n/locales/zh-TW.ts b/client/src/i18n/locales/zh-TW.ts index 4af92db66..2967bf90a 100644 --- a/client/src/i18n/locales/zh-TW.ts +++ b/client/src/i18n/locales/zh-TW.ts @@ -1130,7 +1130,7 @@ ok: "確定", payload_role_elfldr: "ELF 載入器,在 PS5Upload 助手之前載入", payload_desc_elfldr: "接收 payload 的載入器。請在 PS5Upload 助手之前,透過越獄或自動載入器載入它。傳送它需要已在執行的載入器:它無法開啟已關閉的連接埠。助手連線後,PS5Upload 可以用自己的修補版取代正在執行的標準載入器。", payload_role_kstuff_echostretch: "具讀寫權限的核心漏洞利用", -payload_desc_kstuff_echostretch: "適用於韌體 1.00 到 12.x 的核心修補程式。ShadowMount+ 和大多數特權 payload 都需要它。請最先載入。", +payload_desc_kstuff_echostretch_v2: "適用於 1.00 至 13.60 韌體的核心修補程式。ShadowMount+ 和大多數其他需要權限的載荷都依賴它。請先載入它。在高於 11.60 的韌體上執行 PS5 偽造遊戲,請使用 2026 年 11 月或更新的版本。", payload_role_kstuff_lite_drakmor: "核心漏洞利用,掛載遊戲映像更快", payload_desc_kstuff_lite_drakmor: "kstuff-lite 的分支,掛載 .ffpkg 和 PFS 映像更快。較新的版本支援到韌體 12.xx;請在發行說明中確認你的韌體。可以關閉自動掛載(noautomount)。如果你主要用 ShadowMount+ 和遊戲映像,它最合適。請在 ShadowMount+ 和 PS5Upload 之前載入。", payload_role_shadowmountplus: "自動掛載並註冊遊戲備份", diff --git a/client/src/lib/payloadCatalogText.ts b/client/src/lib/payloadCatalogText.ts index baa678e59..e0eca95b2 100644 --- a/client/src/lib/payloadCatalogText.ts +++ b/client/src/lib/payloadCatalogText.ts @@ -8,7 +8,7 @@ type Tr = (key: string, vars: Record<string, string | number> | undefined, fallb /** By catalogue id. Written out, so the checks for unused and missing keys can read them. */ export const CATALOG_KEYS: Record<string, [role: string, description: string]> = { "elfldr": ["payload_role_elfldr", "payload_desc_elfldr"], - "kstuff-echostretch": ["payload_role_kstuff_echostretch", "payload_desc_kstuff_echostretch"], + "kstuff-echostretch": ["payload_role_kstuff_echostretch", "payload_desc_kstuff_echostretch_v2"], "kstuff-lite-drakmor": ["payload_role_kstuff_lite_drakmor", "payload_desc_kstuff_lite_drakmor"], "shadowmountplus": ["payload_role_shadowmountplus", "payload_desc_shadowmountplus"], "etahen": ["payload_role_etahen", "payload_desc_etahen"], diff --git a/engine/crates/ps5upload-core/src/payload_library/catalogue.rs b/engine/crates/ps5upload-core/src/payload_library/catalogue.rs index 1a773be10..0386fda85 100644 --- a/engine/crates/ps5upload-core/src/payload_library/catalogue.rs +++ b/engine/crates/ps5upload-core/src/payload_library/catalogue.rs @@ -71,7 +71,7 @@ pub(super) struct CatalogueEntry { /// /// Sources for the entries: /// -/// - kstuff-echostretch: covers FW 1.00 → 12.x via runtime NID +/// - kstuff-echostretch: covers FW 1.00 → 13.60 via runtime NID /// resolution; the same binary works on every supported firmware /// revision. Best default when firmware coverage matters most. /// - kstuff-lite-drakmor: fork of EchoStretch/kstuff-lite tuned for @@ -113,7 +113,7 @@ pub(super) const CATALOGUE: &[CatalogueEntry] = &[ id: "kstuff-echostretch", display_name: "kstuff-lite (EchoStretch)", role: "Kernel exploit + R/W primitive", - description: "Kernel patcher for the full PS5 firmware range. Resolves kernel symbols at runtime via the SDK's NID table, so the same binary covers FW 1.00 → 12.x. Required by ShadowMountPlus and most other privileged payloads. Load this first.", + description: "Kernel patcher for the full PS5 firmware range. Resolves kernel symbols at runtime via the SDK's NID table, so the same binary covers FW 1.00 → 13.60. Required by ShadowMountPlus and most other privileged payloads. Load this first.", repo_host: "github.com", repo_owner: "EchoStretch", repo_name: "kstuff-lite", diff --git a/scripts/i18n-source-hashes.json b/scripts/i18n-source-hashes.json index 6f1d391f8..123182a86 100644 --- a/scripts/i18n-source-hashes.json +++ b/scripts/i18n-source-hashes.json @@ -5679,7 +5679,7 @@ "payload_desc_hush": "06f9c01d XCyAx-_KeS2vxj5w7-ep_NiHAR-orogRp-ZemAAJyBW2T02poLRpToEPh0_n", "payload_desc_itemzflow": "62deb73a v68ripur7LWI8VXVIBJSvRcWEa8e5kz0Ek3oDF98DIxRBQ7303cjY99Ejel4", "payload_desc_klogsrv": "59fd9bd3 hSSVCtPqFAx6rWmBABe0QxIgZiu7Q_dzxAR0TJ0AeZiDhs4n4s5KjEKUKfN8", - "payload_desc_kstuff_echostretch": "fa1f0798 B-UR8yIz-UpfG_he5iWw1y1RC06gvouKKvB4w00GicK1Q5-mhQ2XcwpYVf3H", + "payload_desc_kstuff_echostretch_v2": "ae0f3f9d fwJDOFeI4O3Fd00EaS3j63HwdPqS4kBH_YX76h5WGQJMM5Z3vX-3SxkUzL7K", "payload_desc_kstuff_lite_drakmor": "4e4b6c0e A8ET5uLvbaCCUi4TBRZ4JquOXmKDG1IWx_UN87OONnzt5p_bM5Fe9xSWXTmp", "payload_desc_lz4_compression": "2421a680 V4S85pRLU359ysZtzLi6ZKscR_3oFC9CXNNG5yFzBZK6RpcnYpx3QZWFr4IA", "payload_desc_nanodns": "4e933c6d BxMeX3l6oVeZKIqionuh5LynFOFIlhm8AYBkb51bBgas1DI8ebMW_PSmNEwy", From 2e4a6c68a372eeaeb74d61ff45615f72086193bc Mon Sep 17 00:00:00 2001 From: phantomptr <phantomptr@gmail.com> Date: Tue, 24 Nov 2026 22:30:01 -0800 Subject: [PATCH 11/12] 12.6.28 release notes; catch up to 12.6.27 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- CHANGELOG.md | 13 +++++++++++ VERSION | 2 +- client/package-lock.json | 4 ++-- client/package.json | 2 +- client/src-tauri/Cargo.lock | 30 ++++++++++++------------ client/src-tauri/Cargo.toml | 2 +- client/src-tauri/tauri.conf.json | 2 +- engine/Cargo.lock | 40 ++++++++++++++++---------------- engine/Cargo.toml | 2 +- payload/include/config.h | 2 +- 10 files changed, 56 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 56f7591d7..3c804f6f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,19 @@ What's new in ps5upload, written for humans. ## Unreleased +**Fake packages (FPKG)** +- **Fake PS5 games play up to firmware 13.60.** A kstuff build with fake-package support up to 13.60 came out in November 2026. The app no longer warns that an installed fake PS5 game won't start on 11.61, 12.xx or 13.xx: the warning now appears only above 13.60. The fake-package note, Convert, the Payloads list, the FAQ and the README say that firmware above 11.60 needs that November 2026 kstuff (or newer). Convert again suggests a package, not an image, for a PS5 game on 13.60. +- **A fake PS5 game that won't start says why.** On 11.61 to 13.60, a launch that fails now adds that a game from a fake package needs the November 2026 kstuff, so load it and press Play again. + +**Play Together** +- **A friend sees the whole picture (#929).** On some Windows PCs a friend's picture was zoomed into its top-left corner, and on a wide window the bottom could fall below the screen. The friend's player now shows the whole picture, fitted to the window. + +**Saves** +- **Backup times show in your own time zone (#928).** Save backup times were shown in UTC. They now show in the device's local time, in the app's language. Backup names don't change. +- **EglantinePS5 Switch saves are backed up (#927, thanks EnriqueWood).** Automatic backups, Back up now and Restore now include EglantinePS5's Switch and Switch 2 saves, listed in their own group. Restore waits until EglantinePS5 is closed, and its saves never mix with ProsperoEden's, in backups or when two consoles sync. + +## 12.6.27 + **Install** - **PS4 add-ons install even when their title ID differs from the game's (#924).** Some games use a different title ID for their add-ons than for the game itself (Dead or Alive 5 Last Round: game CUSA01778, add-ons CUSA01601). The app refused those add-ons with "the base game is not on this PS5", even though the PS5 installs them fine. Add-ons are no longer checked for a base game; the PS5 decides. Updates still are, because the PS5 accepts an update without its game and then installs nothing. diff --git a/VERSION b/VERSION index 2340fa1f9..1868d5fbb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -12.6.26 +12.6.27 diff --git a/client/package-lock.json b/client/package-lock.json index 0338ec077..537e0a1db 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -1,12 +1,12 @@ { "name": "ps5upload-client", - "version": "12.6.26", + "version": "12.6.27", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ps5upload-client", - "version": "12.6.26", + "version": "12.6.27", "dependencies": { "@tauri-apps/api": "^2.12.5", "@tauri-apps/plugin-dialog": "^2.8.4", diff --git a/client/package.json b/client/package.json index aab73a120..7cbdf9bad 100644 --- a/client/package.json +++ b/client/package.json @@ -2,7 +2,7 @@ "name": "ps5upload-client", "private": true, "type": "module", - "version": "12.6.26", + "version": "12.6.27", "description": "The all-in-one PS5 companion app.", "homepage": "https://github.com/phantomptr/ps5upload", "author": "PhantomPtr <phantomptr@gmail.com>", diff --git a/client/src-tauri/Cargo.lock b/client/src-tauri/Cargo.lock index cf464b5c6..c497ec8a6 100644 --- a/client/src-tauri/Cargo.lock +++ b/client/src-tauri/Cargo.lock @@ -4743,7 +4743,7 @@ dependencies = [ [[package]] name = "ps5-dump-forge-exfat" -version = "12.6.26" +version = "12.6.27" dependencies = [ "ps5-dump-forge-patch", "ps5upload-fpkg", @@ -4752,14 +4752,14 @@ dependencies = [ [[package]] name = "ps5-dump-forge-patch" -version = "12.6.26" +version = "12.6.27" dependencies = [ "crc32fast", ] [[package]] name = "ps5-dump-forge-pfs" -version = "12.6.26" +version = "12.6.27" dependencies = [ "flate2", "ps5-dump-forge-patch", @@ -4768,7 +4768,7 @@ dependencies = [ [[package]] name = "ps5-dump-forge-ufs2" -version = "12.6.26" +version = "12.6.27" dependencies = [ "ps5-dump-forge-patch", "ps5upload-fpkg", @@ -4777,7 +4777,7 @@ dependencies = [ [[package]] name = "ps5-dump-forge-zstd" -version = "12.6.26" +version = "12.6.27" dependencies = [ "crc32fast", "getrandom 0.4.3", @@ -4788,7 +4788,7 @@ dependencies = [ [[package]] name = "ps5upload-archive" -version = "12.6.26" +version = "12.6.27" dependencies = [ "anyhow", "crc32fast", @@ -4798,7 +4798,7 @@ dependencies = [ [[package]] name = "ps5upload-ava1" -version = "12.6.26" +version = "12.6.27" dependencies = [ "anyhow", "ava1", @@ -4817,7 +4817,7 @@ dependencies = [ [[package]] name = "ps5upload-convert-core" -version = "12.6.26" +version = "12.6.27" dependencies = [ "blake3", "libc", @@ -4834,7 +4834,7 @@ dependencies = [ [[package]] name = "ps5upload-core" -version = "12.6.26" +version = "12.6.27" dependencies = [ "aes 0.9.2", "aes-gcm 0.11.0", @@ -4868,7 +4868,7 @@ dependencies = [ [[package]] name = "ps5upload-desktop" -version = "12.6.26" +version = "12.6.27" dependencies = [ "anyhow", "ava1", @@ -4909,7 +4909,7 @@ dependencies = [ [[package]] name = "ps5upload-engine" -version = "12.6.26" +version = "12.6.27" dependencies = [ "aes 0.9.2", "aes-gcm 0.11.0", @@ -4973,7 +4973,7 @@ dependencies = [ [[package]] name = "ps5upload-fpkg" -version = "12.6.26" +version = "12.6.27" dependencies = [ "aes 0.9.2", "crc32fast", @@ -4996,7 +4996,7 @@ dependencies = [ [[package]] name = "ps5upload-hub" -version = "12.6.26" +version = "12.6.27" dependencies = [ "axum", "base64 0.23.1", @@ -5010,7 +5010,7 @@ dependencies = [ [[package]] name = "ps5upload-pkg" -version = "12.6.26" +version = "12.6.27" dependencies = [ "aes 0.9.2", "blake3", @@ -5022,7 +5022,7 @@ dependencies = [ [[package]] name = "ps5upload-tailnet" -version = "12.6.26" +version = "12.6.27" dependencies = [ "cc", ] diff --git a/client/src-tauri/Cargo.toml b/client/src-tauri/Cargo.toml index 4eabe9503..378c495a2 100644 --- a/client/src-tauri/Cargo.toml +++ b/client/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ps5upload-desktop" -version = "12.6.26" +version = "12.6.27" description = "The all-in-one PS5 companion app." license = "GPL-3.0-or-later" edition = "2021" diff --git a/client/src-tauri/tauri.conf.json b/client/src-tauri/tauri.conf.json index 67012c11a..901c77deb 100644 --- a/client/src-tauri/tauri.conf.json +++ b/client/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "PS5Upload", - "version": "12.6.26", + "version": "12.6.27", "identifier": "com.phantomptr.ps5upload", "build": { "beforeDevCommand": "npm run dev:vite", diff --git a/engine/Cargo.lock b/engine/Cargo.lock index 85c776833..963dc1323 100644 --- a/engine/Cargo.lock +++ b/engine/Cargo.lock @@ -2561,7 +2561,7 @@ dependencies = [ [[package]] name = "ps5-dump-forge-exfat" -version = "12.6.26" +version = "12.6.27" dependencies = [ "ps5-dump-forge-patch", "ps5upload-fpkg", @@ -2570,14 +2570,14 @@ dependencies = [ [[package]] name = "ps5-dump-forge-patch" -version = "12.6.26" +version = "12.6.27" dependencies = [ "crc32fast", ] [[package]] name = "ps5-dump-forge-pfs" -version = "12.6.26" +version = "12.6.27" dependencies = [ "flate2", "ps5-dump-forge-patch", @@ -2587,7 +2587,7 @@ dependencies = [ [[package]] name = "ps5-dump-forge-ufs2" -version = "12.6.26" +version = "12.6.27" dependencies = [ "ps5-dump-forge-patch", "ps5upload-fpkg", @@ -2597,7 +2597,7 @@ dependencies = [ [[package]] name = "ps5-dump-forge-zstd" -version = "12.6.26" +version = "12.6.27" dependencies = [ "crc32fast", "getrandom 0.4.3", @@ -2608,7 +2608,7 @@ dependencies = [ [[package]] name = "ps5upload-apidoc" -version = "12.6.26" +version = "12.6.27" dependencies = [ "proc-macro2", "quote", @@ -2618,7 +2618,7 @@ dependencies = [ [[package]] name = "ps5upload-archive" -version = "12.6.26" +version = "12.6.27" dependencies = [ "anyhow", "crc32fast", @@ -2628,7 +2628,7 @@ dependencies = [ [[package]] name = "ps5upload-ava1" -version = "12.6.26" +version = "12.6.27" dependencies = [ "anyhow", "ava1", @@ -2651,7 +2651,7 @@ dependencies = [ [[package]] name = "ps5upload-convert" -version = "12.6.26" +version = "12.6.27" dependencies = [ "libc", "ps5upload-archive", @@ -2666,7 +2666,7 @@ dependencies = [ [[package]] name = "ps5upload-convert-core" -version = "12.6.26" +version = "12.6.27" dependencies = [ "blake3", "flate2", @@ -2686,7 +2686,7 @@ dependencies = [ [[package]] name = "ps5upload-core" -version = "12.6.26" +version = "12.6.27" dependencies = [ "aes 0.9.4", "aes-gcm 0.11.1", @@ -2720,7 +2720,7 @@ dependencies = [ [[package]] name = "ps5upload-ctest" -version = "12.6.26" +version = "12.6.27" dependencies = [ "anyhow", "ava1", @@ -2736,7 +2736,7 @@ dependencies = [ [[package]] name = "ps5upload-engine" -version = "12.6.26" +version = "12.6.27" dependencies = [ "aes 0.9.4", "aes-gcm 0.11.1", @@ -2804,7 +2804,7 @@ dependencies = [ [[package]] name = "ps5upload-fpkg" -version = "12.6.26" +version = "12.6.27" dependencies = [ "aes 0.9.4", "blake3", @@ -2828,7 +2828,7 @@ dependencies = [ [[package]] name = "ps5upload-hub" -version = "12.6.26" +version = "12.6.27" dependencies = [ "axum", "base64 0.23.1", @@ -2843,7 +2843,7 @@ dependencies = [ [[package]] name = "ps5upload-lab" -version = "12.6.26" +version = "12.6.27" dependencies = [ "anyhow", "ava1", @@ -2861,7 +2861,7 @@ dependencies = [ [[package]] name = "ps5upload-pkg" -version = "12.6.26" +version = "12.6.27" dependencies = [ "aes 0.9.4", "blake3", @@ -2873,14 +2873,14 @@ dependencies = [ [[package]] name = "ps5upload-tailnet" -version = "12.6.26" +version = "12.6.27" dependencies = [ "cc", ] [[package]] name = "ps5upload-tests" -version = "12.6.26" +version = "12.6.27" dependencies = [ "anyhow", "ava1", @@ -2898,7 +2898,7 @@ dependencies = [ [[package]] name = "ps5upload-unrar" -version = "12.6.26" +version = "12.6.27" dependencies = [ "serde", "serde_json", diff --git a/engine/Cargo.toml b/engine/Cargo.toml index 12e00ee68..3da299fd5 100644 --- a/engine/Cargo.toml +++ b/engine/Cargo.toml @@ -32,7 +32,7 @@ resolver = "2" [workspace.package] edition = "2021" license = "GPL-3.0-or-later" -version = "12.6.26" +version = "12.6.27" [workspace.dependencies] # AVA1 (github.com/phantomptr/ava1): the Rust crate from crates.io; the payload builds the C side diff --git a/payload/include/config.h b/payload/include/config.h index 481dd33c2..41d6e4cc2 100644 --- a/payload/include/config.h +++ b/payload/include/config.h @@ -5,7 +5,7 @@ * UI tell apart an old payload still running from a build that includes * a particular fix, without having to boot the console. Keep in sync * with the desktop app's package.json during releases. */ -#define PS5UPLOAD2_VERSION "12.6.26" +#define PS5UPLOAD2_VERSION "12.6.27" /* Author credit — embedded in the startup toast so anyone looking at * the console screen knows who wrote the software that just loaded. * Kept separate from VERSION so release scripts can bump the version From 288e436c58f7054b0ee24760d744b40d0e37977b Mon Sep 17 00:00:00 2001 From: phantomptr <phantomptr@gmail.com> Date: Tue, 24 Nov 2026 22:52:36 -0800 Subject: [PATCH 12/12] Rebuild the embedded join and pad pages (#929 player fix) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GtiJiJdHq1hekoZ6vizvVT --- .../ps5upload-engine/src/join_page.html | 24 +++++++++---------- .../crates/ps5upload-engine/src/pad_page.html | 20 ++++++++-------- site/join/index.html | 24 +++++++++---------- site/pad/index.html | 20 ++++++++-------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/engine/crates/ps5upload-engine/src/join_page.html b/engine/crates/ps5upload-engine/src/join_page.html index a08a3b6ec..90639f109 100644 --- a/engine/crates/ps5upload-engine/src/join_page.html +++ b/engine/crates/ps5upload-engine/src/join_page.html @@ -8,15 +8,15 @@ <!-- No icon to fetch: the engine refuses /favicon.ico from another device and logs it. --> <link rel="icon" href="data:," /> <title>PS5Upload · Play Together - +I€wu¸öôú!3å6³‹âVq£³¹´RN£%y10º:pŠ#\:J:b9Hµ7h_Ž:¢I9 _¼™µV,þ <`});var T={a:v};this.setModule=t=>{e.setModule(yi,t)},this.getModule=()=>e.getModule(yi),this.instantiate=()=>(this.getModule().then(e=>WebAssembly.instantiate(e,T)).then(e=>{let t=e.exports;y(t),a=t.g,o(),te(t),n()}),this.ready=new Promise(e=>{n=e}).then(()=>{this.HEAP=a.buffer,this.malloc=x,this.free=C,this.opus_frame_decoder_create=b,this.opus_frame_decode_float_deinterleaved=S,this.opus_frame_decoder_destroy=ee}),this)}var bi=o((()=>{}));function xi(e={}){xi.errors||Object.defineProperties(xi,{errors:{value:new Map([[-1,`OPUS_BAD_ARG: One or more invalid/out of range arguments`],[-2,`OPUS_BUFFER_TOO_SMALL: Not enough bytes allocated in the buffer`],[-3,`OPUS_INTERNAL_ERROR: An internal error was detected`],[-4,`OPUS_INVALID_PACKET: The compressed data passed is corrupted`],[-5,`OPUS_UNIMPLEMENTED: Invalid/unsupported request number`],[-6,`OPUS_INVALID_STATE: An encoder or decoder structure is invalid or already freed`],[-7,`OPUS_ALLOC_FAIL: Memory allocation has failed`]])}}),this._init=()=>new this._WASMAudioDecoderCommon(this).instantiate(this._EmscriptenWASM,this._module).then(e=>{this._common=e,this._inputBytes=0,this._outputSamples=0,this._frameNumber=0,this._input=this._common.allocateTypedArray(this._inputSize,Uint8Array),this._output=this._common.allocateTypedArray(this._outputChannels*this._outputChannelSize,Float32Array);let t=this._common.allocateTypedArray(this._channels,Uint8Array);t.buf.set(this._channelMappingTable),this._decoder=this._common.wasm.opus_frame_decoder_create(this._sampleRate,this._channels,this._streamCount,this._coupledStreamCount,t.ptr,this._preSkip,this._forceStereo)}),Object.defineProperty(this,"ready",{enumerable:!0,get:()=>this._ready}),this.reset=()=>(this.free(),this._init()),this.free=()=>{this._common.free(),this._common.wasm.opus_frame_decoder_destroy(this._decoder),this._common.wasm.free(this._decoder)},this._decode=e=>{if(!(e instanceof Uint8Array))throw Error(`Data to decode must be Uint8Array. Instead got `+typeof e);this._input.buf.set(e);let t=this._common.wasm.opus_frame_decode_float_deinterleaved(this._decoder,this._input.ptr,e.length,this._output.ptr),n;return t<0&&(n=`libopus `+t+` `+(xi.errors.get(t)||`Unknown Error`),console.error(n),t=0),{outputBuffer:this._common.getOutputChannels(this._output.buf,this._outputChannels,t),samplesDecoded:t,error:n}},this.decodeFrame=e=>{let t=[],n=this._decode(e);return n.error&&this._common.addError(t,n.error,e.length,this._frameNumber,this._inputBytes,this._outputSamples),this._frameNumber++,this._inputBytes+=e.length,this._outputSamples+=n.samplesDecoded,this._WASMAudioDecoderCommon.getDecodedAudioMultiChannel(t,[n.outputBuffer],this._outputChannels,n.samplesDecoded,this._sampleRate)},this.decodeFrames=e=>{let t=[],n=[],r=0,i=0;for(;itypeof e==`number`,n=e.sampleRate,r=e.channels,i=e.streamCount,a=e.coupledStreamCount,o=e.channelMappingTable,s=e.preSkip,c=+!!e.forceStereo;if(r>2&&(!t(i)||!t(a)||!Array.isArray(o)))throw Error(`Invalid Opus Decoder Options for multichannel decoding.`);return this._sampleRate=[8e3,12e3,16e3,24e3,48e3].includes(n)?n:48e3,this._channels=t(r)?r:2,this._streamCount=t(i)?i:1,this._coupledStreamCount=t(a)?a:this._channels-1,this._channelMappingTable=o||(this._channels===2?[0,1]:[0]),this._preSkip=s||0,this._forceStereo=r<=8&&r!=2?c:0,this._inputSize=3840*this._channels,this._outputChannelSize=5760,this._outputChannels=this._forceStereo?2:this._channels,this._ready=this._init(),this}var Si=o((()=>{vi(),bi()})),Ci,wi=o((()=>{vi(),bi(),Si(),Ci=class extends mi{constructor(e){super(e,`opus-decoder`,xi,yi)}async decodeFrame(e){return this.postToDecoder(`decodeFrame`,e)}async decodeFrames(e){return this.postToDecoder(`decodeFrames`,e)}}})),Ti=c({OpusDecoder:()=>xi,OpusDecoderWebWorker:()=>Ci}),Ei=o((()=>{Si(),wi(),vi(),gi(xi,`OpusDecoder`),gi(Ci,`OpusDecoderWebWorker`)})),Di=[8e3,12e3,16e3,24e3,48e3],Oi=null;function ki(){return Oi??=Yn(()=>Promise.resolve().then(()=>(Ei(),Ti)),__VITE_PRELOAD__,import.meta.url).catch(e=>{throw Oi=null,e}),Oi}function Ai(){return typeof WebAssembly==`object`&&typeof WebAssembly.instantiate==`function`}function ji(e,t,n,r){return{numberOfFrames:t,numberOfChannels:e.length,sampleRate:n,timestamp:r,format:`f32-planar`,duration:Math.round(t/n*1e6),copyTo(n,r){n.set(e[r.planeIndex].subarray(0,t))},close(){}}}var Mi=class{constructor(e,t=ki){this.init=e,this.load=t,this.state=`unconfigured`,this.dec=null,this.pending=[]}configure(e){if(this.state===`closed`)throw Error(`the decoder is closed`);if(!Ai())throw Error(`no WebAssembly here`);let t=e.sampleRate;if(!Di.includes(t))throw Error(`Opus does not decode at ${t} Hz`);let n=e.numberOfChannels;if(n<1||n>2)throw Error(`${n} channels: only mono and stereo are decoded`);this.state=`configured`,this.load().then(async e=>{if(this.state===`closed`)return;let r=new e.OpusDecoder({channels:n,sampleRate:t});if(await r.ready,this.state!==`configured`){r.free();return}this.dec=r;let i=this.pending;this.pending=[];for(let e of i)this.state===`configured`&&this.run(e)}).catch(e=>this.fail(e))}decode(e){if(this.state!==`configured`)return;let t=e;if(this.dec)return this.run(t);this.pending.push({timestamp:t.timestamp,data:t.data.slice()}),this.pending.length>50&&this.pending.shift()}run(e){let t=this.dec;if(!t)return;let n;try{n=t.decodeFrame(e.data)}catch(e){return this.fail(e)}n.samplesDecoded&&n.channelData.length&&this.init.output(ji(n.channelData,n.samplesDecoded,n.sampleRate,e.timestamp))}fail(e){if(this.state===`closed`)return;this.close();let t=e instanceof Error?e:Error(String(e));queueMicrotask(()=>this.init.error(t))}close(){this.state=`closed`,this.pending=[];let e=this.dec;this.dec=null;try{e?.free()}catch{}}},Ni={makeDecoder:e=>new Mi(e),makeChunk:e=>({type:e.type,timestamp:e.timestamp,data:e.data instanceof Uint8Array?e.data:new Uint8Array(e.data)})};function Pi(e,t){for(let n=0;n+3>1&63;if(t>=16&&t<=21)return!0;if(t<16)return!1}else{let t=e[n+3]&31;if(t===5)return!0;if(t===1)return!1}}return!1}function Fi(e){for(let t=0;t+6e.toString(16).padStart(2,`0`);return`avc1.${n(e[t+4])}${n(e[t+5])}${n(e[t+6])}`}return`avc1.4d4028`}var Ii=[`hev1.1.6.L153.B0`,`hvc1.1.6.L153.B0`,`hev1.2.4.L153.B0`,`hvc1.2.4.L153.B0`,`hev1.1.6.L150.90`];async function Li(e,t){if(typeof VideoDecoder>`u`)return null;for(let n of Ii)try{if((await VideoDecoder.isConfigSupported({codec:n,codedWidth:e,codedHeight:t})).supported)return n}catch{}return null}function Ri(e){let t=[];for(let n=0;n+2{let i=r+1n&&e[i-1]===0;)i--;return e.subarray(n,i)}).filter(e=>e.length>0)}var zi=(e,t)=>t?e[0]>>1&63:e[0]&31;function Bi(e,...t){let n=8+t.reduce((e,t)=>e+t.length,0),r=new Uint8Array(n);new DataView(r.buffer).setUint32(0,n);for(let t=0;t<4;t++)r[4+t]=e.charCodeAt(t);let i=8;for(let e of t)r.set(e,i),i+=e.length;return r}function I(...e){let t=new Uint8Array(e.reduce((e,[,t])=>e+t,0)),n=0;for(let[r,i]of e){for(let e=i-1;e>=0;e--)t[n+i-1-e]=Math.floor(r/2**(8*e))&255;n+=i}return t}var Vi=(e,t,n,...r)=>Bi(e,I([t,1],[n,3]),...r),Hi=I([65536,4],[0,4],[0,4],[0,4],[65536,4],[0,4],[0,4],[0,4],[1073741824,4]);function Ui(e){let t=e.handler===`vide`,n=Bi(`ftyp`,new TextEncoder().encode(`isom`),I([1,4]),new TextEncoder().encode(`isomiso6mp41`)),r=Bi(`moov`,Vi(`mvhd`,0,0,I([0,4],[0,4],[e.timescale,4],[0,4],[65536,4],[256,2],[0,2],[0,4],[0,4]),Hi,new Uint8Array(24),I([2,4])),Bi(`trak`,Vi(`tkhd`,0,3,I([0,4],[0,4],[1,4],[0,4],[0,4],[0,4],[0,4],[0,2],[0,2],[t?0:256,2],[0,2]),Hi,I([(e.width??0)*65536,4],[(e.height??0)*65536,4])),Bi(`mdia`,Vi(`mdhd`,0,0,I([0,4],[0,4],[e.timescale,4],[0,4],[21956,2],[0,2])),Vi(`hdlr`,0,0,I([0,4]),new TextEncoder().encode(e.handler),new Uint8Array(12),I([0,1])),Bi(`minf`,t?Vi(`vmhd`,0,1,new Uint8Array(8)):Vi(`smhd`,0,0,I([0,4])),Bi(`dinf`,Vi(`dref`,0,0,I([1,4]),Vi(`url `,0,1))),Bi(`stbl`,Vi(`stsd`,0,0,I([1,4]),e.sampleEntry),Vi(`stts`,0,0,I([0,4])),Vi(`stsc`,0,0,I([0,4])),Vi(`stsz`,0,0,I([0,4],[0,4])),Vi(`stco`,0,0,I([0,4])))))),Bi(`mvex`,Vi(`trex`,0,0,I([1,4],[1,4],[0,4],[0,4],[0,4])))),i=new Uint8Array(n.length+r.length);return i.set(n,0),i.set(r,n.length),i}function Wi(e,t,n,r,i){let a=i?33554432:16842752,o=e=>Vi(`trun`,0,1793,I([1,4],[e,4],[n,4],[r.length,4],[a,4])),s=e=>Bi(`traf`,Vi(`tfhd`,0,131072,I([1,4])),Vi(`tfdt`,1,0,I([t,8])),o(e)),c=Vi(`mfhd`,0,0,I([e,4])),l=Bi(`moof`,c,s(0)).length,u=Bi(`moof`,c,s(l+8)),d=Bi(`mdat`,r),f=new Uint8Array(u.length+d.length);return f.set(u,0),f.set(d,u.length),f}function Gi(e,t,n=!1){let r=t?[35,...n?[32,33,34]:[]]:[9,...n?[7,8]:[]],i=Ri(e).filter(e=>!r.includes(zi(e,t))),a=new Uint8Array(i.reduce((e,t)=>e+4+t.length,0)),o=new DataView(a.buffer),s=0;for(let e of i)o.setUint32(s,e.length),a.set(e,s+4),s+=4+e.length;return a}var Ki=e=>e.toString(16).padStart(2,`0`),qi=e=>{let t=new Uint8Array(2+e.length);return t[0]=e.length>>8,t[1]=e.length&255,t.set(e,2),t},Ji=e=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t};function Yi(e){let t=Ri(e),n=t.filter(e=>zi(e,!1)===7),r=t.filter(e=>zi(e,!1)===8);return!n.length||!r.length||n[0].length<4?null:Ji([I([1,1],[n[0][1],1],[n[0][2],1],[n[0][3],1],[255,1],[224|n.length,1]),...n.map(qi),I([r.length,1]),...r.map(qi)])}function Xi(e,t,n){let r=Ri(e),i=e=>r.filter(n=>zi(n,t)===e),a=(e,t)=>Bi(e,new Uint8Array(6),I([1,2],[0,16],[n.w,2],[n.h,2],[4718592,4],[4718592,4],[0,4],[1,2]),new Uint8Array(32),I([24,2],[65535,2]),t);if(!t){let t=i(7),r=Yi(e);return r?{init:Ui({handler:`vide`,timescale:9e4,sampleEntry:a(`avc1`,Bi(`avcC`,r)),width:n.w,height:n.h}),mime:`video/mp4; codecs="avc1.${Ki(t[0][1])}${Ki(t[0][2])}${Ki(t[0][3])}"`}:null}let o=i(32),s=i(33),c=i(34);if(!o.length||!s.length||!c.length)return null;let l=Yr(s[0]);if(l.length<15)return null;let u=l.subarray(3,15),d=u[0]&31,f=d===2?2:0,p=(e,t)=>Ji([I([128|e,1],[t.length,2]),...t.map(qi)]),m=Bi(`hvcC`,I([1,1]),u,I([61440,2],[252,1],[253,1],[248|f,1],[248|f,1],[0,2],[15,1],[3,1]),p(32,o),p(33,s),p(34,c)),h=[``,`A`,`B`,`C`][u[0]>>6],g=0,_=(u[1]<<24|u[2]<<16|u[3]<<8|u[4])>>>0;for(let e=0;e<32;e++)_&1<>>0).toString(16),`${u[0]&32?`H`:`L`}${u[11]}`,...v.map(e=>e.toString(16))].join(`.`);return{init:Ui({handler:`vide`,timescale:9e4,sampleEntry:a(`hvc1`,m),width:n.w,height:n.h}),mime:`video/mp4; codecs="${y}"`}}function Zi(e,t,n,r,i,a){return Wi(e,t,n,Gi(r,i),a)}function Qi(e,t){let n=Bi(`dOps`,I([0,1],[e,1],[312,2],[t,4],[0,2],[0,1]));return Ui({handler:`soun`,timescale:48e3,sampleEntry:Bi(`Opus`,new Uint8Array(6),I([1,2],[0,8],[e,2],[16,2],[0,4],[3145728e3,4]),n)})}function $i(e){if(!e.length)return 960;let t=e[0]>>3,n=t<12?[480,960,1920,2880][t%4]:t<16?[480,960][t%2]:[120,240,480,960][t%4],r=e[0]&3,i=r===0?1:r===3?(e[1]??1)&63:2;return n*Math.max(1,i)}function ea(e,t,n){return Wi(e,t,$i(n),n,!0)}var ta={watch:30,player:4},na={watch:{seek:.5,speed:1/0,target:.05},player:{seek:.15,speed:.06,target:.02}},ra={seek:.8,speed:.25,target:.12};function ia(e,t,n){let r=typeof n==`string`?na[n]:n;return e>r.seek?{seekTo:t-r.target,rate:1}:e>r.speed?{seekTo:null,rate:1.1}:{seekTo:null,rate:1}}function aa(e,t=`watch`,n){return typeof VideoDecoder<`u`?new ma(e,t,n):new Oa(e,t,n)}var oa=class{constructor(e,t=()=>performance.now()){this.ask=e,this.now=t,this.last=-1/0}waiting(){if(!this.ask)return;let e=this.now();e-this.last<1e3||(this.last=e,this.ask())}};function L(e){return e.length<3?null:{index:e[0]<<8|e[1],packet:e.subarray(2)}}var R=class{constructor(){this.last=-1}take(e){if(this.last>=0){let t=e-this.last&65535;if(t===0||t>=32768)return!1}return this.last=e,!0}reset(){this.last=-1}};function sa(e){if(e.length>=10)return e;let t=new Uint8Array(10);t.set(e.subarray(0,6));let n=new DataView(t.buffer);return n.setUint32(6,Math.round(n.getUint32(2)/100)||480),t}function ca(e,t){return{snd:e,snd_decoded:t.decoded,snd_concealed:t.concealed,snd_underruns:t.underruns,snd_dropped:t.dropped}}var la=class{constructor(e,t=.2){this.min=e,this.max=t,this.next=0,this.calmSince=0,this.minLead=1/0,this.windowAt=0,this.underruns=0,this.dropped=0,this.cushion=e}at(e,t){this.next0&&(this.underruns++,this.cushion=Math.min(this.max,this.cushion+.02)),this.calmSince=e,this.next=e+this.cushion,this.minLead=1/0,this.windowAt=e):e-this.calmSince>10&&this.cushion>this.min&&(this.cushion=Math.max(this.min,this.cushion-.01),this.calmSince=e);let n=this.next-e;if(n>this.cushion+.15)return this.dropped++,null;if(this.minLead=Math.min(this.minLead,n),e-this.windowAt>=.25){let t=this.minLead>this.cushion+ua;if(this.minLead=1/0,this.windowAt=e,t)return this.dropped++,null}let r=this.next;return this.next+=t,r}reset(){this.next=0}},ua=.02;async function da(e,t){try{return typeof AudioDecoder>`u`?!1:!!(await AudioDecoder.isConfigSupported({codec:`opus`,sampleRate:e,numberOfChannels:t})).supported}catch{return!1}}var fa=class{constructor(e,t=()=>performance.now()){this.decoder=e,this.now=t,this.n={frames:0,dropped:0,late:0,stalls:0,stall_ms:0,worst_stall_ms:0,key_waits:0},this.a=0,this.d=0,this.w=!1,this.q=[],this.sum=0,this.cnt=0,this.codec=``}get frames(){return this.n.frames}arrived(){let e=this.now();this.a&&e-this.a>50&&this.n.late++,this.a=e}drop(){this.n.dropped++,this.w||this.n.key_waits++,this.w=!0}decoding(){this.w=!1,this.q.push(this.now())>64&&this.q.shift()}drawn(e=!1){let t=this.now(),n=e?this.q.shift():void 0;n!==void 0&&(this.sum+=t-n,this.cnt++);let r=this.d?t-this.d:0;r>100&&this.stall(r),this.d=t,this.n.frames++}stall(e){this.n.stalls++,this.n.stall_ms+=e,this.n.worst_stall_ms=Math.max(this.n.worst_stall_ms,e)}snapshot(){let e=this.d?this.now()-this.d:0,t={...this.n,decoder:this.decoder};this.codec&&(t.codec=this.codec),e>100&&(t.stalls=this.n.stalls+1,t.stall_ms=this.n.stall_ms+e,t.worst_stall_ms=Math.max(this.n.worst_stall_ms,e));for(let e of[`stall_ms`,`worst_stall_ms`])t[e]=Math.round(t[e]);return t.decode_ms=this.cnt?Math.round(this.sum/this.cnt*10)/10:0,this.sum=this.cnt=0,t}},pa=[`pointerup`,`touchend`,`click`,`keydown`],ma=class{get element(){if(!this.wrap){let e=document.createElement(`div`);e.className=`h-full w-full`,e.append(this.canvas),this.mse&&e.append(this.mse.element),this.wrap=e}return this.wrap}get stats(){return this.mse?.stats??this.ownStats}soundReport(){return this.soundOn?this.mseSound?this.mseSound.report():ca(this.soundWasm?`wasm`:`webcodecs`,this.soundStats):null}constructor(e,t=`watch`,n){this.onProblem=e,this.latency=t,this.onNeedKey=n,this.canvas=document.createElement(`canvas`),this.wrap=null,this.mse=null,this.failsNoPicture=0,this.ctx=this.canvas.getContext(`2d`,{alpha:!1}),this.hevc=!1,this.header=null,this.spsRect=null,this.software=!1,this.video=null,this.opening=!1,this.sawKey=!1,this.ownStats=new fa(`webcodecs`),this.problemShown=!1,this.ts=0,this.pipe=null,this.audioGen=0,this.actx=null,this.soundOn=!1,this.unarm=null,this.mseSound=null,this.audioHeader=null,this.soundWasm=!1,this.onSoundFail=null,this.muted=!1,this.keyAsk=new oa(n),this.clock=new la(t===`player`?.05:.08),typeof AudioDecoder>`u`&&_a()&&(this.mseSound=new va(t,()=>this.mseSoundFailed())),this.canvas.className=`block h-full w-full object-contain`,this.canvas.dataset.testid=`watch-canvas`}setHevc(e){this.hevc=e,this.header&&(this.spsRect=ti(this.header,e)),this.mse?.setHevc(e)}get onMse(){return!!this.mse}decodeFailed(){if(this.mse||this.ownStats.frames>0||++this.failsNoPicture<3||!ba())return!1;let e=new Oa(this.onProblem,this.latency,this.onNeedKey);e.setHevc(this.hevc),e.markProblemShown(),this.mse=e;let t=this.video;this.video=null;try{t?.close()}catch{}return this.canvas.style&&(this.canvas.style.display=`none`),this.wrap?.append(e.element),this.header&&e.onMessage(new Uint8Array([0,...this.header]).buffer),this.onNeedKey?.(),!0}startSound(){this.soundOn=!0,ha(),this.mseSound?this.mseSound.start():this.openContext()}openContext(){try{if(!this.actx){let e=new AudioContext({latencyHint:`interactive`});this.actx=e,e.onstatechange=()=>{this.actx===e&&e.state!==`running`&&e.state!==`closed`&&this.armResume()}}this.actx.resume().catch(()=>{})}catch{this.onSoundFail?.()}}get sound(){return this.soundOn}setMuted(e){this.muted=e,this.mseSound?.setMuted(e)}resumeSound(){if(!this.soundOn)return;if(this.mseSound)return this.mseSound.resume();let e=this.actx;e&&e.state!==`running`&&e.state!==`closed`&&(this.clock.reset(),e.resume().catch(()=>{}),this.armResume())}get soundStats(){return{decoded:this.pipe?.decoded??0,concealed:this.pipe?.concealed??0,underruns:this.clock.underruns,dropped:this.clock.dropped,cushionMs:Math.round(this.clock.cushion*1e3)}}armResume(){if(this.unarm||typeof window>`u`||!window.addEventListener)return;let e=()=>{let e=this.actx;if(!e||e.state===`closed`)return this.unarm?.();this.clock.reset(),e.resume().then(()=>{e.state===`running`&&this.unarm?.()}).catch(()=>{})};for(let t of pa)window.addEventListener(t,e,!0);this.unarm=()=>{for(let t of pa)window.removeEventListener(t,e,!0);this.unarm=null}}onMessage(e){let t=new Uint8Array(e);if(t.length<1)return;let n=t[0],r=t.subarray(1);if(this.mse&&(n===0||n===1))return n===0&&(this.header=r.slice()),this.mse.onMessage(e);n===0?this.openVideo(r.slice()):n===1?this.onVideo(r):n===3?this.openAudio(r.slice()):n===4&&this.onAudio(r)}async openVideo(e){if(this.header=e,this.spsRect=ti(e,this.hevc),!this.opening){this.opening=!0;try{let t=this.hevc?await ka(e):Fi(e);if(this.mse)return;if(!t){this.problemShown=!0,this.onProblem(`no_hevc`);return}this.ownStats.codec=t;let n=this.hevc?void 0:Yi(e)??void 0;try{this.video?.close()}catch{}let r=new VideoDecoder({output:e=>{let t=this.realVisible(e),n=this.canvas;(n.width!==t.displayWidth||n.height!==t.displayHeight)&&(n.width=t.displayWidth,n.height=t.displayHeight),this.ctx?.drawImage(t,0,0,n.width,n.height),this.ownStats.drawn(!0),t.close(),this.problemShown&&(this.problemShown=!1,this.onProblem(null))},error:()=>{this.video===r&&(this.problemShown=!0,this.onProblem(`decode`),this.decodeFailed()||this.rebuild())}}),i={codec:t,optimizeForLatency:!0};n&&(i.description=n),this.software&&(i.hardwareAcceleration=`prefer-software`),r.configure(i),this.video=r,this.sawKey=!1}catch{this.problemShown=!0,this.onProblem(`decode`),this.decodeFailed()}finally{this.opening=!1}}}realVisible(e){let t=this.spsRect,n=ni(e,t);if(n)try{let t=new VideoFrame(e,{visibleRect:{x:n.x,y:n.y,width:n.w,height:n.h},displayWidth:n.w,displayHeight:n.h});return e.close(),t}catch{return e}let r=e.visibleRect;if(t&&r&&!this.software&&(r.width{if(this.video===e){try{e?.close()}catch{}this.rebuild(),this.onNeedKey?.()}})}return e}rebuild(){this.mse||(this.video=null,this.sawKey=!1,this.header&&this.openVideo(this.header).then(()=>this.keyAsk.waiting()))}onVideo(e){let t=this.video;if(t?.state===`closed`){this.opening||this.rebuild();return}if(!t||t.state!==`configured`)return;let n=Pi(e,this.hevc);if(this.ownStats.arrived(),!this.sawKey&&!n)return this.ownStats.drop(),this.keyAsk.waiting();if(!n&&t.decodeQueueSize>ta[this.latency])return this.sawKey=!1,this.ownStats.drop(),this.keyAsk.waiting();this.sawKey=!0;let r=e;this.hevc?n&&this.header&&(r=new Uint8Array(this.header.length+e.length),r.set(this.header,0),r.set(e,this.header.length)):r=Gi(e,!1,!0),this.ts+=16667,this.ownStats.decoding(),t.decode(new EncodedVideoChunk({type:n?`key`:`delta`,timestamp:this.ts,data:r}))}openAudio(e){if(e.length<6)return;let t=++this.audioGen;if(this.pipe?.reset(),this.pipe=null,this.clock.reset(),this.audioHeader=e,this.mseSound)return this.mseSound.setHeader(e);let n=e[0];da(new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2),n).then(n=>{if(t!==this.audioGen)return;if(!n)return _a()?this.soundThroughMse(e):this.soundThroughWasm(e);let r=new oi((e,t)=>this.play(e,t,r.sampleRate));try{r.header(sa(e)),this.pipe=r}catch{this.soundThroughMse(e)}})}soundThroughMse(e){this.pipe=null,this.mseSound||(this.mseSound=new va(this.latency,()=>this.mseSoundFailed()),this.soundOn&&this.mseSound.start()),this.mseSound.setHeader(e)}soundThroughWasm(e){this.pipe?.reset(),this.soundWasm=!0;let t=new oi((e,n)=>this.play(e,n,t.sampleRate),Ni,()=>{this.pipe===t&&(this.pipe=null),this.onSoundFail?.()});this.pipe=t,t.header(sa(e))}mseSoundFailed(){let e=this.mseSound;e&&(this.mseSound=null,e.stop(),this.soundOn&&(this.openContext(),this.actx&&this.actx.state!==`running`&&this.armResume()),this.audioHeader&&this.soundThroughWasm(this.audioHeader))}onAudio(e){if(this.mseSound)return this.mseSound.frame(e);this.soundOn&&this.pipe&&this.pipe.packet(e)}play(e,t,n){let r=this.actx;if(!r||r.state!==`running`||!e.length)return;let i=e[0].length,a=this.clock.at(r.currentTime,i/n);if(a===null)return;let o=r.createBuffer(e.length,i,n),s=this.muted?0:t;e.forEach((e,t)=>o.copyToChannel(s===1?e:e.map(e=>e*s),t));let c=r.createBufferSource();c.buffer=o,c.connect(r.destination),c.start(a)}stop(){try{this.video?.close()}catch{}this.mse?.stop(),this.audioGen++,this.pipe?.reset(),this.pipe=null,this.unarm?.(),this.actx?.close().catch(()=>{}),this.mseSound?.stop()}};function ha(){try{let e=navigator.audioSession;e&&e.type!==`playback`&&(e.type=`playback`)}catch{}}function ga(e,t){try{return e.isTypeSupported(t)}catch{return!1}}function _a(){let e=typeof window>`u`?null:ba();return!!e&&(ga(e,`audio/mp4; codecs="Opus"`)||ga(e,`audio/mp4; codecs="opus"`))}var va=class{constructor(e,t,n=document.createElement(`audio`)){this.onFail=t,this.header=null,this.time=0,this.on=!1,this.failed=!1,this.order=new R,this.el=n,this.track=new wa(n,()=>this.fail(),e===`player`?ra:e)}get playing(){return this.on&&!this.failed}report(){return{snd:`mse`,snd_jumps:this.track.seeks}}setHeader(e){this.header=e,this.on&&this.open()}start(){if(!this.on&&(this.on=!0,this.header&&this.open(),!this.failed))try{this.el.play()?.catch?.(()=>{})}catch{}}frame(e){if(!this.on||this.failed||!this.track.ready&&!this.track.backlog)return;let t=L(e);if(!t||!this.order.take(t.index))return;let n=ea(this.track.nextSeq(),this.time,t.packet);this.time+=$i(t.packet),this.track.push(n)}setMuted(e){this.el.muted=e}resume(){if(this.playing&&this.el.paused)try{this.el.play()?.catch?.(()=>{})}catch{}}stop(){this.on=!1,this.track.close()}open(){let e=this.header;if(!e||e.length<6||this.failed)return;let t=e[0],n=Qi(t,new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2));this.track.open(`audio/mp4; codecs="Opus"`,n)||this.track.open(`audio/mp4; codecs="opus"`,n)?(this.time=0,this.order.reset()):this.fail()}fail(){this.failed||(this.failed=!0,this.onFail())}},ya=class{constructor(e,t,n=Ni){this.onFail=t,this.codecs=n,this.actx=null,this.pipe=null,this.header=null,this.on=!1,this.failed=!1,this.muted=!1,this.unarm=null,this.played=!1,this.clock=new la(e===`player`?.05:.08)}get playing(){return this.on&&!this.failed}get stats(){return{decoded:this.pipe?.decoded??0,concealed:this.pipe?.concealed??0,underruns:this.clock.underruns,dropped:this.clock.dropped}}start(){if(!this.failed){this.on=!0,ha();try{if(!this.actx){let e=new AudioContext({latencyHint:`interactive`});this.actx=e,e.onstatechange=()=>{this.actx===e&&e.state!==`running`&&e.state!==`closed`&&this.armResume()}}this.actx.resume().catch(()=>{}),this.actx.state!==`running`&&this.armResume()}catch{return this.fail()}this.header&&!this.pipe&&this.open()}}setHeader(e){e.length<6||(this.header=e,this.pipe?.reset(),this.pipe=null,this.clock.reset(),this.on&&this.open())}frame(e){this.on&&!this.failed&&this.pipe?.packet(e)}setMuted(e){this.muted=e}resume(){let e=this.actx;this.playing&&e&&e.state!==`running`&&e.state!==`closed`&&(this.clock.reset(),e.resume().catch(()=>{}),this.armResume())}stop(){this.on=!1,this.pipe?.reset(),this.pipe=null,this.unarm?.(),this.actx?.close().catch(()=>{}),this.actx=null}open(){let e=this.header;if(!e||this.failed)return;let t=new oi((e,n)=>this.play(e,n,t.sampleRate),this.codecs,()=>{this.pipe===t&&this.fail()});this.pipe=t,t.header(sa(e))}play(e,t,n){let r=this.actx;if(!r||r.state!==`running`||!e.length)return;let i=e[0].length,a=this.clock.at(r.currentTime,i/n);if(a===null)return;let o=r.createBuffer(e.length,i,n),s=this.muted?0:t;e.forEach((e,t)=>o.copyToChannel(s===1?e:e.map(e=>e*s),t));let c=r.createBufferSource();c.buffer=o,c.connect(r.destination),c.start(a),this.played=!0}armResume(){if(this.unarm||typeof window>`u`||!window.addEventListener)return;let e=()=>{let e=this.actx;if(!e||e.state===`closed`)return this.unarm?.();this.clock.reset(),e.resume().then(()=>{e.state===`running`&&this.unarm?.()}).catch(()=>{})};for(let t of pa)window.addEventListener(t,e,!0);this.unarm=()=>{for(let t of pa)window.removeEventListener(t,e,!0);this.unarm=null}}fail(){this.failed||(this.failed=!0,this.stop(),this.onFail())}};function ba(){let e=window;return e.ManagedMediaSource??e.MediaSource??null}var xa=10,Sa=3;function Ca(e,t,n,r=Sa){let i=null;for(let a of e)a>t&&a<=n-r&&(i=a);return i}var wa=class{constructor(e,t,n=`watch`,r,i=()=>performance.now()){this.el=e,this.onError=t,this.latency=n,this.onNeedKey=r,this.now=i,this.ms=null,this.sb=null,this.queue=[],this.mime=``,this.seq=1,this.ready=!1,this.dropped=!1,this.keys=null,this.seeks=0,this.maxLagS=0,this.fromZero=0,this.trims=0,this.lastJump=null,this.trimAt=-1,this.trimFrom=-1,this.keyAt=-1,this.attached=null,r&&(this.keys=[])}setEdge(e){this.latency=e}markKey(e){this.keys?.push(e),this.keyAt=this.now()}open(e,t){let n=ba();if(!n||!ga(n,e))return!1;this.close();let r=new n;return this.ms=r,this.mime=e,this.queue=[t],this.seq=1,this.ready=!1,this.keys&&=[],r.addEventListener(`sourceopen`,()=>{if(this.ms===r)try{let e=r.addSourceBuffer(this.mime);e.mode=`segments`,e.addEventListener(`updateend`,()=>this.pump()),e.addEventListener(`error`,()=>this.onError()),this.sb=e,this.ready=!0,this.pump()}catch{this.onError()}}),`ManagedMediaSource`in window&&n===window.ManagedMediaSource&&(this.el.disableRemotePlayback=!0),this.attached=Ta(this.el,r),!0}nextSeq(){return this.seq++}get backlog(){return this.queue.length}push(e){this.queue.push(e),this.pump()}pump(){let e=this.sb;if(!e||e.updating||!this.ready)return;let t=this.el;if(e.buffered.length){let n=e.buffered.end(e.buffered.length-1),r=e.buffered.start(0),i=n-t.currentTime,a=ia(i,n,this.latency);if(a.seekTo!==null){this.seeks++,this.maxLagS=Math.max(this.maxLagS,i);let o=this.now(),s=e=>e<0?-1:Math.round(o-e);t.currentTime<.05&&r>1&&this.fromZero++,this.lastJump={at:t.currentTime,start:r,end:n,ranges:e.buffered.length,readyState:t.readyState,paused:t.paused,seeking:t.seeking,sinceTrimMs:s(this.trimAt),trimFrom:this.trimFrom,sinceKeyMs:s(this.keyAt)},t.currentTime=Math.max(r,a.seekTo)}if(t.playbackRate!==a.rate&&(t.playbackRate=a.rate),t.currentTime-r>xa&&this.trim(e,r))return}let n=this.queue.shift();if(n){try{e.appendBuffer(n)}catch{this.dropped=!0}t.paused&&t.play().catch(()=>{})}}trim(e,t){let n=this.el.currentTime,r=n-Sa;if(this.keys){if(r=Ca(this.keys,t,n),r===null)return(this.keys[this.keys.length-1]??-1/0)<=n-Sa&&this.onNeedKey?.(),!1;let e=r;this.keys=this.keys.filter(t=>t>=e),r-=.001}try{return e.remove(t,r),this.trims++,this.trimAt=this.now(),this.trimFrom=n,!0}catch{return!1}}close(){this.ready=!1,this.sb=null,this.queue=[];let e=this.ms;if(this.ms=null,e&&e.readyState===`open`)try{e.endOfStream()}catch{}if(this.attached===`object`)try{this.el.srcObject=null}catch{}this.attached=null,this.el.src?.startsWith(`blob:`)&&URL.revokeObjectURL(this.el.src),this.el.removeAttribute(`src`)}};function Ta(e,t){if(`srcObject`in e)try{return e.srcObject=t,`object`}catch{}return e.src=URL.createObjectURL(t),`url`}var Ea=1e4,Da=class{constructor(e=3,t=Ea,n=()=>performance.now()){this.max=e,this.windowMs=t,this.now=n,this.at=[]}fail(){let e=this.now();return this.at=this.at.filter(t=>e-t=this.max}clear(){this.at=[]}},Oa=class{constructor(e,t=`watch`,n,r){this.onProblem=e,this.latency=t,this.wasm=null,this.audioHeader=null,this.muted=!1,this.gaveUp=!1,this.reopening=!1,this.failedWhileOpening=!1,this.wrap=document.createElement(`div`),this.hevc=!1,this.header=null,this.sawKey=!1,this.stats=new fa(`mse`),this.problemShown=!1,this.vTime=0,this.vLast=0,this.soundOn=!1,this.onSoundFail=null,this.onGiveUp=null,this.keyAsk=new oa(n),this.fails=new Da(3,Ea,r);let i=document.createElement(`video`);i.muted=!0,i.autoplay=!0,i.playsInline=!0,i.className=`block h-full w-full object-contain`,i.dataset.testid=`watch-video`,this.audio=new va(t,()=>this.soundThroughWasm()),this.wrap.className=`h-full w-full`,this.wrap.append(i,this.audio.el),this.video=new wa(i,()=>this.showProblem(),t,()=>this.keyAsk.waiting()),i.addEventListener(`error`,()=>this.restartVideo()),i.addEventListener(`playing`,()=>{this.fails.clear(),this.problemShown&&(this.problemShown=!1,this.onProblem(null))})}markProblemShown(){this.problemShown=!0}showProblem(){this.problemShown||(this.problemShown=!0,this.onProblem(`decode`))}restartVideo(){if(this.gaveUp)return;if(this.reopening){this.failedWhileOpening=!0;return}if(this.showProblem(),this.fails.fail()){this.gaveUp=!0,this.video.close(),this.onGiveUp?.();return}let e=this.header;if(e){this.header=null,this.reopening=!0,this.failedWhileOpening=!1;try{this.openVideo(e)}finally{this.reopening=!1}this.sawKey=!1,this.keyAsk.waiting(),this.failedWhileOpening&&(this.failedWhileOpening=!1,this.restartVideo())}}get failed(){return this.gaveUp}setVideoEdge(e){this.video.setEdge(e)}get videoSeeks(){return{seeks:this.video.seeks,maxLagMs:Math.round(this.video.maxLagS*1e3),fromZero:this.video.fromZero,trims:this.video.trims,lastJump:this.video.lastJump}}get element(){return this.wrap}resume(){let e=this.video.el;e.paused&&e.play()?.catch?.(()=>{})}setHevc(e){this.hevc=e}startSound(){if(this.soundOn=!0,this.wasm)return this.wasm.start();if(!_a())return this.soundThroughWasm();this.audio.start()}soundThroughWasm(){if(this.wasm)return;this.audio.stop();let e=new ya(this.latency,()=>this.onSoundFail?.());this.wasm=e,e.setMuted(this.muted),this.audioHeader&&e.setHeader(this.audioHeader),this.soundOn&&e.start()}resumeSound(){this.soundOn&&(this.wasm?this.wasm.resume():this.audio.resume())}setMuted(e){this.muted=e,this.audio.setMuted(e),this.wasm?.setMuted(e)}soundReport(){return this.soundOn?this.wasm?ca(`wasm`,this.wasm.stats):this.audio.report():null}get soundPlaying(){return this.wasm?this.wasm.played:this.audio.playing}get sound(){return this.soundOn}onMessage(e){let t=new Uint8Array(e);if(t.length<1)return;let n=t[0],r=t.subarray(1);n===0?this.openVideo(r.slice()):n===1?this.onVideo(r):n===3?(this.audioHeader=r.slice(),(this.wasm??this.audio).setHeader(this.audioHeader)):n===4&&(this.wasm??this.audio).frame(r)}openVideo(e){let t=!!this.header&&this.header.length===e.length&&this.header.every((t,n)=>t===e[n]);if(t&&this.video.ready)return;if(this.gaveUp){if(t)return;this.gaveUp=!1,this.fails.clear()}this.header=e;let n=ti(e,this.hevc)??{w:1920,h:1080},r=Xi(e,this.hevc,n);r&&(this.stats.codec=/codecs="([^"]+)"/.exec(r.mime)?.[1]??``,this.video.open(r.mime,r.init)?(this.sawKey=!1,this.vTime=0,this.vLast=0):(this.problemShown=!0,this.onProblem(this.hevc?`no_hevc`:`decode`)))}onVideo(e){if(!this.video.ready&&!this.video.backlog)return;let t=Pi(e,this.hevc);if(this.video.dropped&&(this.video.dropped=!1,this.sawKey=!1),this.stats.arrived(),!this.sawKey&&!t)return this.stats.drop(),this.keyAsk.waiting();if(!t&&this.video.backlog>ta[this.latency])return this.sawKey=!1,this.stats.drop(),this.keyAsk.waiting();this.sawKey=!0,this.stats.drawn();let n=performance.now(),r=this.vLast?Math.min(9e3,Math.max(750,Math.round((n-this.vLast)*90))):1500;this.vLast=n,t&&this.video.markKey(this.vTime/9e4),this.video.push(Zi(this.video.nextSeq(),this.vTime,r,e,this.hevc,t)),this.vTime+=r}stop(){this.video.close(),this.audio.stop(),this.wasm?.stop()}};async function ka(e){let t=ri(e);if(t&&typeof VideoDecoder<`u`)try{if((await VideoDecoder.isConfigSupported({codec:t,codedWidth:1920,codedHeight:1080})).supported)return t}catch{}return Li(1920,1080)}var z={CROSS:1,CIRCLE:2,SQUARE:4,TRIANGLE:8,LEFT:16,RIGHT:32,UP:64,DOWN:128,L1:256,R1:512,L3:1024,R3:2048,OPTIONS:4096,SHARE:8192,TOUCHPAD:16384,PS:32768},Aa={buttons:0,l2:0,r2:0,lx:0,ly:0,rx:0,ry:0};function ja(e,t){let n=e=>Math.max(0,Math.min(1,e));return[Math.round(n(e)*1919),Math.round(n(t)*941)]}var Ma={ArrowUp:{button:z.UP},ArrowDown:{button:z.DOWN},ArrowLeft:{button:z.LEFT},ArrowRight:{button:z.RIGHT},Enter:{button:z.CROSS},Space:{button:z.CROSS},Backspace:{button:z.CIRCLE},Escape:{button:z.CIRCLE},KeyQ:{button:z.SQUARE},KeyE:{button:z.TRIANGLE},KeyZ:{button:z.L1},KeyC:{button:z.R1},Digit1:{trigger:`l2`},Digit3:{trigger:`r2`},KeyF:{button:z.L3},KeyG:{button:z.R3},Tab:{button:z.OPTIONS},Backquote:{button:z.SHARE},KeyH:{button:z.PS},KeyT:{button:z.TOUCHPAD},KeyW:{stick:`ly`,dir:-1},KeyS:{stick:`ly`,dir:1},KeyA:{stick:`lx`,dir:-1},KeyD:{stick:`lx`,dir:1},KeyI:{stick:`ry`,dir:-1},KeyK:{stick:`ry`,dir:1},KeyJ:{stick:`rx`,dir:-1},KeyL:{stick:`rx`,dir:1}};z.UP,z.DOWN,z.LEFT,z.RIGHT,z.CROSS,z.CIRCLE,z.SQUARE,z.TRIANGLE,z.L1,z.R1,z.L3,z.R3,z.OPTIONS,z.SHARE,z.PS,z.TOUCHPAD;var Na=e=>Math.max(-32768,Math.min(32767,Math.round(e)));function Pa(e,t=Ma){let n={...Aa};for(let r of e){let e=t[r];e&&(`button`in e?n.buttons|=e.button:`stick`in e?n[e.stick]=Na(n[e.stick]+e.dir*32767):n[e.trigger]=255)}return n}var Fa=[z.CROSS,z.CIRCLE,z.SQUARE,z.TRIANGLE,z.L1,z.R1,0,0,z.SHARE,z.OPTIONS,z.L3,z.R3,z.UP,z.DOWN,z.LEFT,z.RIGHT,z.PS,z.TOUCHPAD];function Ia(e){return Math.abs(e)<=1.01?Math.round((e+1)*3.5)%8:null}var La=[0,1,1,1,0,-1,-1,-1],Ra=[-1,-1,0,1,1,1,0,-1];function za(e,t){let n=e.axes[t.a]??0;if(t.hat){let e=Ia(n);return e===null?0:(t.hat===`x`?La:Ra)[e]}return t.inv?-n:n}var Ba={buttons:Fa.flatMap((e,t)=>e?[[e,{b:t}]]:[]),l2:{b:6},r2:{b:7},lx:{a:0},ly:{a:1},rx:{a:2},ry:{a:3}};function Va(e,t,n=!1){if(`b`in t){let r=e.buttons[t.b];return r?n&&r.value>0?Math.min(1,r.value):Math.max(+!!r.pressed,r.value):0}if(`h`in t){let n=Ia(e.axes[t.h]??9);if(n===null)return 0;let r=(n-t.at+8)%8;return+(r===0||r===1||r===7)}let r=e.axes[t.a];if(r===void 0)return 0;let i=t.rest??0;return Math.min(1,Math.max(0,(r-i)/(t.d-i)))}function Ha(e){if(e.mapping===`standard`)return Ba;let t=Ua.get(e.id);if(t)return t;let n=e.axes.findIndex(e=>Math.abs(e)>1.05);if(n<0)return Ba;let r={...Ba,buttons:[...Ba.buttons,[z.UP,{h:n,at:0}],[z.RIGHT,{h:n,at:2}],[z.DOWN,{h:n,at:4}],[z.LEFT,{h:n,at:6}]]};return Ua.set(e.id,r),r}var Ua=new Map;function Wa(e,t=Ha){let n={...Aa},r=e=>Math.abs(e)<.08?0:Na(e*32767),i=(e,t)=>Math.abs(t)>Math.abs(e)?t:e,a=(e,t)=>t?r(za(e,t)):0;for(let r of e){if(!r||!r.connected)continue;let e=t(r);for(let[t,i]of e.buttons)Va(r,i)>.5&&(n.buttons|=t);e.l2&&(n.l2=Math.max(n.l2,Math.round(Va(r,e.l2,!0)*255))),e.r2&&(n.r2=Math.max(n.r2,Math.round(Va(r,e.r2,!0)*255))),n.lx=i(n.lx,a(r,e.lx)),n.ly=i(n.ly,a(r,e.ly)),n.rx=i(n.rx,a(r,e.rx)),n.ry=i(n.ry,a(r,e.ry))}return n}function Ga(e,t){return{buttons:e.buttons|t.buttons,l2:Math.max(e.l2,t.l2),r2:Math.max(e.r2,t.r2),lx:Na(e.lx+t.lx),ly:Na(e.ly+t.ly),rx:Na(e.rx+t.rx),ry:Na(e.ry+t.ry),touch:e.touch??t.touch??null,motion:e.motion??t.motion??null}}function Ka(e,t,n,r=()=>globalThis.navigator?.getGamepads?.()??[]){let i=e=>e?.vibrationActuator;for(let a of e.some(i)?e:r()){let e=i(a);e&&(t===0&&n===0?e.reset?.():e.playEffect?.(`dual-rumble`,{duration:1e3,strongMagnitude:t/255,weakMagnitude:n/255}))}}var qa=new Map;function Ja(e,t){return{id:`${e.id} (app)`,index:3+e.slot,connected:!0,mapping:`standard`,timestamp:0,axes:e.axes,buttons:e.buttons.map(e=>({pressed:e>.5,touched:e>0,value:e})),vibrationActuator:t?.vibrationActuator??null,hapticActuators:t?.hapticActuators??[]}}function Ya(e){let t=e?.getGamepads?.()??[];return qa.size===0||t.some(e=>!!e?.connected)?[...t]:[...qa.values()].sort((e,t)=>e.slot-t.slot).map(e=>Ja(e))}var Xa=`b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b1,b2,b0,b3,b6,b4,b7,b5,b8,b9,,,-a1,+a1,-a0,+a0(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,,,,,,,a0,a1(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b2,b1,b3,b0,b4,b5,,,b8,b9,,,-a1,+a1,-a0,+a0(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b2,b3,b0,b1,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b11,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a5(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1(b1,b0,b2,b3,,b7,a3,a4,,b9,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a5,a2(b1,b0,b2,b3,,b7,a3,a4,,b9,,,b12,b14,b15,b13,,,a0,a1,a5,a2(b1,b0,b2,b3,,b7,b4,b5,,b9,,,b12,b14,b15,b13,,,a0,a1,a5~,a2~(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,b8,,a0,a1,a3,a4(b1,b2,,,b7,b5,b4,,,b9,,,b12,b14,b15,b13,,,a0,a1,a5,a2(b0,b1,b3,b4,b6,b5,b7,b2,b8,,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b7,b9,b10,b2,b8,,,h0.1,h0.4,h0.8,h0.2,b5,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,-a1,+a1,-a0,+a0(b0,b1,b3,b4,b6,b5,b7,b2,,b8,,,-a1,+a1,-a0,+a0(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b12,b13,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a5,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b14,,a0,a1,a2,a3(b14,b13,b15,b12,b10,b11,b8,b9,b0,b3,b1,b2,b4,b6,b7,b5,b16,,a0,a1,a2,a3(b0,b1,b3,b2,b4,b5,a2,a5,b8,b9,b11,b12,h0.1,h0.4,h0.8,h0.2,b10,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13,a0,a1,a2,a5(b2,b1,b3,b0,b6,b7,b4,b5,b8,b9,,,-a1,+a1,-a0,+a0(b1,b2,b0,b3,b4,b5,,,b8,b9,,,b12,b13,b15,b14,,,a0,a1,a3,a4(b0,b1,b3,b2,b4,b5,b6,b7,b8,b9,b11,b12,b13,b14,b15,b16,b10,,a0,a1,a2,a3(b0,b1,b3,b2,,b6,a2,a5,,b7,,,b8,b9,b10,b11,,,a0,a1,a3,a4(b0,b1,b3,b2,b4,b5,,,b8,b9,,,b10,b11,b12,b13,,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,,,b13,b8,b10,,,,,,,,hx,hy(b0,b1,b2,b3,b4,b5,,,b12,b9,b11,,,,,,,,hx,hy(b0,b1,b3,b2,b5,b6,b7,b8,b9,b10,b12,b13,b14,b15,b16,b17,b11,,a0,a1,a2,a3(b0,b1,b3,b2,b5,b6,b7,b8,b9,b10,b12,b13,h0.1,h0.4,h0.8,h0.2,b11,,a0,a1,a2,a3(b0,b1,b3,b2,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b0,b1,,,,b2,,b4,,b5,,,h0.1,h0.4,h0.8,h0.2,b6(b0,b1,b2,b3,b12,b4,b13,b5,b14,b6,b15,b7,b11,b8,b10,b9,b16,,a0,a1~,a2,a3~(b1,b3,b0,b2,b13,b5,b12,b4,,b6,,,b11,b8,b10,b9,b16,,a0,a1~,a2,a3~(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b33,,a0,a1,a2,a3(b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b16,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b15,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,,,,,b8,,a0,a1,a3,a4(b1,b0,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12,b13(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,,h0.1,h0.4,h0.8,h0.2,b12,b13(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b11,b12,h0.1,h0.4,h0.8,h0.2,b10,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,b12,b13,b14,b15,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,b14,b13,b14,b13,,,a0,a1,a3,a4(b1,b0,b2,b3,,,,,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b2,b3,b1,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b10(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12,b13,a0,a1,a2,a5(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,+a2,+a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,b8,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b13,,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b0,b3,b2,b4,b5,a2,a5,b6,b7,,,h0.1,h0.4,h0.8,h0.2,b8(b1,b2,,,,,,,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b21,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a5,a4,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,b8,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b13,b13,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,a5,a4,,b6,b7,b8,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a2,a5,b7,b6,b9,b10,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,b7,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a5,a4,b9,b6,b7,b8,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b22,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a2,a3,b6,b7,b9,,b12,b14,b15,b13,b8,,a0,a1(b3,b4,b5,b6,b7,b8,a9,a8,b11,b12,b14,b15,b16,b17,b18,b19,b13,,a0,a1,a2,a3(b0,b1,b3,b4,b8,b6,b9,b7,,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b7,b9,b6,b8,b10,b11,,,h0.1,h0.4,h0.8,h0.2(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b1,b0,b4,b3,b6,b7,,,b10,b11,,,-a1,+a1,-a0,+a0(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,,,b6,b7,b8,b9,,b11,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b3,b1,b4,,b10,a5,a4,,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,,,b6,b7,b8,b9,b10,b11,b13,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,,,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b0,b1,b3,b4,,b6,,b7,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,,,,,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a8,b9,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b8,b6,b9,b7,,b10,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a4,a5,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,,,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b2,b0,b3,b6,b4,b7,b5,b8,b9,,,-a4,+a4,-a3,+a3(b4,b8,b0,b12,b16,b20,b24,b28,b32,b36,b40,b44,h0.1,h0.4,h0.8,h0.2,,,a0,a4,a8,a12(b8,b12,b0,b4,b16,b20,b24,b28,b32,b36,,,h0.1,h0.4,h0.8,h0.2,b44,,a0,a4,a8,a12(b4,b0,b8,b12,,b28,a12,a16,,b36,,,h0.1,h0.4,h0.8,h0.2,,,a0,a4,a20,a8(b1,b2,b0,b3,,b7,a3,a4,,b9,,,b12,b14,b15,b13,,,a0,a1,a5,a2(b4,b0,b8,b12,,b28,a12,a16,,b36,,,b48,b56,b60,b52,,,a0,a4,a20,a8(b1,b2,,,b7,b5,a3,,,b9,,,b12,b14,b15,b13,,,a0,a1,a5,a2(b0,b1,b2,b3,b4,b5,a2,a5,b9,b8,b6,b7,b11,b12,b13,b14,b10,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b7,,,b5,b8,,,-a1,+a1,-a0,+a0,b2(b0,b1,b2,b3,b4,b5,b6,b15,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b13,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a5(b0,b1,b3,b4,b6,b7,a5,a4,b12,b13,b15,b16,h0.1,h0.4,h0.8,h0.2,b14,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,,,-a1,+a1,-a0,+a0,b2(b0,b1,b3,b4,b6,b7,,,b10,b11,,,-a1,+a1,-a0,+a0(b0,b1,b3,b4,b6,b7,b8,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a31(b0,b1,b3,b4,b8,b6,b9,b7,,b11,,,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a3,a4(b1,b0,b4,b3,b6,b7,a4,a5,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,,,b10,b11,,,,,,,,,hx,hy(b0,b1,b2,b3,b4,b5,b6,b7,b16,b15,b8,b9,b10,b11,b13,b12,b17,,a0,a1~,a2,a3~(b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a4(b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b2,b3,b33,b5,,,b6,b7,,,h0.1,h0.4,h0.8,h0.2(b0,b1,b3,b4,b6,b2,,,,b9,,,h0.1,h0.4,h0.8,h0.2(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a3,a4(b1,b2,,,b6,,b9,b7,,b8,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a2(b2,b1,b3,b0,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b3,b4,,b6,,b2,b7,b9,,,b2,b14,b15,b13(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b5,b7,b2,b10,b8,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b6,b7,a5~,a2~,b2,b8,b8,b5,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b4,,b9,b10,b6,b7,b8,,b5,b2,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,,,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b5,b4,b10,b11,b7,b6,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b3,b2,b6,b7,b4,b5,b8,b9,b11,b12,b13,b14,b15,b16,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b16,b19,b17,b18,b6,b7,b8,b9,b10,b11,b13,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a3,a4(b2,b1,b3,b0,b6,b7,b4,b5,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a5,a2(b0,b1,b2,b3,b4,b5,a2,a2,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a2,,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,b8,b9,b6,b7,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,b10,b11,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,b10,b11,b7,b6,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b1,b2,b0,b3,b10,b5,b11,b7,b8,b9,b4,b6,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b2,b0,b3,b5,b7,b4,b6,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,a3,a4,b8,b13,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13,a0,a1,a2,a5(b0,b4,b2,b1,b3,b6,,,b11,b9,,,h0.1,h0.4,h0.8,h0.2(b1,b2,b0,b3,b4,b5,a2,a5,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b9,b10,a4,a5,b4,b6,b7,b8,b11,b12,b13,b14,,,a0,a1,a2,a3(b1,b0,b3,b2,b4,b5,,,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b2,b3,b4,b5,+a2,-a2,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b1,b0,b3,b2,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,,,,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,+a2,-a2,b6,b7,b8,b9,b11,b14,b12,b13,b10,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,,a2,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b7,a4,a3,,,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,,,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b6,b7,b9,b10,b12,b13,b14,b15,b16,b17,b19,b20,h0.1,h0.4,h0.8,h0.2,b18,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,+a2,-a2,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,,,,,,,b7,b6,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b6,b7,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b6,b7,,,b10,b11,,,,,,,,,a0,a1(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a5(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a3,a4(b1,b0,b4,b3,,b6,,b7,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a5`.split(`(`),Za={l00790006:0,l00790011:1,l00790016:2,l00790122:3,l00790126:4,l00791800:5,l00791803:6,l0079181a:7,l0079181b:8,l0079181c:9,l00791830:10,l00791843:11,l00791844:12,l00791845:11,l00791846:13,l007918d2:7,l007918d4:14,l0079954e:15,l046dc20a:16,l046dc211:17,l046dc216:5,l046dc218:5,l046dc219:5,l046dc21a:18,l046dc21d:14,l046dc21e:14,l046dc21f:14,l046dcad1:5,l046dcad2:5,l04b4010a:19,l04b42411:20,l04b42412:21,l054c0268:22,l054c05c4:23,l054c09cc:24,l054c0ba0:24,l054c0cda:25,l054c0ce6:24,l054c0df2:24,l054c0e5f:24,l054c1337:26,l057e0330:27,l057e0337:28,l057e1337:29,l057e2006:30,l057e2007:31,l057e2008:32,l057e2009:33,l057e2017:34,l057e201e:35,l057e2069:36,l057e2073:37,l05ac022d:38,l05ac055b:39,l05ac057a:40,l05ac061a:41,l0e6f0109:42,l0e6f011e:7,l0e6f011f:14,l0e6f0128:5,l0e6f012f:7,l0e6f0130:7,l0e6f0131:14,l0e6f0139:14,l0e6f0146:43,l0e6f0164:14,l0e6f0180:7,l0e6f0181:7,l0e6f0184:7,l0e6f0185:44,l0e6f0187:7,l0e6f0188:7,l0e6f0203:45,l0e6f0207:46,l0e6f0213:14,l0e6f0214:7,l0e6f02a7:14,l0e6f02a8:47,l0e6f02b2:48,l0e6f02b8:14,l0e6f02c8:14,l0e6f02d7:49,l0e6f02d8:14,l0e6f02da:14,l0e6f02ef:14,l0e6f02f1:14,l0e6f0301:14,l0e6f0315:14,l0e6f0401:14,l0e6f0413:14,l0e6f1112:50,l0e6f1113:51,l0e6ff501:14,l0f0d0009:7,l0f0d0010:42,l0f0d0011:7,l0f0d0016:52,l0f0d0022:42,l0f0d004d:7,l0f0d005e:53,l0f0d005f:54,l0f0d0066:24,l0f0d0067:14,l0f0d006a:8,l0f0d006b:7,l0f0d006d:55,l0f0d006e:7,l0f0d0084:8,l0f0d0085:7,l0f0d0086:47,l0f0d0087:56,l0f0d0088:57,l0f0d0092:58,l0f0d00aa:39,l0f0d00c1:7,l0f0d00ee:59,l0f0d00f6:60,l0f0d00fb:39,l0f0d0137:61,l0f0d0138:62,l0f0d0150:14,l0f0d0185:14,l0f0d0196:63,l0f0d01ab:63,l15320401:24,l15320402:7,l15320705:64,l15320900:65,l15320a03:14,l15320a14:14,l15320a29:14,l15321000:8,l15321008:66,l1532100a:59,l1532100b:24,l15321100:24,l18d19400:65,l20d60dad:67,l20d62002:68,l20d62005:14,l20d6200b:14,l20d6200f:69,l20d62065:14,l20d62802:14,l20d64001:70,l20d64002:70,l20d64005:14,l20d66271:71,l20d6792a:24,l20d689e5:71,l20d6a710:5,l20d6a711:7,l20d6a712:7,l20d6a713:7,l20d6a714:7,l20d6ca6d:7,l24c65300:14,l24c6531a:14,l24c6541a:14,l24c6543a:14,l24c6581a:14,l24c65b02:14,l24c65d04:14,l24c6891a:63,l24c6891b:63,l24c6892a:72,l24c6892b:63,l24c6fafe:14,l27f80bbf:63,l28de1102:73,l28de1105:73,l28de1106:73,l28de1142:73,l28de11fc:43,l28de11ff:14,l28de1201:73,l28de1202:73,l28de1205:74,l2dc80651:75,l2dc81003:76,l2dc81080:76,l2dc82000:14,l2dc82003:14,l2dc8200a:77,l2dc82019:14,l2dc82025:14,l2dc82101:63,l2dc82830:78,l2dc82862:79,l2dc82865:79,l2dc82869:80,l2dc8286a:81,l2dc83010:82,l2dc83011:63,l2dc83012:63,l2dc83013:63,l2dc83015:63,l2dc83016:63,l2dc83017:63,l2dc83019:83,l2dc8301b:63,l2dc8301d:63,l2dc83100:84,l2dc83101:85,l2dc83102:85,l2dc83103:85,l2dc83104:85,l2dc83106:14,l2dc8310a:14,l2dc8310b:14,l2dc83230:86,l2dc83810:79,l2dc83820:87,l2dc85006:88,l2dc85101:89,l2dc85103:86,l2dc85104:90,l2dc85107:91,l2dc85108:91,l2dc85109:90,l2dc85111:92,l2dc85112:82,l2dc86000:92,l2dc86001:93,l2dc86002:92,l2dc86006:82,l2dc86007:94,l2dc86009:82,l2dc86012:63,l2dc86100:87,l2dc86101:93,l2dc86102:92,l2dc86728:95,l2dc89000:96,l2dc89001:96,l2dc89012:93,l2dc89015:79,l2dc89018:78,l2dc89020:97,l2dc89025:98,l2dc8ab21:78,l35371004:14,l35371007:63,l3537100b:14,l35371046:63,l35371058:63,l35371094:63,l35371097:63,l358a0102:63,l358a0202:63,l358a0203:63,l358a0204:63,m00790006:99,m00790011:100,m00791800:101,m00791803:102,m0079181c:41,m00791843:103,m00791844:104,m00791846:105,m007918d2:39,m0079954e:106,m046dc216:5,m046dc218:5,m046dc219:5,m046dc21a:18,m046dc21f:107,m04b4010a:108,m04b42411:20,m04b42412:20,m054c0268:22,m054c05c4:24,m054c09cc:24,m054c0ba0:24,m054c0cda:25,m054c0ce6:24,m054c0df2:24,m054c0e5f:24,m054c1337:26,m057e2006:30,m057e2007:31,m057e2009:60,m057e2017:109,m057e2069:36,m057e2073:37,m05ac061a:41,m0e6f0109:42,m0e6f0184:110,m0e6f0187:5,m0e6f0201:107,m0e6f0203:45,m0e6f0207:46,m0e6f0401:107,m0f0d002d:54,m0f0d004d:7,m0f0d005e:111,m0f0d005f:7,m0f0d0066:24,m0f0d006e:7,m0f0d0084:8,m0f0d0085:7,m0f0d0087:112,m0f0d0088:57,m0f0d0092:58,m0f0d00aa:39,m0f0d00c1:7,m0f0d00ee:113,m0f0d00f6:3,m0f0d0138:62,m0f0d0200:7,m15320401:24,m15320402:7,m15320705:64,m15320900:65,m15320a03:107,m15321000:8,m15321100:24,m18d19400:65,m20d66271:71,m20d6792a:24,m20d6a710:7,m20d6a711:44,m20d6ca6d:7,m24c6543a:107,m24c65d04:107,m24c6891a:114,m24c6891b:63,m24c6892a:64,m24c6892b:63,m24c6fafe:107,m2dc80651:115,m2dc82820:116,m2dc82830:78,m2dc82840:78,m2dc82865:87,m2dc82869:80,m2dc8286a:81,m2dc83011:63,m2dc83012:63,m2dc83013:63,m2dc83015:117,m2dc83016:63,m2dc83017:118,m2dc83019:83,m2dc8301b:63,m2dc8301d:63,m2dc83100:9,m2dc83101:85,m2dc83102:85,m2dc83103:85,m2dc83104:85,m2dc83105:84,m2dc83230:119,m2dc83810:94,m2dc85006:120,m2dc85101:89,m2dc85103:86,m2dc85104:90,m2dc85107:121,m2dc85108:122,m2dc85109:90,m2dc85111:82,m2dc85112:82,m2dc86001:79,m2dc86002:85,m2dc86006:82,m2dc86009:123,m2dc86101:85,m2dc86102:85,m2dc86728:95,m2dc89000:96,m2dc89001:79,m2dc89012:78,m2dc89015:124,m2dc89018:78,m2dc89020:125,m2dc89025:126,m2dc89026:127,m2dc8ab12:116,m35371022:63,m35371041:63,m35371046:63,m35371104:63,m358a0102:63,m358a0201:128,m358a0202:128,m358a0203:128,m358a0204:63,w00790002:129,w00790007:129,w0079000a:129,w00790016:18,w00790122:99,w00790126:130,w00791804:131,w0079181a:7,w0079181b:113,w00791824:132,w00791830:133,w00791845:11,w00791847:12,w0079184f:134,w00791879:135,w0079188f:136,w007918ae:137,w007918d4:138,w046dc209:139,w046dc20a:16,w046dc20b:140,w046dc211:141,w046dc21d:138,w046dc21e:142,w046dc242:142,w046dca84:143,w046dca88:143,w046dcad1:5,w046dcad2:7,w04b42410:144,w04b4c681:130,w054c05c5:145,w057e0330:146,w05ac022d:144,w05ac033d:147,w05ac044d:147,w05ac055b:39,w05ac057a:148,w0e6f0003:149,w0e6f0111:7,w0e6f0114:7,w0e6f0119:7,w0e6f011a:7,w0e6f011e:7,w0e6f011f:150,w0e6f0124:42,w0e6f0128:7,w0e6f012f:7,w0e6f0130:7,w0e6f0132:7,w0e6f0146:138,w0e6f0164:151,w0e6f0180:7,w0e6f0181:7,w0e6f0185:44,w0e6f0188:7,w0e6f0189:7,w0e6f0214:7,w0e6f0301:138,w0e6f1113:51,w0e6f6302:7,w0f0d0009:7,w0f0d000a:152,w0f0d000c:153,w0f0d000d:154,w0f0d0010:155,w0f0d0011:57,w0f0d0013:155,w0f0d001b:152,w0f0d0021:155,w0f0d0022:54,w0f0d0025:42,w0f0d0026:155,w0f0d0027:42,w0f0d0032:155,w0f0d003d:156,w0f0d0040:157,w0f0d0042:155,w0f0d0049:7,w0f0d004b:155,w0f0d0051:155,w0f0d0054:7,w0f0d0055:8,w0f0d005b:113,w0f0d005c:7,w0f0d0064:155,w0f0d0067:70,w0f0d006a:8,w0f0d006b:7,w0f0d006f:158,w0f0d0070:57,w0f0d007b:155,w0f0d008a:8,w0f0d008b:7,w0f0d008c:138,w0f0d009c:8,w0f0d00a0:159,w0f0d00a5:160,w0f0d00a6:111,w0f0d00ad:161,w0f0d00ae:142,w0f0d00af:162,w0f0d00c0:138,w0f0d00c9:5,w0f0d00d8:163,w0f0d00dc:138,w0f0d0101:5,w0f0d0104:142,w0f0d0123:144,w0f0d0137:164,w0f0d0162:165,w0f0d0164:166,w0f0d0196:134,w0f0d0202:167,w0f0d1011:168,w153202a6:169,w15320300:170,w15320707:147,w15320a14:138,w15321004:145,w15321007:145,w15321009:145,w1532100a:5,w18d12c40:171,w20d60060:7,w20d60dad:142,w20d6319f:7,w20d64026:134,w20d64033:134,w20d6571d:7,w20d6576d:7,w20d65795:7,w20d657c7:7,w20d657e5:7,w20d689e5:172,w20d6a712:7,w20d6a713:7,w20d6a714:7,w20d6a720:7,w24c6531a:153,w24c65b02:138,w27f80bbf:173,w28de11fc:70,w28de11ff:174,w2dc802e0:175,w2dc81003:176,w2dc81080:176,w2dc82100:144,w2dc82810:177,w2dc82862:78,w2dc83000:78,w2dc83001:178,w2dc8301c:134,w2dc8310a:134,w2dc83820:179,w2dc85001:180,w2dc86000:79,w2dc86003:123,w2dc86012:134,w2dc86100:85,w2dc86103:123,w2dc8ab11:179,w2dc8ab20:178,w2dc8ab21:78,w35371004:138,w35371007:134,w35371094:134,w35371116:134},Qa=e=>e.toLowerCase().padStart(4,`0`);function $a(e){let t=/^(.*?)\s*\((?:[^()]*?\s)?Vendor:\s*([0-9a-f]{1,4})\s+Product:\s*([0-9a-f]{1,4})\s*\)\s*$/i.exec(e);if(t)return{vendor:Qa(t[2]),product:Qa(t[3]),name:t[1].trim()};let n=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-(.*)$/i.exec(e.trim());return n?{vendor:Qa(n[1]),product:Qa(n[2]),name:n[3].trim()}:null}function eo(e){return($a(e)?.name??e.replace(/\s*\((?:XInput\s*)?STANDARD GAMEPAD\)\s*$/i,``)).trim()||e}function to(e=globalThis.navigator){let t=e?.userAgent??``;return/Android|iPhone|iPad|iPod/i.test(t)?null:/Macintosh|Mac OS X/i.test(t)?(e?.maxTouchPoints??0)>1?null:`m`:/Windows/i.test(t)?`w`:/Linux|CrOS|X11/i.test(t)?`l`:null}function no(e,t){if(!t)return null;let n=t===`l`?[`l`]:[`m`,`w`];for(let t of n){let n=Za[`${t}${e.vendor}${e.product}`];if(n!==void 0)return Xa[n]??null}return null}function ro(e){return e.mapping!==`standard`&&$a(e.id)?.vendor===`2dc8`}var io={6003:`switch`,6006:`switch`,6103:`switch`,3010:`switch`,6001:`startx`,6002:`startx`,6101:`startx`,6102:`startx`,3011:`receiver`,3012:`receiver`,3013:`receiver`,3015:`receiver`,3016:`receiver`,3017:`receiver`,"301b":`receiver`,"301c":`receiver`,"301d":`receiver`,6012:`receiver`,5112:`none`,9020:`none`};function ao(e){let t=$a(e);return t&&io[t.product]||`manual`}var oo={1:0,2:2,4:4,8:6};function so(e){let t=0,n=!1;for(let r of e){let e=/a(\d+)/.exec(r);e&&(t=Math.max(t,Number(e[1])+1)),r.startsWith(`h`)&&(n=!0)}return{n:t,hat:n}}function co(e,t,n){let{n:r,hat:i}=so(t),a=Fa.length,o=e.axes.findIndex(e=>Math.abs(e)>1.05),s=e=>e;if(i&&o<0)return n===`l`&&e.axes.length>=r+2?{hat:-1,hatXY:r,axis:s}:null;if(!(i?o>r:n!==`l`&&e.axes.length>=r+2))return{hat:o,hatXY:-1,axis:s};if(r<=4)return{hat:o,hatXY:-1,axis:e=>[0,1,2,5][e]??e};let c=t[a+2]?.replace(`~`,``)===`a2`&&t[a+3]?.replace(`~`,``)===`a3`,l=[t[6],t[7]].every(e=>/^a[45]~?$/.test(e??``));return r===6&&c&&l?{hat:o,hatXY:-1,axis:e=>[0,1,2,5,3,4][e]??e}:{hat:o,hatXY:-1,axis:s}}function lo(e,t){let n=/^b(\d+)$/.exec(e);if(n)return{b:Number(n[1])};if(n=/^([+-]?)a(\d+)(~?)$/.exec(e),n){let e=t.axis(Number(n[2]));return n[1]===`+`?{a:e,d:1}:n[1]===`-`?{a:e,d:-1}:n[3]?{a:e,d:-1,rest:1}:{a:e,d:1,rest:-1}}if(n=/^h0\.(\d)$/.exec(e),n){let e=oo[n[1]];if(e===void 0)return null;if(t.hat>=0)return{h:t.hat,at:e};if(t.hatXY>=0)return e===0?{a:t.hatXY+1,d:-1}:e===4?{a:t.hatXY+1,d:1}:e===6?{a:t.hatXY,d:-1}:{a:t.hatXY,d:1}}return null}function uo(e,t){let n=/^a(\d+)(~?)$/.exec(e);if(n)return n[2]?{a:t.axis(Number(n[1])),inv:!0}:{a:t.axis(Number(n[1]))};if(e===`hx`||e===`hy`){if(t.hat>=0)return{a:t.hat,hat:e===`hx`?`x`:`y`};if(t.hatXY>=0)return{a:t.hatXY+ +(e===`hy`)}}return null}function fo(e,t,n){let r=e.split(`,`),i=co(t,r,n);if(!i)return null;let a={buttons:[],l2:null,r2:null,lx:null,ly:null,rx:null,ry:null};for(let e=0;eArray.isArray(e)&&e.length===2&&typeof e[0]==`number`&&go(e[1]))&&[t.l2,t.r2,t.lx,t.ly,t.rx,t.ry].every(go)}function vo(){try{let e=It(ho),t=e?JSON.parse(e):null;return!t||typeof t!=`object`||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>_o(e[1])))}catch{return{}}}function yo(e,t){let n=vo();return t?n[e]=t:delete n[e],Ft(ho,JSON.stringify(n)),bo=n,n}var bo=null;function xo(e){return bo??=vo(),bo[e.id]??wo(bo,e.id)??mo(e)??Ha(e)}function So(e){return bo??=vo(),bo[e.id]?`saved`:e.mapping===`standard`?`standard`:mo(e)?`known`:`guess`}function Co(e){return mo(e)??Ha(e)}function wo(e,t){if(!t.endsWith(` (app)`))return null;let n=t.slice(0,-6).trim().toLowerCase();if(!n)return null;let r=Object.keys(e).filter(e=>{let t=e.trim().toLowerCase();return t===n||t.includes(n)}),i=r.find(e=>e.trim().toLowerCase()===n)??(r.length===1?r[0]:null);return i?(bo=yo(t,e[i]),e[i]):null}function To(e){return{buttons:e.buttons.map(e=>Math.max(+!!e.pressed,e.value)),axes:[...e.axes]}}function Eo(e,t){let n=null;if(t.buttons.forEach((t,r)=>{let i=t-(e.buttons[r]??0);t>.5&&i>.5&&(!n||i>n.amount)&&(n={src:{b:r},amount:i})}),n)return n.src;for(let n=0;n1.05?Ia(t.axes[n]):null;if(r!==null)return{h:n,at:r}}return t.axes.forEach((t,r)=>{let i=e.axes[r]??0,a=t-i;if(!(Math.abs(a)<.6)&&(!n||Math.abs(a)>n.amount)){let e=a>0?1:-1;n={src:Math.abs(i)>.5?{a:r,d:e,rest:i}:{a:r,d:e},amount:Math.abs(a)}}}),n?n.src:null}function Do(e,t){let n=null;if(t.axes.forEach((t,r)=>{let i=t-(e.axes[r]??0);Math.abs(i)>=.6&&(!n||Math.abs(i)>Math.abs(n.moved))&&(n={a:r,moved:i})}),!n)return null;let r=n;return r.moved>0?{a:r.a}:{a:r.a,inv:!0}}var Oo=[{kind:`button`,bit:z.CROSS,name:`✕`},{kind:`button`,bit:z.CIRCLE,name:`○`},{kind:`button`,bit:z.SQUARE,name:`□`},{kind:`button`,bit:z.TRIANGLE,name:`△`},{kind:`button`,bit:z.UP,name:`↑`},{kind:`button`,bit:z.DOWN,name:`↓`},{kind:`button`,bit:z.LEFT,name:`←`},{kind:`button`,bit:z.RIGHT,name:`→`},{kind:`button`,bit:z.L1,name:`L1`},{kind:`button`,bit:z.R1,name:`R1`},{kind:`trigger`,which:`l2`,name:`L2`},{kind:`trigger`,which:`r2`,name:`R2`},{kind:`button`,bit:z.L3,name:`L3`},{kind:`button`,bit:z.R3,name:`R3`},{kind:`button`,bit:z.OPTIONS,name:`Options`},{kind:`button`,bit:z.SHARE,name:`Create`},{kind:`button`,bit:z.PS,name:`PS`},{kind:`button`,bit:z.TOUCHPAD,name:`Touchpad`},{kind:`axis`,which:`lx`,name:`L →`},{kind:`axis`,which:`ly`,name:`L ↓`},{kind:`axis`,which:`rx`,name:`R →`},{kind:`axis`,which:`ry`,name:`R ↓`}];function ko(){return{buttons:[],l2:null,r2:null,lx:null,ly:null,rx:null,ry:null}}function Ao(e,t,n){return t.kind===`button`?{...e,buttons:[...e.buttons.filter(([e])=>e!==t.bit),[t.bit,n]]}:(t.kind,{...e,[t.which]:n})}function jo(e,t=Ba){let n=new Set(e.buttons.map(([e])=>e)),r=e=>`b`in e?`b${e.b}`:`h`in e?`h${e.h}.${e.at}`:`a${e.a}${e.d}`,i=new Set([...e.buttons.map(([,e])=>r(e)),...[e.l2,e.r2].filter(e=>!!e).map(r)]);return{buttons:[...e.buttons,...t.buttons.filter(([e,t])=>!n.has(e)&&!i.has(r(t)))],l2:e.l2??t.l2,r2:e.r2??t.r2,lx:e.lx??t.lx,ly:e.ly??t.ly,rx:e.rx??t.rx,ry:e.ry??t.ry}}var Mo=Oo.filter(e=>e.kind!==`button`||![z.L3,z.R3,z.OPTIONS,z.SHARE,z.PS,z.TOUCHPAD].includes(e.bit));function No(e,t){return t.buttons.every((t,n)=>Math.abs(t-(e.buttons[n]??0))<.3)&&t.axes.every((t,n)=>Math.abs(t-(e.axes[n]??0))<.3)}var Po=class{constructor(e=Oo){this.steps=e,this.step=0,this.prof=ko(),this.rest=null,this.waiting=!0}get done(){return this.step>=this.steps.length}get current(){return this.steps[this.step]??null}feed(e){if(this.done)return!1;if(!this.rest)return this.rest=e,this.waiting=!1,!1;if(this.waiting)return No(this.rest,e)&&(this.waiting=!1),!1;let t=this.steps[this.step],n=t.kind===`axis`?Do(this.rest,e):Eo(this.rest,e);return n?(this.prof=Ao(this.prof,t,n),this.go(this.step+1),!0):!1}skip(){this.go(this.step+1)}back(){this.step>0&&this.go(this.step-1)}go(e){this.waiting=!0,this.step=Math.min(e,this.steps.length)}profile(e=Ba){return jo(this.prof,e)}};function Fo(e,t){return e.buttons===t.buttons&&e.l2===t.l2&&e.r2===t.r2&&e.lx===t.lx&&e.ly===t.ly&&e.rx===t.rx&&e.ry===t.ry&&(e.touch?.[0]??-1)===(t.touch?.[0]??-1)&&(e.touch?.[1]??-1)===(t.touch?.[1]??-1)&&(e.motion?.t??-1)===(t.motion?.t??-1)}function Io(){try{return typeof sessionStorage<`u`?sessionStorage:null}catch{return null}}var Lo=e=>`ps5upload.join.token.${e??`app`}`,Ro=class{constructor(e){this.o=e,this.ws=null,this.stage={kind:`connecting`},this.token=null,this.player=0,this.last={...Aa},this.lastSent=0,this.neutral=!1,this.stopped=!1,this.attempt=0,this.deadline=0,this.raf=0,this.keepalive=null,this.pinger=null,this.retry=null,this.lastHeard=0,this.hostAway=!1,this.pings=0,this.now=e.now??(()=>Date.now()),this.storage=e.storage===void 0?Io():e.storage,this.WS=e.WebSocketImpl??WebSocket,this.seq=this.now()>>>0;try{this.token=this.storage?.getItem(this.key)??null}catch{this.token=null}}get key(){return Lo(this.o.invite??this.o.code??null)}get current(){return this.stage}get socket(){return this.ws}get resumeToken(){return this.token}setStage(e){this.stage=e,this.o.onStage(e)}start(){if(this.stopped=!1,this.setStage({kind:`connecting`}),this.connect(),this.stopped)return;let e=()=>{this.sendPad(!1),this.raf=(this.o.raf??(e=>window.requestAnimationFrame(e)))(e)};this.raf=(this.o.raf??(e=>window.requestAnimationFrame(e)))(e),this.keepalive=setInterval(()=>this.sendPad(!1),100),this.pinger=setInterval(()=>this.ping(),1e3)}connect(){let e;try{e=new this.WS(this.o.url)}catch{this.dropped();return}this.ws=e,e.binaryType=`arraybuffer`,e.onopen=()=>{if(this.ws!==e)return;this.lastHeard=this.now();let t={name:this.o.name};this.o.invite&&(t.invite=this.o.invite),this.o.code&&(t.code=this.o.code),this.token&&(t.resume=this.token),e.send(JSON.stringify({hello:t}))},e.onmessage=t=>{this.ws===e&&(this.lastHeard=this.now(),typeof t.data==`string`?this.onText(t.data):t.data instanceof ArrayBuffer&&this.stage.kind===`joined`&&this.o.onFrame?.(t.data))},e.onclose=t=>{if(this.ws!==e)return;this.ws=null;let n=He(t);n===`mismatch`?(this.forgetToken(),this.finish({kind:`ended`,why:n})):n&&this.stage.kind!==`joined`&&this.stage.kind!==`reconnecting`?this.finish({kind:`ended`,why:n}):this.dropped()},e.onerror=()=>{}}onText(e){let t=qe(e);if(t)switch(t.kind){case`pong`:{let e=this.now()-t.t;e>=0&&e<6e4&&this.o.onRtt?.(e);return}case`asking`:this.stage.kind!==`reconnecting`&&this.setStage({kind:`asking`});return;case`waiting`:this.hostAway||(this.hostAway=!0,this.deadline=this.now()+$e),this.attempt=0,this.setStage(this.reconnectingStage());return;case`joined`:this.token=t.token,this.player=t.player,this.attempt=0,this.hostAway=!1;try{this.storage?.setItem(this.key,t.token)}catch{}{let e=t.track&&this.ws?.media||null;this.o.onCodec?.(t.hevc,e,!!e&&t.audio&&!!e.audio)}this.setStage({kind:`joined`,player:t.player,hevc:t.hevc}),this.sendPad(!0);return;case`refused`:this.forgetToken(),this.hostAway&&t.why!==`seat_taken`?this.finish({kind:`ended`,why:`host_stopped`}):this.finish({kind:`refused`,why:t.why});return;case`bye`:if(t.why===`host_stopped`&&this.token){this.hostWait();return}this.forgetToken(),this.finish({kind:`ended`,why:t.why});return;case`status`:this.stage.kind===`joined`&&t.status.player>0&&t.status.player!==this.stage.player&&(this.player=t.status.player,this.setStage({...this.stage,player:t.status.player})),this.o.onStatus?.(t.status);return;case`feedback`:t.rumble&&this.o.onRumble?.(t.rumble[0],t.rumble[1]),t.light&&this.o.onLight?.(t.light);return}}hostWait(){this.hostAway=!0,this.deadline=this.now()+$e,this.attempt=0;let e=this.ws;this.ws=null;try{e?.close()}catch{}this.scheduleRetry()}reconnectingStage(){return{kind:`reconnecting`,player:this.player,attempt:this.attempt,deadline:this.deadline,...this.hostAway?{hostStopped:!0}:{}}}giveUp(){this.forgetToken(),this.finish({kind:`ended`,why:this.hostAway?`host_stopped`:`gave_up`})}dropped(){if(this.stopped)return;let e=this.stage;e.kind===`joined`||e.kind===`reconnecting`&&this.token?(e.kind===`joined`&&(this.deadline=this.now()+Qe),this.scheduleRetry()):this.finish({kind:`ended`,why:`lost`})}scheduleRetry(){if(this.stopped)return;if(this.now()>=this.deadline){this.giveUp();return}let e=Ze(this.attempt);this.setStage(this.reconnectingStage()),this.attempt+=1,this.retry&&clearTimeout(this.retry),this.retry=setTimeout(()=>{this.retry=null,this.stopped||(this.now()>=this.deadline?this.giveUp():this.connect())},e)}forgetToken(){this.token=null;try{this.storage?.removeItem(this.key)}catch{}}ping(){if(this.hostAway&&!this.stopped&&this.now()>=this.deadline+5e3||!this.stopped&&this.stage.kind===`reconnecting`&&this.now()>=this.deadline+5e3){this.giveUp();return}let e=this.ws;if(e&&e.readyState===this.WS.OPEN){if(this.stage.kind===`joined`&&this.now()-this.lastHeard>3500){this.ws=null;try{e.close()}catch{}this.dropped()}else if(e.send(JSON.stringify({ping:this.now()})),this.stage.kind===`joined`&&this.o.readStats&&++this.pings%2==0){let t=this.o.readStats();t&&e.send(JSON.stringify({stats:t}))}}}setNeutral(e){this.neutral!==e&&(this.neutral=e,this.sendPad(!0))}sendPad(e){let t=this.ws;if(!t||t.readyState!==this.WS.OPEN||this.stage.kind!==`joined`)return;let n=this.neutral?{...Aa,touch:null,motion:null}:this.o.readPad(),r=this.now();!e&&Fo(n,this.last)&&r-this.lastSent<100||(this.last=n,this.lastSent=r,this.seq=this.seq+1>>>0,t.send(Xe(this.seq,n)))}clearTimers(){(this.o.cancelRaf??(e=>window.cancelAnimationFrame(e)))(this.raf),this.keepalive&&clearInterval(this.keepalive),this.pinger&&clearInterval(this.pinger),this.retry&&clearTimeout(this.retry),this.keepalive=this.pinger=this.retry=null}finish(e){this.stopped=!0,this.clearTimers();let t=this.ws;this.ws=null;try{t?.close()}catch{}this.setStage(e)}askKeyframe(){let e=this.ws;e&&e.readyState===this.WS.OPEN&&this.stage.kind===`joined`&&e.send(JSON.stringify({keyframe:!0}))}leave(){let e=this.ws;e&&e.readyState===this.WS.OPEN&&(this.stage.kind===`joined`&&(this.seq=this.seq+1>>>0,e.send(Xe(this.seq,Aa))),e.send(JSON.stringify({leave:1}))),this.forgetToken(),this.finish({kind:`ended`,why:`left`})}stop(){let e=this.ws;e&&e.readyState===this.WS.OPEN&&this.stage.kind===`joined`&&(this.seq=this.seq+1>>>0,e.send(Xe(this.seq,Aa))),this.stopped=!0,this.clearTimers(),this.ws=null;try{e?.close()}catch{}}},zo=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),B=s(((e,t)=>{t.exports=zo()}))(),Bo=`ps5upload.openIn`,Vo=`ps5upload.openIn.tab`;function Ho(){try{return sessionStorage.getItem(Vo)===`browser`}catch{return!1}}function V(){try{sessionStorage.setItem(Vo,`browser`)}catch{}}function H(e){return e===`browser`?`browser`:e===`app`?`opening`:`ask`}function Uo({appLink:e,children:t}){let n=Fe(),[r,i]=(0,E.useState)(()=>Ho()?`browser`:H(It(Bo))),[a,o]=(0,E.useState)(!1);if((0,E.useEffect)(()=>{r===`opening`&&It(`ps5upload.openIn`)===`app`&&(location.href=e)},[]),r===`browser`)return(0,B.jsx)(B.Fragment,{children:t});let s=()=>{a&&Ft(Bo,`app`),i(`opening`),location.href=e},c=()=>{r===`ask`&&a?Ft(Bo,`browser`):r===`opening`&&It(`ps5upload.openIn`)===`app`&&Lt(Bo),V(),i(`browser`)};return(0,B.jsx)(`div`,{className:`flex min-h-[100dvh] items-center justify-center bg-black px-6 text-white`,"data-testid":`open-in-gate`,children:(0,B.jsx)(`div`,{className:`w-full max-w-sm space-y-4 rounded-2xl border border-white/10 bg-neutral-900 p-6`,children:r===`ask`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`open_in_title`,void 0,`Open in the PS5Upload app?`)}),(0,B.jsx)(`p`,{className:`text-sm text-white/60`,children:n(`open_in_body`,void 0,`Have the PS5Upload app on this device? Open this there, or carry on in the browser.`)})]}),(0,B.jsx)(`button`,{type:`button`,onClick:s,className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black`,"data-testid":`open-in-app`,children:n(`open_in_app`,void 0,`Open in the app`)}),(0,B.jsx)(`button`,{type:`button`,onClick:c,className:`w-full rounded-full border border-white/20 py-2.5 text-sm font-semibold text-white hover:bg-white/10`,"data-testid":`open-in-browser`,children:n(`open_in_browser`,void 0,`Continue in browser`)}),(0,B.jsxs)(`label`,{className:`flex items-center justify-center gap-2 text-xs text-white/60`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),"data-testid":`open-in-remember`}),n(`open_in_remember`,void 0,`Remember my choice on this device`)]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`open_in_opening`,void 0,`Opening the PS5Upload app…`)}),(0,B.jsx)(`p`,{className:`text-sm text-white/60`,children:n(`open_in_not_opened`,void 0,`Nothing happened? The app may not be on this device.`)})]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>location.href=e,className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black`,"data-testid":`open-in-again`,children:n(`open_in_again`,void 0,`Try again`)}),(0,B.jsx)(`button`,{type:`button`,onClick:c,className:`w-full rounded-full border border-white/20 py-2.5 text-sm font-semibold text-white hover:bg-white/10`,"data-testid":`open-in-browser`,children:n(`open_in_browser`,void 0,`Continue in browser`)})]})})})}function Wo({id:e,className:t}){let n=Fe(),r=ao(e);if(r===`none`)return(0,B.jsx)(`span`,{className:t,"data-testid":`pad-8bitdo-hint`,"data-how":r,children:n(`pad_8bitdo_no_xinput`,void 0,`This 8BitDo has no X-input mode. If a button is wrong, check the controller.`)});let i=r===`switch`?n(`pad_8bitdo_how_switch`,void 0,`set the switch on the back to X, then press Start`):r===`startx`?n(`pad_8bitdo_how_startx`,void 0,`turn it off, then hold Start + X to turn it on`):r===`receiver`?n(`pad_8bitdo_how_receiver`,void 0,`use its 2.4G receiver or a USB cable`):n(`pad_8bitdo_how_manual`,void 0,`its manual says how`);return(0,B.jsx)(`span`,{className:t,"data-testid":`pad-8bitdo-hint`,"data-how":r,children:n(`pad_8bitdo_xinput`,{how:i},`For the best result, switch your 8BitDo to X-input mode: ${i}.`)})}var Go=new Set,Ko={held:new Set,touch:null,touchPad:Aa,mapping:!1,get paused(){return Go.size>0},motion:null},qo={s:.85,m:1,l:1.15},Jo=.25;function Yo(e){return typeof e!=`number`||!Number.isFinite(e)?1:Math.min(1,Math.max(Jo,e))}var Xo={overlay:{width:844,height:390},deck:{width:390,height:480}},Zo=.7,Qo=1.4;function $o(e,t,n,r){let i=qo[e]??1;if(!(t>0)||!(n>0))return i;let a=r?Xo.deck:Xo.overlay,o=Math.min(Qo,Math.max(Zo,Math.min(t/a.width,n/a.height)));return Math.round(o*i*1e3)/1e3}var es=34;function ts(e,t){return t>0&&8+Math.max(112*e,90)+156*e+124*e+Math.max(56*e,44)+es>t}function ns(e,t,n){let r=e/32767,i=t/32767,a=Math.hypot(r,i),o=a>1?1/a:1;return{dx:r*o*n,dy:i*o*n}}var rs=`calc(50% + (env(safe-area-inset-left) - env(safe-area-inset-right)) / 2)`,is=32767,as=12;function os({stream:e,layout:t=`overlay`,opacity:n=1,size:r=`m`,deckTop:i=`0px`,onMenu:a}){let o=Fe(),s=(0,E.useRef)(new Map),c=(0,E.useRef)({...Aa}),[l,u]=(0,E.useState)({...Aa}),[d,f]=(0,E.useState)({l:!1,r:!1,touchpad:!1}),p=(0,E.useRef)(null),[m,h]=(0,E.useState)({width:0,height:0});(0,E.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();h(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})};if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,E.useEffect)(()=>()=>{Ko.touchPad={...Aa}},[]);let g=()=>{let t={...Aa,touch:null},n={l:!1,r:!1,touchpad:!1};for(let e of s.current.values())e.kind===`stick`&&(n[e.which]=!0),e.kind===`touchpad`&&(n.touchpad=!0),e.kind===`button`&&(t.buttons|=e.bit),e.kind===`trigger`&&(t[e.which]=255),e.kind===`touchpad`&&e.pressed&&(t.buttons|=z.TOUCHPAD);t.lx=c.current.lx,t.ly=c.current.ly,t.rx=c.current.rx,t.ry=c.current.ry,t.touch=c.current.touch??null,Ko.touchPad=t,e?.sendPad(),u(t),f(e=>e.l===n.l&&e.r===n.r&&e.touchpad===n.touchpad?e:n)},_=(e,t,n)=>{let r=Math.max(-1,Math.min(1,(t-e.cx)/e.radius)),i=Math.max(-1,Math.min(1,(n-e.cy)/e.radius));c.current[e.which===`l`?`lx`:`rx`]=Math.round(r*is),c.current[e.which===`l`?`ly`:`ry`]=Math.round(i*is)},v=(e,t)=>{e.preventDefault(),e.stopPropagation();let n=e.currentTarget;try{n.setPointerCapture(e.pointerId)}catch{}let r=t(n);s.current.set(e.pointerId,r),r.kind===`stick`&&_(r,e.clientX,e.clientY),r.kind===`touchpad`&&(c.current.touch=ja((e.clientX-r.rect.left)/r.rect.width,(e.clientY-r.rect.top)/r.rect.height)),navigator.vibrate?.(8),g()},y=e=>{let t=s.current.get(e.pointerId);if(t){if(e.stopPropagation(),t.kind===`stick`)_(t,e.clientX,e.clientY);else if(t.kind===`touchpad`)c.current.touch=ja((e.clientX-t.rect.left)/t.rect.width,(e.clientY-t.rect.top)/t.rect.height),t.pressed&&Math.hypot(e.clientX-t.x0,e.clientY-t.y0)>as&&(t.pressed=!1);else return;g()}},b=e=>{let t=s.current.get(e.pointerId);t&&(e.stopPropagation(),s.current.delete(e.pointerId),t.kind===`stick`&&(c.current[t.which===`l`?`lx`:`rx`]=0,c.current[t.which===`l`?`ly`:`ry`]=0),t.kind===`touchpad`&&(c.current.touch=null),g())},x=e=>e.stopPropagation(),S={onPointerMove:y,onPointerUp:b,onPointerCancel:b,onClick:x,onDoubleClick:x},ee=e=>(l.buttons&e)!==0,C=e=>`border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.35)] transition-colors duration-75 ${e?`border-white bg-white/50`:`border-white/70 bg-white/10`}`,w=`text-white [text-shadow:0_1px_2px_rgba(0,0,0,0.6)]`,te={filter:`drop-shadow(0 0 1.5px rgba(0,0,0,0.5))`},T=e=>({stroke:e?`#fff`:`rgba(255,255,255,0.75)`,fill:e?`rgba(255,255,255,0.5)`:`rgba(255,255,255,0.1)`}),ne=`pointer-events-auto flex touch-none select-none items-center justify-center bg-transparent p-0`,re={minHeight:`calc(44px / var(--k))`,minWidth:`calc(44px / var(--k))`},ie=(e,t,n,r)=>(0,B.jsx)(`button`,{type:`button`,"aria-label":e,onPointerDown:e=>v(e,()=>({kind:`button`,bit:t})),...S,className:`${ne} ${n}`,style:re,children:r}),ae=(e,t,n,r)=>(0,B.jsx)(`span`,{className:`flex h-[32px] w-[76px] items-center justify-center text-[13px] font-semibold tracking-wide ${w} ${C(t)}`,style:{borderRadius:r?n===`l`?`16px 9px 9px 9px`:`9px 16px 9px 9px`:`9px`},children:e}),oe=(e,t,n,r)=>ie(e,t,`h-[44px] w-[84px]`,ae(e,ee(t),n,r)),se=(e,t,n)=>(0,B.jsx)(`button`,{type:`button`,"aria-label":e,onPointerDown:e=>v(e,()=>({kind:`trigger`,which:t})),...S,className:`${ne} h-[44px] w-[84px]`,style:re,children:ae(e,l[t]>0,n,!0)}),D=(e,t,n)=>ie(e,t,`h-[52px] w-[52px]`,(0,B.jsx)(`svg`,{viewBox:`0 0 52 52`,width:`52`,height:`52`,"aria-hidden":!0,style:te,children:(0,B.jsxs)(`g`,{transform:`rotate(${n} 26 26)`,strokeWidth:`1.5`,strokeLinejoin:`round`,...T(ee(t)),children:[(0,B.jsx)(`path`,{d:`M10 9 Q10 3 16 3 L36 3 Q42 3 42 9 L42 30 Q42 34.5 38.5 38 L29.5 47 Q26 50.5 22.5 47 L13.5 38 Q10 34.5 10 30 Z`}),(0,B.jsx)(`path`,{d:`M20.5 23 L26 17 L31.5 23`,fill:`none`,stroke:`#fff`,strokeLinecap:`round`,strokeWidth:`1.8`})]})})),O=(e,t,n)=>ie(e,t,`h-[52px] w-[52px]`,(0,B.jsxs)(`svg`,{viewBox:`0 0 52 52`,width:`52`,height:`52`,"aria-hidden":!0,style:te,children:[(0,B.jsx)(`circle`,{cx:`26`,cy:`26`,r:`22.5`,strokeWidth:`1.5`,...T(ee(t))}),(0,B.jsx)(`g`,{fill:`none`,stroke:`#fff`,strokeWidth:`1.8`,strokeLinejoin:`round`,strokeLinecap:`round`,children:n})]})),ce=(e,t)=>ie(e,t,`h-[44px] min-w-[64px] px-[4px]`,(0,B.jsx)(`span`,{className:`flex h-[24px] items-center rounded-full px-[10px] text-[10px] font-semibold uppercase tracking-wider ${w} ${C(ee(t))}`,children:e})),le=(e,t)=>ie(e,t,`h-[44px] w-[44px]`,(0,B.jsx)(`span`,{className:`flex h-[36px] w-[36px] items-center justify-center rounded-full text-[11px] font-bold ${w} ${C(ee(t))}`,children:e})),ue=e=>{let{dx:t,dy:n}=ns(e===`l`?l.lx:l.rx,e===`l`?l.ly:l.ry,34),r=d[e];return(0,B.jsx)(`div`,{"aria-label":e===`l`?o(`rp_touch_left_stick`,void 0,`Left stick`):o(`rp_touch_right_stick`,void 0,`Right stick`),onPointerDown:t=>v(t,t=>{let n=t.getBoundingClientRect();return{kind:`stick`,which:e,cx:n.left+n.width/2,cy:n.top+n.height/2,radius:n.width/2}}),...S,className:`pointer-events-auto relative h-[124px] w-[124px] touch-none rounded-full border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.3)] transition-colors duration-75 ${r?`border-white/80 bg-white/[0.12]`:`border-white/45 bg-white/[0.05]`}`,children:(0,B.jsx)(`div`,{className:`absolute left-1/2 top-1/2 h-[54px] w-[54px] rounded-full ${C(r)}`,style:{transform:`translate(calc(-50% + ${t}px), calc(-50% + ${n}px))`}})})},k=t===`deck`,de=$o(r,m.width,m.height,k),fe=e=>`${e}px * var(--k)`,pe=`max(12px, env(safe-area-inset-left))`,me=`max(12px, env(safe-area-inset-right))`,he=`max(12px, env(safe-area-inset-bottom))`,ge=k?`8px`:t===`overlay-bar`?`3.5rem`:`max(10px, env(safe-area-inset-top))`,_e=(e,t,n=0)=>t?n?`calc(${e} + max(${fe(t)}, ${n}px))`:`calc(${e} + ${fe(t)})`:e,ye=(e,t)=>({position:`absolute`,...t,transform:`scale(var(--k))`,transformOrigin:e}),be=k&&ts(de,m.height),A=k?void 0:`58%`,j=e=>k?{top:_e(ge,be?96:112,be?72:90),[e]:e===`left`?pe:me}:{top:A,translate:`0 -50%`,[e]:e===`left`?pe:me},xe=e=>({bottom:be?he:_e(he,k?56:0,44),[e]:be?`calc(${e===`left`?pe:me} + 8px + max(${fe(80)}, 44px))`:_e(e===`left`?pe:me,k?40:168)}),Se=!!a&&!k;return(0,B.jsxs)(`div`,{ref:p,className:`pointer-events-none absolute z-10 select-none [-webkit-touch-callout:none] ${k?`inset-x-0 bottom-0`:`inset-0`}`,style:{top:k?i:void 0,"--k":de},"data-testid":`rp-touch`,"data-layout":t,"data-scale":de,onContextMenu:e=>e.preventDefault(),children:[(0,B.jsxs)(`div`,{className:`absolute inset-0`,style:{opacity:Yo(n)},children:[(0,B.jsx)(`div`,{style:ye(`top left`,{top:ge,left:pe}),children:(0,B.jsxs)(`div`,{className:`ms-[8px] flex flex-col`,style:{rotate:k?void 0:`6deg`,transformOrigin:`top left`},children:[se(`L2`,`l2`,`l`),oe(`L1`,z.L1,`l`,!1)]})}),(0,B.jsx)(`div`,{style:ye(`top right`,{top:ge,right:me}),children:(0,B.jsxs)(`div`,{className:`me-[8px] flex flex-col items-end`,style:{rotate:k?void 0:`-6deg`,transformOrigin:`top right`},children:[se(`R2`,`r2`,`r`),oe(`R1`,z.R1,`r`,!1)]})}),(0,B.jsx)(`div`,{"aria-label":o(`rp_touch_touchpad`,void 0,`Touchpad`),onPointerDown:e=>v(e,t=>({kind:`touchpad`,rect:t.getBoundingClientRect(),x0:e.clientX,y0:e.clientY,pressed:!0})),...S,className:`pointer-events-auto absolute touch-none rounded-2xl border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.3)] transition-colors duration-75 ${d.touchpad?`border-white/80 bg-white/25`:`border-white/40 bg-white/[0.05]`}`,style:k?{top:_e(ge,6),left:_e(pe,104),right:_e(me,104),height:`max(44px, calc(${fe(64)}))`}:{top:ge,left:`50%`,translate:`-50% 0`,width:`min(calc(${fe(250)}), 34vw)`,height:`max(44px, calc(${fe(56)}))`}}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 grid-rows-3`,style:ye(k?`top left`:`left center`,j(`left`)),children:[(0,B.jsx)(`span`,{}),D(`↑`,z.UP,0),(0,B.jsx)(`span`,{}),D(`←`,z.LEFT,-90),(0,B.jsx)(`span`,{}),D(`→`,z.RIGHT,90),(0,B.jsx)(`span`,{}),D(`↓`,z.DOWN,180),(0,B.jsx)(`span`,{})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 grid-rows-3`,style:ye(k?`top right`:`right center`,j(`right`)),children:[(0,B.jsx)(`span`,{}),O(`△`,z.TRIANGLE,(0,B.jsx)(`path`,{d:`M26 16.5 L35 32 L17 32 Z`})),(0,B.jsx)(`span`,{}),O(`□`,z.SQUARE,(0,B.jsx)(`rect`,{x:`18`,y:`18`,width:`16`,height:`16`,rx:`1`})),(0,B.jsx)(`span`,{}),O(`○`,z.CIRCLE,(0,B.jsx)(`circle`,{cx:`26`,cy:`26`,r:`8.5`})),(0,B.jsx)(`span`,{}),O(`✕`,z.CROSS,(0,B.jsx)(`path`,{d:`M19 19 L33 33 M33 19 L19 33`})),(0,B.jsx)(`span`,{})]}),(0,B.jsx)(`div`,{style:ye(`bottom left`,xe(`left`)),children:ue(`l`)}),(0,B.jsx)(`div`,{style:ye(`bottom right`,xe(`right`)),children:ue(`r`)}),(0,B.jsx)(`div`,{style:ye(`bottom left`,{bottom:he,left:pe}),children:ce(`Create`,z.SHARE)}),(0,B.jsx)(`div`,{style:ye(`bottom right`,{bottom:he,right:me}),children:ce(`Options`,z.OPTIONS)}),(0,B.jsx)(`div`,{style:ye(`bottom center`,{bottom:be?_e(he,124,88):_e(he,Se?48:0,48),left:rs,translate:`-50% 0`}),children:le(`PS`,z.PS)})]}),Se&&(0,B.jsx)(`div`,{style:{...ye(`bottom center`,{bottom:he,left:`calc(50% + (env(safe-area-inset-left) - env(safe-area-inset-right)) / 2)`,translate:`-50% 0`}),opacity:Math.max(.7,Yo(n))},children:(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a?.()},onDoubleClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),"aria-label":o(`rp_menu`,void 0,`Menu`),"aria-haspopup":`dialog`,className:`${ne} h-[44px] w-[56px]`,style:re,"data-testid":`rp-menu-handle`,children:(0,B.jsx)(`span`,{className:`flex h-[26px] w-[44px] items-center justify-center rounded-full ${w} ${C(!1)}`,children:(0,B.jsx)(ve,{size:15,strokeWidth:2,"aria-hidden":!0})})})})]})}var ss=`data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAYZbW9vdgAAAGxtdmhkAAAAAAAAAAAAAAAAAAAfQAAAfQAAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAmt0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAABAAAAAAAAfQAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAABAAAAAQAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAH0AAAAAAAABAAAAAAHjbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAABAAAABAABVxAAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAABjm1pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAU5zdGJsAAAAunN0c2QAAAAAAAAAAQAAAKphdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAABAAEABIAAAASAAAAAAAAAABFExhdmM2My4xLjEwMiBsaWJ4MjY0AAAAAAAAAAAAAAAAGP//AAAAMGF2Y0MBQsAK/+EAF2dCwAqmEXsBEAAAAwAQAAADACDxImEYAQAGaMhCAZSyAAAAEHBhc3AAAAABAAAAAQAAABRidHJ0AAAAAAAABUAAAAAAAAAAGHN0dHMAAAAAAAAAAQAAAAQAAEAAAAAAFHN0c3MAAAAAAAAAAQAAAAEAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAJHN0c3oAAAAAAAAAAAAAAAQAAAKCAAAACgAAAAoAAAAKAAAAIHN0Y28AAAAAAAAABAAABlwAAAj+AAAJKAAACVIAAALZdHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAH0AAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAB9AAAABAAAAQAAAAACUW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAH0AAAIEAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAfxtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAcBzdGJsAAAAfnN0c2QAAAAAAAAAAQAAAG5tcDRhAAAAAAAAAAEAAAAAAAAAAAABABAAAAAAH0AAAAAAADZlc2RzAAAAAAOAgIAlAAIABICAgBdAFQAAAAAAH0AAAAEcBYCAgAUViFblAAaAgIABAgAAABRidHJ0AAAAAAAAH0AAAAEcAAAAIHN0dHMAAAAAAAAAAgAAACAAAAQAAAAAAQAAAQAAAAAoc3RzYwAAAAAAAAACAAAAAQAAAAEAAAABAAAAAgAAAAgAAAABAAAAmHN0c3oAAAAAAAAAAAAAACEAAAATAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAkc3RjbwAAAAAAAAAFAAAGSQAACN4AAAkIAAAJMgAACVwAAAAac2dwZAEAAAByb2xsAAAAAgAAAAH//wAAABxzYmdwAAAAAHJvbGwAAAABAAAAIQAAAAEAAABhdWR0YQAAAFltZXRhAAAAAAAAACFoZGxyAAAAAAAAAABtZGlyYXBwbAAAAAAAAAAAAAAAACxpbHN0AAAAJKl0b28AAAAcZGF0YQAAAAEAAAAATGF2ZjYzLjEuMTAyAAAACGZyZWUAAAM7bWRhdNwATGF2YzYzLjEuMTAyAAIwQA4AAAJvBgX//2vcRem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY1IHIzMjIyIGIzNTYwNWEgLSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDI1IC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9uczogY2FiYWM9MCByZWY9MTYgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDEzMSBtZT11bWggc3VibWU9MTAgcHN5PTEgcHN5X3JkPTEuMDA6MC4wMCBtaXhlZF9yZWY9MSBtZV9yYW5nZT0yNCBjaHJvbWFfbWU9MSB0cmVsbGlzPTIgOHg4ZGN0PTAgY3FtPTAgZGVhZHpvbmU9MjEsMTEgZmFzdF9wc2tpcD0xIGNocm9tYV9xcF9vZmZzZXQ9LTIgdGhyZWFkcz0xIGxvb2thaGVhZF90aHJlYWRzPTEgc2xpY2VkX3RocmVhZHM9MCBucj0wIGRlY2ltYXRlPTEgaW50ZXJsYWNlZD0wIGJsdXJheV9jb21wYXQ9MCBjb25zdHJhaW5lZF9pbnRyYT0wIGJmcmFtZXM9MCB3ZWlnaHRwPTAga2V5aW50PTQga2V5aW50X21pbj0xIHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NCByYz1jcmYgbWJ0cmVlPTEgY3JmPTUxLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAAALZYiCAv5MUAAQv8ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmhwF/UABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmioBb1ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmjsBX1ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBw==`,cs=null,ls=null;function us(e){e.play().catch(()=>{if(ls||cs!==e)return;let t=()=>{ds(),cs===e&&e.play().catch(()=>{})};window.addEventListener(`pointerdown`,t,{capture:!0}),ls=()=>window.removeEventListener(`pointerdown`,t,{capture:!0})})}function ds(){ls?.(),ls=null}function fs(){if(typeof document<`u`){if(!cs){let e=document.createElement(`video`);e.muted=!0,e.loop=!0,e.playsInline=!0,e.setAttribute(`playsinline`,``),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-testid`,`keep-screen-video`),e.style.cssText=`position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none`,e.src=ss,document.body.appendChild(e),cs=e}us(cs)}}function ps(){ds(),cs&&=(cs.pause(),cs.removeAttribute(`src`),cs.remove(),null)}function ms(){return typeof navigator>`u`?null:navigator.wakeLock??null}function hs(){return ut()||!Nn()}var gs=new Set,_s=null,vs=Promise.resolve(),ys=!1;async function bs(){if(gs.size===0||_s&&!_s.released)return;let e=ms();if(!e)ut()&&fs();else try{let t=await e.request(`screen`);t.addEventListener(`release`,()=>{_s===t&&(_s=null)}),_s=t}catch{}}async function xs(){ps();let e=_s;if(_s=null,e&&!e.released)try{await e.release()}catch{}}function Ss(){ys||typeof document>`u`||(ys=!0,document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&gs.size>0&&(vs=vs.then(bs))}))}function Cs(e,t){if(!hs())return;Ss();let n=gs.size>0;t?gs.add(e):gs.delete(e);let r=gs.size>0;n!==r&&(vs=vs.then(r?bs:xs))}var ws=new Set;function Ts(){if(typeof window<`u`)return window.PS5UploadPad}function Es(e,t){let n=ws.size>0;t?ws.add(e):ws.delete(e);let r=ws.size>0;if(n!==r)try{Ts()?.setActive(r)}catch{}}var Ds=class e{constructor(e){this.receiver=e,this.last=null,this.was={}}get frames(){return Number(this.last?.frames??0)}static report(e,t){let n=t=>e[t]??0,r=e=>n(e)-(t[e]??0),i=(e,t)=>r(t)>0?Math.round(r(e)/r(t)*1e4)/10:0;return{frames:n(`framesDecoded`),dropped:n(`framesDropped`),stalls:n(`freezeCount`),stall_ms:Math.round(n(`totalFreezesDuration`)*1e3),decode_ms:i(`totalDecodeTime`,`framesDecoded`),jitter_ms:i(`jitterBufferDelay`,`jitterBufferEmittedCount`),nacks:n(`nackCount`),plis:n(`pliCount`),decoder:`track`}}snapshot(){return this.receiver.getStats().then(t=>{t.forEach(t=>{t.type===`inbound-rtp`&&t.kind===`video`&&(this.last=e.report(t,this.was),this.was={...t})})}).catch(()=>{}),this.last}},Os=class{constructor(e){this.inner=e,this.video=document.createElement(`video`),this.wrap=document.createElement(`div`),this.media=null,this.trackStats=null,this.audio=!1,this.soundOn=!1,this.muted=!1;let t=this.video;t.muted=t.autoplay=t.playsInline=!0,t.className=`block h-full w-full object-contain`,t.dataset.testid=`track-video`,this.wrap.className=`h-full w-full`,this.wrap.append(t,e.element),this.setTrack(null)}get element(){return this.wrap}get stats(){return this.trackStats??this.inner.stats}setTrack(e,t=!1){this.media=e,this.audio=!!e&&t,this.applySound(),this.trackStats=e?new Ds(e.receiver):null,this.video.style.display=e?``:`none`,this.inner.element.style.display=e?`none`:``,this.video.srcObject!==(e?.stream??null)&&(this.video.srcObject=e?.stream??null),e&&this.play()}play(){try{this.video.play()?.catch?.(()=>{})}catch{}}onMessage(e){let t=new Uint8Array(e)[0];this.media&&t<=1||(!this.audio||t!==3&&t!==4)&&this.inner.onMessage(e)}applySound(){this.video.muted=!(this.audio&&this.soundOn&&!this.muted)}setHevc(e){this.inner.setHevc(e)}set onSoundFail(e){this.inner.onSoundFail=e}soundReport(){return this.inner.soundReport()}startSound(){this.inner.startSound(),this.soundOn=!0,this.applySound(),this.media&&this.play()}setMuted(e){this.inner.setMuted(e),this.muted=e,this.applySound()}resumeSound(){this.inner.resumeSound(),this.media&&this.video.paused&&this.play()}stop(){this.inner.stop(),this.video.srcObject=null}},ks=`ps5upload.join.muted`,As=5e3,js=Object.fromEntries(Object.entries(Ma).filter(([e])=>e!==`Escape`)),Ms=new Set;function Ns(e){if(!(e.code in js)||e.ctrlKey||e.metaKey||e.altKey)return!1;let t=e.target;if(e.code===`Tab`&&(e.shiftKey||Ps(t)))return!1;let n=t?.tagName;return!(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||Ps(t))}function Ps(e){let t=e?.tagName;if(t===`BUTTON`||t===`A`)return!0;let n=e?.getAttribute?.(`role`);return n===`button`||n===`link`||n===`menuitem`||n===`tab`||n===`switch`}var Fs=!1;function Is(e){Fs=e}function Ls(e,t,n=null){if(!e||e.frames===0&&!t)return null;let r=e.snapshot();return r&&{...r,...t?{problem:t}:{},...n??{}}}function Rs(){if(Fs)return{...Aa};let e=Wa(Ya(typeof navigator>`u`?void 0:navigator),xo),t=Ko.touchPad;return{...Ga(Ga(e,Pa(Ms,js)),t),touch:t.touch??null,motion:Ko.motion??null}}var zs=class{constructor(e){this.opts=e,this.player=null,this.listeners=new Set,this.cleanups=[],this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.snap={stage:{kind:`connecting`},status:null,rttMs:null,light:null,problem:null,sound:!1,noSound:!1,host:e.host,muted:Vs(),path:null},this.client=new Ro({url:e.url,invite:e.invite,code:e.code??null,name:e.name,WebSocketImpl:e.transport,readPad:Rs,onStage:e=>{this.set({stage:e}),e.kind===`joined`&&this.readPath(),(e.kind===`refused`||e.kind===`ended`)&&this.teardown()},onStatus:e=>this.set({status:e,host:e.host??this.snap.host}),onRtt:e=>this.set({rttMs:e}),onFrame:e=>this.picture().onMessage(e),readStats:()=>Ls(this.player?.stats??null,this.snap.problem,this.player?.soundReport()??null),onCodec:(e,t,n)=>{let r=this.picture();r.setHevc(e),r instanceof Os&&(r.setTrack(t,!!n),t&&this.snap.problem&&this.set({problem:null}))},onRumble:(e,t)=>{let n=Ya(typeof navigator>`u`?void 0:navigator);Ka(n,e,t),n.some(e=>e?.connected)||navigator.vibrate?.(e||t?200:0)},onLight:e=>this.set({light:e})})}picture(){if(!this.player){let e=aa(e=>this.set({problem:e}),`player`,()=>this.client.askKeyframe());this.player=this.opts.transport?new Os(e):e,this.player.onSoundFail=()=>this.set({noSound:!0}),this.player.setMuted(this.snap.muted)}return this.player}async readPath(){let e=this.client.socket,t=this.opts.path??null;if(e?.netPath)try{t=await e.netPath()??this.opts.path??null}catch{t=null}t!==this.snap.path&&this.set({path:t})}get element(){return this.picture().element}start(){let e=()=>{document.visibilityState===`hidden`?Ms.clear():this.player?.resumeSound(),this.client.setNeutral(document.visibilityState===`hidden`)},t=()=>{Ms.clear(),this.client.setNeutral(!0)},n=e=>{this.client.current.kind===`joined`&&Ns(e)&&(!this.opts.keysLive||this.opts.keysLive())&&(e.preventDefault(),Ms.add(e.code))},r=e=>{Ms.delete(e.code)&&Ns(e)&&e.preventDefault()};window.addEventListener(`keydown`,n),window.addEventListener(`keyup`,r);let i=()=>{this.client.setNeutral(document.visibilityState===`hidden`),document.visibilityState!==`hidden`&&this.player?.resumeSound()};document.addEventListener(`visibilitychange`,e),window.addEventListener(`blur`,t),window.addEventListener(`focus`,i);let a=setInterval(()=>{this.client.current.kind===`joined`&&this.readPath()},As);this.cleanups.push(()=>{clearInterval(a),document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`blur`,t),window.removeEventListener(`focus`,i),window.removeEventListener(`keydown`,n),window.removeEventListener(`keyup`,r),Ms.clear()}),this.client.start()}setMuted(e){this.player?.setMuted(e);try{localStorage.setItem(ks,e?`1`:`0`)}catch{}this.set({muted:e})}startSound(){this.snap.sound||(this.picture().startSound(),this.set({sound:!0}))}leave(){this.client.leave(),this.teardown()}stop(){this.client.stop(),this.teardown()}teardown(){for(let e of this.cleanups.splice(0))e();Ko.touchPad={buttons:0,l2:0,r2:0,lx:0,ly:0,rx:0,ry:0};let e=this.player;this.player=null,e&&(e.stop(),e.element.remove())}sendPad(){this.client.sendPad(!1)}get snapshot(){return this.snap}set(e){this.snap={...this.snap,...e};for(let e of this.listeners)e()}};function Bs(e){return(0,E.useSyncExternalStore)(e.subscribe,()=>e.snapshot)}function Vs(){try{return typeof localStorage<`u`&&localStorage.getItem(ks)===`1`}catch{return!1}}function Hs(e){let t=()=>{let t=e.snapshot.stage.kind,n=t!==`refused`&&t!==`ended`;Cs(`play-together`,n),Es(`play-together`,n)};t();let n=e.subscribe(t);return()=>{n(),Cs(`play-together`,!1),Es(`play-together`,!1)}}var Us=3e3,Ws=class{constructor(e,t=Us){this.onChange=e,this.delay=t,this.enabled=!1,this.pinned=!1,this.sticky=!1,this.shown=!0,this.timer=null}get visible(){return!this.enabled||this.pinned||this.shown}set(e,t,n=!1){let r=this.enabled&&!this.pinned,i=this.enabled,a=this.sticky;this.enabled=e,this.pinned=t,this.sticky=n,!e||t?(this.stop(),this.show(!0)):n?(this.stop(),!i||!a?this.show(!1):r||this.show(!0)):(!r||a)&&(this.show(!0),this.arm())}poke(){this.show(!0),this.enabled&&!this.pinned&&!this.sticky&&this.arm()}toggle(){this.visible?this.hide():this.poke()}hide(){this.enabled&&!this.pinned&&(this.stop(),this.show(!1))}dispose(){this.stop()}arm(){this.stop(),this.timer=setTimeout(()=>{this.timer=null,this.show(!1)},this.delay)}stop(){this.timer!==null&&clearTimeout(this.timer),this.timer=null}show(e){this.shown!==e&&(this.shown=e,this.onChange(e))}};function Gs(e,t,n=!1){let[r,i]=(0,E.useState)(!0),a=(0,E.useRef)(null);(0,E.useEffect)(()=>{let e=new Ws(i);return a.current=e,()=>{e.dispose(),a.current=null}},[]),(0,E.useEffect)(()=>{a.current?.set(e,t,n)},[e,t,n]);let o=(0,E.useCallback)(()=>a.current?.poke(),[]),s=(0,E.useCallback)(()=>a.current?.hide(),[]),c=(0,E.useCallback)(()=>a.current?.toggle(),[]);return{shown:!e||t||r,poke:o,hide:s,toggle:c}}var Ks=3e4,qs=class{constructor(e,t=Ks){this.onChange=e,this.ms=t,this.picking=!1,this.over=!1,this.timer=null}get shown(){return this.picking&&!this.over}set(e){e!==this.picking&&(this.picking=e,this.over=!1,this.stop(),e&&(this.timer=setTimeout(()=>{this.timer=null,this.over=!0,this.onChange()},this.ms)))}stop(){this.timer&&clearTimeout(this.timer),this.timer=null}reset(){this.stop(),this.picking=!1,this.over=!1}};function Js(e){let[,t]=(0,E.useState)(0),[n]=(0,E.useState)(()=>new qs(()=>t(e=>e+1)));return(0,E.useEffect)(()=>{n.set(e),t(e=>e+1)},[n,e]),(0,E.useEffect)(()=>()=>n.reset(),[n]),n.shown}var Ys=()=>Ya(typeof navigator>`u`?void 0:navigator).filter(e=>!!e?.connected);function Xs(e,t){if(t.kind===`axis`)return t.which===`lx`?e(`rp_pad_step_lx`,void 0,`Push the left stick right`):t.which===`ly`?e(`rp_pad_step_ly`,void 0,`Push the left stick down`):t.which===`rx`?e(`rp_pad_step_rx`,void 0,`Push the right stick right`):e(`rp_pad_step_ry`,void 0,`Push the right stick down`);if(t.kind===`button`){if(t.bit===z.CROSS)return e(`join_check_bottom`,void 0,`Press the bottom face button (✕)`);if(t.bit===z.CIRCLE)return e(`join_check_right`,void 0,`Press the right face button (○)`);if(t.bit===z.SQUARE)return e(`join_check_left`,void 0,`Press the left face button (□)`);if(t.bit===z.TRIANGLE)return e(`join_check_top`,void 0,`Press the top face button (△)`)}return e(`rp_pad_press`,{name:t.name},`Press ${t.name}`)}function Zs(e,t){let n=(0,E.useRef)(t);(0,E.useEffect)(()=>{n.current=t}),(0,E.useEffect)(()=>{if(e===null)return;let t=0,r=()=>{n.current(Ys().find(t=>t.index===e)??null),t=window.requestAnimationFrame(r)};return t=window.requestAnimationFrame(r),()=>window.cancelAnimationFrame(t)},[e])}var Qs=[[z.CROSS,`✕`],[z.CIRCLE,`○`],[z.SQUARE,`□`],[z.TRIANGLE,`△`],[z.UP,`↑`],[z.DOWN,`↓`],[z.LEFT,`←`],[z.RIGHT,`→`],[z.L1,`L1`],[z.R1,`R1`],[z.L3,`L3`],[z.R3,`R3`],[z.SHARE,`Create`],[z.OPTIONS,`Options`],[z.PS,`PS`],[z.TOUCHPAD,`Touchpad`]];function $s({pad:e}){let t=e=>`flex h-8 min-w-8 items-center justify-center rounded-md px-1.5 text-xs font-medium ${e?`bg-white text-black`:`bg-white/10 text-white/70`}`,n=(e,t,n)=>(0,B.jsxs)(`span`,{className:`relative flex h-12 w-12 items-center justify-center rounded-full bg-white/10 text-[10px] text-white/50`,children:[n,(0,B.jsx)(`span`,{className:`absolute h-3 w-3 rounded-full bg-white`,style:{left:`calc(50% + ${e/32767*18}px - 6px)`,top:`calc(50% + ${t/32767*18}px - 6px)`}})]});return(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`join-pad-test`,"data-buttons":e.buttons,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[Qs.map(([n,r])=>(0,B.jsx)(`span`,{className:t((e.buttons&n)!==0),"data-on":(e.buttons&n)===0?`0`:`1`,children:r},n)),(0,B.jsx)(`span`,{className:t(e.l2>30),children:`L2`}),(0,B.jsx)(`span`,{className:t(e.r2>30),children:`R2`})]}),(0,B.jsxs)(`div`,{className:`flex gap-3`,children:[n(e.lx,e.ly,`L`),n(e.rx,e.ry,`R`)]})]})}function ec({onClose:e}){let t=Fe(),[n,r]=(0,E.useState)(()=>Ys().map(e=>({index:e.index,id:e.id}))),[i,a]=(0,E.useState)(()=>Ys()[0]?.index??null),[o,s]=(0,E.useState)(Aa),[c,l]=(0,E.useState)(null),[u,d]=(0,E.useState)(0),[f,p]=(0,E.useState)(vo),[m,h]=(0,E.useState)(null),[g,_]=(0,E.useState)(null);(0,E.useEffect)(()=>(Is(!0),()=>Is(!1)),[]),(0,E.useEffect)(()=>{let e=()=>{let e=Ys();r(t=>t.length===e.length&&t.every((t,n)=>t.id===e[n].id&&t.index===e[n].index)?t:e.map(e=>({index:e.index,id:e.id}))),a(t=>t!==null&&e.some(e=>e.index===t)?t:e[0]?.index??null)},t=window.setInterval(e,500);return window.addEventListener(`gamepadconnected`,e),window.addEventListener(`gamepaddisconnected`,e),()=>{window.clearInterval(t),window.removeEventListener(`gamepadconnected`,e),window.removeEventListener(`gamepaddisconnected`,e)}},[]),Zs(i,e=>{if(_(t=>t?.id===e?.id?t:e),!e)return;if(c){c.feed(To(e))&&v(c,e);return}let t=Wa([e],xo);s(e=>e.buttons===t.buttons&&e.l2===t.l2&&e.r2===t.r2&&e.lx===t.lx&&e.ly===t.ly&&e.rx===t.rx&&e.ry===t.ry?e:t)});let v=(e,n)=>{if(!e.done)return d(e.step);let r=n?.id??g?.id;l(null),r&&(p(yo(r,e.profile(n?Co(n):void 0))),h(t(`join_check_saved`,void 0,`Saved for this controller on this device. Try it below.`)))},y=()=>{h(null),d(0),l(new Po(Mo))},b=g,x=b?So(b):null,S=!!(b&&f[b.id]);return(0,B.jsx)(`div`,{className:`absolute inset-0 z-40 flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm`,"data-testid":`join-pad-check`,onPointerDown:e=>e.stopPropagation(),children:(0,B.jsxs)(`div`,{className:`w-[min(26rem,100%)] space-y-3 rounded-2xl border border-white/10 bg-neutral-900/95 p-4 text-sm text-white shadow-2xl`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(me,{size:16,className:`text-white/70`}),(0,B.jsx)(`p`,{className:`flex-1 font-semibold`,children:t(`join_check_title`,void 0,`Check your controller`)}),(0,B.jsx)(`button`,{type:`button`,onClick:e,"aria-label":t(`join_done`,void 0,`Done`),className:`flex h-8 w-8 items-center justify-center rounded-full bg-white/10 hover:bg-white/20`,"data-testid":`join-pad-check-close`,children:(0,B.jsx)(Ee,{size:15})})]}),b?(0,B.jsxs)(B.Fragment,{children:[n.length>1&&(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.map(e=>(0,B.jsx)(`button`,{type:`button`,disabled:!!c,onClick:()=>a(e.index),className:`rounded-full px-2.5 py-1 text-xs ${e.index===i?`bg-white text-black`:`bg-white/10`}`,children:eo(e.id)},`${e.index}-${e.id}`))}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`truncate font-medium`,"data-testid":`join-pad-check-name`,children:eo(b.id)}),(0,B.jsx)(`p`,{className:`text-xs text-white/60`,"data-testid":`join-pad-check-kind`,"data-kind":x??``,children:x===`saved`?t(`rp_pad_mapped`,void 0,`Plays with your mapping`):x===`guess`?t(`join_check_unknown`,void 0,`This controller isn't on our list, so its buttons may be mixed up. Setting it up takes a few seconds.`):t(`rp_pad_standard`,void 0,`Recognized`)}),ro(b)&&(0,B.jsx)(Wo,{id:b.id,className:`mt-1 block text-xs text-amber-200/90`})]}),c?(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`join-pad-learn`,children:[(0,B.jsx)(`p`,{className:`text-xs text-white/60`,children:t(`rp_pad_progress`,{n:u+1,total:c.steps.length},`${u+1} of ${c.steps.length}`)}),(0,B.jsx)(`p`,{className:`text-lg font-semibold`,"data-testid":`join-pad-learn-step`,children:c.current?Xs(t,c.current):``}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>{c.skip(),v(c,b)},className:`rounded-full bg-white/15 px-3 py-1.5 text-xs hover:bg-white/25`,"data-testid":`join-pad-learn-skip`,children:t(`rp_pad_skip`,void 0,`Skip`)}),u>0&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{c.back(),d(c.step)},className:`rounded-full bg-white/15 px-3 py-1.5 text-xs hover:bg-white/25`,children:t(`rp_pad_back`,void 0,`Back`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded-full px-3 py-1.5 text-xs text-white/70 hover:bg-white/10`,children:t(`rp_pad_cancel`,void 0,`Cancel`)})]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-xs text-white/60`,children:t(`join_check_try`,void 0,`Press buttons and move the sticks: what you press lights up.`)}),(0,B.jsx)($s,{pad:o}),m&&(0,B.jsx)(`p`,{className:`text-xs text-emerald-300`,role:`status`,children:m}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:y,className:`rounded-full bg-white px-3 py-1.5 text-xs font-medium text-black`,"data-testid":`join-pad-learn-start`,children:S?t(`join_check_redo`,void 0,`Redo`):t(`join_check_map`,void 0,`Set up the buttons`)}),S&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{p(yo(b.id,null)),h(null)},className:`rounded-full bg-white/15 px-3 py-1.5 text-xs hover:bg-white/25`,"data-testid":`join-pad-reset`,children:t(`rp_pad_reset`,void 0,`Reset`)}),(0,B.jsx)(`button`,{type:`button`,onClick:e,className:`rounded-full bg-white/15 px-3 py-1.5 text-xs hover:bg-white/25`,"data-testid":`join-pad-check-done`,children:t(`join_done`,void 0,`Done`)})]})]})]}):(0,B.jsx)(`p`,{className:`text-white/70`,children:t(`rp_pads_none`,void 0,`No controller seen yet. Connect one and press any button on it.`)})]})})}function tc(e,t){let[n,r]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{if(!e||!t)return;let n=!0;return ze(e,Ie).then(e=>{n&&!e&&r(!0)}),()=>{n=!1}},[e,t]),n}function nc({href:e}){let t=Fe();return(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,"data-testid":`open-on-wifi`,children:[(0,B.jsx)(`p`,{className:`max-w-sm text-sm text-white/60`,children:t(`join_open_lan_body`,void 0,`Can't reach the internet? If you're on the same Wi-Fi as your friend, open the game there.`)}),(0,B.jsx)(`a`,{href:e,rel:`noreferrer`,className:`rounded-full bg-white px-4 py-2 text-sm font-medium text-black`,"data-testid":`open-on-wifi-link`,children:t(`join_open_lan`,void 0,`Open on this Wi-Fi`)})]})}function rc(e){let t=Math.max(0,Math.ceil(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var ic=`ps5upload.join.guided`,ac=1;function oc(e){return e.player!==ac&&(!e.guided||e.movedOff)&&!e.reconnecting}function sc(e,t){switch(t){case`lan`:return e(`join_path_lan`,void 0,`Home network`);case`tailscale`:return e(`join_path_tailscale`,void 0,`Tailscale`);default:return e(`join_path_internet`,void 0,`Internet`)}}function cc(e,t){return e(`join_seat_taken`,{host:t},`${t} needed their controller back and no other controller was free on the PS5, so you're out of the game. Ask ${t} to let you in again.`)}function lc(e,t,n,r=!1){if(t.kind===`refused`)switch(t.why){case`key`:return e(`join_refused_key`,{host:n},`This invite has expired. Ask ${n} for a new link.`);case`expired`:return e(`join_refused_expired`,{host:n},`Your place in the game was lost. Ask ${n} to let you in again.`);case`full`:return e(`join_refused_full`,void 0,`The game is full: four players already.`);case`denied`:return e(`join_refused_denied`,{host:n},`${n} didn't let you in this time.`);case`no_answer`:return e(`join_refused_no_answer`,{host:n},`${n} didn't answer in time. Tell ${n}, then try again.`);case`closed`:return e(`join_refused_closed`,{host:n},`${n} isn't hosting Play Together right now.`);case`old_helper`:return e(`join_refused_old_helper`,{host:n},`${n}'s PS5 needs an updated helper for Play Together.`);case`not_playing`:return e(`join_refused_not_playing`,{host:n},`${n} isn't playing right now. Ask ${n} to start Play first.`);case`unreachable`:return e(`join_refused_unreachable`,{host:n},`${n}'s computer couldn't reach their PS5. Try again in a moment.`);case`slow_down`:return e(`join_refused_slow_down`,void 0,`Too many wrong codes. Wait a minute, then try again.`);case`address`:return e(`join_refused_address`,{host:n},`This link's address is outside your home network, so the app will not use it. Ask ${n} for a link with their computer's IP address.`);case`seat_taken`:return cc(e,n);default:return e(`join_refused_other`,{host:n},`${n} didn't let you in.`)}if(t.kind===`ended`)switch(t.why){case`kicked`:return e(`join_ended_kicked`,{host:n},`${n} took you out of the game.`);case`closed`:return e(`join_ended_closed`,{host:n},`${n} closed Play Together.`);case`host_stopped`:return e(`join_ended_host_stopped`,void 0,`The host stopped playing.`);case`replaced`:return e(`join_ended_replaced`,void 0,`This game was opened in another tab or on another device, so it stopped here.`);case`pad_lost`:return e(`join_ended_pad_lost`,{host:n},`The PS5 lost your controller, so you're out of the game. Ask ${n} to let you in again.`);case`gave_up`:return e(`join_ended_gave_up`,{host:n},`The connection to ${n} didn't come back in time.`);case`lost`:return r?e(`join_net_lost`,{host:n},`The connection to ${n} dropped. Check your internet connection, then ask again.`):e(`join_ended_lost`,{host:n},`Couldn't reach ${n}. Check that you're on the same network.`);case`left`:return e(`join_ended_left`,void 0,`You left the game.`);case`seat_taken`:return cc(e,n);case`mismatch`:return e(`join_net_mismatch`,void 0,`This link doesn't match the host; ask them for a new one.`);case`no_direct`:return e(`join_net_no_direct`,void 0,`A direct connection isn't possible from this network (both sides' routers are strict). Try Wi-Fi instead of mobile data, or ask the host to turn on UPnP.`);case`no_room`:return e(`join_net_no_room`,{host:n},`This invite isn't open any more. Ask ${n} for a new link.`);case`net_full`:return e(`join_net_full`,{host:n},`${n}'s game has no room for another friend right now. Try again in a moment.`);case`no_hub`:return e(`join_net_no_hub`,void 0,`Couldn't reach the PS5Upload invite service. Check your internet connection, then try again.`);case`offer`:return e(`join_net_offer`,{host:n},`${n}'s computer couldn't connect to this browser. Try another browser.`);case`no_webrtc`:return e(`join_net_no_webrtc`,void 0,`This browser can't make direct connections. Try a recent Chrome, Safari or Firefox.`)}return``}function uc(e){let[t,n]=(0,E.useState)(()=>Date.now());return(0,E.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),500);return()=>window.clearInterval(t)},[e]),t}function dc(){let[e,t]=(0,E.useState)({ready:!1,pressed:!1,id:null,kind:null,weak8BitDo:!1});return(0,E.useEffect)(()=>{let e=()=>{let e=Ya(typeof navigator>`u`?void 0:navigator).find(e=>!!e?.connected),n=!!e,r=n?Rs():null,i=!!r&&(r.buttons!==0||r.l2>30||r.r2>30),a=e?.id??null,o=e?So(e):null,s=!!e&&ro(e);t(e=>e.ready===n&&e.pressed===i&&e.id===a&&e.kind===o&&e.weak8BitDo===s?e:{ready:n,pressed:i,id:a,kind:o,weak8BitDo:s})};e();let n=window.setInterval(e,120);return window.addEventListener(`gamepadconnected`,e),window.addEventListener(`gamepaddisconnected`,e),()=>{window.clearInterval(n),window.removeEventListener(`gamepadconnected`,e),window.removeEventListener(`gamepaddisconnected`,e)}},[]),e}function fc(e){return!!e?.closest?.(`[data-testid="rp-touch"]`)}var pc=14,mc=()=>typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches,hc={good:`var(--color-good,#32d074)`,fair:`var(--color-warn,#ffb340)`,slow:`var(--color-bad,#ff6961)`,none:`rgba(255,255,255,.5)`};function gc({text:e,body:t,onCancel:n}){let r=Fe();return(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-5 px-6 py-10 text-center`,"data-testid":`join-waiting`,children:[(0,B.jsxs)(`div`,{className:`relative flex h-24 w-24 items-center justify-center`,"aria-hidden":!0,children:[(0,B.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-white/10 [animation-duration:2.4s]`}),(0,B.jsx)(`span`,{className:`absolute inset-3 animate-pulse rounded-full bg-white/10 [animation-duration:2.4s]`}),(0,B.jsx)(`span`,{className:`relative flex h-14 w-14 items-center justify-center rounded-full bg-white/15`,children:(0,B.jsx)(Se,{size:26})})]}),(0,B.jsx)(`p`,{className:`max-w-sm text-base font-medium`,"data-testid":`join-stage`,children:e}),t&&(0,B.jsx)(`p`,{className:`max-w-sm text-sm text-white/60`,children:t}),(0,B.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full bg-white/15 px-4 py-2 text-sm hover:bg-white/25`,"data-testid":`join-cancel`,children:r(`join_cancel`,void 0,`Cancel`)})]})}function _c({session:e,inApp:t=!1,onLeave:n,onAgain:r,onFullscreen:i,lanUrl:a=null,hubDown:o=!1}){let s=Fe(),c=Bs(e),{stage:l,status:u}=c,d=c.host??s(`join_host_fallback`,void 0,`your friend`),f=(0,E.useRef)(null),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(()=>It(ic)===`1`),[_,v]=(0,E.useState)(()=>typeof window<`u`&&window.innerHeight>window.innerWidth),y=dc(),[b,x]=(0,E.useState)(!1),S=l.kind===`reconnecting`,ee=uc(S),C=l.kind===`joined`||S,w=u?.state===`picking_user`,te=l.kind===`joined`||l.kind===`reconnecting`?l.player:0,[T,ne]=(0,E.useState)(!1),re=(0,E.useRef)(te);(0,E.useEffect)(()=>{re.current===ac&&te>ac&&ne(!0),te&&(re.current=te)},[te]);let[ie,ae]=(0,E.useState)(!1),[oe,se]=(0,E.useState)(!1),D=C&&(p||!t),O=mc(),ce=Js(w),ue=Gs(D,S||ce&&!O||ie||oe,O),{poke:de}=ue,pe=(0,E.useRef)(null),he=()=>{pe.current&&clearTimeout(pe.current.timer),pe.current=null};(0,E.useEffect)(()=>he,[]);let[_e,ve]=(0,E.useState)(!1),ye=(0,E.useRef)(!1);(0,E.useEffect)(()=>{if(!D||!O||ue.shown||!h||ye.current)return;ye.current=!0,ve(!0);let e=setTimeout(()=>ve(!1),6e3);return()=>clearTimeout(e)},[D,O,ue.shown,h]),(0,E.useEffect)(()=>{if(!C)return;let t=e.element;return f.current?.appendChild(t),()=>t.remove()},[C,e]),(0,E.useEffect)(()=>{if(!C||c.sound)return;let t=()=>e.startSound(),n=[`pointerup`,`touchend`,`click`,`keydown`];for(let e of n)window.addEventListener(e,t,!0);return()=>{for(let e of n)window.removeEventListener(e,t,!0)}},[C,c.sound,e]),(0,E.useEffect)(()=>{let e=()=>v(window.innerHeight>window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,E.useEffect)(()=>{if(p)return()=>void i?.(!1)},[p,i]);let A=(0,E.useRef)(p);(0,E.useEffect)(()=>{A.current=p},[p]),(0,E.useEffect)(()=>{if(!t||!C||!mc()||typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(orientation: landscape)`),n=()=>{e.matches&&!A.current&&(m(!0),i?.(!0))};return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[t,C,i]),(0,E.useEffect)(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&(de(),p&&m(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,p,de]),(0,E.useEffect)(()=>{if(!p||!mc())return;window.history.pushState(window.history.state,``);let e=window.location.href,t=!1,n=()=>{t=!0,m(!1)};return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n),!t&&window.location.href===e&&window.history.back()}},[p]),(0,E.useEffect)(()=>{if(!p||typeof document>`u`)return;let e=()=>{document.fullscreenElement||mc()||m(!1)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[p]);let xe=()=>{e.leave(),n()};if(l.kind===`connecting`||l.kind===`asking`)return(0,B.jsxs)(`div`,{className:t?`rounded-[var(--radius-card)] bg-neutral-900 text-white`:`flex min-h-[100dvh] flex-col items-center justify-center gap-4 bg-black text-white`,children:[l.kind===`connecting`&&o&&a&&(0,B.jsx)(nc,{href:a}),(0,B.jsx)(gc,{text:l.kind===`connecting`?s(`join_connecting`,{host:d},`Connecting to ${d}…`):s(`join_waiting`,{host:d},`Waiting for ${d} to let you in`),body:l.kind===`asking`?s(`join_waiting_body`,{host:d},`${d} sees your name on their screen and taps Allow.`):void 0,onCancel:xe})]});if(l.kind===`refused`||l.kind===`ended`){let i=l.kind===`refused`||l.why!==`left`&&l.why!==`mismatch`;return(0,B.jsxs)(`div`,{className:t?`flex flex-col items-center gap-4 rounded-[var(--radius-card)] bg-neutral-900 px-6 py-10 text-center text-white`:`flex min-h-[100dvh] flex-col items-center justify-center gap-4 bg-black px-6 text-center text-white`,"data-testid":`join-ended`,"data-why":l.why,children:[(0,B.jsx)(Se,{size:28,className:`text-white/60`}),(0,B.jsx)(`p`,{className:`max-w-sm text-base`,"data-testid":`join-ended-text`,children:lc(s,l,d,e.opts.internet??!!e.opts.transport)}),a&&l.why===`no_hub`&&(0,B.jsx)(nc,{href:a}),(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[i&&(0,B.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-full bg-white px-4 py-2 text-sm font-medium text-black`,"data-testid":`join-again`,children:l.kind===`refused`&&l.why===`not_playing`?s(`join_retry`,void 0,`Try again`):s(`join_again`,void 0,`Ask to join again`)}),(0,B.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full bg-white/15 px-4 py-2 text-sm`,"data-testid":`join-done`,children:s(`join_done`,void 0,`Done`)})]})]})}let Ce=l.player,M=c.light??it(Ce),Te=c.rttMs??u?.rttMs??null,Ee=rt(Te),De=mc(),Oe=C&&!S&&!y.ready&&De&&(!t||p),ke=oc({player:Ce,guided:h,movedOff:T,reconnecting:S}),Ae=Ce===ac,je=u?.playsAs??null,Me=S?(l.deadline-ee)/1e3:0,Ne=async()=>{let e=!p;m(e),await i?.(e)},Pe=t&&!p&&De&&C,Ie=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 font-medium`,"data-testid":`join-player`,children:[(0,B.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-full`,style:{background:`rgb(${M[0]},${M[1]},${M[2]})`}}),t&&(0,B.jsxs)(`span`,{className:`text-white/80`,children:[s(`join_playing_at`,{host:d},`Playing at ${d}'s`),` · `]}),s(`join_you_are`,{n:Ce},`You are Player ${Ce}`)]}),Te!=null&&(0,B.jsxs)(`span`,{className:`rounded-full bg-black/60 px-2 py-1 tabular-nums`,style:{color:hc[Ee]},"data-testid":`join-delay`,"data-tone":Ee,"data-path":c.path??void 0,children:[c.path&&(0,B.jsxs)(`span`,{className:`text-white/80`,children:[sc(s,c.path),` · `]}),Math.round(Te),` ms`]}),Ae&&(0,B.jsx)(`span`,{className:`rounded-full bg-black/60 px-2.5 py-1 text-white/85`,"data-testid":`join-seat-stream`,children:s(`join_seat_stream`,{host:d},`You're playing as ${d}'s PS5 user. No need to pick one.`)}),je&&!Ae&&(0,B.jsx)(`span`,{className:`rounded-full bg-black/60 px-2.5 py-1 text-white/85`,"data-testid":`join-plays-as`,children:s(`join_plays_as`,{profile:je},`You're playing as ${je}. No need to pick one.`)}),w&&!Ae&&u?.seatNote&&(0,B.jsx)(`span`,{className:`rounded-full bg-black/60 px-2.5 py-1 text-white/85`,"data-testid":`join-seat-note`,children:s(`join_seat_tv_asks`,{host:d},`${d} chose a profile for you, but it couldn't be used. The TV will ask who you are.`)}),w&&!Ae&&(0,B.jsx)(`span`,{className:`rounded-full bg-white/90 px-2.5 py-1 font-medium text-black`,"data-testid":`join-picking`,children:s(`join_picking`,void 0,`Press PS, then pick Quick Play on the TV`)})]}),Le=(0,B.jsxs)(B.Fragment,{children:[D&&O&&ue.shown&&!S&&(0,B.jsxs)(`button`,{type:`button`,onClick:ue.hide,className:`flex items-center gap-1 rounded-full bg-white/15 px-2.5 py-1 font-medium`,"data-testid":`join-hide-controls`,children:[(0,B.jsx)(fe,{size:13}),s(`join_hide_controls`,void 0,`Hide`)]}),!c.sound&&(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.startSound(),className:`flex items-center gap-1 rounded-full bg-white/90 px-2.5 py-1 font-medium text-black`,"data-testid":`join-sound`,children:[(0,B.jsx)(we,{size:13}),s(`join_sound`,void 0,`Tap for sound`)]}),c.sound&&!c.noSound&&(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.setMuted(!c.muted),"aria-pressed":c.muted,className:`flex items-center gap-1 rounded-full bg-white/15 px-2.5 py-1 hover:bg-white/25`,"data-testid":`join-mute`,children:[c.muted?(0,B.jsx)(N,{size:13}):(0,B.jsx)(we,{size:13}),c.muted?s(`rp_unmute`,void 0,`Sound on`):s(`rp_mute`,void 0,`Mute`)]}),c.noSound&&(0,B.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-black/60 px-2.5 py-1 text-white/80`,"data-testid":`join-no-sound`,children:[(0,B.jsx)(N,{size:13}),s(`join_no_sound`,void 0,`No sound in this browser`)]}),(t||typeof document<`u`&&!!document.documentElement.requestFullscreen)&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>void Ne(),"aria-label":p?s(`join_exit_fullscreen`,void 0,`Leave full screen`):s(`pad_fill`,void 0,`Full screen`),className:`flex items-center gap-1 rounded-full bg-white/15 px-2.5 py-1 hover:bg-white/25`,"data-testid":`join-full`,children:p?(0,B.jsx)(be,{size:13}):(0,B.jsx)(k,{size:13})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>x(!0),"aria-label":s(`join_check_title`,void 0,`Check your controller`),title:s(`join_check_title`,void 0,`Check your controller`),className:`flex items-center gap-1 rounded-full bg-white/15 px-2.5 py-1 hover:bg-white/25`,"data-testid":`join-check-open`,children:(0,B.jsx)(me,{size:13})}),(0,B.jsxs)(`button`,{type:`button`,onClick:xe,className:`flex items-center gap-1 rounded-full bg-[var(--color-danger,#dc2626)] px-3 py-1 font-medium`,"data-testid":`join-leave`,children:[(0,B.jsx)(ge,{size:13}),s(`join_leave`,void 0,`Leave`)]})]}),Re=ue.shown?`opacity-100`:`pointer-events-none opacity-0`,ze={"data-testid":`join-bar`,"data-shown":ue.shown?`1`:`0`,onFocus:e=>{e.target.matches?.(`:focus-visible`)&&se(!0)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||se(!1)},onPointerEnter:e=>{e.pointerType===`mouse`&&ae(!0)},onPointerLeave:()=>ae(!1)};return(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`${p||!t?`fixed inset-0 z-[200] bg-black`:`relative mx-auto aspect-video w-full max-w-[max(20rem,calc((100dvh_-_22rem)*16/9))] overflow-hidden rounded-[var(--radius-card)] bg-black shadow-[var(--shadow-2)]`} select-none text-white [-webkit-touch-callout:none]`,style:{touchAction:`none`},onPointerMove:e=>{if(e.pointerType===`mouse`)return de();let t=pe.current;t&&t.id===e.pointerId&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>pc&&he()},onPointerDown:e=>{if(fc(e.target))return;if(e.pointerType===`mouse`||!O)return de();if(e.target.closest?.(`[data-testid="join-bar"], button, a, input, [role="button"]`))return;he();let{pointerId:t,clientX:n,clientY:r}=e;pe.current={id:t,x:n,y:r,timer:setTimeout(()=>{pe.current=null,navigator.vibrate?.(15),ue.toggle()},450)}},onPointerUp:he,onPointerCancel:he,onPointerLeave:he,"data-testid":`join-stage-view`,children:[(0,B.jsx)(`div`,{ref:f,className:`pointer-events-none absolute inset-0 z-0 flex items-center justify-center`,"aria-hidden":!0}),D&&!ue.shown&&!S&&Te!=null&&(0,B.jsxs)(`span`,{className:`pointer-events-none absolute z-10 rounded-full bg-black/40 px-1.5 py-0.5 text-[10px] leading-none tabular-nums`,style:{color:hc[Ee],top:`max(0.5rem, env(safe-area-inset-top))`,right:`max(0.5rem, env(safe-area-inset-right))`},"data-testid":`join-delay-corner`,children:[Math.round(Te),` ms`]}),Oe?(0,B.jsxs)(`div`,{className:`absolute left-1/2 top-1/2 z-20 flex w-max max-w-[min(24rem,calc(100%-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col items-center gap-2 rounded-2xl bg-black/70 p-3 text-xs backdrop-blur-sm transition-opacity duration-300 ${Re}`,...ze,children:[(0,B.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:Ie}),(0,B.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:Le})]}):Pe?null:(0,B.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-20 flex flex-wrap items-center gap-2 bg-gradient-to-b from-black/70 to-transparent px-3 pb-5 pt-[max(8px,env(safe-area-inset-top))] text-xs transition-opacity duration-300 ${Re}`,...ze,children:[Ie,(0,B.jsx)(`span`,{className:`flex-1`}),Le]}),!ue.shown&&!Oe&&(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),de()},"aria-label":s(`join_show_controls`,void 0,`Show controls`),className:`absolute left-1/2 top-[max(6px,env(safe-area-inset-top))] z-20 flex h-7 w-11 -translate-x-1/2 items-center justify-center rounded-full bg-black/40 text-white/70 opacity-60 hover:opacity-100 focus-visible:opacity-100`,"data-testid":`join-show-controls`,children:(0,B.jsx)(le,{size:16,"aria-hidden":!0})}),_e&&!ue.shown&&(0,B.jsx)(`p`,{className:`pointer-events-none absolute left-1/2 top-[max(10px,env(safe-area-inset-top))] z-20 -translate-x-1/2 rounded-full bg-black/60 px-3 py-1 text-xs text-white/85`,"data-testid":`join-hold-hint`,children:s(`join_hold_hint`,void 0,`Press and hold the picture to show the buttons`)}),c.problem&&(0,B.jsx)(`p`,{className:`absolute inset-x-4 top-1/2 z-10 -translate-y-1/2 text-center text-sm text-white/85`,"data-testid":`join-problem`,children:c.problem===`no_hevc`?s(`pad_watch_no_hevc`,void 0,`This device can't play this stream's picture: the computer streams HEVC, and this device plays only H.264.`):s(`pad_watch_decode`,void 0,`The picture could not be played here.`)}),b&&(0,B.jsx)(ec,{onClose:()=>x(!1)}),Oe&&(0,B.jsx)(os,{stream:e,layout:`overlay`,onMenu:()=>ue.shown?ue.hide():de()}),!Oe&&!S&&(0,B.jsxs)(`div`,{className:`absolute bottom-3 left-3 z-20 flex items-center gap-2 rounded-2xl bg-black/70 px-3 py-1.5 text-xs transition-opacity duration-300 ${Re}`,"data-testid":`join-pad`,children:[(0,B.jsx)(me,{size:14,style:{color:y.pressed?`rgb(${M[0]},${M[1]},${M[2]})`:void 0}}),y.ready?(0,B.jsxs)(`span`,{className:`flex flex-col items-start gap-1`,children:[(0,B.jsx)(`span`,{children:s(`join_pad_ready`,void 0,`Your controller is ready`)}),y.weak8BitDo&&y.id&&(0,B.jsx)(Wo,{id:y.id,className:`text-amber-200/90`}),y.kind===`guess`&&to()&&(0,B.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-white/75`,"data-testid":`join-pad-unknown`,children:[s(`join_check_unknown_short`,void 0,`Not on our list: buttons may be mixed up.`),(0,B.jsx)(`button`,{type:`button`,onClick:()=>x(!0),className:`rounded-full bg-white px-2.5 py-0.5 font-medium text-black`,"data-testid":`join-pad-unknown-check`,children:s(`join_check_title`,void 0,`Check your controller`)})]})]}):De&&t&&!p?s(`join_full_to_play`,void 0,`Tap full screen to play with the on-screen controller.`):(0,B.jsxs)(`span`,{className:`flex flex-col`,children:[(0,B.jsx)(`span`,{children:s(`join_pad_none`,void 0,`Connect a controller (USB or Bluetooth) and press any button.`)}),(0,B.jsx)(`span`,{className:`text-white/60`,"data-testid":`join-pad-keys`,children:s(`join_pad_keys`,void 0,`Or use the keyboard: WASD move, arrows D-pad, Enter ✕, Backspace ○, Q □, E △, Tab Options.`)})]})]}),u?.blockSystem&&u.state===`playing`&&!Oe&&(0,B.jsx)(`p`,{className:`absolute bottom-3 right-3 z-20 rounded-full bg-black/60 px-3 py-1 text-[11px] text-white/70 transition-opacity duration-300 ${Re}`,"data-testid":`join-blocked`,children:s(`join_block_note`,{host:d},`${d} turned off PS and Create for friends.`)}),ce&&!Ae&&O&&!ue.shown&&!S&&(0,B.jsx)(`p`,{className:`pointer-events-none absolute left-1/2 top-2 z-20 -translate-x-1/2 whitespace-nowrap rounded-full bg-white/90 px-2.5 py-1 text-xs font-medium text-black`,"data-testid":`join-picking-note`,children:s(`join_picking`,void 0,`Press PS, then pick Quick Play on the TV`)}),ke&&!je&&(0,B.jsxs)(`div`,{className:`absolute bottom-14 left-1/2 z-30 w-[min(22rem,calc(100%-2rem))] -translate-x-1/2 rounded-2xl border border-white/10 bg-neutral-900/90 p-4 text-sm shadow-2xl backdrop-blur-md`,"data-testid":`join-guide`,children:[(0,B.jsx)(`p`,{className:`font-semibold`,children:s(`join_guide_title`,void 0,`One more step on the TV`)}),(0,B.jsx)(`p`,{className:`mt-1 text-white/75`,children:s(`join_guide_body`,void 0,`On your controller, press PS once. The TV asks "Who's using this controller?". Pick Quick Play or your own user. The host doesn't need to do anything.`)}),(0,B.jsx)(`p`,{className:`mt-1 text-white/60`,children:s(`join_guide_menus`,void 0,`On the PS5's home screen only the host controls the menus; your controller plays inside games.`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{Ft(ic,`1`),g(!0),ne(!1)},className:`mt-3 rounded-full bg-white px-3 py-1 text-xs font-medium text-black`,"data-testid":`join-guide-ok`,children:s(`join_guide_ok`,void 0,`Got it`)})]}),S&&(0,B.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col items-center justify-center gap-3 bg-black/70 px-6 text-center`,"data-testid":`join-reconnecting`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:xe,className:`absolute right-3 top-[max(10px,env(safe-area-inset-top))] flex items-center gap-1 rounded-full bg-white/15 px-3 py-1.5 text-sm font-medium hover:bg-white/25`,"data-testid":`join-reconnecting-leave`,children:[(0,B.jsx)(ge,{size:14}),s(`join_leave`,void 0,`Leave`)]}),(0,B.jsx)(`span`,{className:`h-7 w-7 animate-spin rounded-full border-2 border-white/30 border-t-white`,"aria-hidden":!0}),l.hostStopped?(0,B.jsx)(`p`,{className:`max-w-sm text-base font-medium`,"data-testid":`join-host-away`,children:s(`join_host_away`,{time:rc(Me)},`The host stopped playing — waiting for them to start again (${rc(Me)})`)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-base font-medium`,children:s(`join_reconnecting`,void 0,`Reconnecting…`)}),(0,B.jsx)(`p`,{className:`text-sm text-white/70`,"data-testid":`join-reconnecting-left`,children:s(`join_reconnecting_left`,{time:rc(Me)},`Your place is kept for ${rc(Me)}.`)})]})]}),!t&&C&&_&&De&&(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-16 z-20 flex justify-center`,children:(0,B.jsxs)(`span`,{className:`flex items-center gap-2 rounded-full bg-black/70 px-3 py-1.5 text-xs text-white/85`,children:[(0,B.jsx)(j,{size:14}),s(`pad_turn`,void 0,`Turn the phone sideways`)]})})]}),Pe&&(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-[var(--radius-card)] bg-neutral-900 px-3 py-2 text-xs text-white`,"data-testid":`join-bar`,"data-shown":`1`,"data-below":`1`,children:[(0,B.jsx)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center gap-2`,children:Ie}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>void Ne(),className:`flex h-11 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full bg-white/15 px-3 text-sm font-medium hover:bg-white/25`,"data-testid":`join-fullscreen-below`,children:[(0,B.jsx)(k,{size:15}),s(`pad_fill`,void 0,`Full screen`)]}),c.sound&&!c.noSound?(0,B.jsx)(`button`,{type:`button`,onClick:()=>e.setMuted(!c.muted),"aria-pressed":c.muted,"aria-label":c.muted?s(`rp_unmute`,void 0,`Sound on`):s(`rp_mute`,void 0,`Mute`),className:`flex h-11 w-11 items-center justify-center rounded-full bg-white/15 hover:bg-white/25`,children:c.muted?(0,B.jsx)(N,{size:16}):(0,B.jsx)(we,{size:16})}):c.sound?null:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.startSound(),className:`flex h-11 items-center justify-center gap-1.5 rounded-full bg-white px-3 text-sm font-medium text-black`,children:[(0,B.jsx)(we,{size:15}),s(`join_sound`,void 0,`Tap for sound`)]}),(0,B.jsxs)(`button`,{type:`button`,onClick:xe,className:`flex h-11 items-center justify-center gap-1.5 rounded-full bg-[var(--color-danger,#dc2626)] px-4 text-sm font-medium`,"data-testid":`join-leave-below`,children:[(0,B.jsx)(ge,{size:15}),s(`join_leave`,void 0,`Leave`)]})]})]})}var vc=`ps5upload.join.name`;function yc(e){return/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:``}function bc(e){return e.trim().slice(0,32)}function xc(e=``){return bc(It(`ps5upload.join.name`)??``)||e}function Sc(e){let t=bc(e);return t&&Ft(vc,t),t}function Cc(e){try{return!!sessionStorage.getItem(Lo(e))}catch{return!1}}async function wc(e){try{e?(await document.documentElement.requestFullscreen?.({navigationUI:`hide`}),await screen.orientation.lock?.(`landscape`)):document.fullscreenElement&&await document.exitFullscreen()}catch{}}function Tc({url:e,invite:t,host:n,transport:r,lanUrl:i=null,path:a=null,internet:o}){let s=Fe(),c=tc(r&&o!==!1?e:null,i),[l,u]=(0,E.useState)(()=>xc(yc(typeof navigator>`u`?``:navigator.userAgent))),[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)(0),h=i=>{let s=Sc(i);if(!s)return;let c=new zs({url:e,invite:t,name:s,host:n,transport:r,path:a,...o===void 0?{}:{internet:o}});f(c),m(e=>e+1),c.start()};if((0,E.useEffect)(()=>{!d&&Cc(t)&&l.trim()&&h(l)},[]),(0,E.useEffect)(()=>d?Hs(d):void 0,[d]),(0,E.useEffect)(()=>{if(!d)return;let e=()=>d.stop();return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[d]),d)return(0,B.jsx)(_c,{session:d,lanUrl:i,hubDown:c,onLeave:()=>f(null),onAgain:()=>{d.stop(),h(l)},onFullscreen:wc},p);let g=n??s(`join_host_fallback`,void 0,`your friend`),_=(0,B.jsx)(`div`,{className:`flex min-h-[100dvh] items-center justify-center bg-black px-6 text-white`,"data-testid":`join-name-step`,children:(0,B.jsxs)(`form`,{className:`w-full max-w-sm space-y-4 rounded-2xl border border-white/10 bg-neutral-900 p-6`,onSubmit:e=>{e.preventDefault(),h(l)},children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-white/10`,children:(0,B.jsx)(Se,{size:20})}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:s(`join_title`,void 0,`Join a friend's game`)}),(0,B.jsx)(`p`,{className:`text-sm text-white/60`,children:s(`join_title_body`,{host:g},`Play on ${g}'s PS5 as Player 2, 3 or 4.`)})]})]}),(0,B.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium`,children:s(`join_name_label`,void 0,`Your name`)}),(0,B.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),maxLength:32,autoComplete:`nickname`,className:`block w-full rounded-lg border border-white/15 bg-black px-3 py-2 text-base outline-none focus:border-white/50`,"data-testid":`join-name`}),(0,B.jsx)(`span`,{className:`block text-xs text-white/50`,children:s(`join_name_hint`,void 0,`Your friend sees this when you ask to join.`)})]}),(0,B.jsx)(`button`,{type:`submit`,disabled:!l.trim(),className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black disabled:opacity-40`,"data-testid":`join-go`,children:s(`join_button`,void 0,`Join`)}),c&&i&&(0,B.jsx)(nc,{href:i})]})});return t?(0,B.jsx)(Uo,{appLink:nt(location.href),children:_}):_}function Ec(e){let t=(e??``).trim().replace(/^\[|\]$/g,``).toLowerCase(),n=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(t);if(n){let e=n.slice(1).map(Number);if(e.some(e=>e>255))return null;let[t,r]=e;return t===10||t===172&&r>=16&&r<32||t===192&&r===168||t===169&&r===254||t===127?0:t===100&&r>=64&&r<128?1:2}if(!t.includes(`:`)||!/^[0-9a-f:.]+$/.test(t))return null;if(t.startsWith(`fd7a:115c:a1e0:`))return 1;let r=parseInt(t.split(`:`)[0]||`0`,16);return(r&65024)==64512||(r&65472)==65152||t===`::1`?0:2}function Dc(e,t){let n=Ec(e),r=Ec(t);return n===1||r===1?`tailscale`:r===0?`lan`:r===2?`internet`:null}function Oc(e){let t=(e??``).toLowerCase();if(t.endsWith(`.local`))return`lan`;if(t.endsWith(`.ts.net`))return`tailscale`;let n=Ec(t);return n===0?`lan`:n===1?`tailscale`:null}function kc(e){let t=[];if(typeof e.forEach==`function`)e.forEach(e=>t.push(e));else for(let n of e)t.push(n);let n=new Map(t.map(e=>[String(e.id),e])),r=t.filter(e=>e.type===`candidate-pair`),i=t.filter(e=>e.type===`transport`&&typeof e.selectedCandidatePairId==`string`).map(e=>n.get(String(e.selectedCandidatePairId))).find(Boolean)??r.find(e=>e.selected===!0)??r.find(e=>e.nominated===!0&&e.state===`succeeded`);if(!i)return null;let a=e=>{let t=n.get(String(e));if(!t)return null;let r=t.address??t.ip;return typeof r==`string`?r:null};return Dc(a(i.localCandidateId),a(i.remoteCandidateId))}function Ac(e){let t=e.replace(/:\d+$/,``).replace(/^\[|\]$/g,``);return`${t===`localhost`||t===`127.0.0.1`||t===`::1`?`ws`:`wss`}://${e}/ws`}function jc(e){let t=new Set;for(let n of e.matchAll(/^a=fingerprint:sha-256[ \t]+([0-9A-Fa-f:]+)[ \t]*\r?$/gim))t.add(n[1].toUpperCase());return/^a=fingerprint:(?!sha-256[ \t])/im.test(e)?null:t.size===1?[...t][0]:null}function Mc(e,t){let n=jc(e);return n!==null&&n===t.toUpperCase()}var Nc=16777216;function Pc(e){let t=16383,n=Math.max(1,Math.ceil(e.length/t)),r=[];for(let i=0;ithis.max)return this.parts=[],this.size=0,{kind:`error`,why:`too_big`};if(this.parts.push(r.slice()),this.size+=r.length,n===1)return{kind:`partial`};let i=new Uint8Array(this.size),a=0;for(let e of this.parts)i.set(e,a),a+=e.length;return this.parts=[],this.size=0,{kind:`message`,data:i.buffer}}};function Ic(e){let t=new Uint8Array(9);return t[0]=3,t.set(e.subarray(0,8),1),t}var Lc=[`stun:stun.cloudflare.com:3478`,`stun:stun.l.google.com:19302`],Rc=1500,zc=2e4;function Bc(e){let t=e?.codecs??[],n=e=>t.filter(t=>t.mimeType.toLowerCase()===e);return[...n(`video/h264`),...n(`video/h265`),...n(`video/rtx`)]}var Vc=null;function Hc(e){e.onopen=e.onmessage=e.onclose=e.onerror=null;try{e.readyState===1&&e.send(JSON.stringify({t:`leave`})),e.close(1e3)}catch{}}function Uc(e,t={}){let n=t.WebSocketImpl??(typeof WebSocket>`u`?void 0:WebSocket);if(!n||Vc)return;let r=Ac(e.hub),i;try{i=new n(r)}catch{return}let a={url:r,room:e.room,ws:i,msgs:[],timer:null};Vc=a;let o=()=>{Vc===a&&(Vc=null,a.timer&&clearTimeout(a.timer),Hc(i))};i.onopen=()=>i.send(JSON.stringify({v:1,t:`join`,room:e.room})),i.onmessage=e=>{if(typeof e.data==`string`)try{a.msgs.push(JSON.parse(e.data))}catch{}},i.onclose=o,i.onerror=()=>{},a.timer=setTimeout(o,t.keepMs??6e4)}function Wc(e,t){let n=Vc;return n?(Vc=null,n.timer&&clearTimeout(n.timer),n.url!==e||n.room!==t||n.ws.readyState>1||n.msgs.some(e=>e.t===`error`||e.t===`closed`)?(Hc(n.ws),null):{ws:n.ws,msgs:n.msgs}):null}function Gc(e,t={}){var n;let r=t.WebSocketImpl??(typeof WebSocket>`u`?void 0:WebSocket),i=t.PeerConnection??(typeof RTCPeerConnection>`u`?void 0:RTCPeerConnection),a=t.iceTimeoutMs??15e3,o=t.log??(()=>{});class s{constructor(e){this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this.readyState=0,this.binaryType=`arraybuffer`,this.onopen=null,this.onmessage=null,this.onclose=null,this.onerror=null,this.hub=null,this.pc=null,this.dc=null,this.timer=null,this.rx=new Fc,this.answered=!1,this.early=[],this.hubBackUntil=0,this.offerSdp=null,this.offerSent=!1,this.ownEarly=[],this.media=null,setTimeout(()=>this.begin(),0)}begin(){if(this.readyState!==0)return;if(!i||!r){this.fail(`no_webrtc`);return}let n=t.signalUrl??Ac(e.hub),a=t.signalUrl||t.lan?null:Wc(n,e.room),s;if(a)s=a.ws,o(`hub: joined early`);else try{s=new r(n)}catch{this.fail(`no_hub`);return}if(this.hub=s,this.prepare(),this.readyState===0){s.onopen=()=>s.send(JSON.stringify(t.lan?{v:1,t:`join`,lan:!0}:{v:1,t:`join`,room:e.room})),s.onmessage=e=>{if(typeof e.data!=`string`)return;let t;try{t=JSON.parse(e.data)}catch{return}this.onHub(t)},s.onclose=e=>{this.hub===s&&(this.hub=null,this.readyState===0&&(this.answered||e?.code===1001&&this.hubRestarting()||this.fail(`no_hub`)))},s.onerror=()=>{};for(let e of a?.msgs??[])this.onHub(e)}}signal(e){let t=this.hub;t&&t.readyState===1&&t.send(JSON.stringify({t:`signal`,to:`host`,data:e}))}onHub(e){if(this.readyState===0)switch(e.t){case`joined`:o(`hub: joined room as ${e.gid??`?`}`),this.sendOffer();return;case`signal`:e.from===`host`&&e.data&&typeof e.data==`object`&&this.onSignal(e.data);return;case`closed`:this.fail(`no_room`);return;case`error`:if(o(`hub: error ${e.why??`?`}`),e.why===`no_room`&&this.hubBackUntil&&this.hubRestarting())return;this.fail(e.why===`no_room`?`no_room`:e.why===`room_full`?`net_full`:`no_hub`);return}}prepare(){if(!i)return;this.offerSent=!1,this.ownEarly=[];let e;try{e=new i({iceServers:[{urls:Lc}]})}catch{this.fail(`no_webrtc`);return}this.pc=e;let n=e.createDataChannel(t.label??`join`,{ordered:!0});if(n.binaryType=`arraybuffer`,this.dc=n,n.onopen=()=>this.opened(n),n.onmessage=e=>this.fromChannel(e.data),n.onclose=()=>{this.dc===n&&this.dropped()},t.video&&e.addTransceiver){try{let t=e.addTransceiver(`video`,{direction:`recvonly`}),n=Bc(globalThis.RTCRtpReceiver?.getCapabilities?.(`video`));n.length&&t.setCodecPreferences&&t.setCodecPreferences(n)}catch{}try{e.addTransceiver(`audio`,{direction:`recvonly`})}catch{}e.ontrack=t=>{if(this.pc!==e)return;let n=this.media?.stream??t.streams[0]??new MediaStream;n.getTracks().includes(t.track)||n.addTrack(t.track),this.media=t.track.kind===`audio`?{stream:n,receiver:this.media?.receiver??t.receiver,audio:t.receiver}:{stream:n,receiver:t.receiver,...this.media?.audio?{audio:this.media.audio}:{}}}}e.onicecandidate=t=>{if(this.pc!==e)return;let n=t.candidate;if(!n||!n.candidate)return;let r={type:`candidate`,candidate:n.candidate,sdpMid:n.sdpMid??`0`};this.offerSent?this.signal(r):this.ownEarly.push(r)},e.oniceconnectionstatechange=()=>{if(this.pc!==e)return;let t=e.iceConnectionState;o(`ice: ${t}`),t===`failed`&&(this.readyState===0?this.fail(`no_direct`):this.dropped())},this.offerSdp=(async()=>{let t=await e.createOffer();return await e.setLocalDescription(t),e.localDescription?.sdp??t.sdp??``})().catch(()=>(this.pc===e&&this.fail(`no_webrtc`),null))}async sendOffer(){let e=this.pc,t=this.offerSdp;if(!e||!t||this.offerSent)return;this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.readyState===0&&this.fail(`no_direct`)},a);let n=await t;if(this.pc===e&&n!==null&&this.readyState===0){this.signal({type:`offer`,sdp:n}),this.offerSent=!0;for(let e of this.ownEarly.splice(0))this.signal(e)}}async onSignal(t){let n=this.pc;if(t.type===`bye`)this.fail(t.why===`full`?`net_full`:`offer`);else if(n){if(t.type===`answer`){if(this.answered||typeof t.sdp!=`string`)return;if(e.fp?!Mc(t.sdp,e.fp):jc(t.sdp)===null){o(`answer: fingerprint does not match the link`),this.fail(`mismatch`);return}this.answered=!0;try{await n.setRemoteDescription({type:`answer`,sdp:t.sdp});for(let e of this.early.splice(0))await n.addIceCandidate(e).catch(()=>{})}catch{this.fail(`offer`)}}else if(t.type===`candidate`&&typeof t.candidate==`string`&&t.candidate){let e={candidate:t.candidate,sdpMid:typeof t.sdpMid==`string`?t.sdpMid:`0`,sdpMLineIndex:typeof t.sdpMLineIndex==`number`?t.sdpMLineIndex:0};this.answered?await n.addIceCandidate(e).catch(()=>{}):this.early.push(e)}}}opened(e){this.dc===e&&this.readyState===0&&(this.clearTimer(),this.readyState=1,o(`channel open`),this.leaveHub(),this.onopen?.(new Event(`open`)))}fromChannel(e){if(this.readyState!==1)return;if(typeof e==`string`){this.onmessage?.(new MessageEvent(`message`,{data:e}));return}if(!(e instanceof ArrayBuffer))return;let t=this.rx.push(e);switch(t.kind){case`ping`:try{this.dc?.send(Ic(t.data))}catch{}return;case`message`:this.onmessage?.(new MessageEvent(`message`,{data:t.data}));return;case`error`:o(`channel: bad binary message (${t.why})`),this.dropped();return;default:return}}async netPath(){let e=this.pc;if(!e||this.readyState!==1||typeof e.getStats!=`function`)return null;try{return kc(await e.getStats())}catch{return null}}send(e){let t=this.dc;if(this.readyState!==1||!t||t.readyState!==`open`)throw Error(`not open`);if(typeof e==`string`){t.send(e);return}let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e);for(let e of Pc(n))t.send(e)}close(){this.readyState!==3&&(this.teardown(),this.emitClose(1e3,``,!0))}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}leaveHub(){let e=this.hub;if(this.hub=null,e)try{e.readyState===1&&e.send(JSON.stringify({t:`leave`})),e.close(1e3)}catch{}}hubRestarting(){let e=Date.now();return this.hubBackUntil||=e+zc,e>=this.hubBackUntil?!1:(o(`hub: restarting, trying again`),this.clearTimer(),this.leaveHub(),this.closePeer(),this.answered=!1,this.early=[],this.timer=setTimeout(()=>{this.timer=null,this.begin()},Rc),!0)}teardown(){this.readyState=3,this.clearTimer(),this.leaveHub(),this.closePeer()}closePeer(){let e=this.pc,t=this.dc;this.pc=null,this.dc=null,this.media=null,this.offerSdp=null,this.offerSent=!1,this.ownEarly=[];try{t?.close()}catch{}try{e?.close()}catch{}}dropped(){this.readyState!==3&&(this.teardown(),this.emitClose(1006,``,!1))}fail(e){this.readyState!==3&&(o(`failed: ${e}`),this.teardown(),this.emitClose(Ve,`net:${e}`,!1))}emitClose(e,t,n){let r=this.onclose;if(!r)return;let i=typeof CloseEvent>`u`?{type:`close`,code:e,reason:t,wasClean:n}:new CloseEvent(`close`,{code:e,reason:t,wasClean:n});setTimeout(()=>r(i),0)}}return n=s,n.CONNECTING=0,n.OPEN=1,n.CLOSING=2,n.CLOSED=3,s}var Kc=3e3;function qc(e,t){return/^https?:\/\/[^/?#]+(\/[^?#]*)?\/join\/?$/.test(e)?e.replace(/^http/,`ws`).replace(/\/join\/?$/,`/${t}`):null}var Jc=e=>qc(e,`api/join/signal`);function Yc(e){let t=[];if(e.rtc){let n=e.net??{room:``,key:``,fp:e.fp??``,hub:``};for(let[r,i]of[[`lan`,e.lan],[`tailscale`,e.ts]]){let a=i?Jc(i):null;if(!a)continue;let o=e.rtcMake(n,{signalUrl:e.reach(a),...e.net?{}:{lan:!0}});t.push({via:r,make:()=>new o(``),pinned:!!n.fp})}if(e.net){let n=e.rtcMake(e.net,{});t.push({via:`hub`,make:()=>new n(``),pinned:!0})}}let n=e.lan?qc(e.lan,`api/join/ws`):null;if(n){let r=e.reach(n);t.push({via:`socket`,make:()=>e.socket(r)})}return t}var Xc=new Map;function Zc(e,t,n=300,r=Kc){let i=e.some(e=>e===`lan`||e===`tailscale`),a=e.some(e=>e!==`socket`);return e.map(e=>e===t?0:e===`hub`&&i?n:e===`socket`&&a?r:0)}function Qc(e){let t=e.find(e=>e.via===`hub`),n=e.find(e=>(e.via===`lan`||e.via===`tailscale`)&&[`no_direct`,`net_full`,`offer`].includes(He(e.e)??``));return t&&(He(t.e)!==`no_hub`||!n)?t.e:n?n.e:t?.e??e[e.length-1]?.e??null}function $c(e,t){var n;let r=t.log??(()=>{}),i=t.headStartMs??300,a=t.socketAfterMs??3e3;class o{constructor(e){this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this.readyState=0,this.binaryType=`arraybuffer`,this.onopen=null,this.onmessage=null,this.onclose=null,this.onerror=null,this.live=[],this.waiting=[],this.pinned=new Set,this.t0=0,this.closes=[],this.winner=null,setTimeout(()=>this.begin(),0)}get via(){return this.winner?.via??null}get media(){return this.winner?.s?.media??null}async netPath(){let e=this.winner?.s;return e?.netPath?e.netPath():null}begin(){if(this.readyState!==0)return;let n=e();if(!n.length){this.end({type:`close`,code:1006,reason:``,wasClean:!1});return}this.t0=Date.now();for(let e of n)e.pinned&&this.pinned.add(e.via);let r=Zc(n.map(e=>e.via),Xc.get(t.room)??null,i,a);n.forEach((e,t)=>{r[t]===0?this.launch(e.via,e.make):this.waiting.push({via:e.via,make:e.make,timer:setTimeout(()=>this.startWaiting(e.via),r[t])})})}startWaiting(e){let t=this.waiting.findIndex(t=>t.via===e);if(t<0)return;let[n]=this.waiting.splice(t,1);clearTimeout(n.timer),this.launch(n.via,n.make)}launch(e,t){if(this.readyState!==0)return;let n;try{n=t()}catch{this.tryClosed(e,{type:`close`,code:1006,reason:``,wasClean:!1});return}r(`path: trying ${e}`);let i={via:e,s:n};this.live.push(i),n.binaryType=this.binaryType,n.onopen=e=>this.won(i,e),n.onclose=t=>{this.live=this.live.filter(e=>e!==i),this.tryClosed(e,t)},n.onerror=()=>{},n.onmessage=null}tryClosed(e,t){if(this.readyState===0){if(r(`path: ${e} failed after ${Date.now()-this.t0} ms${t?.reason?` (${t.reason})`:``}`),this.closes.push({via:e,e:t}),this.pinned.has(e)&&He(t)===`mismatch`){for(let e of this.waiting.filter(e=>e.via===`socket`))clearTimeout(e.timer);this.waiting=this.waiting.filter(e=>e.via!==`socket`)}!this.live.length&&this.waiting.length?this.startWaiting(this.waiting[0].via):!this.live.length&&!this.waiting.length&&this.end(Qc(this.closes))}}won(e,n){if(this.readyState!==0)return;this.winner=e,Xc.set(t.room,e.via),r(`path: playing by ${e.via} after ${Date.now()-this.t0} ms`);for(let e of this.waiting.splice(0))clearTimeout(e.timer);for(let t of this.live.splice(0))if(t!==e){t.s.onopen=t.s.onclose=t.s.onmessage=t.s.onerror=null;try{t.s.close()}catch{}}let i=e.s;i.onmessage=e=>this.onmessage?.(e),i.onerror=e=>this.onerror?.(e),i.onclose=e=>{this.readyState!==3&&(this.readyState=3,this.onclose?.(e))},this.readyState=1,t.onWin?.(e.via),this.onopen?.(n)}send(e){if(this.readyState!==1||!this.winner)throw Error(`not open`);this.winner.s.send(e)}close(e,t){if(this.readyState===3)return;let n=this.readyState===1;this.readyState=3;for(let e of this.waiting.splice(0))clearTimeout(e.timer);let r=this.winner?[this.winner,...this.live]:this.live.splice(0);for(let n of r){n.s.onopen=n.s.onclose=n.s.onmessage=n.s.onerror=null;try{n.s.close(e,t)}catch{}}let i=this.onclose;if(i){let r={type:`close`,code:e??1e3,reason:t??``,wasClean:n};setTimeout(()=>i(r),0)}}end(e){if(this.readyState===3)return;this.readyState=3;let t=this.onclose,n=e??{type:`close`,code:1006,reason:``,wasClean:!1};t&&setTimeout(()=>t(n),0)}}return n=o,n.CONNECTING=0,n.OPEN=1,n.CLOSING=2,n.CLOSED=3,o}var el=new URLSearchParams(location.hash.slice(1)),tl=el.get(`n`)?.trim()||null,nl=tt(location.hash);nl&&Uc(nl);var rl=(0,x.createRoot)(document.getElementById(`root`));if(nl){let e=Gc(nl,{video:!0,log:e=>console.info(`[join] ${e}`)}),t=Le(location.hash,`join`);rl.render((0,B.jsx)(Tc,{url:Ac(nl.hub),invite:nl.key,host:tl,transport:e,lanUrl:t?Re(t,{key:nl.key}):null}))}else{let e=el.get(`i`)||null,t=location.pathname.replace(/\/join\/?$/,``),n=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}${t}/api/join/ws`,r=e=>console.info(`[join] ${e}`),i=`${location.origin}${t}/join`,a=typeof RTCPeerConnection>`u`?void 0:$c(()=>Yc({net:null,lan:i,ts:null,fp:et(el.get(`fp`)),rtc:!0,reach:e=>e,rtcMake:(e,t)=>Gc(e,{video:!0,log:r,...t}),socket:e=>new WebSocket(e)}),{room:i,log:r});rl.render((0,B.jsx)(Tc,{url:n,invite:e,host:tl,path:Oc(location.hostname),transport:a,internet:!1}))} diff --git a/engine/crates/ps5upload-engine/src/pad_page.html b/engine/crates/ps5upload-engine/src/pad_page.html index 51c8b4785..d9893367e 100644 --- a/engine/crates/ps5upload-engine/src/pad_page.html +++ b/engine/crates/ps5upload-engine/src/pad_page.html @@ -8,15 +8,15 @@ PS5Upload controller - +I€wu¸öôú!3å6³‹âVq£³¹´RN£%y10º:pŠ#\:J:b9Hµ7h_Ž:¢I9 _¼™µV,þ <`});var w={a:v};this.setModule=t=>{e.setModule(fi,t)},this.getModule=()=>e.getModule(fi),this.instantiate=()=>(this.getModule().then(e=>WebAssembly.instantiate(e,w)).then(e=>{let t=e.exports;y(t),a=t.g,o(),ne(t),n()}),this.ready=new Promise(e=>{n=e}).then(()=>{this.HEAP=a.buffer,this.malloc=x,this.free=te,this.opus_frame_decoder_create=b,this.opus_frame_decode_float_deinterleaved=S,this.opus_frame_decoder_destroy=ee}),this)}var pi=o((()=>{}));function mi(e={}){mi.errors||Object.defineProperties(mi,{errors:{value:new Map([[-1,`OPUS_BAD_ARG: One or more invalid/out of range arguments`],[-2,`OPUS_BUFFER_TOO_SMALL: Not enough bytes allocated in the buffer`],[-3,`OPUS_INTERNAL_ERROR: An internal error was detected`],[-4,`OPUS_INVALID_PACKET: The compressed data passed is corrupted`],[-5,`OPUS_UNIMPLEMENTED: Invalid/unsupported request number`],[-6,`OPUS_INVALID_STATE: An encoder or decoder structure is invalid or already freed`],[-7,`OPUS_ALLOC_FAIL: Memory allocation has failed`]])}}),this._init=()=>new this._WASMAudioDecoderCommon(this).instantiate(this._EmscriptenWASM,this._module).then(e=>{this._common=e,this._inputBytes=0,this._outputSamples=0,this._frameNumber=0,this._input=this._common.allocateTypedArray(this._inputSize,Uint8Array),this._output=this._common.allocateTypedArray(this._outputChannels*this._outputChannelSize,Float32Array);let t=this._common.allocateTypedArray(this._channels,Uint8Array);t.buf.set(this._channelMappingTable),this._decoder=this._common.wasm.opus_frame_decoder_create(this._sampleRate,this._channels,this._streamCount,this._coupledStreamCount,t.ptr,this._preSkip,this._forceStereo)}),Object.defineProperty(this,"ready",{enumerable:!0,get:()=>this._ready}),this.reset=()=>(this.free(),this._init()),this.free=()=>{this._common.free(),this._common.wasm.opus_frame_decoder_destroy(this._decoder),this._common.wasm.free(this._decoder)},this._decode=e=>{if(!(e instanceof Uint8Array))throw Error(`Data to decode must be Uint8Array. Instead got `+typeof e);this._input.buf.set(e);let t=this._common.wasm.opus_frame_decode_float_deinterleaved(this._decoder,this._input.ptr,e.length,this._output.ptr),n;return t<0&&(n=`libopus `+t+` `+(mi.errors.get(t)||`Unknown Error`),console.error(n),t=0),{outputBuffer:this._common.getOutputChannels(this._output.buf,this._outputChannels,t),samplesDecoded:t,error:n}},this.decodeFrame=e=>{let t=[],n=this._decode(e);return n.error&&this._common.addError(t,n.error,e.length,this._frameNumber,this._inputBytes,this._outputSamples),this._frameNumber++,this._inputBytes+=e.length,this._outputSamples+=n.samplesDecoded,this._WASMAudioDecoderCommon.getDecodedAudioMultiChannel(t,[n.outputBuffer],this._outputChannels,n.samplesDecoded,this._sampleRate)},this.decodeFrames=e=>{let t=[],n=[],r=0,i=0;for(;itypeof e==`number`,n=e.sampleRate,r=e.channels,i=e.streamCount,a=e.coupledStreamCount,o=e.channelMappingTable,s=e.preSkip,c=+!!e.forceStereo;if(r>2&&(!t(i)||!t(a)||!Array.isArray(o)))throw Error(`Invalid Opus Decoder Options for multichannel decoding.`);return this._sampleRate=[8e3,12e3,16e3,24e3,48e3].includes(n)?n:48e3,this._channels=t(r)?r:2,this._streamCount=t(i)?i:1,this._coupledStreamCount=t(a)?a:this._channels-1,this._channelMappingTable=o||(this._channels===2?[0,1]:[0]),this._preSkip=s||0,this._forceStereo=r<=8&&r!=2?c:0,this._inputSize=3840*this._channels,this._outputChannelSize=5760,this._outputChannels=this._forceStereo?2:this._channels,this._ready=this._init(),this}var hi=o((()=>{di(),pi()})),gi,_i=o((()=>{di(),pi(),hi(),gi=class extends si{constructor(e){super(e,`opus-decoder`,mi,fi)}async decodeFrame(e){return this.postToDecoder(`decodeFrame`,e)}async decodeFrames(e){return this.postToDecoder(`decodeFrames`,e)}}})),vi=c({OpusDecoder:()=>mi,OpusDecoderWebWorker:()=>gi}),yi=o((()=>{hi(),_i(),di(),li(mi,`OpusDecoder`),li(gi,`OpusDecoderWebWorker`)})),bi=[8e3,12e3,16e3,24e3,48e3],xi=null;function Si(){return xi??=Vn(()=>Promise.resolve().then(()=>(yi(),vi)),__VITE_PRELOAD__,import.meta.url).catch(e=>{throw xi=null,e}),xi}function Ci(){return typeof WebAssembly==`object`&&typeof WebAssembly.instantiate==`function`}function wi(e,t,n,r){return{numberOfFrames:t,numberOfChannels:e.length,sampleRate:n,timestamp:r,format:`f32-planar`,duration:Math.round(t/n*1e6),copyTo(n,r){n.set(e[r.planeIndex].subarray(0,t))},close(){}}}var Ti=class{constructor(e,t=Si){this.init=e,this.load=t,this.state=`unconfigured`,this.dec=null,this.pending=[]}configure(e){if(this.state===`closed`)throw Error(`the decoder is closed`);if(!Ci())throw Error(`no WebAssembly here`);let t=e.sampleRate;if(!bi.includes(t))throw Error(`Opus does not decode at ${t} Hz`);let n=e.numberOfChannels;if(n<1||n>2)throw Error(`${n} channels: only mono and stereo are decoded`);this.state=`configured`,this.load().then(async e=>{if(this.state===`closed`)return;let r=new e.OpusDecoder({channels:n,sampleRate:t});if(await r.ready,this.state!==`configured`){r.free();return}this.dec=r;let i=this.pending;this.pending=[];for(let e of i)this.state===`configured`&&this.run(e)}).catch(e=>this.fail(e))}decode(e){if(this.state!==`configured`)return;let t=e;if(this.dec)return this.run(t);this.pending.push({timestamp:t.timestamp,data:t.data.slice()}),this.pending.length>50&&this.pending.shift()}run(e){let t=this.dec;if(!t)return;let n;try{n=t.decodeFrame(e.data)}catch(e){return this.fail(e)}n.samplesDecoded&&n.channelData.length&&this.init.output(wi(n.channelData,n.samplesDecoded,n.sampleRate,e.timestamp))}fail(e){if(this.state===`closed`)return;this.close();let t=e instanceof Error?e:Error(String(e));queueMicrotask(()=>this.init.error(t))}close(){this.state=`closed`,this.pending=[];let e=this.dec;this.dec=null;try{e?.free()}catch{}}},Ei={makeDecoder:e=>new Ti(e),makeChunk:e=>({type:e.type,timestamp:e.timestamp,data:e.data instanceof Uint8Array?e.data:new Uint8Array(e.data)})};function Di(e,t){for(let n=0;n+3>1&63;if(t>=16&&t<=21)return!0;if(t<16)return!1}else{let t=e[n+3]&31;if(t===5)return!0;if(t===1)return!1}}return!1}function Oi(e){for(let t=0;t+6e.toString(16).padStart(2,`0`);return`avc1.${n(e[t+4])}${n(e[t+5])}${n(e[t+6])}`}return`avc1.4d4028`}var ki=[`hev1.1.6.L153.B0`,`hvc1.1.6.L153.B0`,`hev1.2.4.L153.B0`,`hvc1.2.4.L153.B0`,`hev1.1.6.L150.90`];async function Ai(e,t){if(typeof VideoDecoder>`u`)return null;for(let n of ki)try{if((await VideoDecoder.isConfigSupported({codec:n,codedWidth:e,codedHeight:t})).supported)return n}catch{}return null}function ji(e){let t=[];for(let n=0;n+2{let i=r+1n&&e[i-1]===0;)i--;return e.subarray(n,i)}).filter(e=>e.length>0)}var Mi=(e,t)=>t?e[0]>>1&63:e[0]&31;function j(e,...t){let n=8+t.reduce((e,t)=>e+t.length,0),r=new Uint8Array(n);new DataView(r.buffer).setUint32(0,n);for(let t=0;t<4;t++)r[4+t]=e.charCodeAt(t);let i=8;for(let e of t)r.set(e,i),i+=e.length;return r}function M(...e){let t=new Uint8Array(e.reduce((e,[,t])=>e+t,0)),n=0;for(let[r,i]of e){for(let e=i-1;e>=0;e--)t[n+i-1-e]=Math.floor(r/2**(8*e))&255;n+=i}return t}var Ni=(e,t,n,...r)=>j(e,M([t,1],[n,3]),...r),Pi=M([65536,4],[0,4],[0,4],[0,4],[65536,4],[0,4],[0,4],[0,4],[1073741824,4]);function Fi(e){let t=e.handler===`vide`,n=j(`ftyp`,new TextEncoder().encode(`isom`),M([1,4]),new TextEncoder().encode(`isomiso6mp41`)),r=j(`moov`,Ni(`mvhd`,0,0,M([0,4],[0,4],[e.timescale,4],[0,4],[65536,4],[256,2],[0,2],[0,4],[0,4]),Pi,new Uint8Array(24),M([2,4])),j(`trak`,Ni(`tkhd`,0,3,M([0,4],[0,4],[1,4],[0,4],[0,4],[0,4],[0,4],[0,2],[0,2],[t?0:256,2],[0,2]),Pi,M([(e.width??0)*65536,4],[(e.height??0)*65536,4])),j(`mdia`,Ni(`mdhd`,0,0,M([0,4],[0,4],[e.timescale,4],[0,4],[21956,2],[0,2])),Ni(`hdlr`,0,0,M([0,4]),new TextEncoder().encode(e.handler),new Uint8Array(12),M([0,1])),j(`minf`,t?Ni(`vmhd`,0,1,new Uint8Array(8)):Ni(`smhd`,0,0,M([0,4])),j(`dinf`,Ni(`dref`,0,0,M([1,4]),Ni(`url `,0,1))),j(`stbl`,Ni(`stsd`,0,0,M([1,4]),e.sampleEntry),Ni(`stts`,0,0,M([0,4])),Ni(`stsc`,0,0,M([0,4])),Ni(`stsz`,0,0,M([0,4],[0,4])),Ni(`stco`,0,0,M([0,4])))))),j(`mvex`,Ni(`trex`,0,0,M([1,4],[1,4],[0,4],[0,4],[0,4])))),i=new Uint8Array(n.length+r.length);return i.set(n,0),i.set(r,n.length),i}function Ii(e,t,n,r,i){let a=i?33554432:16842752,o=e=>Ni(`trun`,0,1793,M([1,4],[e,4],[n,4],[r.length,4],[a,4])),s=e=>j(`traf`,Ni(`tfhd`,0,131072,M([1,4])),Ni(`tfdt`,1,0,M([t,8])),o(e)),c=Ni(`mfhd`,0,0,M([e,4])),l=j(`moof`,c,s(0)).length,u=j(`moof`,c,s(l+8)),d=j(`mdat`,r),f=new Uint8Array(u.length+d.length);return f.set(u,0),f.set(d,u.length),f}function Li(e,t,n=!1){let r=t?[35,...n?[32,33,34]:[]]:[9,...n?[7,8]:[]],i=ji(e).filter(e=>!r.includes(Mi(e,t))),a=new Uint8Array(i.reduce((e,t)=>e+4+t.length,0)),o=new DataView(a.buffer),s=0;for(let e of i)o.setUint32(s,e.length),a.set(e,s+4),s+=4+e.length;return a}var Ri=e=>e.toString(16).padStart(2,`0`),zi=e=>{let t=new Uint8Array(2+e.length);return t[0]=e.length>>8,t[1]=e.length&255,t.set(e,2),t},Bi=e=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t};function Vi(e){let t=ji(e),n=t.filter(e=>Mi(e,!1)===7),r=t.filter(e=>Mi(e,!1)===8);return!n.length||!r.length||n[0].length<4?null:Bi([M([1,1],[n[0][1],1],[n[0][2],1],[n[0][3],1],[255,1],[224|n.length,1]),...n.map(zi),M([r.length,1]),...r.map(zi)])}function Hi(e,t,n){let r=ji(e),i=e=>r.filter(n=>Mi(n,t)===e),a=(e,t)=>j(e,new Uint8Array(6),M([1,2],[0,16],[n.w,2],[n.h,2],[4718592,4],[4718592,4],[0,4],[1,2]),new Uint8Array(32),M([24,2],[65535,2]),t);if(!t){let t=i(7),r=Vi(e);return r?{init:Fi({handler:`vide`,timescale:9e4,sampleEntry:a(`avc1`,j(`avcC`,r)),width:n.w,height:n.h}),mime:`video/mp4; codecs="avc1.${Ri(t[0][1])}${Ri(t[0][2])}${Ri(t[0][3])}"`}:null}let o=i(32),s=i(33),c=i(34);if(!o.length||!s.length||!c.length)return null;let l=Vr(s[0]);if(l.length<15)return null;let u=l.subarray(3,15),d=u[0]&31,f=d===2?2:0,p=(e,t)=>Bi([M([128|e,1],[t.length,2]),...t.map(zi)]),m=j(`hvcC`,M([1,1]),u,M([61440,2],[252,1],[253,1],[248|f,1],[248|f,1],[0,2],[15,1],[3,1]),p(32,o),p(33,s),p(34,c)),h=[``,`A`,`B`,`C`][u[0]>>6],g=0,_=(u[1]<<24|u[2]<<16|u[3]<<8|u[4])>>>0;for(let e=0;e<32;e++)_&1<>>0).toString(16),`${u[0]&32?`H`:`L`}${u[11]}`,...v.map(e=>e.toString(16))].join(`.`);return{init:Fi({handler:`vide`,timescale:9e4,sampleEntry:a(`hvc1`,m),width:n.w,height:n.h}),mime:`video/mp4; codecs="${y}"`}}function Ui(e,t,n,r,i,a){return Ii(e,t,n,Li(r,i),a)}function Wi(e,t){let n=j(`dOps`,M([0,1],[e,1],[312,2],[t,4],[0,2],[0,1]));return Fi({handler:`soun`,timescale:48e3,sampleEntry:j(`Opus`,new Uint8Array(6),M([1,2],[0,8],[e,2],[16,2],[0,4],[3145728e3,4]),n)})}function Gi(e){if(!e.length)return 960;let t=e[0]>>3,n=t<12?[480,960,1920,2880][t%4]:t<16?[480,960][t%2]:[120,240,480,960][t%4],r=e[0]&3,i=r===0?1:r===3?(e[1]??1)&63:2;return n*Math.max(1,i)}function Ki(e,t,n){return Ii(e,t,Gi(n),n,!0)}var qi={watch:30,player:4},Ji={watch:{seek:.5,speed:1/0,target:.05},player:{seek:.15,speed:.06,target:.02}},Yi={seek:.8,speed:.25,target:.12};function Xi(e,t,n){let r=typeof n==`string`?Ji[n]:n;return e>r.seek?{seekTo:t-r.target,rate:1}:e>r.speed?{seekTo:null,rate:1.1}:{seekTo:null,rate:1}}function Zi(e,t=`watch`,n){return typeof VideoDecoder<`u`?new ca(e,t,n):new ba(e,t,n)}var Qi=class{constructor(e,t=()=>performance.now()){this.ask=e,this.now=t,this.last=-1/0}waiting(){if(!this.ask)return;let e=this.now();e-this.last<1e3||(this.last=e,this.ask())}};function $i(e){return e.length<3?null:{index:e[0]<<8|e[1],packet:e.subarray(2)}}var ea=class{constructor(){this.last=-1}take(e){if(this.last>=0){let t=e-this.last&65535;if(t===0||t>=32768)return!1}return this.last=e,!0}reset(){this.last=-1}};function ta(e){if(e.length>=10)return e;let t=new Uint8Array(10);t.set(e.subarray(0,6));let n=new DataView(t.buffer);return n.setUint32(6,Math.round(n.getUint32(2)/100)||480),t}function na(e,t){return{snd:e,snd_decoded:t.decoded,snd_concealed:t.concealed,snd_underruns:t.underruns,snd_dropped:t.dropped}}var ra=class{constructor(e,t=.2){this.min=e,this.max=t,this.next=0,this.calmSince=0,this.minLead=1/0,this.windowAt=0,this.underruns=0,this.dropped=0,this.cushion=e}at(e,t){this.next0&&(this.underruns++,this.cushion=Math.min(this.max,this.cushion+.02)),this.calmSince=e,this.next=e+this.cushion,this.minLead=1/0,this.windowAt=e):e-this.calmSince>10&&this.cushion>this.min&&(this.cushion=Math.max(this.min,this.cushion-.01),this.calmSince=e);let n=this.next-e;if(n>this.cushion+.15)return this.dropped++,null;if(this.minLead=Math.min(this.minLead,n),e-this.windowAt>=.25){let t=this.minLead>this.cushion+ia;if(this.minLead=1/0,this.windowAt=e,t)return this.dropped++,null}let r=this.next;return this.next+=t,r}reset(){this.next=0}},ia=.02;async function aa(e,t){try{return typeof AudioDecoder>`u`?!1:!!(await AudioDecoder.isConfigSupported({codec:`opus`,sampleRate:e,numberOfChannels:t})).supported}catch{return!1}}var oa=class{constructor(e,t=()=>performance.now()){this.decoder=e,this.now=t,this.n={frames:0,dropped:0,late:0,stalls:0,stall_ms:0,worst_stall_ms:0,key_waits:0},this.a=0,this.d=0,this.w=!1,this.q=[],this.sum=0,this.cnt=0,this.codec=``}get frames(){return this.n.frames}arrived(){let e=this.now();this.a&&e-this.a>50&&this.n.late++,this.a=e}drop(){this.n.dropped++,this.w||this.n.key_waits++,this.w=!0}decoding(){this.w=!1,this.q.push(this.now())>64&&this.q.shift()}drawn(e=!1){let t=this.now(),n=e?this.q.shift():void 0;n!==void 0&&(this.sum+=t-n,this.cnt++);let r=this.d?t-this.d:0;r>100&&this.stall(r),this.d=t,this.n.frames++}stall(e){this.n.stalls++,this.n.stall_ms+=e,this.n.worst_stall_ms=Math.max(this.n.worst_stall_ms,e)}snapshot(){let e=this.d?this.now()-this.d:0,t={...this.n,decoder:this.decoder};this.codec&&(t.codec=this.codec),e>100&&(t.stalls=this.n.stalls+1,t.stall_ms=this.n.stall_ms+e,t.worst_stall_ms=Math.max(this.n.worst_stall_ms,e));for(let e of[`stall_ms`,`worst_stall_ms`])t[e]=Math.round(t[e]);return t.decode_ms=this.cnt?Math.round(this.sum/this.cnt*10)/10:0,this.sum=this.cnt=0,t}},sa=[`pointerup`,`touchend`,`click`,`keydown`],ca=class{get element(){if(!this.wrap){let e=document.createElement(`div`);e.className=`h-full w-full`,e.append(this.canvas),this.mse&&e.append(this.mse.element),this.wrap=e}return this.wrap}get stats(){return this.mse?.stats??this.ownStats}soundReport(){return this.soundOn?this.mseSound?this.mseSound.report():na(this.soundWasm?`wasm`:`webcodecs`,this.soundStats):null}constructor(e,t=`watch`,n){this.onProblem=e,this.latency=t,this.onNeedKey=n,this.canvas=document.createElement(`canvas`),this.wrap=null,this.mse=null,this.failsNoPicture=0,this.ctx=this.canvas.getContext(`2d`,{alpha:!1}),this.hevc=!1,this.header=null,this.spsRect=null,this.software=!1,this.video=null,this.opening=!1,this.sawKey=!1,this.ownStats=new oa(`webcodecs`),this.problemShown=!1,this.ts=0,this.pipe=null,this.audioGen=0,this.actx=null,this.soundOn=!1,this.unarm=null,this.mseSound=null,this.audioHeader=null,this.soundWasm=!1,this.onSoundFail=null,this.muted=!1,this.keyAsk=new Qi(n),this.clock=new ra(t===`player`?.05:.08),typeof AudioDecoder>`u`&&N()&&(this.mseSound=new P(t,()=>this.mseSoundFailed())),this.canvas.className=`block h-full w-full object-contain`,this.canvas.dataset.testid=`watch-canvas`}setHevc(e){this.hevc=e,this.header&&(this.spsRect=qr(this.header,e)),this.mse?.setHevc(e)}get onMse(){return!!this.mse}decodeFailed(){if(this.mse||this.ownStats.frames>0||++this.failsNoPicture<3||!fa())return!1;let e=new ba(this.onProblem,this.latency,this.onNeedKey);e.setHevc(this.hevc),e.markProblemShown(),this.mse=e;let t=this.video;this.video=null;try{t?.close()}catch{}return this.canvas.style&&(this.canvas.style.display=`none`),this.wrap?.append(e.element),this.header&&e.onMessage(new Uint8Array([0,...this.header]).buffer),this.onNeedKey?.(),!0}startSound(){this.soundOn=!0,la(),this.mseSound?this.mseSound.start():this.openContext()}openContext(){try{if(!this.actx){let e=new AudioContext({latencyHint:`interactive`});this.actx=e,e.onstatechange=()=>{this.actx===e&&e.state!==`running`&&e.state!==`closed`&&this.armResume()}}this.actx.resume().catch(()=>{})}catch{this.onSoundFail?.()}}get sound(){return this.soundOn}setMuted(e){this.muted=e,this.mseSound?.setMuted(e)}resumeSound(){if(!this.soundOn)return;if(this.mseSound)return this.mseSound.resume();let e=this.actx;e&&e.state!==`running`&&e.state!==`closed`&&(this.clock.reset(),e.resume().catch(()=>{}),this.armResume())}get soundStats(){return{decoded:this.pipe?.decoded??0,concealed:this.pipe?.concealed??0,underruns:this.clock.underruns,dropped:this.clock.dropped,cushionMs:Math.round(this.clock.cushion*1e3)}}armResume(){if(this.unarm||typeof window>`u`||!window.addEventListener)return;let e=()=>{let e=this.actx;if(!e||e.state===`closed`)return this.unarm?.();this.clock.reset(),e.resume().then(()=>{e.state===`running`&&this.unarm?.()}).catch(()=>{})};for(let t of sa)window.addEventListener(t,e,!0);this.unarm=()=>{for(let t of sa)window.removeEventListener(t,e,!0);this.unarm=null}}onMessage(e){let t=new Uint8Array(e);if(t.length<1)return;let n=t[0],r=t.subarray(1);if(this.mse&&(n===0||n===1))return n===0&&(this.header=r.slice()),this.mse.onMessage(e);n===0?this.openVideo(r.slice()):n===1?this.onVideo(r):n===3?this.openAudio(r.slice()):n===4&&this.onAudio(r)}async openVideo(e){if(this.header=e,this.spsRect=qr(e,this.hevc),!this.opening){this.opening=!0;try{let t=this.hevc?await xa(e):Oi(e);if(this.mse)return;if(!t){this.problemShown=!0,this.onProblem(`no_hevc`);return}this.ownStats.codec=t;let n=this.hevc?void 0:Vi(e)??void 0;try{this.video?.close()}catch{}let r=new VideoDecoder({output:e=>{let t=this.realVisible(e),n=this.canvas;(n.width!==t.displayWidth||n.height!==t.displayHeight)&&(n.width=t.displayWidth,n.height=t.displayHeight),this.ctx?.drawImage(t,0,0,n.width,n.height),this.ownStats.drawn(!0),t.close(),this.problemShown&&(this.problemShown=!1,this.onProblem(null))},error:()=>{this.video===r&&(this.problemShown=!0,this.onProblem(`decode`),this.decodeFailed()||this.rebuild())}}),i={codec:t,optimizeForLatency:!0};n&&(i.description=n),this.software&&(i.hardwareAcceleration=`prefer-software`),r.configure(i),this.video=r,this.sawKey=!1}catch{this.problemShown=!0,this.onProblem(`decode`),this.decodeFailed()}finally{this.opening=!1}}}realVisible(e){let t=this.spsRect,n=Jr(e,t);if(n)try{let t=new VideoFrame(e,{visibleRect:{x:n.x,y:n.y,width:n.w,height:n.h},displayWidth:n.w,displayHeight:n.h});return e.close(),t}catch{return e}let r=e.visibleRect;if(t&&r&&!this.software&&(r.width{if(this.video===e){try{e?.close()}catch{}this.rebuild(),this.onNeedKey?.()}})}return e}rebuild(){this.mse||(this.video=null,this.sawKey=!1,this.header&&this.openVideo(this.header).then(()=>this.keyAsk.waiting()))}onVideo(e){let t=this.video;if(t?.state===`closed`){this.opening||this.rebuild();return}if(!t||t.state!==`configured`)return;let n=Di(e,this.hevc);if(this.ownStats.arrived(),!this.sawKey&&!n)return this.ownStats.drop(),this.keyAsk.waiting();if(!n&&t.decodeQueueSize>qi[this.latency])return this.sawKey=!1,this.ownStats.drop(),this.keyAsk.waiting();this.sawKey=!0;let r=e;this.hevc?n&&this.header&&(r=new Uint8Array(this.header.length+e.length),r.set(this.header,0),r.set(e,this.header.length)):r=Li(e,!1,!0),this.ts+=16667,this.ownStats.decoding(),t.decode(new EncodedVideoChunk({type:n?`key`:`delta`,timestamp:this.ts,data:r}))}openAudio(e){if(e.length<6)return;let t=++this.audioGen;if(this.pipe?.reset(),this.pipe=null,this.clock.reset(),this.audioHeader=e,this.mseSound)return this.mseSound.setHeader(e);let n=e[0];aa(new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2),n).then(n=>{if(t!==this.audioGen)return;if(!n)return N()?this.soundThroughMse(e):this.soundThroughWasm(e);let r=new Qr((e,t)=>this.play(e,t,r.sampleRate));try{r.header(ta(e)),this.pipe=r}catch{this.soundThroughMse(e)}})}soundThroughMse(e){this.pipe=null,this.mseSound||(this.mseSound=new P(this.latency,()=>this.mseSoundFailed()),this.soundOn&&this.mseSound.start()),this.mseSound.setHeader(e)}soundThroughWasm(e){this.pipe?.reset(),this.soundWasm=!0;let t=new Qr((e,n)=>this.play(e,n,t.sampleRate),Ei,()=>{this.pipe===t&&(this.pipe=null),this.onSoundFail?.()});this.pipe=t,t.header(ta(e))}mseSoundFailed(){let e=this.mseSound;e&&(this.mseSound=null,e.stop(),this.soundOn&&(this.openContext(),this.actx&&this.actx.state!==`running`&&this.armResume()),this.audioHeader&&this.soundThroughWasm(this.audioHeader))}onAudio(e){if(this.mseSound)return this.mseSound.frame(e);this.soundOn&&this.pipe&&this.pipe.packet(e)}play(e,t,n){let r=this.actx;if(!r||r.state!==`running`||!e.length)return;let i=e[0].length,a=this.clock.at(r.currentTime,i/n);if(a===null)return;let o=r.createBuffer(e.length,i,n),s=this.muted?0:t;e.forEach((e,t)=>o.copyToChannel(s===1?e:e.map(e=>e*s),t));let c=r.createBufferSource();c.buffer=o,c.connect(r.destination),c.start(a)}stop(){try{this.video?.close()}catch{}this.mse?.stop(),this.audioGen++,this.pipe?.reset(),this.pipe=null,this.unarm?.(),this.actx?.close().catch(()=>{}),this.mseSound?.stop()}};function la(){try{let e=navigator.audioSession;e&&e.type!==`playback`&&(e.type=`playback`)}catch{}}function ua(e,t){try{return e.isTypeSupported(t)}catch{return!1}}function N(){let e=typeof window>`u`?null:fa();return!!e&&(ua(e,`audio/mp4; codecs="Opus"`)||ua(e,`audio/mp4; codecs="opus"`))}var P=class{constructor(e,t,n=document.createElement(`audio`)){this.onFail=t,this.header=null,this.time=0,this.on=!1,this.failed=!1,this.order=new ea,this.el=n,this.track=new ga(n,()=>this.fail(),e===`player`?Yi:e)}get playing(){return this.on&&!this.failed}report(){return{snd:`mse`,snd_jumps:this.track.seeks}}setHeader(e){this.header=e,this.on&&this.open()}start(){if(!this.on&&(this.on=!0,this.header&&this.open(),!this.failed))try{this.el.play()?.catch?.(()=>{})}catch{}}frame(e){if(!this.on||this.failed||!this.track.ready&&!this.track.backlog)return;let t=$i(e);if(!t||!this.order.take(t.index))return;let n=Ki(this.track.nextSeq(),this.time,t.packet);this.time+=Gi(t.packet),this.track.push(n)}setMuted(e){this.el.muted=e}resume(){if(this.playing&&this.el.paused)try{this.el.play()?.catch?.(()=>{})}catch{}}stop(){this.on=!1,this.track.close()}open(){let e=this.header;if(!e||e.length<6||this.failed)return;let t=e[0],n=Wi(t,new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2));this.track.open(`audio/mp4; codecs="Opus"`,n)||this.track.open(`audio/mp4; codecs="opus"`,n)?(this.time=0,this.order.reset()):this.fail()}fail(){this.failed||(this.failed=!0,this.onFail())}},da=class{constructor(e,t,n=Ei){this.onFail=t,this.codecs=n,this.actx=null,this.pipe=null,this.header=null,this.on=!1,this.failed=!1,this.muted=!1,this.unarm=null,this.played=!1,this.clock=new ra(e===`player`?.05:.08)}get playing(){return this.on&&!this.failed}get stats(){return{decoded:this.pipe?.decoded??0,concealed:this.pipe?.concealed??0,underruns:this.clock.underruns,dropped:this.clock.dropped}}start(){if(!this.failed){this.on=!0,la();try{if(!this.actx){let e=new AudioContext({latencyHint:`interactive`});this.actx=e,e.onstatechange=()=>{this.actx===e&&e.state!==`running`&&e.state!==`closed`&&this.armResume()}}this.actx.resume().catch(()=>{}),this.actx.state!==`running`&&this.armResume()}catch{return this.fail()}this.header&&!this.pipe&&this.open()}}setHeader(e){e.length<6||(this.header=e,this.pipe?.reset(),this.pipe=null,this.clock.reset(),this.on&&this.open())}frame(e){this.on&&!this.failed&&this.pipe?.packet(e)}setMuted(e){this.muted=e}resume(){let e=this.actx;this.playing&&e&&e.state!==`running`&&e.state!==`closed`&&(this.clock.reset(),e.resume().catch(()=>{}),this.armResume())}stop(){this.on=!1,this.pipe?.reset(),this.pipe=null,this.unarm?.(),this.actx?.close().catch(()=>{}),this.actx=null}open(){let e=this.header;if(!e||this.failed)return;let t=new Qr((e,n)=>this.play(e,n,t.sampleRate),this.codecs,()=>{this.pipe===t&&this.fail()});this.pipe=t,t.header(ta(e))}play(e,t,n){let r=this.actx;if(!r||r.state!==`running`||!e.length)return;let i=e[0].length,a=this.clock.at(r.currentTime,i/n);if(a===null)return;let o=r.createBuffer(e.length,i,n),s=this.muted?0:t;e.forEach((e,t)=>o.copyToChannel(s===1?e:e.map(e=>e*s),t));let c=r.createBufferSource();c.buffer=o,c.connect(r.destination),c.start(a),this.played=!0}armResume(){if(this.unarm||typeof window>`u`||!window.addEventListener)return;let e=()=>{let e=this.actx;if(!e||e.state===`closed`)return this.unarm?.();this.clock.reset(),e.resume().then(()=>{e.state===`running`&&this.unarm?.()}).catch(()=>{})};for(let t of sa)window.addEventListener(t,e,!0);this.unarm=()=>{for(let t of sa)window.removeEventListener(t,e,!0);this.unarm=null}}fail(){this.failed||(this.failed=!0,this.stop(),this.onFail())}};function fa(){let e=window;return e.ManagedMediaSource??e.MediaSource??null}var pa=10,ma=3;function ha(e,t,n,r=ma){let i=null;for(let a of e)a>t&&a<=n-r&&(i=a);return i}var ga=class{constructor(e,t,n=`watch`,r,i=()=>performance.now()){this.el=e,this.onError=t,this.latency=n,this.onNeedKey=r,this.now=i,this.ms=null,this.sb=null,this.queue=[],this.mime=``,this.seq=1,this.ready=!1,this.dropped=!1,this.keys=null,this.seeks=0,this.maxLagS=0,this.fromZero=0,this.trims=0,this.lastJump=null,this.trimAt=-1,this.trimFrom=-1,this.keyAt=-1,this.attached=null,r&&(this.keys=[])}setEdge(e){this.latency=e}markKey(e){this.keys?.push(e),this.keyAt=this.now()}open(e,t){let n=fa();if(!n||!ua(n,e))return!1;this.close();let r=new n;return this.ms=r,this.mime=e,this.queue=[t],this.seq=1,this.ready=!1,this.keys&&=[],r.addEventListener(`sourceopen`,()=>{if(this.ms===r)try{let e=r.addSourceBuffer(this.mime);e.mode=`segments`,e.addEventListener(`updateend`,()=>this.pump()),e.addEventListener(`error`,()=>this.onError()),this.sb=e,this.ready=!0,this.pump()}catch{this.onError()}}),`ManagedMediaSource`in window&&n===window.ManagedMediaSource&&(this.el.disableRemotePlayback=!0),this.attached=_a(this.el,r),!0}nextSeq(){return this.seq++}get backlog(){return this.queue.length}push(e){this.queue.push(e),this.pump()}pump(){let e=this.sb;if(!e||e.updating||!this.ready)return;let t=this.el;if(e.buffered.length){let n=e.buffered.end(e.buffered.length-1),r=e.buffered.start(0),i=n-t.currentTime,a=Xi(i,n,this.latency);if(a.seekTo!==null){this.seeks++,this.maxLagS=Math.max(this.maxLagS,i);let o=this.now(),s=e=>e<0?-1:Math.round(o-e);t.currentTime<.05&&r>1&&this.fromZero++,this.lastJump={at:t.currentTime,start:r,end:n,ranges:e.buffered.length,readyState:t.readyState,paused:t.paused,seeking:t.seeking,sinceTrimMs:s(this.trimAt),trimFrom:this.trimFrom,sinceKeyMs:s(this.keyAt)},t.currentTime=Math.max(r,a.seekTo)}if(t.playbackRate!==a.rate&&(t.playbackRate=a.rate),t.currentTime-r>pa&&this.trim(e,r))return}let n=this.queue.shift();if(n){try{e.appendBuffer(n)}catch{this.dropped=!0}t.paused&&t.play().catch(()=>{})}}trim(e,t){let n=this.el.currentTime,r=n-ma;if(this.keys){if(r=ha(this.keys,t,n),r===null)return(this.keys[this.keys.length-1]??-1/0)<=n-ma&&this.onNeedKey?.(),!1;let e=r;this.keys=this.keys.filter(t=>t>=e),r-=.001}try{return e.remove(t,r),this.trims++,this.trimAt=this.now(),this.trimFrom=n,!0}catch{return!1}}close(){this.ready=!1,this.sb=null,this.queue=[];let e=this.ms;if(this.ms=null,e&&e.readyState===`open`)try{e.endOfStream()}catch{}if(this.attached===`object`)try{this.el.srcObject=null}catch{}this.attached=null,this.el.src?.startsWith(`blob:`)&&URL.revokeObjectURL(this.el.src),this.el.removeAttribute(`src`)}};function _a(e,t){if(`srcObject`in e)try{return e.srcObject=t,`object`}catch{}return e.src=URL.createObjectURL(t),`url`}var va=1e4,ya=class{constructor(e=3,t=va,n=()=>performance.now()){this.max=e,this.windowMs=t,this.now=n,this.at=[]}fail(){let e=this.now();return this.at=this.at.filter(t=>e-t=this.max}clear(){this.at=[]}},ba=class{constructor(e,t=`watch`,n,r){this.onProblem=e,this.latency=t,this.wasm=null,this.audioHeader=null,this.muted=!1,this.gaveUp=!1,this.reopening=!1,this.failedWhileOpening=!1,this.wrap=document.createElement(`div`),this.hevc=!1,this.header=null,this.sawKey=!1,this.stats=new oa(`mse`),this.problemShown=!1,this.vTime=0,this.vLast=0,this.soundOn=!1,this.onSoundFail=null,this.onGiveUp=null,this.keyAsk=new Qi(n),this.fails=new ya(3,va,r);let i=document.createElement(`video`);i.muted=!0,i.autoplay=!0,i.playsInline=!0,i.className=`block h-full w-full object-contain`,i.dataset.testid=`watch-video`,this.audio=new P(t,()=>this.soundThroughWasm()),this.wrap.className=`h-full w-full`,this.wrap.append(i,this.audio.el),this.video=new ga(i,()=>this.showProblem(),t,()=>this.keyAsk.waiting()),i.addEventListener(`error`,()=>this.restartVideo()),i.addEventListener(`playing`,()=>{this.fails.clear(),this.problemShown&&(this.problemShown=!1,this.onProblem(null))})}markProblemShown(){this.problemShown=!0}showProblem(){this.problemShown||(this.problemShown=!0,this.onProblem(`decode`))}restartVideo(){if(this.gaveUp)return;if(this.reopening){this.failedWhileOpening=!0;return}if(this.showProblem(),this.fails.fail()){this.gaveUp=!0,this.video.close(),this.onGiveUp?.();return}let e=this.header;if(e){this.header=null,this.reopening=!0,this.failedWhileOpening=!1;try{this.openVideo(e)}finally{this.reopening=!1}this.sawKey=!1,this.keyAsk.waiting(),this.failedWhileOpening&&(this.failedWhileOpening=!1,this.restartVideo())}}get failed(){return this.gaveUp}setVideoEdge(e){this.video.setEdge(e)}get videoSeeks(){return{seeks:this.video.seeks,maxLagMs:Math.round(this.video.maxLagS*1e3),fromZero:this.video.fromZero,trims:this.video.trims,lastJump:this.video.lastJump}}get element(){return this.wrap}resume(){let e=this.video.el;e.paused&&e.play()?.catch?.(()=>{})}setHevc(e){this.hevc=e}startSound(){if(this.soundOn=!0,this.wasm)return this.wasm.start();if(!N())return this.soundThroughWasm();this.audio.start()}soundThroughWasm(){if(this.wasm)return;this.audio.stop();let e=new da(this.latency,()=>this.onSoundFail?.());this.wasm=e,e.setMuted(this.muted),this.audioHeader&&e.setHeader(this.audioHeader),this.soundOn&&e.start()}resumeSound(){this.soundOn&&(this.wasm?this.wasm.resume():this.audio.resume())}setMuted(e){this.muted=e,this.audio.setMuted(e),this.wasm?.setMuted(e)}soundReport(){return this.soundOn?this.wasm?na(`wasm`,this.wasm.stats):this.audio.report():null}get soundPlaying(){return this.wasm?this.wasm.played:this.audio.playing}get sound(){return this.soundOn}onMessage(e){let t=new Uint8Array(e);if(t.length<1)return;let n=t[0],r=t.subarray(1);n===0?this.openVideo(r.slice()):n===1?this.onVideo(r):n===3?(this.audioHeader=r.slice(),(this.wasm??this.audio).setHeader(this.audioHeader)):n===4&&(this.wasm??this.audio).frame(r)}openVideo(e){let t=!!this.header&&this.header.length===e.length&&this.header.every((t,n)=>t===e[n]);if(t&&this.video.ready)return;if(this.gaveUp){if(t)return;this.gaveUp=!1,this.fails.clear()}this.header=e;let n=qr(e,this.hevc)??{w:1920,h:1080},r=Hi(e,this.hevc,n);r&&(this.stats.codec=/codecs="([^"]+)"/.exec(r.mime)?.[1]??``,this.video.open(r.mime,r.init)?(this.sawKey=!1,this.vTime=0,this.vLast=0):(this.problemShown=!0,this.onProblem(this.hevc?`no_hevc`:`decode`)))}onVideo(e){if(!this.video.ready&&!this.video.backlog)return;let t=Di(e,this.hevc);if(this.video.dropped&&(this.video.dropped=!1,this.sawKey=!1),this.stats.arrived(),!this.sawKey&&!t)return this.stats.drop(),this.keyAsk.waiting();if(!t&&this.video.backlog>qi[this.latency])return this.sawKey=!1,this.stats.drop(),this.keyAsk.waiting();this.sawKey=!0,this.stats.drawn();let n=performance.now(),r=this.vLast?Math.min(9e3,Math.max(750,Math.round((n-this.vLast)*90))):1500;this.vLast=n,t&&this.video.markKey(this.vTime/9e4),this.video.push(Ui(this.video.nextSeq(),this.vTime,r,e,this.hevc,t)),this.vTime+=r}stop(){this.video.close(),this.audio.stop(),this.wasm?.stop()}};async function xa(e){let t=Yr(e);if(t&&typeof VideoDecoder<`u`)try{if((await VideoDecoder.isConfigSupported({codec:t,codedWidth:1920,codedHeight:1080})).supported)return t}catch{}return Ai(1920,1080)}var F={CROSS:1,CIRCLE:2,SQUARE:4,TRIANGLE:8,LEFT:16,RIGHT:32,UP:64,DOWN:128,L1:256,R1:512,L3:1024,R3:2048,OPTIONS:4096,SHARE:8192,TOUCHPAD:16384,PS:32768},Sa={buttons:0,l2:0,r2:0,lx:0,ly:0,rx:0,ry:0};function Ca(e,t){let n=e=>Math.max(0,Math.min(1,e));return[Math.round(n(e)*1919),Math.round(n(t)*941)]}F.UP,F.DOWN,F.LEFT,F.RIGHT,F.CROSS,F.CROSS,F.CIRCLE,F.CIRCLE,F.SQUARE,F.TRIANGLE,F.L1,F.R1,F.L3,F.R3,F.OPTIONS,F.SHARE,F.PS,F.TOUCHPAD,F.UP,F.DOWN,F.LEFT,F.RIGHT,F.CROSS,F.CIRCLE,F.SQUARE,F.TRIANGLE,F.L1,F.R1,F.L3,F.R3,F.OPTIONS,F.SHARE,F.PS,F.TOUCHPAD;var wa=e=>Math.max(-32768,Math.min(32767,Math.round(e))),Ta=[F.CROSS,F.CIRCLE,F.SQUARE,F.TRIANGLE,F.L1,F.R1,0,0,F.SHARE,F.OPTIONS,F.L3,F.R3,F.UP,F.DOWN,F.LEFT,F.RIGHT,F.PS,F.TOUCHPAD];function Ea(e){return Math.abs(e)<=1.01?Math.round((e+1)*3.5)%8:null}var Da=[0,1,1,1,0,-1,-1,-1],Oa=[-1,-1,0,1,1,1,0,-1];function ka(e,t){let n=e.axes[t.a]??0;if(t.hat){let e=Ea(n);return e===null?0:(t.hat===`x`?Da:Oa)[e]}return t.inv?-n:n}var Aa={buttons:Ta.flatMap((e,t)=>e?[[e,{b:t}]]:[]),l2:{b:6},r2:{b:7},lx:{a:0},ly:{a:1},rx:{a:2},ry:{a:3}};function ja(e,t,n=!1){if(`b`in t){let r=e.buttons[t.b];return r?n&&r.value>0?Math.min(1,r.value):Math.max(+!!r.pressed,r.value):0}if(`h`in t){let n=Ea(e.axes[t.h]??9);if(n===null)return 0;let r=(n-t.at+8)%8;return+(r===0||r===1||r===7)}let r=e.axes[t.a];if(r===void 0)return 0;let i=t.rest??0;return Math.min(1,Math.max(0,(r-i)/(t.d-i)))}function Ma(e){if(e.mapping===`standard`)return Aa;let t=Na.get(e.id);if(t)return t;let n=e.axes.findIndex(e=>Math.abs(e)>1.05);if(n<0)return Aa;let r={...Aa,buttons:[...Aa.buttons,[F.UP,{h:n,at:0}],[F.RIGHT,{h:n,at:2}],[F.DOWN,{h:n,at:4}],[F.LEFT,{h:n,at:6}]]};return Na.set(e.id,r),r}var Na=new Map;function Pa(e,t=Ma){let n={...Sa},r=e=>Math.abs(e)<.08?0:wa(e*32767),i=(e,t)=>Math.abs(t)>Math.abs(e)?t:e,a=(e,t)=>t?r(ka(e,t)):0;for(let r of e){if(!r||!r.connected)continue;let e=t(r);for(let[t,i]of e.buttons)ja(r,i)>.5&&(n.buttons|=t);e.l2&&(n.l2=Math.max(n.l2,Math.round(ja(r,e.l2,!0)*255))),e.r2&&(n.r2=Math.max(n.r2,Math.round(ja(r,e.r2,!0)*255))),n.lx=i(n.lx,a(r,e.lx)),n.ly=i(n.ly,a(r,e.ly)),n.rx=i(n.rx,a(r,e.rx)),n.ry=i(n.ry,a(r,e.ry))}return n}function Fa(e,t){return{buttons:e.buttons|t.buttons,l2:Math.max(e.l2,t.l2),r2:Math.max(e.r2,t.r2),lx:wa(e.lx+t.lx),ly:wa(e.ly+t.ly),rx:wa(e.rx+t.rx),ry:wa(e.ry+t.ry),touch:e.touch??t.touch??null,motion:e.motion??t.motion??null}}var I=e=>e.toLowerCase().padStart(4,`0`);function Ia(e){let t=/^(.*?)\s*\((?:[^()]*?\s)?Vendor:\s*([0-9a-f]{1,4})\s+Product:\s*([0-9a-f]{1,4})\s*\)\s*$/i.exec(e);if(t)return{vendor:I(t[2]),product:I(t[3]),name:t[1].trim()};let n=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-(.*)$/i.exec(e.trim());return n?{vendor:I(n[1]),product:I(n[2]),name:n[3].trim()}:null}function La(e=globalThis.navigator){let t=e?.userAgent??``;return/Android|iPhone|iPad|iPod/i.test(t)?null:/Macintosh|Mac OS X/i.test(t)?(e?.maxTouchPoints??0)>1?null:`m`:/Windows/i.test(t)?`w`:/Linux|CrOS|X11/i.test(t)?`l`:null}function Ra(e,t){if(!t)return null;let n=t===`l`?[`l`]:[`m`,`w`];for(let t of n){let n=Ge[`${t}${e.vendor}${e.product}`];if(n!==void 0)return We[n]??null}return null}var za={1:0,2:2,4:4,8:6};function Ba(e){let t=0,n=!1;for(let r of e){let e=/a(\d+)/.exec(r);e&&(t=Math.max(t,Number(e[1])+1)),r.startsWith(`h`)&&(n=!0)}return{n:t,hat:n}}function Va(e,t,n){let{n:r,hat:i}=Ba(t),a=Ta.length,o=e.axes.findIndex(e=>Math.abs(e)>1.05),s=e=>e;if(i&&o<0)return n===`l`&&e.axes.length>=r+2?{hat:-1,hatXY:r,axis:s}:null;if(!(i?o>r:n!==`l`&&e.axes.length>=r+2))return{hat:o,hatXY:-1,axis:s};if(r<=4)return{hat:o,hatXY:-1,axis:e=>[0,1,2,5][e]??e};let c=t[a+2]?.replace(`~`,``)===`a2`&&t[a+3]?.replace(`~`,``)===`a3`,l=[t[6],t[7]].every(e=>/^a[45]~?$/.test(e??``));return r===6&&c&&l?{hat:o,hatXY:-1,axis:e=>[0,1,2,5,3,4][e]??e}:{hat:o,hatXY:-1,axis:s}}function Ha(e,t){let n=/^b(\d+)$/.exec(e);if(n)return{b:Number(n[1])};if(n=/^([+-]?)a(\d+)(~?)$/.exec(e),n){let e=t.axis(Number(n[2]));return n[1]===`+`?{a:e,d:1}:n[1]===`-`?{a:e,d:-1}:n[3]?{a:e,d:-1,rest:1}:{a:e,d:1,rest:-1}}if(n=/^h0\.(\d)$/.exec(e),n){let e=za[n[1]];if(e===void 0)return null;if(t.hat>=0)return{h:t.hat,at:e};if(t.hatXY>=0)return e===0?{a:t.hatXY+1,d:-1}:e===4?{a:t.hatXY+1,d:1}:e===6?{a:t.hatXY,d:-1}:{a:t.hatXY,d:1}}return null}function Ua(e,t){let n=/^a(\d+)(~?)$/.exec(e);if(n)return n[2]?{a:t.axis(Number(n[1])),inv:!0}:{a:t.axis(Number(n[1]))};if(e===`hx`||e===`hy`){if(t.hat>=0)return{a:t.hat,hat:e===`hx`?`x`:`y`};if(t.hatXY>=0)return{a:t.hatXY+ +(e===`hy`)}}return null}function Wa(e,t,n){let r=e.split(`,`),i=Va(t,r,n);if(!i)return null;let a={buttons:[],l2:null,r2:null,lx:null,ly:null,rx:null,ry:null};for(let e=0;eArray.isArray(e)&&e.length===2&&typeof e[0]==`number`&&Ja(e[1]))&&[t.l2,t.r2,t.lx,t.ly,t.rx,t.ry].every(Ja)}function Xa(){try{let e=yt(qa),t=e?JSON.parse(e):null;return!t||typeof t!=`object`||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>Ya(e[1])))}catch{return{}}}function Za(e,t){let n=Xa();return t?n[e]=t:delete n[e],vt(qa,JSON.stringify(n)),Qa=n,n}var Qa=null;function $a(e){return Qa??=Xa(),Qa[e.id]??eo(Qa,e.id)??Ka(e)??Ma(e)}function eo(e,t){if(!t.endsWith(` (app)`))return null;let n=t.slice(0,-6).trim().toLowerCase();if(!n)return null;let r=Object.keys(e).filter(e=>{let t=e.trim().toLowerCase();return t===n||t.includes(n)}),i=r.find(e=>e.trim().toLowerCase()===n)??(r.length===1?r[0]:null);return i?(Qa=Za(t,e[i]),e[i]):null}[{kind:`button`,bit:F.CROSS,name:`✕`},{kind:`button`,bit:F.CIRCLE,name:`○`},{kind:`button`,bit:F.SQUARE,name:`□`},{kind:`button`,bit:F.TRIANGLE,name:`△`},{kind:`button`,bit:F.UP,name:`↑`},{kind:`button`,bit:F.DOWN,name:`↓`},{kind:`button`,bit:F.LEFT,name:`←`},{kind:`button`,bit:F.RIGHT,name:`→`},{kind:`button`,bit:F.L1,name:`L1`},{kind:`button`,bit:F.R1,name:`R1`},{kind:`trigger`,which:`l2`,name:`L2`},{kind:`trigger`,which:`r2`,name:`R2`},{kind:`button`,bit:F.L3,name:`L3`},{kind:`button`,bit:F.R3,name:`R3`},{kind:`button`,bit:F.OPTIONS,name:`Options`},{kind:`button`,bit:F.SHARE,name:`Create`},{kind:`button`,bit:F.PS,name:`PS`},{kind:`button`,bit:F.TOUCHPAD,name:`Touchpad`},{kind:`axis`,which:`lx`,name:`L →`},{kind:`axis`,which:`ly`,name:`L ↓`},{kind:`axis`,which:`rx`,name:`R →`},{kind:`axis`,which:`ry`,name:`R ↓`}].filter(e=>e.kind!==`button`||![F.L3,F.R3,F.OPTIONS,F.SHARE,F.PS,F.TOUCHPAD].includes(e.bit));var to=12e4;function no(e){let t;try{t=JSON.parse(e)}catch{return null}return Array.isArray(t.rumble)?{rumble:[Number(t.rumble[0])||0,Number(t.rumble[1])||0]}:Array.isArray(t.light)?{light:t.light}:t.stage===`asking`?{kind:`asking`}:t.stage===`refused`?{kind:`refused`,why:String(t.why??``)}:t.stage===`joined`?{kind:`joined`,host:t.session?.host??null,playing:!!t.session?.playing,passcode:!!t.session?.passcode}:null}function ro(e,t){return e.buttons===t.buttons&&e.l2===t.l2&&e.r2===t.r2&&e.lx===t.lx&&e.ly===t.ly&&e.rx===t.rx&&e.ry===t.ry&&(e.touch?.[0]??-1)===(t.touch?.[0]??-1)&&(e.touch?.[1]??-1)===(t.touch?.[1]??-1)&&(e.motion?.t??-1)===(t.motion?.t??-1)}var io=class{constructor(e){this.o=e,this.ws=null,this.last={...Sa},this.lastSent=0,this.raf=0,this.keepalive=null,this.watchdog=null,this.retry=null,this.done=!1,this.stage={kind:`connecting`},this.wasIn=!1,this.attempt=0,this.deadline=0,this.lastHeard=0,this.control=!1,this.neutral=!1,this.now=e.now??(()=>Date.now()),this.WS=e.WebSocketImpl??WebSocket}get currentStage(){return this.stage}setStage(e){this.stage=e,this.o.onStage(e)}start(){if(this.done=!1,this.setStage({kind:`connecting`}),this.connect(),this.done)return;let e=this.o.raf??(e=>window.requestAnimationFrame(e)),t=()=>{this.send(!1),this.raf=e(t)};this.raf=e(t),this.keepalive=setInterval(()=>this.send(!1),250),this.watchdog=setInterval(()=>this.checkSilence(),1e3)}connect(){let e;this.lastHeard=this.now();try{e=new this.WS(this.o.url)}catch{this.dropped();return}this.ws=e,e.binaryType=`arraybuffer`,this.control=!this.o.watch,this.o.watch&&this.o.watch.onControl(!1),e.onmessage=t=>{this.ws===e&&(this.lastHeard=this.now(),this.onMessage(t.data))},e.onclose=t=>{if(this.ws!==e)return;this.ws=null;let n=Le(t);n&&!this.wasIn?this.finish({kind:`refused`,why:`net:${n}`}):this.dropped()},e.onopen=()=>{this.ws===e&&(this.lastHeard=this.now(),this.o.hello&&e.send(JSON.stringify({hello:this.o.hello})),this.send(!0))}}onMessage(e){if(typeof e!=`string`){e instanceof ArrayBuffer&&this.o.watch?.onFrame(e);return}if(this.o.hello&&e.startsWith(`{"rt":`))try{let t=JSON.parse(e);if(typeof t.rt==`string`&&/^[0-9a-f]{32}$/.test(t.rt)){this.o.hello.rt=t.rt,this.o.onReconnectToken?.(t.rt);return}}catch{}if(e.includes(`"kbm_caps"`))try{let t=JSON.parse(e);if(t.kbm_caps){let e=t.kbm_caps;this.o.onKbmCaps?.({mouse:e.mouse===!0,keyboard:e.keyboard===!0,reason:typeof e.reason==`string`?e.reason:null});return}}catch{}if(this.o.watch)try{let t=JSON.parse(e);if(t.watch&&this.o.watch.onCodec(!!t.watch.hevc),typeof t.control==`boolean`){this.control=t.control,this.o.watch.onControl(t.control),t.control&&this.send(!0);return}}catch{}let t=no(e);if(t){if(`rumble`in t){let[e,n]=t.rumble;navigator.vibrate?.(e||n?250:0)}else if(`light`in t)this.o.onLight?.(t.light);else if(t.kind===`refused`)this.finish(t);else{if(t.kind===`joined`){let e=this.stage.kind!==`joined`;this.wasIn=!0,this.attempt=0,this.setStage(t),e&&this.send(!0);return}this.setStage(t)}}}dropped(){if(this.done)return;if(!this.wasIn||(this.stage.kind!==`reconnecting`&&(this.deadline=this.now()+to),this.now()>=this.deadline)){this.finish({kind:`lost`});return}let e=Re(this.attempt);this.setStage({kind:`reconnecting`,attempt:this.attempt}),this.attempt+=1,this.retry&&clearTimeout(this.retry),this.retry=setTimeout(()=>{this.retry=null,this.done||this.connect()},e)}checkSilence(){let e=this.ws;if(e&&!this.done&&(this.stage.kind===`joined`||this.stage.kind===`reconnecting`)&&!(this.now()-this.lastHeard<=3500)){this.ws=null;try{e.close()}catch{}this.dropped()}}wake(){this.stage.kind===`lost`&&this.wasIn?(this.attempt=0,this.start()):this.stage.kind===`reconnecting`&&(this.deadline=this.now()+to,this.attempt=0,this.retry&&(clearTimeout(this.retry),this.retry=null,this.connect()))}setNeutral(e){this.neutral!==e&&(this.neutral=e,this.send(!0))}current(){let e=Pa(Ue(typeof navigator>`u`?void 0:navigator),$a),t=this.o.touchPad();return{...Fa(e,t),touch:t.touch??null,motion:this.o.motion?.()??null}}send(e){let t=this.ws;if(!t||t.readyState!==this.WS.OPEN||!this.control)return;let n=this.neutral?{...Sa,touch:null,motion:null}:this.current(),r=this.now();!e&&ro(n,this.last)&&r-this.lastSent<250||(this.last=n,this.lastSent=r,t.send(JSON.stringify({pad:{...n,touch:n.touch??null,motion:n.motion??null},ka:1})))}askKeyframe(){let e=this.ws;e&&e.readyState===this.WS.OPEN&&e.send(JSON.stringify({keyframe:!0}))}sendKbm(e){let t=this.ws;return!t||t.readyState!==this.WS.OPEN||!this.control?!1:(t.send(e instanceof Uint8Array?e:JSON.stringify(e)),!0)}sendPad(){this.send(!1)}clearTimers(){(this.o.cancelRaf??(e=>window.cancelAnimationFrame(e)))(this.raf),this.keepalive&&clearInterval(this.keepalive),this.watchdog&&clearInterval(this.watchdog),this.retry&&clearTimeout(this.retry),this.keepalive=this.watchdog=this.retry=null}finish(e){this.done=!0,this.clearTimers();let t=this.ws;this.ws=null;try{t?.close()}catch{}this.setStage(e)}stop(){this.done=!0,this.clearTimers();let e=this.ws;this.ws=null,e&&e.readyState===this.WS.OPEN&&e.send(JSON.stringify({pad:{...Sa,touch:null}})),e?.close()}},ao=`ps5upload.pad.device`;function oo(e,t=e=>crypto.getRandomValues(e)){let n=e.get(ao);if(n&&/^[0-9a-f]{32}$/.test(n))return n;let r=new Uint8Array(16);t(r);let i=Array.from(r,e=>e.toString(16).padStart(2,`0`)).join(``);return e.set(ao,i),i}var so=new Set,co={held:new Set,touch:null,touchPad:Sa,mapping:!1,get paused(){return so.size>0},motion:null},lo={s:.85,m:1,l:1.15},uo=.25;function fo(e){return typeof e!=`number`||!Number.isFinite(e)?1:Math.min(1,Math.max(uo,e))}var po={overlay:{width:844,height:390},deck:{width:390,height:480}},mo=.7,ho=1.4;function go(e,t,n,r){let i=lo[e]??1;if(!(t>0)||!(n>0))return i;let a=r?po.deck:po.overlay,o=Math.min(ho,Math.max(mo,Math.min(t/a.width,n/a.height)));return Math.round(o*i*1e3)/1e3}var _o=34;function vo(e,t){return t>0&&8+Math.max(112*e,90)+156*e+124*e+Math.max(56*e,44)+_o>t}function yo(e,t,n){let r=e/32767,i=t/32767,a=Math.hypot(r,i),o=a>1?1/a:1;return{dx:r*o*n,dy:i*o*n}}var bo=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),L=s(((e,t)=>{t.exports=bo()}))(),xo=`calc(50% + (env(safe-area-inset-left) - env(safe-area-inset-right)) / 2)`,So=32767,Co=12;function wo({stream:e,layout:t=`overlay`,opacity:n=1,size:r=`m`,deckTop:i=`0px`,onMenu:a}){let o=Tn(),s=(0,T.useRef)(new Map),c=(0,T.useRef)({...Sa}),[l,u]=(0,T.useState)({...Sa}),[d,f]=(0,T.useState)({l:!1,r:!1,touchpad:!1}),p=(0,T.useRef)(null),[m,h]=(0,T.useState)({width:0,height:0});(0,T.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();h(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})};if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,T.useEffect)(()=>()=>{co.touchPad={...Sa}},[]);let g=()=>{let t={...Sa,touch:null},n={l:!1,r:!1,touchpad:!1};for(let e of s.current.values())e.kind===`stick`&&(n[e.which]=!0),e.kind===`touchpad`&&(n.touchpad=!0),e.kind===`button`&&(t.buttons|=e.bit),e.kind===`trigger`&&(t[e.which]=255),e.kind===`touchpad`&&e.pressed&&(t.buttons|=F.TOUCHPAD);t.lx=c.current.lx,t.ly=c.current.ly,t.rx=c.current.rx,t.ry=c.current.ry,t.touch=c.current.touch??null,co.touchPad=t,e?.sendPad(),u(t),f(e=>e.l===n.l&&e.r===n.r&&e.touchpad===n.touchpad?e:n)},_=(e,t,n)=>{let r=Math.max(-1,Math.min(1,(t-e.cx)/e.radius)),i=Math.max(-1,Math.min(1,(n-e.cy)/e.radius));c.current[e.which===`l`?`lx`:`rx`]=Math.round(r*So),c.current[e.which===`l`?`ly`:`ry`]=Math.round(i*So)},v=(e,t)=>{e.preventDefault(),e.stopPropagation();let n=e.currentTarget;try{n.setPointerCapture(e.pointerId)}catch{}let r=t(n);s.current.set(e.pointerId,r),r.kind===`stick`&&_(r,e.clientX,e.clientY),r.kind===`touchpad`&&(c.current.touch=Ca((e.clientX-r.rect.left)/r.rect.width,(e.clientY-r.rect.top)/r.rect.height)),navigator.vibrate?.(8),g()},y=e=>{let t=s.current.get(e.pointerId);if(t){if(e.stopPropagation(),t.kind===`stick`)_(t,e.clientX,e.clientY);else if(t.kind===`touchpad`)c.current.touch=Ca((e.clientX-t.rect.left)/t.rect.width,(e.clientY-t.rect.top)/t.rect.height),t.pressed&&Math.hypot(e.clientX-t.x0,e.clientY-t.y0)>Co&&(t.pressed=!1);else return;g()}},b=e=>{let t=s.current.get(e.pointerId);t&&(e.stopPropagation(),s.current.delete(e.pointerId),t.kind===`stick`&&(c.current[t.which===`l`?`lx`:`rx`]=0,c.current[t.which===`l`?`ly`:`ry`]=0),t.kind===`touchpad`&&(c.current.touch=null),g())},x=e=>e.stopPropagation(),S={onPointerMove:y,onPointerUp:b,onPointerCancel:b,onClick:x,onDoubleClick:x},ee=e=>(l.buttons&e)!==0,te=e=>`border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.35)] transition-colors duration-75 ${e?`border-white bg-white/50`:`border-white/70 bg-white/10`}`,C=`text-white [text-shadow:0_1px_2px_rgba(0,0,0,0.6)]`,ne={filter:`drop-shadow(0 0 1.5px rgba(0,0,0,0.5))`},w=e=>({stroke:e?`#fff`:`rgba(255,255,255,0.75)`,fill:e?`rgba(255,255,255,0.5)`:`rgba(255,255,255,0.1)`}),re=`pointer-events-auto flex touch-none select-none items-center justify-center bg-transparent p-0`,ie={minHeight:`calc(44px / var(--k))`,minWidth:`calc(44px / var(--k))`},ae=(e,t,n,r)=>(0,L.jsx)(`button`,{type:`button`,"aria-label":e,onPointerDown:e=>v(e,()=>({kind:`button`,bit:t})),...S,className:`${re} ${n}`,style:ie,children:r}),oe=(e,t,n,r)=>(0,L.jsx)(`span`,{className:`flex h-[32px] w-[76px] items-center justify-center text-[13px] font-semibold tracking-wide ${C} ${te(t)}`,style:{borderRadius:r?n===`l`?`16px 9px 9px 9px`:`9px 16px 9px 9px`:`9px`},children:e}),se=(e,t,n,r)=>ae(e,t,`h-[44px] w-[84px]`,oe(e,ee(t),n,r)),ce=(e,t,n)=>(0,L.jsx)(`button`,{type:`button`,"aria-label":e,onPointerDown:e=>v(e,()=>({kind:`trigger`,which:t})),...S,className:`${re} h-[44px] w-[84px]`,style:ie,children:oe(e,l[t]>0,n,!0)}),le=(e,t,n)=>ae(e,t,`h-[52px] w-[52px]`,(0,L.jsx)(`svg`,{viewBox:`0 0 52 52`,width:`52`,height:`52`,"aria-hidden":!0,style:ne,children:(0,L.jsxs)(`g`,{transform:`rotate(${n} 26 26)`,strokeWidth:`1.5`,strokeLinejoin:`round`,...w(ee(t)),children:[(0,L.jsx)(`path`,{d:`M10 9 Q10 3 16 3 L36 3 Q42 3 42 9 L42 30 Q42 34.5 38.5 38 L29.5 47 Q26 50.5 22.5 47 L13.5 38 Q10 34.5 10 30 Z`}),(0,L.jsx)(`path`,{d:`M20.5 23 L26 17 L31.5 23`,fill:`none`,stroke:`#fff`,strokeLinecap:`round`,strokeWidth:`1.8`})]})})),ue=(e,t,n)=>ae(e,t,`h-[52px] w-[52px]`,(0,L.jsxs)(`svg`,{viewBox:`0 0 52 52`,width:`52`,height:`52`,"aria-hidden":!0,style:ne,children:[(0,L.jsx)(`circle`,{cx:`26`,cy:`26`,r:`22.5`,strokeWidth:`1.5`,...w(ee(t))}),(0,L.jsx)(`g`,{fill:`none`,stroke:`#fff`,strokeWidth:`1.8`,strokeLinejoin:`round`,strokeLinecap:`round`,children:n})]})),de=(e,t)=>ae(e,t,`h-[44px] min-w-[64px] px-[4px]`,(0,L.jsx)(`span`,{className:`flex h-[24px] items-center rounded-full px-[10px] text-[10px] font-semibold uppercase tracking-wider ${C} ${te(ee(t))}`,children:e})),fe=(e,t)=>ae(e,t,`h-[44px] w-[44px]`,(0,L.jsx)(`span`,{className:`flex h-[36px] w-[36px] items-center justify-center rounded-full text-[11px] font-bold ${C} ${te(ee(t))}`,children:e})),pe=e=>{let{dx:t,dy:n}=yo(e===`l`?l.lx:l.rx,e===`l`?l.ly:l.ry,34),r=d[e];return(0,L.jsx)(`div`,{"aria-label":e===`l`?o(`rp_touch_left_stick`,void 0,`Left stick`):o(`rp_touch_right_stick`,void 0,`Right stick`),onPointerDown:t=>v(t,t=>{let n=t.getBoundingClientRect();return{kind:`stick`,which:e,cx:n.left+n.width/2,cy:n.top+n.height/2,radius:n.width/2}}),...S,className:`pointer-events-auto relative h-[124px] w-[124px] touch-none rounded-full border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.3)] transition-colors duration-75 ${r?`border-white/80 bg-white/[0.12]`:`border-white/45 bg-white/[0.05]`}`,children:(0,L.jsx)(`div`,{className:`absolute left-1/2 top-1/2 h-[54px] w-[54px] rounded-full ${te(r)}`,style:{transform:`translate(calc(-50% + ${t}px), calc(-50% + ${n}px))`}})})},E=t===`deck`,me=go(r,m.width,m.height,E),he=e=>`${e}px * var(--k)`,ge=`max(12px, env(safe-area-inset-left))`,ve=`max(12px, env(safe-area-inset-right))`,ye=`max(12px, env(safe-area-inset-bottom))`,be=E?`8px`:t===`overlay-bar`?`3.5rem`:`max(10px, env(safe-area-inset-top))`,xe=(e,t,n=0)=>t?n?`calc(${e} + max(${he(t)}, ${n}px))`:`calc(${e} + ${he(t)})`:e,Se=(e,t)=>({position:`absolute`,...t,transform:`scale(var(--k))`,transformOrigin:e}),Ce=E&&vo(me,m.height),D=E?void 0:`58%`,O=e=>E?{top:xe(be,Ce?96:112,Ce?72:90),[e]:e===`left`?ge:ve}:{top:D,translate:`0 -50%`,[e]:e===`left`?ge:ve},we=e=>({bottom:Ce?ye:xe(ye,E?56:0,44),[e]:Ce?`calc(${e===`left`?ge:ve} + 8px + max(${he(80)}, 44px))`:xe(e===`left`?ge:ve,E?40:168)}),Te=!!a&&!E;return(0,L.jsxs)(`div`,{ref:p,className:`pointer-events-none absolute z-10 select-none [-webkit-touch-callout:none] ${E?`inset-x-0 bottom-0`:`inset-0`}`,style:{top:E?i:void 0,"--k":me},"data-testid":`rp-touch`,"data-layout":t,"data-scale":me,onContextMenu:e=>e.preventDefault(),children:[(0,L.jsxs)(`div`,{className:`absolute inset-0`,style:{opacity:fo(n)},children:[(0,L.jsx)(`div`,{style:Se(`top left`,{top:be,left:ge}),children:(0,L.jsxs)(`div`,{className:`ms-[8px] flex flex-col`,style:{rotate:E?void 0:`6deg`,transformOrigin:`top left`},children:[ce(`L2`,`l2`,`l`),se(`L1`,F.L1,`l`,!1)]})}),(0,L.jsx)(`div`,{style:Se(`top right`,{top:be,right:ve}),children:(0,L.jsxs)(`div`,{className:`me-[8px] flex flex-col items-end`,style:{rotate:E?void 0:`-6deg`,transformOrigin:`top right`},children:[ce(`R2`,`r2`,`r`),se(`R1`,F.R1,`r`,!1)]})}),(0,L.jsx)(`div`,{"aria-label":o(`rp_touch_touchpad`,void 0,`Touchpad`),onPointerDown:e=>v(e,t=>({kind:`touchpad`,rect:t.getBoundingClientRect(),x0:e.clientX,y0:e.clientY,pressed:!0})),...S,className:`pointer-events-auto absolute touch-none rounded-2xl border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.3)] transition-colors duration-75 ${d.touchpad?`border-white/80 bg-white/25`:`border-white/40 bg-white/[0.05]`}`,style:E?{top:xe(be,6),left:xe(ge,104),right:xe(ve,104),height:`max(44px, calc(${he(64)}))`}:{top:be,left:`50%`,translate:`-50% 0`,width:`min(calc(${he(250)}), 34vw)`,height:`max(44px, calc(${he(56)}))`}}),(0,L.jsxs)(`div`,{className:`grid grid-cols-3 grid-rows-3`,style:Se(E?`top left`:`left center`,O(`left`)),children:[(0,L.jsx)(`span`,{}),le(`↑`,F.UP,0),(0,L.jsx)(`span`,{}),le(`←`,F.LEFT,-90),(0,L.jsx)(`span`,{}),le(`→`,F.RIGHT,90),(0,L.jsx)(`span`,{}),le(`↓`,F.DOWN,180),(0,L.jsx)(`span`,{})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-3 grid-rows-3`,style:Se(E?`top right`:`right center`,O(`right`)),children:[(0,L.jsx)(`span`,{}),ue(`△`,F.TRIANGLE,(0,L.jsx)(`path`,{d:`M26 16.5 L35 32 L17 32 Z`})),(0,L.jsx)(`span`,{}),ue(`□`,F.SQUARE,(0,L.jsx)(`rect`,{x:`18`,y:`18`,width:`16`,height:`16`,rx:`1`})),(0,L.jsx)(`span`,{}),ue(`○`,F.CIRCLE,(0,L.jsx)(`circle`,{cx:`26`,cy:`26`,r:`8.5`})),(0,L.jsx)(`span`,{}),ue(`✕`,F.CROSS,(0,L.jsx)(`path`,{d:`M19 19 L33 33 M33 19 L19 33`})),(0,L.jsx)(`span`,{})]}),(0,L.jsx)(`div`,{style:Se(`bottom left`,we(`left`)),children:pe(`l`)}),(0,L.jsx)(`div`,{style:Se(`bottom right`,we(`right`)),children:pe(`r`)}),(0,L.jsx)(`div`,{style:Se(`bottom left`,{bottom:ye,left:ge}),children:de(`Create`,F.SHARE)}),(0,L.jsx)(`div`,{style:Se(`bottom right`,{bottom:ye,right:ve}),children:de(`Options`,F.OPTIONS)}),(0,L.jsx)(`div`,{style:Se(`bottom center`,{bottom:Ce?xe(ye,124,88):xe(ye,Te?48:0,48),left:xo,translate:`-50% 0`}),children:fe(`PS`,F.PS)})]}),Te&&(0,L.jsx)(`div`,{style:{...Se(`bottom center`,{bottom:ye,left:`calc(50% + (env(safe-area-inset-left) - env(safe-area-inset-right)) / 2)`,translate:`-50% 0`}),opacity:Math.max(.7,fo(n))},children:(0,L.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a?.()},onDoubleClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),"aria-label":o(`rp_menu`,void 0,`Menu`),"aria-haspopup":`dialog`,className:`${re} h-[44px] w-[56px]`,style:ie,"data-testid":`rp-menu-handle`,children:(0,L.jsx)(`span`,{className:`flex h-[26px] w-[44px] items-center justify-center rounded-full ${C} ${te(!1)}`,children:(0,L.jsx)(_e,{size:15,strokeWidth:2,"aria-hidden":!0})})})})]})}var To=class{constructor(e,t=()=>1){this.sink=e,this.speed=t,this.fingers=new Map,this.most=0,this.moved=!1,this.gestureT0=0,this.lastTap=null,this.dragging=!1}down(e,t,n,r){if(!this.fingers.size){this.most=0,this.moved=!1,this.gestureT0=r;let e=this.lastTap;e&&r-e.t<=300&&Math.hypot(t-e.x,n-e.y)<=40&&(this.dragging=!0,this.sink.button(0,!0)),this.lastTap=null}this.fingers.set(e,{x:t,y:n,x0:t,y0:n,t0:r}),this.most=Math.max(this.most,this.fingers.size)}move(e,t,n){let r=this.fingers.get(e);if(!r)return;let i=t-r.x,a=n-r.y;if(r.x=t,r.y=n,!this.moved&&Math.hypot(t-r.x0,n-r.y0)>10&&(this.moved=!0),!this.moved)return;if(this.fingers.size>=2){if(this.dragging)return;let e=this.fingers.size;this.sink.scroll(-a/e,-i/e);return}if(this.most>=2)return;let o=this.speed();this.sink.move(i*o,a*o)}up(e,t){let n=this.fingers.get(e);if(!n||(this.fingers.delete(e),this.fingers.size))return;if(this.dragging){this.dragging=!1,this.sink.button(0,!1);return}let r=t-this.gestureT0<=250+(this.most>=2?150:0);if(this.moved||!r)return;let i=this.most>=2?2:0;this.sink.button(i,!0),this.sink.button(i,!1),i===0&&(this.lastTap={t,x:n.x,y:n.y})}cancel(){this.fingers.clear(),this.lastTap=null,this.dragging&&(this.dragging=!1,this.sink.button(0,!1))}},Eo={" ":`Space`,"-":`Minus`,"=":`Equal`,"[":`BracketLeft`,"]":`BracketRight`,"\\":`Backslash`,";":`Semicolon`,"'":`Quote`,"`":`Backquote`,",":`Comma`,".":`Period`,"/":`Slash`,"\n":`Enter`,"\r":`Enter`," ":`Tab`},Do={"!":`Digit1`,"@":`Digit2`,"#":`Digit3`,$:`Digit4`,"%":`Digit5`,"^":`Digit6`,"&":`Digit7`,"*":`Digit8`,"(":`Digit9`,")":`Digit0`,_:`Minus`,"+":`Equal`,"{":`BracketLeft`,"}":`BracketRight`,"|":`Backslash`,":":`Semicolon`,'"':`Quote`,"~":`Backquote`,"<":`Comma`,">":`Period`,"?":`Slash`};function Oo(e){return e.length===1?e>=`a`&&e<=`z`?{code:`Key${e.toUpperCase()}`,shift:!1}:e>=`A`&&e<=`Z`?{code:`Key${e}`,shift:!0}:e>=`0`&&e<=`9`?{code:`Digit${e}`,shift:!1}:Eo[e]?{code:Eo[e],shift:!1}:Do[e]?{code:Do[e],shift:!0}:null:null}var ko={Backspace:`Backspace`,Enter:`Enter`,Tab:`Tab`,Escape:`Escape`,Delete:`Delete`,ArrowUp:`ArrowUp`,ArrowDown:`ArrowDown`,ArrowLeft:`ArrowLeft`,ArrowRight:`ArrowRight`,Home:`Home`,End:`End`,PageUp:`PageUp`,PageDown:`PageDown`};function Ao(e){return ko[e]??null}function jo(e,t){let n=``;for(let r of t){let t=Oo(r);t?Mo(e,t.code,t.shift):n+=r}return n}function Mo(e,t,n=!1){let r=n&&!e.shiftHeld?.();r&&e.key(`ShiftLeft`,!0),e.key(t,!0),e.key(t,!1),r&&e.key(`ShiftLeft`,!1)}function No(e,t){let n=[...e],r=[...t],i=0;for(;i{o.current=e,s.current=t});let c=(0,T.useRef)(null),l=()=>c.current??=new To({move:(e,t)=>o.current?.move(e,t),button:(e,t)=>o.current?.button(e,t),scroll:(e,t)=>o.current?.scroll(e,t)},()=>s.current);(0,T.useEffect)(()=>()=>c.current?.cancel(),[]);let u=e=>e.stopPropagation();return(0,L.jsx)(`div`,{className:`touch-none select-none [-webkit-touch-callout:none] ${n}`,style:r,"data-testid":a,onPointerDown:e=>{u(e);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}l().down(e.pointerId,e.clientX,e.clientY,e.timeStamp)},onPointerMove:e=>{u(e),l().move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{u(e),l().up(e.pointerId,e.timeStamp)},onPointerCancel:e=>{u(e),l().cancel()},onClick:u,onDoubleClick:u,onContextMenu:e=>{e.preventDefault(),u(e)},children:i})}var R=` `,Fo=40;function Io({sink:e,onUntypeable:t,className:n=``}){let r=Tn(),i=(0,T.useRef)(null),a=(0,T.useRef)(R),o=(0,T.useRef)(!1),[s,c]=(0,T.useState)(!1),[l,u]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(!l)return;let e=window.setTimeout(()=>u(!1),3e3);return()=>window.clearTimeout(e)},[l]);let d=()=>{let e=i.current;e&&!o.current&&(!e.value.startsWith(R)||e.value.length>Fo)&&(e.value=R,a.current=R)},f=()=>{let n=i.current;if(!n||!e)return;let{deleted:r,inserted:o}=No(a.current,n.value);a.current=n.value;for(let t=0;te.stopPropagation(),onClick:e=>{e.stopPropagation();let t=i.current;t&&(s?t.blur():(t.value=R,a.current=R,t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length)))},className:`flex h-11 w-11 items-center justify-center rounded-full border border-white/25 bg-black/45 text-white backdrop-blur-sm disabled:opacity-40 ${s?`bg-white/30`:``} ${n}`,"data-testid":`rp-tp-keyboard`,children:(0,L.jsx)(he,{size:18,"aria-hidden":!0})}),(0,L.jsx)(`input`,{ref:i,type:`text`,defaultValue:R,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,enterKeyHint:`send`,"aria-label":r(`rp_tp_keyboard`,void 0,`Keyboard`),className:`pointer-events-none fixed bottom-0 left-1/2 h-px w-px opacity-0`,"data-testid":`rp-tp-keyboard-input`,"data-rp-typing":``,onFocus:()=>c(!0),onBlur:()=>c(!1),onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onKeyDown:t=>{if(t.stopPropagation(),!e||t.nativeEvent.isComposing)return;let n=Ao(t.key);n&&(t.preventDefault(),Mo(e,n))},onKeyUp:e=>e.stopPropagation(),onCompositionStart:()=>{o.current=!0},onCompositionEnd:()=>{o.current=!1,f()},onInput:f}),l&&(0,L.jsx)(`div`,{className:`pointer-events-none fixed bottom-20 left-1/2 z-[300] w-max max-w-[min(22rem,calc(100%-2rem))] -translate-x-1/2 rounded-full bg-black/80 px-3 py-1.5 text-center text-xs text-white`,"data-testid":`rp-tp-untypeable`,children:r(`rp_tp_untypeable`,void 0,`Only English letters, numbers and symbols can be typed here. Use a text field on the PS5 for others.`)})]})}function Lo({mode:e,onChange:t,blocked:n,style:r,touchpadLabel:i,tight:a=!1,hidden:o=!1}){let s=Tn(),c=(r,i,o)=>{let s=r===`touchpad`&&!!n;return(0,L.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===r,"aria-disabled":s||void 0,"aria-label":a&&e!==r?o:void 0,title:s?n:o,onClick:e=>{e.stopPropagation(),s||t(r)},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),className:`flex h-8 items-center gap-1 rounded-full px-2.5 text-xs ${e===r?`bg-white text-black`:`text-white`} ${s?`opacity-40`:``}`,"data-testid":`rp-touch-mode-${r}`,children:[i,(!a||e===r)&&(0,L.jsx)(`span`,{children:o})]})};return(0,L.jsxs)(`div`,{role:`radiogroup`,"aria-label":s(`rp_tp_mode`,void 0,`Touch controls`),"aria-hidden":o||void 0,className:`absolute left-1/2 z-30 flex -translate-x-1/2 gap-0.5 rounded-full border border-white/20 bg-black/50 p-0.5 backdrop-blur-sm transition-opacity duration-200 ${o?`pointer-events-none opacity-0`:`pointer-events-auto opacity-100`}`,style:r,"data-testid":`rp-touch-mode`,children:[c(`controller`,(0,L.jsx)(E,{size:14,"aria-hidden":!0}),s(`rp_kbm_controller`,void 0,`Controller`)),c(`touchpad`,(0,L.jsx)(ye,{size:14,"aria-hidden":!0}),i??s(`rp_tp_touchpad`,void 0,`Touchpad`))]})}var Ro={0:1,2:2,1:4,3:8,4:16},zo={ControlLeft:1,ShiftLeft:2,AltLeft:4,MetaLeft:8,OSLeft:8,ControlRight:16,ShiftRight:32,AltRight:64,MetaRight:128,OSRight:128};function Bo(){let e={};for(let t=0;t<26;t++)e[`Key${String.fromCharCode(65+t)}`]=4+t;for(let t=1;t<=9;t++)e[`Digit${t}`]=30+t-1;e.Digit0=39,Object.assign(e,{Enter:40,Escape:41,Backspace:42,Tab:43,Space:44,Minus:45,Equal:46,BracketLeft:47,BracketRight:48,Backslash:49,IntlHash:50,Semicolon:51,Quote:52,Backquote:53,Comma:54,Period:55,Slash:56,CapsLock:57,PrintScreen:70,ScrollLock:71,Pause:72,Insert:73,Home:74,PageUp:75,Delete:76,End:77,PageDown:78,ArrowRight:79,ArrowLeft:80,ArrowDown:81,ArrowUp:82,NumLock:83,NumpadDivide:84,NumpadMultiply:85,NumpadSubtract:86,NumpadAdd:87,NumpadEnter:88,NumpadDecimal:99,IntlBackslash:100,ContextMenu:101,NumpadEqual:103,IntlRo:135,KanaMode:136,IntlYen:137,Convert:138,NonConvert:139,Lang1:144,Lang2:145});for(let t=1;t<=9;t++)e[`Numpad${t}`]=89+t-1;e.Numpad0=98;for(let t=1;t<=12;t++)e[`F${t}`]=58+t-1;for(let t=13;t<=24;t++)e[`F${t}`]=104+t-13;return e}var Vo=Bo(),Ho=(e,t,n)=>Math.max(t,Math.min(n,Math.trunc(e)));function Uo(e,t=0,n=0,r=0,i=0){let a=new Uint8Array(17),o=new DataView(a.buffer);return a[0]=8,a[1]=e.buttons&255,a[2]=e.mods&255,o.setInt16(3,Ho(t,-32768,32767),!0),o.setInt16(5,Ho(n,-32768,32767),!0),o.setInt8(7,Ho(r,-128,127)),o.setInt8(8,Ho(i,-128,127)),e.keys.slice(0,8).forEach((e,t)=>a[9+t]=e&255),a}function Wo(e){let t={buttons:0,mods:0,keys:[]};for(let n of e){t.buttons|=n.buttons,t.mods|=n.mods;for(let e of n.keys)!t.keys.includes(e)&&t.keys.length<8&&t.keys.push(e)}return t}function z(e,t,n){let r=e+t/(n===1?3:n===2?1:100),i=Math.trunc(r);return{notches:-i,carry:r-i}}var B=class{constructor(e){this.st={buttons:0,mods:0,keys:[]},this.dx=0,this.dy=0,this.wheel=0,this.hwheel=0,this.wheelCarry=0,this.hwheelCarry=0,this.moveTimer=null,this.hb=null,this.want={mouse:!1,keyboard:!1},this.guests=new Map,this.d={setTimer:(e,t)=>window.setTimeout(e,t),clearTimer:e=>window.clearTimeout(e),setRepeat:(e,t)=>window.setInterval(e,t),clearRepeat:e=>window.clearInterval(e),...e}}get state(){return this.st}shiftHeld(){return(this.st.mods&(zo.ShiftLeft|zo.ShiftRight))!==0}get holding(){return this.st.buttons!==0||this.st.mods!==0||this.st.keys.length>0}setWant(e){let t=e.mouse||e.keyboard,n=e.mouse!==this.want.mouse||e.keyboard!==this.want.keyboard;this.want={...e},n&&(this.hb!==null&&this.d.clearRepeat(this.hb),this.hb=null,this.beat(),t&&(this.hb=this.d.setRepeat(()=>this.beat(),500)))}get wanted(){return this.want}beat(){let e=this.want.mouse||this.want.keyboard;this.d.send({kbm:e?{on:!0,mouse:this.want.mouse,keyboard:this.want.keyboard}:{on:!1}})}key(e,t){let n=zo[e];if(n){let e=t?this.st.mods|n:this.st.mods&~n;return e!==this.st.mods&&(this.st={...this.st,mods:e},this.flush()),!0}let r=Vo[e];if(!r)return!1;let i=this.st.keys.includes(r);return t&&!i&&this.st.keys.length<8?(this.st={...this.st,keys:[...this.st.keys,r]},this.flush()):!t&&i&&(this.st={...this.st,keys:this.st.keys.filter(e=>e!==r)},this.flush()),!0}button(e,t){let n=Ro[e];if(!n)return;let r=t?this.st.buttons|n:this.st.buttons&~n;r!==this.st.buttons&&(this.st={...this.st,buttons:r},this.flush())}guest(e,t){if(t)this.guests.set(e,{buttons:t.buttons,mods:t.mods,keys:t.keys.slice(0,8)});else if(!this.guests.delete(e))return;this.flush()}guestMotion(e,t,n,r){this.dx+=e,this.dy+=t,this.wheel+=n,this.hwheel+=r,(e||t||n||r)&&this.later()}get guestIds(){return[...this.guests.keys()]}move(e,t){this.dx+=e,this.dy+=t,this.later()}scroll(e,t,n){let r=z(this.wheelCarry,e,n),i=z(this.hwheelCarry,t,n);this.wheelCarry=r.carry,this.hwheelCarry=i.carry,this.wheel+=r.notches,this.hwheel-=i.notches,(this.wheel||this.hwheel)&&this.later()}later(){this.moveTimer===null&&(this.moveTimer=this.d.setTimer(()=>this.flush(),4))}flush(){this.moveTimer!==null&&this.d.clearTimer(this.moveTimer),this.moveTimer=null;let e=this.guests.size?Wo([this.st,...this.guests.values()]):this.st;do{let t=Ho(this.dx,-32768,32767),n=Ho(this.dy,-32768,32767),r=Ho(this.wheel,-128,127),i=Ho(this.hwheel,-128,127);this.dx-=t,this.dy-=n,this.wheel-=r,this.hwheel-=i,this.d.send(Uo(e,t,n,r,i))}while(Math.abs(this.dx)>=1||Math.abs(this.dy)>=1||this.wheel||this.hwheel)}releaseAll(){this.dx=this.dy=this.wheel=this.hwheel=0,this.wheelCarry=this.hwheelCarry=0;let e=this.holding;this.st={buttons:0,mods:0,keys:[]},this.moveTimer!==null&&this.d.clearTimer(this.moveTimer),this.moveTimer=null,e&&this.d.send(Uo(this.guests.size?Wo(this.guests.values()):this.st))}dispose(){this.guests.clear(),this.releaseAll(),this.setWant({mouse:!1,keyboard:!1})}},Go=`data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAYZbW9vdgAAAGxtdmhkAAAAAAAAAAAAAAAAAAAfQAAAfQAAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAmt0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAABAAAAAAAAfQAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAABAAAAAQAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAH0AAAAAAAABAAAAAAHjbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAABAAAABAABVxAAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAABjm1pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAU5zdGJsAAAAunN0c2QAAAAAAAAAAQAAAKphdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAABAAEABIAAAASAAAAAAAAAABFExhdmM2My4xLjEwMiBsaWJ4MjY0AAAAAAAAAAAAAAAAGP//AAAAMGF2Y0MBQsAK/+EAF2dCwAqmEXsBEAAAAwAQAAADACDxImEYAQAGaMhCAZSyAAAAEHBhc3AAAAABAAAAAQAAABRidHJ0AAAAAAAABUAAAAAAAAAAGHN0dHMAAAAAAAAAAQAAAAQAAEAAAAAAFHN0c3MAAAAAAAAAAQAAAAEAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAJHN0c3oAAAAAAAAAAAAAAAQAAAKCAAAACgAAAAoAAAAKAAAAIHN0Y28AAAAAAAAABAAABlwAAAj+AAAJKAAACVIAAALZdHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAH0AAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAB9AAAABAAAAQAAAAACUW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAH0AAAIEAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAfxtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAcBzdGJsAAAAfnN0c2QAAAAAAAAAAQAAAG5tcDRhAAAAAAAAAAEAAAAAAAAAAAABABAAAAAAH0AAAAAAADZlc2RzAAAAAAOAgIAlAAIABICAgBdAFQAAAAAAH0AAAAEcBYCAgAUViFblAAaAgIABAgAAABRidHJ0AAAAAAAAH0AAAAEcAAAAIHN0dHMAAAAAAAAAAgAAACAAAAQAAAAAAQAAAQAAAAAoc3RzYwAAAAAAAAACAAAAAQAAAAEAAAABAAAAAgAAAAgAAAABAAAAmHN0c3oAAAAAAAAAAAAAACEAAAATAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAkc3RjbwAAAAAAAAAFAAAGSQAACN4AAAkIAAAJMgAACVwAAAAac2dwZAEAAAByb2xsAAAAAgAAAAH//wAAABxzYmdwAAAAAHJvbGwAAAABAAAAIQAAAAEAAABhdWR0YQAAAFltZXRhAAAAAAAAACFoZGxyAAAAAAAAAABtZGlyYXBwbAAAAAAAAAAAAAAAACxpbHN0AAAAJKl0b28AAAAcZGF0YQAAAAEAAAAATGF2ZjYzLjEuMTAyAAAACGZyZWUAAAM7bWRhdNwATGF2YzYzLjEuMTAyAAIwQA4AAAJvBgX//2vcRem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY1IHIzMjIyIGIzNTYwNWEgLSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDI1IC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9uczogY2FiYWM9MCByZWY9MTYgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDEzMSBtZT11bWggc3VibWU9MTAgcHN5PTEgcHN5X3JkPTEuMDA6MC4wMCBtaXhlZF9yZWY9MSBtZV9yYW5nZT0yNCBjaHJvbWFfbWU9MSB0cmVsbGlzPTIgOHg4ZGN0PTAgY3FtPTAgZGVhZHpvbmU9MjEsMTEgZmFzdF9wc2tpcD0xIGNocm9tYV9xcF9vZmZzZXQ9LTIgdGhyZWFkcz0xIGxvb2thaGVhZF90aHJlYWRzPTEgc2xpY2VkX3RocmVhZHM9MCBucj0wIGRlY2ltYXRlPTEgaW50ZXJsYWNlZD0wIGJsdXJheV9jb21wYXQ9MCBjb25zdHJhaW5lZF9pbnRyYT0wIGJmcmFtZXM9MCB3ZWlnaHRwPTAga2V5aW50PTQga2V5aW50X21pbj0xIHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NCByYz1jcmYgbWJ0cmVlPTEgY3JmPTUxLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAAALZYiCAv5MUAAQv8ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmhwF/UABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmioBb1ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmjsBX1ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBw==`,Ko=null,qo=null;function Jo(e){e.play().catch(()=>{if(qo||Ko!==e)return;let t=()=>{Yo(),Ko===e&&e.play().catch(()=>{})};window.addEventListener(`pointerdown`,t,{capture:!0}),qo=()=>window.removeEventListener(`pointerdown`,t,{capture:!0})})}function Yo(){qo?.(),qo=null}function Xo(){if(typeof document<`u`){if(!Ko){let e=document.createElement(`video`);e.muted=!0,e.loop=!0,e.playsInline=!0,e.setAttribute(`playsinline`,``),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-testid`,`keep-screen-video`),e.style.cssText=`position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none`,e.src=Go,document.body.appendChild(e),Ko=e}Jo(Ko)}}function Zo(){Yo(),Ko&&=(Ko.pause(),Ko.removeAttribute(`src`),Ko.remove(),null)}function Qo(){return typeof navigator>`u`?null:navigator.wakeLock??null}function V(){return Te()||!gn()}var $o=new Set,es=null,ts=Promise.resolve(),ns=!1;async function rs(){if($o.size===0||es&&!es.released)return;let e=Qo();if(!e)Te()&&Xo();else try{let t=await e.request(`screen`);t.addEventListener(`release`,()=>{es===t&&(es=null)}),es=t}catch{}}async function is(){Zo();let e=es;if(es=null,e&&!e.released)try{await e.release()}catch{}}function as(){ns||typeof document>`u`||(ns=!0,document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&$o.size>0&&(ts=ts.then(rs))}))}function os(e,t){if(!V())return;as();let n=$o.size>0;t?$o.add(e):$o.delete(e);let r=$o.size>0;n!==r&&(ts=ts.then(r?rs:is))}var ss=new Set;function cs(){if(typeof window<`u`)return window.PS5UploadPad}function ls(e,t){let n=ss.size>0;t?ss.add(e):ss.delete(e);let r=ss.size>0;if(n!==r)try{cs()?.setActive(r)}catch{}}function us(e,t){let[n,r]=(0,T.useState)(!1);return(0,T.useEffect)(()=>{if(!e||!t)return;let n=!0;return Pe(e,je).then(e=>{n&&!e&&r(!0)}),()=>{n=!1}},[e,t]),n}function ds({href:e}){let t=Tn();return(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,"data-testid":`open-on-wifi`,children:[(0,L.jsx)(`p`,{className:`max-w-sm text-sm text-white/60`,children:t(`join_open_lan_body`,void 0,`Can't reach the internet? If you're on the same Wi-Fi as your friend, open the game there.`)}),(0,L.jsx)(`a`,{href:e,rel:`noreferrer`,className:`rounded-full bg-white px-4 py-2 text-sm font-medium text-black`,"data-testid":`open-on-wifi-link`,children:t(`join_open_lan`,void 0,`Open on this Wi-Fi`)})]})}function fs(e,t,n){switch(t.kind){case`connecting`:return e(`pad_connecting`,void 0,`Connecting…`);case`asking`:return e(`pad_asking`,{name:n},`Waiting for ${n} to allow this phone…`);case`joined`:return t.host?t.passcode&&!t.playing?e(`pad_wait_passcode`,{name:n},`Waiting for the passcode on ${n}`):t.playing?e(`pad_playing`,{host:t.host},`Controller for ${t.host}`):e(`pad_starting`,void 0,`Connected. The stream is starting…`):e(`pad_no_session`,void 0,`Connected. Waiting for Remote Play to start on the computer.`);case`refused`:return t.why===`denied`?e(`pad_denied`,void 0,`The computer said no.`):t.why===`no_answer`?e(`pad_no_answer`,void 0,`The computer didn't answer in time. Try again.`):t.why===`kicked`?e(`pad_kicked`,void 0,`The computer took this phone out of the game.`):t.why===`closed`?e(`pad_link_closed`,void 0,`The computer closed the link. Scan the new code to play again.`):t.why===`key`?e(`pad_old_code`,void 0,`This code has expired. Scan the new one on the computer.`):t.why===`full`?e(`pad_full`,void 0,`Four phones are playing already.`):t.why===`no_stream`?e(`pad_watch_no_stream`,void 0,`Nothing is streaming on the computer right now.`):t.why.startsWith(`net:`)?ps(e,t.why.slice(4)):e(`pad_refused`,void 0,`The computer did not let this phone in.`);case`reconnecting`:return e(`pad_reconnecting`,void 0,`Connection lost. Reconnecting…`);case`lost`:return e(`pad_lost`,void 0,`Lost the connection to the computer.`)}}function ps(e,t){switch(t){case`mismatch`:return e(`join_net_mismatch`,void 0,`This link doesn't match the host; ask them for a new one.`);case`no_direct`:return e(`join_net_no_direct`,void 0,`A direct connection isn't possible from this network (both sides' routers are strict). Try Wi-Fi instead of mobile data, or ask the host to turn on UPnP.`);case`no_room`:return e(`pad_old_code`,void 0,`This code has expired. Scan the new one on the computer.`);case`net_full`:return e(`pad_full`,void 0,`Four phones are playing already.`);case`no_hub`:return e(`join_net_no_hub`,void 0,`Couldn't reach the PS5Upload invite service. Check your internet connection, then try again.`);case`offer`:case`no_webrtc`:return e(`join_net_no_webrtc`,void 0,`This browser can't make direct connections. Try a recent Chrome, Safari or Firefox.`);default:return e(`pad_lost`,void 0,`Lost the connection to the computer.`)}}function ms(e){return e.kind!==`refused`||e.why!==`kicked`&&e.why!==`closed`}async function hs(){try{await document.documentElement.requestFullscreen?.({navigationUI:`hide`}),await screen.orientation.lock?.(`landscape`)}catch{}}function gs(e,t){return t?.mouse?null:t?.reason===`vinput_helper_old`||t?.reason===`helper_old`?e(`rp_kbm_helper_old`,void 0,`Update the PS5 helper to use a keyboard and mouse.`):t?.reason===`vinput_needs_loader`?e(`rp_kbm_needs_loader`,void 0,`Needs a payload loader on port 9021`):e(`rp_kbm_unavailable`,void 0,`Native keyboard & mouse isn't available on this console yet.`)}function _s({client:e,caps:t}){let n=Tn(),r=(0,T.useMemo)(()=>new B({send:t=>e.sendKbm(t)}),[e]);(0,T.useEffect)(()=>{r.setWant({mouse:!0,keyboard:t.keyboard})},[r,t.keyboard]),(0,T.useEffect)(()=>()=>r.dispose(),[r]);let i=(0,T.useMemo)(()=>({move:(e,t)=>r.move(e,t),button:(e,t)=>r.button(e,t),scroll:(e,t)=>r.scroll(e,t,0),key:(e,t)=>r.key(e,t),shiftHeld:()=>r.shiftHeld()}),[r]);return(0,L.jsxs)(Po,{sink:i,speed:1.5,className:`absolute inset-0 z-10`,testId:`pad-touchpad`,children:[(0,L.jsx)(`p`,{className:`pointer-events-none absolute inset-x-6 top-1/2 -translate-y-1/2 text-center text-xs leading-5 text-white/50`,children:n(`rp_tp_tips`,void 0,`Drag to move. Tap to click. Two fingers: tap to right-click, drag to scroll. Tap, then touch and drag to select.`)}),(0,L.jsx)(`div`,{className:`absolute`,style:{right:`max(12px, env(safe-area-inset-right))`,bottom:`max(12px, env(safe-area-inset-bottom))`},children:(0,L.jsx)(Io,{sink:t.keyboard?i:null})})]})}function vs({url:e,computer:t,onLeave:n,watch:r=!1,transport:i,hello:a,onReconnectToken:o,lanUrl:s=null}){let c=Tn(),l=us(i?e:null,s),u=t??c(`pad_net_computer`,void 0,`the computer`),[d,f]=(0,T.useState)({kind:`connecting`}),[p,m]=(0,T.useState)(0),[h,g]=(0,T.useState)(()=>typeof window<`u`&&window.innerHeight>window.innerWidth),[_,v]=(0,T.useState)(null),[y,b]=(0,T.useState)(null),[x,S]=(0,T.useState)(!1),ee=(0,T.useRef)(null),te=(0,T.useRef)(null),[C,ne]=(0,T.useState)(!r),[w,re]=(0,T.useState)(null),[ie,ae]=(0,T.useState)(!1),[oe,se]=(0,T.useState)(null),[ce,le]=(0,T.useState)(`controller`);(0,T.useEffect)(()=>(os(`pad-remote`,!0),ls(`pad-remote`,!0),()=>{os(`pad-remote`,!1),ls(`pad-remote`,!1)}),[]),(0,T.useEffect)(()=>{if(!x)return;let e=Ae(e=>{co.motion=e});return()=>{e(),co.motion=null}},[x]),(0,T.useEffect)(()=>{let t=r?Zi(re,`watch`,()=>n.askKeyframe()):null;ee.current=t,t&&te.current?.appendChild(t.element),ne(!r),ae(!1);let n=new io({url:e,WebSocketImpl:i,hello:a,onReconnectToken:o,onStage:f,touchPad:()=>co.touchPad,onLight:v,onKbmCaps:se,motion:()=>co.motion,watch:t?{onFrame:e=>t.onMessage(e),onCodec:e=>t.setHevc(e),onControl:ne}:void 0});b(n),n.start();let s=()=>{let e=document.visibilityState===`hidden`;n.setNeutral(e),e||n.wake()},c=()=>n.setNeutral(!0);return document.addEventListener(`visibilitychange`,s),window.addEventListener(`blur`,c),window.addEventListener(`focus`,s),()=>{document.removeEventListener(`visibilitychange`,s),window.removeEventListener(`blur`,c),window.removeEventListener(`focus`,s),n.stop(),t?.stop(),t?.element.remove()}},[e,p,r]),(0,T.useEffect)(()=>{let e=()=>g(window.innerHeight>window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let ue=d.kind===`refused`||d.kind===`lost`,de=d.kind===`joined`||d.kind===`reconnecting`,pe=!!s&&!de&&(l||d.kind===`refused`&&d.why===`net:no_hub`);return(0,L.jsxs)(`div`,{className:`fixed inset-0 select-none overflow-hidden bg-black text-white [-webkit-touch-callout:none]`,style:{touchAction:`none`},"data-testid":`pad-app`,children:[(0,L.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-20 flex items-center justify-center gap-2 px-3 pt-[max(6px,env(safe-area-inset-top))] text-xs text-white/80`,children:[(0,L.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full`,style:{background:d.kind===`joined`?_?`rgb(${_[0]},${_[1]},${_[2]})`:`var(--color-success,#22c55e)`:ue?`var(--color-bad,#ef4444)`:`#eab308`}}),(0,L.jsx)(`span`,{className:`truncate`,"data-testid":`pad-stage`,children:r&&d.kind===`joined`&&d.host&&(!d.passcode||d.playing)?C?c(`pad_watch_control`,void 0,`Watching, and you have the controller`):c(`pad_watch_watching`,{host:d.host},`Watching ${d.host}`):fs(c,d,u)}),de&&typeof document<`u`&&!!document.documentElement.requestFullscreen&&!document.fullscreenElement&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>void hs(),className:`flex items-center gap-1 rounded-full bg-white/15 px-2 py-1`,"data-testid":`pad-full`,children:[(0,L.jsx)(fe,{size:12}),c(`pad_fill`,void 0,`Full screen`)]}),de&&k()&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{x?S(!1):ke().then(S)},"aria-pressed":x,className:`rounded-full px-2 py-1 ${x?`bg-white text-black`:`bg-white/15`}`,"data-testid":`pad-motion`,children:c(`pad_motion`,void 0,`Motion`)}),n&&(0,L.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full bg-white/15 px-2 py-1`,"data-testid":`pad-leave`,children:c(`pad_leave`,void 0,`Stop being a controller`)})]}),(0,L.jsx)(`div`,{ref:te,className:`absolute inset-0 z-0 flex items-center justify-center`,"aria-hidden":!0}),r&&de&&!ie&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{ee.current?.startSound(),ae(!0)},className:`absolute bottom-4 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1.5 rounded-full bg-white/90 px-3 py-1.5 text-xs font-medium text-black`,"data-testid":`watch-sound`,children:[(0,L.jsx)(Ce,{size:14}),c(`pad_watch_sound`,void 0,`Sound`)]}),r&&w&&(0,L.jsx)(`p`,{className:`absolute inset-x-4 top-1/2 z-10 -translate-y-1/2 text-center text-sm text-white/85`,"data-testid":`watch-problem`,children:w===`no_hevc`?c(`pad_watch_no_hevc`,void 0,`This device can't play this stream's picture: the computer streams HEVC, and this device plays only H.264.`):c(`pad_watch_decode`,void 0,`The picture could not be played here.`)}),de&&C&&(ce===`touchpad`&&oe?.mouse&&y?(0,L.jsx)(_s,{client:y,caps:oe}):(0,L.jsx)(wo,{stream:y,layout:`overlay`})),de&&C&&(0,L.jsx)(Lo,{mode:ce===`touchpad`&&oe?.mouse?`touchpad`:`controller`,onChange:le,blocked:gs(c,oe),touchpadLabel:c(`pad_touchpad_tab`,void 0,`Touchpad & keyboard`),style:{top:`calc(max(6px, env(safe-area-inset-top)) + 2rem)`}}),de&&h&&(0,L.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-6 z-20 flex justify-center`,children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2 rounded-full bg-black/70 px-3 py-1.5 text-xs text-white/85`,children:[(0,L.jsx)(xe,{size:14}),c(`pad_turn`,void 0,`Turn the phone sideways`)]})}),pe&&!ue&&s&&(0,L.jsx)(`div`,{className:`absolute inset-x-0 bottom-8 z-10 flex justify-center px-6`,children:(0,L.jsx)(ds,{href:s})}),ue&&(0,L.jsxs)(`div`,{className:`absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 px-6 text-center text-sm`,children:[(0,L.jsx)(`p`,{className:`max-w-sm text-white/85`,children:fs(c,d,u)}),pe&&s&&(0,L.jsx)(ds,{href:s}),ms(d)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>m(e=>e+1),className:`rounded-full bg-white px-4 py-2 text-sm font-medium text-black`,"data-testid":`pad-retry`,children:c(`pad_retry`,void 0,`Try again`)})]})]})}var ys=`ps5upload.openIn`,bs=`ps5upload.openIn.tab`;function xs(){try{return sessionStorage.getItem(bs)===`browser`}catch{return!1}}function Ss(){try{sessionStorage.setItem(bs,`browser`)}catch{}}function Cs(e){return e===`browser`?`browser`:e===`app`?`opening`:`ask`}function ws({appLink:e,children:t}){let n=Tn(),[r,i]=(0,T.useState)(()=>xs()?`browser`:Cs(yt(ys))),[a,o]=(0,T.useState)(!1);if((0,T.useEffect)(()=>{r===`opening`&&yt(`ps5upload.openIn`)===`app`&&(location.href=e)},[]),r===`browser`)return(0,L.jsx)(L.Fragment,{children:t});let s=()=>{a&&vt(ys,`app`),i(`opening`),location.href=e},c=()=>{r===`ask`&&a?vt(ys,`browser`):r===`opening`&&yt(`ps5upload.openIn`)===`app`&&bt(ys),Ss(),i(`browser`)};return(0,L.jsx)(`div`,{className:`flex min-h-[100dvh] items-center justify-center bg-black px-6 text-white`,"data-testid":`open-in-gate`,children:(0,L.jsx)(`div`,{className:`w-full max-w-sm space-y-4 rounded-2xl border border-white/10 bg-neutral-900 p-6`,children:r===`ask`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`open_in_title`,void 0,`Open in the PS5Upload app?`)}),(0,L.jsx)(`p`,{className:`text-sm text-white/60`,children:n(`open_in_body`,void 0,`Have the PS5Upload app on this device? Open this there, or carry on in the browser.`)})]}),(0,L.jsx)(`button`,{type:`button`,onClick:s,className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black`,"data-testid":`open-in-app`,children:n(`open_in_app`,void 0,`Open in the app`)}),(0,L.jsx)(`button`,{type:`button`,onClick:c,className:`w-full rounded-full border border-white/20 py-2.5 text-sm font-semibold text-white hover:bg-white/10`,"data-testid":`open-in-browser`,children:n(`open_in_browser`,void 0,`Continue in browser`)}),(0,L.jsxs)(`label`,{className:`flex items-center justify-center gap-2 text-xs text-white/60`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),"data-testid":`open-in-remember`}),n(`open_in_remember`,void 0,`Remember my choice on this device`)]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`open_in_opening`,void 0,`Opening the PS5Upload app…`)}),(0,L.jsx)(`p`,{className:`text-sm text-white/60`,children:n(`open_in_not_opened`,void 0,`Nothing happened? The app may not be on this device.`)})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>location.href=e,className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black`,"data-testid":`open-in-again`,children:n(`open_in_again`,void 0,`Try again`)}),(0,L.jsx)(`button`,{type:`button`,onClick:c,className:`w-full rounded-full border border-white/20 py-2.5 text-sm font-semibold text-white hover:bg-white/10`,"data-testid":`open-in-browser`,children:n(`open_in_browser`,void 0,`Continue in browser`)})]})})})}function Ts(e){return`ps5upload://pad?link=${encodeURIComponent(e)}`}function Es(e){let t=(e??``).trim().replace(/^\[|\]$/g,``).toLowerCase(),n=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(t);if(n){let e=n.slice(1).map(Number);if(e.some(e=>e>255))return null;let[t,r]=e;return t===10||t===172&&r>=16&&r<32||t===192&&r===168||t===169&&r===254||t===127?0:t===100&&r>=64&&r<128?1:2}if(!t.includes(`:`)||!/^[0-9a-f:.]+$/.test(t))return null;if(t.startsWith(`fd7a:115c:a1e0:`))return 1;let r=parseInt(t.split(`:`)[0]||`0`,16);return(r&65024)==64512||(r&65472)==65152||t===`::1`?0:2}function Ds(e,t){let n=Es(e),r=Es(t);return n===1||r===1?`tailscale`:r===0?`lan`:r===2?`internet`:null}function Os(e){let t=[];if(typeof e.forEach==`function`)e.forEach(e=>t.push(e));else for(let n of e)t.push(n);let n=new Map(t.map(e=>[String(e.id),e])),r=t.filter(e=>e.type===`candidate-pair`),i=t.filter(e=>e.type===`transport`&&typeof e.selectedCandidatePairId==`string`).map(e=>n.get(String(e.selectedCandidatePairId))).find(Boolean)??r.find(e=>e.selected===!0)??r.find(e=>e.nominated===!0&&e.state===`succeeded`);if(!i)return null;let a=e=>{let t=n.get(String(e));if(!t)return null;let r=t.address??t.ip;return typeof r==`string`?r:null};return Ds(a(i.localCandidateId),a(i.remoteCandidateId))}function ks(e){let t=e.replace(/:\d+$/,``).replace(/^\[|\]$/g,``);return`${t===`localhost`||t===`127.0.0.1`||t===`::1`?`ws`:`wss`}://${e}/ws`}function As(e){let t=new Set;for(let n of e.matchAll(/^a=fingerprint:sha-256[ \t]+([0-9A-Fa-f:]+)[ \t]*\r?$/gim))t.add(n[1].toUpperCase());return/^a=fingerprint:(?!sha-256[ \t])/im.test(e)?null:t.size===1?[...t][0]:null}function js(e,t){let n=As(e);return n!==null&&n===t.toUpperCase()}var Ms=16777216;function Ns(e){let t=16383,n=Math.max(1,Math.ceil(e.length/t)),r=[];for(let i=0;ithis.max)return this.parts=[],this.size=0,{kind:`error`,why:`too_big`};if(this.parts.push(r.slice()),this.size+=r.length,n===1)return{kind:`partial`};let i=new Uint8Array(this.size),a=0;for(let e of this.parts)i.set(e,a),a+=e.length;return this.parts=[],this.size=0,{kind:`message`,data:i.buffer}}};function Fs(e){let t=new Uint8Array(9);return t[0]=3,t.set(e.subarray(0,8),1),t}var Is=[`stun:stun.cloudflare.com:3478`,`stun:stun.l.google.com:19302`],Ls=1500,Rs=2e4;function zs(e){let t=e?.codecs??[],n=e=>t.filter(t=>t.mimeType.toLowerCase()===e);return[...n(`video/h264`),...n(`video/h265`),...n(`video/rtx`)]}var Bs=null;function Vs(e){e.onopen=e.onmessage=e.onclose=e.onerror=null;try{e.readyState===1&&e.send(JSON.stringify({t:`leave`})),e.close(1e3)}catch{}}function Hs(e,t){let n=Bs;return n?(Bs=null,n.timer&&clearTimeout(n.timer),n.url!==e||n.room!==t||n.ws.readyState>1||n.msgs.some(e=>e.t===`error`||e.t===`closed`)?(Vs(n.ws),null):{ws:n.ws,msgs:n.msgs}):null}function Us(e,t={}){var n;let r=t.WebSocketImpl??(typeof WebSocket>`u`?void 0:WebSocket),i=t.PeerConnection??(typeof RTCPeerConnection>`u`?void 0:RTCPeerConnection),a=t.iceTimeoutMs??15e3,o=t.log??(()=>{});class s{constructor(e){this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this.readyState=0,this.binaryType=`arraybuffer`,this.onopen=null,this.onmessage=null,this.onclose=null,this.onerror=null,this.hub=null,this.pc=null,this.dc=null,this.timer=null,this.rx=new Ps,this.answered=!1,this.early=[],this.hubBackUntil=0,this.offerSdp=null,this.offerSent=!1,this.ownEarly=[],this.media=null,setTimeout(()=>this.begin(),0)}begin(){if(this.readyState!==0)return;if(!i||!r){this.fail(`no_webrtc`);return}let n=t.signalUrl??ks(e.hub),a=t.signalUrl||t.lan?null:Hs(n,e.room),s;if(a)s=a.ws,o(`hub: joined early`);else try{s=new r(n)}catch{this.fail(`no_hub`);return}if(this.hub=s,this.prepare(),this.readyState===0){s.onopen=()=>s.send(JSON.stringify(t.lan?{v:1,t:`join`,lan:!0}:{v:1,t:`join`,room:e.room})),s.onmessage=e=>{if(typeof e.data!=`string`)return;let t;try{t=JSON.parse(e.data)}catch{return}this.onHub(t)},s.onclose=e=>{this.hub===s&&(this.hub=null,this.readyState===0&&(this.answered||e?.code===1001&&this.hubRestarting()||this.fail(`no_hub`)))},s.onerror=()=>{};for(let e of a?.msgs??[])this.onHub(e)}}signal(e){let t=this.hub;t&&t.readyState===1&&t.send(JSON.stringify({t:`signal`,to:`host`,data:e}))}onHub(e){if(this.readyState===0)switch(e.t){case`joined`:o(`hub: joined room as ${e.gid??`?`}`),this.sendOffer();return;case`signal`:e.from===`host`&&e.data&&typeof e.data==`object`&&this.onSignal(e.data);return;case`closed`:this.fail(`no_room`);return;case`error`:if(o(`hub: error ${e.why??`?`}`),e.why===`no_room`&&this.hubBackUntil&&this.hubRestarting())return;this.fail(e.why===`no_room`?`no_room`:e.why===`room_full`?`net_full`:`no_hub`);return}}prepare(){if(!i)return;this.offerSent=!1,this.ownEarly=[];let e;try{e=new i({iceServers:[{urls:Is}]})}catch{this.fail(`no_webrtc`);return}this.pc=e;let n=e.createDataChannel(t.label??`join`,{ordered:!0});if(n.binaryType=`arraybuffer`,this.dc=n,n.onopen=()=>this.opened(n),n.onmessage=e=>this.fromChannel(e.data),n.onclose=()=>{this.dc===n&&this.dropped()},t.video&&e.addTransceiver){try{let t=e.addTransceiver(`video`,{direction:`recvonly`}),n=zs(globalThis.RTCRtpReceiver?.getCapabilities?.(`video`));n.length&&t.setCodecPreferences&&t.setCodecPreferences(n)}catch{}try{e.addTransceiver(`audio`,{direction:`recvonly`})}catch{}e.ontrack=t=>{if(this.pc!==e)return;let n=this.media?.stream??t.streams[0]??new MediaStream;n.getTracks().includes(t.track)||n.addTrack(t.track),this.media=t.track.kind===`audio`?{stream:n,receiver:this.media?.receiver??t.receiver,audio:t.receiver}:{stream:n,receiver:t.receiver,...this.media?.audio?{audio:this.media.audio}:{}}}}e.onicecandidate=t=>{if(this.pc!==e)return;let n=t.candidate;if(!n||!n.candidate)return;let r={type:`candidate`,candidate:n.candidate,sdpMid:n.sdpMid??`0`};this.offerSent?this.signal(r):this.ownEarly.push(r)},e.oniceconnectionstatechange=()=>{if(this.pc!==e)return;let t=e.iceConnectionState;o(`ice: ${t}`),t===`failed`&&(this.readyState===0?this.fail(`no_direct`):this.dropped())},this.offerSdp=(async()=>{let t=await e.createOffer();return await e.setLocalDescription(t),e.localDescription?.sdp??t.sdp??``})().catch(()=>(this.pc===e&&this.fail(`no_webrtc`),null))}async sendOffer(){let e=this.pc,t=this.offerSdp;if(!e||!t||this.offerSent)return;this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.readyState===0&&this.fail(`no_direct`)},a);let n=await t;if(this.pc===e&&n!==null&&this.readyState===0){this.signal({type:`offer`,sdp:n}),this.offerSent=!0;for(let e of this.ownEarly.splice(0))this.signal(e)}}async onSignal(t){let n=this.pc;if(t.type===`bye`)this.fail(t.why===`full`?`net_full`:`offer`);else if(n){if(t.type===`answer`){if(this.answered||typeof t.sdp!=`string`)return;if(e.fp?!js(t.sdp,e.fp):As(t.sdp)===null){o(`answer: fingerprint does not match the link`),this.fail(`mismatch`);return}this.answered=!0;try{await n.setRemoteDescription({type:`answer`,sdp:t.sdp});for(let e of this.early.splice(0))await n.addIceCandidate(e).catch(()=>{})}catch{this.fail(`offer`)}}else if(t.type===`candidate`&&typeof t.candidate==`string`&&t.candidate){let e={candidate:t.candidate,sdpMid:typeof t.sdpMid==`string`?t.sdpMid:`0`,sdpMLineIndex:typeof t.sdpMLineIndex==`number`?t.sdpMLineIndex:0};this.answered?await n.addIceCandidate(e).catch(()=>{}):this.early.push(e)}}}opened(e){this.dc===e&&this.readyState===0&&(this.clearTimer(),this.readyState=1,o(`channel open`),this.leaveHub(),this.onopen?.(new Event(`open`)))}fromChannel(e){if(this.readyState!==1)return;if(typeof e==`string`){this.onmessage?.(new MessageEvent(`message`,{data:e}));return}if(!(e instanceof ArrayBuffer))return;let t=this.rx.push(e);switch(t.kind){case`ping`:try{this.dc?.send(Fs(t.data))}catch{}return;case`message`:this.onmessage?.(new MessageEvent(`message`,{data:t.data}));return;case`error`:o(`channel: bad binary message (${t.why})`),this.dropped();return;default:return}}async netPath(){let e=this.pc;if(!e||this.readyState!==1||typeof e.getStats!=`function`)return null;try{return Os(await e.getStats())}catch{return null}}send(e){let t=this.dc;if(this.readyState!==1||!t||t.readyState!==`open`)throw Error(`not open`);if(typeof e==`string`){t.send(e);return}let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e);for(let e of Ns(n))t.send(e)}close(){this.readyState!==3&&(this.teardown(),this.emitClose(1e3,``,!0))}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}leaveHub(){let e=this.hub;if(this.hub=null,e)try{e.readyState===1&&e.send(JSON.stringify({t:`leave`})),e.close(1e3)}catch{}}hubRestarting(){let e=Date.now();return this.hubBackUntil||=e+Rs,e>=this.hubBackUntil?!1:(o(`hub: restarting, trying again`),this.clearTimer(),this.leaveHub(),this.closePeer(),this.answered=!1,this.early=[],this.timer=setTimeout(()=>{this.timer=null,this.begin()},Ls),!0)}teardown(){this.readyState=3,this.clearTimer(),this.leaveHub(),this.closePeer()}closePeer(){let e=this.pc,t=this.dc;this.pc=null,this.dc=null,this.media=null,this.offerSdp=null,this.offerSent=!1,this.ownEarly=[];try{t?.close()}catch{}try{e?.close()}catch{}}dropped(){this.readyState!==3&&(this.teardown(),this.emitClose(1006,``,!1))}fail(e){this.readyState!==3&&(o(`failed: ${e}`),this.teardown(),this.emitClose(Ie,`net:${e}`,!1))}emitClose(e,t,n){let r=this.onclose;if(!r)return;let i=typeof CloseEvent>`u`?{type:`close`,code:e,reason:t,wasClean:n}:new CloseEvent(`close`,{code:e,reason:t,wasClean:n});setTimeout(()=>r(i),0)}}return n=s,n.CONNECTING=0,n.OPEN=1,n.CLOSING=2,n.CLOSED=3,s}function Ws(e,t=0){return/iPad/.test(e)||/Macintosh/.test(e)&&t>1?`ipad`:/iPhone|iPod/.test(e)?`iphone`:/Android/.test(e)?`android`:`phone`}var Gs=new URLSearchParams(location.hash.slice(1)),Ks=Gs.get(`t`)??``,qs=Gs.get(`w`)===`1`,Js=Ws(navigator.userAgent,navigator.maxTouchPoints),Ys=oo({get:yt,set:vt}),Xs=Be(location.hash),Zs=(0,x.createRoot)(document.getElementById(`root`));if(Xs){let e=Us(Xs,{label:`pad`,log:e=>console.info(`[pad] ${e}`)}),t=`ps5upload.pad.rt.${Xs.room}`,n=yt(t),r={t:Xs.key,name:Js,d:Ys,...qs?{w:1}:{},...n?{rt:n}:{}},i=Me(location.hash,`pad`);Zs.render((0,L.jsx)(vs,{url:ks(Xs.hub),computer:null,watch:qs,transport:e,hello:r,onReconnectToken:e=>vt(t,e),lanUrl:i?Ne(i,{watch:qs}):null}))}else{let e=location.pathname.replace(/\/pad\/?$/,``),t=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}${e}/api/pad/ws?t=${encodeURIComponent(Ks)}&name=${Js}&d=${Ys}${qs?`&w=1`:``}`;Zs.render((0,L.jsx)(ws,{appLink:Ts(location.href),children:(0,L.jsx)(vs,{url:t,computer:location.hostname,watch:qs})}))} diff --git a/site/join/index.html b/site/join/index.html index a08a3b6ec..90639f109 100644 --- a/site/join/index.html +++ b/site/join/index.html @@ -8,15 +8,15 @@ PS5Upload · Play Together - +I€wu¸öôú!3å6³‹âVq£³¹´RN£%y10º:pŠ#\:J:b9Hµ7h_Ž:¢I9 _¼™µV,þ <`});var T={a:v};this.setModule=t=>{e.setModule(yi,t)},this.getModule=()=>e.getModule(yi),this.instantiate=()=>(this.getModule().then(e=>WebAssembly.instantiate(e,T)).then(e=>{let t=e.exports;y(t),a=t.g,o(),te(t),n()}),this.ready=new Promise(e=>{n=e}).then(()=>{this.HEAP=a.buffer,this.malloc=x,this.free=C,this.opus_frame_decoder_create=b,this.opus_frame_decode_float_deinterleaved=S,this.opus_frame_decoder_destroy=ee}),this)}var bi=o((()=>{}));function xi(e={}){xi.errors||Object.defineProperties(xi,{errors:{value:new Map([[-1,`OPUS_BAD_ARG: One or more invalid/out of range arguments`],[-2,`OPUS_BUFFER_TOO_SMALL: Not enough bytes allocated in the buffer`],[-3,`OPUS_INTERNAL_ERROR: An internal error was detected`],[-4,`OPUS_INVALID_PACKET: The compressed data passed is corrupted`],[-5,`OPUS_UNIMPLEMENTED: Invalid/unsupported request number`],[-6,`OPUS_INVALID_STATE: An encoder or decoder structure is invalid or already freed`],[-7,`OPUS_ALLOC_FAIL: Memory allocation has failed`]])}}),this._init=()=>new this._WASMAudioDecoderCommon(this).instantiate(this._EmscriptenWASM,this._module).then(e=>{this._common=e,this._inputBytes=0,this._outputSamples=0,this._frameNumber=0,this._input=this._common.allocateTypedArray(this._inputSize,Uint8Array),this._output=this._common.allocateTypedArray(this._outputChannels*this._outputChannelSize,Float32Array);let t=this._common.allocateTypedArray(this._channels,Uint8Array);t.buf.set(this._channelMappingTable),this._decoder=this._common.wasm.opus_frame_decoder_create(this._sampleRate,this._channels,this._streamCount,this._coupledStreamCount,t.ptr,this._preSkip,this._forceStereo)}),Object.defineProperty(this,"ready",{enumerable:!0,get:()=>this._ready}),this.reset=()=>(this.free(),this._init()),this.free=()=>{this._common.free(),this._common.wasm.opus_frame_decoder_destroy(this._decoder),this._common.wasm.free(this._decoder)},this._decode=e=>{if(!(e instanceof Uint8Array))throw Error(`Data to decode must be Uint8Array. Instead got `+typeof e);this._input.buf.set(e);let t=this._common.wasm.opus_frame_decode_float_deinterleaved(this._decoder,this._input.ptr,e.length,this._output.ptr),n;return t<0&&(n=`libopus `+t+` `+(xi.errors.get(t)||`Unknown Error`),console.error(n),t=0),{outputBuffer:this._common.getOutputChannels(this._output.buf,this._outputChannels,t),samplesDecoded:t,error:n}},this.decodeFrame=e=>{let t=[],n=this._decode(e);return n.error&&this._common.addError(t,n.error,e.length,this._frameNumber,this._inputBytes,this._outputSamples),this._frameNumber++,this._inputBytes+=e.length,this._outputSamples+=n.samplesDecoded,this._WASMAudioDecoderCommon.getDecodedAudioMultiChannel(t,[n.outputBuffer],this._outputChannels,n.samplesDecoded,this._sampleRate)},this.decodeFrames=e=>{let t=[],n=[],r=0,i=0;for(;itypeof e==`number`,n=e.sampleRate,r=e.channels,i=e.streamCount,a=e.coupledStreamCount,o=e.channelMappingTable,s=e.preSkip,c=+!!e.forceStereo;if(r>2&&(!t(i)||!t(a)||!Array.isArray(o)))throw Error(`Invalid Opus Decoder Options for multichannel decoding.`);return this._sampleRate=[8e3,12e3,16e3,24e3,48e3].includes(n)?n:48e3,this._channels=t(r)?r:2,this._streamCount=t(i)?i:1,this._coupledStreamCount=t(a)?a:this._channels-1,this._channelMappingTable=o||(this._channels===2?[0,1]:[0]),this._preSkip=s||0,this._forceStereo=r<=8&&r!=2?c:0,this._inputSize=3840*this._channels,this._outputChannelSize=5760,this._outputChannels=this._forceStereo?2:this._channels,this._ready=this._init(),this}var Si=o((()=>{vi(),bi()})),Ci,wi=o((()=>{vi(),bi(),Si(),Ci=class extends mi{constructor(e){super(e,`opus-decoder`,xi,yi)}async decodeFrame(e){return this.postToDecoder(`decodeFrame`,e)}async decodeFrames(e){return this.postToDecoder(`decodeFrames`,e)}}})),Ti=c({OpusDecoder:()=>xi,OpusDecoderWebWorker:()=>Ci}),Ei=o((()=>{Si(),wi(),vi(),gi(xi,`OpusDecoder`),gi(Ci,`OpusDecoderWebWorker`)})),Di=[8e3,12e3,16e3,24e3,48e3],Oi=null;function ki(){return Oi??=Yn(()=>Promise.resolve().then(()=>(Ei(),Ti)),__VITE_PRELOAD__,import.meta.url).catch(e=>{throw Oi=null,e}),Oi}function Ai(){return typeof WebAssembly==`object`&&typeof WebAssembly.instantiate==`function`}function ji(e,t,n,r){return{numberOfFrames:t,numberOfChannels:e.length,sampleRate:n,timestamp:r,format:`f32-planar`,duration:Math.round(t/n*1e6),copyTo(n,r){n.set(e[r.planeIndex].subarray(0,t))},close(){}}}var Mi=class{constructor(e,t=ki){this.init=e,this.load=t,this.state=`unconfigured`,this.dec=null,this.pending=[]}configure(e){if(this.state===`closed`)throw Error(`the decoder is closed`);if(!Ai())throw Error(`no WebAssembly here`);let t=e.sampleRate;if(!Di.includes(t))throw Error(`Opus does not decode at ${t} Hz`);let n=e.numberOfChannels;if(n<1||n>2)throw Error(`${n} channels: only mono and stereo are decoded`);this.state=`configured`,this.load().then(async e=>{if(this.state===`closed`)return;let r=new e.OpusDecoder({channels:n,sampleRate:t});if(await r.ready,this.state!==`configured`){r.free();return}this.dec=r;let i=this.pending;this.pending=[];for(let e of i)this.state===`configured`&&this.run(e)}).catch(e=>this.fail(e))}decode(e){if(this.state!==`configured`)return;let t=e;if(this.dec)return this.run(t);this.pending.push({timestamp:t.timestamp,data:t.data.slice()}),this.pending.length>50&&this.pending.shift()}run(e){let t=this.dec;if(!t)return;let n;try{n=t.decodeFrame(e.data)}catch(e){return this.fail(e)}n.samplesDecoded&&n.channelData.length&&this.init.output(ji(n.channelData,n.samplesDecoded,n.sampleRate,e.timestamp))}fail(e){if(this.state===`closed`)return;this.close();let t=e instanceof Error?e:Error(String(e));queueMicrotask(()=>this.init.error(t))}close(){this.state=`closed`,this.pending=[];let e=this.dec;this.dec=null;try{e?.free()}catch{}}},Ni={makeDecoder:e=>new Mi(e),makeChunk:e=>({type:e.type,timestamp:e.timestamp,data:e.data instanceof Uint8Array?e.data:new Uint8Array(e.data)})};function Pi(e,t){for(let n=0;n+3>1&63;if(t>=16&&t<=21)return!0;if(t<16)return!1}else{let t=e[n+3]&31;if(t===5)return!0;if(t===1)return!1}}return!1}function Fi(e){for(let t=0;t+6e.toString(16).padStart(2,`0`);return`avc1.${n(e[t+4])}${n(e[t+5])}${n(e[t+6])}`}return`avc1.4d4028`}var Ii=[`hev1.1.6.L153.B0`,`hvc1.1.6.L153.B0`,`hev1.2.4.L153.B0`,`hvc1.2.4.L153.B0`,`hev1.1.6.L150.90`];async function Li(e,t){if(typeof VideoDecoder>`u`)return null;for(let n of Ii)try{if((await VideoDecoder.isConfigSupported({codec:n,codedWidth:e,codedHeight:t})).supported)return n}catch{}return null}function Ri(e){let t=[];for(let n=0;n+2{let i=r+1n&&e[i-1]===0;)i--;return e.subarray(n,i)}).filter(e=>e.length>0)}var zi=(e,t)=>t?e[0]>>1&63:e[0]&31;function Bi(e,...t){let n=8+t.reduce((e,t)=>e+t.length,0),r=new Uint8Array(n);new DataView(r.buffer).setUint32(0,n);for(let t=0;t<4;t++)r[4+t]=e.charCodeAt(t);let i=8;for(let e of t)r.set(e,i),i+=e.length;return r}function I(...e){let t=new Uint8Array(e.reduce((e,[,t])=>e+t,0)),n=0;for(let[r,i]of e){for(let e=i-1;e>=0;e--)t[n+i-1-e]=Math.floor(r/2**(8*e))&255;n+=i}return t}var Vi=(e,t,n,...r)=>Bi(e,I([t,1],[n,3]),...r),Hi=I([65536,4],[0,4],[0,4],[0,4],[65536,4],[0,4],[0,4],[0,4],[1073741824,4]);function Ui(e){let t=e.handler===`vide`,n=Bi(`ftyp`,new TextEncoder().encode(`isom`),I([1,4]),new TextEncoder().encode(`isomiso6mp41`)),r=Bi(`moov`,Vi(`mvhd`,0,0,I([0,4],[0,4],[e.timescale,4],[0,4],[65536,4],[256,2],[0,2],[0,4],[0,4]),Hi,new Uint8Array(24),I([2,4])),Bi(`trak`,Vi(`tkhd`,0,3,I([0,4],[0,4],[1,4],[0,4],[0,4],[0,4],[0,4],[0,2],[0,2],[t?0:256,2],[0,2]),Hi,I([(e.width??0)*65536,4],[(e.height??0)*65536,4])),Bi(`mdia`,Vi(`mdhd`,0,0,I([0,4],[0,4],[e.timescale,4],[0,4],[21956,2],[0,2])),Vi(`hdlr`,0,0,I([0,4]),new TextEncoder().encode(e.handler),new Uint8Array(12),I([0,1])),Bi(`minf`,t?Vi(`vmhd`,0,1,new Uint8Array(8)):Vi(`smhd`,0,0,I([0,4])),Bi(`dinf`,Vi(`dref`,0,0,I([1,4]),Vi(`url `,0,1))),Bi(`stbl`,Vi(`stsd`,0,0,I([1,4]),e.sampleEntry),Vi(`stts`,0,0,I([0,4])),Vi(`stsc`,0,0,I([0,4])),Vi(`stsz`,0,0,I([0,4],[0,4])),Vi(`stco`,0,0,I([0,4])))))),Bi(`mvex`,Vi(`trex`,0,0,I([1,4],[1,4],[0,4],[0,4],[0,4])))),i=new Uint8Array(n.length+r.length);return i.set(n,0),i.set(r,n.length),i}function Wi(e,t,n,r,i){let a=i?33554432:16842752,o=e=>Vi(`trun`,0,1793,I([1,4],[e,4],[n,4],[r.length,4],[a,4])),s=e=>Bi(`traf`,Vi(`tfhd`,0,131072,I([1,4])),Vi(`tfdt`,1,0,I([t,8])),o(e)),c=Vi(`mfhd`,0,0,I([e,4])),l=Bi(`moof`,c,s(0)).length,u=Bi(`moof`,c,s(l+8)),d=Bi(`mdat`,r),f=new Uint8Array(u.length+d.length);return f.set(u,0),f.set(d,u.length),f}function Gi(e,t,n=!1){let r=t?[35,...n?[32,33,34]:[]]:[9,...n?[7,8]:[]],i=Ri(e).filter(e=>!r.includes(zi(e,t))),a=new Uint8Array(i.reduce((e,t)=>e+4+t.length,0)),o=new DataView(a.buffer),s=0;for(let e of i)o.setUint32(s,e.length),a.set(e,s+4),s+=4+e.length;return a}var Ki=e=>e.toString(16).padStart(2,`0`),qi=e=>{let t=new Uint8Array(2+e.length);return t[0]=e.length>>8,t[1]=e.length&255,t.set(e,2),t},Ji=e=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t};function Yi(e){let t=Ri(e),n=t.filter(e=>zi(e,!1)===7),r=t.filter(e=>zi(e,!1)===8);return!n.length||!r.length||n[0].length<4?null:Ji([I([1,1],[n[0][1],1],[n[0][2],1],[n[0][3],1],[255,1],[224|n.length,1]),...n.map(qi),I([r.length,1]),...r.map(qi)])}function Xi(e,t,n){let r=Ri(e),i=e=>r.filter(n=>zi(n,t)===e),a=(e,t)=>Bi(e,new Uint8Array(6),I([1,2],[0,16],[n.w,2],[n.h,2],[4718592,4],[4718592,4],[0,4],[1,2]),new Uint8Array(32),I([24,2],[65535,2]),t);if(!t){let t=i(7),r=Yi(e);return r?{init:Ui({handler:`vide`,timescale:9e4,sampleEntry:a(`avc1`,Bi(`avcC`,r)),width:n.w,height:n.h}),mime:`video/mp4; codecs="avc1.${Ki(t[0][1])}${Ki(t[0][2])}${Ki(t[0][3])}"`}:null}let o=i(32),s=i(33),c=i(34);if(!o.length||!s.length||!c.length)return null;let l=Yr(s[0]);if(l.length<15)return null;let u=l.subarray(3,15),d=u[0]&31,f=d===2?2:0,p=(e,t)=>Ji([I([128|e,1],[t.length,2]),...t.map(qi)]),m=Bi(`hvcC`,I([1,1]),u,I([61440,2],[252,1],[253,1],[248|f,1],[248|f,1],[0,2],[15,1],[3,1]),p(32,o),p(33,s),p(34,c)),h=[``,`A`,`B`,`C`][u[0]>>6],g=0,_=(u[1]<<24|u[2]<<16|u[3]<<8|u[4])>>>0;for(let e=0;e<32;e++)_&1<>>0).toString(16),`${u[0]&32?`H`:`L`}${u[11]}`,...v.map(e=>e.toString(16))].join(`.`);return{init:Ui({handler:`vide`,timescale:9e4,sampleEntry:a(`hvc1`,m),width:n.w,height:n.h}),mime:`video/mp4; codecs="${y}"`}}function Zi(e,t,n,r,i,a){return Wi(e,t,n,Gi(r,i),a)}function Qi(e,t){let n=Bi(`dOps`,I([0,1],[e,1],[312,2],[t,4],[0,2],[0,1]));return Ui({handler:`soun`,timescale:48e3,sampleEntry:Bi(`Opus`,new Uint8Array(6),I([1,2],[0,8],[e,2],[16,2],[0,4],[3145728e3,4]),n)})}function $i(e){if(!e.length)return 960;let t=e[0]>>3,n=t<12?[480,960,1920,2880][t%4]:t<16?[480,960][t%2]:[120,240,480,960][t%4],r=e[0]&3,i=r===0?1:r===3?(e[1]??1)&63:2;return n*Math.max(1,i)}function ea(e,t,n){return Wi(e,t,$i(n),n,!0)}var ta={watch:30,player:4},na={watch:{seek:.5,speed:1/0,target:.05},player:{seek:.15,speed:.06,target:.02}},ra={seek:.8,speed:.25,target:.12};function ia(e,t,n){let r=typeof n==`string`?na[n]:n;return e>r.seek?{seekTo:t-r.target,rate:1}:e>r.speed?{seekTo:null,rate:1.1}:{seekTo:null,rate:1}}function aa(e,t=`watch`,n){return typeof VideoDecoder<`u`?new ma(e,t,n):new Oa(e,t,n)}var oa=class{constructor(e,t=()=>performance.now()){this.ask=e,this.now=t,this.last=-1/0}waiting(){if(!this.ask)return;let e=this.now();e-this.last<1e3||(this.last=e,this.ask())}};function L(e){return e.length<3?null:{index:e[0]<<8|e[1],packet:e.subarray(2)}}var R=class{constructor(){this.last=-1}take(e){if(this.last>=0){let t=e-this.last&65535;if(t===0||t>=32768)return!1}return this.last=e,!0}reset(){this.last=-1}};function sa(e){if(e.length>=10)return e;let t=new Uint8Array(10);t.set(e.subarray(0,6));let n=new DataView(t.buffer);return n.setUint32(6,Math.round(n.getUint32(2)/100)||480),t}function ca(e,t){return{snd:e,snd_decoded:t.decoded,snd_concealed:t.concealed,snd_underruns:t.underruns,snd_dropped:t.dropped}}var la=class{constructor(e,t=.2){this.min=e,this.max=t,this.next=0,this.calmSince=0,this.minLead=1/0,this.windowAt=0,this.underruns=0,this.dropped=0,this.cushion=e}at(e,t){this.next0&&(this.underruns++,this.cushion=Math.min(this.max,this.cushion+.02)),this.calmSince=e,this.next=e+this.cushion,this.minLead=1/0,this.windowAt=e):e-this.calmSince>10&&this.cushion>this.min&&(this.cushion=Math.max(this.min,this.cushion-.01),this.calmSince=e);let n=this.next-e;if(n>this.cushion+.15)return this.dropped++,null;if(this.minLead=Math.min(this.minLead,n),e-this.windowAt>=.25){let t=this.minLead>this.cushion+ua;if(this.minLead=1/0,this.windowAt=e,t)return this.dropped++,null}let r=this.next;return this.next+=t,r}reset(){this.next=0}},ua=.02;async function da(e,t){try{return typeof AudioDecoder>`u`?!1:!!(await AudioDecoder.isConfigSupported({codec:`opus`,sampleRate:e,numberOfChannels:t})).supported}catch{return!1}}var fa=class{constructor(e,t=()=>performance.now()){this.decoder=e,this.now=t,this.n={frames:0,dropped:0,late:0,stalls:0,stall_ms:0,worst_stall_ms:0,key_waits:0},this.a=0,this.d=0,this.w=!1,this.q=[],this.sum=0,this.cnt=0,this.codec=``}get frames(){return this.n.frames}arrived(){let e=this.now();this.a&&e-this.a>50&&this.n.late++,this.a=e}drop(){this.n.dropped++,this.w||this.n.key_waits++,this.w=!0}decoding(){this.w=!1,this.q.push(this.now())>64&&this.q.shift()}drawn(e=!1){let t=this.now(),n=e?this.q.shift():void 0;n!==void 0&&(this.sum+=t-n,this.cnt++);let r=this.d?t-this.d:0;r>100&&this.stall(r),this.d=t,this.n.frames++}stall(e){this.n.stalls++,this.n.stall_ms+=e,this.n.worst_stall_ms=Math.max(this.n.worst_stall_ms,e)}snapshot(){let e=this.d?this.now()-this.d:0,t={...this.n,decoder:this.decoder};this.codec&&(t.codec=this.codec),e>100&&(t.stalls=this.n.stalls+1,t.stall_ms=this.n.stall_ms+e,t.worst_stall_ms=Math.max(this.n.worst_stall_ms,e));for(let e of[`stall_ms`,`worst_stall_ms`])t[e]=Math.round(t[e]);return t.decode_ms=this.cnt?Math.round(this.sum/this.cnt*10)/10:0,this.sum=this.cnt=0,t}},pa=[`pointerup`,`touchend`,`click`,`keydown`],ma=class{get element(){if(!this.wrap){let e=document.createElement(`div`);e.className=`h-full w-full`,e.append(this.canvas),this.mse&&e.append(this.mse.element),this.wrap=e}return this.wrap}get stats(){return this.mse?.stats??this.ownStats}soundReport(){return this.soundOn?this.mseSound?this.mseSound.report():ca(this.soundWasm?`wasm`:`webcodecs`,this.soundStats):null}constructor(e,t=`watch`,n){this.onProblem=e,this.latency=t,this.onNeedKey=n,this.canvas=document.createElement(`canvas`),this.wrap=null,this.mse=null,this.failsNoPicture=0,this.ctx=this.canvas.getContext(`2d`,{alpha:!1}),this.hevc=!1,this.header=null,this.spsRect=null,this.software=!1,this.video=null,this.opening=!1,this.sawKey=!1,this.ownStats=new fa(`webcodecs`),this.problemShown=!1,this.ts=0,this.pipe=null,this.audioGen=0,this.actx=null,this.soundOn=!1,this.unarm=null,this.mseSound=null,this.audioHeader=null,this.soundWasm=!1,this.onSoundFail=null,this.muted=!1,this.keyAsk=new oa(n),this.clock=new la(t===`player`?.05:.08),typeof AudioDecoder>`u`&&_a()&&(this.mseSound=new va(t,()=>this.mseSoundFailed())),this.canvas.className=`block h-full w-full object-contain`,this.canvas.dataset.testid=`watch-canvas`}setHevc(e){this.hevc=e,this.header&&(this.spsRect=ti(this.header,e)),this.mse?.setHevc(e)}get onMse(){return!!this.mse}decodeFailed(){if(this.mse||this.ownStats.frames>0||++this.failsNoPicture<3||!ba())return!1;let e=new Oa(this.onProblem,this.latency,this.onNeedKey);e.setHevc(this.hevc),e.markProblemShown(),this.mse=e;let t=this.video;this.video=null;try{t?.close()}catch{}return this.canvas.style&&(this.canvas.style.display=`none`),this.wrap?.append(e.element),this.header&&e.onMessage(new Uint8Array([0,...this.header]).buffer),this.onNeedKey?.(),!0}startSound(){this.soundOn=!0,ha(),this.mseSound?this.mseSound.start():this.openContext()}openContext(){try{if(!this.actx){let e=new AudioContext({latencyHint:`interactive`});this.actx=e,e.onstatechange=()=>{this.actx===e&&e.state!==`running`&&e.state!==`closed`&&this.armResume()}}this.actx.resume().catch(()=>{})}catch{this.onSoundFail?.()}}get sound(){return this.soundOn}setMuted(e){this.muted=e,this.mseSound?.setMuted(e)}resumeSound(){if(!this.soundOn)return;if(this.mseSound)return this.mseSound.resume();let e=this.actx;e&&e.state!==`running`&&e.state!==`closed`&&(this.clock.reset(),e.resume().catch(()=>{}),this.armResume())}get soundStats(){return{decoded:this.pipe?.decoded??0,concealed:this.pipe?.concealed??0,underruns:this.clock.underruns,dropped:this.clock.dropped,cushionMs:Math.round(this.clock.cushion*1e3)}}armResume(){if(this.unarm||typeof window>`u`||!window.addEventListener)return;let e=()=>{let e=this.actx;if(!e||e.state===`closed`)return this.unarm?.();this.clock.reset(),e.resume().then(()=>{e.state===`running`&&this.unarm?.()}).catch(()=>{})};for(let t of pa)window.addEventListener(t,e,!0);this.unarm=()=>{for(let t of pa)window.removeEventListener(t,e,!0);this.unarm=null}}onMessage(e){let t=new Uint8Array(e);if(t.length<1)return;let n=t[0],r=t.subarray(1);if(this.mse&&(n===0||n===1))return n===0&&(this.header=r.slice()),this.mse.onMessage(e);n===0?this.openVideo(r.slice()):n===1?this.onVideo(r):n===3?this.openAudio(r.slice()):n===4&&this.onAudio(r)}async openVideo(e){if(this.header=e,this.spsRect=ti(e,this.hevc),!this.opening){this.opening=!0;try{let t=this.hevc?await ka(e):Fi(e);if(this.mse)return;if(!t){this.problemShown=!0,this.onProblem(`no_hevc`);return}this.ownStats.codec=t;let n=this.hevc?void 0:Yi(e)??void 0;try{this.video?.close()}catch{}let r=new VideoDecoder({output:e=>{let t=this.realVisible(e),n=this.canvas;(n.width!==t.displayWidth||n.height!==t.displayHeight)&&(n.width=t.displayWidth,n.height=t.displayHeight),this.ctx?.drawImage(t,0,0,n.width,n.height),this.ownStats.drawn(!0),t.close(),this.problemShown&&(this.problemShown=!1,this.onProblem(null))},error:()=>{this.video===r&&(this.problemShown=!0,this.onProblem(`decode`),this.decodeFailed()||this.rebuild())}}),i={codec:t,optimizeForLatency:!0};n&&(i.description=n),this.software&&(i.hardwareAcceleration=`prefer-software`),r.configure(i),this.video=r,this.sawKey=!1}catch{this.problemShown=!0,this.onProblem(`decode`),this.decodeFailed()}finally{this.opening=!1}}}realVisible(e){let t=this.spsRect,n=ni(e,t);if(n)try{let t=new VideoFrame(e,{visibleRect:{x:n.x,y:n.y,width:n.w,height:n.h},displayWidth:n.w,displayHeight:n.h});return e.close(),t}catch{return e}let r=e.visibleRect;if(t&&r&&!this.software&&(r.width{if(this.video===e){try{e?.close()}catch{}this.rebuild(),this.onNeedKey?.()}})}return e}rebuild(){this.mse||(this.video=null,this.sawKey=!1,this.header&&this.openVideo(this.header).then(()=>this.keyAsk.waiting()))}onVideo(e){let t=this.video;if(t?.state===`closed`){this.opening||this.rebuild();return}if(!t||t.state!==`configured`)return;let n=Pi(e,this.hevc);if(this.ownStats.arrived(),!this.sawKey&&!n)return this.ownStats.drop(),this.keyAsk.waiting();if(!n&&t.decodeQueueSize>ta[this.latency])return this.sawKey=!1,this.ownStats.drop(),this.keyAsk.waiting();this.sawKey=!0;let r=e;this.hevc?n&&this.header&&(r=new Uint8Array(this.header.length+e.length),r.set(this.header,0),r.set(e,this.header.length)):r=Gi(e,!1,!0),this.ts+=16667,this.ownStats.decoding(),t.decode(new EncodedVideoChunk({type:n?`key`:`delta`,timestamp:this.ts,data:r}))}openAudio(e){if(e.length<6)return;let t=++this.audioGen;if(this.pipe?.reset(),this.pipe=null,this.clock.reset(),this.audioHeader=e,this.mseSound)return this.mseSound.setHeader(e);let n=e[0];da(new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2),n).then(n=>{if(t!==this.audioGen)return;if(!n)return _a()?this.soundThroughMse(e):this.soundThroughWasm(e);let r=new oi((e,t)=>this.play(e,t,r.sampleRate));try{r.header(sa(e)),this.pipe=r}catch{this.soundThroughMse(e)}})}soundThroughMse(e){this.pipe=null,this.mseSound||(this.mseSound=new va(this.latency,()=>this.mseSoundFailed()),this.soundOn&&this.mseSound.start()),this.mseSound.setHeader(e)}soundThroughWasm(e){this.pipe?.reset(),this.soundWasm=!0;let t=new oi((e,n)=>this.play(e,n,t.sampleRate),Ni,()=>{this.pipe===t&&(this.pipe=null),this.onSoundFail?.()});this.pipe=t,t.header(sa(e))}mseSoundFailed(){let e=this.mseSound;e&&(this.mseSound=null,e.stop(),this.soundOn&&(this.openContext(),this.actx&&this.actx.state!==`running`&&this.armResume()),this.audioHeader&&this.soundThroughWasm(this.audioHeader))}onAudio(e){if(this.mseSound)return this.mseSound.frame(e);this.soundOn&&this.pipe&&this.pipe.packet(e)}play(e,t,n){let r=this.actx;if(!r||r.state!==`running`||!e.length)return;let i=e[0].length,a=this.clock.at(r.currentTime,i/n);if(a===null)return;let o=r.createBuffer(e.length,i,n),s=this.muted?0:t;e.forEach((e,t)=>o.copyToChannel(s===1?e:e.map(e=>e*s),t));let c=r.createBufferSource();c.buffer=o,c.connect(r.destination),c.start(a)}stop(){try{this.video?.close()}catch{}this.mse?.stop(),this.audioGen++,this.pipe?.reset(),this.pipe=null,this.unarm?.(),this.actx?.close().catch(()=>{}),this.mseSound?.stop()}};function ha(){try{let e=navigator.audioSession;e&&e.type!==`playback`&&(e.type=`playback`)}catch{}}function ga(e,t){try{return e.isTypeSupported(t)}catch{return!1}}function _a(){let e=typeof window>`u`?null:ba();return!!e&&(ga(e,`audio/mp4; codecs="Opus"`)||ga(e,`audio/mp4; codecs="opus"`))}var va=class{constructor(e,t,n=document.createElement(`audio`)){this.onFail=t,this.header=null,this.time=0,this.on=!1,this.failed=!1,this.order=new R,this.el=n,this.track=new wa(n,()=>this.fail(),e===`player`?ra:e)}get playing(){return this.on&&!this.failed}report(){return{snd:`mse`,snd_jumps:this.track.seeks}}setHeader(e){this.header=e,this.on&&this.open()}start(){if(!this.on&&(this.on=!0,this.header&&this.open(),!this.failed))try{this.el.play()?.catch?.(()=>{})}catch{}}frame(e){if(!this.on||this.failed||!this.track.ready&&!this.track.backlog)return;let t=L(e);if(!t||!this.order.take(t.index))return;let n=ea(this.track.nextSeq(),this.time,t.packet);this.time+=$i(t.packet),this.track.push(n)}setMuted(e){this.el.muted=e}resume(){if(this.playing&&this.el.paused)try{this.el.play()?.catch?.(()=>{})}catch{}}stop(){this.on=!1,this.track.close()}open(){let e=this.header;if(!e||e.length<6||this.failed)return;let t=e[0],n=Qi(t,new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2));this.track.open(`audio/mp4; codecs="Opus"`,n)||this.track.open(`audio/mp4; codecs="opus"`,n)?(this.time=0,this.order.reset()):this.fail()}fail(){this.failed||(this.failed=!0,this.onFail())}},ya=class{constructor(e,t,n=Ni){this.onFail=t,this.codecs=n,this.actx=null,this.pipe=null,this.header=null,this.on=!1,this.failed=!1,this.muted=!1,this.unarm=null,this.played=!1,this.clock=new la(e===`player`?.05:.08)}get playing(){return this.on&&!this.failed}get stats(){return{decoded:this.pipe?.decoded??0,concealed:this.pipe?.concealed??0,underruns:this.clock.underruns,dropped:this.clock.dropped}}start(){if(!this.failed){this.on=!0,ha();try{if(!this.actx){let e=new AudioContext({latencyHint:`interactive`});this.actx=e,e.onstatechange=()=>{this.actx===e&&e.state!==`running`&&e.state!==`closed`&&this.armResume()}}this.actx.resume().catch(()=>{}),this.actx.state!==`running`&&this.armResume()}catch{return this.fail()}this.header&&!this.pipe&&this.open()}}setHeader(e){e.length<6||(this.header=e,this.pipe?.reset(),this.pipe=null,this.clock.reset(),this.on&&this.open())}frame(e){this.on&&!this.failed&&this.pipe?.packet(e)}setMuted(e){this.muted=e}resume(){let e=this.actx;this.playing&&e&&e.state!==`running`&&e.state!==`closed`&&(this.clock.reset(),e.resume().catch(()=>{}),this.armResume())}stop(){this.on=!1,this.pipe?.reset(),this.pipe=null,this.unarm?.(),this.actx?.close().catch(()=>{}),this.actx=null}open(){let e=this.header;if(!e||this.failed)return;let t=new oi((e,n)=>this.play(e,n,t.sampleRate),this.codecs,()=>{this.pipe===t&&this.fail()});this.pipe=t,t.header(sa(e))}play(e,t,n){let r=this.actx;if(!r||r.state!==`running`||!e.length)return;let i=e[0].length,a=this.clock.at(r.currentTime,i/n);if(a===null)return;let o=r.createBuffer(e.length,i,n),s=this.muted?0:t;e.forEach((e,t)=>o.copyToChannel(s===1?e:e.map(e=>e*s),t));let c=r.createBufferSource();c.buffer=o,c.connect(r.destination),c.start(a),this.played=!0}armResume(){if(this.unarm||typeof window>`u`||!window.addEventListener)return;let e=()=>{let e=this.actx;if(!e||e.state===`closed`)return this.unarm?.();this.clock.reset(),e.resume().then(()=>{e.state===`running`&&this.unarm?.()}).catch(()=>{})};for(let t of pa)window.addEventListener(t,e,!0);this.unarm=()=>{for(let t of pa)window.removeEventListener(t,e,!0);this.unarm=null}}fail(){this.failed||(this.failed=!0,this.stop(),this.onFail())}};function ba(){let e=window;return e.ManagedMediaSource??e.MediaSource??null}var xa=10,Sa=3;function Ca(e,t,n,r=Sa){let i=null;for(let a of e)a>t&&a<=n-r&&(i=a);return i}var wa=class{constructor(e,t,n=`watch`,r,i=()=>performance.now()){this.el=e,this.onError=t,this.latency=n,this.onNeedKey=r,this.now=i,this.ms=null,this.sb=null,this.queue=[],this.mime=``,this.seq=1,this.ready=!1,this.dropped=!1,this.keys=null,this.seeks=0,this.maxLagS=0,this.fromZero=0,this.trims=0,this.lastJump=null,this.trimAt=-1,this.trimFrom=-1,this.keyAt=-1,this.attached=null,r&&(this.keys=[])}setEdge(e){this.latency=e}markKey(e){this.keys?.push(e),this.keyAt=this.now()}open(e,t){let n=ba();if(!n||!ga(n,e))return!1;this.close();let r=new n;return this.ms=r,this.mime=e,this.queue=[t],this.seq=1,this.ready=!1,this.keys&&=[],r.addEventListener(`sourceopen`,()=>{if(this.ms===r)try{let e=r.addSourceBuffer(this.mime);e.mode=`segments`,e.addEventListener(`updateend`,()=>this.pump()),e.addEventListener(`error`,()=>this.onError()),this.sb=e,this.ready=!0,this.pump()}catch{this.onError()}}),`ManagedMediaSource`in window&&n===window.ManagedMediaSource&&(this.el.disableRemotePlayback=!0),this.attached=Ta(this.el,r),!0}nextSeq(){return this.seq++}get backlog(){return this.queue.length}push(e){this.queue.push(e),this.pump()}pump(){let e=this.sb;if(!e||e.updating||!this.ready)return;let t=this.el;if(e.buffered.length){let n=e.buffered.end(e.buffered.length-1),r=e.buffered.start(0),i=n-t.currentTime,a=ia(i,n,this.latency);if(a.seekTo!==null){this.seeks++,this.maxLagS=Math.max(this.maxLagS,i);let o=this.now(),s=e=>e<0?-1:Math.round(o-e);t.currentTime<.05&&r>1&&this.fromZero++,this.lastJump={at:t.currentTime,start:r,end:n,ranges:e.buffered.length,readyState:t.readyState,paused:t.paused,seeking:t.seeking,sinceTrimMs:s(this.trimAt),trimFrom:this.trimFrom,sinceKeyMs:s(this.keyAt)},t.currentTime=Math.max(r,a.seekTo)}if(t.playbackRate!==a.rate&&(t.playbackRate=a.rate),t.currentTime-r>xa&&this.trim(e,r))return}let n=this.queue.shift();if(n){try{e.appendBuffer(n)}catch{this.dropped=!0}t.paused&&t.play().catch(()=>{})}}trim(e,t){let n=this.el.currentTime,r=n-Sa;if(this.keys){if(r=Ca(this.keys,t,n),r===null)return(this.keys[this.keys.length-1]??-1/0)<=n-Sa&&this.onNeedKey?.(),!1;let e=r;this.keys=this.keys.filter(t=>t>=e),r-=.001}try{return e.remove(t,r),this.trims++,this.trimAt=this.now(),this.trimFrom=n,!0}catch{return!1}}close(){this.ready=!1,this.sb=null,this.queue=[];let e=this.ms;if(this.ms=null,e&&e.readyState===`open`)try{e.endOfStream()}catch{}if(this.attached===`object`)try{this.el.srcObject=null}catch{}this.attached=null,this.el.src?.startsWith(`blob:`)&&URL.revokeObjectURL(this.el.src),this.el.removeAttribute(`src`)}};function Ta(e,t){if(`srcObject`in e)try{return e.srcObject=t,`object`}catch{}return e.src=URL.createObjectURL(t),`url`}var Ea=1e4,Da=class{constructor(e=3,t=Ea,n=()=>performance.now()){this.max=e,this.windowMs=t,this.now=n,this.at=[]}fail(){let e=this.now();return this.at=this.at.filter(t=>e-t=this.max}clear(){this.at=[]}},Oa=class{constructor(e,t=`watch`,n,r){this.onProblem=e,this.latency=t,this.wasm=null,this.audioHeader=null,this.muted=!1,this.gaveUp=!1,this.reopening=!1,this.failedWhileOpening=!1,this.wrap=document.createElement(`div`),this.hevc=!1,this.header=null,this.sawKey=!1,this.stats=new fa(`mse`),this.problemShown=!1,this.vTime=0,this.vLast=0,this.soundOn=!1,this.onSoundFail=null,this.onGiveUp=null,this.keyAsk=new oa(n),this.fails=new Da(3,Ea,r);let i=document.createElement(`video`);i.muted=!0,i.autoplay=!0,i.playsInline=!0,i.className=`block h-full w-full object-contain`,i.dataset.testid=`watch-video`,this.audio=new va(t,()=>this.soundThroughWasm()),this.wrap.className=`h-full w-full`,this.wrap.append(i,this.audio.el),this.video=new wa(i,()=>this.showProblem(),t,()=>this.keyAsk.waiting()),i.addEventListener(`error`,()=>this.restartVideo()),i.addEventListener(`playing`,()=>{this.fails.clear(),this.problemShown&&(this.problemShown=!1,this.onProblem(null))})}markProblemShown(){this.problemShown=!0}showProblem(){this.problemShown||(this.problemShown=!0,this.onProblem(`decode`))}restartVideo(){if(this.gaveUp)return;if(this.reopening){this.failedWhileOpening=!0;return}if(this.showProblem(),this.fails.fail()){this.gaveUp=!0,this.video.close(),this.onGiveUp?.();return}let e=this.header;if(e){this.header=null,this.reopening=!0,this.failedWhileOpening=!1;try{this.openVideo(e)}finally{this.reopening=!1}this.sawKey=!1,this.keyAsk.waiting(),this.failedWhileOpening&&(this.failedWhileOpening=!1,this.restartVideo())}}get failed(){return this.gaveUp}setVideoEdge(e){this.video.setEdge(e)}get videoSeeks(){return{seeks:this.video.seeks,maxLagMs:Math.round(this.video.maxLagS*1e3),fromZero:this.video.fromZero,trims:this.video.trims,lastJump:this.video.lastJump}}get element(){return this.wrap}resume(){let e=this.video.el;e.paused&&e.play()?.catch?.(()=>{})}setHevc(e){this.hevc=e}startSound(){if(this.soundOn=!0,this.wasm)return this.wasm.start();if(!_a())return this.soundThroughWasm();this.audio.start()}soundThroughWasm(){if(this.wasm)return;this.audio.stop();let e=new ya(this.latency,()=>this.onSoundFail?.());this.wasm=e,e.setMuted(this.muted),this.audioHeader&&e.setHeader(this.audioHeader),this.soundOn&&e.start()}resumeSound(){this.soundOn&&(this.wasm?this.wasm.resume():this.audio.resume())}setMuted(e){this.muted=e,this.audio.setMuted(e),this.wasm?.setMuted(e)}soundReport(){return this.soundOn?this.wasm?ca(`wasm`,this.wasm.stats):this.audio.report():null}get soundPlaying(){return this.wasm?this.wasm.played:this.audio.playing}get sound(){return this.soundOn}onMessage(e){let t=new Uint8Array(e);if(t.length<1)return;let n=t[0],r=t.subarray(1);n===0?this.openVideo(r.slice()):n===1?this.onVideo(r):n===3?(this.audioHeader=r.slice(),(this.wasm??this.audio).setHeader(this.audioHeader)):n===4&&(this.wasm??this.audio).frame(r)}openVideo(e){let t=!!this.header&&this.header.length===e.length&&this.header.every((t,n)=>t===e[n]);if(t&&this.video.ready)return;if(this.gaveUp){if(t)return;this.gaveUp=!1,this.fails.clear()}this.header=e;let n=ti(e,this.hevc)??{w:1920,h:1080},r=Xi(e,this.hevc,n);r&&(this.stats.codec=/codecs="([^"]+)"/.exec(r.mime)?.[1]??``,this.video.open(r.mime,r.init)?(this.sawKey=!1,this.vTime=0,this.vLast=0):(this.problemShown=!0,this.onProblem(this.hevc?`no_hevc`:`decode`)))}onVideo(e){if(!this.video.ready&&!this.video.backlog)return;let t=Pi(e,this.hevc);if(this.video.dropped&&(this.video.dropped=!1,this.sawKey=!1),this.stats.arrived(),!this.sawKey&&!t)return this.stats.drop(),this.keyAsk.waiting();if(!t&&this.video.backlog>ta[this.latency])return this.sawKey=!1,this.stats.drop(),this.keyAsk.waiting();this.sawKey=!0,this.stats.drawn();let n=performance.now(),r=this.vLast?Math.min(9e3,Math.max(750,Math.round((n-this.vLast)*90))):1500;this.vLast=n,t&&this.video.markKey(this.vTime/9e4),this.video.push(Zi(this.video.nextSeq(),this.vTime,r,e,this.hevc,t)),this.vTime+=r}stop(){this.video.close(),this.audio.stop(),this.wasm?.stop()}};async function ka(e){let t=ri(e);if(t&&typeof VideoDecoder<`u`)try{if((await VideoDecoder.isConfigSupported({codec:t,codedWidth:1920,codedHeight:1080})).supported)return t}catch{}return Li(1920,1080)}var z={CROSS:1,CIRCLE:2,SQUARE:4,TRIANGLE:8,LEFT:16,RIGHT:32,UP:64,DOWN:128,L1:256,R1:512,L3:1024,R3:2048,OPTIONS:4096,SHARE:8192,TOUCHPAD:16384,PS:32768},Aa={buttons:0,l2:0,r2:0,lx:0,ly:0,rx:0,ry:0};function ja(e,t){let n=e=>Math.max(0,Math.min(1,e));return[Math.round(n(e)*1919),Math.round(n(t)*941)]}var Ma={ArrowUp:{button:z.UP},ArrowDown:{button:z.DOWN},ArrowLeft:{button:z.LEFT},ArrowRight:{button:z.RIGHT},Enter:{button:z.CROSS},Space:{button:z.CROSS},Backspace:{button:z.CIRCLE},Escape:{button:z.CIRCLE},KeyQ:{button:z.SQUARE},KeyE:{button:z.TRIANGLE},KeyZ:{button:z.L1},KeyC:{button:z.R1},Digit1:{trigger:`l2`},Digit3:{trigger:`r2`},KeyF:{button:z.L3},KeyG:{button:z.R3},Tab:{button:z.OPTIONS},Backquote:{button:z.SHARE},KeyH:{button:z.PS},KeyT:{button:z.TOUCHPAD},KeyW:{stick:`ly`,dir:-1},KeyS:{stick:`ly`,dir:1},KeyA:{stick:`lx`,dir:-1},KeyD:{stick:`lx`,dir:1},KeyI:{stick:`ry`,dir:-1},KeyK:{stick:`ry`,dir:1},KeyJ:{stick:`rx`,dir:-1},KeyL:{stick:`rx`,dir:1}};z.UP,z.DOWN,z.LEFT,z.RIGHT,z.CROSS,z.CIRCLE,z.SQUARE,z.TRIANGLE,z.L1,z.R1,z.L3,z.R3,z.OPTIONS,z.SHARE,z.PS,z.TOUCHPAD;var Na=e=>Math.max(-32768,Math.min(32767,Math.round(e)));function Pa(e,t=Ma){let n={...Aa};for(let r of e){let e=t[r];e&&(`button`in e?n.buttons|=e.button:`stick`in e?n[e.stick]=Na(n[e.stick]+e.dir*32767):n[e.trigger]=255)}return n}var Fa=[z.CROSS,z.CIRCLE,z.SQUARE,z.TRIANGLE,z.L1,z.R1,0,0,z.SHARE,z.OPTIONS,z.L3,z.R3,z.UP,z.DOWN,z.LEFT,z.RIGHT,z.PS,z.TOUCHPAD];function Ia(e){return Math.abs(e)<=1.01?Math.round((e+1)*3.5)%8:null}var La=[0,1,1,1,0,-1,-1,-1],Ra=[-1,-1,0,1,1,1,0,-1];function za(e,t){let n=e.axes[t.a]??0;if(t.hat){let e=Ia(n);return e===null?0:(t.hat===`x`?La:Ra)[e]}return t.inv?-n:n}var Ba={buttons:Fa.flatMap((e,t)=>e?[[e,{b:t}]]:[]),l2:{b:6},r2:{b:7},lx:{a:0},ly:{a:1},rx:{a:2},ry:{a:3}};function Va(e,t,n=!1){if(`b`in t){let r=e.buttons[t.b];return r?n&&r.value>0?Math.min(1,r.value):Math.max(+!!r.pressed,r.value):0}if(`h`in t){let n=Ia(e.axes[t.h]??9);if(n===null)return 0;let r=(n-t.at+8)%8;return+(r===0||r===1||r===7)}let r=e.axes[t.a];if(r===void 0)return 0;let i=t.rest??0;return Math.min(1,Math.max(0,(r-i)/(t.d-i)))}function Ha(e){if(e.mapping===`standard`)return Ba;let t=Ua.get(e.id);if(t)return t;let n=e.axes.findIndex(e=>Math.abs(e)>1.05);if(n<0)return Ba;let r={...Ba,buttons:[...Ba.buttons,[z.UP,{h:n,at:0}],[z.RIGHT,{h:n,at:2}],[z.DOWN,{h:n,at:4}],[z.LEFT,{h:n,at:6}]]};return Ua.set(e.id,r),r}var Ua=new Map;function Wa(e,t=Ha){let n={...Aa},r=e=>Math.abs(e)<.08?0:Na(e*32767),i=(e,t)=>Math.abs(t)>Math.abs(e)?t:e,a=(e,t)=>t?r(za(e,t)):0;for(let r of e){if(!r||!r.connected)continue;let e=t(r);for(let[t,i]of e.buttons)Va(r,i)>.5&&(n.buttons|=t);e.l2&&(n.l2=Math.max(n.l2,Math.round(Va(r,e.l2,!0)*255))),e.r2&&(n.r2=Math.max(n.r2,Math.round(Va(r,e.r2,!0)*255))),n.lx=i(n.lx,a(r,e.lx)),n.ly=i(n.ly,a(r,e.ly)),n.rx=i(n.rx,a(r,e.rx)),n.ry=i(n.ry,a(r,e.ry))}return n}function Ga(e,t){return{buttons:e.buttons|t.buttons,l2:Math.max(e.l2,t.l2),r2:Math.max(e.r2,t.r2),lx:Na(e.lx+t.lx),ly:Na(e.ly+t.ly),rx:Na(e.rx+t.rx),ry:Na(e.ry+t.ry),touch:e.touch??t.touch??null,motion:e.motion??t.motion??null}}function Ka(e,t,n,r=()=>globalThis.navigator?.getGamepads?.()??[]){let i=e=>e?.vibrationActuator;for(let a of e.some(i)?e:r()){let e=i(a);e&&(t===0&&n===0?e.reset?.():e.playEffect?.(`dual-rumble`,{duration:1e3,strongMagnitude:t/255,weakMagnitude:n/255}))}}var qa=new Map;function Ja(e,t){return{id:`${e.id} (app)`,index:3+e.slot,connected:!0,mapping:`standard`,timestamp:0,axes:e.axes,buttons:e.buttons.map(e=>({pressed:e>.5,touched:e>0,value:e})),vibrationActuator:t?.vibrationActuator??null,hapticActuators:t?.hapticActuators??[]}}function Ya(e){let t=e?.getGamepads?.()??[];return qa.size===0||t.some(e=>!!e?.connected)?[...t]:[...qa.values()].sort((e,t)=>e.slot-t.slot).map(e=>Ja(e))}var Xa=`b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b1,b2,b0,b3,b6,b4,b7,b5,b8,b9,,,-a1,+a1,-a0,+a0(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,,,,,,,a0,a1(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b2,b1,b3,b0,b4,b5,,,b8,b9,,,-a1,+a1,-a0,+a0(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b2,b3,b0,b1,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b11,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a5(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1(b1,b0,b2,b3,,b7,a3,a4,,b9,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a5,a2(b1,b0,b2,b3,,b7,a3,a4,,b9,,,b12,b14,b15,b13,,,a0,a1,a5,a2(b1,b0,b2,b3,,b7,b4,b5,,b9,,,b12,b14,b15,b13,,,a0,a1,a5~,a2~(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,b8,,a0,a1,a3,a4(b1,b2,,,b7,b5,b4,,,b9,,,b12,b14,b15,b13,,,a0,a1,a5,a2(b0,b1,b3,b4,b6,b5,b7,b2,b8,,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b7,b9,b10,b2,b8,,,h0.1,h0.4,h0.8,h0.2,b5,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,-a1,+a1,-a0,+a0(b0,b1,b3,b4,b6,b5,b7,b2,,b8,,,-a1,+a1,-a0,+a0(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b12,b13,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a5,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b14,,a0,a1,a2,a3(b14,b13,b15,b12,b10,b11,b8,b9,b0,b3,b1,b2,b4,b6,b7,b5,b16,,a0,a1,a2,a3(b0,b1,b3,b2,b4,b5,a2,a5,b8,b9,b11,b12,h0.1,h0.4,h0.8,h0.2,b10,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13,a0,a1,a2,a5(b2,b1,b3,b0,b6,b7,b4,b5,b8,b9,,,-a1,+a1,-a0,+a0(b1,b2,b0,b3,b4,b5,,,b8,b9,,,b12,b13,b15,b14,,,a0,a1,a3,a4(b0,b1,b3,b2,b4,b5,b6,b7,b8,b9,b11,b12,b13,b14,b15,b16,b10,,a0,a1,a2,a3(b0,b1,b3,b2,,b6,a2,a5,,b7,,,b8,b9,b10,b11,,,a0,a1,a3,a4(b0,b1,b3,b2,b4,b5,,,b8,b9,,,b10,b11,b12,b13,,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,,,b13,b8,b10,,,,,,,,hx,hy(b0,b1,b2,b3,b4,b5,,,b12,b9,b11,,,,,,,,hx,hy(b0,b1,b3,b2,b5,b6,b7,b8,b9,b10,b12,b13,b14,b15,b16,b17,b11,,a0,a1,a2,a3(b0,b1,b3,b2,b5,b6,b7,b8,b9,b10,b12,b13,h0.1,h0.4,h0.8,h0.2,b11,,a0,a1,a2,a3(b0,b1,b3,b2,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b0,b1,,,,b2,,b4,,b5,,,h0.1,h0.4,h0.8,h0.2,b6(b0,b1,b2,b3,b12,b4,b13,b5,b14,b6,b15,b7,b11,b8,b10,b9,b16,,a0,a1~,a2,a3~(b1,b3,b0,b2,b13,b5,b12,b4,,b6,,,b11,b8,b10,b9,b16,,a0,a1~,a2,a3~(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b33,,a0,a1,a2,a3(b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b16,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b15,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,,,,,b8,,a0,a1,a3,a4(b1,b0,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12,b13(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,,h0.1,h0.4,h0.8,h0.2,b12,b13(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b11,b12,h0.1,h0.4,h0.8,h0.2,b10,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,b12,b13,b14,b15,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,b14,b13,b14,b13,,,a0,a1,a3,a4(b1,b0,b2,b3,,,,,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b2,b3,b1,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b10(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12,b13,a0,a1,a2,a5(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,+a2,+a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,b8,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b13,,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b0,b3,b2,b4,b5,a2,a5,b6,b7,,,h0.1,h0.4,h0.8,h0.2,b8(b1,b2,,,,,,,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b21,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a5,a4,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,b8,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b13,b13,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,a5,a4,,b6,b7,b8,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a2,a5,b7,b6,b9,b10,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,b7,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a5,a4,b9,b6,b7,b8,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b22,,a0,a1,a2,a3(b0,b1,b2,b3,b4,b5,a2,a3,b6,b7,b9,,b12,b14,b15,b13,b8,,a0,a1(b3,b4,b5,b6,b7,b8,a9,a8,b11,b12,b14,b15,b16,b17,b18,b19,b13,,a0,a1,a2,a3(b0,b1,b3,b4,b8,b6,b9,b7,,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b7,b9,b6,b8,b10,b11,,,h0.1,h0.4,h0.8,h0.2(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b9,b10,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b1,b0,b4,b3,b6,b7,,,b10,b11,,,-a1,+a1,-a0,+a0(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,,,b6,b7,b8,b9,,b11,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b3,b1,b4,,b10,a5,a4,,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,,,b6,b7,b8,b9,b10,b11,b13,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,,,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b0,b1,b3,b4,,b6,,b7,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,,,,,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a8,b9,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b8,b6,b9,b7,,b10,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a4,a5,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,,,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b2,b0,b3,b6,b4,b7,b5,b8,b9,,,-a4,+a4,-a3,+a3(b4,b8,b0,b12,b16,b20,b24,b28,b32,b36,b40,b44,h0.1,h0.4,h0.8,h0.2,,,a0,a4,a8,a12(b8,b12,b0,b4,b16,b20,b24,b28,b32,b36,,,h0.1,h0.4,h0.8,h0.2,b44,,a0,a4,a8,a12(b4,b0,b8,b12,,b28,a12,a16,,b36,,,h0.1,h0.4,h0.8,h0.2,,,a0,a4,a20,a8(b1,b2,b0,b3,,b7,a3,a4,,b9,,,b12,b14,b15,b13,,,a0,a1,a5,a2(b4,b0,b8,b12,,b28,a12,a16,,b36,,,b48,b56,b60,b52,,,a0,a4,a20,a8(b1,b2,,,b7,b5,a3,,,b9,,,b12,b14,b15,b13,,,a0,a1,a5,a2(b0,b1,b2,b3,b4,b5,a2,a5,b9,b8,b6,b7,b11,b12,b13,b14,b10,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b7,,,b5,b8,,,-a1,+a1,-a0,+a0,b2(b0,b1,b2,b3,b4,b5,b6,b15,b8,b9,,,h0.1,h0.4,h0.8,h0.2(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b13,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a5(b0,b1,b3,b4,b6,b7,a5,a4,b12,b13,b15,b16,h0.1,h0.4,h0.8,h0.2,b14,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,,,-a1,+a1,-a0,+a0,b2(b0,b1,b3,b4,b6,b7,,,b10,b11,,,-a1,+a1,-a0,+a0(b0,b1,b3,b4,b6,b7,b8,a4,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a31(b0,b1,b3,b4,b8,b6,b9,b7,,b11,,,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,a5,a4,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a3,a4(b1,b0,b4,b3,b6,b7,a4,a5,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a3(b1,b0,b4,b3,b6,b7,a5,a4,b10,b11,,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,,,b10,b11,,,,,,,,,hx,hy(b0,b1,b2,b3,b4,b5,b6,b7,b16,b15,b8,b9,b10,b11,b13,b12,b17,,a0,a1~,a2,a3~(b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a4(b2,b1,b3,b0,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b2,b3,b33,b5,,,b6,b7,,,h0.1,h0.4,h0.8,h0.2(b0,b1,b3,b4,b6,b2,,,,b9,,,h0.1,h0.4,h0.8,h0.2(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a3,a4(b1,b2,,,b6,,b9,b7,,b8,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a2(b2,b1,b3,b0,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b3,b4,,b6,,b2,b7,b9,,,b2,b14,b15,b13(b0,b1,b2,b3,b4,b5,a2,a5,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b5,b7,b2,b10,b8,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b6,b7,a5~,a2~,b2,b8,b8,b5,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b4,,b9,b10,b6,b7,b8,,b5,b2,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,,,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b5,b4,b10,b11,b7,b6,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b3,b2,b6,b7,b4,b5,b8,b9,b11,b12,b13,b14,b15,b16,,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b16,b19,b17,b18,b6,b7,b8,b9,b10,b11,b13,,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a3,a4(b2,b1,b3,b0,b6,b7,b4,b5,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a5,a2(b0,b1,b2,b3,b4,b5,a2,a2,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,a2,,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,b8,b9,b6,b7,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,b10,b11,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,b10,b11,b7,b6,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b1,b2,b0,b3,b10,b5,b11,b7,b8,b9,b4,b6,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b2,b0,b3,b5,b7,b4,b6,b8,b9,,,h0.1,h0.4,h0.8,h0.2,b12(b1,b2,b0,b3,b4,b5,a3,a4,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a3(b1,b2,b0,b3,b4,b5,a3,a4,b8,b13,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,b13,a0,a1,a2,a5(b0,b4,b2,b1,b3,b6,,,b11,b9,,,h0.1,h0.4,h0.8,h0.2(b1,b2,b0,b3,b4,b5,a2,a5,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b2,b3,b9,b10,a4,a5,b4,b6,b7,b8,b11,b12,b13,b14,,,a0,a1,a2,a3(b1,b0,b3,b2,b4,b5,,,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b1,b2,b0,b3,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b2,b3,b4,b5,+a2,-a2,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b1,b0,b3,b2,b4,b5,b6,b7,b8,b9,b10,b11,h0.1,h0.4,h0.8,h0.2,b12,,a0,a1,a2,a3(b0,b1,b3,b4,b6,b7,,,,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,+a2,-a2,b6,b7,b8,b9,b11,b14,b12,b13,b10,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,,a2,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,b3,b4,b6,b7,a4,a3,,,b13,b14,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b0,b1,b2,b3,b4,b5,,,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a2,a5(b6,b7,b9,b10,b12,b13,b14,b15,b16,b17,b19,b20,h0.1,h0.4,h0.8,h0.2,b18,,a0,a1,a3,a4(b0,b1,b2,b3,b4,b5,+a2,-a2,b6,b7,b8,b9,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a4(b0,b1,,,,,,,b7,b6,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b6,b7,,,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1(b0,b1,b3,b4,b6,b7,,,b10,b11,,,,,,,,,a0,a1(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a2,a5(b1,b0,b4,b3,b6,b7,b8,b9,b10,b11,b13,b14,h0.1,h0.4,h0.8,h0.2,b2,,a0,a1,a3,a4(b1,b0,b4,b3,,b6,,b7,b10,b11,,,h0.1,h0.4,h0.8,h0.2,,,a0,a1,a3,a5`.split(`(`),Za={l00790006:0,l00790011:1,l00790016:2,l00790122:3,l00790126:4,l00791800:5,l00791803:6,l0079181a:7,l0079181b:8,l0079181c:9,l00791830:10,l00791843:11,l00791844:12,l00791845:11,l00791846:13,l007918d2:7,l007918d4:14,l0079954e:15,l046dc20a:16,l046dc211:17,l046dc216:5,l046dc218:5,l046dc219:5,l046dc21a:18,l046dc21d:14,l046dc21e:14,l046dc21f:14,l046dcad1:5,l046dcad2:5,l04b4010a:19,l04b42411:20,l04b42412:21,l054c0268:22,l054c05c4:23,l054c09cc:24,l054c0ba0:24,l054c0cda:25,l054c0ce6:24,l054c0df2:24,l054c0e5f:24,l054c1337:26,l057e0330:27,l057e0337:28,l057e1337:29,l057e2006:30,l057e2007:31,l057e2008:32,l057e2009:33,l057e2017:34,l057e201e:35,l057e2069:36,l057e2073:37,l05ac022d:38,l05ac055b:39,l05ac057a:40,l05ac061a:41,l0e6f0109:42,l0e6f011e:7,l0e6f011f:14,l0e6f0128:5,l0e6f012f:7,l0e6f0130:7,l0e6f0131:14,l0e6f0139:14,l0e6f0146:43,l0e6f0164:14,l0e6f0180:7,l0e6f0181:7,l0e6f0184:7,l0e6f0185:44,l0e6f0187:7,l0e6f0188:7,l0e6f0203:45,l0e6f0207:46,l0e6f0213:14,l0e6f0214:7,l0e6f02a7:14,l0e6f02a8:47,l0e6f02b2:48,l0e6f02b8:14,l0e6f02c8:14,l0e6f02d7:49,l0e6f02d8:14,l0e6f02da:14,l0e6f02ef:14,l0e6f02f1:14,l0e6f0301:14,l0e6f0315:14,l0e6f0401:14,l0e6f0413:14,l0e6f1112:50,l0e6f1113:51,l0e6ff501:14,l0f0d0009:7,l0f0d0010:42,l0f0d0011:7,l0f0d0016:52,l0f0d0022:42,l0f0d004d:7,l0f0d005e:53,l0f0d005f:54,l0f0d0066:24,l0f0d0067:14,l0f0d006a:8,l0f0d006b:7,l0f0d006d:55,l0f0d006e:7,l0f0d0084:8,l0f0d0085:7,l0f0d0086:47,l0f0d0087:56,l0f0d0088:57,l0f0d0092:58,l0f0d00aa:39,l0f0d00c1:7,l0f0d00ee:59,l0f0d00f6:60,l0f0d00fb:39,l0f0d0137:61,l0f0d0138:62,l0f0d0150:14,l0f0d0185:14,l0f0d0196:63,l0f0d01ab:63,l15320401:24,l15320402:7,l15320705:64,l15320900:65,l15320a03:14,l15320a14:14,l15320a29:14,l15321000:8,l15321008:66,l1532100a:59,l1532100b:24,l15321100:24,l18d19400:65,l20d60dad:67,l20d62002:68,l20d62005:14,l20d6200b:14,l20d6200f:69,l20d62065:14,l20d62802:14,l20d64001:70,l20d64002:70,l20d64005:14,l20d66271:71,l20d6792a:24,l20d689e5:71,l20d6a710:5,l20d6a711:7,l20d6a712:7,l20d6a713:7,l20d6a714:7,l20d6ca6d:7,l24c65300:14,l24c6531a:14,l24c6541a:14,l24c6543a:14,l24c6581a:14,l24c65b02:14,l24c65d04:14,l24c6891a:63,l24c6891b:63,l24c6892a:72,l24c6892b:63,l24c6fafe:14,l27f80bbf:63,l28de1102:73,l28de1105:73,l28de1106:73,l28de1142:73,l28de11fc:43,l28de11ff:14,l28de1201:73,l28de1202:73,l28de1205:74,l2dc80651:75,l2dc81003:76,l2dc81080:76,l2dc82000:14,l2dc82003:14,l2dc8200a:77,l2dc82019:14,l2dc82025:14,l2dc82101:63,l2dc82830:78,l2dc82862:79,l2dc82865:79,l2dc82869:80,l2dc8286a:81,l2dc83010:82,l2dc83011:63,l2dc83012:63,l2dc83013:63,l2dc83015:63,l2dc83016:63,l2dc83017:63,l2dc83019:83,l2dc8301b:63,l2dc8301d:63,l2dc83100:84,l2dc83101:85,l2dc83102:85,l2dc83103:85,l2dc83104:85,l2dc83106:14,l2dc8310a:14,l2dc8310b:14,l2dc83230:86,l2dc83810:79,l2dc83820:87,l2dc85006:88,l2dc85101:89,l2dc85103:86,l2dc85104:90,l2dc85107:91,l2dc85108:91,l2dc85109:90,l2dc85111:92,l2dc85112:82,l2dc86000:92,l2dc86001:93,l2dc86002:92,l2dc86006:82,l2dc86007:94,l2dc86009:82,l2dc86012:63,l2dc86100:87,l2dc86101:93,l2dc86102:92,l2dc86728:95,l2dc89000:96,l2dc89001:96,l2dc89012:93,l2dc89015:79,l2dc89018:78,l2dc89020:97,l2dc89025:98,l2dc8ab21:78,l35371004:14,l35371007:63,l3537100b:14,l35371046:63,l35371058:63,l35371094:63,l35371097:63,l358a0102:63,l358a0202:63,l358a0203:63,l358a0204:63,m00790006:99,m00790011:100,m00791800:101,m00791803:102,m0079181c:41,m00791843:103,m00791844:104,m00791846:105,m007918d2:39,m0079954e:106,m046dc216:5,m046dc218:5,m046dc219:5,m046dc21a:18,m046dc21f:107,m04b4010a:108,m04b42411:20,m04b42412:20,m054c0268:22,m054c05c4:24,m054c09cc:24,m054c0ba0:24,m054c0cda:25,m054c0ce6:24,m054c0df2:24,m054c0e5f:24,m054c1337:26,m057e2006:30,m057e2007:31,m057e2009:60,m057e2017:109,m057e2069:36,m057e2073:37,m05ac061a:41,m0e6f0109:42,m0e6f0184:110,m0e6f0187:5,m0e6f0201:107,m0e6f0203:45,m0e6f0207:46,m0e6f0401:107,m0f0d002d:54,m0f0d004d:7,m0f0d005e:111,m0f0d005f:7,m0f0d0066:24,m0f0d006e:7,m0f0d0084:8,m0f0d0085:7,m0f0d0087:112,m0f0d0088:57,m0f0d0092:58,m0f0d00aa:39,m0f0d00c1:7,m0f0d00ee:113,m0f0d00f6:3,m0f0d0138:62,m0f0d0200:7,m15320401:24,m15320402:7,m15320705:64,m15320900:65,m15320a03:107,m15321000:8,m15321100:24,m18d19400:65,m20d66271:71,m20d6792a:24,m20d6a710:7,m20d6a711:44,m20d6ca6d:7,m24c6543a:107,m24c65d04:107,m24c6891a:114,m24c6891b:63,m24c6892a:64,m24c6892b:63,m24c6fafe:107,m2dc80651:115,m2dc82820:116,m2dc82830:78,m2dc82840:78,m2dc82865:87,m2dc82869:80,m2dc8286a:81,m2dc83011:63,m2dc83012:63,m2dc83013:63,m2dc83015:117,m2dc83016:63,m2dc83017:118,m2dc83019:83,m2dc8301b:63,m2dc8301d:63,m2dc83100:9,m2dc83101:85,m2dc83102:85,m2dc83103:85,m2dc83104:85,m2dc83105:84,m2dc83230:119,m2dc83810:94,m2dc85006:120,m2dc85101:89,m2dc85103:86,m2dc85104:90,m2dc85107:121,m2dc85108:122,m2dc85109:90,m2dc85111:82,m2dc85112:82,m2dc86001:79,m2dc86002:85,m2dc86006:82,m2dc86009:123,m2dc86101:85,m2dc86102:85,m2dc86728:95,m2dc89000:96,m2dc89001:79,m2dc89012:78,m2dc89015:124,m2dc89018:78,m2dc89020:125,m2dc89025:126,m2dc89026:127,m2dc8ab12:116,m35371022:63,m35371041:63,m35371046:63,m35371104:63,m358a0102:63,m358a0201:128,m358a0202:128,m358a0203:128,m358a0204:63,w00790002:129,w00790007:129,w0079000a:129,w00790016:18,w00790122:99,w00790126:130,w00791804:131,w0079181a:7,w0079181b:113,w00791824:132,w00791830:133,w00791845:11,w00791847:12,w0079184f:134,w00791879:135,w0079188f:136,w007918ae:137,w007918d4:138,w046dc209:139,w046dc20a:16,w046dc20b:140,w046dc211:141,w046dc21d:138,w046dc21e:142,w046dc242:142,w046dca84:143,w046dca88:143,w046dcad1:5,w046dcad2:7,w04b42410:144,w04b4c681:130,w054c05c5:145,w057e0330:146,w05ac022d:144,w05ac033d:147,w05ac044d:147,w05ac055b:39,w05ac057a:148,w0e6f0003:149,w0e6f0111:7,w0e6f0114:7,w0e6f0119:7,w0e6f011a:7,w0e6f011e:7,w0e6f011f:150,w0e6f0124:42,w0e6f0128:7,w0e6f012f:7,w0e6f0130:7,w0e6f0132:7,w0e6f0146:138,w0e6f0164:151,w0e6f0180:7,w0e6f0181:7,w0e6f0185:44,w0e6f0188:7,w0e6f0189:7,w0e6f0214:7,w0e6f0301:138,w0e6f1113:51,w0e6f6302:7,w0f0d0009:7,w0f0d000a:152,w0f0d000c:153,w0f0d000d:154,w0f0d0010:155,w0f0d0011:57,w0f0d0013:155,w0f0d001b:152,w0f0d0021:155,w0f0d0022:54,w0f0d0025:42,w0f0d0026:155,w0f0d0027:42,w0f0d0032:155,w0f0d003d:156,w0f0d0040:157,w0f0d0042:155,w0f0d0049:7,w0f0d004b:155,w0f0d0051:155,w0f0d0054:7,w0f0d0055:8,w0f0d005b:113,w0f0d005c:7,w0f0d0064:155,w0f0d0067:70,w0f0d006a:8,w0f0d006b:7,w0f0d006f:158,w0f0d0070:57,w0f0d007b:155,w0f0d008a:8,w0f0d008b:7,w0f0d008c:138,w0f0d009c:8,w0f0d00a0:159,w0f0d00a5:160,w0f0d00a6:111,w0f0d00ad:161,w0f0d00ae:142,w0f0d00af:162,w0f0d00c0:138,w0f0d00c9:5,w0f0d00d8:163,w0f0d00dc:138,w0f0d0101:5,w0f0d0104:142,w0f0d0123:144,w0f0d0137:164,w0f0d0162:165,w0f0d0164:166,w0f0d0196:134,w0f0d0202:167,w0f0d1011:168,w153202a6:169,w15320300:170,w15320707:147,w15320a14:138,w15321004:145,w15321007:145,w15321009:145,w1532100a:5,w18d12c40:171,w20d60060:7,w20d60dad:142,w20d6319f:7,w20d64026:134,w20d64033:134,w20d6571d:7,w20d6576d:7,w20d65795:7,w20d657c7:7,w20d657e5:7,w20d689e5:172,w20d6a712:7,w20d6a713:7,w20d6a714:7,w20d6a720:7,w24c6531a:153,w24c65b02:138,w27f80bbf:173,w28de11fc:70,w28de11ff:174,w2dc802e0:175,w2dc81003:176,w2dc81080:176,w2dc82100:144,w2dc82810:177,w2dc82862:78,w2dc83000:78,w2dc83001:178,w2dc8301c:134,w2dc8310a:134,w2dc83820:179,w2dc85001:180,w2dc86000:79,w2dc86003:123,w2dc86012:134,w2dc86100:85,w2dc86103:123,w2dc8ab11:179,w2dc8ab20:178,w2dc8ab21:78,w35371004:138,w35371007:134,w35371094:134,w35371116:134},Qa=e=>e.toLowerCase().padStart(4,`0`);function $a(e){let t=/^(.*?)\s*\((?:[^()]*?\s)?Vendor:\s*([0-9a-f]{1,4})\s+Product:\s*([0-9a-f]{1,4})\s*\)\s*$/i.exec(e);if(t)return{vendor:Qa(t[2]),product:Qa(t[3]),name:t[1].trim()};let n=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-(.*)$/i.exec(e.trim());return n?{vendor:Qa(n[1]),product:Qa(n[2]),name:n[3].trim()}:null}function eo(e){return($a(e)?.name??e.replace(/\s*\((?:XInput\s*)?STANDARD GAMEPAD\)\s*$/i,``)).trim()||e}function to(e=globalThis.navigator){let t=e?.userAgent??``;return/Android|iPhone|iPad|iPod/i.test(t)?null:/Macintosh|Mac OS X/i.test(t)?(e?.maxTouchPoints??0)>1?null:`m`:/Windows/i.test(t)?`w`:/Linux|CrOS|X11/i.test(t)?`l`:null}function no(e,t){if(!t)return null;let n=t===`l`?[`l`]:[`m`,`w`];for(let t of n){let n=Za[`${t}${e.vendor}${e.product}`];if(n!==void 0)return Xa[n]??null}return null}function ro(e){return e.mapping!==`standard`&&$a(e.id)?.vendor===`2dc8`}var io={6003:`switch`,6006:`switch`,6103:`switch`,3010:`switch`,6001:`startx`,6002:`startx`,6101:`startx`,6102:`startx`,3011:`receiver`,3012:`receiver`,3013:`receiver`,3015:`receiver`,3016:`receiver`,3017:`receiver`,"301b":`receiver`,"301c":`receiver`,"301d":`receiver`,6012:`receiver`,5112:`none`,9020:`none`};function ao(e){let t=$a(e);return t&&io[t.product]||`manual`}var oo={1:0,2:2,4:4,8:6};function so(e){let t=0,n=!1;for(let r of e){let e=/a(\d+)/.exec(r);e&&(t=Math.max(t,Number(e[1])+1)),r.startsWith(`h`)&&(n=!0)}return{n:t,hat:n}}function co(e,t,n){let{n:r,hat:i}=so(t),a=Fa.length,o=e.axes.findIndex(e=>Math.abs(e)>1.05),s=e=>e;if(i&&o<0)return n===`l`&&e.axes.length>=r+2?{hat:-1,hatXY:r,axis:s}:null;if(!(i?o>r:n!==`l`&&e.axes.length>=r+2))return{hat:o,hatXY:-1,axis:s};if(r<=4)return{hat:o,hatXY:-1,axis:e=>[0,1,2,5][e]??e};let c=t[a+2]?.replace(`~`,``)===`a2`&&t[a+3]?.replace(`~`,``)===`a3`,l=[t[6],t[7]].every(e=>/^a[45]~?$/.test(e??``));return r===6&&c&&l?{hat:o,hatXY:-1,axis:e=>[0,1,2,5,3,4][e]??e}:{hat:o,hatXY:-1,axis:s}}function lo(e,t){let n=/^b(\d+)$/.exec(e);if(n)return{b:Number(n[1])};if(n=/^([+-]?)a(\d+)(~?)$/.exec(e),n){let e=t.axis(Number(n[2]));return n[1]===`+`?{a:e,d:1}:n[1]===`-`?{a:e,d:-1}:n[3]?{a:e,d:-1,rest:1}:{a:e,d:1,rest:-1}}if(n=/^h0\.(\d)$/.exec(e),n){let e=oo[n[1]];if(e===void 0)return null;if(t.hat>=0)return{h:t.hat,at:e};if(t.hatXY>=0)return e===0?{a:t.hatXY+1,d:-1}:e===4?{a:t.hatXY+1,d:1}:e===6?{a:t.hatXY,d:-1}:{a:t.hatXY,d:1}}return null}function uo(e,t){let n=/^a(\d+)(~?)$/.exec(e);if(n)return n[2]?{a:t.axis(Number(n[1])),inv:!0}:{a:t.axis(Number(n[1]))};if(e===`hx`||e===`hy`){if(t.hat>=0)return{a:t.hat,hat:e===`hx`?`x`:`y`};if(t.hatXY>=0)return{a:t.hatXY+ +(e===`hy`)}}return null}function fo(e,t,n){let r=e.split(`,`),i=co(t,r,n);if(!i)return null;let a={buttons:[],l2:null,r2:null,lx:null,ly:null,rx:null,ry:null};for(let e=0;eArray.isArray(e)&&e.length===2&&typeof e[0]==`number`&&go(e[1]))&&[t.l2,t.r2,t.lx,t.ly,t.rx,t.ry].every(go)}function vo(){try{let e=It(ho),t=e?JSON.parse(e):null;return!t||typeof t!=`object`||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>_o(e[1])))}catch{return{}}}function yo(e,t){let n=vo();return t?n[e]=t:delete n[e],Ft(ho,JSON.stringify(n)),bo=n,n}var bo=null;function xo(e){return bo??=vo(),bo[e.id]??wo(bo,e.id)??mo(e)??Ha(e)}function So(e){return bo??=vo(),bo[e.id]?`saved`:e.mapping===`standard`?`standard`:mo(e)?`known`:`guess`}function Co(e){return mo(e)??Ha(e)}function wo(e,t){if(!t.endsWith(` (app)`))return null;let n=t.slice(0,-6).trim().toLowerCase();if(!n)return null;let r=Object.keys(e).filter(e=>{let t=e.trim().toLowerCase();return t===n||t.includes(n)}),i=r.find(e=>e.trim().toLowerCase()===n)??(r.length===1?r[0]:null);return i?(bo=yo(t,e[i]),e[i]):null}function To(e){return{buttons:e.buttons.map(e=>Math.max(+!!e.pressed,e.value)),axes:[...e.axes]}}function Eo(e,t){let n=null;if(t.buttons.forEach((t,r)=>{let i=t-(e.buttons[r]??0);t>.5&&i>.5&&(!n||i>n.amount)&&(n={src:{b:r},amount:i})}),n)return n.src;for(let n=0;n1.05?Ia(t.axes[n]):null;if(r!==null)return{h:n,at:r}}return t.axes.forEach((t,r)=>{let i=e.axes[r]??0,a=t-i;if(!(Math.abs(a)<.6)&&(!n||Math.abs(a)>n.amount)){let e=a>0?1:-1;n={src:Math.abs(i)>.5?{a:r,d:e,rest:i}:{a:r,d:e},amount:Math.abs(a)}}}),n?n.src:null}function Do(e,t){let n=null;if(t.axes.forEach((t,r)=>{let i=t-(e.axes[r]??0);Math.abs(i)>=.6&&(!n||Math.abs(i)>Math.abs(n.moved))&&(n={a:r,moved:i})}),!n)return null;let r=n;return r.moved>0?{a:r.a}:{a:r.a,inv:!0}}var Oo=[{kind:`button`,bit:z.CROSS,name:`✕`},{kind:`button`,bit:z.CIRCLE,name:`○`},{kind:`button`,bit:z.SQUARE,name:`□`},{kind:`button`,bit:z.TRIANGLE,name:`△`},{kind:`button`,bit:z.UP,name:`↑`},{kind:`button`,bit:z.DOWN,name:`↓`},{kind:`button`,bit:z.LEFT,name:`←`},{kind:`button`,bit:z.RIGHT,name:`→`},{kind:`button`,bit:z.L1,name:`L1`},{kind:`button`,bit:z.R1,name:`R1`},{kind:`trigger`,which:`l2`,name:`L2`},{kind:`trigger`,which:`r2`,name:`R2`},{kind:`button`,bit:z.L3,name:`L3`},{kind:`button`,bit:z.R3,name:`R3`},{kind:`button`,bit:z.OPTIONS,name:`Options`},{kind:`button`,bit:z.SHARE,name:`Create`},{kind:`button`,bit:z.PS,name:`PS`},{kind:`button`,bit:z.TOUCHPAD,name:`Touchpad`},{kind:`axis`,which:`lx`,name:`L →`},{kind:`axis`,which:`ly`,name:`L ↓`},{kind:`axis`,which:`rx`,name:`R →`},{kind:`axis`,which:`ry`,name:`R ↓`}];function ko(){return{buttons:[],l2:null,r2:null,lx:null,ly:null,rx:null,ry:null}}function Ao(e,t,n){return t.kind===`button`?{...e,buttons:[...e.buttons.filter(([e])=>e!==t.bit),[t.bit,n]]}:(t.kind,{...e,[t.which]:n})}function jo(e,t=Ba){let n=new Set(e.buttons.map(([e])=>e)),r=e=>`b`in e?`b${e.b}`:`h`in e?`h${e.h}.${e.at}`:`a${e.a}${e.d}`,i=new Set([...e.buttons.map(([,e])=>r(e)),...[e.l2,e.r2].filter(e=>!!e).map(r)]);return{buttons:[...e.buttons,...t.buttons.filter(([e,t])=>!n.has(e)&&!i.has(r(t)))],l2:e.l2??t.l2,r2:e.r2??t.r2,lx:e.lx??t.lx,ly:e.ly??t.ly,rx:e.rx??t.rx,ry:e.ry??t.ry}}var Mo=Oo.filter(e=>e.kind!==`button`||![z.L3,z.R3,z.OPTIONS,z.SHARE,z.PS,z.TOUCHPAD].includes(e.bit));function No(e,t){return t.buttons.every((t,n)=>Math.abs(t-(e.buttons[n]??0))<.3)&&t.axes.every((t,n)=>Math.abs(t-(e.axes[n]??0))<.3)}var Po=class{constructor(e=Oo){this.steps=e,this.step=0,this.prof=ko(),this.rest=null,this.waiting=!0}get done(){return this.step>=this.steps.length}get current(){return this.steps[this.step]??null}feed(e){if(this.done)return!1;if(!this.rest)return this.rest=e,this.waiting=!1,!1;if(this.waiting)return No(this.rest,e)&&(this.waiting=!1),!1;let t=this.steps[this.step],n=t.kind===`axis`?Do(this.rest,e):Eo(this.rest,e);return n?(this.prof=Ao(this.prof,t,n),this.go(this.step+1),!0):!1}skip(){this.go(this.step+1)}back(){this.step>0&&this.go(this.step-1)}go(e){this.waiting=!0,this.step=Math.min(e,this.steps.length)}profile(e=Ba){return jo(this.prof,e)}};function Fo(e,t){return e.buttons===t.buttons&&e.l2===t.l2&&e.r2===t.r2&&e.lx===t.lx&&e.ly===t.ly&&e.rx===t.rx&&e.ry===t.ry&&(e.touch?.[0]??-1)===(t.touch?.[0]??-1)&&(e.touch?.[1]??-1)===(t.touch?.[1]??-1)&&(e.motion?.t??-1)===(t.motion?.t??-1)}function Io(){try{return typeof sessionStorage<`u`?sessionStorage:null}catch{return null}}var Lo=e=>`ps5upload.join.token.${e??`app`}`,Ro=class{constructor(e){this.o=e,this.ws=null,this.stage={kind:`connecting`},this.token=null,this.player=0,this.last={...Aa},this.lastSent=0,this.neutral=!1,this.stopped=!1,this.attempt=0,this.deadline=0,this.raf=0,this.keepalive=null,this.pinger=null,this.retry=null,this.lastHeard=0,this.hostAway=!1,this.pings=0,this.now=e.now??(()=>Date.now()),this.storage=e.storage===void 0?Io():e.storage,this.WS=e.WebSocketImpl??WebSocket,this.seq=this.now()>>>0;try{this.token=this.storage?.getItem(this.key)??null}catch{this.token=null}}get key(){return Lo(this.o.invite??this.o.code??null)}get current(){return this.stage}get socket(){return this.ws}get resumeToken(){return this.token}setStage(e){this.stage=e,this.o.onStage(e)}start(){if(this.stopped=!1,this.setStage({kind:`connecting`}),this.connect(),this.stopped)return;let e=()=>{this.sendPad(!1),this.raf=(this.o.raf??(e=>window.requestAnimationFrame(e)))(e)};this.raf=(this.o.raf??(e=>window.requestAnimationFrame(e)))(e),this.keepalive=setInterval(()=>this.sendPad(!1),100),this.pinger=setInterval(()=>this.ping(),1e3)}connect(){let e;try{e=new this.WS(this.o.url)}catch{this.dropped();return}this.ws=e,e.binaryType=`arraybuffer`,e.onopen=()=>{if(this.ws!==e)return;this.lastHeard=this.now();let t={name:this.o.name};this.o.invite&&(t.invite=this.o.invite),this.o.code&&(t.code=this.o.code),this.token&&(t.resume=this.token),e.send(JSON.stringify({hello:t}))},e.onmessage=t=>{this.ws===e&&(this.lastHeard=this.now(),typeof t.data==`string`?this.onText(t.data):t.data instanceof ArrayBuffer&&this.stage.kind===`joined`&&this.o.onFrame?.(t.data))},e.onclose=t=>{if(this.ws!==e)return;this.ws=null;let n=He(t);n===`mismatch`?(this.forgetToken(),this.finish({kind:`ended`,why:n})):n&&this.stage.kind!==`joined`&&this.stage.kind!==`reconnecting`?this.finish({kind:`ended`,why:n}):this.dropped()},e.onerror=()=>{}}onText(e){let t=qe(e);if(t)switch(t.kind){case`pong`:{let e=this.now()-t.t;e>=0&&e<6e4&&this.o.onRtt?.(e);return}case`asking`:this.stage.kind!==`reconnecting`&&this.setStage({kind:`asking`});return;case`waiting`:this.hostAway||(this.hostAway=!0,this.deadline=this.now()+$e),this.attempt=0,this.setStage(this.reconnectingStage());return;case`joined`:this.token=t.token,this.player=t.player,this.attempt=0,this.hostAway=!1;try{this.storage?.setItem(this.key,t.token)}catch{}{let e=t.track&&this.ws?.media||null;this.o.onCodec?.(t.hevc,e,!!e&&t.audio&&!!e.audio)}this.setStage({kind:`joined`,player:t.player,hevc:t.hevc}),this.sendPad(!0);return;case`refused`:this.forgetToken(),this.hostAway&&t.why!==`seat_taken`?this.finish({kind:`ended`,why:`host_stopped`}):this.finish({kind:`refused`,why:t.why});return;case`bye`:if(t.why===`host_stopped`&&this.token){this.hostWait();return}this.forgetToken(),this.finish({kind:`ended`,why:t.why});return;case`status`:this.stage.kind===`joined`&&t.status.player>0&&t.status.player!==this.stage.player&&(this.player=t.status.player,this.setStage({...this.stage,player:t.status.player})),this.o.onStatus?.(t.status);return;case`feedback`:t.rumble&&this.o.onRumble?.(t.rumble[0],t.rumble[1]),t.light&&this.o.onLight?.(t.light);return}}hostWait(){this.hostAway=!0,this.deadline=this.now()+$e,this.attempt=0;let e=this.ws;this.ws=null;try{e?.close()}catch{}this.scheduleRetry()}reconnectingStage(){return{kind:`reconnecting`,player:this.player,attempt:this.attempt,deadline:this.deadline,...this.hostAway?{hostStopped:!0}:{}}}giveUp(){this.forgetToken(),this.finish({kind:`ended`,why:this.hostAway?`host_stopped`:`gave_up`})}dropped(){if(this.stopped)return;let e=this.stage;e.kind===`joined`||e.kind===`reconnecting`&&this.token?(e.kind===`joined`&&(this.deadline=this.now()+Qe),this.scheduleRetry()):this.finish({kind:`ended`,why:`lost`})}scheduleRetry(){if(this.stopped)return;if(this.now()>=this.deadline){this.giveUp();return}let e=Ze(this.attempt);this.setStage(this.reconnectingStage()),this.attempt+=1,this.retry&&clearTimeout(this.retry),this.retry=setTimeout(()=>{this.retry=null,this.stopped||(this.now()>=this.deadline?this.giveUp():this.connect())},e)}forgetToken(){this.token=null;try{this.storage?.removeItem(this.key)}catch{}}ping(){if(this.hostAway&&!this.stopped&&this.now()>=this.deadline+5e3||!this.stopped&&this.stage.kind===`reconnecting`&&this.now()>=this.deadline+5e3){this.giveUp();return}let e=this.ws;if(e&&e.readyState===this.WS.OPEN){if(this.stage.kind===`joined`&&this.now()-this.lastHeard>3500){this.ws=null;try{e.close()}catch{}this.dropped()}else if(e.send(JSON.stringify({ping:this.now()})),this.stage.kind===`joined`&&this.o.readStats&&++this.pings%2==0){let t=this.o.readStats();t&&e.send(JSON.stringify({stats:t}))}}}setNeutral(e){this.neutral!==e&&(this.neutral=e,this.sendPad(!0))}sendPad(e){let t=this.ws;if(!t||t.readyState!==this.WS.OPEN||this.stage.kind!==`joined`)return;let n=this.neutral?{...Aa,touch:null,motion:null}:this.o.readPad(),r=this.now();!e&&Fo(n,this.last)&&r-this.lastSent<100||(this.last=n,this.lastSent=r,this.seq=this.seq+1>>>0,t.send(Xe(this.seq,n)))}clearTimers(){(this.o.cancelRaf??(e=>window.cancelAnimationFrame(e)))(this.raf),this.keepalive&&clearInterval(this.keepalive),this.pinger&&clearInterval(this.pinger),this.retry&&clearTimeout(this.retry),this.keepalive=this.pinger=this.retry=null}finish(e){this.stopped=!0,this.clearTimers();let t=this.ws;this.ws=null;try{t?.close()}catch{}this.setStage(e)}askKeyframe(){let e=this.ws;e&&e.readyState===this.WS.OPEN&&this.stage.kind===`joined`&&e.send(JSON.stringify({keyframe:!0}))}leave(){let e=this.ws;e&&e.readyState===this.WS.OPEN&&(this.stage.kind===`joined`&&(this.seq=this.seq+1>>>0,e.send(Xe(this.seq,Aa))),e.send(JSON.stringify({leave:1}))),this.forgetToken(),this.finish({kind:`ended`,why:`left`})}stop(){let e=this.ws;e&&e.readyState===this.WS.OPEN&&this.stage.kind===`joined`&&(this.seq=this.seq+1>>>0,e.send(Xe(this.seq,Aa))),this.stopped=!0,this.clearTimers(),this.ws=null;try{e?.close()}catch{}}},zo=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),B=s(((e,t)=>{t.exports=zo()}))(),Bo=`ps5upload.openIn`,Vo=`ps5upload.openIn.tab`;function Ho(){try{return sessionStorage.getItem(Vo)===`browser`}catch{return!1}}function V(){try{sessionStorage.setItem(Vo,`browser`)}catch{}}function H(e){return e===`browser`?`browser`:e===`app`?`opening`:`ask`}function Uo({appLink:e,children:t}){let n=Fe(),[r,i]=(0,E.useState)(()=>Ho()?`browser`:H(It(Bo))),[a,o]=(0,E.useState)(!1);if((0,E.useEffect)(()=>{r===`opening`&&It(`ps5upload.openIn`)===`app`&&(location.href=e)},[]),r===`browser`)return(0,B.jsx)(B.Fragment,{children:t});let s=()=>{a&&Ft(Bo,`app`),i(`opening`),location.href=e},c=()=>{r===`ask`&&a?Ft(Bo,`browser`):r===`opening`&&It(`ps5upload.openIn`)===`app`&&Lt(Bo),V(),i(`browser`)};return(0,B.jsx)(`div`,{className:`flex min-h-[100dvh] items-center justify-center bg-black px-6 text-white`,"data-testid":`open-in-gate`,children:(0,B.jsx)(`div`,{className:`w-full max-w-sm space-y-4 rounded-2xl border border-white/10 bg-neutral-900 p-6`,children:r===`ask`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`open_in_title`,void 0,`Open in the PS5Upload app?`)}),(0,B.jsx)(`p`,{className:`text-sm text-white/60`,children:n(`open_in_body`,void 0,`Have the PS5Upload app on this device? Open this there, or carry on in the browser.`)})]}),(0,B.jsx)(`button`,{type:`button`,onClick:s,className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black`,"data-testid":`open-in-app`,children:n(`open_in_app`,void 0,`Open in the app`)}),(0,B.jsx)(`button`,{type:`button`,onClick:c,className:`w-full rounded-full border border-white/20 py-2.5 text-sm font-semibold text-white hover:bg-white/10`,"data-testid":`open-in-browser`,children:n(`open_in_browser`,void 0,`Continue in browser`)}),(0,B.jsxs)(`label`,{className:`flex items-center justify-center gap-2 text-xs text-white/60`,children:[(0,B.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),"data-testid":`open-in-remember`}),n(`open_in_remember`,void 0,`Remember my choice on this device`)]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`space-y-1`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`open_in_opening`,void 0,`Opening the PS5Upload app…`)}),(0,B.jsx)(`p`,{className:`text-sm text-white/60`,children:n(`open_in_not_opened`,void 0,`Nothing happened? The app may not be on this device.`)})]}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>location.href=e,className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black`,"data-testid":`open-in-again`,children:n(`open_in_again`,void 0,`Try again`)}),(0,B.jsx)(`button`,{type:`button`,onClick:c,className:`w-full rounded-full border border-white/20 py-2.5 text-sm font-semibold text-white hover:bg-white/10`,"data-testid":`open-in-browser`,children:n(`open_in_browser`,void 0,`Continue in browser`)})]})})})}function Wo({id:e,className:t}){let n=Fe(),r=ao(e);if(r===`none`)return(0,B.jsx)(`span`,{className:t,"data-testid":`pad-8bitdo-hint`,"data-how":r,children:n(`pad_8bitdo_no_xinput`,void 0,`This 8BitDo has no X-input mode. If a button is wrong, check the controller.`)});let i=r===`switch`?n(`pad_8bitdo_how_switch`,void 0,`set the switch on the back to X, then press Start`):r===`startx`?n(`pad_8bitdo_how_startx`,void 0,`turn it off, then hold Start + X to turn it on`):r===`receiver`?n(`pad_8bitdo_how_receiver`,void 0,`use its 2.4G receiver or a USB cable`):n(`pad_8bitdo_how_manual`,void 0,`its manual says how`);return(0,B.jsx)(`span`,{className:t,"data-testid":`pad-8bitdo-hint`,"data-how":r,children:n(`pad_8bitdo_xinput`,{how:i},`For the best result, switch your 8BitDo to X-input mode: ${i}.`)})}var Go=new Set,Ko={held:new Set,touch:null,touchPad:Aa,mapping:!1,get paused(){return Go.size>0},motion:null},qo={s:.85,m:1,l:1.15},Jo=.25;function Yo(e){return typeof e!=`number`||!Number.isFinite(e)?1:Math.min(1,Math.max(Jo,e))}var Xo={overlay:{width:844,height:390},deck:{width:390,height:480}},Zo=.7,Qo=1.4;function $o(e,t,n,r){let i=qo[e]??1;if(!(t>0)||!(n>0))return i;let a=r?Xo.deck:Xo.overlay,o=Math.min(Qo,Math.max(Zo,Math.min(t/a.width,n/a.height)));return Math.round(o*i*1e3)/1e3}var es=34;function ts(e,t){return t>0&&8+Math.max(112*e,90)+156*e+124*e+Math.max(56*e,44)+es>t}function ns(e,t,n){let r=e/32767,i=t/32767,a=Math.hypot(r,i),o=a>1?1/a:1;return{dx:r*o*n,dy:i*o*n}}var rs=`calc(50% + (env(safe-area-inset-left) - env(safe-area-inset-right)) / 2)`,is=32767,as=12;function os({stream:e,layout:t=`overlay`,opacity:n=1,size:r=`m`,deckTop:i=`0px`,onMenu:a}){let o=Fe(),s=(0,E.useRef)(new Map),c=(0,E.useRef)({...Aa}),[l,u]=(0,E.useState)({...Aa}),[d,f]=(0,E.useState)({l:!1,r:!1,touchpad:!1}),p=(0,E.useRef)(null),[m,h]=(0,E.useState)({width:0,height:0});(0,E.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();h(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})};if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,E.useEffect)(()=>()=>{Ko.touchPad={...Aa}},[]);let g=()=>{let t={...Aa,touch:null},n={l:!1,r:!1,touchpad:!1};for(let e of s.current.values())e.kind===`stick`&&(n[e.which]=!0),e.kind===`touchpad`&&(n.touchpad=!0),e.kind===`button`&&(t.buttons|=e.bit),e.kind===`trigger`&&(t[e.which]=255),e.kind===`touchpad`&&e.pressed&&(t.buttons|=z.TOUCHPAD);t.lx=c.current.lx,t.ly=c.current.ly,t.rx=c.current.rx,t.ry=c.current.ry,t.touch=c.current.touch??null,Ko.touchPad=t,e?.sendPad(),u(t),f(e=>e.l===n.l&&e.r===n.r&&e.touchpad===n.touchpad?e:n)},_=(e,t,n)=>{let r=Math.max(-1,Math.min(1,(t-e.cx)/e.radius)),i=Math.max(-1,Math.min(1,(n-e.cy)/e.radius));c.current[e.which===`l`?`lx`:`rx`]=Math.round(r*is),c.current[e.which===`l`?`ly`:`ry`]=Math.round(i*is)},v=(e,t)=>{e.preventDefault(),e.stopPropagation();let n=e.currentTarget;try{n.setPointerCapture(e.pointerId)}catch{}let r=t(n);s.current.set(e.pointerId,r),r.kind===`stick`&&_(r,e.clientX,e.clientY),r.kind===`touchpad`&&(c.current.touch=ja((e.clientX-r.rect.left)/r.rect.width,(e.clientY-r.rect.top)/r.rect.height)),navigator.vibrate?.(8),g()},y=e=>{let t=s.current.get(e.pointerId);if(t){if(e.stopPropagation(),t.kind===`stick`)_(t,e.clientX,e.clientY);else if(t.kind===`touchpad`)c.current.touch=ja((e.clientX-t.rect.left)/t.rect.width,(e.clientY-t.rect.top)/t.rect.height),t.pressed&&Math.hypot(e.clientX-t.x0,e.clientY-t.y0)>as&&(t.pressed=!1);else return;g()}},b=e=>{let t=s.current.get(e.pointerId);t&&(e.stopPropagation(),s.current.delete(e.pointerId),t.kind===`stick`&&(c.current[t.which===`l`?`lx`:`rx`]=0,c.current[t.which===`l`?`ly`:`ry`]=0),t.kind===`touchpad`&&(c.current.touch=null),g())},x=e=>e.stopPropagation(),S={onPointerMove:y,onPointerUp:b,onPointerCancel:b,onClick:x,onDoubleClick:x},ee=e=>(l.buttons&e)!==0,C=e=>`border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.35)] transition-colors duration-75 ${e?`border-white bg-white/50`:`border-white/70 bg-white/10`}`,w=`text-white [text-shadow:0_1px_2px_rgba(0,0,0,0.6)]`,te={filter:`drop-shadow(0 0 1.5px rgba(0,0,0,0.5))`},T=e=>({stroke:e?`#fff`:`rgba(255,255,255,0.75)`,fill:e?`rgba(255,255,255,0.5)`:`rgba(255,255,255,0.1)`}),ne=`pointer-events-auto flex touch-none select-none items-center justify-center bg-transparent p-0`,re={minHeight:`calc(44px / var(--k))`,minWidth:`calc(44px / var(--k))`},ie=(e,t,n,r)=>(0,B.jsx)(`button`,{type:`button`,"aria-label":e,onPointerDown:e=>v(e,()=>({kind:`button`,bit:t})),...S,className:`${ne} ${n}`,style:re,children:r}),ae=(e,t,n,r)=>(0,B.jsx)(`span`,{className:`flex h-[32px] w-[76px] items-center justify-center text-[13px] font-semibold tracking-wide ${w} ${C(t)}`,style:{borderRadius:r?n===`l`?`16px 9px 9px 9px`:`9px 16px 9px 9px`:`9px`},children:e}),oe=(e,t,n,r)=>ie(e,t,`h-[44px] w-[84px]`,ae(e,ee(t),n,r)),se=(e,t,n)=>(0,B.jsx)(`button`,{type:`button`,"aria-label":e,onPointerDown:e=>v(e,()=>({kind:`trigger`,which:t})),...S,className:`${ne} h-[44px] w-[84px]`,style:re,children:ae(e,l[t]>0,n,!0)}),D=(e,t,n)=>ie(e,t,`h-[52px] w-[52px]`,(0,B.jsx)(`svg`,{viewBox:`0 0 52 52`,width:`52`,height:`52`,"aria-hidden":!0,style:te,children:(0,B.jsxs)(`g`,{transform:`rotate(${n} 26 26)`,strokeWidth:`1.5`,strokeLinejoin:`round`,...T(ee(t)),children:[(0,B.jsx)(`path`,{d:`M10 9 Q10 3 16 3 L36 3 Q42 3 42 9 L42 30 Q42 34.5 38.5 38 L29.5 47 Q26 50.5 22.5 47 L13.5 38 Q10 34.5 10 30 Z`}),(0,B.jsx)(`path`,{d:`M20.5 23 L26 17 L31.5 23`,fill:`none`,stroke:`#fff`,strokeLinecap:`round`,strokeWidth:`1.8`})]})})),O=(e,t,n)=>ie(e,t,`h-[52px] w-[52px]`,(0,B.jsxs)(`svg`,{viewBox:`0 0 52 52`,width:`52`,height:`52`,"aria-hidden":!0,style:te,children:[(0,B.jsx)(`circle`,{cx:`26`,cy:`26`,r:`22.5`,strokeWidth:`1.5`,...T(ee(t))}),(0,B.jsx)(`g`,{fill:`none`,stroke:`#fff`,strokeWidth:`1.8`,strokeLinejoin:`round`,strokeLinecap:`round`,children:n})]})),ce=(e,t)=>ie(e,t,`h-[44px] min-w-[64px] px-[4px]`,(0,B.jsx)(`span`,{className:`flex h-[24px] items-center rounded-full px-[10px] text-[10px] font-semibold uppercase tracking-wider ${w} ${C(ee(t))}`,children:e})),le=(e,t)=>ie(e,t,`h-[44px] w-[44px]`,(0,B.jsx)(`span`,{className:`flex h-[36px] w-[36px] items-center justify-center rounded-full text-[11px] font-bold ${w} ${C(ee(t))}`,children:e})),ue=e=>{let{dx:t,dy:n}=ns(e===`l`?l.lx:l.rx,e===`l`?l.ly:l.ry,34),r=d[e];return(0,B.jsx)(`div`,{"aria-label":e===`l`?o(`rp_touch_left_stick`,void 0,`Left stick`):o(`rp_touch_right_stick`,void 0,`Right stick`),onPointerDown:t=>v(t,t=>{let n=t.getBoundingClientRect();return{kind:`stick`,which:e,cx:n.left+n.width/2,cy:n.top+n.height/2,radius:n.width/2}}),...S,className:`pointer-events-auto relative h-[124px] w-[124px] touch-none rounded-full border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.3)] transition-colors duration-75 ${r?`border-white/80 bg-white/[0.12]`:`border-white/45 bg-white/[0.05]`}`,children:(0,B.jsx)(`div`,{className:`absolute left-1/2 top-1/2 h-[54px] w-[54px] rounded-full ${C(r)}`,style:{transform:`translate(calc(-50% + ${t}px), calc(-50% + ${n}px))`}})})},k=t===`deck`,de=$o(r,m.width,m.height,k),fe=e=>`${e}px * var(--k)`,pe=`max(12px, env(safe-area-inset-left))`,me=`max(12px, env(safe-area-inset-right))`,he=`max(12px, env(safe-area-inset-bottom))`,ge=k?`8px`:t===`overlay-bar`?`3.5rem`:`max(10px, env(safe-area-inset-top))`,_e=(e,t,n=0)=>t?n?`calc(${e} + max(${fe(t)}, ${n}px))`:`calc(${e} + ${fe(t)})`:e,ye=(e,t)=>({position:`absolute`,...t,transform:`scale(var(--k))`,transformOrigin:e}),be=k&&ts(de,m.height),A=k?void 0:`58%`,j=e=>k?{top:_e(ge,be?96:112,be?72:90),[e]:e===`left`?pe:me}:{top:A,translate:`0 -50%`,[e]:e===`left`?pe:me},xe=e=>({bottom:be?he:_e(he,k?56:0,44),[e]:be?`calc(${e===`left`?pe:me} + 8px + max(${fe(80)}, 44px))`:_e(e===`left`?pe:me,k?40:168)}),Se=!!a&&!k;return(0,B.jsxs)(`div`,{ref:p,className:`pointer-events-none absolute z-10 select-none [-webkit-touch-callout:none] ${k?`inset-x-0 bottom-0`:`inset-0`}`,style:{top:k?i:void 0,"--k":de},"data-testid":`rp-touch`,"data-layout":t,"data-scale":de,onContextMenu:e=>e.preventDefault(),children:[(0,B.jsxs)(`div`,{className:`absolute inset-0`,style:{opacity:Yo(n)},children:[(0,B.jsx)(`div`,{style:ye(`top left`,{top:ge,left:pe}),children:(0,B.jsxs)(`div`,{className:`ms-[8px] flex flex-col`,style:{rotate:k?void 0:`6deg`,transformOrigin:`top left`},children:[se(`L2`,`l2`,`l`),oe(`L1`,z.L1,`l`,!1)]})}),(0,B.jsx)(`div`,{style:ye(`top right`,{top:ge,right:me}),children:(0,B.jsxs)(`div`,{className:`me-[8px] flex flex-col items-end`,style:{rotate:k?void 0:`-6deg`,transformOrigin:`top right`},children:[se(`R2`,`r2`,`r`),oe(`R1`,z.R1,`r`,!1)]})}),(0,B.jsx)(`div`,{"aria-label":o(`rp_touch_touchpad`,void 0,`Touchpad`),onPointerDown:e=>v(e,t=>({kind:`touchpad`,rect:t.getBoundingClientRect(),x0:e.clientX,y0:e.clientY,pressed:!0})),...S,className:`pointer-events-auto absolute touch-none rounded-2xl border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.3)] transition-colors duration-75 ${d.touchpad?`border-white/80 bg-white/25`:`border-white/40 bg-white/[0.05]`}`,style:k?{top:_e(ge,6),left:_e(pe,104),right:_e(me,104),height:`max(44px, calc(${fe(64)}))`}:{top:ge,left:`50%`,translate:`-50% 0`,width:`min(calc(${fe(250)}), 34vw)`,height:`max(44px, calc(${fe(56)}))`}}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 grid-rows-3`,style:ye(k?`top left`:`left center`,j(`left`)),children:[(0,B.jsx)(`span`,{}),D(`↑`,z.UP,0),(0,B.jsx)(`span`,{}),D(`←`,z.LEFT,-90),(0,B.jsx)(`span`,{}),D(`→`,z.RIGHT,90),(0,B.jsx)(`span`,{}),D(`↓`,z.DOWN,180),(0,B.jsx)(`span`,{})]}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 grid-rows-3`,style:ye(k?`top right`:`right center`,j(`right`)),children:[(0,B.jsx)(`span`,{}),O(`△`,z.TRIANGLE,(0,B.jsx)(`path`,{d:`M26 16.5 L35 32 L17 32 Z`})),(0,B.jsx)(`span`,{}),O(`□`,z.SQUARE,(0,B.jsx)(`rect`,{x:`18`,y:`18`,width:`16`,height:`16`,rx:`1`})),(0,B.jsx)(`span`,{}),O(`○`,z.CIRCLE,(0,B.jsx)(`circle`,{cx:`26`,cy:`26`,r:`8.5`})),(0,B.jsx)(`span`,{}),O(`✕`,z.CROSS,(0,B.jsx)(`path`,{d:`M19 19 L33 33 M33 19 L19 33`})),(0,B.jsx)(`span`,{})]}),(0,B.jsx)(`div`,{style:ye(`bottom left`,xe(`left`)),children:ue(`l`)}),(0,B.jsx)(`div`,{style:ye(`bottom right`,xe(`right`)),children:ue(`r`)}),(0,B.jsx)(`div`,{style:ye(`bottom left`,{bottom:he,left:pe}),children:ce(`Create`,z.SHARE)}),(0,B.jsx)(`div`,{style:ye(`bottom right`,{bottom:he,right:me}),children:ce(`Options`,z.OPTIONS)}),(0,B.jsx)(`div`,{style:ye(`bottom center`,{bottom:be?_e(he,124,88):_e(he,Se?48:0,48),left:rs,translate:`-50% 0`}),children:le(`PS`,z.PS)})]}),Se&&(0,B.jsx)(`div`,{style:{...ye(`bottom center`,{bottom:he,left:`calc(50% + (env(safe-area-inset-left) - env(safe-area-inset-right)) / 2)`,translate:`-50% 0`}),opacity:Math.max(.7,Yo(n))},children:(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a?.()},onDoubleClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),"aria-label":o(`rp_menu`,void 0,`Menu`),"aria-haspopup":`dialog`,className:`${ne} h-[44px] w-[56px]`,style:re,"data-testid":`rp-menu-handle`,children:(0,B.jsx)(`span`,{className:`flex h-[26px] w-[44px] items-center justify-center rounded-full ${w} ${C(!1)}`,children:(0,B.jsx)(ve,{size:15,strokeWidth:2,"aria-hidden":!0})})})})]})}var ss=`data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAYZbW9vdgAAAGxtdmhkAAAAAAAAAAAAAAAAAAAfQAAAfQAAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAmt0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAABAAAAAAAAfQAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAABAAAAAQAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAH0AAAAAAAABAAAAAAHjbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAABAAAABAABVxAAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAABjm1pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAU5zdGJsAAAAunN0c2QAAAAAAAAAAQAAAKphdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAABAAEABIAAAASAAAAAAAAAABFExhdmM2My4xLjEwMiBsaWJ4MjY0AAAAAAAAAAAAAAAAGP//AAAAMGF2Y0MBQsAK/+EAF2dCwAqmEXsBEAAAAwAQAAADACDxImEYAQAGaMhCAZSyAAAAEHBhc3AAAAABAAAAAQAAABRidHJ0AAAAAAAABUAAAAAAAAAAGHN0dHMAAAAAAAAAAQAAAAQAAEAAAAAAFHN0c3MAAAAAAAAAAQAAAAEAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAJHN0c3oAAAAAAAAAAAAAAAQAAAKCAAAACgAAAAoAAAAKAAAAIHN0Y28AAAAAAAAABAAABlwAAAj+AAAJKAAACVIAAALZdHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAH0AAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAB9AAAABAAAAQAAAAACUW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAH0AAAIEAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAfxtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAcBzdGJsAAAAfnN0c2QAAAAAAAAAAQAAAG5tcDRhAAAAAAAAAAEAAAAAAAAAAAABABAAAAAAH0AAAAAAADZlc2RzAAAAAAOAgIAlAAIABICAgBdAFQAAAAAAH0AAAAEcBYCAgAUViFblAAaAgIABAgAAABRidHJ0AAAAAAAAH0AAAAEcAAAAIHN0dHMAAAAAAAAAAgAAACAAAAQAAAAAAQAAAQAAAAAoc3RzYwAAAAAAAAACAAAAAQAAAAEAAAABAAAAAgAAAAgAAAABAAAAmHN0c3oAAAAAAAAAAAAAACEAAAATAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAkc3RjbwAAAAAAAAAFAAAGSQAACN4AAAkIAAAJMgAACVwAAAAac2dwZAEAAAByb2xsAAAAAgAAAAH//wAAABxzYmdwAAAAAHJvbGwAAAABAAAAIQAAAAEAAABhdWR0YQAAAFltZXRhAAAAAAAAACFoZGxyAAAAAAAAAABtZGlyYXBwbAAAAAAAAAAAAAAAACxpbHN0AAAAJKl0b28AAAAcZGF0YQAAAAEAAAAATGF2ZjYzLjEuMTAyAAAACGZyZWUAAAM7bWRhdNwATGF2YzYzLjEuMTAyAAIwQA4AAAJvBgX//2vcRem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY1IHIzMjIyIGIzNTYwNWEgLSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDI1IC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9uczogY2FiYWM9MCByZWY9MTYgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDEzMSBtZT11bWggc3VibWU9MTAgcHN5PTEgcHN5X3JkPTEuMDA6MC4wMCBtaXhlZF9yZWY9MSBtZV9yYW5nZT0yNCBjaHJvbWFfbWU9MSB0cmVsbGlzPTIgOHg4ZGN0PTAgY3FtPTAgZGVhZHpvbmU9MjEsMTEgZmFzdF9wc2tpcD0xIGNocm9tYV9xcF9vZmZzZXQ9LTIgdGhyZWFkcz0xIGxvb2thaGVhZF90aHJlYWRzPTEgc2xpY2VkX3RocmVhZHM9MCBucj0wIGRlY2ltYXRlPTEgaW50ZXJsYWNlZD0wIGJsdXJheV9jb21wYXQ9MCBjb25zdHJhaW5lZF9pbnRyYT0wIGJmcmFtZXM9MCB3ZWlnaHRwPTAga2V5aW50PTQga2V5aW50X21pbj0xIHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NCByYz1jcmYgbWJ0cmVlPTEgY3JmPTUxLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAAALZYiCAv5MUAAQv8ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmhwF/UABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmioBb1ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmjsBX1ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBw==`,cs=null,ls=null;function us(e){e.play().catch(()=>{if(ls||cs!==e)return;let t=()=>{ds(),cs===e&&e.play().catch(()=>{})};window.addEventListener(`pointerdown`,t,{capture:!0}),ls=()=>window.removeEventListener(`pointerdown`,t,{capture:!0})})}function ds(){ls?.(),ls=null}function fs(){if(typeof document<`u`){if(!cs){let e=document.createElement(`video`);e.muted=!0,e.loop=!0,e.playsInline=!0,e.setAttribute(`playsinline`,``),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-testid`,`keep-screen-video`),e.style.cssText=`position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none`,e.src=ss,document.body.appendChild(e),cs=e}us(cs)}}function ps(){ds(),cs&&=(cs.pause(),cs.removeAttribute(`src`),cs.remove(),null)}function ms(){return typeof navigator>`u`?null:navigator.wakeLock??null}function hs(){return ut()||!Nn()}var gs=new Set,_s=null,vs=Promise.resolve(),ys=!1;async function bs(){if(gs.size===0||_s&&!_s.released)return;let e=ms();if(!e)ut()&&fs();else try{let t=await e.request(`screen`);t.addEventListener(`release`,()=>{_s===t&&(_s=null)}),_s=t}catch{}}async function xs(){ps();let e=_s;if(_s=null,e&&!e.released)try{await e.release()}catch{}}function Ss(){ys||typeof document>`u`||(ys=!0,document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&gs.size>0&&(vs=vs.then(bs))}))}function Cs(e,t){if(!hs())return;Ss();let n=gs.size>0;t?gs.add(e):gs.delete(e);let r=gs.size>0;n!==r&&(vs=vs.then(r?bs:xs))}var ws=new Set;function Ts(){if(typeof window<`u`)return window.PS5UploadPad}function Es(e,t){let n=ws.size>0;t?ws.add(e):ws.delete(e);let r=ws.size>0;if(n!==r)try{Ts()?.setActive(r)}catch{}}var Ds=class e{constructor(e){this.receiver=e,this.last=null,this.was={}}get frames(){return Number(this.last?.frames??0)}static report(e,t){let n=t=>e[t]??0,r=e=>n(e)-(t[e]??0),i=(e,t)=>r(t)>0?Math.round(r(e)/r(t)*1e4)/10:0;return{frames:n(`framesDecoded`),dropped:n(`framesDropped`),stalls:n(`freezeCount`),stall_ms:Math.round(n(`totalFreezesDuration`)*1e3),decode_ms:i(`totalDecodeTime`,`framesDecoded`),jitter_ms:i(`jitterBufferDelay`,`jitterBufferEmittedCount`),nacks:n(`nackCount`),plis:n(`pliCount`),decoder:`track`}}snapshot(){return this.receiver.getStats().then(t=>{t.forEach(t=>{t.type===`inbound-rtp`&&t.kind===`video`&&(this.last=e.report(t,this.was),this.was={...t})})}).catch(()=>{}),this.last}},Os=class{constructor(e){this.inner=e,this.video=document.createElement(`video`),this.wrap=document.createElement(`div`),this.media=null,this.trackStats=null,this.audio=!1,this.soundOn=!1,this.muted=!1;let t=this.video;t.muted=t.autoplay=t.playsInline=!0,t.className=`block h-full w-full object-contain`,t.dataset.testid=`track-video`,this.wrap.className=`h-full w-full`,this.wrap.append(t,e.element),this.setTrack(null)}get element(){return this.wrap}get stats(){return this.trackStats??this.inner.stats}setTrack(e,t=!1){this.media=e,this.audio=!!e&&t,this.applySound(),this.trackStats=e?new Ds(e.receiver):null,this.video.style.display=e?``:`none`,this.inner.element.style.display=e?`none`:``,this.video.srcObject!==(e?.stream??null)&&(this.video.srcObject=e?.stream??null),e&&this.play()}play(){try{this.video.play()?.catch?.(()=>{})}catch{}}onMessage(e){let t=new Uint8Array(e)[0];this.media&&t<=1||(!this.audio||t!==3&&t!==4)&&this.inner.onMessage(e)}applySound(){this.video.muted=!(this.audio&&this.soundOn&&!this.muted)}setHevc(e){this.inner.setHevc(e)}set onSoundFail(e){this.inner.onSoundFail=e}soundReport(){return this.inner.soundReport()}startSound(){this.inner.startSound(),this.soundOn=!0,this.applySound(),this.media&&this.play()}setMuted(e){this.inner.setMuted(e),this.muted=e,this.applySound()}resumeSound(){this.inner.resumeSound(),this.media&&this.video.paused&&this.play()}stop(){this.inner.stop(),this.video.srcObject=null}},ks=`ps5upload.join.muted`,As=5e3,js=Object.fromEntries(Object.entries(Ma).filter(([e])=>e!==`Escape`)),Ms=new Set;function Ns(e){if(!(e.code in js)||e.ctrlKey||e.metaKey||e.altKey)return!1;let t=e.target;if(e.code===`Tab`&&(e.shiftKey||Ps(t)))return!1;let n=t?.tagName;return!(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||Ps(t))}function Ps(e){let t=e?.tagName;if(t===`BUTTON`||t===`A`)return!0;let n=e?.getAttribute?.(`role`);return n===`button`||n===`link`||n===`menuitem`||n===`tab`||n===`switch`}var Fs=!1;function Is(e){Fs=e}function Ls(e,t,n=null){if(!e||e.frames===0&&!t)return null;let r=e.snapshot();return r&&{...r,...t?{problem:t}:{},...n??{}}}function Rs(){if(Fs)return{...Aa};let e=Wa(Ya(typeof navigator>`u`?void 0:navigator),xo),t=Ko.touchPad;return{...Ga(Ga(e,Pa(Ms,js)),t),touch:t.touch??null,motion:Ko.motion??null}}var zs=class{constructor(e){this.opts=e,this.player=null,this.listeners=new Set,this.cleanups=[],this.subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e)),this.snap={stage:{kind:`connecting`},status:null,rttMs:null,light:null,problem:null,sound:!1,noSound:!1,host:e.host,muted:Vs(),path:null},this.client=new Ro({url:e.url,invite:e.invite,code:e.code??null,name:e.name,WebSocketImpl:e.transport,readPad:Rs,onStage:e=>{this.set({stage:e}),e.kind===`joined`&&this.readPath(),(e.kind===`refused`||e.kind===`ended`)&&this.teardown()},onStatus:e=>this.set({status:e,host:e.host??this.snap.host}),onRtt:e=>this.set({rttMs:e}),onFrame:e=>this.picture().onMessage(e),readStats:()=>Ls(this.player?.stats??null,this.snap.problem,this.player?.soundReport()??null),onCodec:(e,t,n)=>{let r=this.picture();r.setHevc(e),r instanceof Os&&(r.setTrack(t,!!n),t&&this.snap.problem&&this.set({problem:null}))},onRumble:(e,t)=>{let n=Ya(typeof navigator>`u`?void 0:navigator);Ka(n,e,t),n.some(e=>e?.connected)||navigator.vibrate?.(e||t?200:0)},onLight:e=>this.set({light:e})})}picture(){if(!this.player){let e=aa(e=>this.set({problem:e}),`player`,()=>this.client.askKeyframe());this.player=this.opts.transport?new Os(e):e,this.player.onSoundFail=()=>this.set({noSound:!0}),this.player.setMuted(this.snap.muted)}return this.player}async readPath(){let e=this.client.socket,t=this.opts.path??null;if(e?.netPath)try{t=await e.netPath()??this.opts.path??null}catch{t=null}t!==this.snap.path&&this.set({path:t})}get element(){return this.picture().element}start(){let e=()=>{document.visibilityState===`hidden`?Ms.clear():this.player?.resumeSound(),this.client.setNeutral(document.visibilityState===`hidden`)},t=()=>{Ms.clear(),this.client.setNeutral(!0)},n=e=>{this.client.current.kind===`joined`&&Ns(e)&&(!this.opts.keysLive||this.opts.keysLive())&&(e.preventDefault(),Ms.add(e.code))},r=e=>{Ms.delete(e.code)&&Ns(e)&&e.preventDefault()};window.addEventListener(`keydown`,n),window.addEventListener(`keyup`,r);let i=()=>{this.client.setNeutral(document.visibilityState===`hidden`),document.visibilityState!==`hidden`&&this.player?.resumeSound()};document.addEventListener(`visibilitychange`,e),window.addEventListener(`blur`,t),window.addEventListener(`focus`,i);let a=setInterval(()=>{this.client.current.kind===`joined`&&this.readPath()},As);this.cleanups.push(()=>{clearInterval(a),document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`blur`,t),window.removeEventListener(`focus`,i),window.removeEventListener(`keydown`,n),window.removeEventListener(`keyup`,r),Ms.clear()}),this.client.start()}setMuted(e){this.player?.setMuted(e);try{localStorage.setItem(ks,e?`1`:`0`)}catch{}this.set({muted:e})}startSound(){this.snap.sound||(this.picture().startSound(),this.set({sound:!0}))}leave(){this.client.leave(),this.teardown()}stop(){this.client.stop(),this.teardown()}teardown(){for(let e of this.cleanups.splice(0))e();Ko.touchPad={buttons:0,l2:0,r2:0,lx:0,ly:0,rx:0,ry:0};let e=this.player;this.player=null,e&&(e.stop(),e.element.remove())}sendPad(){this.client.sendPad(!1)}get snapshot(){return this.snap}set(e){this.snap={...this.snap,...e};for(let e of this.listeners)e()}};function Bs(e){return(0,E.useSyncExternalStore)(e.subscribe,()=>e.snapshot)}function Vs(){try{return typeof localStorage<`u`&&localStorage.getItem(ks)===`1`}catch{return!1}}function Hs(e){let t=()=>{let t=e.snapshot.stage.kind,n=t!==`refused`&&t!==`ended`;Cs(`play-together`,n),Es(`play-together`,n)};t();let n=e.subscribe(t);return()=>{n(),Cs(`play-together`,!1),Es(`play-together`,!1)}}var Us=3e3,Ws=class{constructor(e,t=Us){this.onChange=e,this.delay=t,this.enabled=!1,this.pinned=!1,this.sticky=!1,this.shown=!0,this.timer=null}get visible(){return!this.enabled||this.pinned||this.shown}set(e,t,n=!1){let r=this.enabled&&!this.pinned,i=this.enabled,a=this.sticky;this.enabled=e,this.pinned=t,this.sticky=n,!e||t?(this.stop(),this.show(!0)):n?(this.stop(),!i||!a?this.show(!1):r||this.show(!0)):(!r||a)&&(this.show(!0),this.arm())}poke(){this.show(!0),this.enabled&&!this.pinned&&!this.sticky&&this.arm()}toggle(){this.visible?this.hide():this.poke()}hide(){this.enabled&&!this.pinned&&(this.stop(),this.show(!1))}dispose(){this.stop()}arm(){this.stop(),this.timer=setTimeout(()=>{this.timer=null,this.show(!1)},this.delay)}stop(){this.timer!==null&&clearTimeout(this.timer),this.timer=null}show(e){this.shown!==e&&(this.shown=e,this.onChange(e))}};function Gs(e,t,n=!1){let[r,i]=(0,E.useState)(!0),a=(0,E.useRef)(null);(0,E.useEffect)(()=>{let e=new Ws(i);return a.current=e,()=>{e.dispose(),a.current=null}},[]),(0,E.useEffect)(()=>{a.current?.set(e,t,n)},[e,t,n]);let o=(0,E.useCallback)(()=>a.current?.poke(),[]),s=(0,E.useCallback)(()=>a.current?.hide(),[]),c=(0,E.useCallback)(()=>a.current?.toggle(),[]);return{shown:!e||t||r,poke:o,hide:s,toggle:c}}var Ks=3e4,qs=class{constructor(e,t=Ks){this.onChange=e,this.ms=t,this.picking=!1,this.over=!1,this.timer=null}get shown(){return this.picking&&!this.over}set(e){e!==this.picking&&(this.picking=e,this.over=!1,this.stop(),e&&(this.timer=setTimeout(()=>{this.timer=null,this.over=!0,this.onChange()},this.ms)))}stop(){this.timer&&clearTimeout(this.timer),this.timer=null}reset(){this.stop(),this.picking=!1,this.over=!1}};function Js(e){let[,t]=(0,E.useState)(0),[n]=(0,E.useState)(()=>new qs(()=>t(e=>e+1)));return(0,E.useEffect)(()=>{n.set(e),t(e=>e+1)},[n,e]),(0,E.useEffect)(()=>()=>n.reset(),[n]),n.shown}var Ys=()=>Ya(typeof navigator>`u`?void 0:navigator).filter(e=>!!e?.connected);function Xs(e,t){if(t.kind===`axis`)return t.which===`lx`?e(`rp_pad_step_lx`,void 0,`Push the left stick right`):t.which===`ly`?e(`rp_pad_step_ly`,void 0,`Push the left stick down`):t.which===`rx`?e(`rp_pad_step_rx`,void 0,`Push the right stick right`):e(`rp_pad_step_ry`,void 0,`Push the right stick down`);if(t.kind===`button`){if(t.bit===z.CROSS)return e(`join_check_bottom`,void 0,`Press the bottom face button (✕)`);if(t.bit===z.CIRCLE)return e(`join_check_right`,void 0,`Press the right face button (○)`);if(t.bit===z.SQUARE)return e(`join_check_left`,void 0,`Press the left face button (□)`);if(t.bit===z.TRIANGLE)return e(`join_check_top`,void 0,`Press the top face button (△)`)}return e(`rp_pad_press`,{name:t.name},`Press ${t.name}`)}function Zs(e,t){let n=(0,E.useRef)(t);(0,E.useEffect)(()=>{n.current=t}),(0,E.useEffect)(()=>{if(e===null)return;let t=0,r=()=>{n.current(Ys().find(t=>t.index===e)??null),t=window.requestAnimationFrame(r)};return t=window.requestAnimationFrame(r),()=>window.cancelAnimationFrame(t)},[e])}var Qs=[[z.CROSS,`✕`],[z.CIRCLE,`○`],[z.SQUARE,`□`],[z.TRIANGLE,`△`],[z.UP,`↑`],[z.DOWN,`↓`],[z.LEFT,`←`],[z.RIGHT,`→`],[z.L1,`L1`],[z.R1,`R1`],[z.L3,`L3`],[z.R3,`R3`],[z.SHARE,`Create`],[z.OPTIONS,`Options`],[z.PS,`PS`],[z.TOUCHPAD,`Touchpad`]];function $s({pad:e}){let t=e=>`flex h-8 min-w-8 items-center justify-center rounded-md px-1.5 text-xs font-medium ${e?`bg-white text-black`:`bg-white/10 text-white/70`}`,n=(e,t,n)=>(0,B.jsxs)(`span`,{className:`relative flex h-12 w-12 items-center justify-center rounded-full bg-white/10 text-[10px] text-white/50`,children:[n,(0,B.jsx)(`span`,{className:`absolute h-3 w-3 rounded-full bg-white`,style:{left:`calc(50% + ${e/32767*18}px - 6px)`,top:`calc(50% + ${t/32767*18}px - 6px)`}})]});return(0,B.jsxs)(`div`,{className:`space-y-2`,"data-testid":`join-pad-test`,"data-buttons":e.buttons,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[Qs.map(([n,r])=>(0,B.jsx)(`span`,{className:t((e.buttons&n)!==0),"data-on":(e.buttons&n)===0?`0`:`1`,children:r},n)),(0,B.jsx)(`span`,{className:t(e.l2>30),children:`L2`}),(0,B.jsx)(`span`,{className:t(e.r2>30),children:`R2`})]}),(0,B.jsxs)(`div`,{className:`flex gap-3`,children:[n(e.lx,e.ly,`L`),n(e.rx,e.ry,`R`)]})]})}function ec({onClose:e}){let t=Fe(),[n,r]=(0,E.useState)(()=>Ys().map(e=>({index:e.index,id:e.id}))),[i,a]=(0,E.useState)(()=>Ys()[0]?.index??null),[o,s]=(0,E.useState)(Aa),[c,l]=(0,E.useState)(null),[u,d]=(0,E.useState)(0),[f,p]=(0,E.useState)(vo),[m,h]=(0,E.useState)(null),[g,_]=(0,E.useState)(null);(0,E.useEffect)(()=>(Is(!0),()=>Is(!1)),[]),(0,E.useEffect)(()=>{let e=()=>{let e=Ys();r(t=>t.length===e.length&&t.every((t,n)=>t.id===e[n].id&&t.index===e[n].index)?t:e.map(e=>({index:e.index,id:e.id}))),a(t=>t!==null&&e.some(e=>e.index===t)?t:e[0]?.index??null)},t=window.setInterval(e,500);return window.addEventListener(`gamepadconnected`,e),window.addEventListener(`gamepaddisconnected`,e),()=>{window.clearInterval(t),window.removeEventListener(`gamepadconnected`,e),window.removeEventListener(`gamepaddisconnected`,e)}},[]),Zs(i,e=>{if(_(t=>t?.id===e?.id?t:e),!e)return;if(c){c.feed(To(e))&&v(c,e);return}let t=Wa([e],xo);s(e=>e.buttons===t.buttons&&e.l2===t.l2&&e.r2===t.r2&&e.lx===t.lx&&e.ly===t.ly&&e.rx===t.rx&&e.ry===t.ry?e:t)});let v=(e,n)=>{if(!e.done)return d(e.step);let r=n?.id??g?.id;l(null),r&&(p(yo(r,e.profile(n?Co(n):void 0))),h(t(`join_check_saved`,void 0,`Saved for this controller on this device. Try it below.`)))},y=()=>{h(null),d(0),l(new Po(Mo))},b=g,x=b?So(b):null,S=!!(b&&f[b.id]);return(0,B.jsx)(`div`,{className:`absolute inset-0 z-40 flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm`,"data-testid":`join-pad-check`,onPointerDown:e=>e.stopPropagation(),children:(0,B.jsxs)(`div`,{className:`w-[min(26rem,100%)] space-y-3 rounded-2xl border border-white/10 bg-neutral-900/95 p-4 text-sm text-white shadow-2xl`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(me,{size:16,className:`text-white/70`}),(0,B.jsx)(`p`,{className:`flex-1 font-semibold`,children:t(`join_check_title`,void 0,`Check your controller`)}),(0,B.jsx)(`button`,{type:`button`,onClick:e,"aria-label":t(`join_done`,void 0,`Done`),className:`flex h-8 w-8 items-center justify-center rounded-full bg-white/10 hover:bg-white/20`,"data-testid":`join-pad-check-close`,children:(0,B.jsx)(Ee,{size:15})})]}),b?(0,B.jsxs)(B.Fragment,{children:[n.length>1&&(0,B.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.map(e=>(0,B.jsx)(`button`,{type:`button`,disabled:!!c,onClick:()=>a(e.index),className:`rounded-full px-2.5 py-1 text-xs ${e.index===i?`bg-white text-black`:`bg-white/10`}`,children:eo(e.id)},`${e.index}-${e.id}`))}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`truncate font-medium`,"data-testid":`join-pad-check-name`,children:eo(b.id)}),(0,B.jsx)(`p`,{className:`text-xs text-white/60`,"data-testid":`join-pad-check-kind`,"data-kind":x??``,children:x===`saved`?t(`rp_pad_mapped`,void 0,`Plays with your mapping`):x===`guess`?t(`join_check_unknown`,void 0,`This controller isn't on our list, so its buttons may be mixed up. Setting it up takes a few seconds.`):t(`rp_pad_standard`,void 0,`Recognized`)}),ro(b)&&(0,B.jsx)(Wo,{id:b.id,className:`mt-1 block text-xs text-amber-200/90`})]}),c?(0,B.jsxs)(`div`,{className:`space-y-3`,"data-testid":`join-pad-learn`,children:[(0,B.jsx)(`p`,{className:`text-xs text-white/60`,children:t(`rp_pad_progress`,{n:u+1,total:c.steps.length},`${u+1} of ${c.steps.length}`)}),(0,B.jsx)(`p`,{className:`text-lg font-semibold`,"data-testid":`join-pad-learn-step`,children:c.current?Xs(t,c.current):``}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>{c.skip(),v(c,b)},className:`rounded-full bg-white/15 px-3 py-1.5 text-xs hover:bg-white/25`,"data-testid":`join-pad-learn-skip`,children:t(`rp_pad_skip`,void 0,`Skip`)}),u>0&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{c.back(),d(c.step)},className:`rounded-full bg-white/15 px-3 py-1.5 text-xs hover:bg-white/25`,children:t(`rp_pad_back`,void 0,`Back`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>l(null),className:`rounded-full px-3 py-1.5 text-xs text-white/70 hover:bg-white/10`,children:t(`rp_pad_cancel`,void 0,`Cancel`)})]})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-xs text-white/60`,children:t(`join_check_try`,void 0,`Press buttons and move the sticks: what you press lights up.`)}),(0,B.jsx)($s,{pad:o}),m&&(0,B.jsx)(`p`,{className:`text-xs text-emerald-300`,role:`status`,children:m}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:y,className:`rounded-full bg-white px-3 py-1.5 text-xs font-medium text-black`,"data-testid":`join-pad-learn-start`,children:S?t(`join_check_redo`,void 0,`Redo`):t(`join_check_map`,void 0,`Set up the buttons`)}),S&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{p(yo(b.id,null)),h(null)},className:`rounded-full bg-white/15 px-3 py-1.5 text-xs hover:bg-white/25`,"data-testid":`join-pad-reset`,children:t(`rp_pad_reset`,void 0,`Reset`)}),(0,B.jsx)(`button`,{type:`button`,onClick:e,className:`rounded-full bg-white/15 px-3 py-1.5 text-xs hover:bg-white/25`,"data-testid":`join-pad-check-done`,children:t(`join_done`,void 0,`Done`)})]})]})]}):(0,B.jsx)(`p`,{className:`text-white/70`,children:t(`rp_pads_none`,void 0,`No controller seen yet. Connect one and press any button on it.`)})]})})}function tc(e,t){let[n,r]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{if(!e||!t)return;let n=!0;return ze(e,Ie).then(e=>{n&&!e&&r(!0)}),()=>{n=!1}},[e,t]),n}function nc({href:e}){let t=Fe();return(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,"data-testid":`open-on-wifi`,children:[(0,B.jsx)(`p`,{className:`max-w-sm text-sm text-white/60`,children:t(`join_open_lan_body`,void 0,`Can't reach the internet? If you're on the same Wi-Fi as your friend, open the game there.`)}),(0,B.jsx)(`a`,{href:e,rel:`noreferrer`,className:`rounded-full bg-white px-4 py-2 text-sm font-medium text-black`,"data-testid":`open-on-wifi-link`,children:t(`join_open_lan`,void 0,`Open on this Wi-Fi`)})]})}function rc(e){let t=Math.max(0,Math.ceil(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var ic=`ps5upload.join.guided`,ac=1;function oc(e){return e.player!==ac&&(!e.guided||e.movedOff)&&!e.reconnecting}function sc(e,t){switch(t){case`lan`:return e(`join_path_lan`,void 0,`Home network`);case`tailscale`:return e(`join_path_tailscale`,void 0,`Tailscale`);default:return e(`join_path_internet`,void 0,`Internet`)}}function cc(e,t){return e(`join_seat_taken`,{host:t},`${t} needed their controller back and no other controller was free on the PS5, so you're out of the game. Ask ${t} to let you in again.`)}function lc(e,t,n,r=!1){if(t.kind===`refused`)switch(t.why){case`key`:return e(`join_refused_key`,{host:n},`This invite has expired. Ask ${n} for a new link.`);case`expired`:return e(`join_refused_expired`,{host:n},`Your place in the game was lost. Ask ${n} to let you in again.`);case`full`:return e(`join_refused_full`,void 0,`The game is full: four players already.`);case`denied`:return e(`join_refused_denied`,{host:n},`${n} didn't let you in this time.`);case`no_answer`:return e(`join_refused_no_answer`,{host:n},`${n} didn't answer in time. Tell ${n}, then try again.`);case`closed`:return e(`join_refused_closed`,{host:n},`${n} isn't hosting Play Together right now.`);case`old_helper`:return e(`join_refused_old_helper`,{host:n},`${n}'s PS5 needs an updated helper for Play Together.`);case`not_playing`:return e(`join_refused_not_playing`,{host:n},`${n} isn't playing right now. Ask ${n} to start Play first.`);case`unreachable`:return e(`join_refused_unreachable`,{host:n},`${n}'s computer couldn't reach their PS5. Try again in a moment.`);case`slow_down`:return e(`join_refused_slow_down`,void 0,`Too many wrong codes. Wait a minute, then try again.`);case`address`:return e(`join_refused_address`,{host:n},`This link's address is outside your home network, so the app will not use it. Ask ${n} for a link with their computer's IP address.`);case`seat_taken`:return cc(e,n);default:return e(`join_refused_other`,{host:n},`${n} didn't let you in.`)}if(t.kind===`ended`)switch(t.why){case`kicked`:return e(`join_ended_kicked`,{host:n},`${n} took you out of the game.`);case`closed`:return e(`join_ended_closed`,{host:n},`${n} closed Play Together.`);case`host_stopped`:return e(`join_ended_host_stopped`,void 0,`The host stopped playing.`);case`replaced`:return e(`join_ended_replaced`,void 0,`This game was opened in another tab or on another device, so it stopped here.`);case`pad_lost`:return e(`join_ended_pad_lost`,{host:n},`The PS5 lost your controller, so you're out of the game. Ask ${n} to let you in again.`);case`gave_up`:return e(`join_ended_gave_up`,{host:n},`The connection to ${n} didn't come back in time.`);case`lost`:return r?e(`join_net_lost`,{host:n},`The connection to ${n} dropped. Check your internet connection, then ask again.`):e(`join_ended_lost`,{host:n},`Couldn't reach ${n}. Check that you're on the same network.`);case`left`:return e(`join_ended_left`,void 0,`You left the game.`);case`seat_taken`:return cc(e,n);case`mismatch`:return e(`join_net_mismatch`,void 0,`This link doesn't match the host; ask them for a new one.`);case`no_direct`:return e(`join_net_no_direct`,void 0,`A direct connection isn't possible from this network (both sides' routers are strict). Try Wi-Fi instead of mobile data, or ask the host to turn on UPnP.`);case`no_room`:return e(`join_net_no_room`,{host:n},`This invite isn't open any more. Ask ${n} for a new link.`);case`net_full`:return e(`join_net_full`,{host:n},`${n}'s game has no room for another friend right now. Try again in a moment.`);case`no_hub`:return e(`join_net_no_hub`,void 0,`Couldn't reach the PS5Upload invite service. Check your internet connection, then try again.`);case`offer`:return e(`join_net_offer`,{host:n},`${n}'s computer couldn't connect to this browser. Try another browser.`);case`no_webrtc`:return e(`join_net_no_webrtc`,void 0,`This browser can't make direct connections. Try a recent Chrome, Safari or Firefox.`)}return``}function uc(e){let[t,n]=(0,E.useState)(()=>Date.now());return(0,E.useEffect)(()=>{if(!e)return;n(Date.now());let t=window.setInterval(()=>n(Date.now()),500);return()=>window.clearInterval(t)},[e]),t}function dc(){let[e,t]=(0,E.useState)({ready:!1,pressed:!1,id:null,kind:null,weak8BitDo:!1});return(0,E.useEffect)(()=>{let e=()=>{let e=Ya(typeof navigator>`u`?void 0:navigator).find(e=>!!e?.connected),n=!!e,r=n?Rs():null,i=!!r&&(r.buttons!==0||r.l2>30||r.r2>30),a=e?.id??null,o=e?So(e):null,s=!!e&&ro(e);t(e=>e.ready===n&&e.pressed===i&&e.id===a&&e.kind===o&&e.weak8BitDo===s?e:{ready:n,pressed:i,id:a,kind:o,weak8BitDo:s})};e();let n=window.setInterval(e,120);return window.addEventListener(`gamepadconnected`,e),window.addEventListener(`gamepaddisconnected`,e),()=>{window.clearInterval(n),window.removeEventListener(`gamepadconnected`,e),window.removeEventListener(`gamepaddisconnected`,e)}},[]),e}function fc(e){return!!e?.closest?.(`[data-testid="rp-touch"]`)}var pc=14,mc=()=>typeof window<`u`&&!!window.matchMedia?.(`(pointer: coarse)`).matches,hc={good:`var(--color-good,#32d074)`,fair:`var(--color-warn,#ffb340)`,slow:`var(--color-bad,#ff6961)`,none:`rgba(255,255,255,.5)`};function gc({text:e,body:t,onCancel:n}){let r=Fe();return(0,B.jsxs)(`div`,{className:`flex flex-col items-center gap-5 px-6 py-10 text-center`,"data-testid":`join-waiting`,children:[(0,B.jsxs)(`div`,{className:`relative flex h-24 w-24 items-center justify-center`,"aria-hidden":!0,children:[(0,B.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-white/10 [animation-duration:2.4s]`}),(0,B.jsx)(`span`,{className:`absolute inset-3 animate-pulse rounded-full bg-white/10 [animation-duration:2.4s]`}),(0,B.jsx)(`span`,{className:`relative flex h-14 w-14 items-center justify-center rounded-full bg-white/15`,children:(0,B.jsx)(Se,{size:26})})]}),(0,B.jsx)(`p`,{className:`max-w-sm text-base font-medium`,"data-testid":`join-stage`,children:e}),t&&(0,B.jsx)(`p`,{className:`max-w-sm text-sm text-white/60`,children:t}),(0,B.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full bg-white/15 px-4 py-2 text-sm hover:bg-white/25`,"data-testid":`join-cancel`,children:r(`join_cancel`,void 0,`Cancel`)})]})}function _c({session:e,inApp:t=!1,onLeave:n,onAgain:r,onFullscreen:i,lanUrl:a=null,hubDown:o=!1}){let s=Fe(),c=Bs(e),{stage:l,status:u}=c,d=c.host??s(`join_host_fallback`,void 0,`your friend`),f=(0,E.useRef)(null),[p,m]=(0,E.useState)(!1),[h,g]=(0,E.useState)(()=>It(ic)===`1`),[_,v]=(0,E.useState)(()=>typeof window<`u`&&window.innerHeight>window.innerWidth),y=dc(),[b,x]=(0,E.useState)(!1),S=l.kind===`reconnecting`,ee=uc(S),C=l.kind===`joined`||S,w=u?.state===`picking_user`,te=l.kind===`joined`||l.kind===`reconnecting`?l.player:0,[T,ne]=(0,E.useState)(!1),re=(0,E.useRef)(te);(0,E.useEffect)(()=>{re.current===ac&&te>ac&&ne(!0),te&&(re.current=te)},[te]);let[ie,ae]=(0,E.useState)(!1),[oe,se]=(0,E.useState)(!1),D=C&&(p||!t),O=mc(),ce=Js(w),ue=Gs(D,S||ce&&!O||ie||oe,O),{poke:de}=ue,pe=(0,E.useRef)(null),he=()=>{pe.current&&clearTimeout(pe.current.timer),pe.current=null};(0,E.useEffect)(()=>he,[]);let[_e,ve]=(0,E.useState)(!1),ye=(0,E.useRef)(!1);(0,E.useEffect)(()=>{if(!D||!O||ue.shown||!h||ye.current)return;ye.current=!0,ve(!0);let e=setTimeout(()=>ve(!1),6e3);return()=>clearTimeout(e)},[D,O,ue.shown,h]),(0,E.useEffect)(()=>{if(!C)return;let t=e.element;return f.current?.appendChild(t),()=>t.remove()},[C,e]),(0,E.useEffect)(()=>{if(!C||c.sound)return;let t=()=>e.startSound(),n=[`pointerup`,`touchend`,`click`,`keydown`];for(let e of n)window.addEventListener(e,t,!0);return()=>{for(let e of n)window.removeEventListener(e,t,!0)}},[C,c.sound,e]),(0,E.useEffect)(()=>{let e=()=>v(window.innerHeight>window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,E.useEffect)(()=>{if(p)return()=>void i?.(!1)},[p,i]);let A=(0,E.useRef)(p);(0,E.useEffect)(()=>{A.current=p},[p]),(0,E.useEffect)(()=>{if(!t||!C||!mc()||typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(orientation: landscape)`),n=()=>{e.matches&&!A.current&&(m(!0),i?.(!0))};return n(),e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[t,C,i]),(0,E.useEffect)(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&(de(),p&&m(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,p,de]),(0,E.useEffect)(()=>{if(!p||!mc())return;window.history.pushState(window.history.state,``);let e=window.location.href,t=!1,n=()=>{t=!0,m(!1)};return window.addEventListener(`popstate`,n),()=>{window.removeEventListener(`popstate`,n),!t&&window.location.href===e&&window.history.back()}},[p]),(0,E.useEffect)(()=>{if(!p||typeof document>`u`)return;let e=()=>{document.fullscreenElement||mc()||m(!1)};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[p]);let xe=()=>{e.leave(),n()};if(l.kind===`connecting`||l.kind===`asking`)return(0,B.jsxs)(`div`,{className:t?`rounded-[var(--radius-card)] bg-neutral-900 text-white`:`flex min-h-[100dvh] flex-col items-center justify-center gap-4 bg-black text-white`,children:[l.kind===`connecting`&&o&&a&&(0,B.jsx)(nc,{href:a}),(0,B.jsx)(gc,{text:l.kind===`connecting`?s(`join_connecting`,{host:d},`Connecting to ${d}…`):s(`join_waiting`,{host:d},`Waiting for ${d} to let you in`),body:l.kind===`asking`?s(`join_waiting_body`,{host:d},`${d} sees your name on their screen and taps Allow.`):void 0,onCancel:xe})]});if(l.kind===`refused`||l.kind===`ended`){let i=l.kind===`refused`||l.why!==`left`&&l.why!==`mismatch`;return(0,B.jsxs)(`div`,{className:t?`flex flex-col items-center gap-4 rounded-[var(--radius-card)] bg-neutral-900 px-6 py-10 text-center text-white`:`flex min-h-[100dvh] flex-col items-center justify-center gap-4 bg-black px-6 text-center text-white`,"data-testid":`join-ended`,"data-why":l.why,children:[(0,B.jsx)(Se,{size:28,className:`text-white/60`}),(0,B.jsx)(`p`,{className:`max-w-sm text-base`,"data-testid":`join-ended-text`,children:lc(s,l,d,e.opts.internet??!!e.opts.transport)}),a&&l.why===`no_hub`&&(0,B.jsx)(nc,{href:a}),(0,B.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[i&&(0,B.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-full bg-white px-4 py-2 text-sm font-medium text-black`,"data-testid":`join-again`,children:l.kind===`refused`&&l.why===`not_playing`?s(`join_retry`,void 0,`Try again`):s(`join_again`,void 0,`Ask to join again`)}),(0,B.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full bg-white/15 px-4 py-2 text-sm`,"data-testid":`join-done`,children:s(`join_done`,void 0,`Done`)})]})]})}let Ce=l.player,M=c.light??it(Ce),Te=c.rttMs??u?.rttMs??null,Ee=rt(Te),De=mc(),Oe=C&&!S&&!y.ready&&De&&(!t||p),ke=oc({player:Ce,guided:h,movedOff:T,reconnecting:S}),Ae=Ce===ac,je=u?.playsAs??null,Me=S?(l.deadline-ee)/1e3:0,Ne=async()=>{let e=!p;m(e),await i?.(e)},Pe=t&&!p&&De&&C,Ie=(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 font-medium`,"data-testid":`join-player`,children:[(0,B.jsx)(`span`,{className:`inline-block h-2.5 w-2.5 rounded-full`,style:{background:`rgb(${M[0]},${M[1]},${M[2]})`}}),t&&(0,B.jsxs)(`span`,{className:`text-white/80`,children:[s(`join_playing_at`,{host:d},`Playing at ${d}'s`),` · `]}),s(`join_you_are`,{n:Ce},`You are Player ${Ce}`)]}),Te!=null&&(0,B.jsxs)(`span`,{className:`rounded-full bg-black/60 px-2 py-1 tabular-nums`,style:{color:hc[Ee]},"data-testid":`join-delay`,"data-tone":Ee,"data-path":c.path??void 0,children:[c.path&&(0,B.jsxs)(`span`,{className:`text-white/80`,children:[sc(s,c.path),` · `]}),Math.round(Te),` ms`]}),Ae&&(0,B.jsx)(`span`,{className:`rounded-full bg-black/60 px-2.5 py-1 text-white/85`,"data-testid":`join-seat-stream`,children:s(`join_seat_stream`,{host:d},`You're playing as ${d}'s PS5 user. No need to pick one.`)}),je&&!Ae&&(0,B.jsx)(`span`,{className:`rounded-full bg-black/60 px-2.5 py-1 text-white/85`,"data-testid":`join-plays-as`,children:s(`join_plays_as`,{profile:je},`You're playing as ${je}. No need to pick one.`)}),w&&!Ae&&u?.seatNote&&(0,B.jsx)(`span`,{className:`rounded-full bg-black/60 px-2.5 py-1 text-white/85`,"data-testid":`join-seat-note`,children:s(`join_seat_tv_asks`,{host:d},`${d} chose a profile for you, but it couldn't be used. The TV will ask who you are.`)}),w&&!Ae&&(0,B.jsx)(`span`,{className:`rounded-full bg-white/90 px-2.5 py-1 font-medium text-black`,"data-testid":`join-picking`,children:s(`join_picking`,void 0,`Press PS, then pick Quick Play on the TV`)})]}),Le=(0,B.jsxs)(B.Fragment,{children:[D&&O&&ue.shown&&!S&&(0,B.jsxs)(`button`,{type:`button`,onClick:ue.hide,className:`flex items-center gap-1 rounded-full bg-white/15 px-2.5 py-1 font-medium`,"data-testid":`join-hide-controls`,children:[(0,B.jsx)(fe,{size:13}),s(`join_hide_controls`,void 0,`Hide`)]}),!c.sound&&(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.startSound(),className:`flex items-center gap-1 rounded-full bg-white/90 px-2.5 py-1 font-medium text-black`,"data-testid":`join-sound`,children:[(0,B.jsx)(we,{size:13}),s(`join_sound`,void 0,`Tap for sound`)]}),c.sound&&!c.noSound&&(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.setMuted(!c.muted),"aria-pressed":c.muted,className:`flex items-center gap-1 rounded-full bg-white/15 px-2.5 py-1 hover:bg-white/25`,"data-testid":`join-mute`,children:[c.muted?(0,B.jsx)(N,{size:13}):(0,B.jsx)(we,{size:13}),c.muted?s(`rp_unmute`,void 0,`Sound on`):s(`rp_mute`,void 0,`Mute`)]}),c.noSound&&(0,B.jsxs)(`span`,{className:`flex items-center gap-1 rounded-full bg-black/60 px-2.5 py-1 text-white/80`,"data-testid":`join-no-sound`,children:[(0,B.jsx)(N,{size:13}),s(`join_no_sound`,void 0,`No sound in this browser`)]}),(t||typeof document<`u`&&!!document.documentElement.requestFullscreen)&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>void Ne(),"aria-label":p?s(`join_exit_fullscreen`,void 0,`Leave full screen`):s(`pad_fill`,void 0,`Full screen`),className:`flex items-center gap-1 rounded-full bg-white/15 px-2.5 py-1 hover:bg-white/25`,"data-testid":`join-full`,children:p?(0,B.jsx)(be,{size:13}):(0,B.jsx)(k,{size:13})}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>x(!0),"aria-label":s(`join_check_title`,void 0,`Check your controller`),title:s(`join_check_title`,void 0,`Check your controller`),className:`flex items-center gap-1 rounded-full bg-white/15 px-2.5 py-1 hover:bg-white/25`,"data-testid":`join-check-open`,children:(0,B.jsx)(me,{size:13})}),(0,B.jsxs)(`button`,{type:`button`,onClick:xe,className:`flex items-center gap-1 rounded-full bg-[var(--color-danger,#dc2626)] px-3 py-1 font-medium`,"data-testid":`join-leave`,children:[(0,B.jsx)(ge,{size:13}),s(`join_leave`,void 0,`Leave`)]})]}),Re=ue.shown?`opacity-100`:`pointer-events-none opacity-0`,ze={"data-testid":`join-bar`,"data-shown":ue.shown?`1`:`0`,onFocus:e=>{e.target.matches?.(`:focus-visible`)&&se(!0)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||se(!1)},onPointerEnter:e=>{e.pointerType===`mouse`&&ae(!0)},onPointerLeave:()=>ae(!1)};return(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsxs)(`div`,{className:`${p||!t?`fixed inset-0 z-[200] bg-black`:`relative mx-auto aspect-video w-full max-w-[max(20rem,calc((100dvh_-_22rem)*16/9))] overflow-hidden rounded-[var(--radius-card)] bg-black shadow-[var(--shadow-2)]`} select-none text-white [-webkit-touch-callout:none]`,style:{touchAction:`none`},onPointerMove:e=>{if(e.pointerType===`mouse`)return de();let t=pe.current;t&&t.id===e.pointerId&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>pc&&he()},onPointerDown:e=>{if(fc(e.target))return;if(e.pointerType===`mouse`||!O)return de();if(e.target.closest?.(`[data-testid="join-bar"], button, a, input, [role="button"]`))return;he();let{pointerId:t,clientX:n,clientY:r}=e;pe.current={id:t,x:n,y:r,timer:setTimeout(()=>{pe.current=null,navigator.vibrate?.(15),ue.toggle()},450)}},onPointerUp:he,onPointerCancel:he,onPointerLeave:he,"data-testid":`join-stage-view`,children:[(0,B.jsx)(`div`,{ref:f,className:`pointer-events-none absolute inset-0 z-0 flex items-center justify-center`,"aria-hidden":!0}),D&&!ue.shown&&!S&&Te!=null&&(0,B.jsxs)(`span`,{className:`pointer-events-none absolute z-10 rounded-full bg-black/40 px-1.5 py-0.5 text-[10px] leading-none tabular-nums`,style:{color:hc[Ee],top:`max(0.5rem, env(safe-area-inset-top))`,right:`max(0.5rem, env(safe-area-inset-right))`},"data-testid":`join-delay-corner`,children:[Math.round(Te),` ms`]}),Oe?(0,B.jsxs)(`div`,{className:`absolute left-1/2 top-1/2 z-20 flex w-max max-w-[min(24rem,calc(100%-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col items-center gap-2 rounded-2xl bg-black/70 p-3 text-xs backdrop-blur-sm transition-opacity duration-300 ${Re}`,...ze,children:[(0,B.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:Ie}),(0,B.jsx)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:Le})]}):Pe?null:(0,B.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-20 flex flex-wrap items-center gap-2 bg-gradient-to-b from-black/70 to-transparent px-3 pb-5 pt-[max(8px,env(safe-area-inset-top))] text-xs transition-opacity duration-300 ${Re}`,...ze,children:[Ie,(0,B.jsx)(`span`,{className:`flex-1`}),Le]}),!ue.shown&&!Oe&&(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),de()},"aria-label":s(`join_show_controls`,void 0,`Show controls`),className:`absolute left-1/2 top-[max(6px,env(safe-area-inset-top))] z-20 flex h-7 w-11 -translate-x-1/2 items-center justify-center rounded-full bg-black/40 text-white/70 opacity-60 hover:opacity-100 focus-visible:opacity-100`,"data-testid":`join-show-controls`,children:(0,B.jsx)(le,{size:16,"aria-hidden":!0})}),_e&&!ue.shown&&(0,B.jsx)(`p`,{className:`pointer-events-none absolute left-1/2 top-[max(10px,env(safe-area-inset-top))] z-20 -translate-x-1/2 rounded-full bg-black/60 px-3 py-1 text-xs text-white/85`,"data-testid":`join-hold-hint`,children:s(`join_hold_hint`,void 0,`Press and hold the picture to show the buttons`)}),c.problem&&(0,B.jsx)(`p`,{className:`absolute inset-x-4 top-1/2 z-10 -translate-y-1/2 text-center text-sm text-white/85`,"data-testid":`join-problem`,children:c.problem===`no_hevc`?s(`pad_watch_no_hevc`,void 0,`This device can't play this stream's picture: the computer streams HEVC, and this device plays only H.264.`):s(`pad_watch_decode`,void 0,`The picture could not be played here.`)}),b&&(0,B.jsx)(ec,{onClose:()=>x(!1)}),Oe&&(0,B.jsx)(os,{stream:e,layout:`overlay`,onMenu:()=>ue.shown?ue.hide():de()}),!Oe&&!S&&(0,B.jsxs)(`div`,{className:`absolute bottom-3 left-3 z-20 flex items-center gap-2 rounded-2xl bg-black/70 px-3 py-1.5 text-xs transition-opacity duration-300 ${Re}`,"data-testid":`join-pad`,children:[(0,B.jsx)(me,{size:14,style:{color:y.pressed?`rgb(${M[0]},${M[1]},${M[2]})`:void 0}}),y.ready?(0,B.jsxs)(`span`,{className:`flex flex-col items-start gap-1`,children:[(0,B.jsx)(`span`,{children:s(`join_pad_ready`,void 0,`Your controller is ready`)}),y.weak8BitDo&&y.id&&(0,B.jsx)(Wo,{id:y.id,className:`text-amber-200/90`}),y.kind===`guess`&&to()&&(0,B.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-white/75`,"data-testid":`join-pad-unknown`,children:[s(`join_check_unknown_short`,void 0,`Not on our list: buttons may be mixed up.`),(0,B.jsx)(`button`,{type:`button`,onClick:()=>x(!0),className:`rounded-full bg-white px-2.5 py-0.5 font-medium text-black`,"data-testid":`join-pad-unknown-check`,children:s(`join_check_title`,void 0,`Check your controller`)})]})]}):De&&t&&!p?s(`join_full_to_play`,void 0,`Tap full screen to play with the on-screen controller.`):(0,B.jsxs)(`span`,{className:`flex flex-col`,children:[(0,B.jsx)(`span`,{children:s(`join_pad_none`,void 0,`Connect a controller (USB or Bluetooth) and press any button.`)}),(0,B.jsx)(`span`,{className:`text-white/60`,"data-testid":`join-pad-keys`,children:s(`join_pad_keys`,void 0,`Or use the keyboard: WASD move, arrows D-pad, Enter ✕, Backspace ○, Q □, E △, Tab Options.`)})]})]}),u?.blockSystem&&u.state===`playing`&&!Oe&&(0,B.jsx)(`p`,{className:`absolute bottom-3 right-3 z-20 rounded-full bg-black/60 px-3 py-1 text-[11px] text-white/70 transition-opacity duration-300 ${Re}`,"data-testid":`join-blocked`,children:s(`join_block_note`,{host:d},`${d} turned off PS and Create for friends.`)}),ce&&!Ae&&O&&!ue.shown&&!S&&(0,B.jsx)(`p`,{className:`pointer-events-none absolute left-1/2 top-2 z-20 -translate-x-1/2 whitespace-nowrap rounded-full bg-white/90 px-2.5 py-1 text-xs font-medium text-black`,"data-testid":`join-picking-note`,children:s(`join_picking`,void 0,`Press PS, then pick Quick Play on the TV`)}),ke&&!je&&(0,B.jsxs)(`div`,{className:`absolute bottom-14 left-1/2 z-30 w-[min(22rem,calc(100%-2rem))] -translate-x-1/2 rounded-2xl border border-white/10 bg-neutral-900/90 p-4 text-sm shadow-2xl backdrop-blur-md`,"data-testid":`join-guide`,children:[(0,B.jsx)(`p`,{className:`font-semibold`,children:s(`join_guide_title`,void 0,`One more step on the TV`)}),(0,B.jsx)(`p`,{className:`mt-1 text-white/75`,children:s(`join_guide_body`,void 0,`On your controller, press PS once. The TV asks "Who's using this controller?". Pick Quick Play or your own user. The host doesn't need to do anything.`)}),(0,B.jsx)(`p`,{className:`mt-1 text-white/60`,children:s(`join_guide_menus`,void 0,`On the PS5's home screen only the host controls the menus; your controller plays inside games.`)}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{Ft(ic,`1`),g(!0),ne(!1)},className:`mt-3 rounded-full bg-white px-3 py-1 text-xs font-medium text-black`,"data-testid":`join-guide-ok`,children:s(`join_guide_ok`,void 0,`Got it`)})]}),S&&(0,B.jsxs)(`div`,{className:`absolute inset-0 z-30 flex flex-col items-center justify-center gap-3 bg-black/70 px-6 text-center`,"data-testid":`join-reconnecting`,children:[(0,B.jsxs)(`button`,{type:`button`,onClick:xe,className:`absolute right-3 top-[max(10px,env(safe-area-inset-top))] flex items-center gap-1 rounded-full bg-white/15 px-3 py-1.5 text-sm font-medium hover:bg-white/25`,"data-testid":`join-reconnecting-leave`,children:[(0,B.jsx)(ge,{size:14}),s(`join_leave`,void 0,`Leave`)]}),(0,B.jsx)(`span`,{className:`h-7 w-7 animate-spin rounded-full border-2 border-white/30 border-t-white`,"aria-hidden":!0}),l.hostStopped?(0,B.jsx)(`p`,{className:`max-w-sm text-base font-medium`,"data-testid":`join-host-away`,children:s(`join_host_away`,{time:rc(Me)},`The host stopped playing — waiting for them to start again (${rc(Me)})`)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`p`,{className:`text-base font-medium`,children:s(`join_reconnecting`,void 0,`Reconnecting…`)}),(0,B.jsx)(`p`,{className:`text-sm text-white/70`,"data-testid":`join-reconnecting-left`,children:s(`join_reconnecting_left`,{time:rc(Me)},`Your place is kept for ${rc(Me)}.`)})]})]}),!t&&C&&_&&De&&(0,B.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-16 z-20 flex justify-center`,children:(0,B.jsxs)(`span`,{className:`flex items-center gap-2 rounded-full bg-black/70 px-3 py-1.5 text-xs text-white/85`,children:[(0,B.jsx)(j,{size:14}),s(`pad_turn`,void 0,`Turn the phone sideways`)]})})]}),Pe&&(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 rounded-[var(--radius-card)] bg-neutral-900 px-3 py-2 text-xs text-white`,"data-testid":`join-bar`,"data-shown":`1`,"data-below":`1`,children:[(0,B.jsx)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center gap-2`,children:Ie}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>void Ne(),className:`flex h-11 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-full bg-white/15 px-3 text-sm font-medium hover:bg-white/25`,"data-testid":`join-fullscreen-below`,children:[(0,B.jsx)(k,{size:15}),s(`pad_fill`,void 0,`Full screen`)]}),c.sound&&!c.noSound?(0,B.jsx)(`button`,{type:`button`,onClick:()=>e.setMuted(!c.muted),"aria-pressed":c.muted,"aria-label":c.muted?s(`rp_unmute`,void 0,`Sound on`):s(`rp_mute`,void 0,`Mute`),className:`flex h-11 w-11 items-center justify-center rounded-full bg-white/15 hover:bg-white/25`,children:c.muted?(0,B.jsx)(N,{size:16}):(0,B.jsx)(we,{size:16})}):c.sound?null:(0,B.jsxs)(`button`,{type:`button`,onClick:()=>e.startSound(),className:`flex h-11 items-center justify-center gap-1.5 rounded-full bg-white px-3 text-sm font-medium text-black`,children:[(0,B.jsx)(we,{size:15}),s(`join_sound`,void 0,`Tap for sound`)]}),(0,B.jsxs)(`button`,{type:`button`,onClick:xe,className:`flex h-11 items-center justify-center gap-1.5 rounded-full bg-[var(--color-danger,#dc2626)] px-4 text-sm font-medium`,"data-testid":`join-leave-below`,children:[(0,B.jsx)(ge,{size:15}),s(`join_leave`,void 0,`Leave`)]})]})]})}var vc=`ps5upload.join.name`;function yc(e){return/iPhone/.test(e)?`iPhone`:/iPad/.test(e)?`iPad`:/Android/.test(e)?`Android`:``}function bc(e){return e.trim().slice(0,32)}function xc(e=``){return bc(It(`ps5upload.join.name`)??``)||e}function Sc(e){let t=bc(e);return t&&Ft(vc,t),t}function Cc(e){try{return!!sessionStorage.getItem(Lo(e))}catch{return!1}}async function wc(e){try{e?(await document.documentElement.requestFullscreen?.({navigationUI:`hide`}),await screen.orientation.lock?.(`landscape`)):document.fullscreenElement&&await document.exitFullscreen()}catch{}}function Tc({url:e,invite:t,host:n,transport:r,lanUrl:i=null,path:a=null,internet:o}){let s=Fe(),c=tc(r&&o!==!1?e:null,i),[l,u]=(0,E.useState)(()=>xc(yc(typeof navigator>`u`?``:navigator.userAgent))),[d,f]=(0,E.useState)(null),[p,m]=(0,E.useState)(0),h=i=>{let s=Sc(i);if(!s)return;let c=new zs({url:e,invite:t,name:s,host:n,transport:r,path:a,...o===void 0?{}:{internet:o}});f(c),m(e=>e+1),c.start()};if((0,E.useEffect)(()=>{!d&&Cc(t)&&l.trim()&&h(l)},[]),(0,E.useEffect)(()=>d?Hs(d):void 0,[d]),(0,E.useEffect)(()=>{if(!d)return;let e=()=>d.stop();return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[d]),d)return(0,B.jsx)(_c,{session:d,lanUrl:i,hubDown:c,onLeave:()=>f(null),onAgain:()=>{d.stop(),h(l)},onFullscreen:wc},p);let g=n??s(`join_host_fallback`,void 0,`your friend`),_=(0,B.jsx)(`div`,{className:`flex min-h-[100dvh] items-center justify-center bg-black px-6 text-white`,"data-testid":`join-name-step`,children:(0,B.jsxs)(`form`,{className:`w-full max-w-sm space-y-4 rounded-2xl border border-white/10 bg-neutral-900 p-6`,onSubmit:e=>{e.preventDefault(),h(l)},children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,B.jsx)(`span`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-white/10`,children:(0,B.jsx)(Se,{size:20})}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:s(`join_title`,void 0,`Join a friend's game`)}),(0,B.jsx)(`p`,{className:`text-sm text-white/60`,children:s(`join_title_body`,{host:g},`Play on ${g}'s PS5 as Player 2, 3 or 4.`)})]})]}),(0,B.jsxs)(`label`,{className:`block space-y-1.5`,children:[(0,B.jsx)(`span`,{className:`text-sm font-medium`,children:s(`join_name_label`,void 0,`Your name`)}),(0,B.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),maxLength:32,autoComplete:`nickname`,className:`block w-full rounded-lg border border-white/15 bg-black px-3 py-2 text-base outline-none focus:border-white/50`,"data-testid":`join-name`}),(0,B.jsx)(`span`,{className:`block text-xs text-white/50`,children:s(`join_name_hint`,void 0,`Your friend sees this when you ask to join.`)})]}),(0,B.jsx)(`button`,{type:`submit`,disabled:!l.trim(),className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black disabled:opacity-40`,"data-testid":`join-go`,children:s(`join_button`,void 0,`Join`)}),c&&i&&(0,B.jsx)(nc,{href:i})]})});return t?(0,B.jsx)(Uo,{appLink:nt(location.href),children:_}):_}function Ec(e){let t=(e??``).trim().replace(/^\[|\]$/g,``).toLowerCase(),n=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(t);if(n){let e=n.slice(1).map(Number);if(e.some(e=>e>255))return null;let[t,r]=e;return t===10||t===172&&r>=16&&r<32||t===192&&r===168||t===169&&r===254||t===127?0:t===100&&r>=64&&r<128?1:2}if(!t.includes(`:`)||!/^[0-9a-f:.]+$/.test(t))return null;if(t.startsWith(`fd7a:115c:a1e0:`))return 1;let r=parseInt(t.split(`:`)[0]||`0`,16);return(r&65024)==64512||(r&65472)==65152||t===`::1`?0:2}function Dc(e,t){let n=Ec(e),r=Ec(t);return n===1||r===1?`tailscale`:r===0?`lan`:r===2?`internet`:null}function Oc(e){let t=(e??``).toLowerCase();if(t.endsWith(`.local`))return`lan`;if(t.endsWith(`.ts.net`))return`tailscale`;let n=Ec(t);return n===0?`lan`:n===1?`tailscale`:null}function kc(e){let t=[];if(typeof e.forEach==`function`)e.forEach(e=>t.push(e));else for(let n of e)t.push(n);let n=new Map(t.map(e=>[String(e.id),e])),r=t.filter(e=>e.type===`candidate-pair`),i=t.filter(e=>e.type===`transport`&&typeof e.selectedCandidatePairId==`string`).map(e=>n.get(String(e.selectedCandidatePairId))).find(Boolean)??r.find(e=>e.selected===!0)??r.find(e=>e.nominated===!0&&e.state===`succeeded`);if(!i)return null;let a=e=>{let t=n.get(String(e));if(!t)return null;let r=t.address??t.ip;return typeof r==`string`?r:null};return Dc(a(i.localCandidateId),a(i.remoteCandidateId))}function Ac(e){let t=e.replace(/:\d+$/,``).replace(/^\[|\]$/g,``);return`${t===`localhost`||t===`127.0.0.1`||t===`::1`?`ws`:`wss`}://${e}/ws`}function jc(e){let t=new Set;for(let n of e.matchAll(/^a=fingerprint:sha-256[ \t]+([0-9A-Fa-f:]+)[ \t]*\r?$/gim))t.add(n[1].toUpperCase());return/^a=fingerprint:(?!sha-256[ \t])/im.test(e)?null:t.size===1?[...t][0]:null}function Mc(e,t){let n=jc(e);return n!==null&&n===t.toUpperCase()}var Nc=16777216;function Pc(e){let t=16383,n=Math.max(1,Math.ceil(e.length/t)),r=[];for(let i=0;ithis.max)return this.parts=[],this.size=0,{kind:`error`,why:`too_big`};if(this.parts.push(r.slice()),this.size+=r.length,n===1)return{kind:`partial`};let i=new Uint8Array(this.size),a=0;for(let e of this.parts)i.set(e,a),a+=e.length;return this.parts=[],this.size=0,{kind:`message`,data:i.buffer}}};function Ic(e){let t=new Uint8Array(9);return t[0]=3,t.set(e.subarray(0,8),1),t}var Lc=[`stun:stun.cloudflare.com:3478`,`stun:stun.l.google.com:19302`],Rc=1500,zc=2e4;function Bc(e){let t=e?.codecs??[],n=e=>t.filter(t=>t.mimeType.toLowerCase()===e);return[...n(`video/h264`),...n(`video/h265`),...n(`video/rtx`)]}var Vc=null;function Hc(e){e.onopen=e.onmessage=e.onclose=e.onerror=null;try{e.readyState===1&&e.send(JSON.stringify({t:`leave`})),e.close(1e3)}catch{}}function Uc(e,t={}){let n=t.WebSocketImpl??(typeof WebSocket>`u`?void 0:WebSocket);if(!n||Vc)return;let r=Ac(e.hub),i;try{i=new n(r)}catch{return}let a={url:r,room:e.room,ws:i,msgs:[],timer:null};Vc=a;let o=()=>{Vc===a&&(Vc=null,a.timer&&clearTimeout(a.timer),Hc(i))};i.onopen=()=>i.send(JSON.stringify({v:1,t:`join`,room:e.room})),i.onmessage=e=>{if(typeof e.data==`string`)try{a.msgs.push(JSON.parse(e.data))}catch{}},i.onclose=o,i.onerror=()=>{},a.timer=setTimeout(o,t.keepMs??6e4)}function Wc(e,t){let n=Vc;return n?(Vc=null,n.timer&&clearTimeout(n.timer),n.url!==e||n.room!==t||n.ws.readyState>1||n.msgs.some(e=>e.t===`error`||e.t===`closed`)?(Hc(n.ws),null):{ws:n.ws,msgs:n.msgs}):null}function Gc(e,t={}){var n;let r=t.WebSocketImpl??(typeof WebSocket>`u`?void 0:WebSocket),i=t.PeerConnection??(typeof RTCPeerConnection>`u`?void 0:RTCPeerConnection),a=t.iceTimeoutMs??15e3,o=t.log??(()=>{});class s{constructor(e){this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this.readyState=0,this.binaryType=`arraybuffer`,this.onopen=null,this.onmessage=null,this.onclose=null,this.onerror=null,this.hub=null,this.pc=null,this.dc=null,this.timer=null,this.rx=new Fc,this.answered=!1,this.early=[],this.hubBackUntil=0,this.offerSdp=null,this.offerSent=!1,this.ownEarly=[],this.media=null,setTimeout(()=>this.begin(),0)}begin(){if(this.readyState!==0)return;if(!i||!r){this.fail(`no_webrtc`);return}let n=t.signalUrl??Ac(e.hub),a=t.signalUrl||t.lan?null:Wc(n,e.room),s;if(a)s=a.ws,o(`hub: joined early`);else try{s=new r(n)}catch{this.fail(`no_hub`);return}if(this.hub=s,this.prepare(),this.readyState===0){s.onopen=()=>s.send(JSON.stringify(t.lan?{v:1,t:`join`,lan:!0}:{v:1,t:`join`,room:e.room})),s.onmessage=e=>{if(typeof e.data!=`string`)return;let t;try{t=JSON.parse(e.data)}catch{return}this.onHub(t)},s.onclose=e=>{this.hub===s&&(this.hub=null,this.readyState===0&&(this.answered||e?.code===1001&&this.hubRestarting()||this.fail(`no_hub`)))},s.onerror=()=>{};for(let e of a?.msgs??[])this.onHub(e)}}signal(e){let t=this.hub;t&&t.readyState===1&&t.send(JSON.stringify({t:`signal`,to:`host`,data:e}))}onHub(e){if(this.readyState===0)switch(e.t){case`joined`:o(`hub: joined room as ${e.gid??`?`}`),this.sendOffer();return;case`signal`:e.from===`host`&&e.data&&typeof e.data==`object`&&this.onSignal(e.data);return;case`closed`:this.fail(`no_room`);return;case`error`:if(o(`hub: error ${e.why??`?`}`),e.why===`no_room`&&this.hubBackUntil&&this.hubRestarting())return;this.fail(e.why===`no_room`?`no_room`:e.why===`room_full`?`net_full`:`no_hub`);return}}prepare(){if(!i)return;this.offerSent=!1,this.ownEarly=[];let e;try{e=new i({iceServers:[{urls:Lc}]})}catch{this.fail(`no_webrtc`);return}this.pc=e;let n=e.createDataChannel(t.label??`join`,{ordered:!0});if(n.binaryType=`arraybuffer`,this.dc=n,n.onopen=()=>this.opened(n),n.onmessage=e=>this.fromChannel(e.data),n.onclose=()=>{this.dc===n&&this.dropped()},t.video&&e.addTransceiver){try{let t=e.addTransceiver(`video`,{direction:`recvonly`}),n=Bc(globalThis.RTCRtpReceiver?.getCapabilities?.(`video`));n.length&&t.setCodecPreferences&&t.setCodecPreferences(n)}catch{}try{e.addTransceiver(`audio`,{direction:`recvonly`})}catch{}e.ontrack=t=>{if(this.pc!==e)return;let n=this.media?.stream??t.streams[0]??new MediaStream;n.getTracks().includes(t.track)||n.addTrack(t.track),this.media=t.track.kind===`audio`?{stream:n,receiver:this.media?.receiver??t.receiver,audio:t.receiver}:{stream:n,receiver:t.receiver,...this.media?.audio?{audio:this.media.audio}:{}}}}e.onicecandidate=t=>{if(this.pc!==e)return;let n=t.candidate;if(!n||!n.candidate)return;let r={type:`candidate`,candidate:n.candidate,sdpMid:n.sdpMid??`0`};this.offerSent?this.signal(r):this.ownEarly.push(r)},e.oniceconnectionstatechange=()=>{if(this.pc!==e)return;let t=e.iceConnectionState;o(`ice: ${t}`),t===`failed`&&(this.readyState===0?this.fail(`no_direct`):this.dropped())},this.offerSdp=(async()=>{let t=await e.createOffer();return await e.setLocalDescription(t),e.localDescription?.sdp??t.sdp??``})().catch(()=>(this.pc===e&&this.fail(`no_webrtc`),null))}async sendOffer(){let e=this.pc,t=this.offerSdp;if(!e||!t||this.offerSent)return;this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.readyState===0&&this.fail(`no_direct`)},a);let n=await t;if(this.pc===e&&n!==null&&this.readyState===0){this.signal({type:`offer`,sdp:n}),this.offerSent=!0;for(let e of this.ownEarly.splice(0))this.signal(e)}}async onSignal(t){let n=this.pc;if(t.type===`bye`)this.fail(t.why===`full`?`net_full`:`offer`);else if(n){if(t.type===`answer`){if(this.answered||typeof t.sdp!=`string`)return;if(e.fp?!Mc(t.sdp,e.fp):jc(t.sdp)===null){o(`answer: fingerprint does not match the link`),this.fail(`mismatch`);return}this.answered=!0;try{await n.setRemoteDescription({type:`answer`,sdp:t.sdp});for(let e of this.early.splice(0))await n.addIceCandidate(e).catch(()=>{})}catch{this.fail(`offer`)}}else if(t.type===`candidate`&&typeof t.candidate==`string`&&t.candidate){let e={candidate:t.candidate,sdpMid:typeof t.sdpMid==`string`?t.sdpMid:`0`,sdpMLineIndex:typeof t.sdpMLineIndex==`number`?t.sdpMLineIndex:0};this.answered?await n.addIceCandidate(e).catch(()=>{}):this.early.push(e)}}}opened(e){this.dc===e&&this.readyState===0&&(this.clearTimer(),this.readyState=1,o(`channel open`),this.leaveHub(),this.onopen?.(new Event(`open`)))}fromChannel(e){if(this.readyState!==1)return;if(typeof e==`string`){this.onmessage?.(new MessageEvent(`message`,{data:e}));return}if(!(e instanceof ArrayBuffer))return;let t=this.rx.push(e);switch(t.kind){case`ping`:try{this.dc?.send(Ic(t.data))}catch{}return;case`message`:this.onmessage?.(new MessageEvent(`message`,{data:t.data}));return;case`error`:o(`channel: bad binary message (${t.why})`),this.dropped();return;default:return}}async netPath(){let e=this.pc;if(!e||this.readyState!==1||typeof e.getStats!=`function`)return null;try{return kc(await e.getStats())}catch{return null}}send(e){let t=this.dc;if(this.readyState!==1||!t||t.readyState!==`open`)throw Error(`not open`);if(typeof e==`string`){t.send(e);return}let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e);for(let e of Pc(n))t.send(e)}close(){this.readyState!==3&&(this.teardown(),this.emitClose(1e3,``,!0))}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}leaveHub(){let e=this.hub;if(this.hub=null,e)try{e.readyState===1&&e.send(JSON.stringify({t:`leave`})),e.close(1e3)}catch{}}hubRestarting(){let e=Date.now();return this.hubBackUntil||=e+zc,e>=this.hubBackUntil?!1:(o(`hub: restarting, trying again`),this.clearTimer(),this.leaveHub(),this.closePeer(),this.answered=!1,this.early=[],this.timer=setTimeout(()=>{this.timer=null,this.begin()},Rc),!0)}teardown(){this.readyState=3,this.clearTimer(),this.leaveHub(),this.closePeer()}closePeer(){let e=this.pc,t=this.dc;this.pc=null,this.dc=null,this.media=null,this.offerSdp=null,this.offerSent=!1,this.ownEarly=[];try{t?.close()}catch{}try{e?.close()}catch{}}dropped(){this.readyState!==3&&(this.teardown(),this.emitClose(1006,``,!1))}fail(e){this.readyState!==3&&(o(`failed: ${e}`),this.teardown(),this.emitClose(Ve,`net:${e}`,!1))}emitClose(e,t,n){let r=this.onclose;if(!r)return;let i=typeof CloseEvent>`u`?{type:`close`,code:e,reason:t,wasClean:n}:new CloseEvent(`close`,{code:e,reason:t,wasClean:n});setTimeout(()=>r(i),0)}}return n=s,n.CONNECTING=0,n.OPEN=1,n.CLOSING=2,n.CLOSED=3,s}var Kc=3e3;function qc(e,t){return/^https?:\/\/[^/?#]+(\/[^?#]*)?\/join\/?$/.test(e)?e.replace(/^http/,`ws`).replace(/\/join\/?$/,`/${t}`):null}var Jc=e=>qc(e,`api/join/signal`);function Yc(e){let t=[];if(e.rtc){let n=e.net??{room:``,key:``,fp:e.fp??``,hub:``};for(let[r,i]of[[`lan`,e.lan],[`tailscale`,e.ts]]){let a=i?Jc(i):null;if(!a)continue;let o=e.rtcMake(n,{signalUrl:e.reach(a),...e.net?{}:{lan:!0}});t.push({via:r,make:()=>new o(``),pinned:!!n.fp})}if(e.net){let n=e.rtcMake(e.net,{});t.push({via:`hub`,make:()=>new n(``),pinned:!0})}}let n=e.lan?qc(e.lan,`api/join/ws`):null;if(n){let r=e.reach(n);t.push({via:`socket`,make:()=>e.socket(r)})}return t}var Xc=new Map;function Zc(e,t,n=300,r=Kc){let i=e.some(e=>e===`lan`||e===`tailscale`),a=e.some(e=>e!==`socket`);return e.map(e=>e===t?0:e===`hub`&&i?n:e===`socket`&&a?r:0)}function Qc(e){let t=e.find(e=>e.via===`hub`),n=e.find(e=>(e.via===`lan`||e.via===`tailscale`)&&[`no_direct`,`net_full`,`offer`].includes(He(e.e)??``));return t&&(He(t.e)!==`no_hub`||!n)?t.e:n?n.e:t?.e??e[e.length-1]?.e??null}function $c(e,t){var n;let r=t.log??(()=>{}),i=t.headStartMs??300,a=t.socketAfterMs??3e3;class o{constructor(e){this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this.readyState=0,this.binaryType=`arraybuffer`,this.onopen=null,this.onmessage=null,this.onclose=null,this.onerror=null,this.live=[],this.waiting=[],this.pinned=new Set,this.t0=0,this.closes=[],this.winner=null,setTimeout(()=>this.begin(),0)}get via(){return this.winner?.via??null}get media(){return this.winner?.s?.media??null}async netPath(){let e=this.winner?.s;return e?.netPath?e.netPath():null}begin(){if(this.readyState!==0)return;let n=e();if(!n.length){this.end({type:`close`,code:1006,reason:``,wasClean:!1});return}this.t0=Date.now();for(let e of n)e.pinned&&this.pinned.add(e.via);let r=Zc(n.map(e=>e.via),Xc.get(t.room)??null,i,a);n.forEach((e,t)=>{r[t]===0?this.launch(e.via,e.make):this.waiting.push({via:e.via,make:e.make,timer:setTimeout(()=>this.startWaiting(e.via),r[t])})})}startWaiting(e){let t=this.waiting.findIndex(t=>t.via===e);if(t<0)return;let[n]=this.waiting.splice(t,1);clearTimeout(n.timer),this.launch(n.via,n.make)}launch(e,t){if(this.readyState!==0)return;let n;try{n=t()}catch{this.tryClosed(e,{type:`close`,code:1006,reason:``,wasClean:!1});return}r(`path: trying ${e}`);let i={via:e,s:n};this.live.push(i),n.binaryType=this.binaryType,n.onopen=e=>this.won(i,e),n.onclose=t=>{this.live=this.live.filter(e=>e!==i),this.tryClosed(e,t)},n.onerror=()=>{},n.onmessage=null}tryClosed(e,t){if(this.readyState===0){if(r(`path: ${e} failed after ${Date.now()-this.t0} ms${t?.reason?` (${t.reason})`:``}`),this.closes.push({via:e,e:t}),this.pinned.has(e)&&He(t)===`mismatch`){for(let e of this.waiting.filter(e=>e.via===`socket`))clearTimeout(e.timer);this.waiting=this.waiting.filter(e=>e.via!==`socket`)}!this.live.length&&this.waiting.length?this.startWaiting(this.waiting[0].via):!this.live.length&&!this.waiting.length&&this.end(Qc(this.closes))}}won(e,n){if(this.readyState!==0)return;this.winner=e,Xc.set(t.room,e.via),r(`path: playing by ${e.via} after ${Date.now()-this.t0} ms`);for(let e of this.waiting.splice(0))clearTimeout(e.timer);for(let t of this.live.splice(0))if(t!==e){t.s.onopen=t.s.onclose=t.s.onmessage=t.s.onerror=null;try{t.s.close()}catch{}}let i=e.s;i.onmessage=e=>this.onmessage?.(e),i.onerror=e=>this.onerror?.(e),i.onclose=e=>{this.readyState!==3&&(this.readyState=3,this.onclose?.(e))},this.readyState=1,t.onWin?.(e.via),this.onopen?.(n)}send(e){if(this.readyState!==1||!this.winner)throw Error(`not open`);this.winner.s.send(e)}close(e,t){if(this.readyState===3)return;let n=this.readyState===1;this.readyState=3;for(let e of this.waiting.splice(0))clearTimeout(e.timer);let r=this.winner?[this.winner,...this.live]:this.live.splice(0);for(let n of r){n.s.onopen=n.s.onclose=n.s.onmessage=n.s.onerror=null;try{n.s.close(e,t)}catch{}}let i=this.onclose;if(i){let r={type:`close`,code:e??1e3,reason:t??``,wasClean:n};setTimeout(()=>i(r),0)}}end(e){if(this.readyState===3)return;this.readyState=3;let t=this.onclose,n=e??{type:`close`,code:1006,reason:``,wasClean:!1};t&&setTimeout(()=>t(n),0)}}return n=o,n.CONNECTING=0,n.OPEN=1,n.CLOSING=2,n.CLOSED=3,o}var el=new URLSearchParams(location.hash.slice(1)),tl=el.get(`n`)?.trim()||null,nl=tt(location.hash);nl&&Uc(nl);var rl=(0,x.createRoot)(document.getElementById(`root`));if(nl){let e=Gc(nl,{video:!0,log:e=>console.info(`[join] ${e}`)}),t=Le(location.hash,`join`);rl.render((0,B.jsx)(Tc,{url:Ac(nl.hub),invite:nl.key,host:tl,transport:e,lanUrl:t?Re(t,{key:nl.key}):null}))}else{let e=el.get(`i`)||null,t=location.pathname.replace(/\/join\/?$/,``),n=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}${t}/api/join/ws`,r=e=>console.info(`[join] ${e}`),i=`${location.origin}${t}/join`,a=typeof RTCPeerConnection>`u`?void 0:$c(()=>Yc({net:null,lan:i,ts:null,fp:et(el.get(`fp`)),rtc:!0,reach:e=>e,rtcMake:(e,t)=>Gc(e,{video:!0,log:r,...t}),socket:e=>new WebSocket(e)}),{room:i,log:r});rl.render((0,B.jsx)(Tc,{url:n,invite:e,host:tl,path:Oc(location.hostname),transport:a,internet:!1}))} diff --git a/site/pad/index.html b/site/pad/index.html index 51c8b4785..d9893367e 100644 --- a/site/pad/index.html +++ b/site/pad/index.html @@ -8,15 +8,15 @@ PS5Upload controller - +I€wu¸öôú!3å6³‹âVq£³¹´RN£%y10º:pŠ#\:J:b9Hµ7h_Ž:¢I9 _¼™µV,þ <`});var w={a:v};this.setModule=t=>{e.setModule(fi,t)},this.getModule=()=>e.getModule(fi),this.instantiate=()=>(this.getModule().then(e=>WebAssembly.instantiate(e,w)).then(e=>{let t=e.exports;y(t),a=t.g,o(),ne(t),n()}),this.ready=new Promise(e=>{n=e}).then(()=>{this.HEAP=a.buffer,this.malloc=x,this.free=te,this.opus_frame_decoder_create=b,this.opus_frame_decode_float_deinterleaved=S,this.opus_frame_decoder_destroy=ee}),this)}var pi=o((()=>{}));function mi(e={}){mi.errors||Object.defineProperties(mi,{errors:{value:new Map([[-1,`OPUS_BAD_ARG: One or more invalid/out of range arguments`],[-2,`OPUS_BUFFER_TOO_SMALL: Not enough bytes allocated in the buffer`],[-3,`OPUS_INTERNAL_ERROR: An internal error was detected`],[-4,`OPUS_INVALID_PACKET: The compressed data passed is corrupted`],[-5,`OPUS_UNIMPLEMENTED: Invalid/unsupported request number`],[-6,`OPUS_INVALID_STATE: An encoder or decoder structure is invalid or already freed`],[-7,`OPUS_ALLOC_FAIL: Memory allocation has failed`]])}}),this._init=()=>new this._WASMAudioDecoderCommon(this).instantiate(this._EmscriptenWASM,this._module).then(e=>{this._common=e,this._inputBytes=0,this._outputSamples=0,this._frameNumber=0,this._input=this._common.allocateTypedArray(this._inputSize,Uint8Array),this._output=this._common.allocateTypedArray(this._outputChannels*this._outputChannelSize,Float32Array);let t=this._common.allocateTypedArray(this._channels,Uint8Array);t.buf.set(this._channelMappingTable),this._decoder=this._common.wasm.opus_frame_decoder_create(this._sampleRate,this._channels,this._streamCount,this._coupledStreamCount,t.ptr,this._preSkip,this._forceStereo)}),Object.defineProperty(this,"ready",{enumerable:!0,get:()=>this._ready}),this.reset=()=>(this.free(),this._init()),this.free=()=>{this._common.free(),this._common.wasm.opus_frame_decoder_destroy(this._decoder),this._common.wasm.free(this._decoder)},this._decode=e=>{if(!(e instanceof Uint8Array))throw Error(`Data to decode must be Uint8Array. Instead got `+typeof e);this._input.buf.set(e);let t=this._common.wasm.opus_frame_decode_float_deinterleaved(this._decoder,this._input.ptr,e.length,this._output.ptr),n;return t<0&&(n=`libopus `+t+` `+(mi.errors.get(t)||`Unknown Error`),console.error(n),t=0),{outputBuffer:this._common.getOutputChannels(this._output.buf,this._outputChannels,t),samplesDecoded:t,error:n}},this.decodeFrame=e=>{let t=[],n=this._decode(e);return n.error&&this._common.addError(t,n.error,e.length,this._frameNumber,this._inputBytes,this._outputSamples),this._frameNumber++,this._inputBytes+=e.length,this._outputSamples+=n.samplesDecoded,this._WASMAudioDecoderCommon.getDecodedAudioMultiChannel(t,[n.outputBuffer],this._outputChannels,n.samplesDecoded,this._sampleRate)},this.decodeFrames=e=>{let t=[],n=[],r=0,i=0;for(;itypeof e==`number`,n=e.sampleRate,r=e.channels,i=e.streamCount,a=e.coupledStreamCount,o=e.channelMappingTable,s=e.preSkip,c=+!!e.forceStereo;if(r>2&&(!t(i)||!t(a)||!Array.isArray(o)))throw Error(`Invalid Opus Decoder Options for multichannel decoding.`);return this._sampleRate=[8e3,12e3,16e3,24e3,48e3].includes(n)?n:48e3,this._channels=t(r)?r:2,this._streamCount=t(i)?i:1,this._coupledStreamCount=t(a)?a:this._channels-1,this._channelMappingTable=o||(this._channels===2?[0,1]:[0]),this._preSkip=s||0,this._forceStereo=r<=8&&r!=2?c:0,this._inputSize=3840*this._channels,this._outputChannelSize=5760,this._outputChannels=this._forceStereo?2:this._channels,this._ready=this._init(),this}var hi=o((()=>{di(),pi()})),gi,_i=o((()=>{di(),pi(),hi(),gi=class extends si{constructor(e){super(e,`opus-decoder`,mi,fi)}async decodeFrame(e){return this.postToDecoder(`decodeFrame`,e)}async decodeFrames(e){return this.postToDecoder(`decodeFrames`,e)}}})),vi=c({OpusDecoder:()=>mi,OpusDecoderWebWorker:()=>gi}),yi=o((()=>{hi(),_i(),di(),li(mi,`OpusDecoder`),li(gi,`OpusDecoderWebWorker`)})),bi=[8e3,12e3,16e3,24e3,48e3],xi=null;function Si(){return xi??=Vn(()=>Promise.resolve().then(()=>(yi(),vi)),__VITE_PRELOAD__,import.meta.url).catch(e=>{throw xi=null,e}),xi}function Ci(){return typeof WebAssembly==`object`&&typeof WebAssembly.instantiate==`function`}function wi(e,t,n,r){return{numberOfFrames:t,numberOfChannels:e.length,sampleRate:n,timestamp:r,format:`f32-planar`,duration:Math.round(t/n*1e6),copyTo(n,r){n.set(e[r.planeIndex].subarray(0,t))},close(){}}}var Ti=class{constructor(e,t=Si){this.init=e,this.load=t,this.state=`unconfigured`,this.dec=null,this.pending=[]}configure(e){if(this.state===`closed`)throw Error(`the decoder is closed`);if(!Ci())throw Error(`no WebAssembly here`);let t=e.sampleRate;if(!bi.includes(t))throw Error(`Opus does not decode at ${t} Hz`);let n=e.numberOfChannels;if(n<1||n>2)throw Error(`${n} channels: only mono and stereo are decoded`);this.state=`configured`,this.load().then(async e=>{if(this.state===`closed`)return;let r=new e.OpusDecoder({channels:n,sampleRate:t});if(await r.ready,this.state!==`configured`){r.free();return}this.dec=r;let i=this.pending;this.pending=[];for(let e of i)this.state===`configured`&&this.run(e)}).catch(e=>this.fail(e))}decode(e){if(this.state!==`configured`)return;let t=e;if(this.dec)return this.run(t);this.pending.push({timestamp:t.timestamp,data:t.data.slice()}),this.pending.length>50&&this.pending.shift()}run(e){let t=this.dec;if(!t)return;let n;try{n=t.decodeFrame(e.data)}catch(e){return this.fail(e)}n.samplesDecoded&&n.channelData.length&&this.init.output(wi(n.channelData,n.samplesDecoded,n.sampleRate,e.timestamp))}fail(e){if(this.state===`closed`)return;this.close();let t=e instanceof Error?e:Error(String(e));queueMicrotask(()=>this.init.error(t))}close(){this.state=`closed`,this.pending=[];let e=this.dec;this.dec=null;try{e?.free()}catch{}}},Ei={makeDecoder:e=>new Ti(e),makeChunk:e=>({type:e.type,timestamp:e.timestamp,data:e.data instanceof Uint8Array?e.data:new Uint8Array(e.data)})};function Di(e,t){for(let n=0;n+3>1&63;if(t>=16&&t<=21)return!0;if(t<16)return!1}else{let t=e[n+3]&31;if(t===5)return!0;if(t===1)return!1}}return!1}function Oi(e){for(let t=0;t+6e.toString(16).padStart(2,`0`);return`avc1.${n(e[t+4])}${n(e[t+5])}${n(e[t+6])}`}return`avc1.4d4028`}var ki=[`hev1.1.6.L153.B0`,`hvc1.1.6.L153.B0`,`hev1.2.4.L153.B0`,`hvc1.2.4.L153.B0`,`hev1.1.6.L150.90`];async function Ai(e,t){if(typeof VideoDecoder>`u`)return null;for(let n of ki)try{if((await VideoDecoder.isConfigSupported({codec:n,codedWidth:e,codedHeight:t})).supported)return n}catch{}return null}function ji(e){let t=[];for(let n=0;n+2{let i=r+1n&&e[i-1]===0;)i--;return e.subarray(n,i)}).filter(e=>e.length>0)}var Mi=(e,t)=>t?e[0]>>1&63:e[0]&31;function j(e,...t){let n=8+t.reduce((e,t)=>e+t.length,0),r=new Uint8Array(n);new DataView(r.buffer).setUint32(0,n);for(let t=0;t<4;t++)r[4+t]=e.charCodeAt(t);let i=8;for(let e of t)r.set(e,i),i+=e.length;return r}function M(...e){let t=new Uint8Array(e.reduce((e,[,t])=>e+t,0)),n=0;for(let[r,i]of e){for(let e=i-1;e>=0;e--)t[n+i-1-e]=Math.floor(r/2**(8*e))&255;n+=i}return t}var Ni=(e,t,n,...r)=>j(e,M([t,1],[n,3]),...r),Pi=M([65536,4],[0,4],[0,4],[0,4],[65536,4],[0,4],[0,4],[0,4],[1073741824,4]);function Fi(e){let t=e.handler===`vide`,n=j(`ftyp`,new TextEncoder().encode(`isom`),M([1,4]),new TextEncoder().encode(`isomiso6mp41`)),r=j(`moov`,Ni(`mvhd`,0,0,M([0,4],[0,4],[e.timescale,4],[0,4],[65536,4],[256,2],[0,2],[0,4],[0,4]),Pi,new Uint8Array(24),M([2,4])),j(`trak`,Ni(`tkhd`,0,3,M([0,4],[0,4],[1,4],[0,4],[0,4],[0,4],[0,4],[0,2],[0,2],[t?0:256,2],[0,2]),Pi,M([(e.width??0)*65536,4],[(e.height??0)*65536,4])),j(`mdia`,Ni(`mdhd`,0,0,M([0,4],[0,4],[e.timescale,4],[0,4],[21956,2],[0,2])),Ni(`hdlr`,0,0,M([0,4]),new TextEncoder().encode(e.handler),new Uint8Array(12),M([0,1])),j(`minf`,t?Ni(`vmhd`,0,1,new Uint8Array(8)):Ni(`smhd`,0,0,M([0,4])),j(`dinf`,Ni(`dref`,0,0,M([1,4]),Ni(`url `,0,1))),j(`stbl`,Ni(`stsd`,0,0,M([1,4]),e.sampleEntry),Ni(`stts`,0,0,M([0,4])),Ni(`stsc`,0,0,M([0,4])),Ni(`stsz`,0,0,M([0,4],[0,4])),Ni(`stco`,0,0,M([0,4])))))),j(`mvex`,Ni(`trex`,0,0,M([1,4],[1,4],[0,4],[0,4],[0,4])))),i=new Uint8Array(n.length+r.length);return i.set(n,0),i.set(r,n.length),i}function Ii(e,t,n,r,i){let a=i?33554432:16842752,o=e=>Ni(`trun`,0,1793,M([1,4],[e,4],[n,4],[r.length,4],[a,4])),s=e=>j(`traf`,Ni(`tfhd`,0,131072,M([1,4])),Ni(`tfdt`,1,0,M([t,8])),o(e)),c=Ni(`mfhd`,0,0,M([e,4])),l=j(`moof`,c,s(0)).length,u=j(`moof`,c,s(l+8)),d=j(`mdat`,r),f=new Uint8Array(u.length+d.length);return f.set(u,0),f.set(d,u.length),f}function Li(e,t,n=!1){let r=t?[35,...n?[32,33,34]:[]]:[9,...n?[7,8]:[]],i=ji(e).filter(e=>!r.includes(Mi(e,t))),a=new Uint8Array(i.reduce((e,t)=>e+4+t.length,0)),o=new DataView(a.buffer),s=0;for(let e of i)o.setUint32(s,e.length),a.set(e,s+4),s+=4+e.length;return a}var Ri=e=>e.toString(16).padStart(2,`0`),zi=e=>{let t=new Uint8Array(2+e.length);return t[0]=e.length>>8,t[1]=e.length&255,t.set(e,2),t},Bi=e=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t};function Vi(e){let t=ji(e),n=t.filter(e=>Mi(e,!1)===7),r=t.filter(e=>Mi(e,!1)===8);return!n.length||!r.length||n[0].length<4?null:Bi([M([1,1],[n[0][1],1],[n[0][2],1],[n[0][3],1],[255,1],[224|n.length,1]),...n.map(zi),M([r.length,1]),...r.map(zi)])}function Hi(e,t,n){let r=ji(e),i=e=>r.filter(n=>Mi(n,t)===e),a=(e,t)=>j(e,new Uint8Array(6),M([1,2],[0,16],[n.w,2],[n.h,2],[4718592,4],[4718592,4],[0,4],[1,2]),new Uint8Array(32),M([24,2],[65535,2]),t);if(!t){let t=i(7),r=Vi(e);return r?{init:Fi({handler:`vide`,timescale:9e4,sampleEntry:a(`avc1`,j(`avcC`,r)),width:n.w,height:n.h}),mime:`video/mp4; codecs="avc1.${Ri(t[0][1])}${Ri(t[0][2])}${Ri(t[0][3])}"`}:null}let o=i(32),s=i(33),c=i(34);if(!o.length||!s.length||!c.length)return null;let l=Vr(s[0]);if(l.length<15)return null;let u=l.subarray(3,15),d=u[0]&31,f=d===2?2:0,p=(e,t)=>Bi([M([128|e,1],[t.length,2]),...t.map(zi)]),m=j(`hvcC`,M([1,1]),u,M([61440,2],[252,1],[253,1],[248|f,1],[248|f,1],[0,2],[15,1],[3,1]),p(32,o),p(33,s),p(34,c)),h=[``,`A`,`B`,`C`][u[0]>>6],g=0,_=(u[1]<<24|u[2]<<16|u[3]<<8|u[4])>>>0;for(let e=0;e<32;e++)_&1<>>0).toString(16),`${u[0]&32?`H`:`L`}${u[11]}`,...v.map(e=>e.toString(16))].join(`.`);return{init:Fi({handler:`vide`,timescale:9e4,sampleEntry:a(`hvc1`,m),width:n.w,height:n.h}),mime:`video/mp4; codecs="${y}"`}}function Ui(e,t,n,r,i,a){return Ii(e,t,n,Li(r,i),a)}function Wi(e,t){let n=j(`dOps`,M([0,1],[e,1],[312,2],[t,4],[0,2],[0,1]));return Fi({handler:`soun`,timescale:48e3,sampleEntry:j(`Opus`,new Uint8Array(6),M([1,2],[0,8],[e,2],[16,2],[0,4],[3145728e3,4]),n)})}function Gi(e){if(!e.length)return 960;let t=e[0]>>3,n=t<12?[480,960,1920,2880][t%4]:t<16?[480,960][t%2]:[120,240,480,960][t%4],r=e[0]&3,i=r===0?1:r===3?(e[1]??1)&63:2;return n*Math.max(1,i)}function Ki(e,t,n){return Ii(e,t,Gi(n),n,!0)}var qi={watch:30,player:4},Ji={watch:{seek:.5,speed:1/0,target:.05},player:{seek:.15,speed:.06,target:.02}},Yi={seek:.8,speed:.25,target:.12};function Xi(e,t,n){let r=typeof n==`string`?Ji[n]:n;return e>r.seek?{seekTo:t-r.target,rate:1}:e>r.speed?{seekTo:null,rate:1.1}:{seekTo:null,rate:1}}function Zi(e,t=`watch`,n){return typeof VideoDecoder<`u`?new ca(e,t,n):new ba(e,t,n)}var Qi=class{constructor(e,t=()=>performance.now()){this.ask=e,this.now=t,this.last=-1/0}waiting(){if(!this.ask)return;let e=this.now();e-this.last<1e3||(this.last=e,this.ask())}};function $i(e){return e.length<3?null:{index:e[0]<<8|e[1],packet:e.subarray(2)}}var ea=class{constructor(){this.last=-1}take(e){if(this.last>=0){let t=e-this.last&65535;if(t===0||t>=32768)return!1}return this.last=e,!0}reset(){this.last=-1}};function ta(e){if(e.length>=10)return e;let t=new Uint8Array(10);t.set(e.subarray(0,6));let n=new DataView(t.buffer);return n.setUint32(6,Math.round(n.getUint32(2)/100)||480),t}function na(e,t){return{snd:e,snd_decoded:t.decoded,snd_concealed:t.concealed,snd_underruns:t.underruns,snd_dropped:t.dropped}}var ra=class{constructor(e,t=.2){this.min=e,this.max=t,this.next=0,this.calmSince=0,this.minLead=1/0,this.windowAt=0,this.underruns=0,this.dropped=0,this.cushion=e}at(e,t){this.next0&&(this.underruns++,this.cushion=Math.min(this.max,this.cushion+.02)),this.calmSince=e,this.next=e+this.cushion,this.minLead=1/0,this.windowAt=e):e-this.calmSince>10&&this.cushion>this.min&&(this.cushion=Math.max(this.min,this.cushion-.01),this.calmSince=e);let n=this.next-e;if(n>this.cushion+.15)return this.dropped++,null;if(this.minLead=Math.min(this.minLead,n),e-this.windowAt>=.25){let t=this.minLead>this.cushion+ia;if(this.minLead=1/0,this.windowAt=e,t)return this.dropped++,null}let r=this.next;return this.next+=t,r}reset(){this.next=0}},ia=.02;async function aa(e,t){try{return typeof AudioDecoder>`u`?!1:!!(await AudioDecoder.isConfigSupported({codec:`opus`,sampleRate:e,numberOfChannels:t})).supported}catch{return!1}}var oa=class{constructor(e,t=()=>performance.now()){this.decoder=e,this.now=t,this.n={frames:0,dropped:0,late:0,stalls:0,stall_ms:0,worst_stall_ms:0,key_waits:0},this.a=0,this.d=0,this.w=!1,this.q=[],this.sum=0,this.cnt=0,this.codec=``}get frames(){return this.n.frames}arrived(){let e=this.now();this.a&&e-this.a>50&&this.n.late++,this.a=e}drop(){this.n.dropped++,this.w||this.n.key_waits++,this.w=!0}decoding(){this.w=!1,this.q.push(this.now())>64&&this.q.shift()}drawn(e=!1){let t=this.now(),n=e?this.q.shift():void 0;n!==void 0&&(this.sum+=t-n,this.cnt++);let r=this.d?t-this.d:0;r>100&&this.stall(r),this.d=t,this.n.frames++}stall(e){this.n.stalls++,this.n.stall_ms+=e,this.n.worst_stall_ms=Math.max(this.n.worst_stall_ms,e)}snapshot(){let e=this.d?this.now()-this.d:0,t={...this.n,decoder:this.decoder};this.codec&&(t.codec=this.codec),e>100&&(t.stalls=this.n.stalls+1,t.stall_ms=this.n.stall_ms+e,t.worst_stall_ms=Math.max(this.n.worst_stall_ms,e));for(let e of[`stall_ms`,`worst_stall_ms`])t[e]=Math.round(t[e]);return t.decode_ms=this.cnt?Math.round(this.sum/this.cnt*10)/10:0,this.sum=this.cnt=0,t}},sa=[`pointerup`,`touchend`,`click`,`keydown`],ca=class{get element(){if(!this.wrap){let e=document.createElement(`div`);e.className=`h-full w-full`,e.append(this.canvas),this.mse&&e.append(this.mse.element),this.wrap=e}return this.wrap}get stats(){return this.mse?.stats??this.ownStats}soundReport(){return this.soundOn?this.mseSound?this.mseSound.report():na(this.soundWasm?`wasm`:`webcodecs`,this.soundStats):null}constructor(e,t=`watch`,n){this.onProblem=e,this.latency=t,this.onNeedKey=n,this.canvas=document.createElement(`canvas`),this.wrap=null,this.mse=null,this.failsNoPicture=0,this.ctx=this.canvas.getContext(`2d`,{alpha:!1}),this.hevc=!1,this.header=null,this.spsRect=null,this.software=!1,this.video=null,this.opening=!1,this.sawKey=!1,this.ownStats=new oa(`webcodecs`),this.problemShown=!1,this.ts=0,this.pipe=null,this.audioGen=0,this.actx=null,this.soundOn=!1,this.unarm=null,this.mseSound=null,this.audioHeader=null,this.soundWasm=!1,this.onSoundFail=null,this.muted=!1,this.keyAsk=new Qi(n),this.clock=new ra(t===`player`?.05:.08),typeof AudioDecoder>`u`&&N()&&(this.mseSound=new P(t,()=>this.mseSoundFailed())),this.canvas.className=`block h-full w-full object-contain`,this.canvas.dataset.testid=`watch-canvas`}setHevc(e){this.hevc=e,this.header&&(this.spsRect=qr(this.header,e)),this.mse?.setHevc(e)}get onMse(){return!!this.mse}decodeFailed(){if(this.mse||this.ownStats.frames>0||++this.failsNoPicture<3||!fa())return!1;let e=new ba(this.onProblem,this.latency,this.onNeedKey);e.setHevc(this.hevc),e.markProblemShown(),this.mse=e;let t=this.video;this.video=null;try{t?.close()}catch{}return this.canvas.style&&(this.canvas.style.display=`none`),this.wrap?.append(e.element),this.header&&e.onMessage(new Uint8Array([0,...this.header]).buffer),this.onNeedKey?.(),!0}startSound(){this.soundOn=!0,la(),this.mseSound?this.mseSound.start():this.openContext()}openContext(){try{if(!this.actx){let e=new AudioContext({latencyHint:`interactive`});this.actx=e,e.onstatechange=()=>{this.actx===e&&e.state!==`running`&&e.state!==`closed`&&this.armResume()}}this.actx.resume().catch(()=>{})}catch{this.onSoundFail?.()}}get sound(){return this.soundOn}setMuted(e){this.muted=e,this.mseSound?.setMuted(e)}resumeSound(){if(!this.soundOn)return;if(this.mseSound)return this.mseSound.resume();let e=this.actx;e&&e.state!==`running`&&e.state!==`closed`&&(this.clock.reset(),e.resume().catch(()=>{}),this.armResume())}get soundStats(){return{decoded:this.pipe?.decoded??0,concealed:this.pipe?.concealed??0,underruns:this.clock.underruns,dropped:this.clock.dropped,cushionMs:Math.round(this.clock.cushion*1e3)}}armResume(){if(this.unarm||typeof window>`u`||!window.addEventListener)return;let e=()=>{let e=this.actx;if(!e||e.state===`closed`)return this.unarm?.();this.clock.reset(),e.resume().then(()=>{e.state===`running`&&this.unarm?.()}).catch(()=>{})};for(let t of sa)window.addEventListener(t,e,!0);this.unarm=()=>{for(let t of sa)window.removeEventListener(t,e,!0);this.unarm=null}}onMessage(e){let t=new Uint8Array(e);if(t.length<1)return;let n=t[0],r=t.subarray(1);if(this.mse&&(n===0||n===1))return n===0&&(this.header=r.slice()),this.mse.onMessage(e);n===0?this.openVideo(r.slice()):n===1?this.onVideo(r):n===3?this.openAudio(r.slice()):n===4&&this.onAudio(r)}async openVideo(e){if(this.header=e,this.spsRect=qr(e,this.hevc),!this.opening){this.opening=!0;try{let t=this.hevc?await xa(e):Oi(e);if(this.mse)return;if(!t){this.problemShown=!0,this.onProblem(`no_hevc`);return}this.ownStats.codec=t;let n=this.hevc?void 0:Vi(e)??void 0;try{this.video?.close()}catch{}let r=new VideoDecoder({output:e=>{let t=this.realVisible(e),n=this.canvas;(n.width!==t.displayWidth||n.height!==t.displayHeight)&&(n.width=t.displayWidth,n.height=t.displayHeight),this.ctx?.drawImage(t,0,0,n.width,n.height),this.ownStats.drawn(!0),t.close(),this.problemShown&&(this.problemShown=!1,this.onProblem(null))},error:()=>{this.video===r&&(this.problemShown=!0,this.onProblem(`decode`),this.decodeFailed()||this.rebuild())}}),i={codec:t,optimizeForLatency:!0};n&&(i.description=n),this.software&&(i.hardwareAcceleration=`prefer-software`),r.configure(i),this.video=r,this.sawKey=!1}catch{this.problemShown=!0,this.onProblem(`decode`),this.decodeFailed()}finally{this.opening=!1}}}realVisible(e){let t=this.spsRect,n=Jr(e,t);if(n)try{let t=new VideoFrame(e,{visibleRect:{x:n.x,y:n.y,width:n.w,height:n.h},displayWidth:n.w,displayHeight:n.h});return e.close(),t}catch{return e}let r=e.visibleRect;if(t&&r&&!this.software&&(r.width{if(this.video===e){try{e?.close()}catch{}this.rebuild(),this.onNeedKey?.()}})}return e}rebuild(){this.mse||(this.video=null,this.sawKey=!1,this.header&&this.openVideo(this.header).then(()=>this.keyAsk.waiting()))}onVideo(e){let t=this.video;if(t?.state===`closed`){this.opening||this.rebuild();return}if(!t||t.state!==`configured`)return;let n=Di(e,this.hevc);if(this.ownStats.arrived(),!this.sawKey&&!n)return this.ownStats.drop(),this.keyAsk.waiting();if(!n&&t.decodeQueueSize>qi[this.latency])return this.sawKey=!1,this.ownStats.drop(),this.keyAsk.waiting();this.sawKey=!0;let r=e;this.hevc?n&&this.header&&(r=new Uint8Array(this.header.length+e.length),r.set(this.header,0),r.set(e,this.header.length)):r=Li(e,!1,!0),this.ts+=16667,this.ownStats.decoding(),t.decode(new EncodedVideoChunk({type:n?`key`:`delta`,timestamp:this.ts,data:r}))}openAudio(e){if(e.length<6)return;let t=++this.audioGen;if(this.pipe?.reset(),this.pipe=null,this.clock.reset(),this.audioHeader=e,this.mseSound)return this.mseSound.setHeader(e);let n=e[0];aa(new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2),n).then(n=>{if(t!==this.audioGen)return;if(!n)return N()?this.soundThroughMse(e):this.soundThroughWasm(e);let r=new Qr((e,t)=>this.play(e,t,r.sampleRate));try{r.header(ta(e)),this.pipe=r}catch{this.soundThroughMse(e)}})}soundThroughMse(e){this.pipe=null,this.mseSound||(this.mseSound=new P(this.latency,()=>this.mseSoundFailed()),this.soundOn&&this.mseSound.start()),this.mseSound.setHeader(e)}soundThroughWasm(e){this.pipe?.reset(),this.soundWasm=!0;let t=new Qr((e,n)=>this.play(e,n,t.sampleRate),Ei,()=>{this.pipe===t&&(this.pipe=null),this.onSoundFail?.()});this.pipe=t,t.header(ta(e))}mseSoundFailed(){let e=this.mseSound;e&&(this.mseSound=null,e.stop(),this.soundOn&&(this.openContext(),this.actx&&this.actx.state!==`running`&&this.armResume()),this.audioHeader&&this.soundThroughWasm(this.audioHeader))}onAudio(e){if(this.mseSound)return this.mseSound.frame(e);this.soundOn&&this.pipe&&this.pipe.packet(e)}play(e,t,n){let r=this.actx;if(!r||r.state!==`running`||!e.length)return;let i=e[0].length,a=this.clock.at(r.currentTime,i/n);if(a===null)return;let o=r.createBuffer(e.length,i,n),s=this.muted?0:t;e.forEach((e,t)=>o.copyToChannel(s===1?e:e.map(e=>e*s),t));let c=r.createBufferSource();c.buffer=o,c.connect(r.destination),c.start(a)}stop(){try{this.video?.close()}catch{}this.mse?.stop(),this.audioGen++,this.pipe?.reset(),this.pipe=null,this.unarm?.(),this.actx?.close().catch(()=>{}),this.mseSound?.stop()}};function la(){try{let e=navigator.audioSession;e&&e.type!==`playback`&&(e.type=`playback`)}catch{}}function ua(e,t){try{return e.isTypeSupported(t)}catch{return!1}}function N(){let e=typeof window>`u`?null:fa();return!!e&&(ua(e,`audio/mp4; codecs="Opus"`)||ua(e,`audio/mp4; codecs="opus"`))}var P=class{constructor(e,t,n=document.createElement(`audio`)){this.onFail=t,this.header=null,this.time=0,this.on=!1,this.failed=!1,this.order=new ea,this.el=n,this.track=new ga(n,()=>this.fail(),e===`player`?Yi:e)}get playing(){return this.on&&!this.failed}report(){return{snd:`mse`,snd_jumps:this.track.seeks}}setHeader(e){this.header=e,this.on&&this.open()}start(){if(!this.on&&(this.on=!0,this.header&&this.open(),!this.failed))try{this.el.play()?.catch?.(()=>{})}catch{}}frame(e){if(!this.on||this.failed||!this.track.ready&&!this.track.backlog)return;let t=$i(e);if(!t||!this.order.take(t.index))return;let n=Ki(this.track.nextSeq(),this.time,t.packet);this.time+=Gi(t.packet),this.track.push(n)}setMuted(e){this.el.muted=e}resume(){if(this.playing&&this.el.paused)try{this.el.play()?.catch?.(()=>{})}catch{}}stop(){this.on=!1,this.track.close()}open(){let e=this.header;if(!e||e.length<6||this.failed)return;let t=e[0],n=Wi(t,new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(2));this.track.open(`audio/mp4; codecs="Opus"`,n)||this.track.open(`audio/mp4; codecs="opus"`,n)?(this.time=0,this.order.reset()):this.fail()}fail(){this.failed||(this.failed=!0,this.onFail())}},da=class{constructor(e,t,n=Ei){this.onFail=t,this.codecs=n,this.actx=null,this.pipe=null,this.header=null,this.on=!1,this.failed=!1,this.muted=!1,this.unarm=null,this.played=!1,this.clock=new ra(e===`player`?.05:.08)}get playing(){return this.on&&!this.failed}get stats(){return{decoded:this.pipe?.decoded??0,concealed:this.pipe?.concealed??0,underruns:this.clock.underruns,dropped:this.clock.dropped}}start(){if(!this.failed){this.on=!0,la();try{if(!this.actx){let e=new AudioContext({latencyHint:`interactive`});this.actx=e,e.onstatechange=()=>{this.actx===e&&e.state!==`running`&&e.state!==`closed`&&this.armResume()}}this.actx.resume().catch(()=>{}),this.actx.state!==`running`&&this.armResume()}catch{return this.fail()}this.header&&!this.pipe&&this.open()}}setHeader(e){e.length<6||(this.header=e,this.pipe?.reset(),this.pipe=null,this.clock.reset(),this.on&&this.open())}frame(e){this.on&&!this.failed&&this.pipe?.packet(e)}setMuted(e){this.muted=e}resume(){let e=this.actx;this.playing&&e&&e.state!==`running`&&e.state!==`closed`&&(this.clock.reset(),e.resume().catch(()=>{}),this.armResume())}stop(){this.on=!1,this.pipe?.reset(),this.pipe=null,this.unarm?.(),this.actx?.close().catch(()=>{}),this.actx=null}open(){let e=this.header;if(!e||this.failed)return;let t=new Qr((e,n)=>this.play(e,n,t.sampleRate),this.codecs,()=>{this.pipe===t&&this.fail()});this.pipe=t,t.header(ta(e))}play(e,t,n){let r=this.actx;if(!r||r.state!==`running`||!e.length)return;let i=e[0].length,a=this.clock.at(r.currentTime,i/n);if(a===null)return;let o=r.createBuffer(e.length,i,n),s=this.muted?0:t;e.forEach((e,t)=>o.copyToChannel(s===1?e:e.map(e=>e*s),t));let c=r.createBufferSource();c.buffer=o,c.connect(r.destination),c.start(a),this.played=!0}armResume(){if(this.unarm||typeof window>`u`||!window.addEventListener)return;let e=()=>{let e=this.actx;if(!e||e.state===`closed`)return this.unarm?.();this.clock.reset(),e.resume().then(()=>{e.state===`running`&&this.unarm?.()}).catch(()=>{})};for(let t of sa)window.addEventListener(t,e,!0);this.unarm=()=>{for(let t of sa)window.removeEventListener(t,e,!0);this.unarm=null}}fail(){this.failed||(this.failed=!0,this.stop(),this.onFail())}};function fa(){let e=window;return e.ManagedMediaSource??e.MediaSource??null}var pa=10,ma=3;function ha(e,t,n,r=ma){let i=null;for(let a of e)a>t&&a<=n-r&&(i=a);return i}var ga=class{constructor(e,t,n=`watch`,r,i=()=>performance.now()){this.el=e,this.onError=t,this.latency=n,this.onNeedKey=r,this.now=i,this.ms=null,this.sb=null,this.queue=[],this.mime=``,this.seq=1,this.ready=!1,this.dropped=!1,this.keys=null,this.seeks=0,this.maxLagS=0,this.fromZero=0,this.trims=0,this.lastJump=null,this.trimAt=-1,this.trimFrom=-1,this.keyAt=-1,this.attached=null,r&&(this.keys=[])}setEdge(e){this.latency=e}markKey(e){this.keys?.push(e),this.keyAt=this.now()}open(e,t){let n=fa();if(!n||!ua(n,e))return!1;this.close();let r=new n;return this.ms=r,this.mime=e,this.queue=[t],this.seq=1,this.ready=!1,this.keys&&=[],r.addEventListener(`sourceopen`,()=>{if(this.ms===r)try{let e=r.addSourceBuffer(this.mime);e.mode=`segments`,e.addEventListener(`updateend`,()=>this.pump()),e.addEventListener(`error`,()=>this.onError()),this.sb=e,this.ready=!0,this.pump()}catch{this.onError()}}),`ManagedMediaSource`in window&&n===window.ManagedMediaSource&&(this.el.disableRemotePlayback=!0),this.attached=_a(this.el,r),!0}nextSeq(){return this.seq++}get backlog(){return this.queue.length}push(e){this.queue.push(e),this.pump()}pump(){let e=this.sb;if(!e||e.updating||!this.ready)return;let t=this.el;if(e.buffered.length){let n=e.buffered.end(e.buffered.length-1),r=e.buffered.start(0),i=n-t.currentTime,a=Xi(i,n,this.latency);if(a.seekTo!==null){this.seeks++,this.maxLagS=Math.max(this.maxLagS,i);let o=this.now(),s=e=>e<0?-1:Math.round(o-e);t.currentTime<.05&&r>1&&this.fromZero++,this.lastJump={at:t.currentTime,start:r,end:n,ranges:e.buffered.length,readyState:t.readyState,paused:t.paused,seeking:t.seeking,sinceTrimMs:s(this.trimAt),trimFrom:this.trimFrom,sinceKeyMs:s(this.keyAt)},t.currentTime=Math.max(r,a.seekTo)}if(t.playbackRate!==a.rate&&(t.playbackRate=a.rate),t.currentTime-r>pa&&this.trim(e,r))return}let n=this.queue.shift();if(n){try{e.appendBuffer(n)}catch{this.dropped=!0}t.paused&&t.play().catch(()=>{})}}trim(e,t){let n=this.el.currentTime,r=n-ma;if(this.keys){if(r=ha(this.keys,t,n),r===null)return(this.keys[this.keys.length-1]??-1/0)<=n-ma&&this.onNeedKey?.(),!1;let e=r;this.keys=this.keys.filter(t=>t>=e),r-=.001}try{return e.remove(t,r),this.trims++,this.trimAt=this.now(),this.trimFrom=n,!0}catch{return!1}}close(){this.ready=!1,this.sb=null,this.queue=[];let e=this.ms;if(this.ms=null,e&&e.readyState===`open`)try{e.endOfStream()}catch{}if(this.attached===`object`)try{this.el.srcObject=null}catch{}this.attached=null,this.el.src?.startsWith(`blob:`)&&URL.revokeObjectURL(this.el.src),this.el.removeAttribute(`src`)}};function _a(e,t){if(`srcObject`in e)try{return e.srcObject=t,`object`}catch{}return e.src=URL.createObjectURL(t),`url`}var va=1e4,ya=class{constructor(e=3,t=va,n=()=>performance.now()){this.max=e,this.windowMs=t,this.now=n,this.at=[]}fail(){let e=this.now();return this.at=this.at.filter(t=>e-t=this.max}clear(){this.at=[]}},ba=class{constructor(e,t=`watch`,n,r){this.onProblem=e,this.latency=t,this.wasm=null,this.audioHeader=null,this.muted=!1,this.gaveUp=!1,this.reopening=!1,this.failedWhileOpening=!1,this.wrap=document.createElement(`div`),this.hevc=!1,this.header=null,this.sawKey=!1,this.stats=new oa(`mse`),this.problemShown=!1,this.vTime=0,this.vLast=0,this.soundOn=!1,this.onSoundFail=null,this.onGiveUp=null,this.keyAsk=new Qi(n),this.fails=new ya(3,va,r);let i=document.createElement(`video`);i.muted=!0,i.autoplay=!0,i.playsInline=!0,i.className=`block h-full w-full object-contain`,i.dataset.testid=`watch-video`,this.audio=new P(t,()=>this.soundThroughWasm()),this.wrap.className=`h-full w-full`,this.wrap.append(i,this.audio.el),this.video=new ga(i,()=>this.showProblem(),t,()=>this.keyAsk.waiting()),i.addEventListener(`error`,()=>this.restartVideo()),i.addEventListener(`playing`,()=>{this.fails.clear(),this.problemShown&&(this.problemShown=!1,this.onProblem(null))})}markProblemShown(){this.problemShown=!0}showProblem(){this.problemShown||(this.problemShown=!0,this.onProblem(`decode`))}restartVideo(){if(this.gaveUp)return;if(this.reopening){this.failedWhileOpening=!0;return}if(this.showProblem(),this.fails.fail()){this.gaveUp=!0,this.video.close(),this.onGiveUp?.();return}let e=this.header;if(e){this.header=null,this.reopening=!0,this.failedWhileOpening=!1;try{this.openVideo(e)}finally{this.reopening=!1}this.sawKey=!1,this.keyAsk.waiting(),this.failedWhileOpening&&(this.failedWhileOpening=!1,this.restartVideo())}}get failed(){return this.gaveUp}setVideoEdge(e){this.video.setEdge(e)}get videoSeeks(){return{seeks:this.video.seeks,maxLagMs:Math.round(this.video.maxLagS*1e3),fromZero:this.video.fromZero,trims:this.video.trims,lastJump:this.video.lastJump}}get element(){return this.wrap}resume(){let e=this.video.el;e.paused&&e.play()?.catch?.(()=>{})}setHevc(e){this.hevc=e}startSound(){if(this.soundOn=!0,this.wasm)return this.wasm.start();if(!N())return this.soundThroughWasm();this.audio.start()}soundThroughWasm(){if(this.wasm)return;this.audio.stop();let e=new da(this.latency,()=>this.onSoundFail?.());this.wasm=e,e.setMuted(this.muted),this.audioHeader&&e.setHeader(this.audioHeader),this.soundOn&&e.start()}resumeSound(){this.soundOn&&(this.wasm?this.wasm.resume():this.audio.resume())}setMuted(e){this.muted=e,this.audio.setMuted(e),this.wasm?.setMuted(e)}soundReport(){return this.soundOn?this.wasm?na(`wasm`,this.wasm.stats):this.audio.report():null}get soundPlaying(){return this.wasm?this.wasm.played:this.audio.playing}get sound(){return this.soundOn}onMessage(e){let t=new Uint8Array(e);if(t.length<1)return;let n=t[0],r=t.subarray(1);n===0?this.openVideo(r.slice()):n===1?this.onVideo(r):n===3?(this.audioHeader=r.slice(),(this.wasm??this.audio).setHeader(this.audioHeader)):n===4&&(this.wasm??this.audio).frame(r)}openVideo(e){let t=!!this.header&&this.header.length===e.length&&this.header.every((t,n)=>t===e[n]);if(t&&this.video.ready)return;if(this.gaveUp){if(t)return;this.gaveUp=!1,this.fails.clear()}this.header=e;let n=qr(e,this.hevc)??{w:1920,h:1080},r=Hi(e,this.hevc,n);r&&(this.stats.codec=/codecs="([^"]+)"/.exec(r.mime)?.[1]??``,this.video.open(r.mime,r.init)?(this.sawKey=!1,this.vTime=0,this.vLast=0):(this.problemShown=!0,this.onProblem(this.hevc?`no_hevc`:`decode`)))}onVideo(e){if(!this.video.ready&&!this.video.backlog)return;let t=Di(e,this.hevc);if(this.video.dropped&&(this.video.dropped=!1,this.sawKey=!1),this.stats.arrived(),!this.sawKey&&!t)return this.stats.drop(),this.keyAsk.waiting();if(!t&&this.video.backlog>qi[this.latency])return this.sawKey=!1,this.stats.drop(),this.keyAsk.waiting();this.sawKey=!0,this.stats.drawn();let n=performance.now(),r=this.vLast?Math.min(9e3,Math.max(750,Math.round((n-this.vLast)*90))):1500;this.vLast=n,t&&this.video.markKey(this.vTime/9e4),this.video.push(Ui(this.video.nextSeq(),this.vTime,r,e,this.hevc,t)),this.vTime+=r}stop(){this.video.close(),this.audio.stop(),this.wasm?.stop()}};async function xa(e){let t=Yr(e);if(t&&typeof VideoDecoder<`u`)try{if((await VideoDecoder.isConfigSupported({codec:t,codedWidth:1920,codedHeight:1080})).supported)return t}catch{}return Ai(1920,1080)}var F={CROSS:1,CIRCLE:2,SQUARE:4,TRIANGLE:8,LEFT:16,RIGHT:32,UP:64,DOWN:128,L1:256,R1:512,L3:1024,R3:2048,OPTIONS:4096,SHARE:8192,TOUCHPAD:16384,PS:32768},Sa={buttons:0,l2:0,r2:0,lx:0,ly:0,rx:0,ry:0};function Ca(e,t){let n=e=>Math.max(0,Math.min(1,e));return[Math.round(n(e)*1919),Math.round(n(t)*941)]}F.UP,F.DOWN,F.LEFT,F.RIGHT,F.CROSS,F.CROSS,F.CIRCLE,F.CIRCLE,F.SQUARE,F.TRIANGLE,F.L1,F.R1,F.L3,F.R3,F.OPTIONS,F.SHARE,F.PS,F.TOUCHPAD,F.UP,F.DOWN,F.LEFT,F.RIGHT,F.CROSS,F.CIRCLE,F.SQUARE,F.TRIANGLE,F.L1,F.R1,F.L3,F.R3,F.OPTIONS,F.SHARE,F.PS,F.TOUCHPAD;var wa=e=>Math.max(-32768,Math.min(32767,Math.round(e))),Ta=[F.CROSS,F.CIRCLE,F.SQUARE,F.TRIANGLE,F.L1,F.R1,0,0,F.SHARE,F.OPTIONS,F.L3,F.R3,F.UP,F.DOWN,F.LEFT,F.RIGHT,F.PS,F.TOUCHPAD];function Ea(e){return Math.abs(e)<=1.01?Math.round((e+1)*3.5)%8:null}var Da=[0,1,1,1,0,-1,-1,-1],Oa=[-1,-1,0,1,1,1,0,-1];function ka(e,t){let n=e.axes[t.a]??0;if(t.hat){let e=Ea(n);return e===null?0:(t.hat===`x`?Da:Oa)[e]}return t.inv?-n:n}var Aa={buttons:Ta.flatMap((e,t)=>e?[[e,{b:t}]]:[]),l2:{b:6},r2:{b:7},lx:{a:0},ly:{a:1},rx:{a:2},ry:{a:3}};function ja(e,t,n=!1){if(`b`in t){let r=e.buttons[t.b];return r?n&&r.value>0?Math.min(1,r.value):Math.max(+!!r.pressed,r.value):0}if(`h`in t){let n=Ea(e.axes[t.h]??9);if(n===null)return 0;let r=(n-t.at+8)%8;return+(r===0||r===1||r===7)}let r=e.axes[t.a];if(r===void 0)return 0;let i=t.rest??0;return Math.min(1,Math.max(0,(r-i)/(t.d-i)))}function Ma(e){if(e.mapping===`standard`)return Aa;let t=Na.get(e.id);if(t)return t;let n=e.axes.findIndex(e=>Math.abs(e)>1.05);if(n<0)return Aa;let r={...Aa,buttons:[...Aa.buttons,[F.UP,{h:n,at:0}],[F.RIGHT,{h:n,at:2}],[F.DOWN,{h:n,at:4}],[F.LEFT,{h:n,at:6}]]};return Na.set(e.id,r),r}var Na=new Map;function Pa(e,t=Ma){let n={...Sa},r=e=>Math.abs(e)<.08?0:wa(e*32767),i=(e,t)=>Math.abs(t)>Math.abs(e)?t:e,a=(e,t)=>t?r(ka(e,t)):0;for(let r of e){if(!r||!r.connected)continue;let e=t(r);for(let[t,i]of e.buttons)ja(r,i)>.5&&(n.buttons|=t);e.l2&&(n.l2=Math.max(n.l2,Math.round(ja(r,e.l2,!0)*255))),e.r2&&(n.r2=Math.max(n.r2,Math.round(ja(r,e.r2,!0)*255))),n.lx=i(n.lx,a(r,e.lx)),n.ly=i(n.ly,a(r,e.ly)),n.rx=i(n.rx,a(r,e.rx)),n.ry=i(n.ry,a(r,e.ry))}return n}function Fa(e,t){return{buttons:e.buttons|t.buttons,l2:Math.max(e.l2,t.l2),r2:Math.max(e.r2,t.r2),lx:wa(e.lx+t.lx),ly:wa(e.ly+t.ly),rx:wa(e.rx+t.rx),ry:wa(e.ry+t.ry),touch:e.touch??t.touch??null,motion:e.motion??t.motion??null}}var I=e=>e.toLowerCase().padStart(4,`0`);function Ia(e){let t=/^(.*?)\s*\((?:[^()]*?\s)?Vendor:\s*([0-9a-f]{1,4})\s+Product:\s*([0-9a-f]{1,4})\s*\)\s*$/i.exec(e);if(t)return{vendor:I(t[2]),product:I(t[3]),name:t[1].trim()};let n=/^([0-9a-f]{1,4})-([0-9a-f]{1,4})-(.*)$/i.exec(e.trim());return n?{vendor:I(n[1]),product:I(n[2]),name:n[3].trim()}:null}function La(e=globalThis.navigator){let t=e?.userAgent??``;return/Android|iPhone|iPad|iPod/i.test(t)?null:/Macintosh|Mac OS X/i.test(t)?(e?.maxTouchPoints??0)>1?null:`m`:/Windows/i.test(t)?`w`:/Linux|CrOS|X11/i.test(t)?`l`:null}function Ra(e,t){if(!t)return null;let n=t===`l`?[`l`]:[`m`,`w`];for(let t of n){let n=Ge[`${t}${e.vendor}${e.product}`];if(n!==void 0)return We[n]??null}return null}var za={1:0,2:2,4:4,8:6};function Ba(e){let t=0,n=!1;for(let r of e){let e=/a(\d+)/.exec(r);e&&(t=Math.max(t,Number(e[1])+1)),r.startsWith(`h`)&&(n=!0)}return{n:t,hat:n}}function Va(e,t,n){let{n:r,hat:i}=Ba(t),a=Ta.length,o=e.axes.findIndex(e=>Math.abs(e)>1.05),s=e=>e;if(i&&o<0)return n===`l`&&e.axes.length>=r+2?{hat:-1,hatXY:r,axis:s}:null;if(!(i?o>r:n!==`l`&&e.axes.length>=r+2))return{hat:o,hatXY:-1,axis:s};if(r<=4)return{hat:o,hatXY:-1,axis:e=>[0,1,2,5][e]??e};let c=t[a+2]?.replace(`~`,``)===`a2`&&t[a+3]?.replace(`~`,``)===`a3`,l=[t[6],t[7]].every(e=>/^a[45]~?$/.test(e??``));return r===6&&c&&l?{hat:o,hatXY:-1,axis:e=>[0,1,2,5,3,4][e]??e}:{hat:o,hatXY:-1,axis:s}}function Ha(e,t){let n=/^b(\d+)$/.exec(e);if(n)return{b:Number(n[1])};if(n=/^([+-]?)a(\d+)(~?)$/.exec(e),n){let e=t.axis(Number(n[2]));return n[1]===`+`?{a:e,d:1}:n[1]===`-`?{a:e,d:-1}:n[3]?{a:e,d:-1,rest:1}:{a:e,d:1,rest:-1}}if(n=/^h0\.(\d)$/.exec(e),n){let e=za[n[1]];if(e===void 0)return null;if(t.hat>=0)return{h:t.hat,at:e};if(t.hatXY>=0)return e===0?{a:t.hatXY+1,d:-1}:e===4?{a:t.hatXY+1,d:1}:e===6?{a:t.hatXY,d:-1}:{a:t.hatXY,d:1}}return null}function Ua(e,t){let n=/^a(\d+)(~?)$/.exec(e);if(n)return n[2]?{a:t.axis(Number(n[1])),inv:!0}:{a:t.axis(Number(n[1]))};if(e===`hx`||e===`hy`){if(t.hat>=0)return{a:t.hat,hat:e===`hx`?`x`:`y`};if(t.hatXY>=0)return{a:t.hatXY+ +(e===`hy`)}}return null}function Wa(e,t,n){let r=e.split(`,`),i=Va(t,r,n);if(!i)return null;let a={buttons:[],l2:null,r2:null,lx:null,ly:null,rx:null,ry:null};for(let e=0;eArray.isArray(e)&&e.length===2&&typeof e[0]==`number`&&Ja(e[1]))&&[t.l2,t.r2,t.lx,t.ly,t.rx,t.ry].every(Ja)}function Xa(){try{let e=yt(qa),t=e?JSON.parse(e):null;return!t||typeof t!=`object`||Array.isArray(t)?{}:Object.fromEntries(Object.entries(t).filter(e=>Ya(e[1])))}catch{return{}}}function Za(e,t){let n=Xa();return t?n[e]=t:delete n[e],vt(qa,JSON.stringify(n)),Qa=n,n}var Qa=null;function $a(e){return Qa??=Xa(),Qa[e.id]??eo(Qa,e.id)??Ka(e)??Ma(e)}function eo(e,t){if(!t.endsWith(` (app)`))return null;let n=t.slice(0,-6).trim().toLowerCase();if(!n)return null;let r=Object.keys(e).filter(e=>{let t=e.trim().toLowerCase();return t===n||t.includes(n)}),i=r.find(e=>e.trim().toLowerCase()===n)??(r.length===1?r[0]:null);return i?(Qa=Za(t,e[i]),e[i]):null}[{kind:`button`,bit:F.CROSS,name:`✕`},{kind:`button`,bit:F.CIRCLE,name:`○`},{kind:`button`,bit:F.SQUARE,name:`□`},{kind:`button`,bit:F.TRIANGLE,name:`△`},{kind:`button`,bit:F.UP,name:`↑`},{kind:`button`,bit:F.DOWN,name:`↓`},{kind:`button`,bit:F.LEFT,name:`←`},{kind:`button`,bit:F.RIGHT,name:`→`},{kind:`button`,bit:F.L1,name:`L1`},{kind:`button`,bit:F.R1,name:`R1`},{kind:`trigger`,which:`l2`,name:`L2`},{kind:`trigger`,which:`r2`,name:`R2`},{kind:`button`,bit:F.L3,name:`L3`},{kind:`button`,bit:F.R3,name:`R3`},{kind:`button`,bit:F.OPTIONS,name:`Options`},{kind:`button`,bit:F.SHARE,name:`Create`},{kind:`button`,bit:F.PS,name:`PS`},{kind:`button`,bit:F.TOUCHPAD,name:`Touchpad`},{kind:`axis`,which:`lx`,name:`L →`},{kind:`axis`,which:`ly`,name:`L ↓`},{kind:`axis`,which:`rx`,name:`R →`},{kind:`axis`,which:`ry`,name:`R ↓`}].filter(e=>e.kind!==`button`||![F.L3,F.R3,F.OPTIONS,F.SHARE,F.PS,F.TOUCHPAD].includes(e.bit));var to=12e4;function no(e){let t;try{t=JSON.parse(e)}catch{return null}return Array.isArray(t.rumble)?{rumble:[Number(t.rumble[0])||0,Number(t.rumble[1])||0]}:Array.isArray(t.light)?{light:t.light}:t.stage===`asking`?{kind:`asking`}:t.stage===`refused`?{kind:`refused`,why:String(t.why??``)}:t.stage===`joined`?{kind:`joined`,host:t.session?.host??null,playing:!!t.session?.playing,passcode:!!t.session?.passcode}:null}function ro(e,t){return e.buttons===t.buttons&&e.l2===t.l2&&e.r2===t.r2&&e.lx===t.lx&&e.ly===t.ly&&e.rx===t.rx&&e.ry===t.ry&&(e.touch?.[0]??-1)===(t.touch?.[0]??-1)&&(e.touch?.[1]??-1)===(t.touch?.[1]??-1)&&(e.motion?.t??-1)===(t.motion?.t??-1)}var io=class{constructor(e){this.o=e,this.ws=null,this.last={...Sa},this.lastSent=0,this.raf=0,this.keepalive=null,this.watchdog=null,this.retry=null,this.done=!1,this.stage={kind:`connecting`},this.wasIn=!1,this.attempt=0,this.deadline=0,this.lastHeard=0,this.control=!1,this.neutral=!1,this.now=e.now??(()=>Date.now()),this.WS=e.WebSocketImpl??WebSocket}get currentStage(){return this.stage}setStage(e){this.stage=e,this.o.onStage(e)}start(){if(this.done=!1,this.setStage({kind:`connecting`}),this.connect(),this.done)return;let e=this.o.raf??(e=>window.requestAnimationFrame(e)),t=()=>{this.send(!1),this.raf=e(t)};this.raf=e(t),this.keepalive=setInterval(()=>this.send(!1),250),this.watchdog=setInterval(()=>this.checkSilence(),1e3)}connect(){let e;this.lastHeard=this.now();try{e=new this.WS(this.o.url)}catch{this.dropped();return}this.ws=e,e.binaryType=`arraybuffer`,this.control=!this.o.watch,this.o.watch&&this.o.watch.onControl(!1),e.onmessage=t=>{this.ws===e&&(this.lastHeard=this.now(),this.onMessage(t.data))},e.onclose=t=>{if(this.ws!==e)return;this.ws=null;let n=Le(t);n&&!this.wasIn?this.finish({kind:`refused`,why:`net:${n}`}):this.dropped()},e.onopen=()=>{this.ws===e&&(this.lastHeard=this.now(),this.o.hello&&e.send(JSON.stringify({hello:this.o.hello})),this.send(!0))}}onMessage(e){if(typeof e!=`string`){e instanceof ArrayBuffer&&this.o.watch?.onFrame(e);return}if(this.o.hello&&e.startsWith(`{"rt":`))try{let t=JSON.parse(e);if(typeof t.rt==`string`&&/^[0-9a-f]{32}$/.test(t.rt)){this.o.hello.rt=t.rt,this.o.onReconnectToken?.(t.rt);return}}catch{}if(e.includes(`"kbm_caps"`))try{let t=JSON.parse(e);if(t.kbm_caps){let e=t.kbm_caps;this.o.onKbmCaps?.({mouse:e.mouse===!0,keyboard:e.keyboard===!0,reason:typeof e.reason==`string`?e.reason:null});return}}catch{}if(this.o.watch)try{let t=JSON.parse(e);if(t.watch&&this.o.watch.onCodec(!!t.watch.hevc),typeof t.control==`boolean`){this.control=t.control,this.o.watch.onControl(t.control),t.control&&this.send(!0);return}}catch{}let t=no(e);if(t){if(`rumble`in t){let[e,n]=t.rumble;navigator.vibrate?.(e||n?250:0)}else if(`light`in t)this.o.onLight?.(t.light);else if(t.kind===`refused`)this.finish(t);else{if(t.kind===`joined`){let e=this.stage.kind!==`joined`;this.wasIn=!0,this.attempt=0,this.setStage(t),e&&this.send(!0);return}this.setStage(t)}}}dropped(){if(this.done)return;if(!this.wasIn||(this.stage.kind!==`reconnecting`&&(this.deadline=this.now()+to),this.now()>=this.deadline)){this.finish({kind:`lost`});return}let e=Re(this.attempt);this.setStage({kind:`reconnecting`,attempt:this.attempt}),this.attempt+=1,this.retry&&clearTimeout(this.retry),this.retry=setTimeout(()=>{this.retry=null,this.done||this.connect()},e)}checkSilence(){let e=this.ws;if(e&&!this.done&&(this.stage.kind===`joined`||this.stage.kind===`reconnecting`)&&!(this.now()-this.lastHeard<=3500)){this.ws=null;try{e.close()}catch{}this.dropped()}}wake(){this.stage.kind===`lost`&&this.wasIn?(this.attempt=0,this.start()):this.stage.kind===`reconnecting`&&(this.deadline=this.now()+to,this.attempt=0,this.retry&&(clearTimeout(this.retry),this.retry=null,this.connect()))}setNeutral(e){this.neutral!==e&&(this.neutral=e,this.send(!0))}current(){let e=Pa(Ue(typeof navigator>`u`?void 0:navigator),$a),t=this.o.touchPad();return{...Fa(e,t),touch:t.touch??null,motion:this.o.motion?.()??null}}send(e){let t=this.ws;if(!t||t.readyState!==this.WS.OPEN||!this.control)return;let n=this.neutral?{...Sa,touch:null,motion:null}:this.current(),r=this.now();!e&&ro(n,this.last)&&r-this.lastSent<250||(this.last=n,this.lastSent=r,t.send(JSON.stringify({pad:{...n,touch:n.touch??null,motion:n.motion??null},ka:1})))}askKeyframe(){let e=this.ws;e&&e.readyState===this.WS.OPEN&&e.send(JSON.stringify({keyframe:!0}))}sendKbm(e){let t=this.ws;return!t||t.readyState!==this.WS.OPEN||!this.control?!1:(t.send(e instanceof Uint8Array?e:JSON.stringify(e)),!0)}sendPad(){this.send(!1)}clearTimers(){(this.o.cancelRaf??(e=>window.cancelAnimationFrame(e)))(this.raf),this.keepalive&&clearInterval(this.keepalive),this.watchdog&&clearInterval(this.watchdog),this.retry&&clearTimeout(this.retry),this.keepalive=this.watchdog=this.retry=null}finish(e){this.done=!0,this.clearTimers();let t=this.ws;this.ws=null;try{t?.close()}catch{}this.setStage(e)}stop(){this.done=!0,this.clearTimers();let e=this.ws;this.ws=null,e&&e.readyState===this.WS.OPEN&&e.send(JSON.stringify({pad:{...Sa,touch:null}})),e?.close()}},ao=`ps5upload.pad.device`;function oo(e,t=e=>crypto.getRandomValues(e)){let n=e.get(ao);if(n&&/^[0-9a-f]{32}$/.test(n))return n;let r=new Uint8Array(16);t(r);let i=Array.from(r,e=>e.toString(16).padStart(2,`0`)).join(``);return e.set(ao,i),i}var so=new Set,co={held:new Set,touch:null,touchPad:Sa,mapping:!1,get paused(){return so.size>0},motion:null},lo={s:.85,m:1,l:1.15},uo=.25;function fo(e){return typeof e!=`number`||!Number.isFinite(e)?1:Math.min(1,Math.max(uo,e))}var po={overlay:{width:844,height:390},deck:{width:390,height:480}},mo=.7,ho=1.4;function go(e,t,n,r){let i=lo[e]??1;if(!(t>0)||!(n>0))return i;let a=r?po.deck:po.overlay,o=Math.min(ho,Math.max(mo,Math.min(t/a.width,n/a.height)));return Math.round(o*i*1e3)/1e3}var _o=34;function vo(e,t){return t>0&&8+Math.max(112*e,90)+156*e+124*e+Math.max(56*e,44)+_o>t}function yo(e,t,n){let r=e/32767,i=t/32767,a=Math.hypot(r,i),o=a>1?1/a:1;return{dx:r*o*n,dy:i*o*n}}var bo=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),L=s(((e,t)=>{t.exports=bo()}))(),xo=`calc(50% + (env(safe-area-inset-left) - env(safe-area-inset-right)) / 2)`,So=32767,Co=12;function wo({stream:e,layout:t=`overlay`,opacity:n=1,size:r=`m`,deckTop:i=`0px`,onMenu:a}){let o=Tn(),s=(0,T.useRef)(new Map),c=(0,T.useRef)({...Sa}),[l,u]=(0,T.useState)({...Sa}),[d,f]=(0,T.useState)({l:!1,r:!1,touchpad:!1}),p=(0,T.useRef)(null),[m,h]=(0,T.useState)({width:0,height:0});(0,T.useEffect)(()=>{let e=p.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect();h(e=>e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})};if(t(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t);let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]),(0,T.useEffect)(()=>()=>{co.touchPad={...Sa}},[]);let g=()=>{let t={...Sa,touch:null},n={l:!1,r:!1,touchpad:!1};for(let e of s.current.values())e.kind===`stick`&&(n[e.which]=!0),e.kind===`touchpad`&&(n.touchpad=!0),e.kind===`button`&&(t.buttons|=e.bit),e.kind===`trigger`&&(t[e.which]=255),e.kind===`touchpad`&&e.pressed&&(t.buttons|=F.TOUCHPAD);t.lx=c.current.lx,t.ly=c.current.ly,t.rx=c.current.rx,t.ry=c.current.ry,t.touch=c.current.touch??null,co.touchPad=t,e?.sendPad(),u(t),f(e=>e.l===n.l&&e.r===n.r&&e.touchpad===n.touchpad?e:n)},_=(e,t,n)=>{let r=Math.max(-1,Math.min(1,(t-e.cx)/e.radius)),i=Math.max(-1,Math.min(1,(n-e.cy)/e.radius));c.current[e.which===`l`?`lx`:`rx`]=Math.round(r*So),c.current[e.which===`l`?`ly`:`ry`]=Math.round(i*So)},v=(e,t)=>{e.preventDefault(),e.stopPropagation();let n=e.currentTarget;try{n.setPointerCapture(e.pointerId)}catch{}let r=t(n);s.current.set(e.pointerId,r),r.kind===`stick`&&_(r,e.clientX,e.clientY),r.kind===`touchpad`&&(c.current.touch=Ca((e.clientX-r.rect.left)/r.rect.width,(e.clientY-r.rect.top)/r.rect.height)),navigator.vibrate?.(8),g()},y=e=>{let t=s.current.get(e.pointerId);if(t){if(e.stopPropagation(),t.kind===`stick`)_(t,e.clientX,e.clientY);else if(t.kind===`touchpad`)c.current.touch=Ca((e.clientX-t.rect.left)/t.rect.width,(e.clientY-t.rect.top)/t.rect.height),t.pressed&&Math.hypot(e.clientX-t.x0,e.clientY-t.y0)>Co&&(t.pressed=!1);else return;g()}},b=e=>{let t=s.current.get(e.pointerId);t&&(e.stopPropagation(),s.current.delete(e.pointerId),t.kind===`stick`&&(c.current[t.which===`l`?`lx`:`rx`]=0,c.current[t.which===`l`?`ly`:`ry`]=0),t.kind===`touchpad`&&(c.current.touch=null),g())},x=e=>e.stopPropagation(),S={onPointerMove:y,onPointerUp:b,onPointerCancel:b,onClick:x,onDoubleClick:x},ee=e=>(l.buttons&e)!==0,te=e=>`border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.35)] transition-colors duration-75 ${e?`border-white bg-white/50`:`border-white/70 bg-white/10`}`,C=`text-white [text-shadow:0_1px_2px_rgba(0,0,0,0.6)]`,ne={filter:`drop-shadow(0 0 1.5px rgba(0,0,0,0.5))`},w=e=>({stroke:e?`#fff`:`rgba(255,255,255,0.75)`,fill:e?`rgba(255,255,255,0.5)`:`rgba(255,255,255,0.1)`}),re=`pointer-events-auto flex touch-none select-none items-center justify-center bg-transparent p-0`,ie={minHeight:`calc(44px / var(--k))`,minWidth:`calc(44px / var(--k))`},ae=(e,t,n,r)=>(0,L.jsx)(`button`,{type:`button`,"aria-label":e,onPointerDown:e=>v(e,()=>({kind:`button`,bit:t})),...S,className:`${re} ${n}`,style:ie,children:r}),oe=(e,t,n,r)=>(0,L.jsx)(`span`,{className:`flex h-[32px] w-[76px] items-center justify-center text-[13px] font-semibold tracking-wide ${C} ${te(t)}`,style:{borderRadius:r?n===`l`?`16px 9px 9px 9px`:`9px 16px 9px 9px`:`9px`},children:e}),se=(e,t,n,r)=>ae(e,t,`h-[44px] w-[84px]`,oe(e,ee(t),n,r)),ce=(e,t,n)=>(0,L.jsx)(`button`,{type:`button`,"aria-label":e,onPointerDown:e=>v(e,()=>({kind:`trigger`,which:t})),...S,className:`${re} h-[44px] w-[84px]`,style:ie,children:oe(e,l[t]>0,n,!0)}),le=(e,t,n)=>ae(e,t,`h-[52px] w-[52px]`,(0,L.jsx)(`svg`,{viewBox:`0 0 52 52`,width:`52`,height:`52`,"aria-hidden":!0,style:ne,children:(0,L.jsxs)(`g`,{transform:`rotate(${n} 26 26)`,strokeWidth:`1.5`,strokeLinejoin:`round`,...w(ee(t)),children:[(0,L.jsx)(`path`,{d:`M10 9 Q10 3 16 3 L36 3 Q42 3 42 9 L42 30 Q42 34.5 38.5 38 L29.5 47 Q26 50.5 22.5 47 L13.5 38 Q10 34.5 10 30 Z`}),(0,L.jsx)(`path`,{d:`M20.5 23 L26 17 L31.5 23`,fill:`none`,stroke:`#fff`,strokeLinecap:`round`,strokeWidth:`1.8`})]})})),ue=(e,t,n)=>ae(e,t,`h-[52px] w-[52px]`,(0,L.jsxs)(`svg`,{viewBox:`0 0 52 52`,width:`52`,height:`52`,"aria-hidden":!0,style:ne,children:[(0,L.jsx)(`circle`,{cx:`26`,cy:`26`,r:`22.5`,strokeWidth:`1.5`,...w(ee(t))}),(0,L.jsx)(`g`,{fill:`none`,stroke:`#fff`,strokeWidth:`1.8`,strokeLinejoin:`round`,strokeLinecap:`round`,children:n})]})),de=(e,t)=>ae(e,t,`h-[44px] min-w-[64px] px-[4px]`,(0,L.jsx)(`span`,{className:`flex h-[24px] items-center rounded-full px-[10px] text-[10px] font-semibold uppercase tracking-wider ${C} ${te(ee(t))}`,children:e})),fe=(e,t)=>ae(e,t,`h-[44px] w-[44px]`,(0,L.jsx)(`span`,{className:`flex h-[36px] w-[36px] items-center justify-center rounded-full text-[11px] font-bold ${C} ${te(ee(t))}`,children:e})),pe=e=>{let{dx:t,dy:n}=yo(e===`l`?l.lx:l.rx,e===`l`?l.ly:l.ry,34),r=d[e];return(0,L.jsx)(`div`,{"aria-label":e===`l`?o(`rp_touch_left_stick`,void 0,`Left stick`):o(`rp_touch_right_stick`,void 0,`Right stick`),onPointerDown:t=>v(t,t=>{let n=t.getBoundingClientRect();return{kind:`stick`,which:e,cx:n.left+n.width/2,cy:n.top+n.height/2,radius:n.width/2}}),...S,className:`pointer-events-auto relative h-[124px] w-[124px] touch-none rounded-full border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.3)] transition-colors duration-75 ${r?`border-white/80 bg-white/[0.12]`:`border-white/45 bg-white/[0.05]`}`,children:(0,L.jsx)(`div`,{className:`absolute left-1/2 top-1/2 h-[54px] w-[54px] rounded-full ${te(r)}`,style:{transform:`translate(calc(-50% + ${t}px), calc(-50% + ${n}px))`}})})},E=t===`deck`,me=go(r,m.width,m.height,E),he=e=>`${e}px * var(--k)`,ge=`max(12px, env(safe-area-inset-left))`,ve=`max(12px, env(safe-area-inset-right))`,ye=`max(12px, env(safe-area-inset-bottom))`,be=E?`8px`:t===`overlay-bar`?`3.5rem`:`max(10px, env(safe-area-inset-top))`,xe=(e,t,n=0)=>t?n?`calc(${e} + max(${he(t)}, ${n}px))`:`calc(${e} + ${he(t)})`:e,Se=(e,t)=>({position:`absolute`,...t,transform:`scale(var(--k))`,transformOrigin:e}),Ce=E&&vo(me,m.height),D=E?void 0:`58%`,O=e=>E?{top:xe(be,Ce?96:112,Ce?72:90),[e]:e===`left`?ge:ve}:{top:D,translate:`0 -50%`,[e]:e===`left`?ge:ve},we=e=>({bottom:Ce?ye:xe(ye,E?56:0,44),[e]:Ce?`calc(${e===`left`?ge:ve} + 8px + max(${he(80)}, 44px))`:xe(e===`left`?ge:ve,E?40:168)}),Te=!!a&&!E;return(0,L.jsxs)(`div`,{ref:p,className:`pointer-events-none absolute z-10 select-none [-webkit-touch-callout:none] ${E?`inset-x-0 bottom-0`:`inset-0`}`,style:{top:E?i:void 0,"--k":me},"data-testid":`rp-touch`,"data-layout":t,"data-scale":me,onContextMenu:e=>e.preventDefault(),children:[(0,L.jsxs)(`div`,{className:`absolute inset-0`,style:{opacity:fo(n)},children:[(0,L.jsx)(`div`,{style:Se(`top left`,{top:be,left:ge}),children:(0,L.jsxs)(`div`,{className:`ms-[8px] flex flex-col`,style:{rotate:E?void 0:`6deg`,transformOrigin:`top left`},children:[ce(`L2`,`l2`,`l`),se(`L1`,F.L1,`l`,!1)]})}),(0,L.jsx)(`div`,{style:Se(`top right`,{top:be,right:ve}),children:(0,L.jsxs)(`div`,{className:`me-[8px] flex flex-col items-end`,style:{rotate:E?void 0:`-6deg`,transformOrigin:`top right`},children:[ce(`R2`,`r2`,`r`),se(`R1`,F.R1,`r`,!1)]})}),(0,L.jsx)(`div`,{"aria-label":o(`rp_touch_touchpad`,void 0,`Touchpad`),onPointerDown:e=>v(e,t=>({kind:`touchpad`,rect:t.getBoundingClientRect(),x0:e.clientX,y0:e.clientY,pressed:!0})),...S,className:`pointer-events-auto absolute touch-none rounded-2xl border-[1.5px] shadow-[0_0_3px_rgba(0,0,0,0.3)] transition-colors duration-75 ${d.touchpad?`border-white/80 bg-white/25`:`border-white/40 bg-white/[0.05]`}`,style:E?{top:xe(be,6),left:xe(ge,104),right:xe(ve,104),height:`max(44px, calc(${he(64)}))`}:{top:be,left:`50%`,translate:`-50% 0`,width:`min(calc(${he(250)}), 34vw)`,height:`max(44px, calc(${he(56)}))`}}),(0,L.jsxs)(`div`,{className:`grid grid-cols-3 grid-rows-3`,style:Se(E?`top left`:`left center`,O(`left`)),children:[(0,L.jsx)(`span`,{}),le(`↑`,F.UP,0),(0,L.jsx)(`span`,{}),le(`←`,F.LEFT,-90),(0,L.jsx)(`span`,{}),le(`→`,F.RIGHT,90),(0,L.jsx)(`span`,{}),le(`↓`,F.DOWN,180),(0,L.jsx)(`span`,{})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-3 grid-rows-3`,style:Se(E?`top right`:`right center`,O(`right`)),children:[(0,L.jsx)(`span`,{}),ue(`△`,F.TRIANGLE,(0,L.jsx)(`path`,{d:`M26 16.5 L35 32 L17 32 Z`})),(0,L.jsx)(`span`,{}),ue(`□`,F.SQUARE,(0,L.jsx)(`rect`,{x:`18`,y:`18`,width:`16`,height:`16`,rx:`1`})),(0,L.jsx)(`span`,{}),ue(`○`,F.CIRCLE,(0,L.jsx)(`circle`,{cx:`26`,cy:`26`,r:`8.5`})),(0,L.jsx)(`span`,{}),ue(`✕`,F.CROSS,(0,L.jsx)(`path`,{d:`M19 19 L33 33 M33 19 L19 33`})),(0,L.jsx)(`span`,{})]}),(0,L.jsx)(`div`,{style:Se(`bottom left`,we(`left`)),children:pe(`l`)}),(0,L.jsx)(`div`,{style:Se(`bottom right`,we(`right`)),children:pe(`r`)}),(0,L.jsx)(`div`,{style:Se(`bottom left`,{bottom:ye,left:ge}),children:de(`Create`,F.SHARE)}),(0,L.jsx)(`div`,{style:Se(`bottom right`,{bottom:ye,right:ve}),children:de(`Options`,F.OPTIONS)}),(0,L.jsx)(`div`,{style:Se(`bottom center`,{bottom:Ce?xe(ye,124,88):xe(ye,Te?48:0,48),left:xo,translate:`-50% 0`}),children:fe(`PS`,F.PS)})]}),Te&&(0,L.jsx)(`div`,{style:{...Se(`bottom center`,{bottom:ye,left:`calc(50% + (env(safe-area-inset-left) - env(safe-area-inset-right)) / 2)`,translate:`-50% 0`}),opacity:Math.max(.7,fo(n))},children:(0,L.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a?.()},onDoubleClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),"aria-label":o(`rp_menu`,void 0,`Menu`),"aria-haspopup":`dialog`,className:`${re} h-[44px] w-[56px]`,style:ie,"data-testid":`rp-menu-handle`,children:(0,L.jsx)(`span`,{className:`flex h-[26px] w-[44px] items-center justify-center rounded-full ${C} ${te(!1)}`,children:(0,L.jsx)(_e,{size:15,strokeWidth:2,"aria-hidden":!0})})})})]})}var To=class{constructor(e,t=()=>1){this.sink=e,this.speed=t,this.fingers=new Map,this.most=0,this.moved=!1,this.gestureT0=0,this.lastTap=null,this.dragging=!1}down(e,t,n,r){if(!this.fingers.size){this.most=0,this.moved=!1,this.gestureT0=r;let e=this.lastTap;e&&r-e.t<=300&&Math.hypot(t-e.x,n-e.y)<=40&&(this.dragging=!0,this.sink.button(0,!0)),this.lastTap=null}this.fingers.set(e,{x:t,y:n,x0:t,y0:n,t0:r}),this.most=Math.max(this.most,this.fingers.size)}move(e,t,n){let r=this.fingers.get(e);if(!r)return;let i=t-r.x,a=n-r.y;if(r.x=t,r.y=n,!this.moved&&Math.hypot(t-r.x0,n-r.y0)>10&&(this.moved=!0),!this.moved)return;if(this.fingers.size>=2){if(this.dragging)return;let e=this.fingers.size;this.sink.scroll(-a/e,-i/e);return}if(this.most>=2)return;let o=this.speed();this.sink.move(i*o,a*o)}up(e,t){let n=this.fingers.get(e);if(!n||(this.fingers.delete(e),this.fingers.size))return;if(this.dragging){this.dragging=!1,this.sink.button(0,!1);return}let r=t-this.gestureT0<=250+(this.most>=2?150:0);if(this.moved||!r)return;let i=this.most>=2?2:0;this.sink.button(i,!0),this.sink.button(i,!1),i===0&&(this.lastTap={t,x:n.x,y:n.y})}cancel(){this.fingers.clear(),this.lastTap=null,this.dragging&&(this.dragging=!1,this.sink.button(0,!1))}},Eo={" ":`Space`,"-":`Minus`,"=":`Equal`,"[":`BracketLeft`,"]":`BracketRight`,"\\":`Backslash`,";":`Semicolon`,"'":`Quote`,"`":`Backquote`,",":`Comma`,".":`Period`,"/":`Slash`,"\n":`Enter`,"\r":`Enter`," ":`Tab`},Do={"!":`Digit1`,"@":`Digit2`,"#":`Digit3`,$:`Digit4`,"%":`Digit5`,"^":`Digit6`,"&":`Digit7`,"*":`Digit8`,"(":`Digit9`,")":`Digit0`,_:`Minus`,"+":`Equal`,"{":`BracketLeft`,"}":`BracketRight`,"|":`Backslash`,":":`Semicolon`,'"':`Quote`,"~":`Backquote`,"<":`Comma`,">":`Period`,"?":`Slash`};function Oo(e){return e.length===1?e>=`a`&&e<=`z`?{code:`Key${e.toUpperCase()}`,shift:!1}:e>=`A`&&e<=`Z`?{code:`Key${e}`,shift:!0}:e>=`0`&&e<=`9`?{code:`Digit${e}`,shift:!1}:Eo[e]?{code:Eo[e],shift:!1}:Do[e]?{code:Do[e],shift:!0}:null:null}var ko={Backspace:`Backspace`,Enter:`Enter`,Tab:`Tab`,Escape:`Escape`,Delete:`Delete`,ArrowUp:`ArrowUp`,ArrowDown:`ArrowDown`,ArrowLeft:`ArrowLeft`,ArrowRight:`ArrowRight`,Home:`Home`,End:`End`,PageUp:`PageUp`,PageDown:`PageDown`};function Ao(e){return ko[e]??null}function jo(e,t){let n=``;for(let r of t){let t=Oo(r);t?Mo(e,t.code,t.shift):n+=r}return n}function Mo(e,t,n=!1){let r=n&&!e.shiftHeld?.();r&&e.key(`ShiftLeft`,!0),e.key(t,!0),e.key(t,!1),r&&e.key(`ShiftLeft`,!1)}function No(e,t){let n=[...e],r=[...t],i=0;for(;i{o.current=e,s.current=t});let c=(0,T.useRef)(null),l=()=>c.current??=new To({move:(e,t)=>o.current?.move(e,t),button:(e,t)=>o.current?.button(e,t),scroll:(e,t)=>o.current?.scroll(e,t)},()=>s.current);(0,T.useEffect)(()=>()=>c.current?.cancel(),[]);let u=e=>e.stopPropagation();return(0,L.jsx)(`div`,{className:`touch-none select-none [-webkit-touch-callout:none] ${n}`,style:r,"data-testid":a,onPointerDown:e=>{u(e);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}l().down(e.pointerId,e.clientX,e.clientY,e.timeStamp)},onPointerMove:e=>{u(e),l().move(e.pointerId,e.clientX,e.clientY)},onPointerUp:e=>{u(e),l().up(e.pointerId,e.timeStamp)},onPointerCancel:e=>{u(e),l().cancel()},onClick:u,onDoubleClick:u,onContextMenu:e=>{e.preventDefault(),u(e)},children:i})}var R=` `,Fo=40;function Io({sink:e,onUntypeable:t,className:n=``}){let r=Tn(),i=(0,T.useRef)(null),a=(0,T.useRef)(R),o=(0,T.useRef)(!1),[s,c]=(0,T.useState)(!1),[l,u]=(0,T.useState)(!1);(0,T.useEffect)(()=>{if(!l)return;let e=window.setTimeout(()=>u(!1),3e3);return()=>window.clearTimeout(e)},[l]);let d=()=>{let e=i.current;e&&!o.current&&(!e.value.startsWith(R)||e.value.length>Fo)&&(e.value=R,a.current=R)},f=()=>{let n=i.current;if(!n||!e)return;let{deleted:r,inserted:o}=No(a.current,n.value);a.current=n.value;for(let t=0;te.stopPropagation(),onClick:e=>{e.stopPropagation();let t=i.current;t&&(s?t.blur():(t.value=R,a.current=R,t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length)))},className:`flex h-11 w-11 items-center justify-center rounded-full border border-white/25 bg-black/45 text-white backdrop-blur-sm disabled:opacity-40 ${s?`bg-white/30`:``} ${n}`,"data-testid":`rp-tp-keyboard`,children:(0,L.jsx)(he,{size:18,"aria-hidden":!0})}),(0,L.jsx)(`input`,{ref:i,type:`text`,defaultValue:R,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,enterKeyHint:`send`,"aria-label":r(`rp_tp_keyboard`,void 0,`Keyboard`),className:`pointer-events-none fixed bottom-0 left-1/2 h-px w-px opacity-0`,"data-testid":`rp-tp-keyboard-input`,"data-rp-typing":``,onFocus:()=>c(!0),onBlur:()=>c(!1),onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),onKeyDown:t=>{if(t.stopPropagation(),!e||t.nativeEvent.isComposing)return;let n=Ao(t.key);n&&(t.preventDefault(),Mo(e,n))},onKeyUp:e=>e.stopPropagation(),onCompositionStart:()=>{o.current=!0},onCompositionEnd:()=>{o.current=!1,f()},onInput:f}),l&&(0,L.jsx)(`div`,{className:`pointer-events-none fixed bottom-20 left-1/2 z-[300] w-max max-w-[min(22rem,calc(100%-2rem))] -translate-x-1/2 rounded-full bg-black/80 px-3 py-1.5 text-center text-xs text-white`,"data-testid":`rp-tp-untypeable`,children:r(`rp_tp_untypeable`,void 0,`Only English letters, numbers and symbols can be typed here. Use a text field on the PS5 for others.`)})]})}function Lo({mode:e,onChange:t,blocked:n,style:r,touchpadLabel:i,tight:a=!1,hidden:o=!1}){let s=Tn(),c=(r,i,o)=>{let s=r===`touchpad`&&!!n;return(0,L.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===r,"aria-disabled":s||void 0,"aria-label":a&&e!==r?o:void 0,title:s?n:o,onClick:e=>{e.stopPropagation(),s||t(r)},onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),className:`flex h-8 items-center gap-1 rounded-full px-2.5 text-xs ${e===r?`bg-white text-black`:`text-white`} ${s?`opacity-40`:``}`,"data-testid":`rp-touch-mode-${r}`,children:[i,(!a||e===r)&&(0,L.jsx)(`span`,{children:o})]})};return(0,L.jsxs)(`div`,{role:`radiogroup`,"aria-label":s(`rp_tp_mode`,void 0,`Touch controls`),"aria-hidden":o||void 0,className:`absolute left-1/2 z-30 flex -translate-x-1/2 gap-0.5 rounded-full border border-white/20 bg-black/50 p-0.5 backdrop-blur-sm transition-opacity duration-200 ${o?`pointer-events-none opacity-0`:`pointer-events-auto opacity-100`}`,style:r,"data-testid":`rp-touch-mode`,children:[c(`controller`,(0,L.jsx)(E,{size:14,"aria-hidden":!0}),s(`rp_kbm_controller`,void 0,`Controller`)),c(`touchpad`,(0,L.jsx)(ye,{size:14,"aria-hidden":!0}),i??s(`rp_tp_touchpad`,void 0,`Touchpad`))]})}var Ro={0:1,2:2,1:4,3:8,4:16},zo={ControlLeft:1,ShiftLeft:2,AltLeft:4,MetaLeft:8,OSLeft:8,ControlRight:16,ShiftRight:32,AltRight:64,MetaRight:128,OSRight:128};function Bo(){let e={};for(let t=0;t<26;t++)e[`Key${String.fromCharCode(65+t)}`]=4+t;for(let t=1;t<=9;t++)e[`Digit${t}`]=30+t-1;e.Digit0=39,Object.assign(e,{Enter:40,Escape:41,Backspace:42,Tab:43,Space:44,Minus:45,Equal:46,BracketLeft:47,BracketRight:48,Backslash:49,IntlHash:50,Semicolon:51,Quote:52,Backquote:53,Comma:54,Period:55,Slash:56,CapsLock:57,PrintScreen:70,ScrollLock:71,Pause:72,Insert:73,Home:74,PageUp:75,Delete:76,End:77,PageDown:78,ArrowRight:79,ArrowLeft:80,ArrowDown:81,ArrowUp:82,NumLock:83,NumpadDivide:84,NumpadMultiply:85,NumpadSubtract:86,NumpadAdd:87,NumpadEnter:88,NumpadDecimal:99,IntlBackslash:100,ContextMenu:101,NumpadEqual:103,IntlRo:135,KanaMode:136,IntlYen:137,Convert:138,NonConvert:139,Lang1:144,Lang2:145});for(let t=1;t<=9;t++)e[`Numpad${t}`]=89+t-1;e.Numpad0=98;for(let t=1;t<=12;t++)e[`F${t}`]=58+t-1;for(let t=13;t<=24;t++)e[`F${t}`]=104+t-13;return e}var Vo=Bo(),Ho=(e,t,n)=>Math.max(t,Math.min(n,Math.trunc(e)));function Uo(e,t=0,n=0,r=0,i=0){let a=new Uint8Array(17),o=new DataView(a.buffer);return a[0]=8,a[1]=e.buttons&255,a[2]=e.mods&255,o.setInt16(3,Ho(t,-32768,32767),!0),o.setInt16(5,Ho(n,-32768,32767),!0),o.setInt8(7,Ho(r,-128,127)),o.setInt8(8,Ho(i,-128,127)),e.keys.slice(0,8).forEach((e,t)=>a[9+t]=e&255),a}function Wo(e){let t={buttons:0,mods:0,keys:[]};for(let n of e){t.buttons|=n.buttons,t.mods|=n.mods;for(let e of n.keys)!t.keys.includes(e)&&t.keys.length<8&&t.keys.push(e)}return t}function z(e,t,n){let r=e+t/(n===1?3:n===2?1:100),i=Math.trunc(r);return{notches:-i,carry:r-i}}var B=class{constructor(e){this.st={buttons:0,mods:0,keys:[]},this.dx=0,this.dy=0,this.wheel=0,this.hwheel=0,this.wheelCarry=0,this.hwheelCarry=0,this.moveTimer=null,this.hb=null,this.want={mouse:!1,keyboard:!1},this.guests=new Map,this.d={setTimer:(e,t)=>window.setTimeout(e,t),clearTimer:e=>window.clearTimeout(e),setRepeat:(e,t)=>window.setInterval(e,t),clearRepeat:e=>window.clearInterval(e),...e}}get state(){return this.st}shiftHeld(){return(this.st.mods&(zo.ShiftLeft|zo.ShiftRight))!==0}get holding(){return this.st.buttons!==0||this.st.mods!==0||this.st.keys.length>0}setWant(e){let t=e.mouse||e.keyboard,n=e.mouse!==this.want.mouse||e.keyboard!==this.want.keyboard;this.want={...e},n&&(this.hb!==null&&this.d.clearRepeat(this.hb),this.hb=null,this.beat(),t&&(this.hb=this.d.setRepeat(()=>this.beat(),500)))}get wanted(){return this.want}beat(){let e=this.want.mouse||this.want.keyboard;this.d.send({kbm:e?{on:!0,mouse:this.want.mouse,keyboard:this.want.keyboard}:{on:!1}})}key(e,t){let n=zo[e];if(n){let e=t?this.st.mods|n:this.st.mods&~n;return e!==this.st.mods&&(this.st={...this.st,mods:e},this.flush()),!0}let r=Vo[e];if(!r)return!1;let i=this.st.keys.includes(r);return t&&!i&&this.st.keys.length<8?(this.st={...this.st,keys:[...this.st.keys,r]},this.flush()):!t&&i&&(this.st={...this.st,keys:this.st.keys.filter(e=>e!==r)},this.flush()),!0}button(e,t){let n=Ro[e];if(!n)return;let r=t?this.st.buttons|n:this.st.buttons&~n;r!==this.st.buttons&&(this.st={...this.st,buttons:r},this.flush())}guest(e,t){if(t)this.guests.set(e,{buttons:t.buttons,mods:t.mods,keys:t.keys.slice(0,8)});else if(!this.guests.delete(e))return;this.flush()}guestMotion(e,t,n,r){this.dx+=e,this.dy+=t,this.wheel+=n,this.hwheel+=r,(e||t||n||r)&&this.later()}get guestIds(){return[...this.guests.keys()]}move(e,t){this.dx+=e,this.dy+=t,this.later()}scroll(e,t,n){let r=z(this.wheelCarry,e,n),i=z(this.hwheelCarry,t,n);this.wheelCarry=r.carry,this.hwheelCarry=i.carry,this.wheel+=r.notches,this.hwheel-=i.notches,(this.wheel||this.hwheel)&&this.later()}later(){this.moveTimer===null&&(this.moveTimer=this.d.setTimer(()=>this.flush(),4))}flush(){this.moveTimer!==null&&this.d.clearTimer(this.moveTimer),this.moveTimer=null;let e=this.guests.size?Wo([this.st,...this.guests.values()]):this.st;do{let t=Ho(this.dx,-32768,32767),n=Ho(this.dy,-32768,32767),r=Ho(this.wheel,-128,127),i=Ho(this.hwheel,-128,127);this.dx-=t,this.dy-=n,this.wheel-=r,this.hwheel-=i,this.d.send(Uo(e,t,n,r,i))}while(Math.abs(this.dx)>=1||Math.abs(this.dy)>=1||this.wheel||this.hwheel)}releaseAll(){this.dx=this.dy=this.wheel=this.hwheel=0,this.wheelCarry=this.hwheelCarry=0;let e=this.holding;this.st={buttons:0,mods:0,keys:[]},this.moveTimer!==null&&this.d.clearTimer(this.moveTimer),this.moveTimer=null,e&&this.d.send(Uo(this.guests.size?Wo(this.guests.values()):this.st))}dispose(){this.guests.clear(),this.releaseAll(),this.setWant({mouse:!1,keyboard:!1})}},Go=`data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAYZbW9vdgAAAGxtdmhkAAAAAAAAAAAAAAAAAAAfQAAAfQAAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAmt0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAABAAAAAAAAfQAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAABAAAAAQAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAH0AAAAAAAABAAAAAAHjbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAABAAAABAABVxAAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAABjm1pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAU5zdGJsAAAAunN0c2QAAAAAAAAAAQAAAKphdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAABAAEABIAAAASAAAAAAAAAABFExhdmM2My4xLjEwMiBsaWJ4MjY0AAAAAAAAAAAAAAAAGP//AAAAMGF2Y0MBQsAK/+EAF2dCwAqmEXsBEAAAAwAQAAADACDxImEYAQAGaMhCAZSyAAAAEHBhc3AAAAABAAAAAQAAABRidHJ0AAAAAAAABUAAAAAAAAAAGHN0dHMAAAAAAAAAAQAAAAQAAEAAAAAAFHN0c3MAAAAAAAAAAQAAAAEAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAJHN0c3oAAAAAAAAAAAAAAAQAAAKCAAAACgAAAAoAAAAKAAAAIHN0Y28AAAAAAAAABAAABlwAAAj+AAAJKAAACVIAAALZdHJhawAAAFx0a2hkAAAAAwAAAAAAAAAAAAAAAgAAAAAAAH0AAAAAAAAAAAAAAAABAQAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAJGVkdHMAAAAcZWxzdAAAAAAAAAABAAB9AAAABAAAAQAAAAACUW1kaWEAAAAgbWRoZAAAAAAAAAAAAAAAAAAAH0AAAIEAVcQAAAAAAC1oZGxyAAAAAAAAAABzb3VuAAAAAAAAAAAAAAAAU291bmRIYW5kbGVyAAAAAfxtaW5mAAAAEHNtaGQAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAcBzdGJsAAAAfnN0c2QAAAAAAAAAAQAAAG5tcDRhAAAAAAAAAAEAAAAAAAAAAAABABAAAAAAH0AAAAAAADZlc2RzAAAAAAOAgIAlAAIABICAgBdAFQAAAAAAH0AAAAEcBYCAgAUViFblAAaAgIABAgAAABRidHJ0AAAAAAAAH0AAAAEcAAAAIHN0dHMAAAAAAAAAAgAAACAAAAQAAAAAAQAAAQAAAAAoc3RzYwAAAAAAAAACAAAAAQAAAAEAAAABAAAAAgAAAAgAAAABAAAAmHN0c3oAAAAAAAAAAAAAACEAAAATAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAkc3RjbwAAAAAAAAAFAAAGSQAACN4AAAkIAAAJMgAACVwAAAAac2dwZAEAAAByb2xsAAAAAgAAAAH//wAAABxzYmdwAAAAAHJvbGwAAAABAAAAIQAAAAEAAABhdWR0YQAAAFltZXRhAAAAAAAAACFoZGxyAAAAAAAAAABtZGlyYXBwbAAAAAAAAAAAAAAAACxpbHN0AAAAJKl0b28AAAAcZGF0YQAAAAEAAAAATGF2ZjYzLjEuMTAyAAAACGZyZWUAAAM7bWRhdNwATGF2YzYzLjEuMTAyAAIwQA4AAAJvBgX//2vcRem95tlIt5Ys2CDZI+7veDI2NCAtIGNvcmUgMTY1IHIzMjIyIGIzNTYwNWEgLSBILjI2NC9NUEVHLTQgQVZDIGNvZGVjIC0gQ29weWxlZnQgMjAwMy0yMDI1IC0gaHR0cDovL3d3dy52aWRlb2xhbi5vcmcveDI2NC5odG1sIC0gb3B0aW9uczogY2FiYWM9MCByZWY9MTYgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MToweDEzMSBtZT11bWggc3VibWU9MTAgcHN5PTEgcHN5X3JkPTEuMDA6MC4wMCBtaXhlZF9yZWY9MSBtZV9yYW5nZT0yNCBjaHJvbWFfbWU9MSB0cmVsbGlzPTIgOHg4ZGN0PTAgY3FtPTAgZGVhZHpvbmU9MjEsMTEgZmFzdF9wc2tpcD0xIGNocm9tYV9xcF9vZmZzZXQ9LTIgdGhyZWFkcz0xIGxvb2thaGVhZF90aHJlYWRzPTEgc2xpY2VkX3RocmVhZHM9MCBucj0wIGRlY2ltYXRlPTEgaW50ZXJsYWNlZD0wIGJsdXJheV9jb21wYXQ9MCBjb25zdHJhaW5lZF9pbnRyYT0wIGJmcmFtZXM9MCB3ZWlnaHRwPTAga2V5aW50PTQga2V5aW50X21pbj0xIHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NCByYz1jcmYgbWJ0cmVlPTEgY3JmPTUxLjAgcWNvbXA9MC42MCBxcG1pbj0wIHFwbWF4PTY5IHFwc3RlcD00IGlwX3JhdGlvPTEuNDAgYXE9MToxLjAwAIAAAAALZYiCAv5MUAAQv8ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmhwF/UABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmioBb1ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBwAAAAZBmjsBX1ABGCAHARggBwEYIAcBGCAHARggBwEYIAcBGCAHARggBw==`,Ko=null,qo=null;function Jo(e){e.play().catch(()=>{if(qo||Ko!==e)return;let t=()=>{Yo(),Ko===e&&e.play().catch(()=>{})};window.addEventListener(`pointerdown`,t,{capture:!0}),qo=()=>window.removeEventListener(`pointerdown`,t,{capture:!0})})}function Yo(){qo?.(),qo=null}function Xo(){if(typeof document<`u`){if(!Ko){let e=document.createElement(`video`);e.muted=!0,e.loop=!0,e.playsInline=!0,e.setAttribute(`playsinline`,``),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-testid`,`keep-screen-video`),e.style.cssText=`position:fixed;left:0;top:0;width:1px;height:1px;opacity:0;pointer-events:none`,e.src=Go,document.body.appendChild(e),Ko=e}Jo(Ko)}}function Zo(){Yo(),Ko&&=(Ko.pause(),Ko.removeAttribute(`src`),Ko.remove(),null)}function Qo(){return typeof navigator>`u`?null:navigator.wakeLock??null}function V(){return Te()||!gn()}var $o=new Set,es=null,ts=Promise.resolve(),ns=!1;async function rs(){if($o.size===0||es&&!es.released)return;let e=Qo();if(!e)Te()&&Xo();else try{let t=await e.request(`screen`);t.addEventListener(`release`,()=>{es===t&&(es=null)}),es=t}catch{}}async function is(){Zo();let e=es;if(es=null,e&&!e.released)try{await e.release()}catch{}}function as(){ns||typeof document>`u`||(ns=!0,document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&$o.size>0&&(ts=ts.then(rs))}))}function os(e,t){if(!V())return;as();let n=$o.size>0;t?$o.add(e):$o.delete(e);let r=$o.size>0;n!==r&&(ts=ts.then(r?rs:is))}var ss=new Set;function cs(){if(typeof window<`u`)return window.PS5UploadPad}function ls(e,t){let n=ss.size>0;t?ss.add(e):ss.delete(e);let r=ss.size>0;if(n!==r)try{cs()?.setActive(r)}catch{}}function us(e,t){let[n,r]=(0,T.useState)(!1);return(0,T.useEffect)(()=>{if(!e||!t)return;let n=!0;return Pe(e,je).then(e=>{n&&!e&&r(!0)}),()=>{n=!1}},[e,t]),n}function ds({href:e}){let t=Tn();return(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,"data-testid":`open-on-wifi`,children:[(0,L.jsx)(`p`,{className:`max-w-sm text-sm text-white/60`,children:t(`join_open_lan_body`,void 0,`Can't reach the internet? If you're on the same Wi-Fi as your friend, open the game there.`)}),(0,L.jsx)(`a`,{href:e,rel:`noreferrer`,className:`rounded-full bg-white px-4 py-2 text-sm font-medium text-black`,"data-testid":`open-on-wifi-link`,children:t(`join_open_lan`,void 0,`Open on this Wi-Fi`)})]})}function fs(e,t,n){switch(t.kind){case`connecting`:return e(`pad_connecting`,void 0,`Connecting…`);case`asking`:return e(`pad_asking`,{name:n},`Waiting for ${n} to allow this phone…`);case`joined`:return t.host?t.passcode&&!t.playing?e(`pad_wait_passcode`,{name:n},`Waiting for the passcode on ${n}`):t.playing?e(`pad_playing`,{host:t.host},`Controller for ${t.host}`):e(`pad_starting`,void 0,`Connected. The stream is starting…`):e(`pad_no_session`,void 0,`Connected. Waiting for Remote Play to start on the computer.`);case`refused`:return t.why===`denied`?e(`pad_denied`,void 0,`The computer said no.`):t.why===`no_answer`?e(`pad_no_answer`,void 0,`The computer didn't answer in time. Try again.`):t.why===`kicked`?e(`pad_kicked`,void 0,`The computer took this phone out of the game.`):t.why===`closed`?e(`pad_link_closed`,void 0,`The computer closed the link. Scan the new code to play again.`):t.why===`key`?e(`pad_old_code`,void 0,`This code has expired. Scan the new one on the computer.`):t.why===`full`?e(`pad_full`,void 0,`Four phones are playing already.`):t.why===`no_stream`?e(`pad_watch_no_stream`,void 0,`Nothing is streaming on the computer right now.`):t.why.startsWith(`net:`)?ps(e,t.why.slice(4)):e(`pad_refused`,void 0,`The computer did not let this phone in.`);case`reconnecting`:return e(`pad_reconnecting`,void 0,`Connection lost. Reconnecting…`);case`lost`:return e(`pad_lost`,void 0,`Lost the connection to the computer.`)}}function ps(e,t){switch(t){case`mismatch`:return e(`join_net_mismatch`,void 0,`This link doesn't match the host; ask them for a new one.`);case`no_direct`:return e(`join_net_no_direct`,void 0,`A direct connection isn't possible from this network (both sides' routers are strict). Try Wi-Fi instead of mobile data, or ask the host to turn on UPnP.`);case`no_room`:return e(`pad_old_code`,void 0,`This code has expired. Scan the new one on the computer.`);case`net_full`:return e(`pad_full`,void 0,`Four phones are playing already.`);case`no_hub`:return e(`join_net_no_hub`,void 0,`Couldn't reach the PS5Upload invite service. Check your internet connection, then try again.`);case`offer`:case`no_webrtc`:return e(`join_net_no_webrtc`,void 0,`This browser can't make direct connections. Try a recent Chrome, Safari or Firefox.`);default:return e(`pad_lost`,void 0,`Lost the connection to the computer.`)}}function ms(e){return e.kind!==`refused`||e.why!==`kicked`&&e.why!==`closed`}async function hs(){try{await document.documentElement.requestFullscreen?.({navigationUI:`hide`}),await screen.orientation.lock?.(`landscape`)}catch{}}function gs(e,t){return t?.mouse?null:t?.reason===`vinput_helper_old`||t?.reason===`helper_old`?e(`rp_kbm_helper_old`,void 0,`Update the PS5 helper to use a keyboard and mouse.`):t?.reason===`vinput_needs_loader`?e(`rp_kbm_needs_loader`,void 0,`Needs a payload loader on port 9021`):e(`rp_kbm_unavailable`,void 0,`Native keyboard & mouse isn't available on this console yet.`)}function _s({client:e,caps:t}){let n=Tn(),r=(0,T.useMemo)(()=>new B({send:t=>e.sendKbm(t)}),[e]);(0,T.useEffect)(()=>{r.setWant({mouse:!0,keyboard:t.keyboard})},[r,t.keyboard]),(0,T.useEffect)(()=>()=>r.dispose(),[r]);let i=(0,T.useMemo)(()=>({move:(e,t)=>r.move(e,t),button:(e,t)=>r.button(e,t),scroll:(e,t)=>r.scroll(e,t,0),key:(e,t)=>r.key(e,t),shiftHeld:()=>r.shiftHeld()}),[r]);return(0,L.jsxs)(Po,{sink:i,speed:1.5,className:`absolute inset-0 z-10`,testId:`pad-touchpad`,children:[(0,L.jsx)(`p`,{className:`pointer-events-none absolute inset-x-6 top-1/2 -translate-y-1/2 text-center text-xs leading-5 text-white/50`,children:n(`rp_tp_tips`,void 0,`Drag to move. Tap to click. Two fingers: tap to right-click, drag to scroll. Tap, then touch and drag to select.`)}),(0,L.jsx)(`div`,{className:`absolute`,style:{right:`max(12px, env(safe-area-inset-right))`,bottom:`max(12px, env(safe-area-inset-bottom))`},children:(0,L.jsx)(Io,{sink:t.keyboard?i:null})})]})}function vs({url:e,computer:t,onLeave:n,watch:r=!1,transport:i,hello:a,onReconnectToken:o,lanUrl:s=null}){let c=Tn(),l=us(i?e:null,s),u=t??c(`pad_net_computer`,void 0,`the computer`),[d,f]=(0,T.useState)({kind:`connecting`}),[p,m]=(0,T.useState)(0),[h,g]=(0,T.useState)(()=>typeof window<`u`&&window.innerHeight>window.innerWidth),[_,v]=(0,T.useState)(null),[y,b]=(0,T.useState)(null),[x,S]=(0,T.useState)(!1),ee=(0,T.useRef)(null),te=(0,T.useRef)(null),[C,ne]=(0,T.useState)(!r),[w,re]=(0,T.useState)(null),[ie,ae]=(0,T.useState)(!1),[oe,se]=(0,T.useState)(null),[ce,le]=(0,T.useState)(`controller`);(0,T.useEffect)(()=>(os(`pad-remote`,!0),ls(`pad-remote`,!0),()=>{os(`pad-remote`,!1),ls(`pad-remote`,!1)}),[]),(0,T.useEffect)(()=>{if(!x)return;let e=Ae(e=>{co.motion=e});return()=>{e(),co.motion=null}},[x]),(0,T.useEffect)(()=>{let t=r?Zi(re,`watch`,()=>n.askKeyframe()):null;ee.current=t,t&&te.current?.appendChild(t.element),ne(!r),ae(!1);let n=new io({url:e,WebSocketImpl:i,hello:a,onReconnectToken:o,onStage:f,touchPad:()=>co.touchPad,onLight:v,onKbmCaps:se,motion:()=>co.motion,watch:t?{onFrame:e=>t.onMessage(e),onCodec:e=>t.setHevc(e),onControl:ne}:void 0});b(n),n.start();let s=()=>{let e=document.visibilityState===`hidden`;n.setNeutral(e),e||n.wake()},c=()=>n.setNeutral(!0);return document.addEventListener(`visibilitychange`,s),window.addEventListener(`blur`,c),window.addEventListener(`focus`,s),()=>{document.removeEventListener(`visibilitychange`,s),window.removeEventListener(`blur`,c),window.removeEventListener(`focus`,s),n.stop(),t?.stop(),t?.element.remove()}},[e,p,r]),(0,T.useEffect)(()=>{let e=()=>g(window.innerHeight>window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let ue=d.kind===`refused`||d.kind===`lost`,de=d.kind===`joined`||d.kind===`reconnecting`,pe=!!s&&!de&&(l||d.kind===`refused`&&d.why===`net:no_hub`);return(0,L.jsxs)(`div`,{className:`fixed inset-0 select-none overflow-hidden bg-black text-white [-webkit-touch-callout:none]`,style:{touchAction:`none`},"data-testid":`pad-app`,children:[(0,L.jsxs)(`div`,{className:`absolute inset-x-0 top-0 z-20 flex items-center justify-center gap-2 px-3 pt-[max(6px,env(safe-area-inset-top))] text-xs text-white/80`,children:[(0,L.jsx)(`span`,{className:`inline-block h-2 w-2 shrink-0 rounded-full`,style:{background:d.kind===`joined`?_?`rgb(${_[0]},${_[1]},${_[2]})`:`var(--color-success,#22c55e)`:ue?`var(--color-bad,#ef4444)`:`#eab308`}}),(0,L.jsx)(`span`,{className:`truncate`,"data-testid":`pad-stage`,children:r&&d.kind===`joined`&&d.host&&(!d.passcode||d.playing)?C?c(`pad_watch_control`,void 0,`Watching, and you have the controller`):c(`pad_watch_watching`,{host:d.host},`Watching ${d.host}`):fs(c,d,u)}),de&&typeof document<`u`&&!!document.documentElement.requestFullscreen&&!document.fullscreenElement&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>void hs(),className:`flex items-center gap-1 rounded-full bg-white/15 px-2 py-1`,"data-testid":`pad-full`,children:[(0,L.jsx)(fe,{size:12}),c(`pad_fill`,void 0,`Full screen`)]}),de&&k()&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{x?S(!1):ke().then(S)},"aria-pressed":x,className:`rounded-full px-2 py-1 ${x?`bg-white text-black`:`bg-white/15`}`,"data-testid":`pad-motion`,children:c(`pad_motion`,void 0,`Motion`)}),n&&(0,L.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-full bg-white/15 px-2 py-1`,"data-testid":`pad-leave`,children:c(`pad_leave`,void 0,`Stop being a controller`)})]}),(0,L.jsx)(`div`,{ref:te,className:`absolute inset-0 z-0 flex items-center justify-center`,"aria-hidden":!0}),r&&de&&!ie&&(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{ee.current?.startSound(),ae(!0)},className:`absolute bottom-4 left-1/2 z-20 flex -translate-x-1/2 items-center gap-1.5 rounded-full bg-white/90 px-3 py-1.5 text-xs font-medium text-black`,"data-testid":`watch-sound`,children:[(0,L.jsx)(Ce,{size:14}),c(`pad_watch_sound`,void 0,`Sound`)]}),r&&w&&(0,L.jsx)(`p`,{className:`absolute inset-x-4 top-1/2 z-10 -translate-y-1/2 text-center text-sm text-white/85`,"data-testid":`watch-problem`,children:w===`no_hevc`?c(`pad_watch_no_hevc`,void 0,`This device can't play this stream's picture: the computer streams HEVC, and this device plays only H.264.`):c(`pad_watch_decode`,void 0,`The picture could not be played here.`)}),de&&C&&(ce===`touchpad`&&oe?.mouse&&y?(0,L.jsx)(_s,{client:y,caps:oe}):(0,L.jsx)(wo,{stream:y,layout:`overlay`})),de&&C&&(0,L.jsx)(Lo,{mode:ce===`touchpad`&&oe?.mouse?`touchpad`:`controller`,onChange:le,blocked:gs(c,oe),touchpadLabel:c(`pad_touchpad_tab`,void 0,`Touchpad & keyboard`),style:{top:`calc(max(6px, env(safe-area-inset-top)) + 2rem)`}}),de&&h&&(0,L.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-6 z-20 flex justify-center`,children:(0,L.jsxs)(`span`,{className:`flex items-center gap-2 rounded-full bg-black/70 px-3 py-1.5 text-xs text-white/85`,children:[(0,L.jsx)(xe,{size:14}),c(`pad_turn`,void 0,`Turn the phone sideways`)]})}),pe&&!ue&&s&&(0,L.jsx)(`div`,{className:`absolute inset-x-0 bottom-8 z-10 flex justify-center px-6`,children:(0,L.jsx)(ds,{href:s})}),ue&&(0,L.jsxs)(`div`,{className:`absolute inset-0 z-10 flex flex-col items-center justify-center gap-3 px-6 text-center text-sm`,children:[(0,L.jsx)(`p`,{className:`max-w-sm text-white/85`,children:fs(c,d,u)}),pe&&s&&(0,L.jsx)(ds,{href:s}),ms(d)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>m(e=>e+1),className:`rounded-full bg-white px-4 py-2 text-sm font-medium text-black`,"data-testid":`pad-retry`,children:c(`pad_retry`,void 0,`Try again`)})]})]})}var ys=`ps5upload.openIn`,bs=`ps5upload.openIn.tab`;function xs(){try{return sessionStorage.getItem(bs)===`browser`}catch{return!1}}function Ss(){try{sessionStorage.setItem(bs,`browser`)}catch{}}function Cs(e){return e===`browser`?`browser`:e===`app`?`opening`:`ask`}function ws({appLink:e,children:t}){let n=Tn(),[r,i]=(0,T.useState)(()=>xs()?`browser`:Cs(yt(ys))),[a,o]=(0,T.useState)(!1);if((0,T.useEffect)(()=>{r===`opening`&&yt(`ps5upload.openIn`)===`app`&&(location.href=e)},[]),r===`browser`)return(0,L.jsx)(L.Fragment,{children:t});let s=()=>{a&&vt(ys,`app`),i(`opening`),location.href=e},c=()=>{r===`ask`&&a?vt(ys,`browser`):r===`opening`&&yt(`ps5upload.openIn`)===`app`&&bt(ys),Ss(),i(`browser`)};return(0,L.jsx)(`div`,{className:`flex min-h-[100dvh] items-center justify-center bg-black px-6 text-white`,"data-testid":`open-in-gate`,children:(0,L.jsx)(`div`,{className:`w-full max-w-sm space-y-4 rounded-2xl border border-white/10 bg-neutral-900 p-6`,children:r===`ask`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`open_in_title`,void 0,`Open in the PS5Upload app?`)}),(0,L.jsx)(`p`,{className:`text-sm text-white/60`,children:n(`open_in_body`,void 0,`Have the PS5Upload app on this device? Open this there, or carry on in the browser.`)})]}),(0,L.jsx)(`button`,{type:`button`,onClick:s,className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black`,"data-testid":`open-in-app`,children:n(`open_in_app`,void 0,`Open in the app`)}),(0,L.jsx)(`button`,{type:`button`,onClick:c,className:`w-full rounded-full border border-white/20 py-2.5 text-sm font-semibold text-white hover:bg-white/10`,"data-testid":`open-in-browser`,children:n(`open_in_browser`,void 0,`Continue in browser`)}),(0,L.jsxs)(`label`,{className:`flex items-center justify-center gap-2 text-xs text-white/60`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),"data-testid":`open-in-remember`}),n(`open_in_remember`,void 0,`Remember my choice on this device`)]})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`open_in_opening`,void 0,`Opening the PS5Upload app…`)}),(0,L.jsx)(`p`,{className:`text-sm text-white/60`,children:n(`open_in_not_opened`,void 0,`Nothing happened? The app may not be on this device.`)})]}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>location.href=e,className:`w-full rounded-full bg-white py-2.5 text-sm font-semibold text-black`,"data-testid":`open-in-again`,children:n(`open_in_again`,void 0,`Try again`)}),(0,L.jsx)(`button`,{type:`button`,onClick:c,className:`w-full rounded-full border border-white/20 py-2.5 text-sm font-semibold text-white hover:bg-white/10`,"data-testid":`open-in-browser`,children:n(`open_in_browser`,void 0,`Continue in browser`)})]})})})}function Ts(e){return`ps5upload://pad?link=${encodeURIComponent(e)}`}function Es(e){let t=(e??``).trim().replace(/^\[|\]$/g,``).toLowerCase(),n=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(t);if(n){let e=n.slice(1).map(Number);if(e.some(e=>e>255))return null;let[t,r]=e;return t===10||t===172&&r>=16&&r<32||t===192&&r===168||t===169&&r===254||t===127?0:t===100&&r>=64&&r<128?1:2}if(!t.includes(`:`)||!/^[0-9a-f:.]+$/.test(t))return null;if(t.startsWith(`fd7a:115c:a1e0:`))return 1;let r=parseInt(t.split(`:`)[0]||`0`,16);return(r&65024)==64512||(r&65472)==65152||t===`::1`?0:2}function Ds(e,t){let n=Es(e),r=Es(t);return n===1||r===1?`tailscale`:r===0?`lan`:r===2?`internet`:null}function Os(e){let t=[];if(typeof e.forEach==`function`)e.forEach(e=>t.push(e));else for(let n of e)t.push(n);let n=new Map(t.map(e=>[String(e.id),e])),r=t.filter(e=>e.type===`candidate-pair`),i=t.filter(e=>e.type===`transport`&&typeof e.selectedCandidatePairId==`string`).map(e=>n.get(String(e.selectedCandidatePairId))).find(Boolean)??r.find(e=>e.selected===!0)??r.find(e=>e.nominated===!0&&e.state===`succeeded`);if(!i)return null;let a=e=>{let t=n.get(String(e));if(!t)return null;let r=t.address??t.ip;return typeof r==`string`?r:null};return Ds(a(i.localCandidateId),a(i.remoteCandidateId))}function ks(e){let t=e.replace(/:\d+$/,``).replace(/^\[|\]$/g,``);return`${t===`localhost`||t===`127.0.0.1`||t===`::1`?`ws`:`wss`}://${e}/ws`}function As(e){let t=new Set;for(let n of e.matchAll(/^a=fingerprint:sha-256[ \t]+([0-9A-Fa-f:]+)[ \t]*\r?$/gim))t.add(n[1].toUpperCase());return/^a=fingerprint:(?!sha-256[ \t])/im.test(e)?null:t.size===1?[...t][0]:null}function js(e,t){let n=As(e);return n!==null&&n===t.toUpperCase()}var Ms=16777216;function Ns(e){let t=16383,n=Math.max(1,Math.ceil(e.length/t)),r=[];for(let i=0;ithis.max)return this.parts=[],this.size=0,{kind:`error`,why:`too_big`};if(this.parts.push(r.slice()),this.size+=r.length,n===1)return{kind:`partial`};let i=new Uint8Array(this.size),a=0;for(let e of this.parts)i.set(e,a),a+=e.length;return this.parts=[],this.size=0,{kind:`message`,data:i.buffer}}};function Fs(e){let t=new Uint8Array(9);return t[0]=3,t.set(e.subarray(0,8),1),t}var Is=[`stun:stun.cloudflare.com:3478`,`stun:stun.l.google.com:19302`],Ls=1500,Rs=2e4;function zs(e){let t=e?.codecs??[],n=e=>t.filter(t=>t.mimeType.toLowerCase()===e);return[...n(`video/h264`),...n(`video/h265`),...n(`video/rtx`)]}var Bs=null;function Vs(e){e.onopen=e.onmessage=e.onclose=e.onerror=null;try{e.readyState===1&&e.send(JSON.stringify({t:`leave`})),e.close(1e3)}catch{}}function Hs(e,t){let n=Bs;return n?(Bs=null,n.timer&&clearTimeout(n.timer),n.url!==e||n.room!==t||n.ws.readyState>1||n.msgs.some(e=>e.t===`error`||e.t===`closed`)?(Vs(n.ws),null):{ws:n.ws,msgs:n.msgs}):null}function Us(e,t={}){var n;let r=t.WebSocketImpl??(typeof WebSocket>`u`?void 0:WebSocket),i=t.PeerConnection??(typeof RTCPeerConnection>`u`?void 0:RTCPeerConnection),a=t.iceTimeoutMs??15e3,o=t.log??(()=>{});class s{constructor(e){this.CONNECTING=0,this.OPEN=1,this.CLOSING=2,this.CLOSED=3,this.readyState=0,this.binaryType=`arraybuffer`,this.onopen=null,this.onmessage=null,this.onclose=null,this.onerror=null,this.hub=null,this.pc=null,this.dc=null,this.timer=null,this.rx=new Ps,this.answered=!1,this.early=[],this.hubBackUntil=0,this.offerSdp=null,this.offerSent=!1,this.ownEarly=[],this.media=null,setTimeout(()=>this.begin(),0)}begin(){if(this.readyState!==0)return;if(!i||!r){this.fail(`no_webrtc`);return}let n=t.signalUrl??ks(e.hub),a=t.signalUrl||t.lan?null:Hs(n,e.room),s;if(a)s=a.ws,o(`hub: joined early`);else try{s=new r(n)}catch{this.fail(`no_hub`);return}if(this.hub=s,this.prepare(),this.readyState===0){s.onopen=()=>s.send(JSON.stringify(t.lan?{v:1,t:`join`,lan:!0}:{v:1,t:`join`,room:e.room})),s.onmessage=e=>{if(typeof e.data!=`string`)return;let t;try{t=JSON.parse(e.data)}catch{return}this.onHub(t)},s.onclose=e=>{this.hub===s&&(this.hub=null,this.readyState===0&&(this.answered||e?.code===1001&&this.hubRestarting()||this.fail(`no_hub`)))},s.onerror=()=>{};for(let e of a?.msgs??[])this.onHub(e)}}signal(e){let t=this.hub;t&&t.readyState===1&&t.send(JSON.stringify({t:`signal`,to:`host`,data:e}))}onHub(e){if(this.readyState===0)switch(e.t){case`joined`:o(`hub: joined room as ${e.gid??`?`}`),this.sendOffer();return;case`signal`:e.from===`host`&&e.data&&typeof e.data==`object`&&this.onSignal(e.data);return;case`closed`:this.fail(`no_room`);return;case`error`:if(o(`hub: error ${e.why??`?`}`),e.why===`no_room`&&this.hubBackUntil&&this.hubRestarting())return;this.fail(e.why===`no_room`?`no_room`:e.why===`room_full`?`net_full`:`no_hub`);return}}prepare(){if(!i)return;this.offerSent=!1,this.ownEarly=[];let e;try{e=new i({iceServers:[{urls:Is}]})}catch{this.fail(`no_webrtc`);return}this.pc=e;let n=e.createDataChannel(t.label??`join`,{ordered:!0});if(n.binaryType=`arraybuffer`,this.dc=n,n.onopen=()=>this.opened(n),n.onmessage=e=>this.fromChannel(e.data),n.onclose=()=>{this.dc===n&&this.dropped()},t.video&&e.addTransceiver){try{let t=e.addTransceiver(`video`,{direction:`recvonly`}),n=zs(globalThis.RTCRtpReceiver?.getCapabilities?.(`video`));n.length&&t.setCodecPreferences&&t.setCodecPreferences(n)}catch{}try{e.addTransceiver(`audio`,{direction:`recvonly`})}catch{}e.ontrack=t=>{if(this.pc!==e)return;let n=this.media?.stream??t.streams[0]??new MediaStream;n.getTracks().includes(t.track)||n.addTrack(t.track),this.media=t.track.kind===`audio`?{stream:n,receiver:this.media?.receiver??t.receiver,audio:t.receiver}:{stream:n,receiver:t.receiver,...this.media?.audio?{audio:this.media.audio}:{}}}}e.onicecandidate=t=>{if(this.pc!==e)return;let n=t.candidate;if(!n||!n.candidate)return;let r={type:`candidate`,candidate:n.candidate,sdpMid:n.sdpMid??`0`};this.offerSent?this.signal(r):this.ownEarly.push(r)},e.oniceconnectionstatechange=()=>{if(this.pc!==e)return;let t=e.iceConnectionState;o(`ice: ${t}`),t===`failed`&&(this.readyState===0?this.fail(`no_direct`):this.dropped())},this.offerSdp=(async()=>{let t=await e.createOffer();return await e.setLocalDescription(t),e.localDescription?.sdp??t.sdp??``})().catch(()=>(this.pc===e&&this.fail(`no_webrtc`),null))}async sendOffer(){let e=this.pc,t=this.offerSdp;if(!e||!t||this.offerSent)return;this.clearTimer(),this.timer=setTimeout(()=>{this.timer=null,this.readyState===0&&this.fail(`no_direct`)},a);let n=await t;if(this.pc===e&&n!==null&&this.readyState===0){this.signal({type:`offer`,sdp:n}),this.offerSent=!0;for(let e of this.ownEarly.splice(0))this.signal(e)}}async onSignal(t){let n=this.pc;if(t.type===`bye`)this.fail(t.why===`full`?`net_full`:`offer`);else if(n){if(t.type===`answer`){if(this.answered||typeof t.sdp!=`string`)return;if(e.fp?!js(t.sdp,e.fp):As(t.sdp)===null){o(`answer: fingerprint does not match the link`),this.fail(`mismatch`);return}this.answered=!0;try{await n.setRemoteDescription({type:`answer`,sdp:t.sdp});for(let e of this.early.splice(0))await n.addIceCandidate(e).catch(()=>{})}catch{this.fail(`offer`)}}else if(t.type===`candidate`&&typeof t.candidate==`string`&&t.candidate){let e={candidate:t.candidate,sdpMid:typeof t.sdpMid==`string`?t.sdpMid:`0`,sdpMLineIndex:typeof t.sdpMLineIndex==`number`?t.sdpMLineIndex:0};this.answered?await n.addIceCandidate(e).catch(()=>{}):this.early.push(e)}}}opened(e){this.dc===e&&this.readyState===0&&(this.clearTimer(),this.readyState=1,o(`channel open`),this.leaveHub(),this.onopen?.(new Event(`open`)))}fromChannel(e){if(this.readyState!==1)return;if(typeof e==`string`){this.onmessage?.(new MessageEvent(`message`,{data:e}));return}if(!(e instanceof ArrayBuffer))return;let t=this.rx.push(e);switch(t.kind){case`ping`:try{this.dc?.send(Fs(t.data))}catch{}return;case`message`:this.onmessage?.(new MessageEvent(`message`,{data:t.data}));return;case`error`:o(`channel: bad binary message (${t.why})`),this.dropped();return;default:return}}async netPath(){let e=this.pc;if(!e||this.readyState!==1||typeof e.getStats!=`function`)return null;try{return Os(await e.getStats())}catch{return null}}send(e){let t=this.dc;if(this.readyState!==1||!t||t.readyState!==`open`)throw Error(`not open`);if(typeof e==`string`){t.send(e);return}let n=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e);for(let e of Ns(n))t.send(e)}close(){this.readyState!==3&&(this.teardown(),this.emitClose(1e3,``,!0))}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}leaveHub(){let e=this.hub;if(this.hub=null,e)try{e.readyState===1&&e.send(JSON.stringify({t:`leave`})),e.close(1e3)}catch{}}hubRestarting(){let e=Date.now();return this.hubBackUntil||=e+Rs,e>=this.hubBackUntil?!1:(o(`hub: restarting, trying again`),this.clearTimer(),this.leaveHub(),this.closePeer(),this.answered=!1,this.early=[],this.timer=setTimeout(()=>{this.timer=null,this.begin()},Ls),!0)}teardown(){this.readyState=3,this.clearTimer(),this.leaveHub(),this.closePeer()}closePeer(){let e=this.pc,t=this.dc;this.pc=null,this.dc=null,this.media=null,this.offerSdp=null,this.offerSent=!1,this.ownEarly=[];try{t?.close()}catch{}try{e?.close()}catch{}}dropped(){this.readyState!==3&&(this.teardown(),this.emitClose(1006,``,!1))}fail(e){this.readyState!==3&&(o(`failed: ${e}`),this.teardown(),this.emitClose(Ie,`net:${e}`,!1))}emitClose(e,t,n){let r=this.onclose;if(!r)return;let i=typeof CloseEvent>`u`?{type:`close`,code:e,reason:t,wasClean:n}:new CloseEvent(`close`,{code:e,reason:t,wasClean:n});setTimeout(()=>r(i),0)}}return n=s,n.CONNECTING=0,n.OPEN=1,n.CLOSING=2,n.CLOSED=3,s}function Ws(e,t=0){return/iPad/.test(e)||/Macintosh/.test(e)&&t>1?`ipad`:/iPhone|iPod/.test(e)?`iphone`:/Android/.test(e)?`android`:`phone`}var Gs=new URLSearchParams(location.hash.slice(1)),Ks=Gs.get(`t`)??``,qs=Gs.get(`w`)===`1`,Js=Ws(navigator.userAgent,navigator.maxTouchPoints),Ys=oo({get:yt,set:vt}),Xs=Be(location.hash),Zs=(0,x.createRoot)(document.getElementById(`root`));if(Xs){let e=Us(Xs,{label:`pad`,log:e=>console.info(`[pad] ${e}`)}),t=`ps5upload.pad.rt.${Xs.room}`,n=yt(t),r={t:Xs.key,name:Js,d:Ys,...qs?{w:1}:{},...n?{rt:n}:{}},i=Me(location.hash,`pad`);Zs.render((0,L.jsx)(vs,{url:ks(Xs.hub),computer:null,watch:qs,transport:e,hello:r,onReconnectToken:e=>vt(t,e),lanUrl:i?Ne(i,{watch:qs}):null}))}else{let e=location.pathname.replace(/\/pad\/?$/,``),t=`${location.protocol===`https:`?`wss`:`ws`}://${location.host}${e}/api/pad/ws?t=${encodeURIComponent(Ks)}&name=${Js}&d=${Ys}${qs?`&w=1`:``}`;Zs.render((0,L.jsx)(ws,{appLink:Ts(location.href),children:(0,L.jsx)(vs,{url:t,computer:location.hostname,watch:qs})}))}