import { defineComponent as V, computed as E, openBlock as a, createBlock as i, unref as r, withCtx as d, createElementVNode as j, normalizeClass as v, createElementBlock as s, createCommentVNode as o, withDirectives as w, createVNode as u, createTextVNode as h, toDisplayString as f, vShow as z, normalizeStyle as T, Fragment as t, renderList as A } from "vue";
import { Disclosure as $, DisclosureButton as D, DisclosurePanel as F } from "@headlessui/vue";
import { ScalarMarkdown as I, ScalarIcon as g } from "@scalar/components";
import q from "../../ScreenReader.vue.js";
import L from "./SchemaHeading.vue.js";
import y from "./SchemaProperty.vue.js";
const M = {
  key: 0,
  class: "schema-card-description"
}, R = {
  key: 0,
  class: "schema-properties"
}, X = /* @__PURE__ */ V({
  __name: "Schema",
  props: {
    value: { type: [Object, Boolean] },
    level: { default: 0 },
    name: {},
    compact: { type: Boolean },
    noncollapsible: { type: Boolean, default: !1 },
    hideHeading: { type: Boolean },
    additionalProperties: { type: Boolean },
    schemas: {}
  },
  setup(N) {
    const k = N, b = E(() => !(k.noncollapsible || k.level === 0)), H = (e) => k.noncollapsible && e.stopPropagation();
    return (e, P) => typeof e.value == "object" && Object.keys(e.value).length ? (a(), i(r($), {
      key: 0,
      defaultOpen: e.noncollapsible
    }, {
      default: d(({ open: n }) => {
        var S;
        return [
          j("div", {
            class: v(["schema-card", [
              `schema-card--level-${e.level}`,
              { "schema-card--compact": e.compact, "schema-card--open": n },
              { "border-t-1/2": e.additionalProperties && n }
            ]])
          }, [
            (S = e.value) != null && S.description && typeof e.value.description == "string" && !e.value.allOf && !e.value.oneOf && !e.value.anyOf && !e.compact ? (a(), s("div", M, [
              e.value.enum ? o("", !0) : (a(), i(r(I), {
                key: 0,
                value: e.value.description
              }, null, 8, ["value"]))
            ])) : o("", !0),
            j("div", {
              class: v(["schema-properties", {
                "schema-properties-open": n
              }])
            }, [
              e.additionalProperties ? w((a(), s("div", R, [
                u(r(D), {
                  as: "button",
                  class: "schema-card-title schema-card-title--compact",
                  onClickCapture: H
                }, {
                  default: d(() => [
                    u(r(g), {
                      class: "schema-card-title-icon",
                      icon: "Add",
                      size: "sm"
                    }),
                    P[0] || (P[0] = h(" Show additional properties ")),
                    e.name ? (a(), i(q, { key: 0 }, {
                      default: d(() => [
                        h("for " + f(e.name), 1)
                      ]),
                      _: 1
                    })) : o("", !0)
                  ]),
                  _: 1
                })
              ], 512)), [
                [z, !n]
              ]) : b.value ? w((a(), i(r(D), {
                key: 1,
                as: e.noncollapsible ? "div" : "button",
                class: v(["schema-card-title", { "schema-card-title--compact": e.compact }]),
                style: T({
                  top: `calc(var(--refs-header-height) +  calc(var(--schema-title-height) * ${e.level}))`
                }),
                onClickCapture: H
              }, {
                default: d(() => {
                  var m, c, l;
                  return [
                    e.compact ? (a(), s(t, { key: 0 }, [
                      u(r(g), {
                        class: v(["schema-card-title-icon", { "schema-card-title-icon--open": n }]),
                        icon: "Add",
                        size: "sm"
                      }, null, 8, ["class"]),
                      n ? (a(), s(t, { key: 0 }, [
                        h(" Hide " + f(((m = e.value) == null ? void 0 : m.title) ?? "Child Attributes"), 1)
                      ], 64)) : (a(), s(t, { key: 1 }, [
                        h(" Show " + f(((c = e.value) == null ? void 0 : c.title) ?? "Child Attributes"), 1)
                      ], 64)),
                      e.name ? (a(), i(q, { key: 2 }, {
                        default: d(() => [
                          h("for " + f(e.name), 1)
                        ]),
                        _: 1
                      })) : o("", !0)
                    ], 64)) : (a(), s(t, { key: 1 }, [
                      u(r(g), {
                        class: v(["schema-card-title-icon", { "schema-card-title-icon--open": n }]),
                        icon: "Add",
                        size: "sm"
                      }, null, 8, ["class"]),
                      u(L, {
                        name: ((l = e.value) == null ? void 0 : l.title) ?? e.name,
                        value: e.value
                      }, null, 8, ["name", "value"])
                    ], 64))
                  ];
                }),
                _: 2
              }, 1032, ["as", "class", "style"])), [
                [z, !e.hideHeading && !(e.noncollapsible && e.compact)]
              ]) : o("", !0),
              u(r(F), {
                as: "ul",
                static: !b.value
              }, {
                default: d(() => {
                  var m, c;
                  return [
                    e.value.properties || e.value.additionalProperties || e.value.patternProperties ? (a(), s(t, { key: 0 }, [
                      e.value.properties ? (a(!0), s(t, { key: 0 }, A(Object.keys((m = e.value) == null ? void 0 : m.properties), (l) => {
                        var p, C, O, B;
                        return a(), i(y, {
                          key: l,
                          compact: e.compact,
                          hideHeading: e.hideHeading,
                          level: e.level + 1,
                          name: l,
                          required: ((p = e.value.required) == null ? void 0 : p.includes(l)) || ((O = (C = e.value.properties) == null ? void 0 : C[l]) == null ? void 0 : O.required) === !0,
                          schemas: e.schemas,
                          value: (B = e.value.properties) == null ? void 0 : B[l]
                        }, null, 8, ["compact", "hideHeading", "level", "name", "required", "schemas", "value"]);
                      }), 128)) : o("", !0),
                      e.value.patternProperties ? (a(!0), s(t, { key: 1 }, A(Object.keys((c = e.value) == null ? void 0 : c.patternProperties), (l) => {
                        var p;
                        return a(), i(y, {
                          key: l,
                          compact: e.compact,
                          hideHeading: e.hideHeading,
                          level: e.level,
                          name: l,
                          pattern: "",
                          schemas: e.schemas,
                          value: (p = e.value.patternProperties) == null ? void 0 : p[l]
                        }, null, 8, ["compact", "hideHeading", "level", "name", "schemas", "value"]);
                      }), 128)) : o("", !0),
                      e.value.additionalProperties ? (a(), s(t, { key: 2 }, [
                        e.value.additionalProperties === !0 || Object.keys(e.value.additionalProperties).length === 0 || !e.value.additionalProperties.type ? (a(), i(y, {
                          key: 0,
                          additional: "",
                          compact: e.compact,
                          hideHeading: e.hideHeading,
                          level: e.level,
                          noncollapsible: "",
                          schemas: e.schemas,
                          value: {
                            type: "anything",
                            ...typeof e.value.additionalProperties == "object" ? e.value.additionalProperties : {}
                          }
                        }, null, 8, ["compact", "hideHeading", "level", "schemas", "value"])) : (a(), i(y, {
                          key: 1,
                          additional: "",
                          compact: e.compact,
                          hideHeading: e.hideHeading,
                          level: e.level,
                          noncollapsible: "",
                          schemas: e.schemas,
                          value: e.value.additionalProperties
                        }, null, 8, ["compact", "hideHeading", "level", "schemas", "value"]))
                      ], 64)) : o("", !0)
                    ], 64)) : (a(), i(y, {
                      key: 1,
                      compact: e.compact,
                      hideHeading: e.hideHeading,
                      name: e.value.name,
                      schemas: e.schemas,
                      value: e.value
                    }, null, 8, ["compact", "hideHeading", "name", "schemas", "value"]))
                  ];
                }),
                _: 1
              }, 8, ["static"])
            ], 2)
          ], 2)
        ];
      }),
      _: 1
    }, 8, ["defaultOpen"])) : o("", !0);
  }
});
export {
  X as default
};
