'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

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

var _propTypes2 = _interopRequireDefault(_propTypes);

var _DecorativeLink = require('../../atoms/links/DecorativeLink');

var _DecorativeLink2 = _interopRequireDefault(_DecorativeLink);

var _Image = require('../../atoms/media/Image');

var _Image2 = _interopRequireDefault(_Image);

var _Paragraph = require('../../atoms/text/Paragraph');

var _Paragraph2 = _interopRequireDefault(_Paragraph);

var _Icon = require('../../base/Icon');

var _Icon2 = _interopRequireDefault(_Icon);

require('./style.css');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var ImagePromo = function ImagePromo(props) {
  var HeadingElement = 'h' + (props.title.level || 2);
  var sectionClasses = ['ma__image-promo', props.stacked && 'ma__image-promo--stacked', props.small && 'ma__image-promo--small', props.location && props.location.map && 'js-location-listing-link'];
  var imagePromoHeader = _react2.default.createElement(
    'div',
    { className: 'ma__image-promo__header' },
    _react2.default.createElement(
      HeadingElement,
      { className: 'ma__image-promo__title' },
      props.tags && _react2.default.createElement(
        'div',
        { className: 'ma__image-promo__tags' },
        props.tags.map(function (tag) {
          return _react2.default.createElement(
            'span',
            { key: tag.id, title: tag.label, 'data-ma-tag-id': tag.id },
            tag.icon
          );
        })
      ),
      props.title ? _react2.default.createElement(_DecorativeLink2.default, props.title) : _react2.default.createElement(
        _react2.default.Fragment,
        null,
        props.title.text
      )
    ),
    props.subTitle && _react2.default.createElement(
      'h3',
      { className: 'ma__org-info__job-title' },
      props.subTitle
    )
  );
  return _react2.default.createElement(
    'section',
    { className: sectionClasses.join(' ') },
    _react2.default.createElement(
      'div',
      { className: 'ma__image-promo__image' },
      props.image && props.image.src && _react2.default.createElement(_Image2.default, props.image),
      props.stacked && imagePromoHeader
    ),
    _react2.default.createElement(
      'div',
      { className: 'ma__image-promo__details' },
      !props.stacked && imagePromoHeader,
      props.location && props.location.text && _react2.default.createElement(
        'div',
        { className: 'ma__image-promo__location' },
        props.location.text,
        props.link && props.link.text && _react2.default.createElement(
          'div',
          null,
          _react2.default.createElement(_DecorativeLink2.default, props.link)
        )
      ),
      props.phone && _react2.default.createElement(
        'div',
        { className: 'ma__image-promo__phone' },
        _react2.default.createElement(_Icon2.default, { name: 'phone' }),
        '\xA0',
        props.phone.href ? _react2.default.createElement(
          'a',
          { href: 'tel:' + props.phone.href },
          props.phone.text
        ) : _react2.default.createElement(
          'span',
          null,
          props.phone.text
        )
      ),
      props.description && _react2.default.createElement(
        'div',
        { className: 'ma__image-promo__description' },
        _react2.default.createElement(_Paragraph2.default, { text: props.description })
      ),
      props.link && !props.location && _react2.default.createElement(
        'div',
        { className: 'ma__image-promo__link' },
        _react2.default.createElement(_DecorativeLink2.default, props.link)
      )
    )
  );
};

ImagePromo.propTypes = process.env.NODE_ENV !== "production" ? {
  title: _propTypes2.default.shape({
    level: _propTypes2.default.number,
    href: _propTypes2.default.string.isRequired,
    text: _propTypes2.default.string.isRequired
  }),
  tags: _propTypes2.default.arrayOf(_propTypes2.default.shape({
    id: _propTypes2.default.string.isRequired,
    label: _propTypes2.default.string,
    icon: _propTypes2.default.element
  })),
  image: _propTypes2.default.shape({
    src: _propTypes2.default.string,
    alt: _propTypes2.default.string,
    width: _propTypes2.default.number,
    height: _propTypes2.default.number
  }),
  /** Stack image and details */
  stacked: _propTypes2.default.bool,
  /** Stack image and details */
  small: _propTypes2.default.bool,
  /** Add a subtitle field below title */
  subTitle: _propTypes2.default.string,
  description: _propTypes2.default.string,
  link: _propTypes2.default.shape({
    text: _propTypes2.default.string,
    href: _propTypes2.default.string,
    info: _propTypes2.default.string
  }),
  location: _propTypes2.default.shape({
    text: _propTypes2.default.string,
    map: _propTypes2.default.bool
  }),
  phone: _propTypes2.default.shape({
    text: _propTypes2.default.string.isRequired,
    href: _propTypes2.default.string
  })
} : {};

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