"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToolBarBrowserContributionRunner = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_common_1 = require("@opensumi/ide-core-common");
const ide_main_layout_1 = require("@opensumi/ide-main-layout");
const ide_theme_1 = require("@opensumi/ide-theme");
const browser_1 = require("@opensumi/ide-toolbar/lib/browser");
const types_1 = require("../types");
let ToolBarBrowserContributionRunner = class ToolBarBrowserContributionRunner extends types_1.AbstractSumiBrowserContributionRunner {
    run(param) {
        const disposer = new ide_core_common_1.Disposable();
        if (!this.injector.creatorMap.has(browser_1.IToolBarViewService)) {
            this.logger.warn('没有找到 toolbarViewService');
            return disposer;
        }
        if (this.contribution.toolBar) {
            this.contribution.toolBar.view.forEach((view) => {
                const { extendProtocol, extendService } = param.getExtensionExtendService(this.extension, view.id);
                const disposable = this.toolBarViewService.registerToolBarElement({
                    type: 'component',
                    component: view.component,
                    position: view.position || this.contribution.toolBar.position || browser_1.ToolBarPosition.LEFT,
                    initialProps: {
                        kaitianExtendService: extendService,
                        kaitianExtendSet: extendProtocol,
                        sumiExtendService: extendService,
                        sumiExtendSet: extendProtocol,
                    },
                    description: view.description,
                    order: view.order,
                    weight: view.weight,
                });
                if (disposable) {
                    disposer.addDispose(disposable);
                }
            });
        }
        return disposer;
    }
};
exports.ToolBarBrowserContributionRunner = ToolBarBrowserContributionRunner;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_main_layout_1.IMainLayoutService),
    tslib_1.__metadata("design:type", Object)
], ToolBarBrowserContributionRunner.prototype, "layoutService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(browser_1.IToolBarViewService),
    tslib_1.__metadata("design:type", browser_1.IToolBarViewService)
], ToolBarBrowserContributionRunner.prototype, "toolBarViewService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_theme_1.IIconService),
    tslib_1.__metadata("design:type", Object)
], ToolBarBrowserContributionRunner.prototype, "iconService", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_common_1.ILogger),
    tslib_1.__metadata("design:type", Object)
], ToolBarBrowserContributionRunner.prototype, "logger", void 0);
tslib_1.__decorate([
    (0, di_1.Autowired)(di_1.INJECTOR_TOKEN),
    tslib_1.__metadata("design:type", di_1.Injector)
], ToolBarBrowserContributionRunner.prototype, "injector", void 0);
exports.ToolBarBrowserContributionRunner = ToolBarBrowserContributionRunner = tslib_1.__decorate([
    (0, di_1.Injectable)({ multiple: true })
], ToolBarBrowserContributionRunner);
//# sourceMappingURL=toolbar.js.map