/** * Geometry helpers for framing a finding on the page. * * `computeFitScale` returns the transform scale that fits a rectangle * into the viewport with padding (clamped to the viewer's zoom limits); * `unionBbox` collapses a finding's bbox + regions into one bounding * rect so a multi-region finding frames as a single group. * * Pure + side-effect free so the zoom math is unit-testable without a * DOM or the react-zoom-pan-pinch runtime. * * @module */ import type { OverlayItem } from "./types"; /** PDF-points bounding box: ``[x0, y0, x1, y1]`` (origin lower-left). */ export type Bbox = readonly [number, number, number, number]; export interface FitScaleOptions { /** CSS-px gap kept between the framed rect and each viewport edge. */ padding?: number; /** Lower zoom bound (transform scale, 1 = 100%). */ minScale?: number; /** Upper zoom bound — stops a tiny finding zooming to a blurry crop. */ maxScale?: number; } /** * Scale (1 = 100%) that frames a ``rectWidthPx × rectHeightPx`` * rectangle inside a ``viewportWidthPx × viewportHeightPx`` viewport, * leaving ``padding`` px around it, clamped to ``[minScale, maxScale]``. * * Degenerate inputs (non-positive rect or viewport) fall back to a * clamped 1.0 so a caller never divides by zero or applies NaN. */ export declare function computeFitScale(rectWidthPx: number, rectHeightPx: number, viewportWidthPx: number, viewportHeightPx: number, options?: FitScaleOptions): number; /** * Smallest bbox covering every rect in ``rects``, or ``null`` when the * list is empty. Corners are normalized, so a rect that arrives with * swapped ``x0/x1`` or ``y0/y1`` still contributes correctly. */ export declare function unionBbox(rects: readonly Bbox[]): Bbox | null; /** * Every locatable rect on a finding: its ``bbox`` (when present) * followed by each entry in ``regions``. Empty for page-level / * loc-less findings, which the viewer surfaces in the sidebar but * never draws or frames. */ export declare function collectItemRects(item: OverlayItem): Bbox[]; /** Union of all of a finding's rects, or ``null`` when loc-less. */ export declare function itemFocusBbox(item: OverlayItem): Bbox | null; /** * Element-wise equality on two bboxes (treating ``null`` as a valid * value). Used by the substrate's focus effect to dedupe re-framing: * if a finding's id stays the same but its bbox/regions change * (e.g. live preflight enriches it in place), we still want to * re-fit, but rapid re-renders that hand us an equivalent rect * shouldn't yank the view back. */ export declare function rectsEqual(a: Bbox | null, b: Bbox | null): boolean; //# sourceMappingURL=fit.d.ts.map