import { Layout, FlowBlock, ParagraphBlock, Measure } from '../../contracts/src/index.js';
import { DisplayPageInfo } from './pageNumbering.js';
/**
 * Numbering context for page token resolution.
 * Contains display page information for each physical page in the document.
 */
export interface NumberingContext {
    /** Total number of pages in the document */
    totalPages: number;
    /** Display page information for each page (indexed by physical page number - 1) */
    displayPages: DisplayPageInfo[];
}
/**
 * Result of page number token resolution.
 * Contains affected block IDs and their updated clones.
 */
export interface ResolvePageTokensResult {
    /** Set of block IDs that had tokens resolved */
    affectedBlockIds: Set<string>;
    /** Map of block ID to updated block clone (only for affected blocks) */
    updatedBlocks: Map<string, FlowBlock>;
}
/**
 * Resolves page number and total page count tokens in document blocks using layout and numbering context.
 *
 * This function walks through all pages and fragments in the layout, finding blocks with
 * page number tokens. For each affected block, it creates a clone with resolved token text,
 * using section-aware display page numbers from the numbering context.
 *
 * The function does NOT mutate original blocks - it returns clones of affected blocks.
 * This ensures thread-safety and allows for clean rollback if re-measurement fails.
 *
 * @param layout - Completed layout with page-numbered fragments
 * @param blocks - Original FlowBlocks array (will not be mutated)
 * @param measures - Measure array (parallel to blocks, used to detect hasPageTokens flag)
 * @param numberingCtx - Numbering context with display page info and total pages
 * @returns Result containing affected block IDs and updated block clones
 *
 * @example
 * ```typescript
 * const layout = layoutDocument(blocks, measures, options);
 * const numberingCtx = buildNumberingContext(layout, sections);
 * const result = resolvePageNumberTokens(layout, blocks, measures, numberingCtx);
 *
 * if (result.affectedBlockIds.size > 0) {
 *   // Re-measure affected blocks and re-run pagination
 *   const updatedBlocks = blocks.map(b => result.updatedBlocks.get(b.id) ?? b);
 *   // ... remeasure and re-layout ...
 * }
 * ```
 */
export declare function resolvePageNumberTokens(layout: Layout, blocks: FlowBlock[], measures: Measure[], numberingCtx: NumberingContext): ResolvePageTokensResult;
/**
 * Resolves page number tokens in paragraph blocks.
 *
 * This is a helper function that processes a single paragraph block's runs,
 * resolving any pageNumber or totalPageCount tokens. It's designed to be called
 * from the layout pipeline where both the layout and blocks are available.
 *
 * @param block - Paragraph block to process
 * @param pageNumber - Current page number (1-indexed)
 * @param totalPages - Total number of pages in the document
 * @returns True if any tokens were resolved in this block
 *
 * @example
 * ```typescript
 * const wasModified = resolveTokensInBlock(paragraphBlock, 3, 10);
 * if (wasModified) {
 *   // Block was modified, may need re-measurement
 * }
 * ```
 */
export declare function resolveTokensInBlock(block: ParagraphBlock, pageNumber: number, totalPages: number): boolean;
//# sourceMappingURL=resolvePageTokens.d.ts.map