import { cn } from '@/lib/utils' import { formatVoteEstimateScenarioAriaLabel, VOTE_ESTIMATE_SCENARIOS, voteEstimateScenarioLabels, type VoteEstimateScenario, type VoteEstimateScenarioViewModel, } from '@/utilities/voteEstimate' const voteFormatter = new Intl.NumberFormat('pt-BR') type VoteEstimateScenarioStripProps = { values: VoteEstimateScenarioViewModel activeScenario?: VoteEstimateScenario className?: string /** @deprecated Prefer labelMode */ showLabels?: boolean labelMode?: 'all' | 'endpoints' | 'none' markerMode?: 'all' | 'active-only' stretch?: boolean } export const VoteEstimateScenarioStrip = ({ values, activeScenario = 'central', className, showLabels = true, labelMode, markerMode = 'all', stretch = false, }: VoteEstimateScenarioStripProps) => { const resolvedLabelMode = labelMode ?? (showLabels ? 'all' : 'none') const activeOnlyMarkers = markerMode === 'active-only' const trackClassName = stretch ? 'w-full min-w-0 max-w-none' : 'w-full min-w-[4.5rem] max-w-[5.5rem]' const filled = VOTE_ESTIMATE_SCENARIOS.map((scenario) => values[scenario]).filter( (value): value is number => value != null, ) const min = filled.length > 0 ? Math.min(...filled) : null const max = filled.length > 0 ? Math.max(...filled) : null const hasSpread = min != null && max != null && max > min const activeValue = values[activeScenario] const activeMarkerPosition = activeValue != null && min != null && max != null ? hasSpread ? ((activeValue - min) / (max - min)) * 100 : 50 : null const activeMarker = activeMarkerPosition != null ? ( ) : null return (