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 { mapToCssModules, tagPropType } from './Shared/helper.js';

//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 React.createElement('img', {
      src: imgSrc(props),
      width: imgWidth(props),
      height: imgHeight(props),
      alt: imgAlt(props),
      className: classBrand,
      key: key.toString()
    });
  };

  //render

  var classes = classNames(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 React.createElement(
    Tag,
    _extends({}, attributes, { className: classes, ref: innerRef }),
    children || img
  );
};

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

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

export default CNavbarBrand;