"use client"; import { useEffect, useMemo, useState, useSyncExternalStore } from "react"; import Link from "next/link"; import { ChevronRight } from "lucide-react"; import { ChartHoverCard } from "@/components/charts/chart-hover-card"; import { ChartYAxis } from "@/components/charts/chart-y-axis"; import type { DiveGasUsePoint } from "@/lib/api/dive-stats"; import { type BinUnit, type GasUseMark, GAS_USE_MARKS, TREND_GAP_MS, bandRanges, binSummaries, binUnit, clipOutliers, quantile, quartiles, scopeRange, } from "@/lib/dive-gas"; import { type ChartScope, monthName } from "@/lib/chart-period"; import { CHART_HEIGHT, CHART_PADDING, CHART_PLOT_HEIGHT, CHART_WIDTH, axisTicks, labelCapacity, niceDomain, plotLeft, } from "@/lib/chart-scale"; import { type PlotMark, nearestByX, nearestWithin, viewBoxPoint, } from "@/lib/chart-readout"; import { GAS_USE_SERIES_KEY, parseSeriesVisibility, readStoredSeries, subscribeToNothing, toggleSeries, writeSeriesVisibility, } from "@/lib/chart-series-view"; import { diveWallClockTime, formatDiveDateTime } from "@/lib/date-time"; import { cn } from "@/lib/utils"; import { useChartReadout } from "@/hooks/useChartReadout"; import { useChartWidth } from "@/hooks/useChartWidth"; import { useUnits } from "@/hooks/useUnits"; import { useWithReturnTo } from "@/hooks/useReturnTo"; import { displayNumber, formatDepth, formatGasVolume, toDisplayUnits, unitLabel, unitWord, type UnitSystem, } from "@/lib/units"; // Hand-rolled SVG rather than a charting library, for two reasons. The app ships // a strict nonce-based CSP (`src/proxy.ts`): inline style *attributes* are // allowed, but a library that injects a `