'use strict';

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

require('./_commonjsHelpers-06173234.js');
require('./_to-object-329a650b.js');
require('./es6.string.iterator-cc0bbaa4.js');
require('./_library-dd23b178.js');
require('./_iter-detect-60b2f026.js');
var toConsumableArray = require('./toConsumableArray-9a3476fe.js');
require('./core.get-iterator-method-f62321d4.js');
require('./_object-pie-68c5bcbc.js');
var _extends = require('./extends-60837c34.js');
require('./_object-sap-5e74ba08.js');
var inherits = require('./inherits-513d81cd.js');
require('./define-property-f4d12f4e.js');
require('./web.dom.iterable-a0e279c1.js');
require('./typeof-725500bc.js');
require('./_is-array-754e012d.js');
var React = require('react');
var React__default = _interopDefault(React);
var index = require('./index-fa8ed292.js');
require('prop-types');
var Container = _interopDefault(require('react-bootstrap/Container'));
var Row = _interopDefault(require('react-bootstrap/Row'));
var Col = _interopDefault(require('react-bootstrap/Col'));
var Card = _interopDefault(require('react-bootstrap/Card'));
var moment = require('./moment-575fe24c.js');
var Router = require('next/router');
var Router__default = _interopDefault(Router);
require('./isSymbol-04666465.js');
var debounce = require('./debounce-eb287781.js');
var index_es = require('./index.es-9110add6.js');
require('react-dom');
var visibilitySensor = require('./visibility-sensor-0c45a583.js');
var index$1 = require('./index-be0c82be.js');
var index$2 = require('./index-da796b8c.js');
var main = require('./main-a4cb15bb.js');
var entities = require('./entities-310b46ee.js');
require('./stringify-7c5aff47.js');
require('./slicedToArray-8f385299.js');
require('./asyncToGenerator-533d476a.js');
require('./_set-species-f92c67c5.js');
require('./Segment.js');
require('./Beam.js');
require('./AdSlot.js');
var ADInfeed = require('./ADInfeed-2fe7211c.js');
var lodash = require('./lodash-fc2922d0.js');
var ADlgInfeed = require('./ADlgInfeed-14e17b43.js');
var getContentCategory = require('./getContentCategory-f38a4c00.js');
var get = require('./get-68c52cb1.js');
require('./AD.js');
var AuthorComponent = require('./AuthorComponent-bb831b74.js');

