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