import { defineComponent as S, computed as r, ref as B, createBlock as V, createElementBlock as g, openBlock as p, unref as n, withCtx as s, createVNode as c, normalizeClass as m, createElementVNode as f, createTextVNode as _, toDisplayString as y } from "vue";
import { cva as k, ScalarListbox as w, ScalarButton as h } from "@scalar/components";
import { ScalarIconCaretDown as q } from "@scalar/icons";
import N from "../../../components/ScreenReader.vue.js";
const j = /* @__PURE__ */ S({
  __name: "ContentTypeSelect",
  props: {
    requestBody: {},
    defaultValue: {}
  },
  emits: ["selectContentType"],
  setup(v, { emit: x }) {
    const t = v, b = x, C = (e) => {
      e != null && e.id && b("selectContentType", { contentType: e.id });
    }, a = r(() => {
      var e;
      return (e = t.requestBody) != null && e.content ? Object.keys(t.requestBody.content) : [];
    }), o = B(
      t.defaultValue || a.value[0]
    ), d = r({
      get: () => u.value.find((e) => e.id === o.value),
      set: (e) => {
        e && (o.value = e.id);
      }
    }), u = r(() => a.value.map((e) => ({
      id: e,
      label: e
    }))), i = k({
      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, l) => t != null && t.requestBody && a.value.length > 1 ? (p(), V(n(w), {
      key: 0,
      modelValue: d.value,
      "onUpdate:modelValue": [
        l[0] || (l[0] = (T) => d.value = T),
        C
      ],
      options: u.value,
      placement: "bottom-end"
    }, {
      default: s(() => [
        c(n(h), {
          class: m(["h-fit", n(i)({ dropdown: !0 })]),
          variant: "ghost"
        }, {
          default: s(() => [
            c(N, null, {
              default: s(() => l[1] || (l[1] = [
                _("Selected Content Type:")
              ])),
              _: 1,
              __: [1]
            }),
            f("span", null, y(o.value), 1),
            c(n(q), {
              weight: "bold",
              class: "ui-open:rotate-180 size-2.75 transition-transform duration-100"
            })
          ]),
          _: 1
        }, 8, ["class"])
      ]),
      _: 1
    }, 8, ["modelValue", "options"])) : (p(), g("div", {
      key: 1,
      class: m([n(i)({ dropdown: !1 }), "selected-content-type"]),
      tabindex: "0"
    }, [
      f("span", null, y(o.value), 1)
    ], 2));
  }
});
export {
  j as default
};
