import { useEffect as u } from "react";
import { useLatestValue as f } from "./use-latest-value.js";
function m(r, e, i, t) {
  let o = f(i);
  u(() => {
    if (!r) return;
    function n(s) {
      o.current(s);
    }
    return window.addEventListener(e, n, t), () => window.removeEventListener(e, n, t);
  }, [r, e, t]);
}
export {
  m as useWindowEvent
};
