import type { SelectModeBoundingRect, SelectModeClickPosition } from "../../_vendor/schemas/generated/selectMode"; export type DragPosition = { clientX: number; clientY: number; pageX: number; pageY: number; }; export type ScrollOffset = { left: number; top: number; }; export type SelectedAreaState = { pageRect: SelectModeBoundingRect; }; export declare function getDragPositionFromClient({ clientX, clientY, scrollOffset, }: { clientX: number; clientY: number; scrollOffset: ScrollOffset; }): DragPosition; export declare function getDocumentScrollOffset(): ScrollOffset; export declare function getViewportSelectionRect({ dragStart, dragCurrent, scrollOffset, }: { dragStart: DragPosition; dragCurrent: DragPosition; scrollOffset: ScrollOffset; }): SelectModeBoundingRect; export declare function getPageRectFromViewportRect({ rect, scrollOffset, }: { rect: SelectModeBoundingRect; scrollOffset: ScrollOffset; }): SelectModeBoundingRect; export declare function getViewportRectFromPageRect({ rect, scrollOffset, }: { rect: SelectModeBoundingRect; scrollOffset: ScrollOffset; }): SelectModeBoundingRect; /** * A drag captures an element when their boxes overlap (within * `tolerancePx`) — but NOT when the drag sits entirely inside the * element. The latter case is the user dragging *within* a large * container (a section, `
`, ``) to lasso its children; the * container itself isn't a thing they're trying to select, so we drop it. */ export declare function doesRectIntersectSelection({ elementRect, selectionRect, tolerancePx, }: { elementRect: SelectModeBoundingRect; selectionRect: SelectModeBoundingRect; tolerancePx: number; }): boolean; export type DragCandidate = { id: string; element: Element; pageRect: SelectModeBoundingRect; }; /** * Snapshots every meaningful element and its page rect when a drag begins. * Each candidate gets a stable id so the parent overlay can key its * live highlights without remounting them as the drag moves. */ export declare function collectDragCandidates(scrollOffset: ScrollOffset): DragCandidate[]; /** * Cheap per-move hit-test against the pre-collected candidates: keep the * ones whose page rect overlaps the selection (excluding any that wholly * enclose it), then collapse any fully-covered parent/children group down * to just the parent (see `collapseFullyCoveredChildren`). Does no DOM * queries or re-measures of geometry — the only DOM reads are cheap * parent/child structural lookups. * * Because the collapse depends on which siblings are currently captured, * elements legitimately move in and out of the result as the drag grows or * shrinks: a child drops out the moment the drag swallows its last sibling * (the parent takes over), and reappears if the drag retreats. */ export declare function getCandidatesInSelection({ candidates, selectionPageRect, }: { candidates: DragCandidate[]; selectionPageRect: SelectModeBoundingRect; }): DragCandidate[]; /** * Shift / Command / Ctrl click toggles the clicked element in the current * selection (theme-builder canvas rules): a click inside an already-selected * ancestor is ignored, selecting a parent drops its selected descendants, * and once every candidate child of a candidate parent is selected the * parent replaces them — the same collapse drag-select applies. */ export declare function getSelectionAfterAdditiveClick({ candidates, currentSelectedElements, targetElement, }: { candidates: DragCandidate[]; currentSelectedElements: Element[]; targetElement: Element; }): Element[]; export declare function isAdditiveSelectionClick(event: { shiftKey: boolean; metaKey: boolean; ctrlKey: boolean; }): boolean; export declare function getPointRect({ x, y, }: { x: number; y: number; }): SelectModeBoundingRect; export declare function unionElementPageRects({ elements, scrollOffset, }: { elements: Element[]; scrollOffset: ScrollOffset; }): SelectModeBoundingRect | null; /** * Picks a "click position" for an element that fell inside an area * selection. We use the corner of the element nearest the top-left of the * selection rect, clamped to the element's own bounds. This anchor is what * lets the selected-element overlay continue to track the element when the * user scrolls (`useSelectionScrollSync` re-projects relative to it). */ export declare function getElementAnchor({ element, selectionRect, }: { element: Element; selectionRect: SelectModeBoundingRect; }): SelectModeClickPosition; export declare function getElementBoundingRect(element: Element): SelectModeBoundingRect;