'use client'; import { Panel } from '@/components/ui/panel'; import type { DetailFinancialRow, DimensionBreakdownRow, FinancialStatementPeriod, FinancialSurfaceKind, SurfaceFinancialRow } from '@/lib/types'; import type { ResolvedStatementSelection } from '@/lib/financials/statement-view-model'; type StatementRowInspectorProps = { selection: ResolvedStatementSelection | null; dimensionRows: DimensionBreakdownRow[]; periods: FinancialStatementPeriod[]; surfaceKind: Extract; renderValue: (row: SurfaceFinancialRow | DetailFinancialRow, periodId: string, previousPeriodId: string | null) => string; renderDimensionValue: (value: number | null, rowKey: string, unit: SurfaceFinancialRow['unit']) => string; }; function InspectorCard(props: { label: string; value: string; }) { return (

{props.label}

{props.value}

); } function renderList(values: string[] | null | undefined) { return (values ?? []).length > 0 ? (values ?? []).join(', ') : 'n/a'; } export function StatementRowInspector(props: StatementRowInspectorProps) { const selection = props.selection; const parentSurfaceLabel = selection?.kind === 'detail' ? selection.parentSurfaceRow?.label ?? (selection.row.parentSurfaceKey === 'unmapped' ? 'Unmapped / Residual' : selection.row.parentSurfaceKey) : null; return ( {!selection ? (

Select a compact surface row or raw detail row to inspect details.

) : selection.kind === 'surface' ? (
0 ? (selection.row.sourceFactIds ?? []).join(', ') : 'n/a'} />
0 ? selection.childSurfaceRows.map((row) => row.label).join(', ') : 'None'} />
{selection.detailRows.length > 0 ? (

Raw Detail Labels

{selection.detailRows.map((row) => ( {row.label} ))}
) : null} {selection.row.hasDimensions ? ( props.dimensionRows.length === 0 ? (

No dimensional facts were returned for the selected compact row.

) : (
{props.dimensionRows.map((row, index) => ( ))}
Period Axis Member Value
{props.periods.find((period) => period.id === row.periodId)?.periodLabel ?? row.periodId} {row.axis} {row.member} {props.renderDimensionValue(row.value, selection.row.key, selection.row.unit)}
) ) : (

No dimensional drill-down is available for this compact surface row.

)}
) : (
0 ? (selection.row.sourceFactIds ?? []).join(', ') : 'n/a'} />

Dimensions Summary

{renderList(selection.row.dimensionsSummary)}

{props.dimensionRows.length === 0 ? (

No dimensional facts were returned for the selected raw detail row.

) : (
{props.dimensionRows.map((row, index) => ( ))}
Period Axis Member Value
{props.periods.find((period) => period.id === row.periodId)?.periodLabel ?? row.periodId} {row.axis} {row.member} {props.renderDimensionValue(row.value, selection.row.key, props.surfaceKind === 'balance_sheet' ? 'currency' : 'currency')}
)}
)}
); }