import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2020-2025 GoodData Corporation
import { Fragment } from "react";
import cx from "classnames";
import { FormattedMessage, defineMessages } from "react-intl";
import { Overlay, Separator } from "@gooddata/sdk-ui-kit";
function DropdownItem({ onClick, labelIntlKey, classNames }) {
    const cssClasses = cx("gd-list-item gd-menu-item", classNames);
    return (_jsx("div", { className: cssClasses, onClick: onClick, children: _jsx(FormattedMessage, { id: labelIntlKey }) }));
}
const labelMessages = defineMessages({
    delete: { id: "alerting.alert.menu.delete" },
    pause: { id: "alerting.alert.menu.pause" },
    resume: { id: "alerting.alert.menu.resume" },
    edit: { id: "alerting.alert.menu.edit" },
});
export function AlertDropdown({ isReadOnly, paused, alignTo, onClose, onEdit, onPause, onDelete, onResume, }) {
    const editItem = {
        labelIntlKey: labelMessages.edit.id,
        classNames: "s-edit-alert-button",
        onClick: onEdit,
    };
    const pauseItem = paused
        ? {
            labelIntlKey: labelMessages.resume.id,
            classNames: "s-resume-alert-button",
            onClick: onResume,
        }
        : {
            labelIntlKey: labelMessages.pause.id,
            classNames: "s-pause-alert-button",
            onClick: onPause,
        };
    const deleteItem = {
        labelIntlKey: labelMessages.delete.id,
        classNames: "s-delete-alert-button deleteItem",
        onClick: onDelete,
        separator: isReadOnly ? undefined : "up",
    };
    const dropdownActions = isReadOnly
        ? [deleteItem]
        : [editItem, pauseItem, deleteItem];
    return (_jsx(Overlay, { className: "s-alert-dropdown", closeOnOutsideClick: true, alignTo: alignTo, alignPoints: [{ align: "br tr" }, { align: "tr br" }], onClose: onClose, positionType: "fixed", children: _jsx("div", { className: cx("gd-notifications-channels-dialog-menu", "gd-dropdown gd-menu-wrapper gd-menu-wrapper-small-spacing"), children: dropdownActions.map((item) => {
                return (_jsxs(Fragment, { children: [item.separator === "up" && _jsx(Separator, {}), _jsx(DropdownItem, { onClick: item.onClick, labelIntlKey: item.labelIntlKey, classNames: item.classNames }), item.separator === "down" && _jsx(Separator, {})] }, item.labelIntlKey));
            }) }) }));
}
//# sourceMappingURL=AlertDropdown.js.map