'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

require('./_commonjsHelpers-06173234.js');
require('./_to-object-7a3ce269.js');
require('./es6.string.iterator-ab94a594.js');
require('./_library-dd23b178.js');
require('./_iter-detect-ef35661e.js');
require('./core.get-iterator-method-6cd7682d.js');
require('./_object-pie-68c5bcbc.js');
require('./extends-acc1318d.js');
require('./web.dom.iterable-68e3aaf2.js');
var React = require('react');
var React__default = _interopDefault(React);
require('./events-1b438fe7.js');
require('./index-98e01cb9.js');
require('prop-types');
require('./isSymbol-04666465.js');
require('./debounce-6191c8ee.js');
require('./toNumber-f2f8744b.js');
var main = require('./main-bc7d4bf8.js');
var slicedToArray = require('./slicedToArray-41819145.js');
require('./stringify-7ccc8524.js');
require('./asyncToGenerator-8ae2191c.js');
require('./Segment.js');
require('./Beam.js');
var AdSlot = require('./AdSlot.js');

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 = _ref.fixedPos;

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

  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
  };

  var browserSizes = [[728, 90], [970, 90], [320, 50], [300, 50]];
  var mobileSizes = [[320, 50], [300, 50]];

  return React__default.createElement(
    'div',
    { className: 'leaderboard-ad-wrapper' },
    React__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.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.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;
