import { ref as C } from "vue";
function N({
  activeChannelType: g,
  showSubMenu: n,
  frozenAttribute: o,
  hoveredAttribute: b,
  hasMultipleChannels: h,
  isAttributeBlocked: M
}) {
  const t = C(0);
  return {
    subMenuTop: t,
    handleAttributeMouseEnter: (e, l) => {
      const u = g.value;
      return !u || !h(u) || M(e) ? null : (b.value = e, n.value = !0, o.value = e, l);
    },
    handleAttributeMouseLeave: () => {
      n.value || (o.value = null);
    },
    keepSubMenuOpen: () => {
      n.value = !0;
    },
    closeSubMenu: () => {
      n.value = !1, o.value = null;
    },
    alignSubMenuWithTarget: (e, l) => {
      var u, r, s;
      if (!l) {
        t.value = 0;
        return;
      }
      try {
        const i = (u = e.value) == null ? void 0 : u.querySelector(".attributes-menu"), a = (r = e.value) == null ? void 0 : r.querySelector(".sub-menu-header"), v = (s = e.value) == null ? void 0 : s.querySelector(".sub-menu");
        if (!i) {
          t.value = 0;
          return;
        }
        const S = i.getBoundingClientRect(), y = l.getBoundingClientRect();
        let m = 0;
        if (a) {
          const c = a.getBoundingClientRect(), f = getComputedStyle(a), p = parseFloat(f.marginBottom || "0");
          m = c.height + (Number.isNaN(p) ? 0 : p);
        }
        let d = 0;
        if (v) {
          const c = getComputedStyle(v);
          d = parseFloat(c.paddingTop || "0") || 0;
        }
        t.value = y.top - S.top - m - d - 2;
      } catch {
        t.value = 0;
      }
    }
  };
}
export {
  N as useCommunicationSubMenu
};
