import type { Run } from '../../..';
import type { HashedGraphNode, StepFunction } from '../utils';
/**
 * Computes the rebased URL for a relative link when content is moved
 * from one file location to another.
 *
 * Returns null if the URL should not be rebased (external, absolute, anchor-only).
 */
export declare function rebaseUrl(url: string, fromDir: string, toDir: string): string | null;
/**
 * Rebases all relative markdown links, images, and link definitions
 * in content from one file location to another.
 *
 * Skips content inside fenced code blocks.
 */
export declare function rebaseRelativePaths(content: string, fromPath: NormalizedPath, toPath: NormalizedPath): string;
export declare function stripHash(link: string): string;
type TermBlock = {
    key: string;
    block: string;
};
/**
 * Extracts term definition blocks from markdown content.
 * In multiline mode, each definition runs from `[*key]:` to the next
 * `[*key]:` or EOF.  Returns clean content (without the term section)
 * and the individual term blocks.
 */
export declare function extractTermDefinitions(content: string): {
    cleanContent: string;
    terms: TermBlock[];
};
/**
 * Returns true if the content contains a top-level CommonMark HTML block
 * of **type 1** (`<script>`, `<style>`, `<pre>`, `<textarea>`) that starts
 * at the very beginning of a line (column 0).
 *
 * Type-1 blocks are special: they are NOT interrupted by blank lines and
 * break rendering when placed inside a list item with any non-zero indent —
 * markdown-it parses them as plain text rather than HTML blocks.
 *
 * Other HTML (type 6: `<div>`, `<a>`, etc.) works correctly inside list
 * items regardless of indent, so it does NOT trigger this check.
 */
export declare function hasTopLevelHtmlBlock(content: string): boolean;
export declare function canInlineInclude(dep: HashedGraphNode, parentContent: string, checkTermBoundary?: boolean): boolean;
/**
 * Strips the first heading from markdown content (for `notitle` includes).
 * Also removes the trailing empty line after the heading if present.
 *
 * If the result is empty (e.g. `#hash` + `notitle` on a section that is
 * only a heading line, like a single `#### {#id}` block) we deliberately
 * return empty content: the author wrote `notitle`, asking for the title
 * to be removed.  Returning the original heading as a fallback would
 * silently contradict the directive and produce different output from
 * the md→html path (which also yields empty content in that case).
 */
export declare function stripFirstHeading(content: string): string;
/**
 * Adds indentation to all lines of content except the first line (which
 * is already preceded by indent in the parent).
 *
 * Empty lines are normally NOT indented to avoid trailing whitespace,
 * EXCEPT when they fall inside a CommonMark HTML block of types 1–5
 * (e.g. multi-line `<!-- ... -->` comments).  Such blocks are not
 * interrupted by blank lines per spec, but markdown-it’s list-item
 * parser treats an unindented blank line as the boundary of the HTML
 * block and breaks the surrounding list / cut / blockquote.  Indenting
 * the blank line keeps the HTML block continuous and the parent
 * structure intact.
 *
 * Preserves original line endings (\r\n, \r, \n) for cross-platform support.
 */
export declare function addIndent(content: string, indent: string): string;
/**
 * Extracts a section from markdown content by anchor.
 *
 * For heading anchors: returns content from the matched heading to the
 * next heading of the **same** level (matches transform `findBlockTokens`),
 * or EOF.
 *
 * For paragraph anchors ({#id} in non-heading text): returns just
 * the paragraph containing the anchor.
 *
 * Skips fenced code blocks so that headings inside them do not
 * prematurely terminate the section.
 */
export declare function extractSection(content: string, hash: string): string;
type FallbackEntry = {
    key: string;
    content: string;
};
/**
 * Recursively collects fallback deps from a sub-tree where the parent
 * was inlined. Keys are rebased (no colon-chain) because the parent's
 * path has been absorbed into the root.
 */
export declare function collectFallbackDepsForInlined(deps: HashedGraphNode[], depPath: NormalizedPath, rootPath: NormalizedPath, seen: Set<string>, parentProcessedContent?: string): FallbackEntry[];
/**
 * Recursively collects all deps as {% included %} fallback entries
 * with colon-chain keys (for non-inlined parent deps).
 */
export declare function collectFallbackDepsWithChain(deps: HashedGraphNode[], parentKey: string, seen: Set<string>): FallbackEntry[];
/**
 * Prepares content from a dependency for inlining: strips frontmatter,
 * extracts section by hash, optionally removes the first heading (notitle),
 * extracts term definitions (collecting them via termsCollector),
 * rebases paths, applies indentation, and adds source map comments.
 *
 * @param trailingSuffix - When the include directive is followed by a YFM
 *   table separator (`||` or `|#`) on the same line, pass that separator
 *   here.  It will be appended on a new line after the inlined content so
 *   that the table structure is preserved.
 */
export declare function prepareInlinedContent(dep: HashedGraphNode, entry: NormalizedPath, parentContent: string, enableSourceMaps?: boolean, termsCollector?: Array<TermBlock & {
    sourcePath: string;
}>, trailingSuffix?: string): string;
/**
 * Adds a non-inlined dependency as a {% included %} fallback entry,
 * including its transitive deps with colon-chain keys.
 */
export declare function addFallbackDep(dep: HashedGraphNode, seen: Set<string>, entries: FallbackEntry[]): void;
/**
 * Merge includes plugin (Steps 1–4).
 *
 * For each include dep:
 * - Standalone includes before the term section are inlined, with indent,
 *   hash, and term extraction support.
 * - When `multilineTermDefinitions` is true:
 *   - Includes inside the term section (after first [*key]:) are resolved
 *     inline when `canInlineInclude(..., false)` allows; otherwise
 *     `{% included %}` fallback (e.g. GFM `**…|…**` table headers in the dep).
 *   - Term definitions from root and inlined deps are extracted, deduplicated,
 *     and appended at the end of the file.
 * - When `multilineTermDefinitions` is false:
 *   - Includes after the first term def use {% included %} fallback
 *     (term definitions are left as-is).
 * - Non-standalone includes always use {% included %} fallback blocks.
 *
 * @param rootMode - When true (entry file), adds fallback blocks and term
 *   sections at the end.  When false (dep files), only inlines standalone
 *   includes so that nested include chains are resolved bottom-up.
 */
export declare function mergeIncludes(run: Run, deps: HashedGraphNode[], parentContent: string, enableSourceMaps?: boolean, rootMode?: boolean): StepFunction;
export {};
