import { _ as _extends } from './extends-60e0e1c6.js';
import { _ as _slicedToArray } from './slicedToArray-be2f7a22.js';
import React, { useState, useEffect } from 'react';
import { B as BlockContent } from './BlockContent-52cf21c5.js';
import { g as getSerializers } from './index-1654b705.js';
import { m as momentTimezone } from './index-79cfd25c.js';
import { useRouter } from 'next/router';
import Button from 'react-bootstrap/Button';
import './_commonjsHelpers-0c4b6f40.js';
import './_to-object-b50e61c3.js';
import './_object-pie-133f504a.js';
import './web.dom.iterable-4109ff68.js';
import './es6.string.iterator-bc33758b.js';
import './core.get-iterator-method-133dfacd.js';
import 'prop-types';
import './index-0dbff1d1.js';
import 'react-bootstrap';
import './urlFor.js';
import './index-2446af28.js';
import './events-6c3a7a63.js';
import './index-c7e2ac95.js';
import './util-3ab476bf.js';
import './Beam.js';
import './stringify-59c8f690.js';
import './asyncToGenerator-7f8f9219.js';
import './_library-528f1934.js';
import './_iter-detect-7e5e5ce2.js';
import './Segment.js';
import './main-b5c5aac1.js';
import './index-35bdcc81.js';
import 'react-dom';
import './typeof-a286cf0c.js';
import './_is-array-3e99e06e.js';
import './brightcove-react-player-loader.es-b43c695a.js';
import './GroupDeck.js';
import './smoothscroll-fa4e3f8c.js';
import './moment-bc12cb97.js';
import './SocialShare.js';
import 'next/head';
import 'react-share';
import './_object-to-array-0f197f89.js';
import './toConsumableArray-6d9a4616.js';
import 'react-bootstrap/Pagination';
import './entities-932b50cf.js';
import './AdSlot.js';
import './debounce-533d9748.js';
import './isSymbol-a7e9aafe.js';
import './toNumber-5aeba6e7.js';
import 'react-bootstrap/Row';
import 'react-bootstrap/Col';
import './inherits-a41fe93f.js';
import './_object-sap-f353c2a9.js';
import './define-property-fe54dc9f.js';
import './index.esm-3fdda599.js';
import './iconBase-602d52fe.js';
import 'react-bootstrap/Figure';

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.createElement(
    'div',
    { id: 'resources' },
    showToggles && React.createElement(
      'div',
      { id: 'toggles' },
      React.createElement(
        'div',
        { onClick: function onClick() {
            return setActive(function () {
              return 'recent';
            });
          }, className: active === 'recent' ? 'active' : '' },
        recentTitle
      ),
      React.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.createElement(
        'div',
        { key: r._id, className: 'resource' },
        dispalyThumb && React.createElement(
          'div',
          { id: 'thumb' },
          React.createElement(
            'a',
            { href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            React.createElement('img', { src: r.thumbnail })
          )
        ),
        React.createElement(
          'div',
          { id: 'details' },
          React.createElement(
            'a',
            { href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            React.createElement(
              'p',
              { id: 'title' },
              r.title
            ),
            r.intro && React.createElement(
              'div',
              { id: 'intro' },
              React.createElement(BlockContent, _extends({ serializers: getSerializers(client), blocks: r.intro }, client.config()))
            ),
            React.createElement(
              'div',
              { id: 'date' },
              React.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Date:'
              ),
              React.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.createElement(
              'div',
              { id: 'speakers' },
              React.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Speakers:'
              ),
              React.createElement(BlockContent, _extends({ serializers: getSerializers(client), blocks: r.speakers }, client.config()))
            ),
            r.location && React.createElement(
              'div',
              { id: 'location' },
              React.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Location:'
              ),
              r.location
            ),
            r.sponsor && React.createElement(
              'div',
              { id: 'sponsor' },
              React.createElement(
                'p',
                { style: { fontWeight: 'bold' } },
                'Sponsors:'
              ),
              r.sponsor
            )
          ),
          React.createElement(
            Button,
            { id: 'cta', variant: 'secondary', href: r.destination, target: '_blank', rel: 'noopener noreferrer' },
            cta
          )
        )
      );
    }) : React.createElement(
      'p',
      null,
      'No content available.'
    ),
    React.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;
