'use strict';

exports.__esModule = true;

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _classnames = require('classnames');

var _classnames2 = _interopRequireDefault(_classnames);

var _CLink = require('./CLink');

var _CLink2 = _interopRequireDefault(_CLink);

var _CBadge = require('./CBadge');

var _CBadge2 = _interopRequireDefault(_CBadge);

var _CIcon = require('./CIcon');

var _CIcon2 = _interopRequireDefault(_CIcon);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: 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; }

//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 = (0, _classnames2.default)(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 = (0, _classnames2.default)('c-sidebar-nav-icon', fontIcon ? fontIcon : null);
    var badgeClasses = (0, _classnames2.default)(badgeClassName);
    return _react2.default.createElement(
      _CLink2.default,
      _extends({}, attributes, { className: classes }),
      icon ? _react2.default.createElement(_CIcon2.default, _extends({ className: 'c-sidebar-nav-icon' }, iconProps)) : '',
      fontIcon ? _react2.default.createElement('i', { className: iconClasses }) : '',
      children,
      badgeProps ? _react2.default.createElement(
        _CBadge2.default,
        _extends({ className: badgeClasses }, badgeProps),
        badgeProps.text
      ) : ''
    );
  }

  return _react2.default.createElement(_CLink2.default, _extends({}, attributes, { className: classes }));
};

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

CSidebarNavLink.defaultProps = {};

exports.default = CSidebarNavLink;
module.exports = exports['default'];