'use client'; import { useState, type ReactNode } from 'react'; import Image from 'next/image'; import { leaderArt } from '@/game/leader-art'; import { specialLeaderArt } from '@/game/special-leader-art'; /** Supply only an identity already authorized for this viewer. No game/deck lookup. */ export function LeaderPortrait({ identityId, name, fallback, className = 'size-20', sizes = '80px', badge, }: { identityId?: string; name: string; fallback: ReactNode; className?: string; sizes?: string; badge?: ReactNode; }) { const [failedSource, setFailedSource] = useState(null); const art = leaderArt(identityId, name) ?? specialLeaderArt(identityId, name); if (!art || failedSource === art.src) return fallback; return ( setFailedSource(art.src)} className="h-full w-full object-cover" style={{ objectPosition: art.objectPosition }} /> {badge !== undefined && ( {badge} )} ); }