import type { CropCanvasHandle } from "../../CropCanvas.js"; import type { EditAction } from "../../types.js"; import { type Quad } from "../../useEdgeDetection.js"; export interface ApplyCropResult { blob: Blob; actions: EditAction[]; } /** * `corners` — drag the four corner/edge handles of the current selection. * `rect` — drag out a brand new axis-aligned rectangle. */ export type CropMode = "corners" | "rect"; export interface CropToolState { activeCorners: Quad; mode: CropMode; /** False while the user is in rect mode and has not drawn a rectangle yet. */ hasSelection: boolean; scale: number; displaySize: { width: number; height: number; }; canvasRef: React.RefObject; cvReady: boolean; cvError: Error | null; cropping: boolean; error: string | null; handleCanvasReady: (canvas: HTMLCanvasElement, w: number, h: number) => void; updateCorner: (index: number, screenX: number, screenY: number) => void; /** Enters rect mode, temporarily clearing (and remembering) the current selection. */ startRectMode: () => void; /** Leaves rect mode without drawing, restoring the selection that was active before. */ cancelRectMode: () => void; startRectDraw: (screenX: number, screenY: number) => void; updateRectDraw: (screenX: number, screenY: number) => void; finishRectDraw: () => void; applyCrop: () => Promise; } /** * Manages all state and logic for the crop tool. * OpenCV is loaded lazily for corner suggestion and perspective warping, but is optional: * when it fails to load the tool stays fully usable, only the suggested border is missing. */ export declare function useCropTool(imageUrl: string, enabled: boolean): CropToolState; /** * Standalone replay handler for the "crop" action type. * Corners are stored as relative (0–1) values so they work at any resolution. * Rectangular crops replay without OpenCV; older actions without a stored mode * are treated as perspective crops. */ export declare function replayCrop(imageUrl: string, params: Record): Promise;