import { g } from './SvgIcon-BAPcdaJk.mjs';
import { useSSRContext, ref, watch, resolveComponent, mergeProps, withCtx, createVNode, openBlock, createBlock, toDisplayString, createCommentVNode, unref, isRef, Transition, Fragment, renderList } from 'vue';
import { ssrRenderComponent, ssrInterpolate, ssrRenderList, ssrRenderClass } from 'vue/server-renderer';
import { Listbox, ListboxButton, ListboxOptions, ListboxOption } from '@headlessui/vue';
import { j as Fv } from './server.mjs';

const S = { __name: "BaseSelectInput", __ssrInlineRender: true, props: { items: { type: Array, required: false, default: () => [] }, name: { type: String, required: true }, label: { type: String, required: false }, placeholder: { type: String, required: false }, value: { type: Object, required: false }, rounded: { type: Boolean, required: false } }, emits: ["update:value"], setup(l2, { expose: S2, emit: q2 }) {
  const C = l2, I = Fv(C.name), j = ref(null);
  watch(() => j.value, (e2, l3) => {
    e2 ? (I.setValue(e2), B("update:value", e2)) : e2 != l3 && (I.setValue(null), B("update:value", undefined));
  }, { deep: true, immediate: true }), watch(() => C.value, (e2, l3) => {
    e2 ? (j.value = e2, I.setValue(e2)) : e2 != l3 && (j.value = null, I.setValue(null));
  }, { deep: true, immediate: true });
  S2({ emptyInput: () => {
    j.value = null;
  } });
  const B = q2;
  return (a2, n2, w2, S3) => {
    const q3 = resolveComponent("VeeField"), C2 = g, I2 = resolveComponent("VeeErrorMessage");
    n2(ssrRenderComponent(q3, mergeProps({ name: l2.name }, S3), { default: withCtx(({ field: e2, meta: a3 }, n3, t2, s2) => {
      if (!n3) return [createVNode("div", { class: "input-wrapper" }, [l2.label ? (openBlock(), createBlock("label", { key: 0, for: "label" }, toDisplayString(l2.label), 1)) : createCommentVNode("", true), createVNode("div", { class: "relative" }, [createVNode(unref(Listbox), { modelValue: unref(j), "onUpdate:modelValue": (e3) => isRef(j) ? j.value = e3 : null }, { default: withCtx(() => [createVNode(unref(ListboxButton), { class: l2.rounded ? "!rounded-full !px-6" : "" }, { default: withCtx(() => {
        var e3, a4, n4, t3;
        return [l2.placeholder && !(null == (e3 = unref(j)) ? undefined : e3.name) ? (openBlock(), createBlock("span", { key: 0, class: "text-desc" }, toDisplayString(l2.placeholder), 1)) : createCommentVNode("", true), (null == (a4 = unref(j)) ? undefined : a4.name) ? (openBlock(), createBlock("span", { key: 1 }, toDisplayString(null == (n4 = unref(j)) ? undefined : n4.name), 1)) : createCommentVNode("", true), createVNode("span", { class: "absolute top-[48%] -translate-y-1/2 end-5" }, [createVNode(C2, { name: "chevron-down" })]), unref(j) && (null == (t3 = unref(j)) ? undefined : t3.id) ? (openBlock(), createBlock("button", { key: 2, onClick: (e4) => {
          e4.stopPropagation(), j.value = null;
        }, class: "absolute top-1/2 -translate-y-1/2 end-10" }, [createVNode(C2, { name: "close-2", class: "text-desc scale-[0.6]" })], 8, ["onClick"])) : createCommentVNode("", true)];
      }), _: 1 }, 8, ["class"]), createVNode(Transition, { name: "fade" }, { default: withCtx(() => [createVNode(unref(ListboxOptions), null, { default: withCtx(() => [(openBlock(true), createBlock(Fragment, null, renderList(l2.items, (e3) => (openBlock(), createBlock(unref(ListboxOption), { as: "template", key: e3.id, value: e3 }, { default: withCtx(({ active: l3, selected: a4 }) => [createVNode("li", { class: [l3 && "bg-primary bg-opacity-20 rounded-lg", a4 && "bg-primary bg-opacity-20 rounded-lg"] }, toDisplayString(null == e3 ? undefined : e3.name), 3)]), _: 2 }, 1032, ["value"]))), 128))]), _: 1 })]), _: 1 })]), _: 1 }, 8, ["modelValue", "onUpdate:modelValue"])])]), createVNode(I2, { class: "text-sm text-red-500", name: l2.name }, null, 8, ["name"])];
      n3(`<div class="input-wrapper"${s2}>`), l2.label ? n3(`<label for="label"${s2}>${ssrInterpolate(l2.label)}</label>`) : n3("<!---->"), n3(`<div class="relative"${s2}>`), n3(ssrRenderComponent(unref(Listbox), { modelValue: unref(j), "onUpdate:modelValue": (e3) => isRef(j) ? j.value = e3 : null }, { default: withCtx((e3, a4, n4, t3) => {
        if (!a4) return [createVNode(unref(ListboxButton), { class: l2.rounded ? "!rounded-full !px-6" : "" }, { default: withCtx(() => {
          var e4, a5, n5, t4;
          return [l2.placeholder && !(null == (e4 = unref(j)) ? undefined : e4.name) ? (openBlock(), createBlock("span", { key: 0, class: "text-desc" }, toDisplayString(l2.placeholder), 1)) : createCommentVNode("", true), (null == (a5 = unref(j)) ? undefined : a5.name) ? (openBlock(), createBlock("span", { key: 1 }, toDisplayString(null == (n5 = unref(j)) ? undefined : n5.name), 1)) : createCommentVNode("", true), createVNode("span", { class: "absolute top-[48%] -translate-y-1/2 end-5" }, [createVNode(C2, { name: "chevron-down" })]), unref(j) && (null == (t4 = unref(j)) ? undefined : t4.id) ? (openBlock(), createBlock("button", { key: 2, onClick: (e5) => {
            e5.stopPropagation(), j.value = null;
          }, class: "absolute top-1/2 -translate-y-1/2 end-10" }, [createVNode(C2, { name: "close-2", class: "text-desc scale-[0.6]" })], 8, ["onClick"])) : createCommentVNode("", true)];
        }), _: 1 }, 8, ["class"]), createVNode(Transition, { name: "fade" }, { default: withCtx(() => [createVNode(unref(ListboxOptions), null, { default: withCtx(() => [(openBlock(true), createBlock(Fragment, null, renderList(l2.items, (e4) => (openBlock(), createBlock(unref(ListboxOption), { as: "template", key: e4.id, value: e4 }, { default: withCtx(({ active: l3, selected: a5 }) => [createVNode("li", { class: [l3 && "bg-primary bg-opacity-20 rounded-lg", a5 && "bg-primary bg-opacity-20 rounded-lg"] }, toDisplayString(null == e4 ? undefined : e4.name), 3)]), _: 2 }, 1032, ["value"]))), 128))]), _: 1 })]), _: 1 })];
        a4(ssrRenderComponent(unref(ListboxButton), { class: l2.rounded ? "!rounded-full !px-6" : "" }, { default: withCtx((e4, a5, n5, t4) => {
          var s3, d2, o2, v2, y2, b2, x2, _2;
          if (!a5) return [l2.placeholder && !(null == (y2 = unref(j)) ? undefined : y2.name) ? (openBlock(), createBlock("span", { key: 0, class: "text-desc" }, toDisplayString(l2.placeholder), 1)) : createCommentVNode("", true), (null == (b2 = unref(j)) ? undefined : b2.name) ? (openBlock(), createBlock("span", { key: 1 }, toDisplayString(null == (x2 = unref(j)) ? undefined : x2.name), 1)) : createCommentVNode("", true), createVNode("span", { class: "absolute top-[48%] -translate-y-1/2 end-5" }, [createVNode(C2, { name: "chevron-down" })]), unref(j) && (null == (_2 = unref(j)) ? undefined : _2.id) ? (openBlock(), createBlock("button", { key: 2, onClick: (e5) => {
            e5.stopPropagation(), j.value = null;
          }, class: "absolute top-1/2 -translate-y-1/2 end-10" }, [createVNode(C2, { name: "close-2", class: "text-desc scale-[0.6]" })], 8, ["onClick"])) : createCommentVNode("", true)];
          l2.placeholder && !(null == (s3 = unref(j)) ? undefined : s3.name) ? a5(`<span class="text-desc"${t4}>${ssrInterpolate(l2.placeholder)}</span>`) : a5("<!---->"), (null == (d2 = unref(j)) ? undefined : d2.name) ? a5(`<span${t4}>${ssrInterpolate(null == (o2 = unref(j)) ? undefined : o2.name)}</span>`) : a5("<!---->"), a5(`<span class="absolute top-[48%] -translate-y-1/2 end-5"${t4}>`), a5(ssrRenderComponent(C2, { name: "chevron-down" }, null, n5, t4)), a5("</span>"), unref(j) && (null == (v2 = unref(j)) ? undefined : v2.id) ? (a5(`<button class="absolute top-1/2 -translate-y-1/2 end-10"${t4}>`), a5(ssrRenderComponent(C2, { name: "close-2", class: "text-desc scale-[0.6]" }, null, n5, t4)), a5("</button>")) : a5("<!---->");
        }), _: 2 }, n4, t3)), a4(""), a4(ssrRenderComponent(unref(ListboxOptions), null, { default: withCtx((e4, a5, n5, t4) => {
          if (!a5) return [(openBlock(true), createBlock(Fragment, null, renderList(l2.items, (e5) => (openBlock(), createBlock(unref(ListboxOption), { as: "template", key: e5.id, value: e5 }, { default: withCtx(({ active: l3, selected: a6 }) => [createVNode("li", { class: [l3 && "bg-primary bg-opacity-20 rounded-lg", a6 && "bg-primary bg-opacity-20 rounded-lg"] }, toDisplayString(null == e5 ? undefined : e5.name), 3)]), _: 2 }, 1032, ["value"]))), 128))];
          a5("<!--[-->"), ssrRenderList(l2.items, (e5) => {
            a5(ssrRenderComponent(unref(ListboxOption), { as: "template", key: e5.id, value: e5 }, { default: withCtx(({ active: l3, selected: a6 }, n6, t5, s3) => {
              if (!n6) return [createVNode("li", { class: [l3 && "bg-primary bg-opacity-20 rounded-lg", a6 && "bg-primary bg-opacity-20 rounded-lg"] }, toDisplayString(null == e5 ? undefined : e5.name), 3)];
              n6(`<li class="${ssrRenderClass([l3 && "bg-primary bg-opacity-20 rounded-lg", a6 && "bg-primary bg-opacity-20 rounded-lg"])}"${s3}>${ssrInterpolate(null == e5 ? undefined : e5.name)}</li>`);
            }), _: 2 }, n5, t4));
          }), a5("<!--]-->");
        }), _: 2 }, n4, t3));
      }), _: 2 }, t2, s2)), n3("</div></div>"), n3(ssrRenderComponent(I2, { class: "text-sm text-red-500", name: l2.name }, null, t2, s2));
    }), _: 1 }, w2));
  };
} }, q = S.setup;
S.setup = (e2, a2) => {
  const n2 = useSSRContext();
  return (n2.modules || (n2.modules = /* @__PURE__ */ new Set())).add("components/Inputs/BaseSelectInput.vue"), q ? q(e2, a2) : undefined;
};

export { S };
//# sourceMappingURL=BaseSelectInput-Bdk72h6q.mjs.map
