'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

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('./define-property-f4d12f4e.js');
require('./web.dom.iterable-a0e279c1.js');
var React = require('react');
var React__default = _interopDefault(React);
require('./index-fa8ed292.js');
require('prop-types');
var Container = _interopDefault(require('react-bootstrap/Container'));
require('react-bootstrap/Row');
require('react-bootstrap/Col');
var Router = require('next/router');
var Router__default = _interopDefault(Router);
require('./isSymbol-04666465.js');
require('./debounce-eb287781.js');
require('./main-a4cb15bb.js');
require('./stringify-7c5aff47.js');
var slicedToArray = require('./slicedToArray-8f385299.js');
require('./asyncToGenerator-533d476a.js');
require('./_set-species-f92c67c5.js');
require('./Segment.js');
require('./Beam.js');
require('./AdSlot.js');
require('./get-68c52cb1.js');
require('./react-social-icons-f7f48f71.js');
require('react-bootstrap');
require('./iconBase-68959171.js');
require('./index.esm-876ca9ff.js');
require('react-bootstrap/Button');
require('./defineProperty-55548b25.js');
require('react-bootstrap/Form');
require('next/head');
var Column1 = require('./Column1.js');
require('./SideFooter.js');
require('./ConferenceBanner-4a16fddc.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-66ffa47a.js');
require('./NavFooter-76c913e3.js');
require('./index.esm-4d410430.js');
require('./SocialIcons.js');
require('react-bootstrap/FormControl');
require('./SocialSearchComponent-9cd24578.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');

// 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.createElement(NavNormal.NavNormal, { logo: website.logo, dataObject: config.navItems });
      case 'magazine':
        return React__default.createElement(NavMagazine.default, { logo: website.logo, mobileLogo: website.mobileLogo, dataObject: config.navItems, subNav: config.leftItems, website: website });
      case 'native':
        return React__default.createElement(NavNative.NavNative, { logo: website.logo, dataObject: config.navItems, subNav: config.leftItems, website: website });
      case 'dvm':
        return React__default.createElement(NavDvm.NavDvm, { logo: website.logo, dataObject: config.navItems, mobileLogo: website.logo, subNav: config.leftItems, website: website });
      case 'hamburgerNav':
        return React__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.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.createElement(
          Column1.Column1,
          { title: title },
          props.children
        );
      case '2':
        return React__default.createElement(
          Column2.Column2,
          { title: title, rightItems: config.rightItems, website: website },
          props.children
        );
      case '3':
        return React__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.createElement('noLayout', null);
    }
  }

  return React__default.createElement(
    'section',
    null,
    noTitle ? React__default.createElement(Header.default, {
      isLiveSite: config.isLiveSite,
      keyword: keywords,
      description: description + ('' + (router && router.query && router.query.page ? '| Page ' + router.query.page : ''))
    }) : React__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.createElement('div', { style: { height: '50px' } }) : React__default.createElement(
      React__default.Fragment,
      null,
      horizontalAD && horizontalAD.networkID && horizontalAD.adUnit && React__default.createElement(
        Container,
        null,
        React__default.createElement(AD728x90, { networkID: horizontalAD.networkID, adUnit: horizontalAD.adUnit, targeting: adTargeting })
      )
    ),
    website.gutterAd && !sponsoredFlag && React__default.createElement(ADGutter, { title: 'gutter-ad', gutterAd: website.gutterAd }),
    React__default.createElement(
      Container,
      null,
      layout()
    )
  );
};

module.exports = TemplateNormal;
