'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 _RichText = require('../../organisms/RichText');

var _RichText2 = _interopRequireDefault(_RichText);

require('./style.css');

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

var PressTeaser = function PressTeaser(pressTeaser) {
  var imageClass = pressTeaser.image ? 'ma__press-teaser ma__press-teaser--image' : 'ma__press-teaser';
  var Element = 'h' + (pressTeaser.level || 2);
  if (process.env.NODE_ENV === 'development') {
    /* eslint-disable-next-line no-console */
    console.warn('This component is deprecated and will be archived in v10. Use the GenTeaser Organism instead.');
  }
  return _react2.default.createElement(
    'section',
    { className: imageClass },
    pressTeaser.image && pressTeaser.image.src && _react2.default.createElement(
      'a',
      {
        className: 'ma__press-teaser__image',
        href: pressTeaser.title.href,
        title: pressTeaser.title.text
      },
      _react2.default.createElement('span', {
        'aria-label': pressTeaser.image.alt,
        role: 'img',
        style: { backgroundImage: 'url(' + pressTeaser.image.src + ')' }
      })
    ),
    _react2.default.createElement(
      'div',
      { className: 'ma__press-teaser__details' },
      pressTeaser.eyebrow && _react2.default.createElement(
        'div',
        { className: 'ma__press-teaser__eyebrow' },
        _react2.default.createElement(
          'span',
          null,
          pressTeaser.eyebrow
        )
      ),
      _react2.default.createElement(
        Element,
        { className: 'ma__press-teaser__title' },
        _react2.default.createElement(_DecorativeLink2.default, pressTeaser.title)
      ),
      (pressTeaser.date || pressTeaser.org) && _react2.default.createElement(
        'div',
        { className: 'ma__press-teaser__details' },
        pressTeaser.date && _react2.default.createElement(
          'span',
          { className: 'ma__press-teaser__date' },
          pressTeaser.date
        ),
        pressTeaser.org && _react2.default.createElement(
          'span',
          { className: 'ma__press-teaser__org' },
          pressTeaser.org
        )
      ),
      pressTeaser.description && _react2.default.createElement(
        'div',
        { className: 'ma__press-teaser__description' },
        _react2.default.createElement(_RichText2.default, pressTeaser.description)
      )
    )
  );
};

PressTeaser.propTypes = process.env.NODE_ENV !== "production" ? {
  /** The image to be displayed in the teaser
    src: The src url for the image
    alt: The alternate text explaining the image, required for accessibility */
  image: _propTypes2.default.shape({
    src: _propTypes2.default.string.isRequired,
    alt: _propTypes2.default.string.isRequired
  }),
  /** The short for tag that will appear in the eyebrow, e.g. press release */
  eyebrow: _propTypes2.default.string,
  /** A linked title for the teaser content, @atoms/links/DecorativeLink */
  title: _propTypes2.default.shape(_DecorativeLink2.default.propTypes).isRequired,
  /** The heading level */
  level: _propTypes2.default.number,
  /** The date the teaser content represents */
  date: _propTypes2.default.string,
  /** The author/publishing entity of the teaser content */
  org: _propTypes2.default.string,
  /** A short description of the teaser content, rendered as a paragraph */
  description: _propTypes2.default.shape(_RichText2.default.propTypes)
} : {};

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