"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createBrowserComponents = createBrowserComponents;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
const Components = tslib_1.__importStar(require("@opensumi/ide-core-browser/lib/components"));
const extension_portal_root_1 = require("../components/extension-portal-root");
function createBrowserComponents(injector, extension) {
    const appConfig = injector.get(ide_core_browser_1.AppConfig);
    if (!appConfig.useExperimentalShadowDom) {
        return Components;
    }
    return new Proxy(Components, {
        get(target, prop) {
            if (prop === 'Dialog' || prop === 'Overlay') {
                const OriginalComponent = Components[prop];
                return (props) => react_1.default.createElement(extension_portal_root_1.PortalRoot, {
                    otherProps: props,
                    extensionId: extension.id,
                    original: OriginalComponent,
                });
            }
            return target[prop];
        },
    });
}
//# sourceMappingURL=components.js.map