import { defineComponent, withDirectives, cloneVNode } from "vue";
import { useIntersectionObserverDirective } from "../hooks/use-element-intersection.mjs";
import "../_utils/global.mjs";
const intersectionObserver = defineComponent({
  name: "OIntersectionObserver",
  emits: ["intersection"],
  setup(_props, { emit, slots }) {
    const { vIntersectionObserver } = useIntersectionObserverDirective({
      listener: (entry) => {
        emit("intersection", entry.isIntersecting, entry);
      },
      removeOnUnmounted: false
    });
    return () => {
      var _a;
      const children = (_a = slots.default) == null ? void 0 : _a.call(slots);
      return children == null ? void 0 : children.map((item) => withDirectives(cloneVNode(item), [[vIntersectionObserver]]));
    };
  }
});
export {
  intersectionObserver as default
};
