import { struct as m, structFrom as u } from "../../../../utils/struct/main.js";
import { enumerable as o } from "../../../../utils/struct/property.js";
import { isUndefined as d } from "../../../../utils/value/is.js";
const h = (() => {
  const r = /* @__PURE__ */ new WeakMap(), n = m({
    remove: o(function() {
      v(this.observerCallback);
    })
  }), i = (e, s) => {
    let t = r.get(e);
    if (d(t)) {
      const b = new IntersectionObserver(
        (c) => {
          c.forEach((f) => {
            e && e(f);
          });
        },
        { root: s ?? null, rootMargin: "", threshold: [1] }
      );
      t = u(n, {
        observerCallback: o(e),
        observer: o(b)
      }), r.set(e, t);
    }
    return t;
  }, v = (e) => {
    r.get(e)?.observer.disconnect(), r.delete(e);
  };
  return i;
})();
export {
  h as default
};
