"use client" import { useState, useEffect } from "react" import { ComposableMap, Geographies, Geography, Marker } from "react-simple-maps" interface Server { id: string name: string location: string subdomain: string coordinates: [number, number] // [longitude, latitude] ping: number | null } const servers: Server[] = [ { id: "us", name: "United States", location: "Chicago", subdomain: "us.tunnl.live", coordinates: [-87.6298, 41.8781], ping: null, }, { id: "eu", name: "Europe", location: "Frankfurt", subdomain: "eu.tunnl.live", coordinates: [8.6821, 50.1109], ping: null, }, { id: "sgp", name: "Singapore", location: "Singapore", subdomain: "sgp.tunnl.live", coordinates: [103.8198, 1.3521], ping: null, }, { id: "id", name: "Indonesia", location: "Bogor", subdomain: "id.tunnl.live", coordinates: [106.8456, -6.5950], ping: null, }, ] const geoUrl = "https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json" interface WorldMapProps { onServerSelect: (server: Server) => void selectedServer: Server } export default function WorldMap({ onServerSelect, selectedServer }: WorldMapProps) { const [serverPings, setServerPings] = useState(servers) const [isLoading, setIsLoading] = useState(true) const getPingColor = (ping: number | null) => { if (!ping) return "text-gray-400" if (ping < 100) return "text-green-400" if (ping < 300) return "text-yellow-400" if (ping < 500) return "text-orange-400" return "text-red-400" } const getPingStatus = (ping: number | null) => { if (!ping) return "Testing..." if (ping < 100) return "Excellent" if (ping < 300) return "Good" if (ping < 500) return "Fair" return "Poor" } const getMarkerColor = (server: Server) => { if (selectedServer.id === server.id) return "#10b981" return "#6b7280" } const getMarkerStroke = (server: Server) => { if (selectedServer.id === server.id) return "#34d399" return "#9ca3af" } return (

Choose Your Server Location

{({ geographies }) => geographies.map((geo) => ( )) } {serverPings.map((server) => ( onServerSelect(server)} > {selectedServer.id === server.id && ( )} {server.location} ))}
{serverPings.map((server) => (
onServerSelect(server)} className={`p-4 rounded-lg border cursor-pointer transition-all duration-200 ${selectedServer.id === server.id ? "bg-emerald-950 border-emerald-500" : "bg-gray-900 border-gray-800 hover:border-gray-700" }`} >

{server.name}

{server.location}

{server.subdomain}

Ping: {isLoading ? ( Testing... ) : ( {server.ping}ms ({getPingStatus(server.ping)}) )}
))}
) }