function i({ element: t, position: r = "top", offset: s = 0 }) {
  if (!window.IntersectionObserver || !t)
    return;
  const c = `${r === "top" ? -(s + 1) : 0}px`, e = `${r === "right" ? -(s + 1) : 0}px`, n = `${r === "bottom" ? -(s + 1) : 0}px`, a = `${r === "left" ? -(s + 1) : 0}px`;
  s !== null && (t._stickyObserver = new window.IntersectionObserver(u, {
    root: null,
    threshold: 1,
    rootMargin: `${c} ${e} ${n} ${a}`
  }), t.style.position = "sticky", t.style[r] = `${s}px`, t._stickyObserver.observe(t));
}
function o(t) {
  t.classList.remove("is-sticky"), t._stickyObserver && (t._stickyObserver.unobserve(t), t._stickyObserver.disconnect(), t._stickyObserver = void 0);
}
function u(t = []) {
  t.forEach((r) => {
    r.target.classList.toggle("is-sticky", !r.isIntersecting);
  });
}
const v = {
  mounted(t, r) {
    i({
      element: t,
      position: r.arg,
      offset: r.value
    });
  },
  unmounted(t) {
    o(t);
  },
  updated(t, r) {
    o(t), i({
      element: t,
      position: r.arg,
      offset: r.value
    });
  }
};
export {
  v as default
};
//# sourceMappingURL=sticky.js.map
