"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                          */
;/* empty css                                                                */
;/* empty css                                                               */
;/* empty css                                                             */
;/* empty css                                                                  */
require("../../../../node_modules/element-plus/theme-chalk/el-tab-pane.css.js");
;/* empty css                                                              */
;/* empty css                                                                  */
;/* empty css                                                               */
;/* empty css                                                               */
;/* empty css                                                             */
;/* empty css                                                            */
;/* empty css                                                              */
;/* empty css                                                               */
const Vue = require("vue");
const index$3 = require("../../../../node_modules/@element-plus/icons-vue/dist/index.js");
const common = require("../utils/common.js");
const fieldSelection = require("./fieldSelection.vue.js");
;/* empty css                                                              */
;/* empty css                                                                */
;/* empty css            */
const _pluginVue_exportHelper = require("../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../node_modules/element-plus/es/components/dialog/index.js");
const index$1 = require("../../../../node_modules/element-plus/es/components/container/index.js");
const index$2 = require("../../../../node_modules/element-plus/es/components/button/index.js");
const index$4 = require("../../../../node_modules/element-plus/es/components/input/index.js");
const index$5 = require("../../../../node_modules/element-plus/es/components/tag/index.js");
const index$6 = require("../../../../node_modules/element-plus/es/components/tabs/index.js");
const index$7 = require("../../../../node_modules/element-plus/es/components/scrollbar/index.js");
const index$8 = require("../../../../node_modules/element-plus/es/components/message/index.js");
const _hoisted_1 = { key: 0 };
const _hoisted_2 = { class: "mode-menu-item is-editing" };
const _hoisted_3 = { class: "new-item-content" };
const _hoisted_4 = { class: "edit-actions" };
const _hoisted_5 = ["onClick"];
const _hoisted_6 = { class: "mode-content" };
const _hoisted_7 = { class: "mode-info-wrapper" };
const _hoisted_8 = { class: "mode-edit-wrapper" };
const _hoisted_9 = { class: "edit-input-group" };
const _hoisted_10 = { class: "edit-actions" };
const _hoisted_11 = { class: "mode-display" };
const _hoisted_12 = { class: "mode-display-content" };
const _hoisted_13 = { class: "mode-name" };
const _hoisted_14 = { class: "mode-key" };
const _hoisted_15 = {
  key: 0,
  class: "mode-actions"
};
const _hoisted_16 = {
  key: 1,
  class: "mode-actions"
};
const _hoisted_17 = { key: 0 };
const _hoisted_18 = {
  key: 1,
  class: "empty-selection"
};
const _hoisted_19 = { class: "dialog-footer" };
const _sfc_main = {
  __name: "index",
  props: {
    "modelValue": { required: true },
    "modelModifiers": {}
  },
  emits: ["update:modelValue"],
  setup(__props) {
    const dialogVisible = Vue.useModel(__props, "modelValue");
    const editConfigData = Vue.computed(() => {
      return common.getEditConfigData();
    });
    const modesData = common.cloneDeep(editConfigData.value.mode || []);
    const fields = Vue.computed(() => {
      return common.getEditConfigDataFields() || [];
    });
    const activeModeIndex = Vue.ref(-1);
    const activeTab = Vue.ref("fields");
    Vue.watch(dialogVisible, (val) => {
      if (val) {
        isEditingNew.value = false;
        editingModeIndex.value = -1;
        if (modesData.length > 0 && activeModeIndex.value === -1) {
          activeModeIndex.value = 0;
        }
      }
    });
    const isEditingNew = Vue.ref(false);
    const newModeName = Vue.ref("");
    const newModeKey = Vue.ref("");
    const editingModeIndex = Vue.ref(-1);
    Vue.ref("");
    const editingModeName = Vue.ref("");
    const editingModeKey = Vue.ref("");
    const startAddMode = () => {
      isEditingNew.value = true;
      newModeName.value = "";
      newModeKey.value = "";
    };
    const confirmAddMode = () => {
      if (!newModeName.value.trim() || !newModeKey.value.trim()) {
        index$8.ElMessage.warning("请输入模式名称和标识");
        return;
      }
      if (modesData.some((mode) => mode.key === newModeKey.value)) {
        index$8.ElMessage.warning("模式标识已存在");
        return;
      }
      modesData.push({
        id: Date.now(),
        name: newModeName.value,
        key: newModeKey.value,
        showFields: [],
        editFields: []
      });
      isEditingNew.value = false;
      newModeName.value = "";
      newModeKey.value = "";
      activeModeIndex.value = modesData.length - 1;
    };
    const cancelAddMode = () => {
      isEditingNew.value = false;
      newModeName.value = "";
      newModeKey.value = "";
    };
    const handleRemoveMode = (index2) => {
      modesData.splice(index2, 1);
      if (activeModeIndex.value === index2) {
        activeModeIndex.value = -1;
      } else if (activeModeIndex.value > index2) {
        activeModeIndex.value--;
      }
    };
    const startEditMode = (index2) => {
      editingModeIndex.value = index2;
      editingModeName.value = modesData[index2].name;
      editingModeKey.value = modesData[index2].key;
    };
    const confirmEditMode = () => {
      if (editingModeIndex.value === -1) return;
      if (!editingModeName.value.trim()) {
        index$8.ElMessage.warning("请输入模式名称");
        return;
      }
      if (!editingModeKey.value.trim()) {
        index$8.ElMessage.warning("请输入模式标识");
        return;
      }
      if (modesData.some(
        (mode, idx) => idx !== editingModeIndex.value && mode.key === editingModeKey.value
      )) {
        index$8.ElMessage.warning("模式标识已存在");
        return;
      }
      modesData[editingModeIndex.value].name = editingModeName.value;
      modesData[editingModeIndex.value].key = editingModeKey.value;
      editingModeIndex.value = -1;
      editingModeName.value = "";
      editingModeKey.value = "";
    };
    const cancelEditMode = () => {
      editingModeIndex.value = -1;
      editingModeName.value = "";
      editingModeKey.value = "";
    };
    const onConfirm = () => {
      editConfigData.value.mode = modesData;
      dialogVisible.value = false;
    };
    return (_ctx, _cache) => {
      const _component_el_button = index$2.ElButton;
      const _component_el_header = index$1.ElHeader;
      const _component_el_input = index$4.ElInput;
      const _component_el_tag = index$5.ElTag;
      const _component_el_main = index$1.ElMain;
      const _component_el_container = index$1.ElContainer;
      const _component_el_aside = index$1.ElAside;
      const _component_el_tab_pane = index$6.ElTabPane;
      const _component_el_scrollbar = index$7.ElScrollbar;
      const _component_el_tabs = index$6.ElTabs;
      const _component_el_dialog = index.ElDialog;
      return Vue.openBlock(), Vue.createBlock(_component_el_dialog, {
        modelValue: dialogVisible.value,
        "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => dialogVisible.value = $event),
        width: "60%",
        title: "模式配置",
        draggable: "",
        overflow: "",
        "append-to-body": "",
        class: "fec-dev-designer-dialog"
      }, {
        footer: Vue.withCtx(() => [
          Vue.createElementVNode("div", _hoisted_19, [
            Vue.createVNode(_component_el_button, {
              onClick: _cache[5] || (_cache[5] = ($event) => dialogVisible.value = false)
            }, {
              default: Vue.withCtx(() => _cache[14] || (_cache[14] = [
                Vue.createTextVNode("取消")
              ])),
              _: 1
            }),
            Vue.createVNode(_component_el_button, {
              type: "primary",
              onClick: onConfirm
            }, {
              default: Vue.withCtx(() => _cache[15] || (_cache[15] = [
                Vue.createTextVNode("确定")
              ])),
              _: 1
            })
          ])
        ]),
        default: Vue.withCtx(() => [
          Vue.createVNode(_component_el_container, { style: { "border": "1px solid #ebeef5", "border-radius": "4px" } }, {
            default: Vue.withCtx(() => [
              Vue.createVNode(_component_el_aside, { width: "300px" }, {
                default: Vue.withCtx(() => [
                  Vue.createVNode(_component_el_container, { style: { "height": "600px" } }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(_component_el_header, {
                        height: "40px",
                        style: { "background-color": "#f2f2f2", "line-height": "40px" }
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createVNode(_component_el_button, {
                            type: "primary",
                            link: "",
                            icon: Vue.unref(index$3.Plus),
                            onClick: startAddMode
                          }, {
                            default: Vue.withCtx(() => _cache[7] || (_cache[7] = [
                              Vue.createTextVNode(" 新增模式 ")
                            ])),
                            _: 1
                          }, 8, ["icon"])
                        ]),
                        _: 1
                      }),
                      Vue.createVNode(_component_el_main, { style: { "padding": "10px" } }, {
                        default: Vue.withCtx(() => [
                          isEditingNew.value ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
                            Vue.createElementVNode("div", _hoisted_2, [
                              Vue.createElementVNode("div", _hoisted_3, [
                                Vue.createVNode(_component_el_input, {
                                  modelValue: newModeName.value,
                                  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => newModeName.value = $event),
                                  placeholder: "模式名称",
                                  size: "default",
                                  onKeyup: Vue.withKeys(confirmAddMode, ["enter"]),
                                  class: "new-item-input"
                                }, null, 8, ["modelValue"]),
                                Vue.createVNode(_component_el_input, {
                                  modelValue: newModeKey.value,
                                  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => newModeKey.value = $event),
                                  placeholder: "模式标识",
                                  size: "default",
                                  onKeyup: Vue.withKeys(confirmAddMode, ["enter"]),
                                  class: "new-item-input"
                                }, null, 8, ["modelValue"]),
                                Vue.createElementVNode("div", _hoisted_4, [
                                  Vue.createVNode(_component_el_button, {
                                    size: "small",
                                    icon: Vue.unref(index$3.Close),
                                    onClick: cancelAddMode
                                  }, {
                                    default: Vue.withCtx(() => _cache[8] || (_cache[8] = [
                                      Vue.createTextVNode(" 取消 ")
                                    ])),
                                    _: 1
                                  }, 8, ["icon"]),
                                  Vue.createVNode(_component_el_button, {
                                    type: "primary",
                                    size: "small",
                                    icon: Vue.unref(index$3.Check),
                                    onClick: confirmAddMode
                                  }, {
                                    default: Vue.withCtx(() => _cache[9] || (_cache[9] = [
                                      Vue.createTextVNode(" 确认 ")
                                    ])),
                                    _: 1
                                  }, 8, ["icon"])
                                ])
                              ])
                            ])
                          ])) : Vue.createCommentVNode("", true),
                          (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(modesData), (mode, index2) => {
                            return Vue.openBlock(), Vue.createElementBlock("div", {
                              key: index2,
                              class: Vue.normalizeClass([
                                "mode-menu-item",
                                {
                                  "is-active": activeModeIndex.value === index2,
                                  "is-default": mode.key === "default"
                                }
                              ]),
                              onClick: ($event) => activeModeIndex.value = index2
                            }, [
                              Vue.createElementVNode("div", _hoisted_6, [
                                Vue.createElementVNode("div", _hoisted_7, [
                                  Vue.withDirectives(Vue.createElementVNode("div", _hoisted_8, [
                                    Vue.createElementVNode("div", _hoisted_9, [
                                      Vue.createVNode(_component_el_input, {
                                        maxlength: "30",
                                        modelValue: editingModeName.value,
                                        "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => editingModeName.value = $event),
                                        placeholder: "模式名称",
                                        size: "small",
                                        onKeyup: Vue.withKeys(confirmEditMode, ["enter"])
                                      }, null, 8, ["modelValue"]),
                                      Vue.createVNode(_component_el_input, {
                                        maxlength: "30",
                                        modelValue: editingModeKey.value,
                                        "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => editingModeKey.value = $event),
                                        placeholder: "模式标识",
                                        size: "small",
                                        onKeyup: Vue.withKeys(confirmEditMode, ["enter"])
                                      }, null, 8, ["modelValue"])
                                    ]),
                                    Vue.createElementVNode("div", _hoisted_10, [
                                      Vue.createVNode(_component_el_button, {
                                        size: "small",
                                        icon: Vue.unref(index$3.Close),
                                        onClick: cancelEditMode
                                      }, {
                                        default: Vue.withCtx(() => _cache[10] || (_cache[10] = [
                                          Vue.createTextVNode("取消")
                                        ])),
                                        _: 1
                                      }, 8, ["icon"]),
                                      Vue.createVNode(_component_el_button, {
                                        type: "primary",
                                        size: "small",
                                        icon: Vue.unref(index$3.Check),
                                        onClick: confirmEditMode
                                      }, {
                                        default: Vue.withCtx(() => _cache[11] || (_cache[11] = [
                                          Vue.createTextVNode("确认")
                                        ])),
                                        _: 1
                                      }, 8, ["icon"])
                                    ])
                                  ], 512), [
                                    [Vue.vShow, editingModeIndex.value === index2]
                                  ]),
                                  Vue.withDirectives(Vue.createElementVNode("div", _hoisted_11, [
                                    Vue.createElementVNode("div", _hoisted_12, [
                                      Vue.createElementVNode("div", _hoisted_13, [
                                        Vue.createTextVNode(Vue.toDisplayString(mode.name) + " ", 1),
                                        mode.key === "default" ? (Vue.openBlock(), Vue.createBlock(_component_el_tag, {
                                          key: 0,
                                          size: "small",
                                          type: "info",
                                          class: "default-tag"
                                        }, {
                                          default: Vue.withCtx(() => _cache[12] || (_cache[12] = [
                                            Vue.createTextVNode("系统")
                                          ])),
                                          _: 1
                                        })) : Vue.createCommentVNode("", true)
                                      ]),
                                      Vue.createElementVNode("div", _hoisted_14, Vue.toDisplayString(mode.key), 1)
                                    ]),
                                    mode.key !== "default" ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_15, [
                                      Vue.createVNode(_component_el_button, {
                                        size: "small",
                                        text: "",
                                        icon: Vue.unref(index$3.Edit),
                                        onClick: Vue.withModifiers(($event) => startEditMode(index2), ["stop"]),
                                        title: "编辑模式"
                                      }, null, 8, ["icon", "onClick"]),
                                      Vue.createVNode(_component_el_button, {
                                        size: "small",
                                        text: "",
                                        type: "danger",
                                        icon: Vue.unref(index$3.Delete),
                                        onClick: Vue.withModifiers(($event) => handleRemoveMode(index2), ["stop"]),
                                        title: "删除模式"
                                      }, null, 8, ["icon", "onClick"])
                                    ])) : (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_16, [
                                      Vue.createVNode(_component_el_button, {
                                        size: "small",
                                        text: "",
                                        icon: Vue.unref(index$3.Edit),
                                        disabled: "",
                                        title: "系统模式不可编辑"
                                      }, null, 8, ["icon"]),
                                      Vue.createVNode(_component_el_button, {
                                        size: "small",
                                        text: "",
                                        type: "danger",
                                        icon: Vue.unref(index$3.Delete),
                                        disabled: "",
                                        title: "系统模式不可删除"
                                      }, null, 8, ["icon"])
                                    ]))
                                  ], 512), [
                                    [Vue.vShow, editingModeIndex.value !== index2]
                                  ])
                                ])
                              ])
                            ], 10, _hoisted_5);
                          }), 128))
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  })
                ]),
                _: 1
              }),
              Vue.createVNode(_component_el_main, { style: { "border-left": "1px solid #ebeef5", "padding": "0" } }, {
                default: Vue.withCtx(() => [
                  activeModeIndex.value !== -1 ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_17, [
                    Vue.createVNode(_component_el_tabs, {
                      modelValue: activeTab.value,
                      "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => activeTab.value = $event),
                      class: "mode-tab"
                    }, {
                      default: Vue.withCtx(() => [
                        Vue.createVNode(_component_el_scrollbar, { height: "540px" }, {
                          default: Vue.withCtx(() => [
                            Vue.createVNode(_component_el_tab_pane, {
                              label: "字段",
                              name: "fields"
                            }, {
                              default: Vue.withCtx(() => [
                                Vue.createVNode(fieldSelection.default, {
                                  mode: Vue.unref(modesData)[activeModeIndex.value],
                                  fields: fields.value
                                }, null, 8, ["mode", "fields"])
                              ]),
                              _: 1
                            }),
                            Vue.createVNode(_component_el_tab_pane, {
                              label: "预留",
                              name: "reserved"
                            }, {
                              default: Vue.withCtx(() => _cache[13] || (_cache[13] = [
                                Vue.createElementVNode("div", { class: "reserved-content" }, [
                                  Vue.createElementVNode("p", null, "预留配置区域")
                                ], -1)
                              ])),
                              _: 1
                            })
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    }, 8, ["modelValue"])
                  ])) : (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_18, "请从左侧选择一个模式"))
                ]),
                _: 1
              })
            ]),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
};
const ModeDialog = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-c0bb64e8"]]);
exports.default = ModeDialog;
