"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createYfmTabs = exports.createYfmTabsCommand = void 0;
const utils_1 = require("@diplodoc/transform/lib/plugins/utils");
const BaseSchema_1 = require("../../base/BaseSchema/index.js");
const const_1 = require("./const.js");
const createYfmTabsCommand = (state, dispatch) => {
    if (dispatch) {
        const { schema } = state;
        const tabId = (0, utils_1.generateID)();
        const panelId = (0, utils_1.generateID)();
        const yfmTabsList = (0, const_1.tabsListType)(schema);
        const yfmTabs = (0, const_1.tabsType)(schema);
        const yfmTabPanel = (0, const_1.tabPanelType)(state.schema).create({
            [const_1.TabPanelAttrs.ariaLabelledby]: tabId,
            [const_1.TabPanelAttrs.id]: panelId,
            [const_1.TabPanelAttrs.class]: const_1.tabPanelActiveClassname,
        }, (0, BaseSchema_1.pType)(state.schema).createAndFill());
        const yfmTab = (0, const_1.tabType)(state.schema).create({
            [const_1.TabAttrs.id]: tabId,
            [const_1.TabAttrs.class]: const_1.tabActiveClassname,
            [const_1.TabAttrs.ariaControls]: panelId,
            [const_1.TabAttrs.dataDiplodocIsActive]: 'true',
            [const_1.TabAttrs.dataDiplodocid]: tabId,
            [const_1.TabAttrs.dataDiplodocKey]: tabId,
        });
        const tabs = yfmTabs.create({ [const_1.TabsAttrs.dataDiplodocGroup]: (0, utils_1.generateID)() }, [
            yfmTabsList.create(null, [yfmTab]),
            yfmTabPanel,
        ]);
        dispatch(state.tr.replaceSelectionWith(tabs).scrollIntoView());
    }
    return true;
};
exports.createYfmTabsCommand = createYfmTabsCommand;
exports.createYfmTabs = {
    isEnable: exports.createYfmTabsCommand,
    run: exports.createYfmTabsCommand,
};
//# sourceMappingURL=actions.js.map
