import "vue";
import { useScrollspy } from "../../composables/useScrollspy/index.mjs";
import { o as omit } from "../../../object-hfadz3TY.mjs";
import { g as getDirectiveUid } from "../../../utils-B5CTzwdb.mjs";
const bind = (el, binding) => {
  if (typeof document === "undefined") return;
  const uid = getDirectiveUid(binding);
  const elWithScrollspy = el;
  elWithScrollspy.$__scrollspy = elWithScrollspy.$__scrollspy ?? /* @__PURE__ */ Object.create(null);
  const existingInstance = elWithScrollspy.$__scrollspy[uid];
  if (existingInstance) {
    existingInstance.cleanup();
  }
  const { arg, value } = binding;
  const isObject = typeof value === "object" && value !== null;
  const content = arg ? arg : typeof value === "string" ? value : isObject ? value.content || value.element : null;
  elWithScrollspy.$__scrollspy[uid] = useScrollspy(
    content,
    el,
    isObject ? omit(value, ["content", "element"]) : {}
  );
};
const vBScrollspy = {
  mounted: bind,
  updated: bind,
  beforeUnmount(el, binding) {
    const uid = getDirectiveUid(binding);
    const elWithScrollspy = el;
    const instance = elWithScrollspy.$__scrollspy?.[uid];
    if (!instance) return;
    instance.cleanup();
    delete elWithScrollspy.$__scrollspy[uid];
  }
};
export {
  vBScrollspy
};
//# sourceMappingURL=index.mjs.map
