import { defineComponent as O, ref as S, openBlock as a, createElementBlock as c, createBlock as n, unref as r, withCtx as o, createVNode as u, createElementVNode as m, toDisplayString as d, Fragment as f, renderList as h, normalizeClass as B } from "vue";
import { TabGroup as T, TabList as H, Tab as N, TabPanel as V } from "@headlessui/vue";
import { cva as j, cx as w } from "@scalar/components";
import { stringify as v } from "flatted";
import { mergeAllOfSchemas as z } from "./helpers/merge-all-of-schemas.js";
import b from "./Schema.vue.js";
const L = { class: "property-rule" }, A = { class: "text-c-3" }, D = { class: "flex items-center gap-1.5" }, E = { class: "schema-tab-label z-1 relative" }, Z = /* @__PURE__ */ O({
  __name: "SchemaDiscriminator",
  props: {
    discriminator: {},
    schemas: {},
    name: {},
    value: {},
    level: {},
    compact: { type: Boolean },
    hideHeading: { type: Boolean }
  },
  setup(y) {
    const i = y, p = S(0), g = j({
      base: "schema-tab",
      variants: {
        selected: {
          true: "schema-tab-selected",
          false: "text-c-3"
        }
      }
    }), k = (e) => {
      if (!e)
        return null;
      if (e.name)
        return e.name;
      if (i.schemas && typeof i.schemas == "object") {
        for (const [s, t] of Object.entries(i.schemas))
          if (v(t) === v(e))
            return s;
        return Object.keys(e)[0];
      }
      return null;
    }, C = (e) => e.replace(/([A-Z])/g, " $1").replace(/^./, (s) => s.toUpperCase()).toLowerCase().replace(/^(\w)/, (s) => s.toUpperCase());
    return (e, s) => (a(), c("div", L, [
      e.discriminator === "oneOf" || e.discriminator === "anyOf" ? (a(), n(r(T), { key: 0 }, {
        default: o(() => [
          u(r(H), { class: "discriminator-tab-list py-1.25 flex flex-col gap-1 rounded-t-lg border border-b-0 px-2 pr-3" }, {
            default: o(() => [
              m("span", A, d(C(e.discriminator)), 1),
              m("div", D, [
                (a(!0), c(f, null, h(e.value[e.discriminator], (t, l) => (a(), n(r(N), {
                  key: l,
                  class: B([
                    "cursor-pointer",
                    r(w)(r(g)({ selected: p.value === l }))
                  ]),
                  onClick: (F) => p.value = l
                }, {
                  default: o(() => [
                    m("span", E, d(k(t) || "Schema"), 1)
                  ]),
                  _: 2
                }, 1032, ["class", "onClick"]))), 128))
              ])
            ]),
            _: 1
          }),
          (a(!0), c(f, null, h(e.value[e.discriminator], (t, l) => (a(), n(r(V), {
            key: l,
            class: "discriminator-panel"
          }, {
            default: o(() => [
              u(b, {
                compact: e.compact,
                hideHeading: e.hideHeading,
                name: e.name,
                noncollapsible: !0,
                schemas: e.schemas,
                value: t
              }, null, 8, ["compact", "hideHeading", "name", "schemas", "value"])
            ]),
            _: 2
          }, 1024))), 128))
        ]),
        _: 1
      })) : (a(), n(b, {
        key: 1,
        compact: e.compact,
        level: e.level,
        name: e.name,
        noncollapsible: e.level == 0,
        schemas: e.schemas,
        value: r(z)(e.value[e.discriminator])
      }, null, 8, ["compact", "level", "name", "noncollapsible", "schemas", "value"]))
    ]));
  }
});
export {
  Z as default
};
