import { defineComponent as C, computed as u, ref as E, createElementBlock as S, createCommentVNode as o, openBlock as s, createVNode as l, createElementVNode as p, unref as r, withCtx as c, createBlock as i, normalizeClass as k, toDisplayString as q } from "vue";
import { Disclosure as D, DisclosureButton as P, DisclosurePanel as V } from "@headlessui/vue";
import { ScalarMarkdown as I } from "@scalar/components";
import { ScalarIconCaretRight as j } from "@scalar/icons";
import { isDefined as N } from "@scalar/oas-utils/helpers";
import T from "./ContentTypeSelect.vue.js";
import z from "./ParameterHeaders.vue.js";
import O from "../../../components/Content/Schema/SchemaProperty.vue.js";
const H = {
  key: 0,
  class: "parameter-item group/parameter-item relative"
}, L = { class: "parameter-item-name" }, M = { class: "parameter-item-type" }, R = { class: "absolute top-3 right-0 opacity-0 group-focus-within/parameter-item:opacity-100 group-hover/parameter-item:opacity-100" }, W = /* @__PURE__ */ C({
  __name: "ParameterListItem",
  props: {
    parameter: {},
    showChildren: { type: Boolean, default: !1 },
    collapsableItems: { type: Boolean, default: !1 },
    withExamples: { type: Boolean, default: !0 },
    schemas: {},
    breadcrumb: {}
  },
  setup(w) {
    const a = w, g = u(() => a.parameter.content ? Object.keys(a.parameter.content) : []), t = E(g.value[0]);
    a.parameter.content && "application/json" in a.parameter.content && (t.value = "application/json");
    const m = u(() => !!(a.collapsableItems && (a.parameter.content || a.parameter.headers || a.parameter.schema))), B = u(() => a.parameter.readOnly !== !0);
    return (e, d) => B.value ? (s(), S("li", H, [
      l(r(D), null, {
        default: c(({ open: n }) => [
          m.value ? (s(), i(r(P), {
            key: 0,
            class: k(["parameter-item-trigger", { "parameter-item-trigger-open": n }])
          }, {
            default: c(() => [
              p("span", L, [
                l(r(j), {
                  weight: "bold",
                  class: k(["parameter-item-icon size-3 transition-transform duration-100", { "rotate-90": n }])
                }, null, 8, ["class"]),
                p("span", null, q(e.parameter.name), 1)
              ]),
              p("span", M, [
                e.parameter.description ? (s(), i(r(I), {
                  key: 0,
                  class: "markdown",
                  value: e.parameter.description
                }, null, 8, ["value"])) : o("", !0)
              ])
            ]),
            _: 2
          }, 1032, ["class"])) : o("", !0),
          l(r(V), {
            class: "parameter-item-container parameter-item-container-markdown",
            static: !m.value
          }, {
            default: c(() => {
              var f, h, y, b, v;
              return [
                e.parameter.headers ? (s(), i(z, {
                  key: 0,
                  breadcrumb: e.breadcrumb,
                  headers: e.parameter.headers
                }, null, 8, ["breadcrumb", "headers"])) : o("", !0),
                l(r(O), {
                  is: "div",
                  compact: "",
                  breadcrumb: e.breadcrumb,
                  description: m.value ? "" : e.parameter.description,
                  name: m.value ? "" : e.parameter.name,
                  noncollapsible: !0,
                  required: e.parameter.required,
                  schemas: e.schemas,
                  value: {
                    ...e.parameter.content ? (h = (f = e.parameter.content) == null ? void 0 : f[t.value]) == null ? void 0 : h.schema : e.parameter.schema,
                    deprecated: e.parameter.deprecated,
                    ...r(N)(e.parameter.example) && { example: e.parameter.example },
                    examples: e.parameter.content ? {
                      ...e.parameter.examples,
                      ...(b = (y = e.parameter.content) == null ? void 0 : y[t.value]) == null ? void 0 : b.examples
                    } : e.parameter.examples || ((v = e.parameter.schema) == null ? void 0 : v.examples)
                  },
                  withExamples: e.withExamples
                }, null, 8, ["breadcrumb", "description", "name", "required", "schemas", "value", "withExamples"])
              ];
            }),
            _: 1
          }, 8, ["static"])
        ]),
        _: 1
      }),
      p("div", R, [
        m.value && a.parameter.content ? (s(), i(T, {
          key: 0,
          class: "parameter-item-content-type",
          defaultValue: t.value,
          requestBody: a.parameter,
          onSelectContentType: d[0] || (d[0] = ({ contentType: n }) => t.value = n)
        }, null, 8, ["defaultValue", "requestBody"])) : o("", !0)
      ])
    ])) : o("", !0);
  }
});
export {
  W as default
};
