import { _ as _slicedToArray } from './slicedToArray-6ebcbfea.js';
import { _ as _toConsumableArray } from './toConsumableArray-f7074d7c.js';
import { _ as _extends } from './extends-6d8e3924.js';
import React__default, { useEffect, useState, useRef } from 'react';
import { Container, Media } from 'react-bootstrap';
import urlFor from './urlFor.js';
import { I as InfiniteScroll } from './index.es-a6137319.js';
import { m as moment } from './moment-bc12cb97.js';
import { V as VisibilitySensor } from './visibility-sensor-72fd8f8b.js';
import { l as lib_3 } from './index-f0fc23eb.js';
import { useRouter } from 'next/router';
import { L as LazyLoad } from './index-755f2cc2.js';
import { m as main_43 } from './main-1894c974.js';
import { c as clean_html_1 } from './entities-6d9154b4.js';
import { A as ADInfeed } from './ADInfeed-6d1fc6bf.js';
import { A as AuthorComponent } from './AuthorComponent-11adff02.js';
import { l as lodash } from './lodash-f97fd99a.js';
import { A as ADlgInfeed } from './ADlgInfeed-dc36c928.js';
import { g as getContentCategory } from './getContentCategory-15dcc413.js';
import timeDifferenceCalc from './timeDifferenceCalc.js';
import './_commonjsHelpers-0c4b6f40.js';
import './web.dom.iterable-ab4dea5c.js';
import './core.get-iterator-method-ea258bb1.js';
import './_iter-detect-98db3b07.js';
import './_object-pie-133f504a.js';
import './index-3f5c03b2.js';
import 'react-dom';
import './events-6c3a7a63.js';
import 'prop-types';
import 'react-bootstrap/Card';
import './AdSlot.js';
import './debounce-533d9748.js';
import './isSymbol-a7e9aafe.js';
import './toNumber-5aeba6e7.js';
import './Beam.js';
import './stringify-2b084bee.js';
import './asyncToGenerator-958ef5fc.js';
import './_library-528f1934.js';
import './Segment.js';

var renderCardImage = function renderCardImage(row, client) {
  var imageHeight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  var imageWidth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
  var imageMaxHeight = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
  var imageFit = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;

  var url = urlFor({ client: client, source: row.thumbnail, imageHeight: imageHeight, imageWidth: imageWidth, imageMaxHeight: imageMaxHeight, imageFit: imageFit });

  return url;
};

var loadMore = function loadMore(values, setValues, itemsPerPage) {
  console.log('Values:::', values);
  setValues({
    page: values.page + 1,
    from: values.from + itemsPerPage,
    to: values.to + itemsPerPage
  });
};

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);
    // const index = Number(itemIndex)
    // const 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, client, mapping, values, seoPaginate, pageview, router, currentPage, setCurrentPage, showPublished, defaultImage, showAuthor, showCategory, imageHeight, imageWidth, imageMaxHeight, imageFit, rightItems, brandInsightAd, showBI, itemsPerPage, heroContent, lgInfeedAd, showPubInfo, contentCategoryMapping, showTimeDiff, showTaxonomies, showIntro) {
  var numberOfItemsBeforeAd = data.length < 6 ? data.length : 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,
        document_group: brandInsightAd.targeting.document_group,
        rootDocumentGroup: brandInsightAd.targeting.rootDocumentGroup
      },
      /* Passing refresh flag */
      refreshFlag: brandInsightAd.refreshFlag ? brandInsightAd.refreshFlag : false
    };

    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,
          document_group: brandInsightAd.targeting.document_group,
          rootDocumentGroup: brandInsightAd.targeting.rootDocumentGroup
        },
        _type: 'brandInsightAd',
        /* Passing refresh flag */
        refreshFlag: brandInsightAd.refreshFlag ? brandInsightAd.refreshFlag : false
      };

      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(pageNumber, seoPaginate, pageview, router, currentPage, setCurrentPage);
              } },
            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, client, imageHeight, imageWidth, imageMaxHeight, imageFit), 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(pageNumber, seoPaginate, pageview, router, currentPage, setCurrentPage);
              } },
            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, client, imageHeight, imageWidth, imageMaxHeight, imageFit), 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, client, imageHeight, imageWidth, imageMaxHeight, imageFit), 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_43 && 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(pageNumber, seoPaginate, pageview, router, currentPage, setCurrentPage);
                } },
              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, client, imageHeight, imageWidth, imageMaxHeight, imageFit), 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(pageNumber, seoPaginate, pageview, router, currentPage, setCurrentPage);
                } },
              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, client, imageHeight, imageWidth, imageMaxHeight, imageFit), 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, client, imageHeight, imageWidth, imageMaxHeight, imageFit), 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_43 && 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 = numberOfItemsBeforeAd < 6 ? 0 : ((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,
      imageMaxHeight = props.imageMaxHeight,
      imageFit = props.imageFit,
      rightItems = props.rightItems,
      brandInsightAd = props.brandInsightAd,
      _props$nextPagePostsC = props.nextPagePostsCount,
      nextPagePostsCount = _props$nextPagePostsC === undefined ? 3 : _props$nextPagePostsC,
      _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 _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(initialCurrentPage || 1),
      _useState8 = _slicedToArray(_useState7, 2),
      currentPage = _useState8[0],
      setCurrentPage = _useState8[1];

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

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

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

  var prevValues = usePrevious(values);

  var renderManualPagination = function renderManualPagination(currentPage) {
    return React__default.createElement(
      'div',
      { className: 'd-flex justify-content-between' },
      currentPage && currentPage > 1 && React__default.createElement(
        'a',
        { href: '?page=' + (currentPage - 1) },
        '<< Previous'
      ),
      !(lastDataSize < itemsPerPage) && nextPagePostsCount > 0 && 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: initialCurrentPage ? initialCurrentPage : 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(() => {
  //   document.addEventListener('scroll', trackScrolling)
  //   return () => {
  //     document.removeEventListener('scroll', trackScrolling)
  //   }
  // }, [currentPage])

  // const 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, itemsPerPage);
          }, hasMore: scrolling, scrollThreshold: 0.9 },
        React__default.createElement(
          Container,
          null,
          cardLoader(data, client, mapping, values, seoPaginate, pageview, router, currentPage, setCurrentPage, showPublished, defaultImage, showAuthor, showCategory, imageHeight, imageWidth, imageMaxHeight, imageFit, 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, client, mapping, values, seoPaginate, pageview, router, currentPage, setCurrentPage, showPublished, defaultImage, showAuthor, showCategory, imageHeight, imageWidth, imageMaxHeight, imageFit, rightItems, brandInsightAd, showBI, itemsPerPage, heroContent, lgInfeedAd, showPubInfo, contentCategoryMapping, showTimeDiff, showTaxonomies, showIntro)
      ),
      React__default.createElement(
        'div',
        { style: { padding: '0px 10px' } },
        scrolling ? React__default.createElement(
          'button',
          {
            className: 'load-more-btn',
            style: { margin: 'auto', width: '100%' },
            onClick: function onClick(e) {
              loadMore(values, setValues, itemsPerPage);
            } },
          '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;
