'use strict';

var slicedToArray = require('./slicedToArray-067dd3bc.js');
var React = require('react');
require('react-bootstrap/Card');
var AdSlot = require('./AdSlot.js');
var main = require('./main-ae8472f3.js');

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

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

var ADlgInfeed = function ADlgInfeed(props) {
  var className = props.className,
      slotId = props.slotId,
      adUnit = props.adUnit,
      _props$targeting = props.targeting,
      targeting = _props$targeting === undefined ? {} : _props$targeting,
      networkID = props.networkID,
      sizes = props.sizes,
      index = props.index,
      _props$refreshFlag = props.refreshFlag,
      refreshFlag = _props$refreshFlag === undefined ? false : _props$refreshFlag;

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

  var _useState3 = React.useState(refreshFlag),
      _useState4 = slicedToArray._slicedToArray(_useState3, 2),
      adRefreshFlag = _useState4[0],
      setAdRefreshFlag = _useState4[1];

  React.useEffect(function () {
    var path = window && window.location && window.location.search;
    // Setting flag for Ad-preview URLs
    setPreviewAd(path.split('&').some(function (param) {
      return param.includes('creativeId');
    }));
    if (main.main_22.toLowerCase().indexOf('adwallet') >= 0) {
      setAdRefreshFlag(false);
    }
  }, []);

  return React__default["default"].createElement(
    'div',
    { id: 'lg-infeed-wrapper-' + (index + 1), className: 'lg-infeed-wrapper', style: { display: 'flex', flex: '1 0 auto' } },
    React__default["default"].createElement(AdSlot, {
      className: className,
      networkID: networkID,
      adUnit: adUnit,
      slotId: slotId,
      targeting: targeting,
      sizes: sizes
      /* Passing function to check for ad creative only if it is not in preview. */
      // checkIsAdFound={previewAd ? null : checkIsAdFound}
      /* Passing refresh flag */
      , refreshFlag: adRefreshFlag
    }),
    React__default["default"].createElement(
      'style',
      { jsx: 'true' },
      '\n        .lg-infeed-wrapper {\n          flex-direction: row;\n          margin-bottom: 1.25rem;\n          padding-bottom: 1.25rem;\n          border-bottom: 1px solid rgb(221, 221, 221);\n        }\n        .lg-infeed-wrapper div[id*=\'google_ads_iframe\']:empty {\n          height: 0px !important;\n        }\n      '
    )
  );
};

exports.ADlgInfeed = ADlgInfeed;
