import { UsersIcon } from 'lucide-react' import { VoteEstimateScenarioStrip } from '@/components/campaign/votePledge/VoteEstimateScenarioStrip' import { cn } from '@/lib/utils' import { formatVoteEstimateScenarioAriaLabel, getVoteEstimateForScenario, hasAnyVoteEstimate, type VoteEstimateScenario, type VoteEstimateScenarioViewModel, } from '@/lib/voteEstimate' import type { MunicipalityPledgeCoverageView } from '@/utilities/votePledgeViews' const voteFormatter = new Intl.NumberFormat('pt-BR') const pledgeCoverageSubline = ( coverage: MunicipalityPledgeCoverageView | null | undefined, ): number | null => { if (!coverage || coverage.pledgeCount === 0) return null if (coverage.missingEstimateCount === coverage.pledgeCount) return null return coverage.effectiveTotal > 0 ? coverage.effectiveTotal : null } export const StaffMunicipalityVotesDisplay = ({ expectedVotes, pledgeCoverage, activeScenario = 'central', layout = 'default', align = 'start', suppressHoverPreview = false, valueClassName = 'text-lg font-medium tabular-nums', }: { expectedVotes: VoteEstimateScenarioViewModel pledgeCoverage?: MunicipalityPledgeCoverageView | null activeScenario?: VoteEstimateScenario layout?: 'default' | 'compact' align?: 'start' | 'center' suppressHoverPreview?: boolean valueClassName?: string }) => { const displayValue = getVoteEstimateForScenario(expectedVotes, activeScenario) const leadershipTotal = pledgeCoverageSubline(pledgeCoverage) const hasEstimate = hasAnyVoteEstimate(expectedVotes) const isCompact = layout === 'compact' if (isCompact) { return ( <> {displayValue == null ? '—' : voteFormatter.format(displayValue)} {hasEstimate && !suppressHoverPreview ? (