import { defineComponent as B, ref as N, useId as h, watch as V, computed as F, createElementBlock as l, createCommentVNode as _, unref as e, openBlock as n, createVNode as i, withCtx as m, createElementVNode as H, Fragment as y, renderList as S, createBlock as A, createTextVNode as E, toDisplayString as p } from "vue";
import { TabGroup as j, TabList as D, TabPanels as G, TabPanel as M } from "@headlessui/vue";
import { useWorkspace as O } from "@scalar/api-client/store";
import { ScalarMarkdown as W, ScalarCodeBlock as q } from "@scalar/components";
import z from "./ClientSelector.vue.js";
import { useFeaturedHttpClients as J } from "./useFeaturedHttpClients.js";
import { useHttpClientStore as Q } from "../../../stores/useHttpClientStore.js";
const R = { key: 0 }, U = ["id"], Y = {
  key: 0,
  class: "selected-client card-footer -outline-offset-2",
  role: "tabpanel",
  tabindex: "0"
}, Z = {
  key: 1,
  class: "selected-client card-footer -outline-offset-2",
  role: "tabpanel",
  tabindex: "1"
}, $ = ["id"], ie = /* @__PURE__ */ B({
  __name: "ClientLibraries",
  setup(X) {
    const {
      availableTargets: C,
      httpTargetTitle: k,
      httpClientTitle: x,
      getClientTitle: T,
      getTargetTitle: L,
      httpClient: r,
      setHttpClient: w
    } = Q(), { featuredClients: d, isFeatured: I } = J(), K = O(), b = N(0), v = h(), g = h();
    V(
      r,
      (a) => {
        a && (b.value = d.findIndex(
          (t) => t.targetKey === a.targetKey && t.clientKey === a.clientKey
        ));
      },
      { immediate: !0 }
    );
    function P(a) {
      const t = d[a];
      t && w(t);
    }
    const o = F(() => {
      var c;
      const a = Object.values(K.collections)[0], t = (c = a == null ? void 0 : a.info) == null ? void 0 : c["x-scalar-sdk-installation"];
      if (!Array.isArray(t) || !(t != null && t.length))
        return;
      const s = t.find(
        (u) => {
          var f;
          return u.lang.toLowerCase() === ((f = r == null ? void 0 : r.targetKey) == null ? void 0 : f.toLowerCase());
        }
      );
      if (s)
        return s;
    });
    return (a, t) => e(C).length ? (n(), l("div", R, [
      i(e(j), {
        manual: "",
        selectedIndex: b.value,
        onChange: P
      }, {
        default: m(() => [
          H("div", {
            id: e(v),
            class: "client-libraries-heading"
          }, " Client Libraries ", 8, U),
          i(e(D), {
            "aria-labelledby": e(v),
            class: "client-libraries-list"
          }, {
            default: m(() => [
              i(z, {
                featured: e(d),
                morePanel: e(g)
              }, null, 8, ["featured", "morePanel"])
            ]),
            _: 1
          }, 8, ["aria-labelledby"]),
          i(e(G), null, {
            default: m(() => {
              var s, c;
              return [
                (s = o.value) != null && s.source || (c = o.value) != null && c.description ? (n(), l(y, { key: 0 }, [
                  o.value.description ? (n(), l("div", Y, [
                    i(e(W), {
                      value: o.value.description
                    }, null, 8, ["value"])
                  ])) : _("", !0),
                  o.value.source ? (n(), l("div", Z, [
                    i(e(q), {
                      lang: "shell",
                      content: o.value.source,
                      copy: !1,
                      class: "min-h-6 p-1"
                    }, null, 8, ["content"])
                  ])) : _("", !0)
                ], 64)) : e(r) && e(I)(e(r)) ? (n(!0), l(y, { key: 1 }, S(e(d), (u, f) => (n(), A(e(M), {
                  key: f,
                  class: "selected-client card-footer -outline-offset-2"
                }, {
                  default: m(() => [
                    E(p(e(T)(u)) + " " + p(e(L)(u)), 1)
                  ]),
                  _: 2
                }, 1024))), 128)) : (n(), l("div", {
                  key: 2,
                  id: e(g),
                  class: "selected-client card-footer -outline-offset-2",
                  role: "tabpanel",
                  tabindex: "0"
                }, p(e(x)) + " " + p(e(k)), 9, $))
              ];
            }),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["selectedIndex"])
    ])) : _("", !0);
  }
});
export {
  ie as default
};
