import { type RefObject } from 'react'; import type { LineChartDatum, LineChartZoomDragState, LineChartZoomPendingState, LineChartZoomRange } from '../LineChartContext'; interface UseLineChartZoomStateResult { enabled: boolean; drag: LineChartZoomDragState | null; pending: LineChartZoomPendingState | null; registerEnabled: () => () => void; startDrag: (index: number, clientX: number, clientY: number) => void; updateDrag: (index: number, clientX: number, clientY: number) => void; endDrag: () => void; cancelDrag: () => void; confirmZoom: () => void; cancelPending: () => void; } /** * Two-phase zoom selection state machine. * * - `drag` is the live mouse-held selection — updated on every mousemove, * torn down on Escape, promoted to `pending` on mouseup. * - `pending` is the released-but-unconfirmed selection — renders the confirm * popover. Commits via `confirmZoom` (fires `onZoomChange`) or dismisses via * `cancelPending` (no emit). * * `enabledCount` (not a boolean) so multiple brush instances can't race when * one unmounts while another remains. Window-level listeners are wired up by * `useZoomDragListeners` so the popover keeps tracking when the cursor leaves * the SVG and a mouseup outside the chart still releases into pending. * * Drag updates from recharts (`updateDrag` — carries index+coords) and from * the window listener (`handleDragMove` — coords only) both write into a * single pending-frame buffer and flush together on the next animation frame. * That collapses the two motion paths into one React commit per frame and * keeps state writes off the synchronous mousemove path. * * Dataset changes invalidate cached indices on both `drag` and `pending`, so * both reset whenever `data` or `xKey` flips — otherwise a stale range could * be committed against a refreshed dataset. */ export declare const useLineChartZoomState: ({ data, xKey, onZoomChangeRef, }: { data: LineChartDatum[]; xKey: string; onZoomChangeRef: RefObject<((range: LineChartZoomRange | null) => void) | undefined>; }) => UseLineChartZoomStateResult; export {};