import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Xmark } from '@gravity-ui/icons';
import { Button, Icon, Popup, Text } from '@gravity-ui/uikit';
import { block } from "../../../utils/cn.js";
import { i18n } from "./i18n/index.js";
import "./ActionPopup.css";
const b = block('action-popup');
/**
 * ActionPopup - Universal anchored popup container for displaying content near action buttons
 *
 * This component provides a flexible popup container that can be anchored to any element
 * (typically action buttons). It supports optional title and subtitle, and can contain
 * any React content as children.
 *
 * @returns React element with anchored popup
 */
export function ActionPopup({ open, onOpenChange, anchorElement, title, subtitle, children, placement = 'bottom-start', className, qa, }) {
    const hasHeader = title || subtitle;
    const handleClose = () => {
        onOpenChange(false);
    };
    return (_jsx(Popup, { open: open, onOpenChange: onOpenChange, anchorElement: anchorElement, placement: placement, className: b(null, className), qa: qa, children: _jsxs("div", { className: b('container'), children: [hasHeader && (_jsxs("div", { className: b('header'), children: [_jsxs("div", { className: b('header-content'), children: [title && _jsx(Text, { variant: "subheader-2", children: title }), subtitle && (_jsx(Text, { variant: "body-1", color: "secondary", children: subtitle }))] }), _jsx(Button, { view: "flat-secondary", size: "s", onClick: handleClose, className: b('close-button'), qa: qa ? `${qa}-close` : undefined, "aria-label": i18n('close'), children: _jsx(Icon, { data: Xmark, size: 16 }) })] })), children] }) }));
}
//# sourceMappingURL=ActionPopup.js.map
