"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.themeMap = exports.themes = exports.localeMap = exports.locales = void 0;

var _path = _interopRequireDefault(require("path"));

var _fsExtra = _interopRequireDefault(require("fs-extra"));

var _theme = require("@reactizer/theme");

const LOCALES = _path.default.join(__dirname, "../static/locales");

const LOCALE_MAP = _path.default.join(__dirname, "../static/generated/locales/map.json");

const THEMES = _path.default.join(__dirname, "../static/themes");

const THEME_MAP = _path.default.join(__dirname, "../static/generated/themes/map.json");

const loadIntls = () => _fsExtra.default.readdirSync(LOCALES).map(file => _fsExtra.default.readJsonSync(_path.default.join(LOCALES, file))).reduce((acc, locale) => ({ ...acc,
  [locale.id]: locale
}), {});

const locales = loadIntls();
exports.locales = locales;

const localeMap = _fsExtra.default.readJSONSync(LOCALE_MAP);

exports.localeMap = localeMap;

const loadThemes = () => _fsExtra.default.readdirSync(THEMES).map(file => ({
  id: file.replace(".json", ""),
  theme: (0, _theme.makeTheme)(_fsExtra.default.readJsonSync(_path.default.join(THEMES, file)))
})).reduce((acc, theme) => ({ ...acc,
  [theme.id]: theme.theme
}), {});

const themes = loadThemes();
exports.themes = themes;

const themeMap = _fsExtra.default.readJSONSync(THEME_MAP);

exports.themeMap = themeMap;