import { useRef as i, useEffect as m } from "react";
import { getOwnerDocument as E } from "../utils/owner.js";
import { useIsoMorphicEffect as N } from "./use-iso-morphic-effect.js";
function T(c, { container: e, accept: r, walk: t }) {
  let o = i(r), n = i(t);
  m(() => {
    o.current = r, n.current = t;
  }, [r, t]), N(() => {
    if (!e || !c) return;
    let u = E(e);
    if (!u) return;
    let f = o.current, s = n.current, l = Object.assign((p) => f(p), { acceptNode: f }), a = u.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, l, !1);
    for (; a.nextNode(); ) s(a.currentNode);
  }, [e, c, o, n]);
}
export {
  T as useTreeWalker
};
