import { defineComponent as B, ref as S, computed as v, openBlock as t, createBlock as r, unref as s, withCtx as c, createVNode as b, createElementBlock as x, createCommentVNode as f, createTextVNode as g, withDirectives as M, createElementVNode as w, vModelCheckbox as N, Fragment as R, renderList as F, toDisplayString as O, pushScopeId as P, popScopeId as A } from "vue";
import { ScalarIcon as D, ScalarCodeBlock as U, ScalarMarkdown as H } from "@scalar/components";
import { normalizeMimeTypeObject as J } from "@scalar/oas-utils/helpers";
import K from "../ExamplePicker.vue.js";
import T from "./ExampleResponse.vue.js";
import L from "../../../Card/Card.vue.js";
import W from "../../../Card/CardTabHeader.vue.js";
import q from "../../../Card/CardTab.vue.js";
import G from "../../../Card/CardContent.vue.js";
import Q from "../../../Card/CardFooter.vue.js";
import { useClipboard as X } from "../../../../hooks/useClipboard.js";
const Y = (u) => (P("data-v-357c6dd1"), u = u(), A(), u), Z = {
  key: 1,
  class: "scalar-card-checkbox"
}, $ = /* @__PURE__ */ Y(() => /* @__PURE__ */ w("span", { class: "scalar-card-checkbox-checkmark" }, null, -1)), z = { class: "scalar-card-container custom-scroll" }, ee = {
  key: 1,
  class: "response-description"
}, ie = /* @__PURE__ */ B({
  __name: "PathResponses",
  props: {
    operation: {}
  },
  setup(u) {
    const k = u, { copyToClipboard: V } = X(), p = S(), C = v(
      () => {
        var e, a;
        return Object.keys(((a = (e = k == null ? void 0 : k.operation) == null ? void 0 : e.information) == null ? void 0 : a.responses) ?? {}).sort();
      }
    ), y = v(
      () => !!o.value.examples
    ), E = S(0), m = v(() => {
      var a, i;
      const e = C.value[E.value];
      return (i = (a = k.operation.information) == null ? void 0 : a.responses) == null ? void 0 : i[e];
    }), o = v(() => {
      var a;
      const e = J(
        (a = m.value) == null ? void 0 : a.content
      );
      return (
        // OpenAPI 3.x
        (e == null ? void 0 : e["application/json"]) ?? (e == null ? void 0 : e["text/plain"]) ?? // Swagger 2.0
        m.value
      );
    }), j = () => {
      if (y.value) {
        if (Array.isArray(o.value.examples))
          return o.value.examples[0];
        {
          const e = Object.keys(o.value.examples)[0];
          return o.value.examples[e];
        }
      } else return o.value.example;
    }, h = v(() => ({
      ...o.value,
      example: y.value && p.value ? o.value.examples[p.value].value ?? o.value.examples[p.value] : j()
    })), I = (e) => {
      E.value = e, p.value = void 0;
    }, _ = S(!1);
    return (e, a) => C.value.length ? (t(), r(s(L), { key: 0 }, {
      default: c(() => {
        var i;
        return [
          b(s(W), {
            muted: "",
            x: "as",
            onChange: I
          }, {
            actions: c(() => {
              var l, d;
              return [
                (l = o.value) != null && l.example ? (t(), x("button", {
                  key: 0,
                  class: "code-copy",
                  type: "button",
                  onClick: a[0] || (a[0] = () => {
                    var n;
                    return s(V)((n = o.value) == null ? void 0 : n.example);
                  })
                }, [
                  b(s(D), {
                    icon: "Clipboard",
                    width: "10px",
                    x: "asd"
                  })
                ])) : f("", !0),
                (d = o.value) != null && d.schema ? (t(), x("label", Z, [
                  g(" Show Schema "),
                  M(w("input", {
                    "onUpdate:modelValue": a[1] || (a[1] = (n) => _.value = n),
                    class: "scalar-card-checkbox-input",
                    type: "checkbox"
                  }, null, 512), [
                    [N, _.value]
                  ]),
                  $
                ])) : f("", !0)
              ];
            }),
            default: c(() => [
              (t(!0), x(R, null, F(C.value, (l) => (t(), r(s(q), { key: l }, {
                default: c(() => [
                  g(O(l), 1)
                ]),
                _: 2
              }, 1024))), 128))
            ]),
            _: 1
          }),
          w("div", z, [
            b(s(G), { muted: "" }, {
              default: c(() => {
                var l;
                return [
                  (l = o.value) != null && l.schema ? (t(), x(R, { key: 0 }, [
                    _.value && h.value ? (t(), r(s(U), {
                      key: 0,
                      content: h.value,
                      lang: "json"
                    }, null, 8, ["content"])) : (t(), r(T, {
                      key: 1,
                      response: h.value
                    }, null, 8, ["response"]))
                  ], 64)) : (t(), r(T, {
                    key: 1,
                    response: h.value
                  }, null, 8, ["response"]))
                ];
              }),
              _: 1
            })
          ]),
          (i = m.value) != null && i.description || y.value ? (t(), r(s(Q), {
            key: 0,
            class: "response-card-footer",
            muted: ""
          }, {
            default: c(() => {
              var l, d;
              return [
                y.value ? (t(), r(K, {
                  key: 0,
                  class: "response-example-selector",
                  examples: (l = o.value) == null ? void 0 : l.examples,
                  "onUpdate:modelValue": a[2] || (a[2] = (n) => p.value = n)
                }, null, 8, ["examples"])) : (d = m.value) != null && d.description ? (t(), x("div", ee, [
                  b(s(H), {
                    class: "markdown",
                    value: m.value.description
                  }, null, 8, ["value"])
                ])) : f("", !0)
              ];
            }),
            _: 1
          })) : f("", !0)
        ];
      }),
      _: 1
    })) : f("", !0);
  }
});
export {
  ie as default
};
