"use client"; import { useEffect, useState, useSyncExternalStore } from "react"; import { closeGameLaunch, getGameLaunchState, subscribeGameLaunch } from "@/components/providers/game-launch-store"; import { openDownloadDialog } from "@/components/providers/download-dialog-store"; import { Button } from "@/components/ui/button"; import { X } from "lucide-react"; import { RobloxLogoIcon } from "@/components/roblox/RobloxIcons"; export function GameLaunchDialog() { const state = useSyncExternalStore( subscribeGameLaunch, getGameLaunchState, getGameLaunchState ); const [launchTimeouted, setLaunchTimeouted] = useState(false); function detectOS() { if (typeof navigator === "undefined") return "Unknown"; const nav = navigator as Navigator & { userAgentData?: { platform?: string }; }; const platform = nav.userAgentData?.platform || nav.platform || ""; const ua = nav.userAgent || ""; const haystack = `${platform} ${ua}`; if (/windows/i.test(haystack)) return "Windows"; if (/mac os x|macintosh|macos/i.test(haystack)) return "Mac"; if (/linux/i.test(haystack)) return "Linux"; return "Unknown"; } function handleDownloadClick() { const os = detectOS(); const canDownload = os === "Windows" || os === "Mac"; const url = canDownload ? "https://www.roblox.com/download/client" : null; openDownloadDialog(url); closeGameLaunch(); if (!canDownload || !url) return; try { window.open(url, "_blank", "noopener,noreferrer"); } catch {} } useEffect(() => { if (!state.isOpen) { setLaunchTimeouted(false); return; } const timeout = setTimeout(() => { setLaunchTimeouted(true); }, 5000); // 5 seconds return () => clearTimeout(timeout); }, [state.isOpen]); if (!state.isOpen) return null; return (
event.stopPropagation()} >

{!launchTimeouted ? ( <> Roblox is now loading.
Get ready! ) : ( <> Download Roblox to play millions of experiences. )}

{launchTimeouted ? ( ) : ( )}
); }