'use strict';

var React = require('react');
var reactBootstrap = require('react-bootstrap');
var index = require('./index-efca863c.js');
var entities = require('./entities-3f9d0f2f.js');
require('./_commonjsHelpers-06173234.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

var urlFor = function urlFor(source, client) {
  var builder = index.imageUrlBuilder(client);
  return builder.image(source).auto('format');
};

var renderCardImage = function renderCardImage(thumbnail, client, imageHeight, imageWidth) {
  var url = urlFor(thumbnail, client);
  if (imageHeight) url = url.height(imageHeight);
  if (imageWidth) url = url.width(imageWidth);
  return url.url();
};

var Hero = function Hero(_ref) {
  var data = _ref.data,
      client = _ref.client,
      imageHeight = _ref.imageHeight,
      imageWidth = _ref.imageWidth;
  var title = data.title,
      summary = data.summary,
      thumbnail = data.thumbnail,
      url = data.url;

  return React__default['default'].createElement(
    'a',
    { href: '/view/' + url.current },
    React__default['default'].createElement(
      reactBootstrap.Card,
      { bsPrefix: 'hero-card' },
      title && React__default['default'].createElement(
        reactBootstrap.Card.Header,
        { className: 'h4' },
        title
      ),
      thumbnail && client && React__default['default'].createElement(reactBootstrap.Card.Img, { src: renderCardImage(thumbnail, client, imageHeight, imageWidth) }),
      summary && React__default['default'].createElement(
        reactBootstrap.Card.Footer,
        { className: 'h6' },
        entities.clean_html_1(summary)
      )
    )
  );
};

module.exports = Hero;
