import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "className", "onSelect", "href", "textAlign", "color", "shade"];
import React from "react";
import PropTypes from "prop-types";
import cx from "classnames";
import { Item } from "@radix-ui/react-dropdown-menu";
import { getColorsLabels, getShades } from "../../styles/colors";
import createComponent from "../../system/createComponent";
import getClasses from "./styles";
var colorsList = getColorsLabels(true);
var shadesList = getShades();
var MenuItem = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var children = props.children,
      className = props.className,
      onSelect = props.onSelect,
      href = props.href,
      textAlign = props.textAlign,
      color = props.color,
      shade = props.shade,
      restProps = _objectWithoutProperties(props, _excluded);

  var justifyContent = {
    left: "flex-start",
    center: "center",
    right: "flex-end"
  };
  var classes = getClasses({
    color: color,
    shade: shade,
    justifyContent: justifyContent[textAlign]
  });
  var rootClassName = cx(classes.item, className);

  if (href) {
    return /*#__PURE__*/React.createElement(Item, {
      ref: ref,
      asChild: true
    }, /*#__PURE__*/React.createElement("a", _extends({
      href: href,
      className: rootClassName
    }, restProps), children));
  }

  return /*#__PURE__*/React.createElement(Item, _extends({
    ref: ref,
    onSelect: onSelect,
    className: rootClassName
  }, restProps), children);
});
MenuItem.propTypes = {
  onSelect: PropTypes.func,
  href: PropTypes.string,
  disabled: PropTypes.bool,
  textAlign: PropTypes.oneOf(["left", "center", "right"]),
  color: PropTypes.oneOf(colorsList),
  shade: PropTypes.oneOf(shadesList)
};
MenuItem.defaultProps = {
  disabled: false,
  color: "neutral",
  shade: 500
};

if (process.env.NODE_ENV !== "production") {
  MenuItem.displayName = "MenuItem";
}

export default createComponent(MenuItem);