var GridContent = function (_React$Component) {
  inherits._inherits(GridContent, _React$Component);

  function GridContent() {
    var _ref;

    var _temp, _this, _ret;

    inherits._classCallCheck(this, GridContent);

    for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    return _ret = (_temp = (_this = inherits._possibleConstructorReturn(this, (_ref = GridContent.__proto__ || inherits._Object$getPrototypeOf(GridContent)).call.apply(_ref, [this].concat(args))), _this), _this.page = _this.props.page, _this.mapping = _this.props.mapping, _this.data = _this.props.dataRecord, _this.query = _this.props.query, _this.params = _this.props.params, _this.pointer = _this.props.pointer ? _this.props.pointer : false, _this.pointerArray = _this.props.pointerArray ? _this.props.pointerArray : false, _this.defaultImage = _this.props.defaultImage ? _this.props.defaultImage : '/placeholder.jpg', _this.state = {
      data: _this.data,
      per: _this.params ? _this.params.to : 2,
      page: _this.props.currentPage || 1,
      from: _this.params ? _this.params.from : 0,
      to: _this.params ? _this.params.to : 2,
      total_pages: null,
      scrolling: true,
      query: _this.query,
      currentPage: _this.props.currentPage || 1,
      lgInfeedAd: _this.props.lgInfeedAd ? _this.props.lgInfeedAd : false,
      showCategory: _this.props.showCategory ? _this.props.showCategory : false,
      contentCategoryMapping: _this.props.contentCategoryMapping ? contentCategoryMapping : []
    }, _this.loadMore = debounce.debounce_1(function () {
      _this.setState(function (state) {
        var page = state.page,
            from = state.from,
            per = state.per,
            to = state.to;

        return {
          page: page + 1,
          from: from + per,
          to: to + per
        };
      }, _this.loadData);
    }, 0), _this.componentDidMount = function () {
      document.addEventListener('scroll', _this.trackScrolling);
    }, _this.componentWillUnmount = function () {
      document.removeEventListener('scroll', _this.trackScrolling);
    }, _this.componentDidUpdate = function (prevProps, prevState) {
      if (prevState.currentPage !== _this.state.currentPage) {
        document.addEventListener('scroll', _this.trackScrolling);
      }

      // Logging GA Pageview on path change
      var _this$props = _this.props,
          pageview = _this$props.pageview,
          currentPath = _this$props.router.asPath;
      var prevPath = prevProps.router.asPath;

      if (pageview && currentPath !== prevPath) {
        pageview(currentPath);
      }
    }, _this.trackScrolling = function () {
      var itemsPerPage = _this.props.params.itemsPerPage ? _this.props.params.itemsPerPage : 10;
      if (window.pageYOffset === 0) {
        if (_this.state.currentPage > 1) {
          _this.changePageNumber(1, itemsPerPage, 1);
        }
      }
    }, _this.loadData = function () {
      var _this$state = _this.state,
          from = _this$state.from,
          to = _this$state.to,
          data = _this$state.data,
          query = _this$state.query,
          page = _this$state.page;
      var client = _this.props.client;


      var params = _extends._extends({}, _this.params, { from: from, to: to
        // const queryUpdated = query.replace('$from', params.from).replace('$to', params.to)
      });client.fetch(query, params).then(function (dataArr) {
        if (_this.pointer && _this.pointerArray) {
          var pointer = _this.pointer;
          dataArr = dataArr[_this.pointerArray][pointer];
        }
        dataArr = dataArr.map(function (item) {
          return _extends._extends({}, item, {
            pageNumber: page
          });
        });

        _this.setState(function () {
          if (dataArr.length > 0) {
            return {
              data: [].concat(toConsumableArray._toConsumableArray(data), toConsumableArray._toConsumableArray(dataArr)),
              scrolling: true
            };
          } else {
            return {
              scrolling: false
            };
          }
        });
      });
    }, _this.urlFor = function (source) {
      var client = _this.props.client;

      var builder = index$1.imageUrlBuilder(client);
      return builder.image(source).auto('format');
    }, _this.renderCardImage = function (row, page) {
      if (row.thumbnail && row.thumbnail.asset) {
        var url = _this.urlFor(row.thumbnail);
        if (_this.props.imageHeight) url = url.height(_this.props.imageHeight);
        if (_this.props.imageWidth) url = url.width(_this.props.imageWidth);
        return url.url();
      } else {
        return _this.defaultImage;
      }
    }, _this.changePageNumber = function (pageNumber, itemsPerPage, itemIndex) {
      var _this$props2 = _this.props,
          seoPaginate = _this$props2.seoPaginate,
          pageview = _this$props2.pageview,
          router = _this$props2.router;
      var currentPage = _this.state.currentPage;

      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$1 = Number(itemIndex);
        var perPage = Number(itemsPerPage);

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

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

          _this.setState({
            currentPage: pageNumber
          }, function () {
            if (path[0] !== '/') {
              path = '/' + path;
            }

            var newPath = pageNumber === 1 ? '' + path : path + '?page=' + pageNumber;
            // if (pageview) {
            //   pageview(newPath)
            // }

            router.push(pathname, newPath, {
              shallow: true
            });
          });
        }
      }
    }, _this.checkExternalUrl = function (url) {
      return new RegExp(['http', 'https'].join('|')).test(url);
    }, _this.renderMobileAd = function (index, numberOfItemsBeforeAd) {
      var rightItems = _this.props.rightItems;

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

      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 >>'
        )
      );
    }, _temp), inherits._possibleConstructorReturn(_this, _ret);
  }

  inherits._createClass(GridContent, [{
    key: 'cardLoader',
    value: function cardLoader(page, columns, variant, showVideo, VideoPlayer, showBI, brandInsight, lgInfeedAd, contentCategoryMapping) {
      var _this2 = this;

      var lgVar = Math.floor(12 / columns);
      var itemCounter = 0;
      var numberOfItemsBeforeAd = 6;
      var numberOfItemsBeforeVideo = 3;
      if (variant === 'stack') {
        return React__default.createElement(
          Row,
          null,
          this.state.data && this.state.data.length > 0 ? this.state.data.map(function (row, index) {
            // const thumbnailURL = get(row, 'thumbnail.asset.url', this.props.defaultImage)
            return React__default.createElement(
              Col,
              { key: index, md: 12, lg: lgVar, style: { display: 'flex', flex: '1 0 auto' } },
              React__default.createElement(
                Card,
                { className: 'queue-card', style: { borderTop: '1px solid #EEE' } },
                React__default.createElement(
                  Row,
                  { style: { flexDirection: 'row' } },
                  React__default.createElement(
                    Col,
                    { md: 12, lg: 4 },
                    React__default.createElement(
                      'a',
                      { href: _this2.page + '/' + get.get_1(row, 'url.current') },
                      React__default.createElement(
                        index$2.LazyLoad,
                        { height: _this2.props.imageHeight },
                        React__default.createElement(Card.Img, { variant: 'top', src: _this2.renderCardImage(row, page), alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : '' })
                      )
                    )
                  ),
                  React__default.createElement(
                    Col,
                    null,
                    React__default.createElement(
                      Card.Body,
                      { style: { padding: '20px' } },
                      React__default.createElement(
                        Card.Title,
                        null,
                        React__default.createElement(
                          'a',
                          { href: _this2.page + '/' + get.get_1(row, 'url.current') },
                          row.title
                        )
                      ),
                      _this2.props.showPublished && row.published && React__default.createElement(
                        Card.Subtitle,
                        { style: { marginTop: 0 } },
                        moment.moment(row.published).format('MMMM DD, YYYY')
                      ),
                      _this2.props.showAuthor && row.authorMapping && row.authorMapping.length > 0 && React__default.createElement(
                        index$2.LazyLoad,
                        { height: 50 },
                        React__default.createElement(AuthorComponent.AuthorComponent, { key: index.toString(), index: index, authors: row.authorMapping })
                      ),
                      _this2.props.showCategory && row.contentCategory && React__default.createElement(
                        index$2.LazyLoad,
                        { height: 50 },
                        React__default.createElement(
                          'p',
                          {
                            className: 'article-category',
                            style: {
                              background: '#3FB618',
                              color: '#ffffff',
                              marginBottom: '.25rem',
                              display: 'inline-block',
                              padding: '0 .25rem',
                              fontSize: '.8rem'
                            } },
                          getContentCategory.getContentCategory(row.contentCategory.name, contentCategoryMapping)
                        )
                      ),
                      React__default.createElement(
                        Card.Text,
                        null,
                        entities.clean_html_1(row.summary)
                      )
                    )
                  )
                )
              )
            );
          }) : React__default.createElement(
            'div',
            null,
            React__default.createElement(
              'h5',
              null,
              React__default.createElement(
                'em',
                null,
                'New content coming soon, please check back later.'
              )
            )
          )
        );
      }

      var insert = function insert(arr, index, newElement) {
        return [].concat(toConsumableArray._toConsumableArray(arr.slice(0, index)), [newElement], toConsumableArray._toConsumableArray(arr.slice(index)));
      };
      var posts = [];
      if (brandInsight && (lgInfeedAd || showBI)) {
        var firstThree = this.state.data.slice(0, 3);
        var data = this.state.data.slice(3);

        //  Need to pass flag "lgInfeedAd={true}" along with brandInsight from site level for large infeed-ad to render
        //  Checking lgInfeedAd flag in desktop view ( window >= 1400px ).
        if (lgInfeedAd && typeof window !== 'undefined' && window.innerWidth >= 1400) {
          var lgInFeedAd = {
            _type: 'lg-infeed',
            adUnit: brandInsight.adUnit,
            className: 'lg-infeed',
            networkID: brandInsight.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: brandInsight.targeting.content_placement,
              document_url: brandInsight.targeting.document_url
            }
          };
          var chunks = lodash.lodash.chunk(data, 6).map(function (chunk) {
            var set = lodash.lodash.chunk(chunk, 2);
            for (var i = 0; i < set.length; i++) {
              if (i !== set.length - 1) {
                set[i].push(lgInFeedAd);
              }
            }
            return lodash.lodash.flattenDeep(set);
          });

          posts = lodash.lodash.flatten(chunks);
        }

        if (showBI) {
          //  Checking lgInfeedAd flag in desktop view ( window >= 1400px ).
          if (lgInfeedAd && typeof window !== 'undefined' && window.innerWidth >= 1400) {
            brandInsight.interval = 8;
          } else if (typeof window !== 'undefined' && window.innerWidth < 1400) {
            brandInsight.interval = 5;
            posts = data;
          }

          var pos = 0;
          for (var i = 1; pos < posts.length; i++) {
            var inFeedAd = {
              adUnit: brandInsight.adUnit,
              className: brandInsight.className,
              networkID: brandInsight.networkID,
              sizes: brandInsight.sizes,
              slotId: brandInsight.slotId + '_' + i,
              targeting: {
                pos: 'infeed',
                content_placement: brandInsight.targeting.content_placement,
                document_url: brandInsight.targeting.document_url
              },
              _type: 'brandInsightAd'
            };

            posts = insert(posts, pos, inFeedAd);
            pos += brandInsight.interval + 1;
          }
        }
        posts = firstThree.concat(posts);
      } else {
        posts = this.state.data;
      }

      // '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;
      posts = posts.map(function (ele, i) {
        if (ele._type === 'lg-infeed') {
          //  Setting pos as top2 for the first occurence of large infeed ad
          // const pos = posts.indexOf(posts.find((d) => d._type === 'lg-infeed')) === i ? 'top2' : `lg-infeed_${i}`
          return _extends._extends({}, ele, { slotId: 'lg-infeed_' + i, targeting: _extends._extends({}, ele.targeting, { pos: 'lg-infeed' }) });
        } else if (ele._type === 'article') {
          // incrementing 'articleCount' for each article.
          ++articleCount;
          return _extends._extends({}, ele, { articleCount: articleCount });
        } else {
          return ele;
        }
      });

      var itemsPerPage = this.props.params && this.props.params.itemsPerPage ? this.props.params.itemsPerPage : 10;
      var heroContent = this.props.heroContent ? this.props.heroContent : 0;
      var featureCount = 0;
      return React__default.createElement(
        'div',
        { className: 'grid-container' },
        posts && posts.length > 0 ? posts.map(function (row, index) {
          var pageNumber = row.pageNumber || _this2.state.page;
          var contentCategoryName = row.contentCategory && row.contentCategory.name && _this2.mapping[row.contentCategory.name] ? row.contentCategory.name : 'Articles';
          var linkHref = row.url && row.url.current ? _this2.mapping[contentCategoryName] + '/' + row.url.current : '';
          if (row._type === 'feature') {
            featureCount++;
            if (row.blank || _this2.checkExternalUrl(row.url.current)) {
              return React__default.createElement(
                React__default.Fragment,
                { key: itemCounter },
                React__default.createElement(
                  visibilitySensor.VisibilitySensor,
                  {
                    partialVisibility: true,
                    onChange: function onChange(isVisible) {
                      isVisible && _this2.changePageNumber(1, itemsPerPage, index);
                    } },
                  React__default.createElement(
                    'div',
                    { counter: itemCounter++, style: { display: 'flex', flex: '1 0 auto' } },
                    React__default.createElement(
                      Card,
                      { className: 'content-card', style: { flexDirection: index === 0 || index % 4 === 0 ? 'top' : 'row' } },
                      (row.thumbnail && row.thumbnail.asset || _this2.props.defaultImage) && React__default.createElement(
                        'a',
                        { rel: 'noopener', href: row.url.current, target: '_blank', className: index === 0 || index % 4 === 0 ? '' : 'card-image' },
                        React__default.createElement(
                          index$2.LazyLoad,
                          { height: _this2.props.imageHeight },
                          React__default.createElement(Card.Img, {
                            variant: 'top',
                            src: _this2.renderCardImage(row, page),
                            alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : ''
                          })
                        )
                      ),
                      React__default.createElement(
                        Card.Body,
                        null,
                        React__default.createElement(
                          'a',
                          { rel: 'noopener', href: row.url.current, target: '_blank' },
                          React__default.createElement(
                            Card.Title,
                            null,
                            row.title
                          )
                        ),
                        _this2.props.showPublished && row.published && React__default.createElement(
                          Card.Subtitle,
                          { style: { marginTop: 0 } },
                          moment.moment(row.published).format('MMMM DD, YYYY')
                        ),
                        _this2.props.showAuthor && row.authorMapping && row.authorMapping.length > 0 && React__default.createElement(
                          index$2.LazyLoad,
                          { height: 50 },
                          React__default.createElement(AuthorComponent.AuthorComponent, { key: index.toString(), index: index, authors: row.authorMapping })
                        ),
                        React__default.createElement(
                          Card.Text,
                          { className: index === 0 || index % 4 === 0 ? '' : 'card-subtext' },
                          entities.clean_html_1(row.summary)
                        )
                      )
                    )
                  )
                ),
                showVideo && (posts.length < numberOfItemsBeforeVideo || index + 1 === numberOfItemsBeforeVideo) && React__default.createElement(VideoPlayer, null),
                main.main_36 && _this2.props.rightItems && (index + 1) % numberOfItemsBeforeAd === 0 && _this2.renderMobileAd(index, numberOfItemsBeforeAd)
              );
            } else {
              return React__default.createElement(
                React__default.Fragment,
                { key: itemCounter },
                React__default.createElement(
                  visibilitySensor.VisibilitySensor,
                  {
                    partialVisibility: true,
                    onChange: function onChange(isVisible) {
                      isVisible && _this2.changePageNumber(1, itemsPerPage, index);
                    } },
                  React__default.createElement(
                    'div',
                    { counter: itemCounter++, style: { display: 'flex', flex: '1 0 auto' } },
                    React__default.createElement(
                      Card,
                      { className: 'content-card', style: { flexDirection: index === 0 || index % 4 === 0 ? 'top' : 'row' } },
                      (row.thumbnail && row.thumbnail.asset || _this2.props.defaultImage) && React__default.createElement(
                        'a',
                        { href: row.url.current, className: index === 0 || index % 4 === 0 ? '' : 'card-image' },
                        React__default.createElement(
                          index$2.LazyLoad,
                          { height: _this2.props.imageHeight },
                          React__default.createElement(Card.Img, {
                            variant: 'top',
                            src: _this2.renderCardImage(row, page),
                            alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : ''
                          })
                        )
                      ),
                      React__default.createElement(
                        Card.Body,
                        null,
                        React__default.createElement(
                          'a',
                          { href: row.url.current },
                          React__default.createElement(
                            Card.Title,
                            null,
                            row.title
                          )
                        ),
                        _this2.props.showPublished && row.published && React__default.createElement(
                          Card.Subtitle,
                          { style: { marginTop: 0 } },
                          moment.moment(row.published).format('MMMM DD, YYYY')
                        ),
                        _this2.props.showAuthor && row.authorMapping && row.authorMapping.length > 0 && React__default.createElement(
                          index$2.LazyLoad,
                          { height: 50 },
                          React__default.createElement(AuthorComponent.AuthorComponent, { key: index.toString(), index: index, authors: row.authorMapping })
                        ),
                        React__default.createElement(
                          Card.Text,
                          { className: index === 0 || index % 4 === 0 ? '' : 'card-subtext' },
                          entities.clean_html_1(row.summary)
                        )
                      )
                    )
                  )
                ),
                showVideo && (posts.length < numberOfItemsBeforeVideo || index + 1 === numberOfItemsBeforeVideo) && React__default.createElement(VideoPlayer, null),
                main.main_36 && _this2.props.rightItems && (index + 1) % numberOfItemsBeforeAd === 0 && _this2.renderMobileAd(index, numberOfItemsBeforeAd)
              );
            }
          } else if (row._type === 'lg-infeed' && row.adUnit) {
            return React__default.createElement(ADlgInfeed.ADlgInfeed, _extends._extends({ index: index }, row));
          } else if (row._type === 'brandInsightAd' && row.adUnit) {
            return React__default.createElement(ADInfeed.ADInfeed, { index: index, infeedAd: row });
          }
          if (index + 1 > heroContent + featureCount && (!row._type || !['lg-infeed', 'brandInsightAd'].includes(row._type))) {
            return React__default.createElement(
              React__default.Fragment,
              { key: itemCounter },
              React__default.createElement(
                visibilitySensor.VisibilitySensor,
                {
                  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 article only.
                    isVisible && _this2.changePageNumber(pageNumber, itemsPerPage, row.articleCount ? row.articleCount : index);
                  } },
                React__default.createElement(
                  'div',
                  { counter: itemCounter++, style: { display: 'flex', flex: '1 0 auto' } },
                  React__default.createElement(
                    Card,
                    { className: 'content-card', style: { flexDirection: index === 0 || index % 4 === 0 ? 'top' : 'row' } },
                    (row.thumbnail && row.thumbnail.asset || _this2.props.defaultImage) && React__default.createElement(
                      'a',
                      { href: linkHref, className: index === 0 || index % 4 === 0 ? '' : 'card-image' },
                      React__default.createElement(
                        index$2.LazyLoad,
                        { height: _this2.props.imageHeight },
                        React__default.createElement(Card.Img, {
                          variant: 'top',
                          src: _this2.renderCardImage(row, page),
                          alt: row.thumbnail && row.thumbnail.asset ? row.thumbnail.asset.originalFilename : ''
                        })
                      )
                    ),
                    React__default.createElement(
                      Card.Body,
                      null,
                      React__default.createElement(
                        'a',
                        { href: linkHref },
                        React__default.createElement(
                          Card.Title,
                          null,
                          row.title
                        )
                      ),
                      _this2.props.showPublished && row.published && React__default.createElement(
                        Card.Subtitle,
                        { style: { marginTop: 0 } },
                        moment.moment(row.published).format('MMMM DD, YYYY')
                      ),
                      _this2.props.showAuthor && row.authorMapping && row.authorMapping.length > 0 && React__default.createElement(
                        index$2.LazyLoad,
                        { height: 50 },
                        React__default.createElement(AuthorComponent.AuthorComponent, { key: index.toString(), index: index, authors: row.authorMapping })
                      ),
                      _this2.props.showCategory && row.contentCategory && React__default.createElement(
                        index$2.LazyLoad,
                        { height: 50 },
                        React__default.createElement(
                          'p',
                          {
                            className: 'article-category',
                            style: {
                              background: '#3FB618',
                              color: '#ffffff',
                              marginBottom: '.25rem',
                              display: 'inline-block',
                              padding: '0 .25rem',
                              fontSize: '.8rem'
                            } },
                          getContentCategory.getContentCategory(row.contentCategory.name, contentCategoryMapping)
                        )
                      ),
                      React__default.createElement(
                        Card.Text,
                        { className: index === 0 || index % 4 === 0 ? '' : 'card-subtext' },
                        entities.clean_html_1(row.summary)
                      )
                    )
                  )
                )
              ),
              showVideo && (posts.length < numberOfItemsBeforeVideo || index + 1 === numberOfItemsBeforeVideo) && React__default.createElement(VideoPlayer, null),
              main.main_36 && _this2.props.rightItems && (index + 1) % numberOfItemsBeforeAd === 0 && _this2.renderMobileAd(index, numberOfItemsBeforeAd)
            );
          } 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.'
            )
          )
        )
      );
    }
  }, {
    key: 'render',
    value: function render() {
      var _this3 = this;

      var _props = this.props,
          columns = _props.columns,
          variant = _props.variant,
          autoScroll = _props.autoScroll,
          page = _props.page,
          showVideo = _props.showVideo,
          VideoPlayer = _props.VideoPlayer,
          showBI = _props.showBI,
          brandInsight = _props.brandInsight;


      return React__default.createElement(
        'div',
        { className: 'contentDeck' },
        autoScroll ? React__default.createElement(
          index_es.InfiniteScroll,
          { dataLength: this.state.data.length, next: this.loadMore, hasMore: this.state.scrolling },
          React__default.createElement(
            Container,
            null,
            this.cardLoader(page, columns, variant, showVideo, VideoPlayer, showBI, brandInsight, this.state.lgInfeedAd, this.state.contentCategoryMapping)
          )
        ) : React__default.createElement(
          React__default.Fragment,
          null,
          React__default.createElement(
            Container,
            null,
            this.cardLoader(page, columns, variant, showVideo, VideoPlayer, showBI, brandInsight, this.state.lgInfeedAd, this.state.contentCategoryMapping)
          ),
          React__default.createElement(
            'div',
            { style: { padding: '0px 10px' } },
            this.state.scrolling ? React__default.createElement(
              'button',
              {
                style: { margin: 'auto', width: '100%' },
                onClick: function onClick(e) {
                  _this3.loadMore();
                } },
              'Load More'
            ) : React__default.createElement(
              'p',
              { style: { textAlign: 'center' } },
              React__default.createElement(
                'b',
                null,
                'End of data'
              )
            )
          ),
          React__default.createElement(
            'noscript',
            null,
            this.renderManualPagination()
          )
        )
      );
    }
  }]);

  return GridContent;
}(React__default.Component);

var GridContent$1 = React__default.memo(Router.withRouter(GridContent));

module.exports = GridContent$1;
