import { CharNode } from "../models";
import { GveRenditionSettings } from "../settings/settings";
import { Logger } from "../core/logger";
/**
 * Position information for a character node.
 */
export interface CharPosition {
    x: number;
    y: number;
    nodeId: number;
    lineNumber: number;
}
/**
 * Text layout calculator.
 * Handles positioning of base text characters, respecting line breaks,
 * spaces, and character offsets.
 */
export declare class TextLayout {
    private _settings;
    private _logger;
    private _spaceWidth;
    /**
     * The SVG element used as the measurement context for text width calculations.
     * This ensures measurements happen in the same CSS context as actual rendering,
     * which is critical when the component runs inside frameworks like Angular
     * that may apply global CSS styles affecting font metrics.
     *
     * When this is undefined, measurements fall back to document.body (legacy behavior)
     * which can cause position mismatches if global styles differ from Shadow DOM styles.
     */
    private _measurementRoot?;
    constructor(settings: GveRenditionSettings, logger: Logger);
    /**
     * Set the measurement root for text width calculations.
     * This should be called with the root SVG element after it's created,
     * before any layout calculations are performed.
     *
     * IMPORTANT: This ensures text measurements happen in the same CSS context
     * as actual rendering (inside Shadow DOM), avoiding position mismatches
     * caused by different font metrics in document.body vs Shadow DOM.
     *
     * @param root - The SVG element to use as measurement context
     */
    setMeasurementRoot(root: SVGElement): void;
    /**
     * Calculate the width of a space character based on reference character.
     */
    private calculateSpaceWidth;
    /**
     * Calculate positions for all base text nodes.
     *
     * @param nodes - The character nodes to position
     * @param charOffsets - Map of node IDs to their offset overrides (from r_char-offsets feature).
     *   Offset values may be plain numbers (px) or strings with units "tw"/"th"
     *   (average character width / height of the current font).
     * @returns Array of character positions
     */
    calculateBaseTextPositions(nodes: CharNode[], charOffsets?: Map<number, {
        x?: number | string;
        y?: number | string;
    }>): CharPosition[];
    /**
     * Calculate position for a single additional text node.
     * Additional text positioning is driven by rendition features.
     *
     * @param referencePosition - The position to use as reference (e.g., from RBR)
     * @param position - Position type (n, ne, e, se, s, sw, w, nw, o)
     * @param offsetX - X offset (can be number or string like "0.5th")
     * @param offsetY - Y offset (can be number or string like "0.5tw")
     * @param refBounds - Reference bounding rectangle dimensions
     * @returns Calculated position
     */
    calculateAdditionalTextPosition(referencePosition: {
        x: number;
        y: number;
    }, position: string, offsetX: number, offsetY: number, refBounds: {
        width: number;
        height: number;
    }): {
        x: number;
        y: number;
    };
    /**
     * Get the line number for a given node ID from positions.
     */
    getLineNumber(positions: CharPosition[], nodeId: number): number;
    /**
     * Get all positions for a specific line.
     */
    getLinePositions(positions: CharPosition[], lineNumber: number): CharPosition[];
    /**
     * Update settings and recalculate space width.
     */
    updateSettings(settings: GveRenditionSettings): void;
    /**
     * Get the computed space width.
     */
    getSpaceWidth(): number;
}
