// The map chooser, rendered on the takeover's back page (light/paper theme — dark ink on the white // sheet). Lists the server's curated maps (town.deception.listMaps) and offers a borderless field to // paste a map AT-URI directly. Picking one continues the flow (investigation for deduction, the // create-game form for deception); the back button returns to the mode picker. import { useEffect, useState } from 'react' import { listMaps, type MapRef } from './maps-api' const MAP_URI_RE = /^at:\/\/[^/]+\/world\.tilemap\.map\/[^/]+$/ export function MapSelector({ onBack, onPick }: { onBack: () => void; onPick: (map: MapRef) => void }) { const [maps, setMaps] = useState(null) const [error, setError] = useState(null) const [custom, setCustom] = useState('') const customUri = custom.trim() const customOk = MAP_URI_RE.test(customUri) useEffect(() => { // The fetch is typically already in flight (prefetched on folder hover/open), so this usually // resolves immediately from the shared cache. let cancelled = false listMaps() .then((m) => !cancelled && setMaps(m)) .catch((e) => !cancelled && setError(e instanceof Error ? e.message : String(e))) return () => { cancelled = true } }, []) function submitCustom(e: React.FormEvent) { e.preventDefault() if (customOk) onPick({ uri: customUri, name: 'Custom map' }) } return (

Choose a Map

Case site

{error &&

{error}

} {!maps && !error &&

loading maps…

} {maps && maps.length === 0 &&

No maps available.

} {maps && maps.length > 0 && (
    {maps.map((m) => (
  • ))}
)} {/* Paste a map AT-URI directly — styled to read as a line written on the page, not a form field. */}
setCustom(e.target.value)} spellCheck={false} autoCapitalize="off" autoCorrect="off" placeholder="at://…/world.tilemap.map/…" className="min-w-0 flex-1 border-0 bg-transparent p-0 font-case text-sm text-stone-900 placeholder:text-stone-400 focus:outline-none focus:ring-0" />
) }