/** * Label bounding-box and collision utilities shared across * Region, Node, and Connector label placement. */ export interface LabelRect { x: number; y: number; w: number; h: number; } /** Check if two rectangles overlap (with optional padding) */ export declare function rectsOverlap(a: LabelRect, b: LabelRect, pad?: number): boolean; /** Check if a rect overlaps with any rect in the list */ export declare function overlapsAny(rect: LabelRect, others: LabelRect[], pad?: number): boolean; /** A pre-computed line segment (pixel coords) */ export interface LineSeg { x1: number; y1: number; x2: number; y2: number; } /** Check if a rect is crossed by any line segment in the list */ export declare function rectHitsAnyLine(rect: LabelRect, lines: LineSeg[], pad?: number): boolean; /** A node's icon-disc in pixel coordinates (for collision-avoidance). */ export interface Circle { cx: number; cy: number; r: number; } /** Closest-point rect-vs-circle overlap test. */ export declare function rectHitsCircle(rect: LabelRect, c: Circle, pad?: number): boolean; /** Check if a rect overlaps with any of the circles. */ export declare function rectHitsAnyCircle(rect: LabelRect, circles: Circle[], pad?: number): boolean; export interface CanvasBounds { width: number; height: number; } /** Check if a rect extends outside the canvas bounds */ export declare function rectOutOfBounds(rect: LabelRect, bounds: CanvasBounds): boolean; /** * Combined boolean check: overlaps label, crosses line, hits an icon * circle, OR out of canvas. Pass `bounds` to enable the canvas-bounds * check; omit to skip. Pass `circles` to enable icon-disc avoidance * (labels won't be placed on top of another node's icon). */ export declare function labelCollides(rect: LabelRect, labels: LabelRect[], lines: LineSeg[], bounds?: CanvasBounds, circles?: Circle[]): boolean; /** * A single thing that overlapped with the probed rect. Pipeline * consumers need this granularity to emit diagnostic records — the * `labelCollides` boolean tells you "it doesn't fit", but not "against * what", which is what an AI agent needs to choose a remediation. * * `index` points back into the corresponding input array so callers can * attach owner-element context (node id, connector id, …) without this * module knowing about element identity. */ export type CollisionHit = { kind: 'canvas-bounds'; } | { kind: 'label'; index: number; rect: LabelRect; } | { kind: 'line'; index: number; line: LineSeg; } | { kind: 'icon'; index: number; circle: Circle; }; /** * Return every collider the rect touches. Empty array ⇒ the slot is * clear. Ordered canvas-bounds → icons → labels → lines, matching the * mental priority of "is this even inside the canvas" then "does it * sit on an icon" etc. */ export declare function findCollisions(rect: LabelRect, labels: LabelRect[], lines: LineSeg[], bounds?: CanvasBounds, circles?: Circle[]): CollisionHit[]; /** * Compute the minimum distance from a point to a line segment. */ export declare function pointToSegDist(px: number, py: number, x1: number, y1: number, x2: number, y2: number): number; /** * Check if a line segment intersects a circle. * Returns true if the segment passes through the circle (center cx,cy radius r). */ export declare function lineIntersectsCircle(x1: number, y1: number, x2: number, y2: number, cx: number, cy: number, r: number): boolean; /** Check if a line segment intersects a rect */ export declare function lineIntersectsRect(x1: number, y1: number, x2: number, y2: number, rx: number, ry: number, rw: number, rh: number): boolean; //# sourceMappingURL=collision.d.ts.map