import { defineComponent, inject, ref, watch, resolveComponent, createElementBlock, openBlock, normalizeClass, unref, createElementVNode, createBlock, createCommentVNode, createTextVNode } from 'vue';
import '../../../../utils/index.mjs';
import './json-xml.vue.mjs';
import './params-table.vue.mjs';
import '../config/index.mjs';
import { createNamespace } from '../../../../utils/create-namespace.mjs';
import _sfc_main$1 from './json-xml.vue2.mjs';
import _sfc_main$2 from './params-table.vue2.mjs';
import { paramsTableColumns, formdataTableColumns } from '../config/table.mjs';
import { bodyEmits, bodyProps } from '../config/body.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "BodyComponent" },
  __name: "body-component",
  props: bodyProps,
  emits: bodyEmits,
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emits = __emit;
    const bem = createNamespace("api-component");
    const disabled = inject("disabled");
    const bodyKey = ref(props.value.bodyParams.type);
    const parameters = ref(
      props.value.bodyParams.parameters
    );
    const jsonSchema = ref(
      props.value.bodyParams.jsonSchema
    );
    const description = ref(
      props.value.bodyParams.description
    );
    const handleChange = (e) => {
      if (e === "none") {
        parameters.value = [];
      }
    };
    watch([parameters, jsonSchema, description], () => {
      const obj = {
        ...props.value,
        bodyParams: {
          type: bodyKey.value,
          parameters: parameters.value,
          jsonSchema: jsonSchema.value,
          description: description.value
        }
      };
      emits("change", obj);
      emits("update:value", obj);
    });
    return (_ctx, _cache) => {
      const _component_ll_code_editor = resolveComponent("ll-code-editor");
      return openBlock(), createElementBlock(
        "div",
        {
          class: normalizeClass(unref(bem).m("body"))
        },
        [
          createElementVNode(
            "div",
            {
              class: normalizeClass(unref(bem).m("body-container"))
            },
            [
              bodyKey.value === "json" ? (openBlock(), createBlock(_sfc_main$1, {
                key: 0,
                value: jsonSchema.value,
                "onUpdate:value": _cache[0] || (_cache[0] = ($event) => jsonSchema.value = $event),
                type: bodyKey.value
              }, null, 8, ["value", "type"])) : createCommentVNode("v-if", true),
              bodyKey.value === "xml" ? (openBlock(), createBlock(_sfc_main$1, {
                key: 1,
                value: jsonSchema.value,
                "onUpdate:value": _cache[1] || (_cache[1] = ($event) => jsonSchema.value = $event),
                type: bodyKey.value
              }, null, 8, ["value", "type"])) : createCommentVNode("v-if", true),
              bodyKey.value === "raw" ? (openBlock(), createBlock(_component_ll_code_editor, {
                key: 2,
                value: description.value,
                "onUpdate:value": _cache[2] || (_cache[2] = ($event) => description.value = $event)
              }, null, 8, ["value"])) : createCommentVNode("v-if", true),
              bodyKey.value === "x-www-form-urlencoded" ? (openBlock(), createBlock(_sfc_main$2, {
                key: 3,
                columns: unref(paramsTableColumns),
                "data-source": parameters.value
              }, null, 8, ["columns", "data-source"])) : createCommentVNode("v-if", true),
              bodyKey.value === "form-data" ? (openBlock(), createBlock(_sfc_main$2, {
                key: 4,
                columns: unref(formdataTableColumns),
                "data-source": parameters.value
              }, null, 8, ["columns", "data-source"])) : createCommentVNode("v-if", true),
              bodyKey.value === "none" ? (openBlock(), createElementBlock(
                "div",
                {
                  key: 5,
                  class: normalizeClass(unref(bem).e("none"))
                },
                [
                  createCommentVNode(" <ll-empty>\n          <template #title> \u8BE5\u8BF7\u6C42\u6CA1\u6709 Body \u4F53 </template>\n        </ll-empty> "),
                  _cache[3] || (_cache[3] = createTextVNode(
                    " \u8BE5\u8BF7\u6C42\u6CA1\u6709 Body \u4F53 ",
                    -1
                    /* CACHED */
                  ))
                ],
                2
                /* CLASS */
              )) : createCommentVNode("v-if", true)
            ],
            2
            /* CLASS */
          )
        ],
        2
        /* CLASS */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=body-component.vue2.mjs.map
