'use strict';

require('./_commonjsHelpers-06173234.js');
require('./_to-object-329a650b.js');
require('./es6.string.iterator-cc0bbaa4.js');
require('./_library-dd23b178.js');
require('./_iter-detect-60b2f026.js');
require('./core.get-iterator-method-f62321d4.js');
require('./_object-pie-68c5bcbc.js');
require('./extends-0a918631.js');
require('./define-property-f4d12f4e.js');
require('./web.dom.iterable-a0e279c1.js');
var React = require('react');
require('./index-e08f00ce.js');
require('prop-types');
var Container = require('react-bootstrap/Container');
require('react-bootstrap/Row');
require('react-bootstrap/Col');
var Router = require('next/router');
require('./isSymbol-04666465.js');
require('./debounce-529c8d06.js');
require('./toNumber-36d1e7e5.js');
require('./main-7b5e57b0.js');
var slicedToArray = require('./slicedToArray-8f385299.js');
require('./stringify-7c5aff47.js');
require('./asyncToGenerator-140e5f89.js');
require('./Segment.js');
require('./Beam.js');
require('./AdSlot.js');
require('./get-adbb11e3.js');
require('./eq-bb2843ed.js');
require('./react-social-icons-07939b41.js');
require('react-bootstrap');
require('./iconBase-68959171.js');
require('./index.esm-974f47d9.js');
require('next/head');
require('react-bootstrap/Button');
require('./defineProperty-55548b25.js');
require('react-bootstrap/Form');
var Column1 = require('./Column1.js');
require('./SideFooter.js');
require('./ConferenceBanner-6c9e718a.js');
var Column2 = require('./Column2.js');
require('./ADSponsoredResources.js');
require('react-bootstrap/ListGroup');
require('./ADWebcast.js');
require('./LeftNav.js');
require('./PageFilter.js');
var Column3 = require('./Column3.js');
var Header = require('./Header.js');
require('react-bootstrap/Nav');
require('react-bootstrap/Navbar');
require('react-bootstrap/NavDropdown');
require('./index.esm-3b9b8952.js');
require('./NavFooter-3dcd99a8.js');
require('./index.esm-3ffa049c.js');
require('./SocialIcons.js');
require('react-bootstrap/FormControl');
require('./SocialSearchComponent-87578cd1.js');
var NavMagazine = require('./NavMagazine.js');
var NavNative = require('./NavNative.js');
require('./Search.js');
var NavNormal = require('./NavNormal.js');
var NavDvm = require('./NavDvm.js');
var HamMagazine = require('./HamMagazine.js');
var ADGutter = require('./ADGutter.js');
var AD728x90 = require('./AD728x90.js');

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

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

