import { AmountDisplay } from '@/components/ui/amount-display'; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card'; import { ChartConfig, ChartContainer } from '@/components/ui/chart'; import { TrendDataPoint } from '@/hooks/use-cashflow-data'; import { useLocale } from '@/hooks/use-locale'; import { cn } from '@/lib/utils'; import { formatCompactNumber, formatMonthFromYearMonth } from '@/utils/date'; import { __ } from '@/utils/i18n'; import { useEffect, useRef } from 'react'; import { Bar, BarChart, CartesianGrid, Line, ReferenceLine, Tooltip, XAxis, YAxis, } from 'recharts'; interface CashflowTrendChartProps { data: TrendDataPoint[]; loading?: boolean; className?: string; currency?: string; } interface TooltipPayloadItem { dataKey?: string; value?: number; color?: string; name?: string; payload?: TrendDataPoint; } interface CustomTooltipProps { active?: boolean; payload?: TooltipPayloadItem[]; currency?: string; } function CustomTooltip({ active, payload, currency = 'USD', }: CustomTooltipProps) { const locale = useLocale(); if (!active || !payload?.length) return null; const data = payload[0].payload; if (!data) return null; return (