import { useEffect, useState } from 'react' import { useSearchParams } from 'react-router-dom' import { CaretRight as ChevronRight, DownloadSimple as Download, Sparkle as Sparkles } from '@phosphor-icons/react' import { BrandIcon } from '../../components/BrandIcon' import { GlassLens } from '../../components/GlassLens' import { detectKind, searchProfiles, type PlatformGroup } from '../../data/mock' import { kindMeta } from './Search' const stages = ['Checking social networks', 'Checking forums', 'Checking developer sites', 'Checking games and media', 'Putting it together'] const groups: ('All' | PlatformGroup)[] = ['All', 'Social', 'Dev', 'Gaming', 'Forums', 'Media'] const SITES = 3100 export default function Results() { const [params] = useSearchParams() const q = params.get('q') ?? 'johndoe_92' const meta = kindMeta[detectKind(q)] const [progress, setProgress] = useState(0) const [filter, setFilter] = useState<(typeof groups)[number]>('All') // Progress is timed locally; swap in the real job status when lookups are connected. useEffect(() => { setProgress(0) const t = setInterval(() => setProgress((p) => Math.min(100, p + 4)), 90) return () => clearInterval(t) }, [q]) const done = progress >= 100 const stage = Math.min(stages.length - 1, Math.floor(progress / (100 / stages.length))) const profiles = searchProfiles(q) const visible = profiles.slice(0, Math.round((progress / 100) * profiles.length)) const list = visible.filter((p) => filter === 'All' || p.group === filter) const same = profiles.filter((p) => p.match === 'exact').length return (
{/* Header */}
{meta.label}

{q}

{done ? (profiles.length ? `Found on ${profiles.length} sites` : 'Nothing found') : 'Searching'}

{/* Status */} {!done ? (
{stages[stage]}… {Math.round((progress / 100) * SITES).toLocaleString('en-US')} of {SITES.toLocaleString('en-US')} sites
) : profiles.length === 0 ? (

Nothing found on public sites

Check the spelling, or try a different nickname, email, phone number or website.

) : (

What Watson found

This {meta.label.toLowerCase()} is used on {profiles.length} public sites.{' '} {same} of them look like the same person: same name, matching photos and links between profiles. The oldest account is from 2015, and they are most active on GitHub and Reddit.

)} {/* Filters: bleed to the window edge so a cut-off chip shows there is more. */} {!(done && profiles.length === 0) && (
{groups.map((g) => { const n = g === 'All' ? visible.length : visible.filter((p) => p.group === g).length const on = g === filter return ( ) })}
)} {/* Grouped list */} {list.length > 0 && ( )}
) }