import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import * as React from 'react';
import { ShadowPortal } from '../internal/components/ShadowPortal';
import { BuildError } from '../internal/container/BuildError';
import { Errors } from '../internal/container/Errors';
import { Base } from '../internal/styles/Base';
import { ComponentStyles } from '../internal/styles/ComponentStyles';
import { CssReset } from '../internal/styles/CssReset';
import { ErrorBoundary } from '../../pages/ErrorBoundary';
import { usePagesReactDevOverlay } from '../../pages/hooks';
export default function ReactDevOverlay(param) {
    let { children, preventDisplay, globalOverlay } = param;
    const { isMounted, displayPrevented, hasBuildError, hasRuntimeErrors, state, onComponentError } = usePagesReactDevOverlay(preventDisplay);
    return /*#__PURE__*/ _jsxs(_Fragment, {
        children: [
            /*#__PURE__*/ _jsx(ErrorBoundary, {
                globalOverlay: globalOverlay,
                isMounted: isMounted,
                onError: onComponentError,
                children: children != null ? children : null
            }),
            isMounted ? /*#__PURE__*/ _jsxs(ShadowPortal, {
                children: [
                    /*#__PURE__*/ _jsx(CssReset, {}),
                    /*#__PURE__*/ _jsx(Base, {}),
                    /*#__PURE__*/ _jsx(ComponentStyles, {}),
                    displayPrevented ? null : hasBuildError ? /*#__PURE__*/ _jsx(BuildError, {
                        message: state.buildError,
                        versionInfo: state.versionInfo
                    }) : hasRuntimeErrors ? /*#__PURE__*/ _jsx(Errors, {
                        isAppDir: false,
                        errors: state.errors,
                        versionInfo: state.versionInfo,
                        initialDisplayState: 'fullscreen'
                    }) : undefined
                ]
            }) : undefined
        ]
    });
}

//# sourceMappingURL=ReactDevOverlay.js.map