import { defineComponent as I, useTemplateRef as L, computed as c, createBlock as u, openBlock as o, unref as O, withCtx as f, createElementBlock as s, createCommentVNode as m, Fragment as a, renderList as p, normalizeClass as h, createVNode as g, createElementVNode as k, createTextVNode as V, toDisplayString as $, withModifiers as y } from "vue";
import z from "../DropdownListItem.vue.js";
import w from "../../utils/DropdownOverlay/DropdownOverlay.vue.js";
import _ from "../../utils/TextLabel.vue.js";
const B = {
  key: 1,
  class: "nothing-found"
}, M = /* @__PURE__ */ I({
  __name: "OptionList",
  props: {
    rootRef: {},
    groups: {},
    rest: {},
    optionSize: {},
    selectOption: { type: Function }
  },
  setup(C, { expose: S }) {
    const r = C, l = L("overlay"), A = c(() => {
      var e;
      return (e = l.value) == null ? void 0 : e.listRef;
    }), d = c(() => r.groups.size > 0), N = c(() => {
      let e = 0;
      for (const v of r.groups.values())
        e += v.length;
      return e + r.rest.length;
    });
    return S({
      scrollIntoActive: () => {
        var e;
        (e = l.value) == null || e.scrollIntoActive();
      },
      listRef: A
    }), (e, v) => (o(), u(O(w), {
      ref_key: "overlay",
      ref: l,
      root: e.rootRef,
      class: "pl-dropdown__options",
      tabindex: "-1",
      gap: 3
    }, {
      default: f(() => [
        (o(!0), s(a, null, p(e.groups.entries(), ([t, i]) => (o(), s("div", {
          key: t,
          class: h({ "group-container": d.value })
        }, [
          g(_, null, {
            default: f(() => [
              V($(t), 1)
            ]),
            _: 2
          }, 1024),
          k("div", null, [
            (o(!0), s(a, null, p(i, (n, R) => (o(), u(z, {
              key: R,
              option: n,
              "is-selected": n.isSelected,
              "is-hovered": n.isActive,
              size: e.optionSize,
              onClick: y((b) => e.selectOption(n.value), ["stop"])
            }, null, 8, ["option", "is-selected", "is-hovered", "size", "onClick"]))), 128))
          ])
        ], 2))), 128)),
        e.rest.length ? (o(), s("div", {
          key: 0,
          class: h({ "group-container": d.value })
        }, [
          g(_),
          k("div", null, [
            (o(!0), s(a, null, p(e.rest, (t, i) => (o(), u(z, {
              key: i,
              option: t,
              "is-selected": t.isSelected,
              "is-hovered": t.isActive,
              size: e.optionSize,
              onClick: y((n) => e.selectOption(t.value), ["stop"])
            }, null, 8, ["option", "is-selected", "is-hovered", "size", "onClick"]))), 128))
          ])
        ], 2)) : m("", !0),
        N.value ? m("", !0) : (o(), s("div", B, "Nothing found"))
      ]),
      _: 1
    }, 8, ["root"]));
  }
});
export {
  M as default
};
//# sourceMappingURL=OptionList.vue.js.map
