import './_commonjsHelpers-0c4b6f40.js';
import './_to-object-a4107da3.js';
import './es6.string.iterator-c990c18c.js';
import './_library-528f1934.js';
import './_iter-detect-5d49a330.js';
import './core.get-iterator-method-e1de7503.js';
import './_object-pie-33c40e79.js';
import './extends-6f2fcc99.js';
import './web.dom.iterable-4439f05a.js';
import React, { useState, useEffect } from 'react';
import './index-acfb8079.js';
import 'prop-types';
import './isSymbol-1981418f.js';
import './debounce-9207d8ee.js';
import './toNumber-2f7a84cd.js';
import { m as main_40 } from './main-747e7d25.js';
import { _ as _slicedToArray } from './slicedToArray-641f241f.js';
import './stringify-4330ccdc.js';
import './asyncToGenerator-fc1c2e29.js';
import './Segment.js';
import './Beam.js';
import DFPAdSlot from './AdSlot.js';

// removed static slotID ,because defining static slotID is restricting AD to render only once.
var AD300x250x600 = function AD300x250x600(_ref) {
  var networkID = _ref.networkID,
      adUnit = _ref.adUnit,
      _ref$slotId = _ref.slotId,
      slotId = _ref$slotId === undefined ? '' : _ref$slotId,
      _ref$targeting = _ref.targeting,
      targeting = _ref$targeting === undefined ? {} : _ref$targeting,
      _ref$pos = _ref.pos,
      pos = _ref$pos === undefined ? 'rec2' : _ref$pos,
      _ref$sizeMapFlag = _ref.sizeMapFlag,
      sizeMapFlag = _ref$sizeMapFlag === undefined ? true : _ref$sizeMapFlag;

  if (main_40) {
    pos = 'rec2-mobile';
  }

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

  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');
    }));
  }, []);

  var adTargeting = {
    content_placement: targeting.content_placement,
    tags: targeting.tags,
    document_group: targeting.document_group,
    document_url: targeting.document_url,
    rootDocumentGroup: targeting.rootDocumentGroup,
    pos: pos,
    campaign_id: targeting.campaign_id,
    issue_url: targeting.issue_url,
    publication_url: targeting.publication_url

    // sizeMapping is made reponsive to handle long ads [300,600] when the sizeMapFlag is 'true'.Otherwise old sizeMapping will be taken.
  };var sizeMapping = sizeMapFlag ? [{
    viewport: [1200, 900],
    sizes: [[300, 100], [300, 250], [300, 600]]
  }, {
    viewport: [1200, 1],
    sizes: [[300, 100], [300, 250]]
  }, {
    viewport: [1, 1],
    sizes: [[300, 100], [300, 250]]
  }] : [{
    viewport: [768, 0],
    sizes: [[300, 100], [300, 250], [300, 600]]
  }, {
    viewport: [1, 1],
    sizes: [[300, 100], [300, 250]]
  }];

  return React.createElement(
    'div',
    null,
    React.createElement(DFPAdSlot, {
      networkID: networkID,
      adUnit: adUnit,
      className: 'AD300x250',
      slotId: slotId,
      targeting: adTargeting
      //  passing all possible sizes.
      , sizes: ([300, 600])
      //  setting responsive sizemapping to make the ads responsive.
      , sizeMapping: sizeMapping
      /* Passing function to check for ad creative only if it is not in preview. */
      // checkIsAdFound={previewAd ? null : checkIsAdFound}
      // style={{ display: 'none' }}
    }),
    React.createElement(
      'style',
      { jsx: 'true' },
      '\n        .AD300x250 .div[id*=\'google_ads_iframe\']:empty {\n          height: 0px !important;\n        }\n      '
    )
  );
};

export default AD300x250x600;
