import type React from 'react';
import type { TextDisplay } from '../theme/types';
import type { BaseProps } from '../BaseProps';
import type { CitationSource } from '../Citation/Citation';
/**
 * A plugin that transforms text patterns into custom React elements
 * inside Markdown. Applied to parsed text nodes only — code blocks,
 * inline code, and other non-prose contexts are unaffected.
 *
 * Follows Lexical's TextMatchTransformer architecture:
 * - `pattern` for initial regex matching
 * - `getEndIndex` for programmatic boundary refinement
 * - `render` for producing the replacement element
 */
export interface MarkdownInlinePlugin {
    /** Regex with global flag. Matched against text nodes only. */
    pattern: RegExp;
    /**
     * Optional: refine the match boundary after the regex hits.
     * Return the end index, or false to reject the match.
     * Default: match.index + match[0].length
     */
    getEndIndex?: (text: string, match: RegExpMatchArray) => number | false;
    /** Render the match as a React element. */
    render: (match: RegExpMatchArray, key: string) => React.ReactNode;
}
/**
 * A citation source referenced inline in the markdown via `[id]` or `【id】`.
 * When `sources` is provided, bracket content matching a source key is rendered
 * as a compact superscript citation pill instead of plain text.
 */
export type MarkdownSource = CitationSource;
export interface MarkdownComponents {
    code?: React.ComponentType<{
        code: string;
        language?: string;
    }>;
    inlineCode?: React.ComponentType<{
        children: string;
    }>;
    citation?: React.ComponentType<{
        source: CitationSource;
        number: number;
        variant: 'label' | 'number';
    }>;
    link?: React.ComponentType<{
        href: string;
        children: React.ReactNode;
    }>;
    heading?: React.ComponentType<{
        level: 1 | 2 | 3 | 4 | 5 | 6;
        children: React.ReactNode;
    }>;
    paragraph?: React.ComponentType<{
        children: React.ReactNode;
    }>;
    image?: React.ComponentType<{
        src: string;
        alt: string;
    }>;
    blockquote?: React.ComponentType<{
        children: React.ReactNode;
    }>;
    hr?: React.ComponentType<object>;
}
export interface MarkdownProps extends BaseProps<HTMLElement> {
    ref?: React.Ref<HTMLDivElement> | React.Ref<HTMLSpanElement>;
    children: string;
    /**
     * Display type. Markdown defaults to block.
     * Use 'inline' for markdown spans embedded inside surrounding text.
     * @default 'block'
     */
    display?: TextDisplay;
    density?: 'default' | 'compact';
    /**
     * The HTML heading level that markdown `#` maps to.
     * Shifts all heading levels down to fit the surrounding page hierarchy.
     * E.g. headingLevelStart={3} renders `#` as h3, `##` as h4, `###` as h5.
     * Levels that would exceed h6 are clamped to h6.
     * @default 1
     */
    headingLevelStart?: 1 | 2 | 3 | 4 | 5 | 6;
    isStreaming?: boolean;
    onLinkClick?: (href: string, event: React.MouseEvent<HTMLAnchorElement>) => void | false;
    /**
     * Citation sources keyed by ID. When provided, `[id]` and `【id】` markers
     * in the markdown that match a key are rendered as citation chips.
     */
    sources?: Record<string, MarkdownSource>;
    /**
     * How citations are displayed inline.
     * - `'label'` (default) — chip with source title text, icon, and border
     * - `'number'` — compact numbered badge (1, 2, 3…)
     * @default 'label'
     */
    citationStyle?: 'label' | 'number';
    /**
     * Max width for prose content (paragraphs, headings, lists, blockquotes).
     * Tables and code blocks are unconstrained and can expand to the full
     * container width. Use for readable line lengths in wide layouts.
     *
     * @example
     * ```
     * <Markdown contentWidth={640}>{text}</Markdown>
     * ```
     */
    contentWidth?: number | string;
    /**
     * Alignment of prose content within the container when `contentWidth`
     * is narrower than the available space.
     * - 'start': left-aligned (default)
     * - 'center': centered
     * @default 'start'
     */
    contentAlign?: 'start' | 'center';
    components?: Partial<MarkdownComponents>;
    /**
     * Plugins that transform text patterns into custom React elements.
     * Applied to text nodes after parsing — code blocks and inline code
     * are unaffected. Patterns are matched in order; first match wins
     * for overlapping ranges.
     */
    inlinePlugins?: MarkdownInlinePlugin[];
    /**
     * Opt-in autolinking of bare URLs and emails inside text.
     * - `'gfm'` — GitHub-Flavored Markdown autolink-literal rules:
     *   `https?://…`, `www.…`, `<scheme:url>`, `<email>`, and bare
     *   `user@host` all become `<a>` links. Trailing sentence punctuation
     *   (`?!.,:*_~`) and unbalanced trailing `)` are excluded; matches inside
     *   code spans, code blocks, existing links, and image alt text are
     *   skipped.
     *
     * Default behavior (option unset) is unchanged — bare URLs render as
     * literal text.
     */
    autolink?: 'gfm';
}
/**
 * Renders a markdown string as Astryx components. Supports streaming with
 * smooth fade-in animation via isStreaming.
 *
 * @example
 * ```
 * <Markdown>
 *   {'# Hello\n\nThis is **bold** and _italic_ text.\n\n- Item one\n- Item two'}
 * </Markdown>
 * ```
 */
export declare function Markdown({ ref, children, display, density, headingLevelStart, isStreaming, onLinkClick, sources, citationStyle, contentWidth, contentAlign, components, inlinePlugins, autolink, xstyle, className, style, 'data-testid': testId, }: MarkdownProps): React.ReactElement;
export declare namespace Markdown {
    var displayName: string;
}
//# sourceMappingURL=Markdown.d.ts.map