import { defineComponent as B, ref as R, computed as m, toRef as p, createBlock as n, openBlock as o, createSlots as V, withCtx as d, createElementBlock as _, createCommentVNode as r, createElementVNode as v, toDisplayString as y, unref as t, createTextVNode as h, createVNode as b } from "vue";
import C from "../../../components/ViewLayout/ViewLayoutCollapse.vue.js";
import { useResponseBody as N } from "../../../hooks/useResponseBody.js";
import T from "./ResponseBodyDownload.vue.js";
import $ from "./ResponseBodyInfo.vue.js";
import E from "./ResponseBodyPreview.vue.js";
import P from "./ResponseBodyRaw.vue.js";
import S from "./ResponseBodyToggle.vue.js";
import { getMediaTypeConfig as U } from "../consts/mediaTypes.js";
const j = {
  key: 0,
  class: "bg-b-1 flex max-h-[calc(100%-32px)] flex-col overflow-hidden"
}, D = { class: "box-content flex min-h-8 items-center justify-between border-y px-3" }, F = { class: "text-xxs font-code leading-5" }, O = /* @__PURE__ */ B({
  __name: "ResponseBody",
  props: {
    title: {},
    layout: {},
    data: {},
    headers: {}
  },
  setup(a) {
    const f = a, s = R(!0), c = m(
      () => !!(e.value?.raw && e.value.preview)
    ), w = m(() => s.value || !c.value), g = m(() => !s.value || !c.value), { mimeType: i, attachmentFilename: x, dataUrl: l } = N({
      data: p(f, "data"),
      headers: p(f, "headers")
    }), e = m(() => U(i.value.essence));
    return (I, u) => (o(), n(C, {
      class: "max-h-content overflow-y-hidden",
      layout: a.layout
    }, V({
      title: d(() => [
        h(y(a.title), 1)
      ]),
      default: d(() => [
        a.data ? (o(), _("div", j, [
          v("div", D, [
            v("span", F, y(t(i).essence), 1),
            c.value ? (o(), n(S, {
              key: 0,
              modelValue: s.value,
              "onUpdate:modelValue": u[0] || (u[0] = (k) => s.value = k)
            }, null, 8, ["modelValue"])) : r("", !0)
          ]),
          e.value?.raw && g.value ? (o(), n(P, {
            key: t(l),
            content: a.data,
            language: e.value.language
          }, null, 8, ["content", "language"])) : r("", !0),
          e.value?.preview && w.value ? (o(), n(E, {
            key: t(l),
            alpha: e.value.alpha,
            mode: e.value.preview,
            src: t(l),
            type: t(i).essence
          }, null, 8, ["alpha", "mode", "src", "type"])) : r("", !0),
          !e.value?.raw && !e.value?.preview ? (o(), n($, { key: 2 }, {
            default: d(() => [...u[1] || (u[1] = [
              h(" Binary file ", -1)
            ])]),
            _: 1
          })) : r("", !0)
        ])) : r("", !0)
      ]),
      _: 2
    }, [
      a.data && t(l) ? {
        name: "actions",
        fn: d(() => [
          b(T, {
            filename: t(x),
            href: t(l),
            type: t(i).essence
          }, null, 8, ["filename", "href", "type"])
        ]),
        key: "0"
      } : void 0
    ]), 1032, ["layout"]));
  }
});
export {
  O as default
};
