import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2022-2026 GoodData Corporation
import { memo, useMemo } from "react";
import { useIntl } from "react-intl";
import { IntlWrapper } from "@gooddata/sdk-ui";
import { useTheme } from "@gooddata/sdk-ui-theme-provider";
import { Button } from "../Button/Button.js";
import { Icon } from "../Icon/Icon.js";
import { Typography } from "../Typography/Typography.js";
import { Overlay } from "./Overlay.js";
function ErrorOverlayCore({ showIcon = true, showButton = true, icon, title, text, buttonTitle, onButtonClick, className, }) {
    const intl = useIntl();
    const theme = useTheme();
    const IconComponent = useMemo(() => {
        const LeaveIcon = Icon["Leave"];
        return icon ?? _jsx(LeaveIcon, { color: theme?.palette?.primary?.base, className: "gd-error-overlay-icon" });
    }, [icon, theme?.palette?.primary?.base]);
    const titleContent = useMemo(() => title ?? intl.formatMessage({ id: "error.overlay.title" }), [title, intl]);
    const textContent = useMemo(() => text ?? intl.formatMessage({ id: "error.overlay.text" }), [text, intl]);
    const buttonValue = useMemo(() => buttonTitle ?? intl.formatMessage({ id: "error.overlay.login" }), [buttonTitle, intl]);
    return (_jsx(Overlay, { isModal: true, positionType: "fixed", alignPoints: [{ align: "cc cc" }], closeOnEscape: false, closeOnParentScroll: false, closeOnOutsideClick: false, closeOnMouseDrag: false, zIndex: 10001, containerClassName: "gd-error-overlay-content", className: className, children: _jsxs("div", { className: "gd-error-overlay s-error-overlay", children: [showIcon ? IconComponent : null, _jsx(Typography, { tagName: "h2", children: titleContent }), _jsx("div", { className: "gd-error-overlay-text", children: textContent }), showButton ? (_jsx(Button, { className: "gd-button gd-button-action gd-error-overlay-button", value: buttonValue, onClick: onButtonClick })) : null] }) }));
}
/**
 * @internal
 */
export const ErrorOverlay = memo(function ErrorOverlay(props) {
    return (_jsx(IntlWrapper, { locale: props.locale, children: _jsx(ErrorOverlayCore, { ...props }) }));
});
