import Link from 'next/link'; import { Section } from '@/components/ui/section'; import { Unavailable } from '@/components/ui/unavailable'; import { fmtInt, num, titleCase } from '@/lib/format'; import { ORBIT_CLASS_COLORS, routes } from '@/lib/site'; import type { HomePayload } from '@/lib/types'; interface RankRow { key: string; href: string; label: string; sub?: string | null; value: number; color?: string; } /** Ranked list with proportional bars where every label is a link (the shared HBars is not linkable). */ export function RankedBars({ rows, valueLabel }: { rows: RankRow[]; valueLabel: string }) { if (!rows.length) return ; const max = Math.max(1, ...rows.map((r) => r.value)); return (
    {rows.map((r, i) => (
  1. {String(i + 1).padStart(2, '0')} {r.label} {r.sub && {r.sub}} {fmtInt(r.value)} {valueLabel}
  2. ))}
); } export function TopConstellations({ items }: { items: HomePayload['top_constellations'] }) { const rows: RankRow[] = items.map((c) => ({ key: c.id, href: routes.constellation(c.slug), label: c.name, sub: [c.service_type ? titleCase(c.service_type) : null, c.orbit_class].filter(Boolean).join(' · '), value: num(c.active) ?? 0, color: ORBIT_CLASS_COLORS[c.orbit_class ?? 'OTHER'] ?? 'var(--series-1)', })); return (

Active satellites · membership is derived (see methodology)

); } export function TopCountries({ items }: { items: HomePayload['top_countries'] }) { const rows: RankRow[] = items.slice(0, 10).map((c) => ({ key: c.code, href: routes.country(c.slug), label: c.name, sub: `${fmtInt(c.objects_on_orbit)} objects on orbit`, value: num(c.active_payloads) ?? 0, color: 'var(--series-6)', })); return (
); } export function TopOperators({ items }: { items: HomePayload['top_operators'] }) { const rows: RankRow[] = items.slice(0, 10).map((o) => ({ key: o.id, href: routes.operator(o.slug), label: o.name, sub: [o.country_code, num(o.payloads_last_365d) ? `${fmtInt(o.payloads_last_365d)} launched in 365 d` : null].filter(Boolean).join(' · '), value: num(o.active_payloads) ?? 0, color: 'var(--series-2)', })); return (
); }