// Main
var TemplateNormal = function TemplateNormal(props) {
  var config = props.config,
      title = props.title,
      keywords = props.keywords,
      description = props.description,
      website = props.website,
      horizontalAD = props.config.horizontalAD,
      showFilter = props.showFilter,
      filterParams = props.filterParams,
      filters = props.filters,
      defaultFilter = props.defaultFilter,
      showRightAd = props.showRightAd,
      sponsoredFlag = props.sponsoredFlag,
      _props$noTitle = props.noTitle,
      noTitle = _props$noTitle === undefined ? false : _props$noTitle;

  var router = Router.useRouter();

  var _useState = React.useState(0),
      _useState2 = slicedToArray._slicedToArray(_useState, 2),
      currentPage = _useState2[0],
      setCurrentPage = _useState2[1];

  React.useEffect(function () {
    router.asPath && router.asPath.split('?').forEach(function (item) {
      if (item.includes('page=')) {
        setCurrentPage(item.split('=')[1]);
      } else {
        setCurrentPage(0);
      }
    });
  }, [router]);
  var navigation = function navigation() {
    switch (config.navComponent) {
      case 'normal':
        return React__default['default'].createElement(NavNormal.NavNormal, { logo: website.logo, dataObject: config.navItems });
      case 'magazine':
        return React__default['default'].createElement(NavMagazine['default'], { logo: website.logo, mobileLogo: website.mobileLogo, dataObject: config.navItems, subNav: config.leftItems, website: website });
      case 'native':
        return React__default['default'].createElement(NavNative.NavNative, { logo: website.logo, dataObject: config.navItems, subNav: config.leftItems, website: website });
      case 'dvm':
        return React__default['default'].createElement(NavDvm.NavDvm, { logo: website.logo, dataObject: config.navItems, mobileLogo: website.logo, subNav: config.leftItems, website: website });
      case 'hamburgerNav':
        return React__default['default'].createElement(HamMagazine.HamMagazine, {
          socialFooterNav: true,
          logo: website.logo,
          dataObject: config.navItems,
          mobileLogo: website.logo,
          subNav: config.leftItems,
          website: website.siteSettingCache,
          showLogin: website.showLogin
        });
      default:
        return React__default['default'].createElement('noNav', null);
    }
  };

  var adTargeting = { desktop: {}, mobile: {} };
  if (horizontalAD.targeting) {
    adTargeting = horizontalAD.targeting;
  }
  if (website.sponsoredAd) {
    website.sponsoredAd['targeting'] = adTargeting;
  }
  if (website.gutterAd) {
    website.gutterAd['targeting'] = adTargeting;
  }
  function layout() {
    switch (config.columns) {
      case '1':
        return React__default['default'].createElement(
          Column1.Column1,
          { title: title },
          props.children
        );
      case '2':
        return React__default['default'].createElement(
          Column2.Column2,
          { title: title, rightItems: config.rightItems, website: website },
          props.children
        );
      case '3':
        return React__default['default'].createElement(
          Column3.Column3,
          {
            title: title,
            leftItems: config.leftItems,
            rightItems: config.rightItems,
            website: website,
            showFilter: showFilter,
            getParams: filterParams,
            filters: filters,
            defaultFilter: defaultFilter,
            showRightAd: showRightAd,
            logo: website.brandLogo },
          props.children
        );
      default:
        return React__default['default'].createElement('noLayout', null);
    }
  }

  return React__default['default'].createElement(
    'section',
    null,
    noTitle ? React__default['default'].createElement(Header['default'], {
      isLiveSite: config.isLiveSite,
      keyword: keywords,
      description: description + ('' + (router && router.query && router.query.page ? '| Page ' + router.query.page : ''))
    }) : React__default['default'].createElement(Header['default'], {
      title: title ? title + ' ' + (currentPage !== 0 ? '| Page ' + currentPage + ' ' : router && router.query && router.query.page ? '| Page ' + router.query.page + ' ' : '') + '| ' + website.title : website.title + ' ' + (currentPage !== 0 ? '| Page ' + currentPage + ' ' : router && router.query && router.query.page ? '| Page ' + router.query.page + ' ' : ''),
      isLiveSite: config.isLiveSite,
      keyword: keywords,
      description: description + ('' + (router && router.query && router.query.page ? '| Page ' + router.query.page : ''))
    }),
    navigation(),
    sponsoredFlag ? React__default['default'].createElement('div', { style: { height: '50px' } }) : React__default['default'].createElement(
      React__default['default'].Fragment,
      null,
      horizontalAD && horizontalAD.networkID && horizontalAD.adUnit && React__default['default'].createElement(
        Container__default['default'],
        null,
        React__default['default'].createElement(AD728x90, { networkID: horizontalAD.networkID, adUnit: horizontalAD.adUnit, targeting: adTargeting })
      )
    ),
    website.gutterAd && !sponsoredFlag && React__default['default'].createElement(ADGutter, { title: 'gutter-ad', gutterAd: website.gutterAd }),
    React__default['default'].createElement(
      Container__default['default'],
      null,
      layout()
    )
  );
};

module.exports = TemplateNormal;
