'use strict';

require('./stringify-f7a37a8d.js');
var slicedToArray = require('./slicedToArray-067dd3bc.js');
var React = require('react');
var main = require('./main-ae8472f3.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-be0d85bc.js');
require('prop-types');
require('./index-d2a6ef75.js');
require('./events-1b438fe7.js');
require('./debounce-d4a2369b.js');
require('./isSymbol-03abbdf0.js');
require('./toNumber-5e1fac58.js');
require('./Beam.js');
require('./asyncToGenerator-65df6bf8.js');
require('./_library-dd23b178.js');
require('./_set-species-0c7864a2.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);

var AD728x90 = function AD728x90(_ref) {
  var networkID = _ref.networkID,
      adUnit = _ref.adUnit,
      _ref$slotId = _ref.slotId,
      slotId = _ref$slotId === undefined ? 'leaderboard-ad' : _ref$slotId,
      _ref$targeting = _ref.targeting,
      targeting = _ref$targeting === undefined ? {} : _ref$targeting,
      _ref$pos = _ref.pos,
      pos = _ref$pos === undefined ? 'top' : _ref$pos;
      _ref.fixedPos;

  var mobileView = false;
  if (main.main_43) {
    pos = 'top-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 = [[728, 90], [970, 90], [320, 50], [300, 50]];
  var mobileSizes = [[320, 50], [300, 50]];

  return React__default["default"].createElement(
    'div',
    { className: 'leaderboard-ad-wrapper' },
    React__default["default"].createElement(AdSlot, {
      slotId: slotId,
      networkID: networkID,
      adUnit: adUnit,
      targeting: adTargeting,
      className: 'AD728x90',
      sizes: mobileView ? mobileSizes : browserSizes,
      sizeMapping: [{
        viewport: [1000, 1],
        sizes: [[728, 90], [970, 90]]
      }, {
        viewport: [768, 1],
        sizes: [[728, 90]]
      }, {
        viewport: [1, 1],
        sizes: [[320, 50], [300, 50]]
      }]
      /* Passing function to check for ad creative only if it is not in preview. */
      // checkIsAdFound={previewAd ? null : checkIsAdFound}
    }),
    React__default["default"].createElement(
      'style',
      { jsx: 'true' },
      '\n        .leaderboard-ad-wrapper {\n          height: auto !important;\n          min-height: 90px;\n          background: #fff;\n        }\n        .leaderboard-ad-wrapper .AD728x90 {\n          height: auto !important;\n        }\n        /* setting height to 0px when the ad slot is empty. */\n        .leaderboard-ad-wrapper .AD728x90 div[id*=\'google_ads_iframe\']:empty {\n          height: 0px !important;\n        }\n      '
    ),
    main.main_43 && React__default["default"].createElement(
      'style',
      { jsx: 'true' },
      '\n          @media screen and (max-width: 768px) {\n            .leaderboard-ad-wrapper {\n              min-height: 0px;\n              position: fixed;\n              background: transparent;\n              background-color: transparent;\n              bottom: 0px;\n              left: 50%;\n              transform: translateX(-50%);\n              z-index: 9999;\n            }\n          }\n        '
    )
  );
};

module.exports = AD728x90;
