'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');
require('./core.get-iterator-method-f62321d4.js');
require('./_object-pie-68c5bcbc.js');
require('./extends-60837c34.js');
require('./web.dom.iterable-a0e279c1.js');
var React = require('react');
var React__default = _interopDefault(React);
require('./index-8bf6c863.js');
require('prop-types');
require('./isSymbol-04666465.js');
require('./debounce-eb287781.js');
var main = require('./main-02daeefe.js');
var slicedToArray = require('./slicedToArray-8f385299.js');
require('./stringify-7c5aff47.js');
require('./asyncToGenerator-533d476a.js');
require('./_set-species-f92c67c5.js');
require('./Segment.js');
require('./Beam.js');
var AdSlot = require('./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.main_36) {
    pos = 'rec2-mobile';
  }

  var _useState = React.useState(true),
      _useState2 = slicedToArray._slicedToArray(_useState, 2),
      previewAd = _useState2[0],
      setPreviewAd = _useState2[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');
    }));
  }, []);

  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__default.createElement(
    'div',
    null,
    React__default.createElement(AdSlot, {
      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__default.createElement(
      'style',
      { jsx: 'true' },
      '\n        .AD300x250 .div[id*=\'google_ads_iframe\']:empty {\n          height: 0px !important;\n        }\n      '
    )
  );
};

module.exports = AD300x250x600;
