import * as platform from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
import { Extensions } from 'monaco-editor/esm/vs/platform/theme/common/colorUtils.js';
import { Themes } from '@journeyapps-labs/reactor-mod';
import { colorToAHex } from '@journeyapps-labs/lib-reactor-utils';
const THEME_JOURNEY = require('../../media/themes/journey.json5');
const THEME_REACTOR = require('../../media/themes/reactor.json5');
const THEME_REACTOR_DARK = require('../../media/themes/reactor-dark.json5');
const THEME_OXIDE = require('../../media/themes/oxide.json5');
const THEME_SCARLET = require('../../media/themes/scarlet.json5');
const THEME_AYU_MIRAGE = require('../../media/themes/ayu-mirage.json5');
const THEME_AYU_LIGHT = require('../../media/themes/ayu-light.json5');
const THEME_BUNNY = require('../../media/themes/bunny.json5');
export const normalizeVSCodeTheme = (themeObject) => {
    var _a;
    const rules = [];
    for (let token of themeObject.tokenColors) {
        // base theme
        if (!token.scope) {
            continue;
        }
        let scope;
        if (Array.isArray(token.scope)) {
            scope = token.scope;
        }
        else {
            scope = token.scope.split(',').map((s) => s.trim());
        }
        if (scope.length === 0) {
            continue;
        }
        let foreground = colorToAHex(token.settings.foreground);
        let background = colorToAHex(token.settings.background);
        let tokenMapped = {};
        if (token.settings.fontStyle) {
            tokenMapped['fontStyle'] = token.settings.fontStyle;
        }
        if (foreground) {
            tokenMapped['foreground'] = foreground;
        }
        if (background) {
            tokenMapped['background'] = background;
        }
        scope.forEach((s) => {
            rules.push(Object.assign({ token: s }, tokenMapped));
        });
    }
    return Object.assign(Object.assign({}, themeObject), { base: themeObject.base || 'vs-dark', inherit: (_a = themeObject.inherit) !== null && _a !== void 0 ? _a : true, colors: themeObject.colors, encodedTokensColors: [], rules: rules });
};
export const colorRegistry = platform.Registry.data.get(Extensions.ColorContribution);
export const DARK_THEME = 'journey-dark';
export const COUPLED_IDE_THEMES = {
    [Themes.JOURNEY]: normalizeVSCodeTheme(THEME_JOURNEY.default),
    [Themes.REACTOR]: normalizeVSCodeTheme(THEME_REACTOR.default),
    [Themes.REACTOR_DARK]: normalizeVSCodeTheme(THEME_REACTOR_DARK.default),
    [Themes.OXIDE]: normalizeVSCodeTheme(THEME_OXIDE.default),
    [Themes.SCARLET]: normalizeVSCodeTheme(THEME_SCARLET.default),
    [Themes.HEXAGON]: normalizeVSCodeTheme(THEME_AYU_MIRAGE.default),
    [Themes.REACTOR_LIGHT]: normalizeVSCodeTheme(THEME_AYU_LIGHT.default),
    [Themes.BUNNY]: normalizeVSCodeTheme(THEME_BUNNY.default)
};
//# sourceMappingURL=theme-utils.js.map