import { Query, TextAddress, UnknownNodeDiagnostic } from '@superdoc/document-api';
import { BlockIndex } from './node-address-resolver.js';
import { Editor } from '../../core/Editor.js';
export type WithinResult = {
    ok: true;
    range: {
        start: number;
        end: number;
    } | undefined;
} | {
    ok: false;
};
export type ResolvedTextTarget = {
    from: number;
    to: number;
};
/**
 * Resolves a {@link TextAddress} to absolute ProseMirror positions.
 *
 * @param editor - The editor instance.
 * @param target - The text address to resolve.
 * @returns Absolute `{ from, to }` positions, or `null` if the target block cannot be found.
 * @throws {DocumentApiAdapterError} `INVALID_TARGET` when multiple text blocks share the same blockId.
 */
export declare function resolveTextTarget(editor: Editor, target: TextAddress): ResolvedTextTarget | null;
/**
 * Resolves the deterministic default insertion target for insert-without-target calls.
 *
 * Priority:
 * 1) First paragraph block in document order.
 * 2) First editable text block in document order.
 */
export declare function resolveDefaultInsertTarget(editor: Editor): {
    target: TextAddress;
    range: ResolvedTextTarget;
} | null;
/**
 * Appends a diagnostic message to the mutable diagnostics array.
 *
 * @param diagnostics - Array to push the diagnostic into.
 * @param message - Human-readable diagnostic message.
 */
export declare function addDiagnostic(diagnostics: UnknownNodeDiagnostic[], message: string): void;
/**
 * Applies offset/limit pagination to an array, returning the total count and the sliced page.
 *
 * @param items - The full result array.
 * @param offset - Number of items to skip (default `0`).
 * @param limit - Maximum items to return (default: all remaining).
 * @returns An object with `total` (pre-pagination count) and `items` (the sliced page).
 */
export declare function paginate<T>(items: T[], offset?: number, limit?: number): {
    total: number;
    items: T[];
};
/**
 * Deduplicates diagnostics by message + hint + address, preserving insertion order.
 *
 * @param diagnostics - The diagnostics to deduplicate.
 * @returns A new array with unique diagnostics.
 */
export declare function dedupeDiagnostics(diagnostics: UnknownNodeDiagnostic[]): UnknownNodeDiagnostic[];
/**
 * Resolves the `within` scope of a query to an absolute position range.
 *
 * @param index - Pre-built block index.
 * @param query - The query whose `within` clause should be resolved.
 * @param diagnostics - Mutable array to collect diagnostics into.
 * @returns `{ ok: true, range }` on success (range is `undefined` when no scope), or `{ ok: false }` with a diagnostic.
 */
export declare function resolveWithinScope(index: BlockIndex, query: Query, diagnostics: UnknownNodeDiagnostic[]): WithinResult;
/**
 * Filters candidates to those fully contained within the given position range.
 * Returns the full array unchanged when `range` is `undefined`.
 *
 * @param candidates - Candidates with `pos` and `end` fields.
 * @param range - Optional absolute position range to filter by.
 * @returns Filtered candidates.
 */
export declare function scopeByRange<T extends {
    pos: number;
    end: number;
}>(candidates: T[], range: {
    start: number;
    end: number;
} | undefined): T[];
/**
 * Binary-searches a sorted candidate array for the entry containing `pos`.
 * Uses half-open interval `[candidate.pos, candidate.end)`.
 *
 * @param candidates - Sorted array of candidates with `pos` and `end` fields.
 * @param pos - The absolute document position to look up.
 * @returns The matching candidate, or `undefined` if no candidate contains the position.
 */
export declare function findCandidateByPos<T extends {
    pos: number;
    end: number;
}>(candidates: T[], pos: number): T | undefined;
//# sourceMappingURL=adapter-utils.d.ts.map