"use client"; import { livingDisplayFromReceipt, windowIntervalsLabel } from "@/lib/rectification-agentic/core/candidate-window"; import type { RectificationCandidateResult } from "@/lib/rectification-candidate-result"; import { RECTIFICATION_USER_COPY, REPRESENTATIVE_MINUTE_DISCLAIMER, rangeDeliveryEventCopy, rangeDeliveryMostLikely, rangeDeliveryShowsPercents, } from "@/lib/rectification-agentic/user-copy"; import type { RangeDeliveryProjection } from "@/lib/rectification-agentic/v9/divergence-panel"; import { SWITCH_TO_RECTIFIED_LABEL, switchToRectifiedConfirmCopy, } from "@/lib/rectification-agentic/birth-time-provenance"; import { RectificationVerificationReport } from "@/components/rectification-verification-report"; import { RectificationSegmentDelivery } from "@/components/rectification-segment-delivery"; import { sessionOutcomeAllowsAdopt } from "@/lib/rectification-agentic/core/rectification-decision"; import { deliveryWindowFromReceipt, protectVargaReport } from "@/lib/rectification-agentic/v9/delivery-window"; function columnHasTraits(column: RangeDeliveryProjection["columns"][number], vargaBlocked: boolean): boolean { return Boolean((!vargaBlocked && (column.traits.d9 || column.traits.d10)) || column.traits.nakshatra.length > 0); } export function RectificationRangeDelivery({ result, acceptingCandidateId, readonly, onAccept, adoptLocked, }: Readonly<{ result: RectificationCandidateResult; acceptingCandidateId: string | null; readonly: boolean; onAccept: (candidateId: string) => void; adoptLocked?: boolean; }>) { 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 || adoptLocked; const adoptAllowed = sessionOutcomeAllowsAdopt(result.sessionOutcome) && result.canAdopt === true; const columns = delivery?.columns ?? []; const living = livingDisplayFromReceipt(result.decisionReceipt, result.declaredBirthDate); const rangeLabel = living ? living.label : result.credibleIntervals?.length ? windowIntervalsLabel(result.credibleIntervals, result.declaredBirthDate) : range ? `${range[0]}–${range[1]}` : null; const title = rangeLabel ? eventCount > 0 ? `${RECTIFICATION_USER_COPY.rangeDeliveryTitle} ${rangeLabel}(${rangeDeliveryEventCopy(eventCount)})` : `${RECTIFICATION_USER_COPY.rangeDeliveryTitle} ${rangeLabel}` : RECTIFICATION_USER_COPY.rangeDeliveryTitle; const windowMinutes = deliveryWindowFromReceipt(result.decisionReceipt) ?? delivery?.window_minutes ?? null; const vargaBlocked = windowMinutes === null || windowMinutes > 61; const markdown = protectVargaReport(delivery?.verification_markdown ?? result.verificationReportMarkdown, vargaBlocked, delivery?.product_delivery?.targets ?? delivery?.segment_summary?.targets); const sharedTraits = vargaBlocked ? [] : delivery?.shared_traits ?? []; // BUG-691: while the birth record disagrees with the range the adopt entry says what // it actually does — swap the charting clock — instead of the neutral 「更像这个」. const recordConflict = delivery?.record_conflict ?? null; const caption = delivery?.narrow_hint ?? null; // D3: the range is the title; the representative minute is the subtitle. // Hidden when the columns are indistinct (D4): 「最可能」 next to 「区分不开」 // would claim a lead the numbers do not have. const mostLikely = delivery?.representative_time ?? result.representativeTime; // D4: per-column numbers only when the first column leads by ≥ 5 points. const showPercents = rangeDeliveryShowsPercents(columns); const indistinct = columns.length >= 2 && !showPercents; if (delivery && (delivery.product_delivery || delivery.segment_summary)) { return candidate.candidateId === delivery.representative_candidate_id)?.candidate_date} />; } return (
{title} {mostLikely && !indistinct ? ( {rangeDeliveryMostLikely(mostLikely)} ) : null}
{vargaBlocked ? (

{windowMinutes === null ? "完整窗口范围暂不可用;暂不推荐分盘解读。" : "分盘解读需要更准的出生时间"}

) : caption ? (

{caption}

) : null} {delivery?.provenance_line ? (

{delivery.provenance_line}

) : null} {adoptLocked ? (

{RECTIFICATION_USER_COPY.rangeDeliveryAdoptLocked}

) : null} {delivery?.tie_break_note ? (

{delivery.tie_break_note}

) : null} {indistinct ? (

{RECTIFICATION_USER_COPY.rangeDeliveryIndistinct}

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

{delivery.more_label}

) : null}

{delivery?.boundary ?? REPRESENTATIVE_MINUTE_DISCLAIMER}

); }