import { VOrientationType } from '../../domain/constants/enum';
import { Doc } from '../view/Doc';
import { WidgetMeta } from '../widget/widget-meta';
export interface CursorMeta {
    nodeId: string;
    offset: number;
    modelId?: string;
    side?: 'before' | 'after';
}
export type CommandResult = CursorMeta | CursorMeta[] | null | undefined;
export type CommandCallback = (result: CommandResult, output?: any) => void;
export type CommandPayload = {
    doCallback?: CommandCallback;
    undoCallback?: CommandCallback;
};
export type CommandPayloadWithoutCb = Omit<CommandPayload, 'doCallback' | 'undoCallback'>;
export interface ICommand<T extends CommandType = CommandType> {
    do(): Promise<CommandResult>;
    undo(): Promise<CommandResult>;
    payload?: CommandPayloadMap[T];
    output?: any;
    isTerminated: boolean;
    needsReLayout: boolean;
}
export type CommandConstructor = new (doc: Doc, payload?: any) => ICommand<any>;
export declare const CommandType: {
    readonly setOrient: "setOrient";
    readonly setPadding: "setPadding";
    readonly insertText: "insertText";
    readonly insertTable: "insertTable";
    readonly insertImage: "insertImage";
    readonly insertField: "insertField";
    readonly insertWidget: "insertWidget";
    readonly delete: "delete";
    readonly backspace: "backspace";
    readonly enter: "enter";
    readonly setColor: "setColor";
    readonly setBold: "setBold";
    readonly setItalic: "setItalic";
    readonly setFont: "setFont";
    readonly setFontSize: "setFontSize";
    readonly setUnderline: "setUnderline";
    readonly setStrike: "setStrike";
    readonly setAlign: "setAlign";
    readonly setRepeating: "setRepeating";
    readonly setBounded: "setBounded";
    readonly setBoundedItem: "setBoundedItem";
    readonly deleteRepeating: "deleteRepeating";
    readonly deleteBounded: "deleteBounded";
    readonly deleteBoundedItem: "deleteBoundedItem";
    readonly insertRow: "insertRow";
    readonly insertCol: "insertCol";
    readonly deleteRow: "deleteRow";
    readonly deleteCol: "deleteCol";
    readonly mergeCells: "mergeCells";
    readonly unmergeCells: "unmergeCells";
    readonly snapshot: "snapshot";
    readonly resizeImage: "resizeImage";
    readonly resizeCol: "resizeCol";
    readonly resizeRow: "resizeRow";
};
export type CommandType = ValueOf<typeof CommandType>;
/**
 * Command 和 Payload 的类型映射表
 * 使用 as const 满足类型约束，避免 Record<> 导致的类型推断弱化
 */
export type CommandPayloadMap = {
    insertText: CommandPayload & {
        text: string;
    };
    insertTable: CommandPayload & {
        rowCount?: number;
        colCount?: number;
    };
    insertImage: CommandPayload & {
        file: File;
        src: string;
    };
    insertField: CommandPayload & {
        widgetMeta: WidgetMeta;
        valuePath: string;
    };
    insertWidget: CommandPayload & {
        widgetMeta: WidgetMeta;
        valuePath: string;
    };
    delete: CommandPayload & Record<string, never>;
    backspace: CommandPayload & Record<string, never>;
    enter: CommandPayload & Record<string, never>;
    setColor: CommandPayload & {
        color: string;
    };
    setBold: CommandPayload & {
        bold?: boolean;
    };
    setItalic: CommandPayload & {
        italic?: boolean;
    };
    setOrient: CommandPayload & {
        orient: VOrientationType;
    };
    setPadding: CommandPayload & {
        padding: [number, number, number, number];
    };
    setFont: CommandPayload & {
        fontFamily: string;
    };
    setFontSize: CommandPayload & {
        fontSize: number;
    };
    setUnderline: CommandPayload & {
        underline?: string;
    };
    setStrike: CommandPayload & {
        strike: boolean;
    };
    setAlign: CommandPayload & {
        align: 'left' | 'center' | 'right' | 'justify';
    };
    setRepeating: CommandPayload & {
        name: string;
        valuePath: string;
    };
    setBounded: CommandPayload & {
        name: string;
        valuePath: string;
    };
    setBoundedItem: CommandPayload & Record<string, never>;
    deleteRepeating: CommandPayload & {
        tableId: string;
        regionId: string;
    };
    deleteBounded: CommandPayload & {
        tableId: string;
        regionId: string;
    };
    deleteBoundedItem: CommandPayload & {
        tableId: string;
        regionId: string;
    };
    insertRow: CommandPayload & {
        tableId: string;
        rowIndex: number;
        position: 'at' | 'before' | 'after';
        count?: number;
    };
    insertCol: CommandPayload & {
        tableId: string;
        colIndex: number;
        position: 'at' | 'before' | 'after';
        count?: number;
    };
    deleteRow: CommandPayload & {
        tableId: string;
        rowIndex: number;
    };
    deleteCol: CommandPayload & {
        tableId: string;
        colIndex: number;
    };
    mergeCells: CommandPayload & Record<string, never>;
    unmergeCells: CommandPayload & Record<string, never>;
    snapshot: CommandPayload & Record<string, never>;
    resizeImage: CommandPayload & {
        id: string;
        width: number;
        height: number;
    };
    resizeCol: CommandPayload & {
        tableId: string;
        colIndex: number;
        width: number;
    };
    resizeRow: CommandPayload & {
        tableId: string;
        rowIndex: number;
        height: number;
    };
};
/**
 * payload 可选的命令类型（不需要额外参数）
 */
export type OptionalPayloadCommands = 'delete' | 'backspace' | 'enter' | 'setBoundedItem' | 'mergeCells' | 'unmergeCells' | 'snapshot';
/**
 * 必须提供 payload 的命令类型
 */
export type RequiredPayloadCommands = Exclude<CommandType, OptionalPayloadCommands>;
