"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DesignMenuBarContribution = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const next_1 = require("@opensumi/ide-core-browser/lib/menu/next");
const menu_bar_store_1 = require("@opensumi/ide-menu-bar/lib/browser/menu-bar.store");
const common_1 = require("../../common");
const menu_bar_view_1 = require("./menu-bar.view");
let DesignMenuBarContribution = class DesignMenuBarContribution extends ide_core_browser_1.Disposable {
    constructor() {
        super();
        this.menubarStore.unregisterMenusBarByCompact(next_1.MenuId.DesignMenuBarTopExtra);
        let toDispose;
        this.addDispose(this.menubarStore.onDidMenuBarChange((menubarItems) => {
            if (toDispose) {
                toDispose.dispose();
            }
            toDispose = this.menuRegistry.registerMenuItems(next_1.MenuId.DesignMenuBarTopExtra, menubarItems.map((item) => ({
                label: item.label,
                submenu: item.id,
                iconClass: item.iconClass,
                group: item.group || '1_navigation',
                order: item.order || 100,
            })));
        }));
    }
    registerComponent(registry) {
        registry.register(common_1.DESIGN_MENUBAR_CONTAINER_VIEW_ID, {
            component: menu_bar_view_1.DesignMenuBarView,
            id: common_1.DESIGN_MENUBAR_CONTAINER_VIEW_ID,
        });
    }
};
tslib_1.__decorate([
    (0, di_1.Autowired)(menu_bar_store_1.MenubarStore),
    tslib_1.__metadata("design:type", menu_bar_store_1.MenubarStore)
], DesignMenuBarContribution.prototype, "menubarStore", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(next_1.IMenuRegistry),
    tslib_1.__metadata("design:type", next_1.IMenuRegistry)
], DesignMenuBarContribution.prototype, "menuRegistry", void 0);
DesignMenuBarContribution = tslib_1.__decorate([
    (0, ide_core_browser_1.Domain)(ide_core_browser_1.ComponentContribution),
    tslib_1.__metadata("design:paramtypes", [])
], DesignMenuBarContribution);
exports.DesignMenuBarContribution = DesignMenuBarContribution;
//# sourceMappingURL=menu-bar.contribution.js.map