"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = exports.DEPRECATED_CONFIG_FIELDS = exports.DEFAULT_CONFIG_PATH = void 0;
const path = require("node:path");
const utils_1 = require("@cobalt-engine/utils");
const fs = require("fs-extra");
const Storage_1 = require("../Storage");
exports.DEFAULT_CONFIG_PATH = path.resolve(__dirname, '../../../settings.json');
exports.DEPRECATED_CONFIG_FIELDS = [
    'componentLibrary',
    'ewizard.version',
];
class Config {
    static get() {
        return Promise.all([fs.readJson(exports.DEFAULT_CONFIG_PATH), Storage_1.Storage.get()])
            .then(([defaultConfig, customConfig]) => {
            return (0, utils_1.deepMixin)(defaultConfig, customConfig || {});
        });
    }
    static getSync() {
        const customConfig = Storage_1.Storage.getSync();
        const defaultConfig = fs.readJsonSync(exports.DEFAULT_CONFIG_PATH);
        return (0, utils_1.deepMixin)(defaultConfig, customConfig);
    }
    static set(newData) {
        return Storage_1.Storage.get()
            .then((currentConfig) => (0, utils_1.deepMixin)(currentConfig, newData))
            .then(Storage_1.Storage.set);
    }
    static reset(fields = []) {
        if (!fields.length) {
            return Storage_1.Storage.clear();
        }
        return Storage_1.Storage.reset(fields);
    }
    static resetDeprecatedFields() {
        return this.reset(exports.DEPRECATED_CONFIG_FIELDS);
    }
}
exports.Config = Config;
//# sourceMappingURL=index.js.map