/** * Layout selector engines for spatial/positional element matching. * * Provides selectors for finding elements based on their position relative * to other elements: left-of, right-of, above, below, near. * * Based on Playwright's layout selector implementation. */ import type { SelectorEngine } from './engine.js'; /** * Layout selector names for spatial positioning. */ export type LayoutSelectorName = 'left-of' | 'right-of' | 'above' | 'below' | 'near'; /** * All layout selector names. */ export declare const kLayoutSelectorNames: LayoutSelectorName[]; /** * Options for layout selectors. */ export interface LayoutSelectorOptions { maxDistance?: number; } /** * Check if box1 is to the right of box2. * Returns distance score or undefined if not right-of. * * Distance calculation: * - Primary: horizontal gap between box1.left and box2.right * - Penalty: vertical misalignment (how much box1 extends beyond box2's vertical bounds) * * @param box1 - The element being checked * @param box2 - The reference element * @param maxDistance - Maximum horizontal distance allowed * @returns Distance score (lower is better) or undefined if not right-of */ export declare function boxRightOf(box1: DOMRect, box2: DOMRect, maxDistance: number | undefined): number | undefined; /** * Check if box1 is to the left of box2. * Returns distance score or undefined if not left-of. * * Distance calculation: * - Primary: horizontal gap between box2.left and box1.right * - Penalty: vertical misalignment * * @param box1 - The element being checked * @param box2 - The reference element * @param maxDistance - Maximum horizontal distance allowed * @returns Distance score (lower is better) or undefined if not left-of */ export declare function boxLeftOf(box1: DOMRect, box2: DOMRect, maxDistance: number | undefined): number | undefined; /** * Check if box1 is above box2. * Returns distance score or undefined if not above. * * Distance calculation: * - Primary: vertical gap between box2.top and box1.bottom * - Penalty: horizontal misalignment * * @param box1 - The element being checked * @param box2 - The reference element * @param maxDistance - Maximum vertical distance allowed * @returns Distance score (lower is better) or undefined if not above */ export declare function boxAbove(box1: DOMRect, box2: DOMRect, maxDistance: number | undefined): number | undefined; /** * Check if box1 is below box2. * Returns distance score or undefined if not below. * * Distance calculation: * - Primary: vertical gap between box1.top and box2.bottom * - Penalty: horizontal misalignment * * @param box1 - The element being checked * @param box2 - The reference element * @param maxDistance - Maximum vertical distance allowed * @returns Distance score (lower is better) or undefined if not below */ export declare function boxBelow(box1: DOMRect, box2: DOMRect, maxDistance: number | undefined): number | undefined; /** * Check if box1 is near box2. * Returns distance score or undefined if not near. * * Distance calculation: * - Sum of all gaps (top, bottom, left, right) between the boxes * - Default threshold is 50px * * @param box1 - The element being checked * @param box2 - The reference element * @param maxDistance - Maximum total gap allowed (default: 50) * @returns Distance score (lower is better) or undefined if not near */ export declare function boxNear(box1: DOMRect, box2: DOMRect, maxDistance: number | undefined): number | undefined; /** * Calculate the score for an element's position relative to inner elements. * Lower score = better match. Returns undefined if not matching. * * @param name - The layout selector name * @param element - The element being scored * @param innerElements - Reference elements to compare against * @param maxDistance - Optional maximum distance constraint * @returns Best score across all inner elements, or undefined if none match */ export declare function layoutSelectorScore(name: LayoutSelectorName, element: Element, innerElements: Element[], maxDistance: number | undefined): number | undefined; /** * Create a layout selector engine for the given name. * * @param name - The layout selector name * @returns A selector engine for the layout selector */ export declare function createLayoutEngine(name: LayoutSelectorName): SelectorEngine; /** * All layout engines for registration. */ export declare const layoutEngines: Record; /** * Register all layout engines with the global registry. */ export declare function registerLayoutEngines(): void; //# sourceMappingURL=layout.d.ts.map