import type MarkdownIt from 'markdown-it';
import OrderedMap from 'orderedmap';
import { inputRules } from 'prosemirror-inputrules';
import type { MarkSpec, NodeSpec, Schema } from 'prosemirror-model';
import type { Plugin } from 'prosemirror-state';
import type { Logger2 } from "../logger.js";
import type { ActionSpec, ActionStorage } from "./types/actions.js";
import type { Keymap } from "./types/keymap.js";
import type { MarkViewConstructor, NodeViewConstructor } from "./types/node-views.js";
import type { Parser, ParserToken } from "./types/parser.js";
import type { Serializer, SerializerMarkToken, SerializerNodeToken } from "./types/serializer.js";
type InputRulesConfig = Parameters<typeof inputRules>[0];
type ConfigureMdParams = {
    /**
     * Apply this configurtion to text parser
     * @default true
     */
    text?: boolean;
    /**
     * Apply this configurtion to markup parser
     * @default true
     */
    markup?: boolean;
};
type ConfigureMdCallback = (md: MarkdownIt) => MarkdownIt;
type AddPmNodeCallback = () => ExtensionNodeSpec;
type AddPmMarkCallback = () => ExtensionMarkSpec;
type AddPmPluginCallback = (deps: ExtensionDeps) => Plugin | Plugin[];
type AddPmKeymapCallback = (deps: ExtensionDeps) => Keymap;
type AddPmInputRulesCallback = (deps: ExtensionDeps) => InputRulesConfig;
type AddActionCallback = (deps: ExtensionDeps) => ActionSpec;
declare enum Priority {
    Highest = 1000000,
    VeryHigh = 100000,
    High = 10000,
    Medium = 1000,
    Low = 100,
    VeryLow = 10,
    Lowest = 0
}
type BuilderContext<T extends object> = {
    has(key: keyof T): boolean;
    get<K extends keyof T>(key: K): T[K] | undefined;
    set<K extends keyof T>(key: K, value: T[K]): BuilderContext<T>;
};
declare global {
    namespace WysiwygEditor {
        interface Context {
        }
    }
}
export type Extension = (builder: ExtensionBuilder) => void;
export type ExtensionWithOptions<T> = (builder: ExtensionBuilder, options: T) => void;
export type ExtensionAuto<T = void> = T extends void ? Extension : ExtensionWithOptions<T>;
export type ExtensionSpec = {
    configureMd(md: MarkdownIt, parserType: 'text' | 'markup'): MarkdownIt;
    nodes(): OrderedMap<ExtensionNodeSpec>;
    marks(): OrderedMap<ExtensionMarkSpec>;
    plugins(deps: ExtensionDeps): Plugin[];
    actions(deps: ExtensionDeps): Record<string, ActionSpec>;
};
export type ExtensionNodeSpec = {
    spec: NodeSpec;
    view?: (deps: ExtensionDeps) => NodeViewConstructor;
    fromMd: {
        tokenName?: string;
        tokenSpec: ParserToken;
    };
    toMd: SerializerNodeToken;
};
export type ExtensionMarkSpec = {
    spec: MarkSpec;
    view?: (deps: ExtensionDeps) => MarkViewConstructor;
    fromMd: {
        tokenName?: string;
        tokenSpec: ParserToken;
    };
    toMd: SerializerMarkToken;
};
export type ExtensionDeps = {
    readonly schema: Schema;
    readonly textParser: Parser;
    readonly markupParser: Parser;
    readonly serializer: Serializer;
    readonly actions: ActionStorage;
};
export declare class ExtensionBuilder {
    #private;
    static createContext(): BuilderContext<WysiwygEditor.Context>;
    static readonly Priority: typeof Priority;
    readonly Priority: typeof Priority;
    readonly context: BuilderContext<WysiwygEditor.Context>;
    constructor(logger: Logger2.ILogger, context?: BuilderContext<WysiwygEditor.Context>);
    get logger(): Logger2.ILogger;
    use(extension: Extension): this;
    use<T>(extension: ExtensionWithOptions<T>, options: T): this;
    configureMd(cb: ConfigureMdCallback, params?: ConfigureMdParams): this;
    hasNodeSpec(name: string): boolean;
    hasMarkSpec(name: string): boolean;
    /**
     * @deprecated Will be removed in the next major version.
     * Use addNodeSpec() + addMarkdownTokenParserSpec() + addNodeSerializerSpec() instead.
     */
    addNode(name: string, cb: AddPmNodeCallback): this;
    /**
     * @deprecated Will be removed in the next major version.
     * Use addMarkSpec() + addMarkdownTokenParserSpec() + addMarkSerializerSpec() instead.
     */
    addMark(name: string, cb: AddPmMarkCallback, priority?: Priority): this;
    addPlugin(cb: AddPmPluginCallback, priority?: Priority): this;
    addKeymap(cb: AddPmKeymapCallback, priority?: Priority): this;
    addInputRules(cb: AddPmInputRulesCallback, priority?: Priority): this;
    addAction(name: string, cb: AddActionCallback): this;
    addNodeSpec(name: string, cb: () => NodeSpec): this;
    addMarkSpec(name: string, cb: () => MarkSpec, priority?: Priority): this;
    addMarkdownTokenParserSpec(tokenName: string, cb: () => ParserToken): this;
    addNodeSerializerSpec(name: string, cb: () => SerializerNodeToken): this;
    addMarkSerializerSpec(name: string, cb: () => SerializerMarkToken): this;
    overrideNodeSpec(name: string, cb: (prev: NodeSpec) => NodeSpec): this;
    overrideMarkSpec(name: string, cb: (prev: MarkSpec) => MarkSpec): this;
    overrideMarkdownTokenParserSpec(tokenName: string, cb: (prev: ParserToken) => ParserToken): this;
    overrideNodeSerializerSpec(name: string, cb: (prev: SerializerNodeToken) => SerializerNodeToken): this;
    overrideMarkSerializerSpec(name: string, cb: (prev: SerializerMarkToken) => SerializerMarkToken): this;
    build(): ExtensionSpec;
}
export {};
