"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigurationDefaultsContributionPoint = void 0;
const tslib_1 = require("tslib");
const di_1 = require("@opensumi/di");
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const common_1 = require("../../../common");
let ConfigurationDefaultsContributionPoint = class ConfigurationDefaultsContributionPoint extends common_1.VSCodeContributePoint {
    contribute() {
        for (const contrib of this.contributesMap) {
            const { contributes } = contrib;
            if (contributes) {
                this.updateDefaultOverridesSchema(contributes);
            }
        }
    }
    updateDefaultOverridesSchema(configurationDefaults) {
        // eslint-disable-next-line guard-for-in
        for (const key in configurationDefaults) {
            const defaultValue = configurationDefaults[key];
            if (ide_core_browser_1.OVERRIDE_PROPERTY_PATTERN.test(key)) {
                const language = key.match(ide_core_browser_1.OVERRIDE_PROPERTY_PATTERN)[1];
                Object.keys(defaultValue).forEach((preferenceName) => {
                    this.defaultPreferenceProvider.setPreference(preferenceName, defaultValue[preferenceName], undefined, language);
                });
            }
        }
    }
};
exports.ConfigurationDefaultsContributionPoint = ConfigurationDefaultsContributionPoint;
tslib_1.__decorate([
    (0, di_1.Autowired)(ide_core_browser_1.PreferenceProvider, { tag: ide_core_browser_1.PreferenceScope.Default }),
    tslib_1.__metadata("design:type", ide_core_browser_1.PreferenceProvider)
], ConfigurationDefaultsContributionPoint.prototype, "defaultPreferenceProvider", void 0);
exports.ConfigurationDefaultsContributionPoint = ConfigurationDefaultsContributionPoint = tslib_1.__decorate([
    (0, di_1.Injectable)(),
    (0, common_1.Contributes)('configurationDefaults'),
    (0, common_1.LifeCycle)(3 /* LifeCyclePhase.Starting */)
], ConfigurationDefaultsContributionPoint);
//# sourceMappingURL=configurationDefaults.js.map