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