import { defineComponent as S, useId as k, createElementBlock as C, openBlock as a, Fragment as V, createElementVNode as v, createVNode as y, createBlock as u, createCommentVNode as m, normalizeClass as B, unref as t } from "vue";
import { ServerSelector as h, ServerVariablesForm as N } from "@scalar/api-client/components/Server";
import { useWorkspace as U } from "@scalar/api-client/store";
import { ScalarMarkdown as E } from "@scalar/components";
import { useConfig as F } from "../../hooks/useConfig.js";
const M = ["id"], q = /* @__PURE__ */ S({
  __name: "BaseUrl",
  props: {
    collection: {},
    server: {}
  },
  setup(l) {
    const { serverMutators: b } = U(), s = k(), p = F(), f = (e, o) => {
      if (!l.server)
        return;
      const r = l.server.variables || {};
      r[e] = { ...r[e], default: o }, b.edit(l.server.uid, "variables", r);
    }, g = (e) => {
      var o, r;
      (r = (o = p.value).onServerChange) == null || r.call(o, e);
    };
    return (e, o) => {
      var r, n, i, d, c;
      return a(), C(V, null, [
        o[0] || (o[0] = v("label", { class: "bg-b-2 flex h-8 items-center rounded-t-lg border border-b-0 px-3 py-2.5 text-sm font-medium" }, " Server ", -1)),
        v("div", {
          id: t(s),
          class: B(["border", {
            "rounded-b-lg": !((r = e.server) != null && r.description)
          }])
        }, [
          (i = (n = e.collection) == null ? void 0 : n.servers) != null && i.length ? (a(), u(t(h), {
            key: 0,
            collection: e.collection,
            server: e.server,
            target: t(s),
            onUpdateServer: g
          }, null, 8, ["collection", "server", "target"])) : m("", !0)
        ], 10, M),
        y(t(N), {
          variables: (d = e.server) == null ? void 0 : d.variables,
          layout: "reference",
          "onUpdate:variable": f
        }, null, 8, ["variables"]),
        (c = e.server) != null && c.description ? (a(), u(t(E), {
          key: 0,
          class: "text-c-3 rounded-b-lg border border-t-0 px-3 py-1.5",
          value: e.server.description
        }, null, 8, ["value"])) : m("", !0)
      ], 64);
    };
  }
});
export {
  q as default
};
