import { geoEqualEarth, type GeoPermissibleObjects } from 'd3-geo'; import { t } from '@/i18n'; import { cn } from '@/lib/cn'; import { MAP_HEIGHT, MAP_WIDTH, worldPaths } from '@/lib/map-geo'; /** * Small static locator map for a country hero: the world in a muted tone, the country (and its neighbours, * lighter) in the accent, plus a ring at the capital / centroid so micro-states stay visible. Server component. */ export function MiniMap({ iso3, neighbours = [], latitude, longitude, name, className }: { iso3: string; neighbours?: string[]; latitude?: number | null; longitude?: number | null; name: string; className?: string }) { const { paths, sphere } = worldPaths(); const projection = geoEqualEarth().fitExtent( [ [4, 4], [MAP_WIDTH - 4, MAP_HEIGHT - 4], ], { type: 'Sphere' } as GeoPermissibleObjects, ); const pt = latitude != null && longitude != null ? projection([longitude, latitude]) : null; const nb = new Set(neighbours); const own = paths.find((p) => p.iso3 === iso3); return ( {t('country.miniMap', { name })} {paths.map((p, i) => ( ))} {own ? : null} {pt ? ( ) : null} ); }