"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Config = void 0;
const path = require("path");
const fs = require("fs-extra");
const utils_1 = require("@cobalt-engine/utils");
const Storage_1 = require("../Storage");
const DEFAULT_CONFIG_PATH = path.resolve(__dirname, '../../../settings.json');
class Config {
    static get() {
        return Promise.all([fs.readJson(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(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);
    }
}
exports.Config = Config;
//# sourceMappingURL=index.js.map