import { MaybeGetter } from './utilities/callOrGet.js';
import { NodeType, ParseRule, Node as PmNode } from 'prosemirror-model';
import { Plugin } from 'prosemirror-state';
import { NodeView, EditorView, Decoration, DecorationSource } from 'prosemirror-view';
import { InputRule } from './InputRule.js';
import { Editor } from './Editor.js';
import { Command } from './types/ChainedCommands.js';
import { AttributeSpec, AttributeValue } from './Attribute.js';
/**
 * Attribute object accepted inside a `SuperDocDOMOutputSpec` tuple.
 * Runtime `setAttribute` coerces non-string values, so number /
 * boolean / null / undefined are accepted alongside string.
 */
export type RenderDOMAttrs = Record<string, string | number | boolean | null | undefined>;
/**
 * Tuple branch of `SuperDocDOMOutputSpec`, declared as an interface
 * to break TypeScript's direct-recursion check (PM's upstream
 * `readonly [string, ...any[]]` avoids this because `any` swallows
 * the recursion; we cannot replicate that with `unknown`). The
 * interface form defers the self-reference through a named type,
 * which TS accepts.
 *
 * The shape mirrors PM's tuple convention: index 0 is the tagName,
 * subsequent items are an optional attrs object, the literal `0`
 * (content hole), or nested specs. Both readonly and mutable
 * arrays satisfy this interface because `ReadonlyArray` is the
 * supertype of `Array`.
 */
export interface SuperDocDOMOutputSpecTuple extends ReadonlyArray<SuperDocDOMOutputSpec | RenderDOMAttrs | 0> {
    readonly 0: string;
}
/**
 * Public DOM rendering output spec for `NodeConfig.renderDOM`.
 * Mirrors ProseMirror's `DOMOutputSpec` shape but replaces the
 * upstream `readonly [string, ...any[]]` tuple branch with the
 * `SuperDocDOMOutputSpecTuple` interface above, so the public type
 * surface does not leak `any` through the SD-3213 supported-root
 * audit.
 *
 * `globalThis.Node` is used to disambiguate from the editor `Node`
 * class exported from this same file.
 */
export type SuperDocDOMOutputSpec = string | globalThis.Node | {
    dom: globalThis.Node;
    contentDOM?: HTMLElement;
} | SuperDocDOMOutputSpecTuple;
/**
 * Public function signature for `NodeConfig.renderDOM`. Function-only
 * (not `MaybeGetter`) because the runtime in
 * `packages/super-editor/src/editors/v1/core/Schema.js:99` invokes
 * `renderDOM({ node, htmlAttributes })` directly with no
 * `callOrGet()` wrapper. Typing it as `MaybeGetter<T>` would
 * advertise a direct-value form that throws `TypeError` at runtime.
 *
 * `htmlAttributes` is the `Record<string, AttributeValue>` that
 * `Attribute.getAttributesToRender()` returns at runtime.
 */
export type RenderDOMFn = (props: {
    node: PmNode;
    htmlAttributes: Record<string, AttributeValue>;
}) => SuperDocDOMOutputSpec;
/**
 * Configuration for Node extensions.
 *
 * @typeParam Options - Type for node options.
 * @typeParam Storage - Type for node storage.
 * @typeParam Attrs - Type for node attributes (optional, enables typed addAttributes).
 */
