"use client"; import type { RectificationCandidateResult } from "@/lib/rectification-candidate-result"; import { RECTIFICATION_USER_COPY, REPRESENTATIVE_MINUTE_DISCLAIMER, rangeDeliveryCaptionWithoutClosedInvite, rangeDeliveryEventCopy, rangeDeliveryShowsOpenCollectInvite, } from "@/lib/rectification-agentic/user-copy"; import type { RangeDeliveryProjection } from "@/lib/rectification-agentic/v9/divergence-panel"; import { RectificationVerificationReport } from "@/components/rectification-verification-report"; function columnHasTraits(column: RangeDeliveryProjection["columns"][number]): boolean { return Boolean(column.traits.d9 || column.traits.d10 || column.traits.nakshatra.length > 0); } export function RectificationRangeDelivery({ result, acceptingCandidateId, readonly, onAccept, onTieBreak, }: Readonly<{ result: RectificationCandidateResult; acceptingCandidateId: string | null; readonly: boolean; onAccept: (candidateId: string) => void; onTieBreak?: () => void; }>) { const delivery: RangeDeliveryProjection | null = result.rangeDelivery; const range = delivery?.range ?? result.credibleRange; const eventCount = delivery?.event_count ?? 0; const selected = result.selectedTime; const busy = Boolean(acceptingCandidateId) || readonly; const columns = delivery?.columns ?? []; const title = range ? eventCount > 0 ? `${RECTIFICATION_USER_COPY.rangeDeliveryTitle} ${range[0]}–${range[1]}(${rangeDeliveryEventCopy(eventCount)})` : `${RECTIFICATION_USER_COPY.rangeDeliveryTitle} ${range[0]}–${range[1]}` : RECTIFICATION_USER_COPY.rangeDeliveryTitle; const markdown = delivery?.verification_markdown ?? result.verificationReportMarkdown; const sharedTraits = delivery?.shared_traits ?? []; const showOpenCollectInvite = rangeDeliveryShowsOpenCollectInvite({ hint: delivery?.narrow_hint, columns, }); const caption = showOpenCollectInvite || delivery?.narrow_hint?.includes( RECTIFICATION_USER_COPY.rangeDeliveryCollectClosed, ) ? rangeDeliveryCaptionWithoutClosedInvite(delivery?.narrow_hint) : delivery?.narrow_hint ?? null; return (
{title}
{caption ? (

{caption}

) : null} {showOpenCollectInvite ? (

{RECTIFICATION_USER_COPY.rangeDeliveryCollectClosed}

) : null} {delivery?.tie_break_available && onTieBreak && !readonly ? ( ) : null} {delivery?.tie_break_note ? (

{delivery.tie_break_note}

) : null} {sharedTraits.length > 0 ? ( ) : null} {delivery?.more_label ? (

{delivery.more_label}

) : null}

{delivery?.boundary ?? REPRESENTATIVE_MINUTE_DISCLAIMER}

); }