"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _fontAwesomeIcon = require("../font-awesome-icon");
var _tooltip = require("../tooltip");
var _button = require("../button");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const FileTreeItemActions = ({
  item,
  actions = [],
  buttonsSize = _button.BUTTON_SIZES.XS,
  testId = 'file-tree-item-actions'
}) => {
  if (!actions.length) {
    return null;
  }
  const renderIcon = action => {
    const iconElement = /*#__PURE__*/(0, _jsxRuntime.jsx)(_fontAwesomeIcon.FontAwesomeIcon, {
      icon: action.icon
    });
    if (!action.tooltip) {
      return iconElement;
    }
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.Tooltip, {
      content: action.tooltip,
      placement: _tooltip.TOOLTIP_PLACEMENT_TYPES.TOP,
      delayType: _tooltip.TOOLTIP_DELAY_TYPES.MEDIUM,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
        children: iconElement
      })
    });
  };
  return (
    /*#__PURE__*/
    // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
    (0, _jsxRuntime.jsx)("div", {
      className: "item-actions",
      "test-id": testId,
      onClick: e => e.stopPropagation(),
      children: actions.map((action, index) => {
        if (!action.method) {
          return null;
        }
        return /*#__PURE__*/(0, _jsxRuntime.jsx)(_button.Button, {
          testId: action.testId,
          accentType: _button.ACCENT_TYPES.ROUND_ICON,
          onClick: () => action.method?.(item),
          size: buttonsSize,
          "aria-label": action.ariaLabel,
          children: renderIcon(action)
        }, index);
      })
    })
  );
};
var _default = exports.default = FileTreeItemActions;