export interface NodeConfig<Options extends Record<string, unknown> = Record<string, never>, Storage extends Record<string, unknown> = Record<string, never>, Attrs extends Record<string, unknown> = Record<string, unknown>> {
    /** The node name */
    name: string;
    /** The node group */
    group?: string;
    /** The node options */
    options?: Options;
    /** Whether the node is an atom node */
    atom?: boolean;
    /** Whether the node is draggable */
    draggable?: boolean;
    /** Whether the node is isolating */
    isolating?: boolean;
    /** Whether the node is defining */
    defining?: boolean;
    /** Whether the node is a top-level node */
    topNode?: boolean;
    /** The role of the node in a table */
    tableRole?: string;
    /** ProseMirror string for what content this node accepts */
    content?: MaybeGetter<string, []>;
    /** The marks applied to this node */
    marks?: string;
    /** Whether the node is an inline node */
    inline?: boolean;
    /** Whether the node is selectable */
    selectable?: boolean;
    /** The ProseMirror node type (set at runtime) */
    type?: NodeType;
    /** The editor instance (set at runtime) */
    editor?: Editor;
    /** The DOM parsing rules */
    parseDOM?: MaybeGetter<ParseRule[]>;
    /**
     * The DOM rendering function for the node. Receives
     * `{ node, htmlAttributes }` at runtime (see `Schema.js:99`) and
     * returns a `SuperDocDOMOutputSpec`: a public local alias
     * mirroring ProseMirror's `DOMOutputSpec` shape but with an
     * unknown-free tuple branch.
     *
     * Typed as a plain function (`RenderDOMFn`) rather than
     * `MaybeGetter<SuperDocDOMOutputSpec>` because the runtime only
     * invokes the function form. A direct-value `renderDOM: ['br']`
     * type-checks under `MaybeGetter<T>` but throws `TypeError` at
     * runtime. Narrowing the type aligns the public contract with
     * what the runtime actually supports.
     */
    renderDOM?: RenderDOMFn;
    /** Function or object to add options to the node */
    addOptions?: MaybeGetter<Options>;
    /** Function or object to add storage to the node */
    addStorage?: MaybeGetter<Storage>;
    /**
     * Function or object to add attributes to the node.
     * When Attrs generic is provided, attribute keys are validated against it.
     */
    addAttributes?: MaybeGetter<{
        [K in keyof Attrs]?: Partial<AttributeSpec>;
    }>;
    /** Function or object to add commands to the node */
    addCommands?: MaybeGetter<Record<string, Command>>;
    /** Function or object to add helpers to the node */
    addHelpers?: MaybeGetter<Record<string, (...args: unknown[]) => unknown>>;
    /** Function or object to add shortcuts to the node */
    addShortcuts?: MaybeGetter<Record<string, Command>>;
    /** Function or object to add input rules to the node */
    addInputRules?: MaybeGetter<InputRule[]>;
    /** Function to add a custom node view to the node */
    addNodeView?: MaybeGetter<(props: {
        node: PmNode;
        view: EditorView;
        getPos: () => number | undefined;
        decorations: readonly Decoration[];
        innerDecorations: DecorationSource;
    }) => NodeView | null>;
    /** Function to add ProseMirror plugins to the node */
    addPmPlugins?: MaybeGetter<Plugin<unknown>[]>;
    /** Function to extend the ProseMirror node schema */
    extendNodeSchema?: MaybeGetter<Record<string, unknown>>;
    /** Additional config fields - use with caution */
    [key: string]: unknown;
}
/**
 * Node class is used to create Node extensions.
 *
 * @typeParam Options - Type for node options.
 * @typeParam Storage - Type for node storage.
 * @typeParam Attrs - Type for node attributes (enables typed attribute access).
 */
export declare class Node<Options extends Record<string, unknown> = Record<string, never>, Storage extends Record<string, unknown> = Record<string, never>, Attrs extends Record<string, unknown> = Record<string, unknown>> {
    type: NodeType | string;
    name: string;
    options: Options;
    group: string | undefined;
    atom: boolean | undefined;
    editor: Editor | undefined;
    storage: Storage;
    config: NodeConfig<Options, Storage, Attrs>;
    /**
     * Type hint for the attributes this node uses.
     * Not used at runtime, but enables type inference.
     */
    readonly __attrsType: Attrs;
    constructor(config: NodeConfig<Options, Storage, Attrs>);
    /**
     * Factory method to construct a new Node extension.
     * @param config - The node configuration.
     * @returns A new Node instance.
     */
    static create<O extends Record<string, unknown> = Record<string, never>, S extends Record<string, unknown> = Record<string, never>, A extends Record<string, unknown> = Record<string, unknown>>(config: NodeConfig<O, S, A>): Node<O, S, A>;
}
//# sourceMappingURL=Node.d.ts.map