import React from 'react';
import { FontAwesomeIcon } from '../font-awesome-icon';
import { Tooltip, TOOLTIP_DELAY_TYPES, TOOLTIP_PLACEMENT_TYPES } from '../tooltip';
import { Button, ACCENT_TYPES, BUTTON_SIZES } from '../button';
import { jsx as _jsx } from "react/jsx-runtime";
const FileTreeItemActions = ({
  item,
  actions = [],
  buttonsSize = BUTTON_SIZES.XS,
  testId = 'file-tree-item-actions'
}) => {
  if (!actions.length) {
    return null;
  }
  const renderIcon = action => {
    const iconElement = /*#__PURE__*/_jsx(FontAwesomeIcon, {
      icon: action.icon
    });
    if (!action.tooltip) {
      return iconElement;
    }
    return /*#__PURE__*/_jsx(Tooltip, {
      content: action.tooltip,
      placement: TOOLTIP_PLACEMENT_TYPES.TOP,
      delayType: TOOLTIP_DELAY_TYPES.MEDIUM,
      children: /*#__PURE__*/_jsx("span", {
        children: iconElement
      })
    });
  };
  return (
    /*#__PURE__*/
    // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
    _jsx("div", {
      className: "item-actions",
      "test-id": testId,
      onClick: e => e.stopPropagation(),
      children: actions.map((action, index) => {
        if (!action.method) {
          return null;
        }
        return /*#__PURE__*/_jsx(Button, {
          testId: action.testId,
          accentType: ACCENT_TYPES.ROUND_ICON,
          onClick: () => action.method?.(item),
          size: buttonsSize,
          "aria-label": action.ariaLabel,
          children: renderIcon(action)
        }, index);
      })
    })
  );
};
export default FileTreeItemActions;