import { defineComponent as f, computed as v, watch as _, onServerPrefetch as k, useSSRContext as x, unref as s, openBlock as a, createElementBlock as S, createElementVNode as h, createVNode as w, createBlock as A, createCommentVNode as i } from "vue";
import { useAuthenticationStore as B, SecuritySchemeSelector as C, SecurityScheme as N } from "@scalar/api-client";
import { hasSecuritySchemes as V } from "../../../helpers/hasSecuritySchemes.js";
import { sleep as E } from "../../../helpers/sleep.js";
const b = { key: 0 }, G = { class: "authentication-header" }, P = { class: "selector" }, R = {
  key: 0,
  class: "authentication-content"
}, D = /* @__PURE__ */ f({
  __name: "Authentication",
  props: {
    parsedSpec: {},
    proxy: {}
  },
  setup(d) {
    const n = d, { authentication: c, setAuthentication: l } = B(), y = v(() => {
      var t, r, o;
      if (!c.preferredSecurityScheme)
        return !1;
      const e = (o = (r = (t = n.parsedSpec) == null ? void 0 : t.components) == null ? void 0 : r.securitySchemes) == null ? void 0 : o[c.preferredSecurityScheme];
      return !!e && "type" in e && !!e.type;
    });
    return _(
      () => {
        var e, t;
        return (t = (e = n.parsedSpec) == null ? void 0 : e.components) == null ? void 0 : t.securitySchemes;
      },
      () => {
        var e, t;
        l({
          securitySchemes: (t = (e = n.parsedSpec) == null ? void 0 : e.components) == null ? void 0 : t.securitySchemes
        });
      },
      { deep: !0, immediate: !0 }
    ), k(async () => {
      const e = x();
      await E(1), e.payload.data["useGlobalStore-authentication"] = c;
    }), (e, t) => {
      var r, o, p, u, m;
      return s(V)(e.parsedSpec) ? (a(), S("div", b, [
        h("div", G, [
          h("div", P, [
            w(s(C), {
              value: (o = (r = e.parsedSpec) == null ? void 0 : r.components) == null ? void 0 : o.securitySchemes
            }, null, 8, ["value"])
          ])
        ]),
        y.value ? (a(), S("div", R, [
          s(c).preferredSecurityScheme ? (a(), A(s(N), {
            key: 0,
            proxy: e.proxy,
            value: (m = (u = (p = e.parsedSpec) == null ? void 0 : p.components) == null ? void 0 : u.securitySchemes) == null ? void 0 : m[s(c).preferredSecurityScheme]
          }, null, 8, ["proxy", "value"])) : i("", !0)
        ])) : i("", !0)
      ])) : i("", !0);
    };
  }
});
export {
  D as default
};
