import React__default from 'react';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Card from 'react-bootstrap/Card';
import Badge from 'react-bootstrap/Badge';
import { L as LazyLoad } from './index-755f2cc2.js';
import urlFor from './urlFor.js';
import { m as moment } from './moment-bc12cb97.js';
import { A as AuthorComponent } from './AuthorComponent-11adff02.js';
import './_commonjsHelpers-0c4b6f40.js';
import 'react-dom';
import 'prop-types';
import './slicedToArray-6ebcbfea.js';
import './web.dom.iterable-ab4dea5c.js';
import './core.get-iterator-method-ea258bb1.js';
import './index-3f5c03b2.js';

var PublicationDeckStack = function PublicationDeckStack(props) {
  var title = props.title,
      coverImage = props.coverImage,
      link = props.link,
      published = props.published,
      author = props.author,
      summary = props.summary,
      section = props.section,
      _props$imageHeight = props.imageHeight,
      imageHeight = _props$imageHeight === undefined ? null : _props$imageHeight,
      _props$imageWidth = props.imageWidth,
      imageWidth = _props$imageWidth === undefined ? null : _props$imageWidth,
      _props$imageFit = props.imageFit,
      imageFit = _props$imageFit === undefined ? null : _props$imageFit,
      client = props.client,
      Settings = props.Settings,
      index = props.index,
      source = props.source;

  return React__default.createElement(
    Col,
    { md: 12, lg: 12, key: index },
    React__default.createElement(
      Card,
      { style: { boxShadow: 'none', borderBottom: '1px solid #aaa', paddingBottom: '1rem' } },
      React__default.createElement(
        'div',
        { style: { display: 'flex', flex: '1 0 auto', paddingBottom: '1rem' } },
        coverImage && React__default.createElement(
          'div',
          { style: { display: 'flex', flexDirection: 'column', justifyContent: 'center' } },
          React__default.createElement(
            'a',
            { href: '/view/' + link },
            React__default.createElement(
              LazyLoad,
              { height: imageHeight },
              React__default.createElement(Card.Img, {
                variant: 'right',
                src: coverImage ? urlFor({ source: coverImage, imageHeight: imageHeight, imageWidth: imageWidth, imageFit: imageFit, client: client }) : Settings.logo,
                alt: title,
                style: { width: '170px', height: 'auto', objectFit: 'contain', padding: '0.25rem', float: 'left' }
              })
            )
          ),
          source && React__default.createElement(
            'div',
            { className: 'mb-2 sanityDisplayLabel displayLabelThumb' },
            source
          )
        ),
        React__default.createElement(
          Card.Body,
          { style: { padding: '0.5rem' } },
          section ? React__default.createElement(
            Badge,
            { variant: 'success' },
            section.name
          ) : '',
          React__default.createElement(
            Card.Title,
            { style: { color: '#121212', fontSize: '1.1rem' } },
            React__default.createElement(
              'a',
              { href: '/view/' + link },
              React__default.createElement(
                'span',
                null,
                title
              )
            ),
            React__default.createElement('br', null)
          ),
          React__default.createElement(
            'div',
            { style: { float: 'left' } },
            source && !coverImage && React__default.createElement(
              'div',
              { className: 'content-category-label' },
              React__default.createElement(
                'div',
                { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                source
              )
            ),
            React__default.createElement(
              'p',
              { style: { color: '#484848', fontSize: '.9rem', fontWeight: '600' }, className: 'mb-0' },
              moment(published).format('MMMM DD, YYYY ')
            ),
            author.length > 0 && React__default.createElement(
              LazyLoad,
              { height: 50 },
              React__default.createElement(AuthorComponent, { key: index.toString(), index: index, authors: author })
            )
          )
        )
      ),
      React__default.createElement(
        'p',
        { style: { paddingLeft: '0.5rem' } },
        summary
      )
    )
  );
};

var PublicationDeckBlock = function PublicationDeckBlock(props) {
  var title = props.title,
      coverImage = props.coverImage,
      link = props.link,
      section = props.section,
      imageHeight = props.imageHeight,
      imageWidth = props.imageWidth,
      client = props.client,
      Settings = props.Settings,
      index = props.index;

  return React__default.createElement(
    Col,
    { md: 12, lg: 6, style: { display: 'flex', flex: '1 0 auto' }, key: index },
    React__default.createElement(
      Card,
      null,
      React__default.createElement(
        'a',
        { href: '/view/' + link },
        coverImage && React__default.createElement(
          LazyLoad,
          { height: imageHeight },
          React__default.createElement(Card.Img, { variant: 'top', src: coverImage ? urlFor({ source: coverImage, imageHeight: imageHeight, imageWidth: imageWidth, imageFit: imageFit, client: client, Settings: Settings }) : Settings.logo, alt: title })
        ),
        React__default.createElement(
          Card.Body,
          null,
          section && section.name ? React__default.createElement(
            Badge,
            { variant: 'success' },
            section && section.name
          ) : '',
          React__default.createElement(
            Card.Title,
            null,
            title
          )
        )
      )
    )
  );
};

var IssueContentDeck = function IssueContentDeck(props) {
  var data = props.data,
      imageHeight = props.imageHeight,
      imageWidth = props.imageWidth,
      website = props.website,
      client = props.client,
      _props$variant = props.variant,
      variant = _props$variant === undefined ? 'block' : _props$variant;

  return React__default.createElement(
    Row,
    null,
    data && data.length ? data.map(function (row, index) {
      if (variant === 'stack') {
        return row.url && row.url.current && React__default.createElement(PublicationDeckStack, {
          index: index,
          title: row.title,
          coverImage: row.thumbnail,
          link: row.url.current,
          section: row.issueSection,
          Settings: website,
          imageHeight: imageHeight,
          imageWidth: imageWidth,
          client: client,
          source: row.source,
          published: row.published,
          author: row.authorMapping && row.authorMapping.length > 0 ? row.authorMapping : [],
          summary: row.summary
        });
      }
      return React__default.createElement(PublicationDeckBlock, {
        index: index,
        title: row.title,
        coverImage: row.thumbnail,
        link: row.url.current,
        section: row.issueSection,
        Settings: website,
        imageHeight: imageHeight,
        imageWidth: imageWidth,
        client: client
      });
    }) : React__default.createElement(
      'div',
      null,
      React__default.createElement(
        'h5',
        null,
        React__default.createElement(
          'em',
          { className: 'pl-3' },
          'New content coming soon, please check back later.'
        )
      )
    ),
    React__default.createElement(
      'style',
      { jsx: 'true' },
      '\n          .displayLabelThumb {\n            margin: 0 auto;\n            margin-top: -1.25rem;\n            background-color: white;\n            position: relative;\n          }\n          .content-category-label {\n            margin: 0.5rem 0;\n            display: block;\n          }\n          .sanityDisplayLabel {\n            margin: 0.5rem 0;\n            border: 1px solid black;\n            width: 100%;\n            display: inline;\n            max-width: 240px;\n            padding: 5px;\n            color: #484848;\n            border-radius: 2px;\n          }\n        '
    )
  );
};

export { IssueContentDeck as default };
