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; };

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

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 CLink from './CLink';
import CBadge from './CBadge';
import CIcon from './CIcon';

//component - CoreUI / CSidebarNavLink

var CSidebarNavLink = function CSidebarNavLink(props) {
  var children = props.children,
      className = props.className,
      custom = props.custom,
      label = props.label,
      icon = props.icon,
      fontIcon = props.fontIcon,
      badgeClassName = props.badgeClassName,
      badgeProps = props.badgeProps,
      attributes = _objectWithoutProperties(props, ['children', 'className', 'custom', 'label', 'icon', 'fontIcon', 'badgeClassName', 'badgeProps']);

  // render

  var classes = classNames(className, label ? 'c-sidebar-nav-label' : 'c-sidebar-nav-link');

  var iconProps = void 0;
  if ((typeof icon === 'undefined' ? 'undefined' : _typeof(icon)) === 'object') iconProps = icon;else iconProps = { name: icon };

  if (!custom) {
    var iconClasses = classNames('c-sidebar-nav-icon', fontIcon ? fontIcon : null);
    var badgeClasses = classNames(badgeClassName);
    return React.createElement(
      CLink,
      _extends({}, attributes, { className: classes }),
      icon ? React.createElement(CIcon, _extends({ className: 'c-sidebar-nav-icon' }, iconProps)) : '',
      fontIcon ? React.createElement('i', { className: iconClasses }) : '',
      children,
      badgeProps ? React.createElement(
        CBadge,
        _extends({ className: badgeClasses }, badgeProps),
        badgeProps.text
      ) : ''
    );
  }

  return React.createElement(CLink, _extends({}, attributes, { className: classes }));
};

CSidebarNavLink.propTypes = process.env.NODE_ENV !== "production" ? {
  children: PropTypes.node,
  className: PropTypes.string,
  custom: PropTypes.bool,
  //
  innerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.string, PropTypes.object]),
  icon: PropTypes.oneOfType(['string', 'object']),
  label: PropTypes.bool,
  fontIcon: PropTypes.string,
  badgeProps: PropTypes.object,
  badgeClassName: PropTypes.object
} : {};

CSidebarNavLink.defaultProps = {};

export default CSidebarNavLink;