import './_commonjsHelpers-0c4b6f40.js';
import './_to-object-cedb5b78.js';
import './es6.string.iterator-1577cb76.js';
import './_library-528f1934.js';
import './_iter-detect-0fa1c752.js';
import './toConsumableArray-81605212.js';
import './core.get-iterator-method-227107e6.js';
import './_object-pie-33c40e79.js';
import { _ as _extends } from './extends-be71a29a.js';
import './_object-sap-1b84e2bf.js';
import './inherits-2cf82c38.js';
import './define-property-2f35af22.js';
import './web.dom.iterable-ace8ed30.js';
import './typeof-ad2c7a21.js';
import './_is-array-328b85b7.js';
import React__default, { useState, useEffect } from 'react';
import './events-6c3a7a63.js';
import './index-41a678ea.js';
import 'prop-types';
import 'react-bootstrap/Row';
import 'react-bootstrap/Col';
import './moment-b6f49411.js';
import { useRouter } from 'next/router';
import './isSymbol-1981418f.js';
import './debounce-89969f66.js';
import './toNumber-e3dcad26.js';
import 'react-dom';
import './index-f7fdcc91.js';
import './urlFor.js';
import './index-5f7e79e7.js';
import './main-ae902629.js';
import './entities-7cc3bf45.js';
import { _ as _slicedToArray } from './slicedToArray-f0edf3d6.js';
import './stringify-d1b9276a.js';
import './asyncToGenerator-e1a2f43a.js';
import './Segment.js';
import './Beam.js';
import './AdSlot.js';
import Button$1 from 'react-bootstrap/Button';
import { B as BlockContent } from './BlockContent-ea93e8f7.js';
import './index-c7e2ac95.js';
import './smoothscroll-0cd4c7a6.js';
import './GroupDeck.js';
import 'react-bootstrap';
import './iconBase-602d52fe.js';
import './index.esm-3fdda599.js';
import { g as getSerializers } from './index-37848dc4.js';
import './util-7700fc59.js';
import './brightcove-react-player-loader.es-e761d404.js';
import 'next/head';
import 'react-share';
import './SocialShare.js';
import './_object-to-array-c8f72bf1.js';
import 'react-bootstrap/Pagination';
import 'react-bootstrap/Figure';
import { m as momentTimezone } from './index-511bdaa5.js';

var ExternalResources = function ExternalResources(props) {
  var resources = props.resources,
      display = props.display,
      client = props.client,
      _props$cta = props.cta,
      cta = _props$cta === undefined ? 'Learn More' : _props$cta,
      _props$url = props.url,
      url = _props$url === undefined ? 'resources' : _props$url,
      _props$recentTitle = props.recentTitle,
      recentTitle = _props$recentTitle === undefined ? 'Recent' : _props$recentTitle,
      _props$archiveTitle = props.archiveTitle,
      archiveTitle = _props$archiveTitle === undefined ? 'Archive' : _props$archiveTitle,
      _props$dispalyThumb = props.dispalyThumb,
      dispalyThumb = _props$dispalyThumb === undefined ? true : _props$dispalyThumb,
      _props$dateFormat = props.dateFormat,
      dateFormat = _props$dateFormat === undefined ? 'MMMM Do YYYY, h:mm a z' : _props$dateFormat,
      _props$showToggles = props.showToggles,
      showToggles = _props$showToggles === undefined ? true : _props$showToggles;

  var _useState = useState(display && (display === 'recent' || display === 'archived') ? display : 'recent'),
      _useState2 = _slicedToArray(_useState, 2),
      active = _useState2[0],
      setActive = _useState2[1];

  var router = useRouter();
  useEffect(function () {
    router.push(router.pathname, '/' + url + '?display=' + active, { shallow: true });
  }, [active]);
  return React__default.createElement(
    'div',
    { id: 'resources' },
    showToggles && React__default.createElement(
      'div',
      { id: 'toggles' },
      React__default.createElement(
        'div',
        { onClick: function onClick() {
            return setActive(function () {
              return 'recent';
            });
          }, className: active === 'recent' ? 'active' : '' },
        recentTitle
      ),
      React__default.createElement(
        'div',
        { onClick: function onClick() {
            return setActive(function () {
              return 'archived';
            });
          }, className: active === 'archived' ? 'active' : '' },
        archiveTitle
      )
    ),
    resources[active].length > 0 ? resources[active].map(function (r) {
      return React__default.createElement(
        'div',
        { key: r._id, className: 'resource' },
        dispalyThumb && React__default.createElement(
          'div',
          { id: 'thumb' },
          React__default.createElement(
            'a',
            { href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            React__default.createElement('img', { src: r.thumbnail })
          )
        ),
        React__default.createElement(
          'div',
          { id: 'details' },
          React__default.createElement(
            'a',
            { href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            React__default.createElement(
              'p',
              { id: 'title' },
              r.title
            ),
            r.intro && React__default.createElement(
              'div',
              { id: 'intro' },
              React__default.createElement(BlockContent, _extends({ serializers: getSerializers(client), blocks: r.intro }, client.config()))
            ),
            React__default.createElement(
              'div',
              { id: 'date' },
              React__default.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Date:'
              ),
              React__default.createElement(
                'p',
                null,
                momentTimezone.tz(r.displayDate, 'America/New_York').format(dateFormat),
                ' ',
                r.endDate && '- ' + momentTimezone.tz(r.endDate, 'America/New_York').format(dateFormat)
              )
            ),
            r.speakers && React__default.createElement(
              'div',
              { id: 'speakers' },
              React__default.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Speakers:'
              ),
              React__default.createElement(BlockContent, _extends({ serializers: getSerializers(client), blocks: r.speakers }, client.config()))
            ),
            r.location && React__default.createElement(
              'div',
              { id: 'location' },
              React__default.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Location:'
              ),
              r.location
            ),
            r.sponsor && React__default.createElement(
              'div',
              { id: 'sponsor' },
              React__default.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Sponsors:'
              ),
              r.sponsor
            )
          ),
          React__default.createElement(
            Button$1,
            { id: 'cta', variant: 'secondary', href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            cta
          )
        )
      );
    }) : React__default.createElement(
      'p',
      null,
      'No content available.'
    ),
    React__default.createElement(
      'style',
      { jsx: true },
      '\n        .resource {\n          display: flex;\n          position: relative;\n          margin: 0 0 1rem 0;\n        }\n        .resource #thumb {\n          box-sizing: border-box;\n          padding: 0.5rem;\n          width: 25%;\n        }\n        .resource #thumb img {\n          width: 100%;\n        }\n        .resource #details {\n          box-sizing: border-box;\n          padding: 0.5rem;\n          width: 75%;\n        }\n        #resources .resource p {\n          margin: 0;\n        }\n        #toggles {\n          display: flex;\n          margin: 0 0 1rem 0;\n        }\n        #toggles > div {\n          padding: 0.5rem;\n          cursor: pointer;\n        }\n        #toggles > div:hover {\n          font-weight: bold;\n          border-bottom: 2px solid #cecece;\n        }\n        #toggles > div.active {\n          font-weight: bold;\n          border-bottom: 2px solid var(--primary);\n        }\n        .resource #title {\n          font-weight: bold;\n          font-size: 1.25rem;\n        }\n        .resource #date,\n        .resource #speakers,\n        .resource #location,\n        .resource #sponsor,\n        .resource #cta {\n          margin: 1rem 0 0 0;\n        }\n      '
    )
  );
};

export default ExternalResources;
