/**
 * Markdown Parser for Section-Aware Chunking
 *
 * Parses Datalab markdown output into structural blocks with section hierarchy,
 * enabling the hybrid chunker to make intelligent split decisions.
 *
 * @module services/chunking/markdown-parser
 */
import { PageOffset } from '../../models/document.js';
/** Classification of a markdown text block */
export type MarkdownBlockType = 'heading' | 'table' | 'code' | 'list' | 'paragraph' | 'page_marker' | 'empty';
/** A single structural block parsed from markdown */
export interface MarkdownBlock {
    type: MarkdownBlockType;
    text: string;
    startOffset: number;
    endOffset: number;
    headingLevel: number | null;
    headingText: string | null;
    pageNumber: number | null;
}
/** Section hierarchy node */
export interface SectionNode {
    level: number;
    text: string;
    path: string;
}
/**
 * Parse markdown text into structural blocks.
 *
 * Splits text by double-newline separators, classifies each segment by type
 * (heading, table, code, list, paragraph, page_marker, empty), and tracks
 * character offsets and page numbers.
 *
 * @param text - The full markdown text from Datalab OCR output
 * @param pageOffsets - Page offset information for page number assignment
 * @returns Array of MarkdownBlock with type, offsets, and page info
 */
export declare function parseMarkdownBlocks(text: string, pageOffsets: PageOffset[]): MarkdownBlock[];
/**
 * Build a section hierarchy map from parsed markdown blocks.
 *
 * Walks the blocks in order, maintaining a heading stack. Each block
 * (heading or content) is mapped to its SectionNode, which includes
 * the heading level, text, and full path (e.g., "Intro > Background > History").
 *
 * @param blocks - Array of MarkdownBlock from parseMarkdownBlocks
 * @returns Map from block index to SectionNode. Blocks before any heading
 *   will not have an entry in the map.
 */
export declare function buildSectionHierarchy(blocks: MarkdownBlock[]): Map<number, SectionNode>;
/**
 * Find the page number for a given character offset using binary search.
 *
 * @param charOffset - The character offset to look up
 * @param pageOffsets - Sorted array of page offset ranges
 * @returns The 1-indexed page number, or null if pageOffsets is empty
 */
export declare function getPageNumberForOffset(charOffset: number, pageOffsets: PageOffset[]): number | null;
/**
 * Check if a segment is a markdown table
 */
/**
 * Extract page offsets from markdown text by scanning for Datalab page markers.
 *
 * This is used when re-chunking already-OCR'd documents where the original
 * pageOffsets from Datalab are no longer available.
 * The function reconstructs page boundaries from the `---\n<!-- Page N -->`
 * markers embedded in the markdown text.
 *
 * @param text - The full markdown text containing Datalab page markers
 * @returns Array of PageOffset sorted by page number, or empty array if no markers found
 */
export declare function extractPageOffsetsFromText(text: string): PageOffset[];
//# sourceMappingURL=markdown-parser.d.ts.map