"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createBrowserApi = createBrowserApi;
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const components_1 = require("@opensumi/ide-core-browser/lib/components");
const browser_1 = require("@opensumi/ide-editor/lib/browser");
const ide_theme_1 = require("@opensumi/ide-theme");
const ide_toolbar_1 = require("@opensumi/ide-toolbar");
const ide_webview_1 = require("@opensumi/ide-webview");
const commands_1 = require("./commands");
const components_2 = require("./components");
const { format } = ide_core_browser_1.strings;
/**
 * Browser 尽量只export视图相关的少量API
 * 设计API时遵循以下原则:
 * 1. browser只暴露getter，任何注册、调用等会产生副作用的行为全部放入逻辑层
 * @param injector
 */
function createBrowserApi(injector, extension, rpcProtocol) {
    const commands = (0, commands_1.createBrowserCommandsApiFactory)(injector, extension, rpcProtocol);
    const components = (0, components_2.createBrowserComponents)(injector, extension);
    const reporter = injector.get(ide_core_browser_1.IReporterService);
    return {
        ...components,
        commands,
        ResizeHandleHorizontal: components_1.ResizeHandleHorizontal,
        ResizeHandleVertical: components_1.ResizeHandleVertical,
        PlainWebview: ide_webview_1.PlainWebview,
        // common classes
        URI: ide_core_browser_1.URI,
        localize: (key, message) => (0, ide_core_browser_1.localize)(key, message, extension.id),
        formatLocalize: (key, ...args) => format((0, ide_core_browser_1.localize)(key, undefined, extension.id), ...args),
        getIcon: ide_core_browser_1.getIcon,
        // theme
        getThemeColors: () => {
            const themeService = injector.get(ide_theme_1.IThemeService);
            const currentTheme = themeService.getCurrentThemeSync();
            const exportedColors = (0, ide_theme_1.getColorRegistry)()
                .getColors()
                .reduce((colors, entry) => {
                const color = currentTheme.getColor(entry.id);
                if (color) {
                    colors[entry.id.replace('.', '-')] = color.toString();
                }
                return colors;
            }, {});
            return exportedColors;
        },
        ToolBarPosition: ide_toolbar_1.ToolBarPosition,
        EditorComponentRenderMode: browser_1.EditorComponentRenderMode,
        reporter,
    };
}
//# sourceMappingURL=index.js.map