import { SUPPORTS_INTERSECTION_OBSERVER } from "@veno-ui/utils";
function mounted(el, binding) {
  if (!SUPPORTS_INTERSECTION_OBSERVER)
    return;
  const modifiers = binding.modifiers || {};
  const value = binding.value;
  const { handler, options } = typeof value === "object" ? value : { handler: value, options: {} };
  const observer = new IntersectionObserver((entries = [], observer2) => {
    if (!el._intersect)
      return;
    const isIntersecting = entries.some((entry) => entry.isIntersecting);
    if (handler && (!modifiers.quiet || el._intersect.init) && (!modifiers.once || isIntersecting || !el._intersect.init)) {
      handler(isIntersecting, entries, observer2);
    }
    if (isIntersecting && modifiers.once) {
      unmounted(el);
    } else {
      el._intersect.init = true;
    }
  }, options);
  el._intersect = { init: false, observer };
  observer.observe(el);
}
function unmounted(el) {
  if (!el._intersect)
    return;
  el._intersect.observer.unobserve(el);
  delete el._intersect;
}
const Intersect = {
  mounted,
  unmounted
};
var intersect_default = Intersect;
export {
  Intersect,
  intersect_default as default
};
//# sourceMappingURL=index.mjs.map
