text: import React from 'react';
  import PropTypes from 'prop-types';
  import Icon from '@material-ui/core/Icon';
  import IconButton from '@material-ui/core/IconButton';
  import Tooltip from '@material-ui/core/Tooltip';
  function MTableAction(props) {
    function render() {
      let action = props.action;
      if (typeof action === 'function') {
        action = action(props.data);
        if (!action) {
          return null;
        }
      }
      if (action.action) {
        action = action.action(props.data);
        if (!action) {
          return null;
        }
      }
      if (action.hidden) {
        return null;
      }
      const disabled = action.disabled || props.disabled;
      const handleOnClick = (event) => {
        if (action.onClick) {
          action.onClick(event, props.data);
          event.stopPropagation();
        }
      };
      const handlers = action.handlers || {};
      const eventHandlers = Object.entries(handlers).reduce((o, [k, v]) => {
        o[k] = (e) => v(e, props.data);
        return o;
      }, {});
      const icon =
        typeof action.icon === 'string'
          ? /* @__PURE__ */ React.createElement(
              Icon,
              {
                ...action.iconProps
              },
              action.icon
            )
          : typeof action.icon === 'function'
          ? action.icon({ ...action.iconProps, disabled })
          : /* @__PURE__ */ React.createElement(action.icon, null);
      const button = /* @__PURE__ */ React.createElement(
        IconButton,
        {
          ref: props.forwardedRef,
          size: props.size,
          color: 'inherit',
          disabled,
          onClick: handleOnClick,
          ...eventHandlers
        },
        icon
      );
      if (action.tooltip) {
        return disabled
          ? /* @__PURE__ */ React.createElement(
              Tooltip,
              {
                title: action.tooltip
              },
              /* @__PURE__ */ React.createElement('span', null, button)
            )
          : /* @__PURE__ */ React.createElement(
              Tooltip,
              {
                title: action.tooltip
              },
              button
            );
      } else {
        return button;
      }
    }
    return render();
  }
  MTableAction.defaultProps = {
    action: {},
    data: {}
  };
  MTableAction.propTypes = {
    action: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired,
    data: PropTypes.oneOfType([
      PropTypes.object,
      PropTypes.arrayOf(PropTypes.object)
    ]),
    disabled: PropTypes.bool,
    size: PropTypes.string
  };
  var MTableAction_default = React.forwardRef(function MTableActionRef(
    props,
    ref
  ) {
    return /* @__PURE__ */ React.createElement(MTableAction, {
      ...props,
      forwardedRef: ref
    });
  });
  export { MTableAction_default as default };
  