import { defineComponent, computed, createElementBlock, createCommentVNode, openBlock, Fragment, createBlock } from "vue";
import { combineParams } from "@scalar/api-client/v2/features/operation";
import { getResolvedRef } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { filterSelectedSecurity } from "./helpers/filter-selected-security.js";
import { getFirstServer } from "./helpers/get-first-server.js";
import ClassicLayout from "./layouts/ClassicLayout.vue.js";
import ModernLayout from "./layouts/ModernLayout.vue.js";
const __default__ = {};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  __name: "Operation",
  props: {
    id: {},
    method: {},
    options: {},
    document: {},
    path: {},
    pathValue: {},
    server: {},
    securitySchemes: {},
    clientOptions: {},
    isCollapsed: { type: Boolean },
    isWebhook: { type: Boolean },
    selectedClient: {},
    eventBus: {},
    authStore: {}
  },
  setup(__props) {
    const operation = computed(() => {
      const entity = getResolvedRef(__props.pathValue?.[__props.method]);
      if (!entity) {
        return null;
      }
      const parameters = combineParams(__props.pathValue?.parameters, entity.parameters);
      return { ...entity, parameters };
    });
    const selectedServer = computed(
      () => getFirstServer(
        // 1) Operation
        operation.value?.servers ?? null,
        // 2) Path Item
        __props.pathValue?.servers ?? null,
        // 3) Document
        __props.server
      )
    );
    const selectedSecuritySchemes = computed(
      () => filterSelectedSecurity(
        __props.document,
        operation.value,
        __props.authStore.getAuthSelectedSchemas({
          type: "document",
          documentName: __props.document?.["x-scalar-navigation"]?.name ?? ""
        }),
        __props.authStore.getAuthSelectedSchemas({
          type: "operation",
          documentName: __props.document?.["x-scalar-navigation"]?.name ?? "",
          path: __props.path,
          method: __props.method
        }),
        __props.securitySchemes
      )
    );
    return (_ctx, _cache) => {
      return operation.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
        __props.options.layout === "classic" ? (openBlock(), createBlock(ClassicLayout, {
          key: 0,
          id: __props.id,
          clientOptions: __props.clientOptions,
          eventBus: __props.eventBus,
          isCollapsed: __props.isCollapsed,
          isWebhook: __props.isWebhook,
          method: __props.method,
          operation: operation.value,
          options: __props.options,
          path: __props.path,
          selectedClient: __props.selectedClient,
          selectedSecuritySchemes: selectedSecuritySchemes.value,
          selectedServer: selectedServer.value
        }, null, 8, ["id", "clientOptions", "eventBus", "isCollapsed", "isWebhook", "method", "operation", "options", "path", "selectedClient", "selectedSecuritySchemes", "selectedServer"])) : (openBlock(), createBlock(ModernLayout, {
          key: 1,
          id: __props.id,
          clientOptions: __props.clientOptions,
          eventBus: __props.eventBus,
          isWebhook: __props.isWebhook,
          method: __props.method,
          operation: operation.value,
          options: __props.options,
          path: __props.path,
          selectedClient: __props.selectedClient,
          selectedSecuritySchemes: selectedSecuritySchemes.value,
          selectedServer: selectedServer.value
        }, null, 8, ["id", "clientOptions", "eventBus", "isWebhook", "method", "operation", "options", "path", "selectedClient", "selectedSecuritySchemes", "selectedServer"]))
      ], 64)) : createCommentVNode("", true);
    };
  }
});
export {
  _sfc_main as default
};
