var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import CSidebarNavLink from './CSidebarNavLink';

//component - CoreUI / CSidebarNavItem

var CSidebarNavItem = function CSidebarNavItem(props) {
  var Tag = props.tag,
      children = props.children,
      className = props.className,
      custom = props.custom,
      innerRef = props.innerRef,
      linkClassName = props.linkClassName,
      linkProps = props.linkProps,
      icon = props.icon,
      to = props.to,
      badge = props.badge,
      attributes = _objectWithoutProperties(props, ['tag', 'children', 'className', 'custom', 'innerRef', 'linkClassName', 'linkProps', 'icon', 'to', 'badge']);

  var link = _extends({}, linkProps);

  //render

  var classes = classNames(className, 'c-sidebar-nav-item');

  var linkClasses = classNames(linkClassName);

  !link && (link = {});
  icon && (link.icon = icon);
  to && (link.to = to);
  badge && (link.badgeProps = badge);

  return !custom ? React.createElement(
    Tag,
    _extends({ className: classes }, attributes, { ref: innerRef }),
    React.createElement(CSidebarNavLink, _extends({ className: linkClasses }, link, { children: children }))
  ) : React.createElement(Tag, _extends({ className: classes }, attributes, { ref: innerRef, children: children }));
};

CSidebarNavItem.propTypes = process.env.NODE_ENV !== "production" ? {
  tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
  children: PropTypes.node,
  className: PropTypes.string,
  custom: PropTypes.bool,
  //
  innerRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func, PropTypes.string]),
  linkClassName: PropTypes.string,
  linkProps: PropTypes.object,
  ///
  icon: PropTypes.oneOfType(['string', 'object']),
  badge: PropTypes.object
} : {};

CSidebarNavItem.defaultProps = {
  tag: 'li'
};

export default CSidebarNavItem;