"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ColorsContributionPoint = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const ide_theme_1 = require("@opensumi/ide-theme");
const common_1 = require("../../../common");
const colorIdPattern = '^\\w+[.\\w+]*$';
let ColorsContributionPoint = class ColorsContributionPoint extends common_1.VSCodeContributePoint {
    contribute() {
        for (const contrib of this.contributesMap) {
            const { contributes } = contrib;
            for (const color of contributes) {
                if (color && color.description) {
                    color.description = (0, ide_core_browser_1.replaceLocalizePlaceholder)(color.description);
                }
                this.themeService.registerColor(color);
            }
        }
    }
};
exports.ColorsContributionPoint = ColorsContributionPoint;
ColorsContributionPoint.schema = {
    description: (0, ide_core_browser_1.localize)('contributes.color', 'Contributes extension defined themable colors'),
    type: 'array',
    items: {
        type: 'object',
        properties: {
            id: {
                type: 'string',
                description: (0, ide_core_browser_1.localize)('contributes.color.id', 'The identifier of the themable color'),
                pattern: colorIdPattern,
                patternErrorMessage: (0, ide_core_browser_1.localize)('contributes.color.id.format', 'Identifiers should be in the form aa[.bb]*'),
            },
            description: {
                type: 'string',
                description: (0, ide_core_browser_1.localize)('contributes.color.description', 'The description of the themable color'),
            },
            defaults: {
                type: 'object',
                properties: {
                    light: {
                        description: (0, ide_core_browser_1.localize)('contributes.defaults.light', 'The default color for light themes. Either a color value in hex (#RRGGBB[AA]) or the identifier of a themable color which provides the default.'),
                        type: 'string',
                        anyOf: [{ type: 'string', format: 'color-hex' }],
                    },
                    dark: {
                        description: (0, ide_core_browser_1.localize)('contributes.defaults.dark', 'The default color for dark themes. Either a color value in hex (#RRGGBB[AA]) or the identifier of a themable color which provides the default.'),
                        type: 'string',
                        anyOf: [{ type: 'string', format: 'color-hex' }],
                    },
                    highContrast: {
                        description: (0, ide_core_browser_1.localize)('contributes.defaults.highContrast', 'The default color for high contrast dark themes. Either a color value in hex (#RRGGBB[AA]) or the identifier of a themable color which provides the default. If not provided, the `dark` color is used as default for high contrast dark themes.'),
                        type: 'string',
                        anyOf: [{ type: 'string', format: 'color-hex' }],
                    },
                    highContrastLight: {
                        description: (0, ide_core_browser_1.localize)('contributes.defaults.highContrastLight', 'The default color for high contrast light themes. Either a color value in hex (#RRGGBB[AA]) or the identifier of a themable color which provides the default. If not provided, the `light` color is used as default for high contrast light themes.'),
                        type: 'string',
                        anyOf: [{ type: 'string', format: 'color-hex' }],
                    },
                },
            },
        },
    },
};
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_theme_1.IThemeService),
    tslib_1.__metadata("design:type", Object)
], ColorsContributionPoint.prototype, "themeService", void 0);
exports.ColorsContributionPoint = ColorsContributionPoint = tslib_1.__decorate([
    (0, di_1.Injectable)(),
    (0, common_1.Contributes)('colors'),
    (0, common_1.LifeCycle)(4 /* LifeCyclePhase.Ready */)
], ColorsContributionPoint);
//# sourceMappingURL=color.js.map