import { defineComponent as j, computed as O, openBlock as l, createBlock as i, unref as p, withCtx as y, createElementVNode as k, normalizeClass as d, createElementBlock as a, createVNode as v, createCommentVNode as r, withDirectives as D, normalizeStyle as q, Fragment as t, createTextVNode as C, toDisplayString as P, vShow as z, renderList as I, pushScopeId as N, popScopeId as V } from "vue";
import { Disclosure as A, DisclosureButton as E, DisclosurePanel as H } from "@headlessui/vue";
import { ScalarMarkdown as T, ScalarIcon as $ } from "@scalar/components";
import F from "./SchemaHeading.vue.js";
import m from "./SchemaProperty.vue.js";
const L = (s) => (N("data-v-25443e6c"), s = s(), V(), s), M = {
  key: 0,
  class: "schema-card-description"
}, R = /* @__PURE__ */ L(() => /* @__PURE__ */ k("polygon", {
  "fill-rule": "nonzero",
  points: "14 8 8 8 8 14 6 14 6 8 0 8 0 6 6 6 6 0 8 0 8 6 14 6"
}, null, -1)), G = [
  R
], Y = /* @__PURE__ */ j({
  __name: "Schema",
  props: {
    value: { type: [Object, Boolean] },
    level: { default: 0 },
    name: {},
    compact: { type: Boolean },
    noncollapsible: { type: Boolean }
  },
  setup(s) {
    const h = s, f = O(() => !(h.noncollapsible || h.level === 0)), B = (e) => h.noncollapsible && e.stopPropagation();
    return (e, J) => typeof e.value == "object" && Object.keys(e.value).length ? (l(), i(p(A), {
      key: 0,
      defaultOpen: e.noncollapsible
    }, {
      default: y(({ open: n }) => {
        var b;
        return [
          k("div", {
            class: d(["schema-card", [
              `schema-card--level-${e.level}`,
              { "schema-card--compact": e.compact, "schema-card--open": n }
            ]])
          }, [
            (b = e.value) != null && b.description && typeof e.value.description == "string" ? (l(), a("div", M, [
              v(p(T), {
                value: e.value.description
              }, null, 8, ["value"])
            ])) : r("", !0),
            k("div", {
              class: d(["schema-properties", { "schema-properties-open": n }])
            }, [
              D(v(p(E), {
                as: e.noncollapsible ? "div" : "button",
                class: d(["schema-card-title", { "schema-card-title--compact": e.compact }]),
                style: q({
                  top: `calc(var(--refs-header-height) +  calc(var(--schema-title-height) * ${e.level}))`
                }),
                onClickCapture: B
              }, {
                default: y(() => {
                  var c, o, u;
                  return [
                    e.compact ? (l(), a(t, { key: 0 }, [
                      f.value ? (l(), a("svg", {
                        key: 0,
                        class: d(["schema-card-title-icon", { "schema-card-title-icon--open": n }]),
                        fill: "currentColor",
                        height: "14",
                        viewBox: "0 0 14 14",
                        width: "14",
                        xmlns: "http://www.w3.org/2000/svg"
                      }, G, 2)) : r("", !0),
                      n ? (l(), a(t, { key: 1 }, [
                        C(" Hide " + P(((c = e.value) == null ? void 0 : c.title) ?? "Child Attributes"), 1)
                      ], 64)) : (l(), a(t, { key: 2 }, [
                        C(" Show " + P(((o = e.value) == null ? void 0 : o.title) ?? "Child Attributes"), 1)
                      ], 64))
                    ], 64)) : (l(), a(t, { key: 1 }, [
                      f.value ? (l(), i(p($), {
                        key: 0,
                        class: d(["schema-card-title-icon", { "schema-card-title-icon--open": n }]),
                        icon: "ChevronRight",
                        size: "md"
                      }, null, 8, ["class"])) : r("", !0),
                      v(F, {
                        name: ((u = e.value) == null ? void 0 : u.title) ?? e.name,
                        value: e.value
                      }, null, 8, ["name", "value"])
                    ], 64))
                  ];
                }),
                _: 2
              }, 1032, ["as", "class", "style"]), [
                [z, !(e.noncollapsible && e.compact)]
              ]),
              v(p(H), { static: e.noncollapsible }, {
                default: y(() => {
                  var c;
                  return [
                    e.value.properties || e.value.additionalProperties ? (l(), a(t, { key: 0 }, [
                      e.value.properties ? (l(!0), a(t, { key: 0 }, I(Object.keys((c = e.value) == null ? void 0 : c.properties), (o) => {
                        var u, g, w, S;
                        return l(), i(m, {
                          key: o,
                          compact: e.compact,
                          level: e.level,
                          name: o,
                          required: ((u = e.value.required) == null ? void 0 : u.includes(o)) || ((w = (g = e.value.properties) == null ? void 0 : g[o]) == null ? void 0 : w.required) === !0,
                          value: (S = e.value.properties) == null ? void 0 : S[o]
                        }, null, 8, ["compact", "level", "name", "required", "value"]);
                      }), 128)) : r("", !0),
                      e.value.additionalProperties ? (l(), a(t, { key: 1 }, [
                        e.value.additionalProperties === !0 || Object.keys(e.value.additionalProperties).length === 0 || !e.value.additionalProperties.type ? (l(), i(m, {
                          key: 0,
                          additional: "",
                          compact: e.compact,
                          level: e.level,
                          noncollapsible: "",
                          value: {
                            type: "any",
                            ...typeof e.value.additionalProperties == "object" ? e.value.additionalProperties : {}
                          }
                        }, null, 8, ["compact", "level", "value"])) : (l(), i(m, {
                          key: 1,
                          additional: "",
                          compact: e.compact,
                          level: e.level,
                          noncollapsible: "",
                          value: e.value.additionalProperties
                        }, null, 8, ["compact", "level", "value"]))
                      ], 64)) : r("", !0)
                    ], 64)) : (l(), i(m, {
                      key: 1,
                      compact: e.compact,
                      level: e.level,
                      name: e.value.name,
                      value: e.value
                    }, null, 8, ["compact", "level", "name", "value"]))
                  ];
                }),
                _: 1
              }, 8, ["static"])
            ], 2)
          ], 2)
        ];
      }),
      _: 1
    }, 8, ["defaultOpen"])) : r("", !0);
  }
});
export {
  Y as default
};
