import './_commonjsHelpers-0c4b6f40.js';
import './_to-object-ded78eb9.js';
import './es6.string.iterator-9b2af4a5.js';
import './_library-528f1934.js';
import './_iter-detect-59409a32.js';
import { _ as _toConsumableArray } from './toConsumableArray-725434a0.js';
import './core.get-iterator-method-54d2e411.js';
import './_object-pie-71ac75a4.js';
import { _ as _extends } from './extends-cc5da797.js';
import './web.dom.iterable-8956f9a5.js';
import React__default, { useEffect, useState, useRef } from 'react';
import { l as lib_3 } from './index-0e45a0b2.js';
import 'prop-types';
import 'react-bootstrap/Card';
import { m as moment } from './moment-e2f9b20c.js';
import { useRouter } from 'next/router';
import './isSymbol-807e927e.js';
import './debounce-1a993acf.js';
import { I as InfiniteScroll } from './index.es-29c1cef5.js';
import 'react-dom';
import { V as VisibilitySensor } from './visibility-sensor-0baa4eea.js';
import { i as imageUrlBuilder } from './index-73819142.js';
import { L as LazyLoad } from './index-5f9f807a.js';
import { m as main_36 } from './main-5d1e4bd3.js';
import { c as clean_html_1 } from './entities-7cc3bf45.js';
import './stringify-008c8802.js';
import { _ as _slicedToArray } from './slicedToArray-7021e5df.js';
import './asyncToGenerator-7c654f36.js';
import './_set-species-cede29f8.js';
import './Segment.js';
import './Beam.js';
import './AdSlot.js';
import { A as ADInfeed } from './ADInfeed-eae71d07.js';
import { l as lodash } from './lodash-17fdfebb.js';
import { A as ADlgInfeed } from './ADlgInfeed-c619fe64.js';
import { g as getContentCategory } from './getContentCategory-15dcc413.js';
import { A as AuthorComponent } from './AuthorComponent-00f13201.js';
import { Container, Media } from 'react-bootstrap';
import timeDifferenceCalc from './timeDifferenceCalc.js';

var urlFor = function urlFor(source, builder) {
  return builder.image(source).auto('format');
};

var renderCardImage = function renderCardImage(row, builder, imageHeight, imageWidth) {
  var url = urlFor(row.thumbnail, builder);
  if (imageHeight) url = url.height(imageHeight);
  if (imageWidth) url = url.width(imageWidth);
  return url.url();
};

var loadMore = function loadMore(values, setValues, per) {
  setValues({
    page: values.page + 1,
    from: values.from + per,
    to: values.to + per
  });
};

var loadData = function loadData(values, query, client, params, setData, setScrolling, setLastDataSize, pointer, pointerArray) {
  params = _extends({}, params, {
    from: values.from,
    to: values.to
  });

  client.fetch(query, params).then(function (dataArr) {
    if (pointer && pointerArray) {
      dataArr = dataArr[pointerArray][pointer];
    }

    if (!dataArr) {
      dataArr = [];
    }

    dataArr = dataArr.map(function (item) {
      return _extends({}, item, {
        pageNumber: values.page
      });
    });

    if (dataArr.length > 0) {
      setData(function (prevData) {
        return [].concat(_toConsumableArray(prevData), _toConsumableArray(dataArr));
      });
      setLastDataSize(dataArr.length);
      setScrolling(true);
    } else {
      setLastDataSize(0);
      setScrolling(false);
    }
  });
};

var changePageNumber = function changePageNumber(pageNumber, seoPaginate, pageview, router, currentPage, setCurrentPage, itemsPerPage, itemIndex) {
  if (seoPaginate) {
    var path = router.asPath;
    var qrIndex = path.indexOf('?');
    var pathname = router.pathname;
    var queryString = '';

    if (qrIndex > 0) {
      path = path.substring(1, qrIndex);

      var partialQS = router.asPath.substring(qrIndex + 1);
      var partialQSArr = partialQS.split('&');

      // exclude page=xxx from query string
      partialQSArr.map(function (item) {
        var itemArr = item.split('=');
        var key = itemArr[0];
        var val = itemArr[1];

        if (key !== 'page') {
          queryString += (queryString.length === 0 ? '' : '&') + key + '=' + val;
        }
      });
    }

    if (queryString.length > 0) {
      path += '?' + queryString;
    }

    // pageNumber = parseInt(pageNumber)
    var index = Number(itemIndex);
    var perPage = Number(itemsPerPage);

    pageNumber = Math.ceil((index + 1) / perPage);

    if (currentPage !== pageNumber) {
      lib_3.refresh();

      setCurrentPage(pageNumber);
      if (path[0] !== '/') {
        path = '/' + path;
      }

      var newPath = pageNumber === 1 ? '' + path : '' + path + (queryString.length > 0 ? '&' : '?') + 'page=' + pageNumber;

      // if (pageview) {
      //   pageview(newPath)
      // }

      router.push(pathname, newPath, {
        shallow: true
      });
    }
  }
};

var checkExternalUrl = function checkExternalUrl(url) {
  return new RegExp(['http', 'https'].join('|')).test(url);
};

