import { defineComponent as z, computed as m, inject as Z, createBlock as u, openBlock as a, resolveDynamicComponent as L, normalizeClass as X, withCtx as b, createCommentVNode as l, createElementBlock as o, createVNode as d, createSlots as G, unref as y, toDisplayString as f, Fragment as h, createTextVNode as V, renderList as J } from "vue";
import { ScalarMarkdown as D } from "@scalar/components";
import { isTypeObject as K } from "./helpers/is-type-object.js";
import { DISCRIMINATOR_CONTEXT as Q } from "../../../hooks/useDiscriminator.js";
import { optimizeValueForDisplay as W, compositions as Y } from "./helpers/optimize-value-for-display.js";
import H from "./Schema.vue.js";
import C from "./SchemaComposition.vue.js";
import _ from "./SchemaDiscriminator.vue.js";
import x from "./SchemaEnumValues.vue.js";
import ee from "./SchemaPropertyHeading.vue.js";
import re from "../../Anchor/WithBreadcrumb.vue2.js";
import ie from "../../../features/specification-extension/SpecificationExtension.vue.js";
const ae = {
  key: 0,
  class: "property-name-pattern-properties"
}, ne = {
  key: 1,
  class: "property-name-additional-properties"
}, oe = {
  key: 1,
  class: "property-description"
}, te = {
  key: 2,
  class: "property-description"
}, se = {
  key: 3,
  class: "children"
}, me = {
  key: 0,
  class: "children"
}, Ne = /* @__PURE__ */ z({
  __name: "SchemaProperty",
  props: {
    is: {},
    value: {},
    noncollapsible: { type: Boolean },
    level: { default: 0 },
    name: {},
    required: { type: Boolean, default: !1 },
    compact: { type: Boolean, default: !1 },
    description: {},
    withExamples: { type: Boolean, default: !0 },
    hideModelNames: { type: Boolean, default: !1 },
    schemas: {},
    hideHeading: { type: Boolean },
    discriminatorMapping: {},
    discriminatorPropertyName: {},
    isDiscriminator: { type: Boolean },
    variant: {},
    breadcrumb: {}
  },
  emits: ["update:modelValue"],
  setup(T, { emit: R }) {
    const c = T, w = R, k = {
      integer: {
        _default: "Integer numbers.",
        int32: "Signed 32-bit integers (commonly used integer type).",
        int64: "Signed 64-bit integers (long type)."
      },
      string: {
        date: "full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21",
        "date-time": "the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z",
        password: "a hint to UIs to mask the input",
        base64: "base64-encoded characters, for example, U3dhZ2dlciByb2Nrcw==",
        byte: "base64-encoded characters, for example, U3dhZ2dlciByb2Nrcw==",
        binary: "binary data, used to describe files"
      }
    }, g = (e, r) => r != null && r.properties || r != null && r.additionalProperties || r != null && r.patternProperties || r != null && r.allOf ? null : e || (r == null ? void 0 : r.description) || null, N = (e) => !e || !k[e.type] ? null : k[e.type][e.format || e.contentEncoding || "_default"], E = (e) => {
      var r;
      return (e == null ? void 0 : e.enum) || ((r = e == null ? void 0 : e.items) == null ? void 0 : r.enum) || [];
    }, i = m(() => W(c.value)), t = Z(Q, null), n = m(() => {
      var e;
      return c.level > 0 ? i.value : (e = t == null ? void 0 : t.value) != null && e.mergedSchema ? t.value.mergedSchema : i.value;
    }), I = m(() => {
      var e;
      return ((e = t == null ? void 0 : t.value) == null ? void 0 : e.selectedType) || (c.discriminatorMapping ? Object.keys(c.discriminatorMapping)[0] : "");
    }), U = (e, r, p) => r || (e == null ? void 0 : e.deprecated) || (e == null ? void 0 : e.const) !== void 0 || (e == null ? void 0 : e.enum) && e.enum.length === 1 || (e == null ? void 0 : e.type) || (e == null ? void 0 : e.nullable) === !0 || (e == null ? void 0 : e.writeOnly) || (e == null ? void 0 : e.readOnly) || p, v = (e) => {
      w("update:modelValue", e);
    }, P = m(() => {
      const e = i.value;
      if (!(e != null && e.items) || typeof e.items != "object")
        return !1;
      const r = e.items;
      return "type" in r && ["object"].includes(r.type) || "$ref" in r || "discriminator" in r || "allOf" in r || "oneOf" in r || "anyOf" in r;
    }), $ = (e) => {
      const r = i.value;
      return !(r != null && r.items) || typeof r.items != "object" || !(e in r.items) ? !1 : !P.value;
    }, q = m(() => P.value), F = m(() => {
      if (!i.value)
        return !1;
      const e = i.value, r = K(e), p = e.properties || e.additionalProperties;
      return r && p;
    }), A = m(() => c.level <= 1);
    return (e, r) => {
      var p;
      return a(), u(L(e.is ?? "li"), {
        class: X(["property", [
          (g(e.description, i.value), ""),
          `property--level-${e.level}`,
          {
            "property--compact": e.compact,
            "property--deprecated": (p = i.value) == null ? void 0 : p.deprecated
          }
        ]])
      }, {
        default: b(() => {
          var M, S;
          return [
            U(i.value, e.name, e.required) ? (a(), u(ee, {
              key: 0,
              enum: E(i.value).length > 0,
              required: e.required,
              value: i.value,
              schemas: e.schemas,
              hideModelNames: e.hideModelNames,
              class: "group"
            }, G({ _: 2 }, [
              e.name ? {
                name: "name",
                fn: b(() => [
                  d(y(re), {
                    breadcrumb: A.value && e.breadcrumb ? [...e.breadcrumb, e.name] : void 0
                  }, {
                    default: b(() => [
                      e.variant === "patternProperties" ? (a(), o("span", ae, f(e.name), 1)) : e.variant === "additionalProperties" ? (a(), o("span", ne, f(e.name), 1)) : (a(), o(h, { key: 2 }, [
                        V(f(e.name), 1)
                      ], 64))
                    ]),
                    _: 1
                  }, 8, ["breadcrumb"])
                ]),
                key: "0"
              } : void 0,
              (M = i.value) != null && M.example ? {
                name: "example",
                fn: b(() => [
                  V(" Example: " + f(i.value.example), 1)
                ]),
                key: "1"
              } : void 0
            ]), 1032, ["enum", "required", "value", "schemas", "hideModelNames"])) : l("", !0),
            g(e.description, i.value) ? (a(), o("div", oe, [
              d(y(D), {
                value: g(e.description, i.value)
              }, null, 8, ["value"])
            ])) : N(i.value) ? (a(), o("div", te, [
              d(y(D), {
                value: N(i.value) || ""
              }, null, 8, ["value"])
            ])) : l("", !0),
            d(x, { value: i.value }, null, 8, ["value"]),
            F.value ? (a(), o("div", se, [
              d(H, {
                compact: e.compact,
                breadcrumb: e.breadcrumb && e.name ? [...e.breadcrumb, e.name] : void 0,
                level: e.level + 1,
                name: e.name,
                noncollapsible: e.noncollapsible,
                value: n.value,
                resolvedSchema: n.value,
                discriminatorMapping: e.discriminatorMapping,
                discriminatorPropertyName: e.discriminatorPropertyName,
                schemas: e.schemas,
                "onUpdate:modelValue": v
              }, null, 8, ["compact", "breadcrumb", "level", "name", "noncollapsible", "value", "resolvedSchema", "discriminatorMapping", "discriminatorPropertyName", "schemas"])
            ])) : l("", !0),
            (S = i.value) != null && S.items && typeof i.value.items == "object" ? (a(), o(h, { key: 4 }, [
              q.value ? (a(), o("div", me, [
                d(H, {
                  compact: e.compact,
                  level: e.level + 1,
                  name: e.name,
                  noncollapsible: e.noncollapsible,
                  value: n.value && typeof n.value == "object" && "items" in n.value ? n.value.items : i.value.items,
                  resolvedSchema: n.value && typeof n.value == "object" && "items" in n.value ? n.value.items : i.value.items,
                  discriminatorMapping: e.discriminatorMapping,
                  discriminatorPropertyName: e.discriminatorPropertyName,
                  schemas: e.schemas,
                  "onUpdate:modelValue": v
                }, null, 8, ["compact", "level", "name", "noncollapsible", "value", "resolvedSchema", "discriminatorMapping", "discriminatorPropertyName", "schemas"])
              ])) : l("", !0)
            ], 64)) : l("", !0),
            (a(!0), o(h, null, J(y(Y), (s) => {
              var O, j, B;
              return a(), o(h, { key: s }, [
                (O = i.value) != null && O[s] && !((j = i.value) != null && j.items && typeof s == "string" && typeof i.value.items == "object" && s in i.value.items) ? (a(), u(C, {
                  key: 0,
                  breadcrumb: e.breadcrumb,
                  compact: e.compact,
                  composition: s,
                  hideHeading: e.hideHeading,
                  level: e.level,
                  name: e.name,
                  noncollapsible: e.noncollapsible,
                  schemas: e.schemas,
                  value: i.value
                }, null, 8, ["breadcrumb", "compact", "composition", "hideHeading", "level", "name", "noncollapsible", "schemas", "value"])) : $(s) ? (a(), u(C, {
                  key: 1,
                  breadcrumb: e.breadcrumb,
                  compact: e.compact,
                  composition: s,
                  hideHeading: e.hideHeading,
                  level: e.level,
                  name: e.name,
                  noncollapsible: e.noncollapsible,
                  schemas: e.schemas,
                  value: (B = i.value) == null ? void 0 : B.items
                }, null, 8, ["breadcrumb", "compact", "composition", "hideHeading", "level", "name", "noncollapsible", "schemas", "value"])) : l("", !0)
              ], 64);
            }), 128)),
            e.isDiscriminator && e.discriminatorMapping && e.compact ? (a(), u(_, {
              key: 5,
              "discriminator-mapping": e.discriminatorMapping,
              discriminator: I.value,
              "onUpdate:modelValue": v
            }, null, 8, ["discriminator-mapping", "discriminator"])) : l("", !0),
            d(y(ie), { value: i.value }, null, 8, ["value"])
          ];
        }),
        _: 1
      }, 8, ["class"]);
    };
  }
});
export {
  Ne as default
};
