import { defineComponent as w, computed as t, toValue as a, createBlock as C, createElementBlock as B, openBlock as m, unref as c, createElementVNode as U } from "vue";
import { getResolvedRef as s } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { mapHiddenClientsConfig as b } from "../modal/helpers/map-hidden-clients-config.js";
import { combineParams as M } from "./helpers/combine-params.js";
import { getSelectedServer as N } from "./helpers/get-selected-server.js";
import { getActiveProxyUrl as A } from "../../helpers/get-active-proxy-url.js";
import { getServers as E } from "../../helpers/get-servers.js";
import R from "../../blocks/operation-block/OperationBlock.vue.js";
const V = {
  key: 1,
  class: "flex h-full w-full items-center justify-center"
}, P = {}, L = /* @__PURE__ */ w({
  ...P,
  __name: "Operation",
  props: {
    documentSlug: {},
    document: {},
    eventBus: {},
    layout: {},
    path: {},
    method: {},
    exampleName: {},
    environment: {},
    securitySchemes: {},
    workspaceStore: {},
    activeWorkspace: {},
    plugins: {},
    customThemes: {},
    currentTheme: {},
    isDarkMode: { type: Boolean },
    fetchRegistryDocument: { type: Function },
    options: {}
  },
  setup(e) {
    const u = t(() => e.path ? s(e.document?.paths?.[e.path]) : null), r = t(() => {
      if (!e.path || !e.method)
        return null;
      const n = s(e.document?.paths?.[e.path]?.[e.method]);
      if (!n)
        return null;
      if (!u.value)
        return n;
      const o = M(
        u.value.parameters,
        n.parameters
      );
      return { ...n, parameters: o };
    }), d = t(() => [
      ...(e.workspaceStore.workspace?.["x-scalar-cookies"] ?? []).map((n) => ({
        ...n,
        location: "workspace"
      })),
      ...(e.document?.["x-scalar-cookies"] ?? []).map((n) => ({
        ...n,
        location: "document"
      }))
    ]), l = t(() => {
      const n = a(e.options)?.servers ?? r.value?.servers ?? // pathItem.value?.servers ?? TODO: add support for pathItem servers
      e.document?.servers;
      return E(n, {
        baseServerUrl: a(e.options)?.baseServerURL,
        documentUrl: e.document?.["x-scalar-original-source-url"]
      });
    }), v = t(() => a(e.options)?.servers != null ? e.document?.["x-scalar-selected-server"] : r.value?.servers != null ? r.value["x-scalar-selected-server"] : e.document?.["x-scalar-selected-server"]), h = t(
      () => N(l.value, v.value)
    ), S = t(() => r.value?.servers != null ? { type: "operation", path: e.path ?? "", method: e.method ?? "get" } : { type: "document" }), y = t(() => e.workspaceStore.auth.getAuthSelectedSchemas({
      type: "document",
      documentName: e.documentSlug
    })), i = t(() => e.workspaceStore.auth.getAuthSelectedSchemas({
      type: "operation",
      documentName: e.documentSlug,
      path: e.path ?? "",
      method: e.method ?? "get"
    })), f = t(() => i.value !== void 0 ? {
      type: "operation",
      path: e.path ?? "",
      method: e.method ?? "get"
    } : { type: "document" }), k = t(() => Array.from(
      new Set(
        Object.keys({
          ...e.document?.["x-scalar-environments"],
          ...e.workspaceStore.workspace["x-scalar-environments"]
        })
      )
    )), g = t(
      () => b(a(e.options)?.hiddenClients)
    ), x = "2.37.0";
    return (n, o) => e.path && e.method && e.exampleName && r.value ? (m(), C(c(R), {
      key: 0,
      activeEnvironment: e.workspaceStore.workspace["x-scalar-active-environment"],
      appVersion: c(x),
      authMeta: f.value,
      documentSecurity: e.document?.security ?? [],
      documentSelectedSecurity: y.value,
      documentUrl: e.document?.["x-scalar-original-source-url"],
      environment: e.environment,
      environments: k.value,
      eventBus: e.eventBus,
      exampleKey: e.exampleName,
      globalCookies: d.value,
      hideClientButton: a(e.options)?.hideClientButton ?? !1,
      history: e.workspaceStore.history.getHistory(e.documentSlug, e.path, e.method),
      httpClients: g.value,
      layout: e.layout,
      method: e.method,
      operation: r.value,
      operationSelectedSecurity: i.value,
      path: e.path,
      plugins: e.plugins,
      proxyUrl: c(A)(
        e.workspaceStore.workspace["x-scalar-active-proxy"],
        e.layout
      ) ?? "",
      securitySchemes: e.securitySchemes,
      selectedClient: e.workspaceStore.workspace["x-scalar-default-client"],
      server: h.value,
      serverMeta: S.value,
      servers: l.value
    }, null, 8, ["activeEnvironment", "appVersion", "authMeta", "documentSecurity", "documentSelectedSecurity", "documentUrl", "environment", "environments", "eventBus", "exampleKey", "globalCookies", "hideClientButton", "history", "httpClients", "layout", "method", "operation", "operationSelectedSecurity", "path", "plugins", "proxyUrl", "securitySchemes", "selectedClient", "server", "serverMeta", "servers"])) : (m(), B("div", V, [...o[0] || (o[0] = [
      U("span", { class: "text-c-3" }, "Select an operation to view details", -1)
    ])]));
  }
});
export {
  L as default
};
