import type { FormulaAstNode } from "./formulaAst.mjs"; import type { FormulaPositionContext } from "./formulaTypes.mjs"; /** * Shifts every relative reference in a parsed formula by a positional delta — * the Excel fill-handle rule: a reference moves by the same `(rowDelta, * columnDelta)` as the cell it lives in, so `=A1*B1` dragged down one row * becomes `=A2*B2`. The delta is measured in the position context's units * (sorted + filtered visible order, 1-based), the same space the A1 display, * paste adjustment and `ROW_POSITION` use, so offsets can never disagree with * what the user sees. * * Single-cell selector semantics mirror `buildColumnSelector`/`buildRowSelector` * in `formulaA1.ts`: * - **Positional** selectors (`COLUMN_POSITION`/`ROW_POSITION`, the canonical * form of `$`-absolute refs) never shift — they are absolute. * - **Stable** selectors (`COLUMN("field")`/`ROW(id)`, the canonical form of * relative refs) re-anchor to the field/row now at `position + delta`. * - **Overshoot** past the last row/column freezes to a positional selector * that resolves to `#REF!` (and recovers if the grid later grows — consistent * with the engine's positional-out-of-range semantics). * - **Underflow** past the first row/column keeps the original reference: the * 1-based canonical store has no representable out-of-bounds-low position * (the parser rejects `ROW_POSITION(0)`), so the reference stays put rather * than corrupting the whole formula into `#ERROR!`. * * `RANGE_REF` windows: an `ANCHOR(delta)` axis copies verbatim — the offset is * relative to the formula's own cell, so moving the formula IS the adjustment * (the Sheets fill model, no arithmetic). A plain positional axis follows the * Excel `$` rule instead: it shifts by the delta (pure arithmetic — window * resolution auto-clips, so overshoot needs no special casing) with underflow * clamping at position 1, and a `FIXED(...)` axis never moves. * * Pure: engine types only, no grid imports. The walk is recursive, bounded by * the parser's AST-height limit exactly like the serializer and evaluator. */ export declare function offsetFormulaReferences(ast: FormulaAstNode, rowDelta: number, columnDelta: number, context: FormulaPositionContext): FormulaAstNode;