import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2022-2026 GoodData Corporation
import { memo } from "react";
import cx from "classnames";
import { useIntl } from "react-intl";
import { IntlWrapper } from "@gooddata/sdk-ui";
import { Button } from "../Button/Button.js";
/**
 * @internal
 */
export const DialogCloseButtonCore = memo(function DialogCloseButton({ className, accessibilityConfig, onClose, }) {
    const intl = useIntl();
    const closeButtonAccessibilityConfig = {
        ariaLabel: intl.formatMessage({ id: "dialogs.closeLabel" }),
        ariaDescribedBy: accessibilityConfig?.descriptionElementId ?? accessibilityConfig?.titleElementId,
        ...accessibilityConfig?.closeButton,
    };
    return (_jsx("div", { className: "gd-dialog-close", children: _jsx(Button, { className: cx("gd-button-link gd-button-icon-only gd-icon-cross s-dialog-close-button", className), onClick: onClose, accessibilityConfig: closeButtonAccessibilityConfig }) }));
});
/**
 * @internal
 */
export function DialogCloseButton(props) {
    return (
    // TODO: local has to be passed as a prop
    // pay attention since there is focus manager and different locales are loaded asynchronously
    // there is delay and focus manager could failed because children are not rendered yet
    _jsx(IntlWrapper, { locale: "en-US", children: _jsx(DialogCloseButtonCore, { ...props }) }));
}
