import { jsx, jsxs } from "react/jsx-runtime";
import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "@uipath/apollo-wind";
import { CanvasIcon } from "../../utils/icon-registry.js";
function CanvasDropdownMenu({ open, onOpenChange, menuItems, onItemClick, triggerTestId, triggerAriaLabel = 'Dropdown menu', contentClassName, disabled }) {
    return /*#__PURE__*/ jsxs(DropdownMenu, {
        open: open,
        onOpenChange: onOpenChange,
        modal: false,
        children: [
            /*#__PURE__*/ jsx(DropdownMenuTrigger, {
                asChild: true,
                children: /*#__PURE__*/ jsx(Button, {
                    variant: "ghost",
                    size: "icon",
                    className: "h-6 w-6",
                    "data-testid": triggerTestId,
                    "aria-label": triggerAriaLabel,
                    disabled: disabled,
                    onClick: (e)=>e.stopPropagation(),
                    onPointerDown: (e)=>e.stopPropagation(),
                    children: /*#__PURE__*/ jsx(CanvasIcon, {
                        icon: "ellipsis-vertical",
                        size: 16
                    })
                })
            }),
            /*#__PURE__*/ jsx(DropdownMenuContent, {
                align: "end",
                sideOffset: 4,
                className: contentClassName,
                children: menuItems.map((item, index)=>{
                    if ('type' in item && 'divider' === item.type) return /*#__PURE__*/ jsx(DropdownMenuSeparator, {}, `divider-${index}`);
                    const actionItem = item;
                    return /*#__PURE__*/ jsxs(DropdownMenuItem, {
                        disabled: actionItem.disabled,
                        onSelect: ()=>onItemClick(actionItem),
                        children: [
                            actionItem.icon,
                            actionItem.label
                        ]
                    }, actionItem.id);
                })
            })
        ]
    });
}
export { CanvasDropdownMenu };
