import { jsx as _jsx } from "react/jsx-runtime";
/**
 * @deprecated This file is deprecated. Use ToolbarsPreset instead.
 */
import { i18n } from "../../i18n/menubar/index.js";
import { insertHRule, insertLink, insertMermaidDiagram, insertYfmHtmlBlock, insertYfmTable, insertYfmTabs, liftListItem, redo, redoDepth, sinkListItem, toBulletList, toH1, toH2, toH3, toH4, toH5, toH6, toOrderedList, toggleBold, toggleItalic, toggleMarked, toggleMonospace, toggleStrikethrough, toggleUnderline, undo, undoDepth, wrapToBlockquote, wrapToCheckbox, wrapToCodeBlock, wrapToInlineCode, wrapToMathBlock, wrapToMathInline, wrapToYfmCut, wrapToYfmNote, } from "../../markup/commands/index.js";
import { Action as A, formatter as f } from "../../shortcuts/index.js";
import { MToolbarColors } from "../toolbar/markup/MToolbarColors.js";
import { MToolbarFilePopup } from "../toolbar/markup/MToolbarFilePopup.js";
import { MToolbarImagePopup } from "../toolbar/markup/MToolbarImagePopup.js";
import { ToolbarDataType } from "../toolbar/types.js";
import { ActionName } from "./action-names.js";
import { icons } from "./icons.js";
import { HeadingPreview } from "./previews/HeadingPreview.js";
const noop = () => { };
const inactive = () => false;
const enable = () => true;
const disable = () => false;
export const mUndoItemData = {
    id: ActionName.undo,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'undo'),
    icon: icons.undo,
    hotkey: f.toView(A.Undo),
    exec: (e) => undo(e.cm),
    isActive: inactive,
    isEnable: (e) => undoDepth(e.cm.state) > 0,
};
export const mRedoItemData = {
    id: ActionName.redo,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'redo'),
    icon: icons.redo,
    hotkey: f.toView(A.Redo),
    exec: (e) => redo(e.cm),
    isActive: inactive,
    isEnable: (e) => redoDepth(e.cm.state) > 0,
};
export const mBoldItemData = {
    id: ActionName.bold,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'bold'),
    icon: icons.bold,
    hotkey: f.toView(A.Bold),
    exec: (e) => toggleBold(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mItalicItemData = {
    id: ActionName.italic,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'italic'),
    icon: icons.italic,
    hotkey: f.toView(A.Italic),
    exec: (e) => toggleItalic(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mUnderlineItemData = {
    id: ActionName.underline,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'underline'),
    icon: icons.underline,
    hotkey: f.toView(A.Underline),
    exec: (e) => toggleUnderline(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mStrikethroughItemData = {
    id: ActionName.strike,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'strike'),
    icon: icons.strikethrough,
    hotkey: f.toView(A.Strike),
    exec: (e) => toggleStrikethrough(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mMonospaceItemData = {
    id: ActionName.mono,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'mono'),
    icon: icons.mono,
    exec: (e) => toggleMonospace(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mMarkedItemData = {
    id: ActionName.mark,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'mark'),
    icon: icons.mark,
    exec: (e) => toggleMarked(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mCheckboxButton = {
    id: ActionName.checkbox,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'checkbox'),
    icon: icons.checklist,
    exec: (e) => wrapToCheckbox(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mCheckboxItemData = mCheckboxButton;
export const mLinkButton = {
    id: ActionName.link,
    type: ToolbarDataType.SingleButton,
    icon: icons.link,
    title: i18n('link'),
    exec: (e) => insertLink(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mLinkItemData = mLinkButton;
export const mQuoteButton = {
    id: ActionName.quote,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'quote'),
    icon: icons.quote,
    exec: (e) => wrapToBlockquote(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mQuoteItemData = mQuoteButton;
export const mCutButton = {
    id: ActionName.yfm_cut,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'cut'),
    icon: icons.cut,
    hotkey: f.toView(A.Cut),
    exec: (e) => wrapToYfmCut(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mCutItemData = mCutButton;
export const mNoteButton = {
    id: ActionName.yfm_note,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'note'),
    icon: icons.note,
    hotkey: f.toView(A.Note),
    exec: (e) => wrapToYfmNote(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mNoteItemData = mNoteButton;
export const mTableButton = {
    id: ActionName.table,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'table'),
    icon: icons.table,
    exec: (e) => insertYfmTable(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mTableItemData = mTableButton;
export const mCodeItemData = {
    id: ActionName.code_inline,
    title: i18n.bind(null, 'code_inline'),
    icon: icons.code,
    hotkey: f.toView(A.Code),
    exec: (e) => wrapToInlineCode(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mImagePopupData = {
    id: 'image',
    type: ToolbarDataType.ButtonPopup,
    icon: icons.image,
    title: i18n('image'),
    exec: noop,
    isActive: inactive,
    isEnable: enable,
    renderPopup: (props) => _jsx(MToolbarImagePopup, { ...props }),
};
export const mImageItemData = mImagePopupData;
export const mFilePopupData = {
    id: 'file',
    type: ToolbarDataType.ButtonPopup,
    icon: icons.file,
    title: i18n('file'),
    exec: noop,
    isActive: inactive,
    isEnable: enable,
    renderPopup: (props) => _jsx(MToolbarFilePopup, { ...props }),
};
export const mFileItemData = mFilePopupData;
export const mTabsItemData = {
    id: 'tabs',
    title: i18n.bind(null, 'tabs'),
    icon: icons.tabs,
    type: ToolbarDataType.SingleButton,
    exec: (e) => insertYfmTabs(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mMathInlineItemData = {
    id: ActionName.math_inline,
    title: i18n.bind(null, 'math_inline'),
    icon: icons.functionInline,
    exec: (e) => wrapToMathInline(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mMathBlockItemData = {
    id: ActionName.math_block,
    title: i18n.bind(null, 'math_block'),
    icon: icons.functionBlock,
    exec: (e) => wrapToMathBlock(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mYfmHtmlBlockButton = {
    id: ActionName.yfm_html_block,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'html'),
    icon: icons.html,
    exec: (e) => insertYfmHtmlBlock(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mYfmHtmlBlockItemData = mYfmHtmlBlockButton;
export const mMermaidButton = {
    id: ActionName.mermaid,
    type: ToolbarDataType.SingleButton,
    title: i18n.bind(null, 'mermaid'),
    icon: icons.mermaid,
    exec: (e) => insertMermaidDiagram(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mMermaidItemData = mMermaidButton;
export const mCodeblockItemData = {
    id: ActionName.code_block,
    title: i18n.bind(null, 'codeblock'),
    icon: icons.codeBlock,
    hotkey: f.toView(A.CodeBlock),
    exec: (e) => wrapToCodeBlock(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mCodeBlockItemData = mCodeblockItemData;
export const mHruleItemData = {
    id: 'hrule',
    title: i18n.bind(null, 'hrule'),
    icon: icons.horizontalRule,
    type: ToolbarDataType.SingleButton,
    exec: (e) => insertHRule(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mEmojiItemData = {
    id: 'emoji',
    title: i18n.bind(null, 'emoji'),
    icon: icons.emoji,
    type: ToolbarDataType.SingleButton,
    exec: noop,
    hintWhenDisabled: i18n.bind(null, 'emoji__hint'),
    isActive: inactive,
    isEnable: disable,
};
export const mMathListItem = {
    id: 'math',
    type: ToolbarDataType.ListButton,
    icon: icons.functionInline,
    withArrow: true,
    title: i18n.bind(null, 'math'),
    data: [mMathInlineItemData, mMathBlockItemData],
};
export const mHeading1ItemData = {
    id: ActionName.heading1,
    title: i18n.bind(null, 'heading1'),
    icon: icons.h1,
    hotkey: f.toView(A.Heading1),
    exec: (e) => toH1(e.cm),
    isActive: inactive,
    isEnable: enable,
    preview: _jsx(HeadingPreview, { level: 1 }),
};
export const mHeading2ItemData = {
    id: ActionName.heading2,
    title: i18n.bind(null, 'heading2'),
    icon: icons.h2,
    hotkey: f.toView(A.Heading2),
    exec: (e) => toH2(e.cm),
    isActive: inactive,
    isEnable: enable,
    preview: _jsx(HeadingPreview, { level: 2 }),
};
export const mHeading3ItemData = {
    id: ActionName.heading3,
    title: i18n.bind(null, 'heading3'),
    icon: icons.h3,
    hotkey: f.toView(A.Heading3),
    exec: (e) => toH3(e.cm),
    isActive: inactive,
    isEnable: enable,
    preview: _jsx(HeadingPreview, { level: 3 }),
};
export const mHeading4ItemData = {
    id: ActionName.heading4,
    title: i18n.bind(null, 'heading4'),
    icon: icons.h4,
    hotkey: f.toView(A.Heading4),
    exec: (e) => toH4(e.cm),
    isActive: inactive,
    isEnable: enable,
    preview: _jsx(HeadingPreview, { level: 4 }),
};
export const mHeading5ItemData = {
    id: ActionName.heading5,
    title: i18n.bind(null, 'heading5'),
    icon: icons.h5,
    hotkey: f.toView(A.Heading5),
    exec: (e) => toH5(e.cm),
    isActive: inactive,
    isEnable: enable,
    preview: _jsx(HeadingPreview, { level: 5 }),
};
export const mHeading6ItemData = {
    id: ActionName.heading6,
    title: i18n.bind(null, 'heading6'),
    icon: icons.h6,
    hotkey: f.toView(A.Heading6),
    exec: (e) => toH6(e.cm),
    isActive: inactive,
    isEnable: enable,
    preview: _jsx(HeadingPreview, { level: 6 }),
};
export const mBulletListItemData = {
    id: ActionName.bulletList,
    title: i18n.bind(null, 'ulist'),
    icon: icons.bulletList,
    exec: (e) => toBulletList(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mOrderedListItemData = {
    id: ActionName.orderedList,
    title: i18n.bind(null, 'olist'),
    icon: icons.orderedList,
    exec: (e) => toOrderedList(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mSinkListItemData = {
    id: ActionName.sinkListItem,
    title: i18n.bind(null, 'list__action_sink'),
    icon: icons.sink,
    exec: (e) => sinkListItem(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mLiftListItemData = {
    id: ActionName.liftListItem,
    title: i18n.bind(null, 'list__action_lift'),
    icon: icons.lift,
    exec: (e) => liftListItem(e.cm),
    isActive: inactive,
    isEnable: enable,
};
export const mHeadingListConfig = {
    icon: icons.headline,
    withArrow: true,
    title: i18n.bind(null, 'heading'),
    data: [
        mHeading1ItemData,
        mHeading2ItemData,
        mHeading3ItemData,
        mHeading4ItemData,
        mHeading5ItemData,
        mHeading6ItemData,
    ],
};
export const mListsListConfig = {
    icon: icons.bulletList,
    withArrow: true,
    title: i18n.bind(null, 'list'),
    data: [mBulletListItemData, mOrderedListItemData],
};
export const mListMoveListConfig = {
    icon: icons.lift,
    withArrow: true,
    title: 'Move list item',
    data: [mSinkListItemData, mLiftListItemData],
};
export const mCodeListConfig = {
    icon: icons.code,
    withArrow: true,
    title: i18n.bind(null, 'code'),
    data: [mCodeItemData, mCodeblockItemData],
};
export const mMathListConfig = {
    icon: icons.functionInline,
    withArrow: true,
    title: i18n.bind(null, 'math'),
    data: [mMathInlineItemData, mMathBlockItemData],
};
export const mHiddenData = [mHruleItemData, mEmojiItemData, mTabsItemData];
export const mHistoryGroupConfig = [mUndoItemData, mRedoItemData];
export const mBiusGroupConfig = [
    mBoldItemData,
    mItalicItemData,
    mUnderlineItemData,
    mStrikethroughItemData,
    mMonospaceItemData,
    mMarkedItemData,
];
export const mToolbarConfig = [
    [mUndoItemData, mRedoItemData],
    mBiusGroupConfig,
    [
        {
            id: 'heading',
            type: ToolbarDataType.ListButton,
            icon: icons.headline,
            withArrow: true,
            title: i18n.bind(null, 'heading'),
            data: [
                mHeading1ItemData,
                mHeading2ItemData,
                mHeading3ItemData,
                mHeading4ItemData,
                mHeading5ItemData,
                mHeading6ItemData,
            ],
        },
        {
            id: 'list',
            type: ToolbarDataType.ListButton,
            icon: icons.bulletList,
            withArrow: true,
            title: i18n.bind(null, 'list'),
            data: [mBulletListItemData, mOrderedListItemData],
        },
        {
            id: 'colorify',
            type: ToolbarDataType.ReactComponent,
            component: MToolbarColors,
            width: 42,
        },
        mLinkButton,
        mNoteButton,
        mCutButton,
        mQuoteButton,
        {
            id: 'code',
            type: ToolbarDataType.ListButton,
            icon: icons.code,
            withArrow: true,
            title: i18n.bind(null, 'code'),
            data: [mCodeItemData, mCodeblockItemData],
        },
    ],
    [mImagePopupData, mFilePopupData, mTableButton, mCheckboxButton],
];
export const mToolbarConfigByPreset = {
    zero: [mHistoryGroupConfig],
    commonmark: [
        [mUndoItemData, mRedoItemData],
        [mBoldItemData, mItalicItemData],
        [
            {
                id: 'heading',
                type: ToolbarDataType.ListButton,
                icon: icons.headline,
                withArrow: true,
                title: i18n.bind(null, 'heading'),
                data: [
                    mHeading1ItemData,
                    mHeading2ItemData,
                    mHeading3ItemData,
                    mHeading4ItemData,
                    mHeading5ItemData,
                    mHeading6ItemData,
                ],
            },
            {
                id: 'list',
                type: ToolbarDataType.ListButton,
                icon: icons.bulletList,
                withArrow: true,
                title: i18n.bind(null, 'list'),
                data: [mBulletListItemData, mOrderedListItemData],
            },
            mLinkButton,
            mQuoteButton,
            {
                id: 'code',
                type: ToolbarDataType.ListButton,
                icon: icons.code,
                withArrow: true,
                title: i18n.bind(null, 'code'),
                data: [mCodeItemData, mCodeblockItemData],
            },
        ],
    ],
    default: [
        [mUndoItemData, mRedoItemData],
        [mBoldItemData, mItalicItemData, mStrikethroughItemData],
        [
            {
                id: 'heading',
                type: ToolbarDataType.ListButton,
                icon: icons.headline,
                withArrow: true,
                title: i18n.bind(null, 'heading'),
                data: [
                    mHeading1ItemData,
                    mHeading2ItemData,
                    mHeading3ItemData,
                    mHeading4ItemData,
                    mHeading5ItemData,
                    mHeading6ItemData,
                ],
            },
            {
                id: 'list',
                type: ToolbarDataType.ListButton,
                icon: icons.bulletList,
                withArrow: true,
                title: i18n.bind(null, 'list'),
                data: [mBulletListItemData, mOrderedListItemData],
            },
            mLinkButton,
            mQuoteButton,
            {
                id: 'code',
                type: ToolbarDataType.ListButton,
                icon: icons.code,
                withArrow: true,
                title: i18n.bind(null, 'code'),
                data: [mCodeItemData, mCodeblockItemData],
            },
        ],
    ],
    yfm: [
        [mUndoItemData, mRedoItemData],
        [
            mBoldItemData,
            mItalicItemData,
            mUnderlineItemData,
            mStrikethroughItemData,
            mMonospaceItemData,
        ],
        [
            {
                id: 'heading',
                type: ToolbarDataType.ListButton,
                icon: icons.headline,
                withArrow: true,
                title: i18n.bind(null, 'heading'),
                data: [
                    mHeading1ItemData,
                    mHeading2ItemData,
                    mHeading3ItemData,
                    mHeading4ItemData,
                    mHeading5ItemData,
                    mHeading6ItemData,
                ],
            },
            {
                id: 'list',
                type: ToolbarDataType.ListButton,
                icon: icons.bulletList,
                withArrow: true,
                title: i18n.bind(null, 'list'),
                data: [mBulletListItemData, mOrderedListItemData],
            },
            mLinkButton,
            mNoteButton,
            mCutButton,
            mQuoteButton,
            {
                id: 'code',
                type: ToolbarDataType.ListButton,
                icon: icons.code,
                withArrow: true,
                title: i18n.bind(null, 'code'),
                data: [mCodeItemData, mCodeblockItemData],
            },
        ],
        [mImagePopupData, mFilePopupData, mTableButton, mCheckboxButton],
    ],
    full: mToolbarConfig.slice(),
};
export const mHiddenDataByPreset = {
    zero: [],
    commonmark: [
        mHeading1ItemData,
        mHeading2ItemData,
        mHeading3ItemData,
        mHeading4ItemData,
        mHeading5ItemData,
        mHeading6ItemData,
        mBulletListItemData,
        mOrderedListItemData,
        mLinkButton,
        mQuoteButton,
        mCodeblockItemData,
        mHruleItemData,
    ],
    default: [
        mHeading1ItemData,
        mHeading2ItemData,
        mHeading3ItemData,
        mHeading4ItemData,
        mHeading5ItemData,
        mHeading6ItemData,
        mBulletListItemData,
        mOrderedListItemData,
        mLinkButton,
        mQuoteButton,
        mCodeblockItemData,
        mHruleItemData,
    ],
    yfm: [
        mHeading1ItemData,
        mHeading2ItemData,
        mHeading3ItemData,
        mHeading4ItemData,
        mHeading5ItemData,
        mHeading6ItemData,
        mBulletListItemData,
        mOrderedListItemData,
        mLinkButton,
        mQuoteButton,
        mNoteButton,
        mCutButton,
        mCodeblockItemData,
        mCheckboxButton,
        mTableButton,
        mImagePopupData,
        mHruleItemData,
        mFilePopupData,
        mTabsItemData,
    ],
    full: [
        mHeading1ItemData,
        mHeading2ItemData,
        mHeading3ItemData,
        mHeading4ItemData,
        mHeading5ItemData,
        mHeading6ItemData,
        mBulletListItemData,
        mOrderedListItemData,
        mLinkButton,
        mQuoteButton,
        mNoteButton,
        mCutButton,
        mCodeblockItemData,
        mCheckboxButton,
        mTableButton,
        mImagePopupData,
        mHruleItemData,
        mEmojiItemData,
        mFilePopupData,
        mTabsItemData,
    ],
};
//# sourceMappingURL=markup.js.map
