import { useEffect as o } from "react";
import t from "prop-types";
import { useDebounceFn as r, useMemoizedFn as u } from "ahooks";
function s({ callback: i }) {
  const e = r(i), n = u(() => {
    document.hidden || e.run();
  });
  return o(() => (window.addEventListener("focus", e.run), document.addEventListener("visibilitychange", n), () => {
    window.removeEventListener("focus", e.run), document.removeEventListener("visibilitychange", n);
  }), []), null;
}
s.propTypes = {
  callback: t.func.isRequired
};
export {
  s as default
};
