'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 _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 _helper = require('./Shared/helper.js');

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 / CNavbarBrand

var CNavbarBrand = function CNavbarBrand(props) {
  var Tag = props.tag,
      className = props.className,
      children = props.children,
      innerRef = props.innerRef,
      attributes = _objectWithoutProperties(props, ['tag', 'className', 'children', 'innerRef']);

  var imgSrc = function imgSrc(brand) {
    return brand.src ? brand.src : '';
  };
  var imgWidth = function imgWidth(brand) {
    return brand.width ? brand.width : 'auto';
  };
  var imgHeight = function imgHeight(brand) {
    return brand.height ? brand.height : 'auto';
  };
  var imgAlt = function imgAlt(brand) {
    return brand.alt ? brand.alt : '';
  };
  var navbarBrandImg = function navbarBrandImg(props, classBrand, key) {
    return _react2.default.createElement('img', {
      src: imgSrc(props),
      width: imgWidth(props),
      height: imgHeight(props),
      alt: imgAlt(props),
      className: classBrand,
      key: key.toString()
    });
  };

  //render

  var classes = (0, _classnames2.default)(className, 'navbar-brand');

  var img = [];
  if (props.brand) {
    var classBrand = 'navbar-brand'; //navbar-brand
    img.push(navbarBrandImg(props.brand, classBrand, img.length + 1));
  }
  if (props.full) {
    var _classBrand = 'navbar-brand-full';
    img.push(navbarBrandImg(props.full, _classBrand, img.length + 1));
  }
  if (props.minimized) {
    var _classBrand2 = 'navbar-brand-minimized';
    img.push(navbarBrandImg(props.minimized, _classBrand2, img.length + 1));
  }

  return _react2.default.createElement(
    Tag,
    _extends({}, attributes, { className: classes, ref: innerRef }),
    children || img
  );
};

CNavbarBrand.propTypes = process.env.NODE_ENV !== "production" ? {
  tag: _helper.tagPropType,
  className: _propTypes2.default.string,
  children: _propTypes2.default.node,
  //
  innerRef: _propTypes2.default.oneOfType([_propTypes2.default.object, _propTypes2.default.func, _propTypes2.default.string]),
  brand: _propTypes2.default.any,
  full: _propTypes2.default.any,
  minimized: _propTypes2.default.any
} : {};

CNavbarBrand.defaultProps = {
  tag: 'div'
};

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