import { defineComponent as S, computed as s, ref as B, createBlock as V, createElementBlock as k, openBlock as p, unref as n, withCtx as r, createVNode as c, normalizeClass as m, createElementVNode as f, createTextVNode as g, toDisplayString as v } from "vue";
import { cva as h, ScalarListbox as w, ScalarButton as _, ScalarIcon as q } from "@scalar/components";
import N from "../../../components/ScreenReader.vue.js";
const O = /* @__PURE__ */ S({
  __name: "ContentTypeSelect",
  props: {
    requestBody: {},
    defaultValue: {}
  },
  emits: ["selectContentType"],
  setup(y, { emit: x }) {
    const t = y, C = x, T = (e) => {
      e != null && e.id && C("selectContentType", { contentType: e.id });
    }, a = s(() => {
      var e;
      return (e = t.requestBody) != null && e.content ? Object.keys(t.requestBody.content) : [];
    }), l = B(
      t.defaultValue || a.value[0]
    ), u = s({
      get: () => d.value.find((e) => e.id === l.value),
      set: (e) => {
        e && (l.value = e.id);
      }
    }), d = s(() => a.value.map((e) => ({
      id: e,
      label: e
    }))), i = h({
      base: "font-normal text-c-2 bg-b-2 py-0.75 flex cursor-pointer items-center gap-1 rounded-full text-xs",
      variants: {
        dropdown: {
          true: "border hover:text-c-1 pl-2 pr-1.5",
          false: "px-2"
        }
      }
    });
    return (e, o) => t != null && t.requestBody && a.value.length > 1 ? (p(), V(n(w), {
      key: 0,
      modelValue: u.value,
      "onUpdate:modelValue": [
        o[0] || (o[0] = (b) => u.value = b),
        T
      ],
      class: "font-normal",
      options: d.value,
      placement: "bottom-end"
    }, {
      default: r(() => [
        c(n(_), {
          class: m(["h-fit", n(i)({ dropdown: !0 })]),
          variant: "ghost"
        }, {
          default: r(() => [
            c(N, null, {
              default: r(() => o[1] || (o[1] = [
                g("Selected Content Type:")
              ])),
              _: 1
            }),
            f("span", null, v(l.value), 1),
            c(n(q), {
              class: "ui-open:rotate-180 ml-auto",
              icon: "ChevronDown",
              size: "sm",
              thickness: "2"
            })
          ]),
          _: 1
        }, 8, ["class"])
      ]),
      _: 1
    }, 8, ["modelValue", "options"])) : (p(), k("div", {
      key: 1,
      class: m(n(i)({ dropdown: !1 })),
      tabindex: "0"
    }, [
      f("span", null, v(l.value), 1)
    ], 2));
  }
});
export {
  O as default
};
