import type { HotkeyProps } from '@gravity-ui/uikit';
import type { EditorState } from 'prosemirror-state';
import type { ActionStorage } from "../../core/index.js";
import type { CodeEditor } from "../../markup/index.js";
import type { ToolbarBaseProps, ToolbarDataType, ToolbarIconData } from "../../toolbar/index.js";
export type ToolbarItemId = string & {};
export type ToolbarListId = string & {};
export interface ToolbarList {
    id: ToolbarListId;
    items: ToolbarItemId[];
}
/**
 * The default value for the `type` property is `ToolbarDataType.SingleButton`.
 */
export type ToolbarItemView<T extends ToolbarDataType = ToolbarDataType.SingleButton> = {
    className?: string;
    hint?: string | (() => string);
    hotkey?: HotkeyProps['value'];
    type?: ToolbarDataType;
    doNotActivateList?: boolean;
} & (T extends ToolbarDataType.SingleButton ? {
    icon: ToolbarIconData;
    title: string | (() => string);
    preview?: React.ReactNode;
} : T extends ToolbarDataType.ListButton ? {
    withArrow?: boolean;
    icon: ToolbarIconData;
    title: string | (() => string);
} : {});
export interface EditorActions<E> {
    exec(editor: E): void;
    isActive(editor: E): boolean;
    isEnable(editor: E): boolean;
}
type ToolbarItemEditor<T, E> = Partial<EditorActions<E>> & {
    hintWhenDisabled?: boolean | string | (() => string);
    condition?: ((state: EditorState) => void) | 'enabled';
} & (T extends ToolbarDataType.ButtonPopup ? {
    renderPopup: (props: ToolbarBaseProps<E> & {
        hide: () => void;
        anchorElement: HTMLElement | null;
    }) => React.ReactNode;
} : T extends ToolbarDataType.ReactComponent ? {
    width: number;
    component: React.ComponentType<ToolbarBaseProps<E>>;
} : {});
export type ToolbarItemWysiwyg<T extends ToolbarDataType = ToolbarDataType.SingleButton> = ToolbarItemEditor<T, ActionStorage>;
export type ToolbarItemMarkup<T extends ToolbarDataType = ToolbarDataType.SingleButton> = ToolbarItemEditor<T, CodeEditor>;
export type ToolbarItem<T extends ToolbarDataType> = {
    view: ToolbarItemView<T>;
    wysiwyg?: ToolbarItemWysiwyg<T>;
    markup?: ToolbarItemMarkup<T>;
};
export type ToolbarsItems = Record<ToolbarItemId, ToolbarItem<ToolbarDataType>>;
export type ToolbarId = string;
export type ToolbarOrders = (ToolbarList | ToolbarItemId)[][];
export type ToolbarsOrders = Record<ToolbarId, ToolbarOrders>;
export interface ToolbarsPreset {
    items: ToolbarsItems;
    orders: ToolbarsOrders;
}
export {};
