// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

import { cloneElement } from 'react';
import classNames from 'classnames';
import Tooltip from '../Tooltip';
import { CLS_PREFIX } from '../../constants';
import { createProxyProps } from '../utils';
import MenuBaseItem from './MenuBaseItem';
import { jsx as _jsx } from "react/jsx-runtime";
/**
 * `MenuItem` is a part of [Menu](#!/Menu) component.
 * @since 0.0.55
 */
const MenuItem = _ref => {
  let {
    className,
    children,
    onClick,
    icon,
    label,
    tooltip,
    baseClassName = `${CLS_PREFIX}menu__item`,
    disabled = false,
    active = false,
    ...props
  } = _ref;
  const element = /*#__PURE__*/_jsx(MenuBaseItem, {
    className: classNames(baseClassName, className, {
      [`${baseClassName}--active`]: active,
      [`${baseClassName}--disabled`]: disabled
    }),
    onClick: e => {
      if (onClick && !disabled) {
        onClick(e);
      }
    },
    role: "menuitem",
    "aria-disabled": disabled ? 'true' : undefined,
    tabIndex: disabled ? -1 : 0,
    icon: icon,
    label: label,
    ...props,
    children: children
  });
  if (tooltip) {
    return createProxyProps(props => /*#__PURE__*/_jsx(Tooltip, {
      title: tooltip,
      children: /*#__PURE__*/cloneElement(element, props)
    }));
  }
  return element;
};
export default MenuItem;