import './_commonjsHelpers-0c4b6f40.js';
import React__default, { useEffect } from 'react';
import { b as lib_1, l as lib_3 } from './index-0e45a0b2.js';
import 'prop-types';

var AdSlotsProvider = function AdSlotsProvider(_ref) {
  var children = _ref.children,
      networkID = _ref.networkID,
      _ref$targeting = _ref.targeting,
      targeting = _ref$targeting === undefined ? {} : _ref$targeting,
      _ref$singleRequest = _ref.singleRequest,
      singleRequest = _ref$singleRequest === undefined ? true : _ref$singleRequest;

  useEffect(function () {
    // Refresh ADs after every one minute of user not scrolled
    var isScrolling = void 0;
    var refreshADsAfterInterval = function refreshADsAfterInterval() {
      isScrolling = setInterval(function () {
        lib_3.refresh();
      }, 30000);
    };
    refreshADsAfterInterval();
    window.addEventListener('scroll', function () {
      clearInterval(isScrolling);
      refreshADsAfterInterval();
    }, false);
    return function () {
      clearInterval(isScrolling);
    };
  }, []);

  return React__default.createElement(
    lib_1,
    {
      dfpNetworkId: networkID,
      targeting: targeting,
      singleRequest: singleRequest,
      lazyLoad: { fetchMarginPercent: 500, renderMarginPercent: 200, mobileScaling: 2.0 } },
    children
  );
};

export default AdSlotsProvider;