var cardLoader = function cardLoader(data, builder, mapping, values, seoPaginate, pageview, router, currentPage, setCurrentPage, showPublished, defaultImage, showAuthor, showCategory, imageHeight, imageWidth, rightItems, brandInsightAd, showBI, itemsPerPage, heroContent, lgInfeedAd, showPubInfo, contentCategoryMapping, showTimeDiff, showTaxonomies, showIntro) {
  var numberOfItemsBeforeAd = 6;
  var insertBrandInsightAd = function insertBrandInsightAd(arr, index, newElement) {
    return [].concat(_toConsumableArray(arr.slice(0, index)), [newElement], _toConsumableArray(arr.slice(index)));
  };

  var _useState = useState(!showBI || !brandInsightAd ? true : false),
      _useState2 = _slicedToArray(_useState, 2),
      dataRemapped = _useState2[0],
      setDataRemapped = _useState2[1];
  //  Need to pass flag "lgInfeedAd={true}" along with brandInsightAd from site level for large infeed-ad to render
  //  Checking window and lgInfeedAd flag in desktop view ( window >= 1400px ).


  if (lgInfeedAd && brandInsightAd && typeof window !== 'undefined' && window.innerWidth >= 1400) {
    var lgInfeed = {
      _type: 'lg-infeed',
      adUnit: brandInsightAd.adUnit,
      className: 'lg-infeed',
      networkID: brandInsightAd.networkID,
      sizes: [728, 90],
      //  Adding sizeMapping for showing ad above 1400px
      sizeMapping: [{
        viewport: [1400, 0],
        sizes: [[728, 90]]
      }, { viewport: [0, 0], sizes: [] }],
      targeting: {
        content_placement: brandInsightAd.targeting.content_placement,
        document_url: brandInsightAd.targeting.document_url
      }
    };

    var chunks = lodash.chunk(data, 6).map(function (chunk) {
      var set = lodash.chunk(chunk, 2);
      for (var i = 0; i < set.length; i++) {
        if (i !== set.length - 1) {
          set[i].push(lgInfeed);
        }
      }
      return lodash.flattenDeep(set);
    });
    data = lodash.flatten(chunks);
    !dataRemapped && setDataRemapped(true); // To detect if appending of insights ads are completed
  }

  // set dataRemap to true as there are no infeed or BI ads or window width is less than limit
  useEffect(function () {
    if (typeof window !== 'undefined' && (!lgInfeedAd || !brandInsightAd || window.innerWidth < 1400) && !dataRemapped) {
      setDataRemapped(true);
    }
  }, []);

  if (showBI && brandInsightAd) {
    //  Checking window and lgInfeedAd flag in desktop view ( window >= 1400px ).
    if (lgInfeedAd && typeof window !== 'undefined' && window.innerWidth >= 1400) brandInsightAd.interval = 8;
    var pos = 0;
    for (var i = 1; pos < data.length; i++) {
      var inFeedAd = {
        adUnit: brandInsightAd.adUnit,
        className: brandInsightAd.className,
        networkID: brandInsightAd.networkID,
        sizes: brandInsightAd.sizes,
        slotId: brandInsightAd.slotId + '_' + i,
        targeting: {
          pos: 'infeed',
          content_placement: brandInsightAd.targeting.content_placement,
          document_url: brandInsightAd.targeting.document_url
        },
        _type: 'brandInsightAd'
      };

      data = insertBrandInsightAd(data, pos, inFeedAd);
      pos += brandInsightAd.interval + 1;
    }
  }

  // 'articleCount' is New parameter to use instead of 'index' while passing to 'changePageNumber()'
  // 'index' was including the indexes for infeed ads along with article count making the page number change before it reaches last article.
  // 'articleCount' will be the indexes of only the articles in the deck.
  var articleCount = -1;
  data = data.map(function (ele, i) {
    if (ele._type === 'lg-infeed') {
      //  Setting pos as top2 for the first occurence of large infeed ad
      // const pos = data.indexOf(data.find((d) => d._type === 'lg-infeed')) === i ? 'top2' : `lg-infeed_${i}`
      return _extends({}, ele, { slotId: 'lg-infeed_' + i, targeting: _extends({}, ele.targeting, { pos: 'lg-infeed' }) });
    } else if (ele._type === 'article') {
      // incrementing 'articleCount' for each article.
      ++articleCount;
      return _extends({}, ele, { articleCount: articleCount });
    } else {
      return ele;
    }
  });

  var featureCount = 0;
  return React__default.createElement(
    'div',
    null,
    data && data.length > 0 ? dataRemapped ? // For Javascript Enabled Cases
    data.map(function (article, index) {
      var pageNumber = article.pageNumber || values.page;
      var contentCategoryName = article.contentCategory ? article.contentCategory.name : 'Articles';

      if (article._type === 'feature') {
        featureCount++;
        if (article.blank || checkExternalUrl(article.url.current)) {
          return React__default.createElement(
            VisibilitySensor,
            {
              key: article._id ? article._id : index,
              partialVisibility: true,
              onChange: function onChange(isVisible) {
                isVisible && changePageNumber(1, seoPaginate, pageview, router, currentPage, setCurrentPage, itemsPerPage, index);
              } },
            React__default.createElement(
              React__default.Fragment,
              null,
              React__default.createElement(
                Media,
                {
                  key: article._id ? article._id : index,
                  className: 'feature-media',
                  style: { flexDirection: 'column', marginBottom: '1.25rem', paddingBottom: '1.25rem', borderBottom: '1px solid #ddd' } },
                (article.thumbnail && article.thumbnail.asset || defaultImage) && React__default.createElement(
                  'a',
                  { rel: 'noopener', href: article.url.current, target: '_blank', className: 'feature-wrapper' },
                  React__default.createElement(
                    LazyLoad,
                    { height: imageHeight, placeholder: React__default.createElement(ImagePlaceholder, null) },
                    article.thumbnail && article.thumbnail.asset ? React__default.createElement('img', { className: 'img-fluid', src: renderCardImage(article, builder, imageHeight, imageWidth), alt: article.title }) : article.thumbnail ? React__default.createElement('img', { src: article.thumbnail, className: 'mr-3', alt: article.title }) : React__default.createElement('img', { src: defaultImage, src2: article.thumbnail, className: 'mr-3', width: '240', height: '135', alt: article.title })
                  ),
                  article.source && React__default.createElement(
                    'div',
                    { className: 'content-category-label' },
                    React__default.createElement(
                      'div',
                      { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                      article.source
                    )
                  )
                ),
                React__default.createElement(
                  Media.Body,
                  null,
                  React__default.createElement(
                    'a',
                    { rel: 'noopener', href: article.url.current, target: '_blank' },
                    article.title && React__default.createElement(
                      'h4',
                      { className: 'card-title', style: { fontWeight: '500', color: 'var(--gray-dark)', marginBottom: '.5rem' } },
                      article.title
                    )
                  ),
                  showPublished && !showTimeDiff && article.published && React__default.createElement(
                    'p',
                    { className: 'card-text', style: { color: 'var(--dark)', margin: '.25rem 0' } },
                    moment(article.published).format('MMMM DD, YYYY')
                  ),
                  showTimeDiff && article.published && React__default.createElement(
                    'p',
                    { className: 'card-text', style: { color: '#464644', lineHeight: '1.25', fontSize: '.875rem', margin: '.25rem 0' } },
                    showTaxonomies && article.taxonomyMapping && article.taxonomyMapping.map(function (taxonomy, index) {
                      if (index > 3) {
                        return null;
                      }
                      if (index === 3) {
                        return React__default.createElement(
                          React__default.Fragment,
                          null,
                          React__default.createElement(
                            'em',
                            { style: { marginRight: '.5rem' } },
                            '...'
                          )
                        );
                      }
                      return React__default.createElement(
                        React__default.Fragment,
                        null,
                        React__default.createElement(
                          'em',
                          null,
                          taxonomy.name
                        ),
                        ' |',
                        ' '
                      );
                    }),
                    ' ',
                    React__default.createElement(
                      'span',
                      { style: { display: 'inline-block' } },
                      timeDifferenceCalc(article.published)
                    )
                  ),
                  showAuthor && article.authorMapping && article.authorMapping.length > 0 && React__default.createElement(
                    LazyLoad,
                    { height: 50 },
                    React__default.createElement(AuthorComponent, { key: index.toString(), index: index, authors: article.authorMapping })
                  ),
                  !article.thumbnail && !defaultImage && article.source && React__default.createElement(
                    'div',
                    { className: 'content-category-label' },
                    React__default.createElement(
                      'div',
                      { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                      article.source
                    )
                  ),
                  React__default.createElement(
                    'div',
                    { style: { display: 'flex', alignItems: 'center', justifyContent: 'flex-start' } },
                    showCategory && article.contentCategory && React__default.createElement(
                      'p',
                      {
                        className: 'article-category',
                        style: {
                          background: '#3FB618',
                          color: '#ffffff',
                          marginBottom: '.25rem',
                          display: 'inline-block',
                          padding: '0 .25rem',
                          fontSize: '.8rem'
                        } },
                      getContentCategory(article.contentCategory.name, contentCategoryMapping)
                    ),
                    article.issueSection && article.issueSection.name && React__default.createElement(
                      'p',
                      {
                        className: 'issueSection',
                        style: {
                          background: '#000000',
                          color: '#ffffff',
                          marginBottom: '.25rem',
                          marginLeft: '.25rem',
                          display: 'inline-block',
                          padding: '0 .25rem',
                          fontSize: '.8rem'
                        } },
                      article.issueSection.name
                    )
                  ),
                  showPubInfo && (article.issue || article.volume) && React__default.createElement(
                    'div',
                    { className: 'pubInfo' },
                    article.volume && React__default.createElement(
                      'p',
                      { className: 'qdeVolume' },
                      article.volume
                    ),
                    article.issue && React__default.createElement(
                      'p',
                      { className: 'qdeIssue' },
                      article.issue
                    )
                  ),
                  showIntro && article.summary && React__default.createElement(
                    'p',
                    { className: 'pt-2 card-text' },
                    clean_html_1(article.summary)
                  )
                )
              )
            )
          );
        } else {
          return React__default.createElement(
            VisibilitySensor,
            {
              key: article._id ? article._id : index,
              partialVisibility: true,
              onChange: function onChange(isVisible) {
                isVisible && changePageNumber(1, seoPaginate, pageview, router, currentPage, setCurrentPage, itemsPerPage, index);
              } },
            React__default.createElement(
              React__default.Fragment,
              null,
              React__default.createElement(
                Media,
                {
                  key: article._id ? article._id : index,
                  className: 'feature-media',
                  style: { flexDirection: 'column', marginBottom: '1.25rem', paddingBottom: '1.25rem', borderBottom: '1px solid #ddd' } },
                (article.thumbnail && article.thumbnail.asset || defaultImage) && React__default.createElement(
                  'a',
                  { href: article.url.current, className: 'feature-wrapper' },
                  React__default.createElement(
                    LazyLoad,
                    { height: imageHeight, placeholder: React__default.createElement(ImagePlaceholder, null) },
                    article.thumbnail && article.thumbnail.asset ? React__default.createElement('img', { className: 'img-fluid', src: renderCardImage(article, builder, imageHeight, imageWidth), alt: article.title }) : article.thumbnail ? React__default.createElement('img', { src: article.thumbnail, className: 'mr-3', alt: article.title }) : React__default.createElement('img', { src: defaultImage, src2: article.thumbnail, className: 'mr-3', width: '240', height: '135', alt: article.title })
                  ),
                  article.source && React__default.createElement(
                    'div',
                    { className: 'content-category-label' },
                    React__default.createElement(
                      'div',
                      { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                      article.source
                    )
                  )
                ),
                React__default.createElement(
                  Media.Body,
                  null,
                  React__default.createElement(
                    'a',
                    { href: article.url.current },
                    article.title && React__default.createElement(
                      'h4',
                      { className: 'card-title', style: { fontWeight: '500', color: 'var(--gray-dark)', marginBottom: '.5rem' } },
                      article.title
                    )
                  ),
                  showPublished && !showTimeDiff && article.published && React__default.createElement(
                    'p',
                    { className: 'card-text', style: { color: 'var(--dark)', margin: '.25rem 0' } },
                    moment(article.published).format('MMMM DD, YYYY')
                  ),
                  showTimeDiff && article.published && React__default.createElement(
                    'p',
                    { className: 'card-text', style: { color: '#464644', lineHeight: '1.25', fontSize: '.875rem', margin: '.25rem 0' } },
                    showTaxonomies && article.taxonomyMapping && article.taxonomyMapping.map(function (taxonomy, index) {
                      if (index > 3) {
                        return null;
                      }
                      if (index === 3) {
                        return React__default.createElement(
                          React__default.Fragment,
                          null,
                          React__default.createElement(
                            'em',
                            { style: { marginRight: '.5rem' } },
                            '...'
                          )
                        );
                      }
                      if (index === 3) {
                        return React__default.createElement(
                          React__default.Fragment,
                          null,
                          React__default.createElement(
                            'em',
                            { style: { marginRight: '.5rem' } },
                            '...'
                          )
                        );
                      }
                      return React__default.createElement(
                        React__default.Fragment,
                        null,
                        React__default.createElement(
                          'em',
                          null,
                          taxonomy.name
                        ),
                        ' |',
                        ' '
                      );
                    }),
                    ' ',
                    React__default.createElement(
                      'span',
                      { style: { display: 'inline-block' } },
                      timeDifferenceCalc(article.published)
                    )
                  ),
                  showAuthor && article.authorMapping && article.authorMapping.length > 0 && React__default.createElement(
                    LazyLoad,
                    { height: 50 },
                    React__default.createElement(AuthorComponent, { key: index.toString(), index: index, authors: article.authorMapping })
                  ),
                  !article.thumbnail && !defaultImage && article.source && React__default.createElement(
                    'div',
                    { className: 'content-category-label' },
                    React__default.createElement(
                      'div',
                      { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                      article.source
                    )
                  ),
                  React__default.createElement(
                    'div',
                    { style: { display: 'flex', alignItems: 'center', justifyContent: 'flex-start' } },
                    showCategory && article.contentCategory && React__default.createElement(
                      'p',
                      {
                        className: 'article-category',
                        style: {
                          background: '#3FB618',
                          color: '#ffffff',
                          marginBottom: '.25rem',
                          display: 'inline-block',
                          padding: '0 .25rem',
                          fontSize: '.8rem'
                        } },
                      getContentCategory(article.contentCategory.name, contentCategoryMapping)
                    ),
                    article.issueSection && article.issueSection.name && React__default.createElement(
                      'p',
                      {
                        className: 'issueSection',
                        style: {
                          background: '#000000',
                          color: '#ffffff',
                          marginBottom: '.25rem',
                          marginLeft: '.25rem',
                          display: 'inline-block',
                          padding: '0 .25rem',
                          fontSize: '.8rem'
                        } },
                      article.issueSection.name
                    )
                  ),
                  showPubInfo && (article.issue || article.volume) && React__default.createElement(
                    'div',
                    { className: 'pubInfo' },
                    article.volume && React__default.createElement(
                      'p',
                      { className: 'qdeVolume' },
                      article.volume
                    ),
                    article.issue && React__default.createElement(
                      'p',
                      { className: 'qdeIssue' },
                      article.issue
                    )
                  ),
                  showIntro && article.summary && React__default.createElement(
                    'p',
                    { className: 'pt-2 card-text' },
                    clean_html_1(article.summary)
                  )
                )
              )
            )
          );
        }
      } else if (article._type === 'lg-infeed' && article.adUnit) {
        return React__default.createElement(ADlgInfeed, _extends({ index: index }, article));
      } else if (article._type === 'brandInsightAd' && article.adUnit) {
        return React__default.createElement(ADInfeed, { index: index, infeedAd: article });
      }
      if ((brandInsightAd ? index > heroContent + featureCount : index + 1 > heroContent + featureCount) && (!article._type || !['lg-infeed', 'brandInsightAd'].includes(article._type))) {
        return React__default.createElement(
          VisibilitySensor,
          {
            key: article._id ? article._id : index,
            onChange: function onChange(isVisible) {
              // Passing 'articleCount' instead of index because index will be including the indexes of ads whereas articleCount will be having index of artilce only.
              isVisible && changePageNumber(pageNumber, seoPaginate, pageview, router, currentPage, setCurrentPage, itemsPerPage, article.articleCount ? article.articleCount : index);
            } },
          React__default.createElement(
            React__default.Fragment,
            null,
            React__default.createElement(
              Media,
              {
                key: article._id ? article._id : index,
                style: { flexDirection: 'row', marginBottom: '1.25rem', paddingBottom: '1.25rem', borderBottom: '1px solid #ddd' } },
              (article.thumbnail && article.thumbnail.asset || defaultImage) && React__default.createElement(
                'a',
                { href: mapping[contentCategoryName] + '/' + article.url.current, className: 'img-wrapper' },
                React__default.createElement(
                  LazyLoad,
                  { height: imageHeight, placeholder: React__default.createElement(ImagePlaceholder, null) },
                  article.thumbnail && article.thumbnail.asset ? React__default.createElement('img', { className: 'mr-3 img-fluid', src: renderCardImage(article, builder, imageHeight, imageWidth), alt: article.title }) : article.thumbnail ? React__default.createElement('img', { src: article.thumbnail, className: 'mr-3', alt: article.title }) : React__default.createElement('img', { src: defaultImage, src2: article.thumbnail, className: 'mr-3', width: '240', height: '135', alt: article.title })
                ),
                article.source && React__default.createElement(
                  'div',
                  { className: 'content-category-label' },
                  React__default.createElement(
                    'div',
                    { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                    article.source
                  )
                )
              ),
              React__default.createElement(
                Media.Body,
                null,
                React__default.createElement(
                  'a',
                  { href: mapping[contentCategoryName] + '/' + article.url.current },
                  article.title && React__default.createElement(
                    'h4',
                    { className: 'card-title', style: { fontWeight: '500', color: 'var(--gray-dark)', marginBottom: '.5rem' } },
                    article.title
                  )
                ),
                showPublished && !showTimeDiff && article.published && React__default.createElement(
                  'p',
                  { className: 'card-text', style: { color: 'var(--dark)', margin: '.25rem 0' } },
                  moment(article.published).format('MMMM DD, YYYY')
                ),
                showTimeDiff && article.published && React__default.createElement(
                  'p',
                  { className: 'card-text', style: { color: '#464644', lineHeight: '1.25', fontSize: '.875rem', margin: '.25rem 0' } },
                  showTaxonomies && article.taxonomyMapping && article.taxonomyMapping.map(function (taxonomy, index) {
                    if (index > 3) {
                      return null;
                    }
                    if (index === 3) {
                      return React__default.createElement(
                        React__default.Fragment,
                        null,
                        React__default.createElement(
                          'em',
                          { style: { marginRight: '.5rem' } },
                          '...'
                        )
                      );
                    }
                    return React__default.createElement(
                      React__default.Fragment,
                      null,
                      React__default.createElement(
                        'em',
                        null,
                        taxonomy.name
                      ),
                      ' |',
                      ' '
                    );
                  }),
                  ' ',
                  React__default.createElement(
                    'span',
                    { style: { display: 'inline-block' } },
                    timeDifferenceCalc(article.published)
                  )
                ),
                React__default.createElement(
                  'div',
                  { className: 'author-sec', style: { lineHeight: 1.5 } },
                  showAuthor && article.authorMapping && article.authorMapping.length > 0 && React__default.createElement(
                    LazyLoad,
                    { height: 50 },
                    React__default.createElement(AuthorComponent, { key: index.toString(), index: index, authors: article.authorMapping })
                  )
                ),
                !article.thumbnail && !defaultImage && article.source && React__default.createElement(
                  'div',
                  { className: 'content-category-label' },
                  React__default.createElement(
                    'div',
                    { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                    article.source
                  )
                ),
                React__default.createElement(
                  'div',
                  { style: { display: 'flex', alignItems: 'center', justifyContent: 'flex-start' } },
                  showCategory && article.contentCategory && React__default.createElement(
                    'p',
                    {
                      className: 'article-category',
                      style: {
                        background: '#3FB618',
                        color: '#ffffff',
                        marginBottom: '.25rem',
                        display: 'inline-block',
                        padding: '0 .25rem',
                        fontSize: '.8rem'
                      } },
                    getContentCategory(article.contentCategory.name, contentCategoryMapping)
                  ),
                  article.issueSection && article.issueSection.name && React__default.createElement(
                    'p',
                    {
                      className: 'issueSection',
                      style: {
                        background: '#000000',
                        color: '#ffffff',
                        marginBottom: '.25rem',
                        marginLeft: '.25rem',
                        display: 'inline-block',
                        padding: '0 .25rem',
                        fontSize: '.8rem'
                      } },
                    article.issueSection.name
                  )
                ),
                showPubInfo && (article.issue || article.volume) && React__default.createElement(
                  'div',
                  { className: 'pubInfo' },
                  article.volume && React__default.createElement(
                    'p',
                    { className: 'qdeVolume' },
                    article.volume
                  ),
                  article.issue && React__default.createElement(
                    'p',
                    { className: 'qdeIssue' },
                    article.issue
                  )
                ),
                showIntro && article.summary && React__default.createElement(
                  'p',
                  { className: 'pt-2 card-text' },
                  clean_html_1(article.summary)
                )
              )
            ),
            React__default.createElement(
              'div',
              null,
              main_36 && rightItems && (index + 1) % numberOfItemsBeforeAd === 0 && renderMobileAd(index, numberOfItemsBeforeAd, rightItems)
            )
          )
        );
      } else return null;
    }) :
    // For Javascript Disabled Cases
    React__default.createElement(
      'noscript',
      null,
      data.map(function (article, index) {
        var pageNumber = article.pageNumber || values.page;
        var contentCategoryName = article.contentCategory ? article.contentCategory.name : 'Articles';

        if (article._type === 'feature') {
          featureCount++;
          if (article.blank || checkExternalUrl(article.url.current)) {
            return React__default.createElement(
              VisibilitySensor,
              {
                key: article._id ? article._id : index,
                partialVisibility: true,
                onChange: function onChange(isVisible) {
                  isVisible && changePageNumber(1, seoPaginate, pageview, router, currentPage, setCurrentPage, itemsPerPage, index);
                } },
              React__default.createElement(
                React__default.Fragment,
                null,
                React__default.createElement(
                  Media,
                  {
                    key: article._id ? article._id : index,
                    className: 'feature-media',
                    style: { flexDirection: 'column', marginBottom: '1.25rem', paddingBottom: '1.25rem', borderBottom: '1px solid #ddd' } },
                  (article.thumbnail && article.thumbnail.asset || defaultImage) && React__default.createElement(
                    'a',
                    { rel: 'noopener', href: article.url.current, target: '_blank', className: 'feature-wrapper' },
                    React__default.createElement(
                      LazyLoad,
                      { height: imageHeight, placeholder: React__default.createElement(ImagePlaceholder, null) },
                      article.thumbnail && article.thumbnail.asset ? React__default.createElement('img', { className: 'img-fluid', src: renderCardImage(article, builder, imageHeight, imageWidth), alt: article.title }) : article.thumbnail ? React__default.createElement('img', { src: article.thumbnail, className: 'mr-3', alt: article.title }) : React__default.createElement('img', { src: defaultImage, src2: article.thumbnail, className: 'mr-3', width: '240', height: '135', alt: article.title })
                    ),
                    article.source && React__default.createElement(
                      'div',
                      { className: 'content-category-label' },
                      React__default.createElement(
                        'div',
                        { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                        article.source
                      )
                    )
                  ),
                  React__default.createElement(
                    Media.Body,
                    null,
                    React__default.createElement(
                      'a',
                      { rel: 'noopener', href: article.url.current, target: '_blank' },
                      article.title && React__default.createElement(
                        'h4',
                        { className: 'card-title', style: { fontWeight: '500', color: 'var(--gray-dark)', marginBottom: '.5rem' } },
                        article.title
                      )
                    ),
                    showPublished && article.published && React__default.createElement(
                      'p',
                      { className: 'card-text', style: { color: 'var(--dark)', marginBottom: '.25rem' } },
                      moment(article.published).format('MMMM DD, YYYY')
                    ),
                    showTimeDiff && article.published && React__default.createElement(
                      'p',
                      { className: 'card-text', style: { color: '#464644', lineHeight: '1.25', fontSize: '.875rem', margin: '.25rem 0' } },
                      showTaxonomies && article.taxonomyMapping && article.taxonomyMapping.map(function (taxonomy, index) {
                        if (index > 3) {
                          return null;
                        }
                        if (index === 3) {
                          return React__default.createElement(
                            React__default.Fragment,
                            null,
                            React__default.createElement(
                              'em',
                              { style: { marginRight: '.5rem' } },
                              '...'
                            )
                          );
                        }
                        return React__default.createElement(
                          React__default.Fragment,
                          null,
                          React__default.createElement(
                            'em',
                            null,
                            taxonomy.name
                          ),
                          ' |',
                          ' '
                        );
                      }),
                      ' ',
                      React__default.createElement(
                        'span',
                        { style: { display: 'inline-block' } },
                        timeDifferenceCalc(article.published)
                      )
                    ),
                    showAuthor && article.authorMapping && article.authorMapping.length > 0 && React__default.createElement(
                      LazyLoad,
                      { height: 50 },
                      React__default.createElement(AuthorComponent, { key: index.toString(), index: index, authors: article.authorMapping })
                    ),
                    !article.thumbnail && !defaultImage && article.source && React__default.createElement(
                      'div',
                      { className: 'content-category-label' },
                      React__default.createElement(
                        'div',
                        { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                        article.source
                      )
                    ),
                    React__default.createElement(
                      'div',
                      { style: { display: 'flex', alignItems: 'center', justifyContent: 'flex-start' } },
                      showCategory && article.contentCategory && React__default.createElement(
                        'p',
                        {
                          className: 'article-category',
                          style: {
                            background: '#3FB618',
                            color: '#ffffff',
                            marginBottom: '.25rem',
                            display: 'inline-block',
                            padding: '0 .25rem',
                            fontSize: '.8rem'
                          } },
                        getContentCategory(article.contentCategory.name, contentCategoryMapping)
                      ),
                      article.issueSection && article.issueSection.name && React__default.createElement(
                        'p',
                        {
                          className: 'issueSection',
                          style: {
                            background: '#000000',
                            color: '#ffffff',
                            marginBottom: '.25rem',
                            marginLeft: '.25rem',
                            display: 'inline-block',
                            padding: '0 .25rem',
                            fontSize: '.8rem'
                          } },
                        article.issueSection.name
                      )
                    ),
                    showPubInfo && (article.issue || article.volume) && React__default.createElement(
                      'div',
                      { className: 'pubInfo' },
                      article.volume && React__default.createElement(
                        'p',
                        { className: 'qdeVolume' },
                        article.volume
                      ),
                      article.issue && React__default.createElement(
                        'p',
                        { className: 'qdeIssue' },
                        article.issue
                      )
                    ),
                    showIntro && article.summary && React__default.createElement(
                      'p',
                      { className: 'pt-2 card-text' },
                      clean_html_1(article.summary)
                    )
                  )
                )
              )
            );
          } else {
            return React__default.createElement(
              VisibilitySensor,
              {
                key: article._id ? article._id : index,
                partialVisibility: true,
                onChange: function onChange(isVisible) {
                  isVisible && changePageNumber(1, seoPaginate, pageview, router, currentPage, setCurrentPage, itemsPerPage, index);
                } },
              React__default.createElement(
                React__default.Fragment,
                null,
                React__default.createElement(
                  Media,
                  {
                    key: article._id ? article._id : index,
                    className: 'feature-media',
                    style: { flexDirection: 'column', marginBottom: '1.25rem', paddingBottom: '1.25rem', borderBottom: '1px solid #ddd' } },
                  (article.thumbnail && article.thumbnail.asset || defaultImage) && React__default.createElement(
                    'a',
                    { href: article.url.current, className: 'feature-wrapper' },
                    React__default.createElement(
                      LazyLoad,
                      { height: imageHeight, placeholder: React__default.createElement(ImagePlaceholder, null) },
                      article.thumbnail && article.thumbnail.asset ? React__default.createElement('img', { className: 'img-fluid', src: renderCardImage(article, builder, imageHeight, imageWidth), alt: article.title }) : article.thumbnail ? React__default.createElement('img', { src: article.thumbnail, className: 'mr-3', alt: article.title }) : React__default.createElement('img', { src: defaultImage, src2: article.thumbnail, className: 'mr-3', width: '240', height: '135', alt: article.title })
                    ),
                    article.source && React__default.createElement(
                      'div',
                      { className: 'content-category-label' },
                      React__default.createElement(
                        'div',
                        { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                        article.source
                      )
                    )
                  ),
                  React__default.createElement(
                    Media.Body,
                    null,
                    React__default.createElement(
                      'a',
                      { href: article.url.current },
                      article.title && React__default.createElement(
                        'h4',
                        { className: 'card-title', style: { fontWeight: '500', color: 'var(--gray-dark)', marginBottom: '.5rem' } },
                        article.title
                      )
                    ),
                    showPublished && article.published && React__default.createElement(
                      'p',
                      { className: 'card-text', style: { color: 'var(--dark)', marginBottom: '.25rem' } },
                      moment(article.published).format('MMMM DD, YYYY')
                    ),
                    showTimeDiff && article.published && React__default.createElement(
                      'p',
                      { className: 'card-text', style: { color: '#464644', lineHeight: '1.25', fontSize: '.875rem', margin: '.25rem 0' } },
                      showTaxonomies && article.taxonomyMapping && article.taxonomyMapping.map(function (taxonomy, index) {
                        if (index > 3) {
                          return null;
                        }
                        if (index === 3) {
                          return React__default.createElement(
                            React__default.Fragment,
                            null,
                            React__default.createElement(
                              'em',
                              { style: { marginRight: '.5rem' } },
                              '...'
                            )
                          );
                        }
                        return React__default.createElement(
                          React__default.Fragment,
                          null,
                          React__default.createElement(
                            'em',
                            null,
                            taxonomy.name
                          ),
                          ' |',
                          ' '
                        );
                      }),
                      ' ',
                      React__default.createElement(
                        'span',
                        { style: { display: 'inline-block' } },
                        timeDifferenceCalc(article.published)
                      )
                    ),
                    showAuthor && article.authorMapping && article.authorMapping.length > 0 && React__default.createElement(
                      LazyLoad,
                      { height: 50 },
                      React__default.createElement(AuthorComponent, { key: index.toString(), index: index, authors: article.authorMapping })
                    ),
                    !article.thumbnail && !defaultImage && article.source && React__default.createElement(
                      'div',
                      { className: 'content-category-label' },
                      React__default.createElement(
                        'div',
                        { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                        article.source
                      )
                    ),
                    React__default.createElement(
                      'div',
                      { style: { display: 'flex', alignItems: 'center', justifyContent: 'flex-start' } },
                      showCategory && article.contentCategory && React__default.createElement(
                        'p',
                        {
                          className: 'article-category',
                          style: {
                            background: '#3FB618',
                            color: '#ffffff',
                            marginBottom: '.25rem',
                            display: 'inline-block',
                            padding: '0 .25rem',
                            fontSize: '.8rem'
                          } },
                        getContentCategory(article.contentCategory.name, contentCategoryMapping)
                      ),
                      article.issueSection && article.issueSection.name && React__default.createElement(
                        'p',
                        {
                          className: 'issueSection',
                          style: {
                            background: '#000000',
                            color: '#ffffff',
                            marginBottom: '.25rem',
                            marginLeft: '.25rem',
                            display: 'inline-block',
                            padding: '0 .25rem',
                            fontSize: '.8rem'
                          } },
                        article.issueSection.name
                      )
                    ),
                    showPubInfo && (article.issue || article.volume) && React__default.createElement(
                      'div',
                      { className: 'pubInfo' },
                      article.volume && React__default.createElement(
                        'p',
                        { className: 'qdeVolume' },
                        article.volume
                      ),
                      article.issue && React__default.createElement(
                        'p',
                        { className: 'qdeIssue' },
                        article.issue
                      )
                    ),
                    showIntro && article.summary && React__default.createElement(
                      'p',
                      { className: 'pt-2 card-text' },
                      clean_html_1(article.summary)
                    )
                  )
                )
              )
            );
          }
        } else if (article._type === 'lg-infeed' && article.adUnit) {
          return React__default.createElement(ADlgInfeed, _extends({ index: index }, article));
        } else if (article._type === 'brandInsightAd' && article.adUnit) {
          return React__default.createElement(ADInfeed, { index: index, infeedAd: article });
        }
        if ((brandInsightAd ? index > heroContent + featureCount : index + 1 > heroContent + featureCount) && (!article._type || !['lg-infeed', 'brandInsightAd'].includes(article._type))) {
          return React__default.createElement(
            VisibilitySensor,
            {
              key: article._id ? article._id : index,
              onChange: function onChange(isVisible) {
                // Passing 'articleCount' instead of index because index will be including the indexes of ads whereas articleCount will be having index of artilce only.
                isVisible && changePageNumber(pageNumber, seoPaginate, pageview, router, currentPage, setCurrentPage, itemsPerPage, article.articleCount ? article.articleCount : index);
              } },
            React__default.createElement(
              React__default.Fragment,
              null,
              React__default.createElement(
                Media,
                {
                  key: article._id ? article._id : index,
                  style: { flexDirection: 'row', marginBottom: '1.25rem', paddingBottom: '1.25rem', borderBottom: '1px solid #ddd' } },
                (article.thumbnail && article.thumbnail.asset || defaultImage) && React__default.createElement(
                  'a',
                  { href: mapping[contentCategoryName] + '/' + article.url.current, className: 'img-wrapper' },
                  React__default.createElement(
                    LazyLoad,
                    { height: imageHeight, placeholder: React__default.createElement(ImagePlaceholder, null) },
                    article.thumbnail && article.thumbnail.asset ? React__default.createElement('img', { className: 'mr-3 img-fluid', src: renderCardImage(article, builder, imageHeight, imageWidth), alt: article.title }) : article.thumbnail ? React__default.createElement('img', { src: article.thumbnail, className: 'mr-3', alt: article.title }) : React__default.createElement('img', { src: defaultImage, src2: article.thumbnail, className: 'mr-3', width: '240', height: '135', alt: article.title })
                  ),
                  article.source && React__default.createElement(
                    'div',
                    { className: 'content-category-label' },
                    React__default.createElement(
                      'div',
                      { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                      article.source
                    )
                  )
                ),
                React__default.createElement(
                  Media.Body,
                  null,
                  React__default.createElement(
                    'a',
                    { href: mapping[contentCategoryName] + '/' + article.url.current },
                    article.title && React__default.createElement(
                      'h4',
                      { className: 'card-title', style: { fontWeight: '500', color: 'var(--gray-dark)', marginBottom: '.5rem' } },
                      article.title
                    )
                  ),
                  showPublished && article.published && React__default.createElement(
                    'p',
                    { className: 'card-text', style: { color: 'var(--dark)', marginBottom: '.25rem' } },
                    moment(article.published).format('MMMM DD, YYYY')
                  ),
                  showTimeDiff && article.published && React__default.createElement(
                    'p',
                    { className: 'card-text', style: { color: '#464644', lineHeight: '1.25', fontSize: '.875rem', margin: '.25rem 0' } },
                    showTaxonomies && article.taxonomyMapping && article.taxonomyMapping.map(function (taxonomy, index) {
                      if (index > 3) {
                        return null;
                      }
                      if (index === 3) {
                        return React__default.createElement(
                          React__default.Fragment,
                          null,
                          React__default.createElement(
                            'em',
                            { style: { marginRight: '.5rem' } },
                            '...'
                          )
                        );
                      }
                      return React__default.createElement(
                        React__default.Fragment,
                        null,
                        React__default.createElement(
                          'em',
                          null,
                          taxonomy.name
                        ),
                        ' |',
                        ' '
                      );
                    }),
                    ' ',
                    React__default.createElement(
                      'span',
                      { style: { display: 'inline-block' } },
                      timeDifferenceCalc(article.published)
                    )
                  ),
                  React__default.createElement(
                    'div',
                    { className: 'author-sec', style: { lineHeight: 1.5 } },
                    showAuthor && article.authorMapping && article.authorMapping.length > 0 && React__default.createElement(
                      LazyLoad,
                      { height: 50 },
                      React__default.createElement(AuthorComponent, { key: index.toString(), index: index, authors: article.authorMapping })
                    )
                  ),
                  !article.thumbnail && !defaultImage && article.source && React__default.createElement(
                    'div',
                    { className: 'content-category-label' },
                    React__default.createElement(
                      'div',
                      { className: 'mb-1 sanityDisplayLabel displayLabelThumb' },
                      article.source
                    )
                  ),
                  React__default.createElement(
                    'div',
                    { style: { display: 'flex', alignItems: 'center', justifyContent: 'flex-start' } },
                    showCategory && article.contentCategory && React__default.createElement(
                      'p',
                      {
                        className: 'article-category',
                        style: {
                          background: '#3FB618',
                          color: '#ffffff',
                          marginBottom: '.25rem',
                          display: 'inline-block',
                          padding: '0 .25rem',
                          fontSize: '.8rem'
                        } },
                      getContentCategory(article.contentCategory.name, contentCategoryMapping)
                    ),
                    article.issueSection && article.issueSection.name && React__default.createElement(
                      'p',
                      {
                        className: 'issueSection',
                        style: {
                          background: '#000000',
                          color: '#ffffff',
                          marginBottom: '.25rem',
                          marginLeft: '.25rem',
                          display: 'inline-block',
                          padding: '0 .25rem',
                          fontSize: '.8rem'
                        } },
                      article.issueSection.name
                    )
                  ),
                  showPubInfo && (article.issue || article.volume) && React__default.createElement(
                    'div',
                    { className: 'pubInfo' },
                    article.volume && React__default.createElement(
                      'p',
                      { className: 'qdeVolume' },
                      article.volume
                    ),
                    article.issue && React__default.createElement(
                      'p',
                      { className: 'qdeIssue' },
                      article.issue
                    )
                  ),
                  showIntro && article.summary && React__default.createElement(
                    'p',
                    { className: 'pt-2 card-text' },
                    clean_html_1(article.summary)
                  )
                )
              ),
              React__default.createElement(
                'div',
                null,
                main_36 && rightItems && (index + 1) % numberOfItemsBeforeAd === 0 && renderMobileAd(index, numberOfItemsBeforeAd, rightItems)
              )
            )
          );
        } else return null;
      })
    ) : React__default.createElement(
      'div',
      null,
      React__default.createElement(
        'h5',
        null,
        React__default.createElement(
          'em',
          null,
          '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: fit-content;\n            width: -moz-fit-content;\n            padding: 5px;\n            color: #484848;\n            border-radius: 2px;\n          }\n          .feature-media > .media-body {\n            -webkit-box-flex: none;\n            -ms-flex: none;\n            flex: none;\n          }\n          .img-wrapper img {\n            max-height: 240px;\n            height: auto;\n            width: 100%;\n            object-fit: contain;\n          }\n          .feature-wrapper {\n            height: 100%;\n            width: 100%;\n          }\n          .feature-wrapper img {\n            width: 100%;\n            margin-bottom: 1em;\n          }\n          @media only screen and (min-width: 768px) {\n            .img-wrapper > img {\n              padding-right: 1em;\n            }\n          }\n          @media only screen and (max-width: 767px) {\n            .sanityDisplayLabel {\n              max-width: 100%;\n            }\n            .img-wrapper {\n              width: 100%;\n            }\n            .img-wrapper img {\n              padding-bottom: 1em;\n            }\n            .media {\n              flex-direction: column !important;\n            }\n          }\n        '
    )
  );
};

var ImagePlaceholder = function ImagePlaceholder() {
  return React__default.createElement(
    React__default.Fragment,
    null,
    React__default.createElement('div', { className: 'queuedeck-exp-image-placeholder' }),
    React__default.createElement(
      'style',
      { jsx: 'true' },
      '\n      .queuedeck-exp-image-placeholder {\n        width: 240px;\n        height: 0;\n        padding-top: calc(240px * 9 / 16);\n        margin: 0 1rem 0 0;\n      }\n      @media only screen and (max-width: 767px) {\n        .queuedeck-exp-image-placeholder {\n          width: 100%;\n          height: 0;\n          padding-top: calc(100% * 9 / 16);\n          margin: 0 0 1rem 0;\n        }\n      }\n    '
    )
  );
};

var renderMobileAd = function renderMobileAd(index, numberOfItemsBeforeAd, rightItems) {
  var i = ((index + 1) / numberOfItemsBeforeAd - 1) % rightItems.length;
  return React__default.createElement(
    'div',
    { style: { display: 'flex', flex: '1 0 auto' } },
    rightItems[i].component
  );
};

var usePrevious = function usePrevious(value) {
  var ref = useRef();
  useEffect(function () {
    ref.current = value;
  });
  return ref.current;
};

var QueueDeckExpanded = function QueueDeckExpanded(props) {
  var router = useRouter();

  // Logging GA Pageview on path change
  var prevPath = usePrevious(lodash.get(router, 'asPath', undefined));
  useEffect(function () {
    var pageview = props.pageview;

    var currentPath = router.asPath;
    if (prevPath && prevPath !== currentPath && pageview) {
      pageview(router.asPath);
    }
  }, [router]);

  var initialData = props.dataRecord,
      client = props.client,
      params = props.params,
      query = props.query,
      autoScroll = props.autoScroll,
      pointer = props.pointer,
      pointerArray = props.pointerArray,
      mapping = props.mapping,
      seoPaginate = props.seoPaginate,
      pageview = props.pageview,
      defaultImage = props.defaultImage,
      showAuthor = props.showAuthor,
      showCategory = props.showCategory,
      imageHeight = props.imageHeight,
      imageWidth = props.imageWidth,
      rightItems = props.rightItems,
      brandInsightAd = props.brandInsightAd,
      _props$showBI = props.showBI,
      showBI = _props$showBI === undefined ? false : _props$showBI,
      _props$heroContent = props.heroContent,
      heroContent = _props$heroContent === undefined ? 0 : _props$heroContent,
      _props$lgInfeedAd = props.lgInfeedAd,
      lgInfeedAd = _props$lgInfeedAd === undefined ? false : _props$lgInfeedAd,
      _props$showPubInfo = props.showPubInfo,
      showPubInfo = _props$showPubInfo === undefined ? false : _props$showPubInfo,
      _props$showTimeDiff = props.showTimeDiff,
      showTimeDiff = _props$showTimeDiff === undefined ? false : _props$showTimeDiff,
      _props$showTaxonomies = props.showTaxonomies,
      showTaxonomies = _props$showTaxonomies === undefined ? false : _props$showTaxonomies,
      _props$showIntro = props.showIntro,
      showIntro = _props$showIntro === undefined ? true : _props$showIntro,
      _props$contentCategor = props.contentCategoryMapping,
      contentCategoryMapping = _props$contentCategor === undefined ? [] : _props$contentCategor;
  var initialCurrentPage = props.currentPage,
      showPublished = props.showPublished;

  var builder = imageUrlBuilder(client);

  var _useState3 = useState(initialData),
      _useState4 = _slicedToArray(_useState3, 2),
      data = _useState4[0],
      setData = _useState4[1];

  var _useState5 = useState(true),
      _useState6 = _slicedToArray(_useState5, 2),
      scrolling = _useState6[0],
      setScrolling = _useState6[1];

  var _useState7 = useState(params ? params.to : 0),
      _useState8 = _slicedToArray(_useState7, 1),
      per = _useState8[0];

  var _useState9 = useState(initialCurrentPage || 1),
      _useState10 = _slicedToArray(_useState9, 2),
      currentPage = _useState10[0],
      setCurrentPage = _useState10[1];

  var _useState11 = useState(initialData ? initialData.length : 0),
      _useState12 = _slicedToArray(_useState11, 2),
      lastDataSize = _useState12[0],
      setLastDataSize = _useState12[1];

  var _useState13 = useState({
    from: params ? params.from : 0,
    to: params ? params.to : 0,
    page: 1
  }),
      _useState14 = _slicedToArray(_useState13, 2),
      values = _useState14[0],
      setValues = _useState14[1];

  var itemsPerPage = params && params.itemsPerPage ? params.itemsPerPage : 10;

  var prevValues = usePrevious(values);

  var renderManualPagination = function renderManualPagination(currentPage) {
    if (lastDataSize < itemsPerPage) {
      return null;
    }

    return React__default.createElement(
      'div',
      { className: 'd-flex justify-content-between' },
      currentPage && currentPage > 1 && React__default.createElement(
        'a',
        { href: '?page=' + (currentPage - 1) },
        '<< Previous'
      ),
      React__default.createElement(
        'a',
        { href: '?page=' + (currentPage + 1) },
        'Next >>'
      )
    );
  };

  //  check for change in filter parameters from client side and refresh the page
  useEffect(function () {
    if (initialData && data !== initialData && initialData.length >= 0) {
      setData(initialData);
      setCurrentPage(initialCurrentPage ? initialCurrentPage : 1);
      setValues({
        from: params ? params.from : 0,
        to: params ? params.to : 0,
        page: 1
      });
      if (initialData.length > 0) {
        setScrolling(true);
      }
    }
  }, [initialData]);

  useEffect(function () {
    if (prevValues) {
      if (values.page !== prevValues.page && values.from !== prevValues.from && values.to !== prevValues.to) {
        loadData(values, query, client, params, setData, setScrolling, setLastDataSize, pointer, pointerArray);
      }
    }
  }, [values, prevValues, query, client, params, setData, setScrolling, setLastDataSize, pointer, pointerArray]);

  useEffect(function () {
    document.addEventListener('scroll', trackScrolling);
    return function () {
      document.removeEventListener('scroll', trackScrolling);
    };
  }, [currentPage]);

  var trackScrolling = function trackScrolling(current) {
    if (window.pageYOffset === 0) {
      if (currentPage > 1) {
        changePageNumber(1, seoPaginate, pageview, router, currentPage, setCurrentPage, itemsPerPage, 1);
      }
    }
  };

  return React__default.createElement(
    'div',
    null,
    autoScroll ? React__default.createElement(
      React__default.Fragment,
      null,
      React__default.createElement(
        InfiniteScroll,
        { dataLength: data && data.length, next: function next() {
            return loadMore(values, setValues, per);
          }, hasMore: scrolling, scrollThreshold: 0.9 },
        React__default.createElement(
          Container,
          null,
          cardLoader(data, builder, mapping, values, seoPaginate, pageview, router, currentPage, setCurrentPage, showPublished, defaultImage, showAuthor, showCategory, imageHeight, imageWidth, rightItems, brandInsightAd, showBI, itemsPerPage, heroContent, lgInfeedAd, showPubInfo, contentCategoryMapping, showTimeDiff, showTaxonomies, showIntro)
        )
      ),
      React__default.createElement(
        'noscript',
        null,
        renderManualPagination(currentPage)
      )
    ) : React__default.createElement(
      React__default.Fragment,
      null,
      React__default.createElement(
        Container,
        null,
        cardLoader(data, builder, mapping, values, seoPaginate, pageview, router, currentPage, setCurrentPage, showPublished, defaultImage, showAuthor, showCategory, rightItems, brandInsightAd, showBI, itemsPerPage, heroContent, lgInfeedAd, showPubInfo, contentCategoryMapping, showTimeDiff, showTaxonomies, showIntro)
      ),
      React__default.createElement(
        'div',
        { style: { padding: '0px 10px' } },
        scrolling ? React__default.createElement(
          'button',
          {
            style: { margin: 'auto', width: '100%' },
            onClick: function onClick(e) {
              loadMore(values, setValues, per);
            } },
          'Load More'
        ) : React__default.createElement(
          'p',
          { style: { textAlign: 'center' } },
          React__default.createElement(
            'b',
            null,
            'End of data'
          )
        )
      ),
      React__default.createElement(
        'noscript',
        null,
        renderManualPagination(currentPage)
      )
    )
  );
};

export default QueueDeckExpanded;
