import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["href", "type", "children", "target", "className"];
import React from "react";
import PropTypes from "prop-types";
import classnames from "classnames";
import makeStyles from "../../styles/makeStyles";
var getClasses = makeStyles({
  link: {
    textDecoration: "none",
    color: "currentColor"
  },
  button: {
    border: 0,
    "&:not(:disabled)": {
      cursor: "pointer"
    }
  }
});
var ButtonBase = /*#__PURE__*/React.forwardRef(function (props, forwardedRef) {
  var href = props.href,
      type = props.type,
      children = props.children,
      target = props.target,
      className = props.className,
      attrs = _objectWithoutProperties(props, _excluded);

  var defaultRel = target === "_blank" ? "noopener" : undefined;
  var classes = getClasses();

  if (href) {
    return /*#__PURE__*/React.createElement("a", _extends({
      rel: defaultRel
    }, attrs, {
      ref: forwardedRef,
      className: classnames(className, classes.link),
      href: href,
      target: target
    }), children);
  }

  return /*#__PURE__*/React.createElement("button", _extends({}, attrs, {
    type: type,
    ref: forwardedRef,
    className: classnames(className, classes.button)
  }), children);
});
ButtonBase.propTypes = {
  href: PropTypes.string,
  target: PropTypes.string,
  rel: PropTypes.string
};
ButtonBase.defaultProps = {
  type: "button"
};
export default ButtonBase;