'use strict';

require('./stringify-f7a37a8d.js');
var slicedToArray = require('./slicedToArray-067dd3bc.js');
var React = require('react');
var main = require('./main-f1c77adb.js');
var AdSlot = require('./AdSlot.js');
require('./_commonjsHelpers-06173234.js');
require('./core.get-iterator-method-5643aa10.js');
require('./web.dom.iterable-d98303e0.js');
require('./extends-7c86182f.js');
require('./_object-pie-083f2dd6.js');
require('prop-types');
require('./index-fc2f1ca2.js');
require('./events-1b438fe7.js');
require('./debounce-d4a2369b.js');
require('./isSymbol-03abbdf0.js');
require('./toNumber-5e1fac58.js');
require('./Beam.js');
require('./asyncToGenerator-77821af0.js');
require('./_library-dd23b178.js');
require('./_iter-detect-b1df62f0.js');
require('./Segment.js');

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

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

// removed static slotID ,because defining static slotID is restricting AD to render only once.
var AD300x250 = function AD300x250(_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 ? 'rec1' : _ref$pos;

  var mobileView = false;
  if (main.main_43) {
    pos = 'rec1-mobile';
    mobileView = true;
  }

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

  var browserSizes = [[300, 600], [300, 250], [300, 100]];
  var mobileSizes = [[300, 250], [300, 100]];

  return React__default['default'].createElement(
    'div',
    null,
    React__default['default'].createElement(AdSlot, {
      networkID: networkID,
      adUnit: adUnit,
      slotId: slotId,
      targeting: adTargeting,
      className: 'AD300x250',
      sizes: mobileView ? mobileSizes : browserSizes
      /* Passing function to check for ad creative only if it is not in preview. */
      // checkIsAdFound={previewAd ? null : checkIsAdFound}
      // style={{ display: 'none' }}
    }),
    React__default['default'].createElement(
      'style',
      { jsx: 'true' },
      '\n        .AD300x250 .div[id*=\'google_ads_iframe\']:empty {\n          height: 0px !important;\n        }\n      '
    )
  );
};

module.exports = AD300x250;
