import "../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                          */
/* empty css                                                              */
/* empty css                                                              */
/* empty css                                                                 */
/* empty css                                                                      */
import { computed, ref, createBlock, openBlock, withCtx, createElementVNode, createVNode, createElementBlock, Fragment, renderList, unref, createCommentVNode, toDisplayString } from "vue";
import emitter from "../../packages/utils/eventBus.mjs";
import { VueDraggable as lo } from "../../../../node_modules/vue-draggable-plus/dist/vue-draggable-plus.mjs";
import { Calendar as calendar_default, DeleteFilled as delete_filled_default, Hide as hide_default } from "../../../../node_modules/@element-plus/icons-vue/dist/index.mjs";
import { getEditConfigData, setSelectedItem, cloneDeep } from "../../packages/utils/common.mjs";
import components$1 from "../../packages/table/aside/index.mjs";
import components from "../../packages/form/aside/index.mjs";
import FieldRecycleBin from "./fieldRecycleBin.vue.mjs";
import HiddenFieldDialog from "./HiddenFieldDialog.vue.mjs";
import { throttle as eo } from "../../../../node_modules/@vexip-ui/utils/dist/index.mjs";
import store from "../../store/index.mjs";
/* empty css            */
import _export_sfc from "../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElAside } from "../../../../node_modules/element-plus/es/components/container/index.mjs";
import { ElCollapse, ElCollapseItem } from "../../../../node_modules/element-plus/es/components/collapse/index.mjs";
import { ElIcon } from "../../../../node_modules/element-plus/es/components/icon/index.mjs";
import { ElBadge } from "../../../../node_modules/element-plus/es/components/badge/index.mjs";
const _hoisted_1 = { class: "dev-designer-aside" };
const _hoisted_2 = { class: "menu-components-item" };
const _hoisted_3 = { class: "components-item-label" };
const _hoisted_4 = {
  key: 0,
  class: "table-item"
};
const _hoisted_5 = { class: "widgets" };
const _hoisted_6 = { class: "field-label" };
const _hoisted_7 = { class: "aside-footer" };
const _sfc_main = {
  __name: "index",
  emits: ["onFormDragMove"],
  setup(__props, { emit: __emit }) {
    const emit = __emit;
    const editingAside = computed(() => {
      switch (store.getters.editingType) {
        case "table":
          return components$1;
        case "form":
          return components;
      }
      return null;
    });
    const editingType = computed(() => {
      return store.getters.editingType;
    });
    const activeNames = ref(["basic", "advanced"]);
    const recycleBinVisible = ref(false);
    const hiddenFieldDialogVisible = ref(false);
    const recycleBinCount = computed(() => {
      var _a;
      const editConfigData = getEditConfigData();
      return ((_a = editConfigData == null ? void 0 : editConfigData.deletedFields) == null ? void 0 : _a.length) || 0;
    });
    const hiddenFieldCount = computed(() => {
      var _a;
      const editConfigData = getEditConfigData();
      return ((_a = editConfigData == null ? void 0 : editConfigData.hiddenFields) == null ? void 0 : _a.length) || 0;
    });
    function clone(element) {
      return {
        ...cloneDeep(element),
        id: Date.now(),
        type: "widgets"
      };
    }
    function onDragEnd(event) {
      setSelectedItem(event.clonedData);
      if (store.getters.editingType == "form") {
        emitter.emit("onFormDragEnd", event);
      }
    }
    const onMove = eo((event) => {
      if (store.getters.editingType == "form") {
        emit("onFormDragMove", event);
        return true;
      }
      return true;
    }, 50);
    function onStart(event) {
      if (store.getters.editingType == "form") {
        emitter.emit("onFormDragStart", event);
      }
    }
    function openRecycleBin() {
      recycleBinVisible.value = true;
    }
    function openHiddenFieldDialog() {
      hiddenFieldDialogVisible.value = true;
    }
    return (_ctx, _cache) => {
      const _component_el_icon = ElIcon;
      const _component_el_collapse_item = ElCollapseItem;
      const _component_el_collapse = ElCollapse;
      const _component_el_badge = ElBadge;
      const _component_el_aside = ElAside;
      return openBlock(), createBlock(_component_el_aside, { class: "root-aside" }, {
        default: withCtx(() => [
          createElementVNode("div", _hoisted_1, [
            createVNode(_component_el_collapse, {
              modelValue: activeNames.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => activeNames.value = $event)
            }, {
              default: withCtx(() => [
                (openBlock(true), createElementBlock(Fragment, null, renderList(editingAside.value, (item) => {
                  return openBlock(), createBlock(_component_el_collapse_item, {
                    key: item.name,
                    title: item.title,
                    name: item.name
                  }, {
                    default: withCtx(() => [
                      createVNode(unref(lo), {
                        modelValue: item.children,
                        "onUpdate:modelValue": ($event) => item.children = $event,
                        animation: 150,
                        ghostClass: "ghost",
                        group: { name: "dev", pull: "clone", put: false },
                        clone,
                        onEnd: onDragEnd,
                        onMove: unref(onMove),
                        onStart,
                        sort: false,
                        class: "components-list"
                      }, {
                        default: withCtx(() => [
                          (openBlock(true), createElementBlock(Fragment, null, renderList(item.children, (comp) => {
                            return openBlock(), createElementBlock("div", {
                              key: comp.fieldType,
                              class: "components-item"
                            }, [
                              createElementVNode("div", _hoisted_2, [
                                createVNode(_component_el_icon, { class: "components-item-icon" }, {
                                  default: withCtx(() => [
                                    createVNode(unref(calendar_default))
                                  ]),
                                  _: 1
                                }),
                                createElementVNode("span", _hoisted_3, toDisplayString(comp.label), 1)
                              ]),
                              editingType.value == "table" ? (openBlock(), createElementBlock("div", _hoisted_4, [
                                createElementVNode("div", _hoisted_5, toDisplayString(comp.label), 1),
                                createElementVNode("div", _hoisted_6, toDisplayString(comp.fieldName), 1)
                              ])) : createCommentVNode("", true)
                            ]);
                          }), 128))
                        ]),
                        _: 2
                      }, 1032, ["modelValue", "onUpdate:modelValue", "onMove"])
                    ]),
                    _: 2
                  }, 1032, ["title", "name"]);
                }), 128))
              ]),
              _: 1
            }, 8, ["modelValue"])
          ]),
          createElementVNode("div", _hoisted_7, [
            createElementVNode("div", {
              class: "footer-btn recycle-btn",
              onClick: openRecycleBin
            }, [
              createVNode(_component_el_icon, { class: "btn-icon" }, {
                default: withCtx(() => [
                  createVNode(unref(delete_filled_default))
                ]),
                _: 1
              }),
              _cache[3] || (_cache[3] = createElementVNode("span", { class: "btn-text" }, "字段回收站", -1)),
              recycleBinCount.value > 0 ? (openBlock(), createBlock(_component_el_badge, {
                key: 0,
                value: recycleBinCount.value,
                max: 99,
                class: "btn-badge"
              }, null, 8, ["value"])) : createCommentVNode("", true)
            ]),
            _cache[5] || (_cache[5] = createElementVNode("div", { class: "footer-divider" }, null, -1)),
            createElementVNode("div", {
              class: "footer-btn hidden-field-btn",
              onClick: openHiddenFieldDialog
            }, [
              createVNode(_component_el_icon, { class: "btn-icon" }, {
                default: withCtx(() => [
                  createVNode(unref(hide_default))
                ]),
                _: 1
              }),
              _cache[4] || (_cache[4] = createElementVNode("span", { class: "btn-text" }, "隐藏域", -1)),
              hiddenFieldCount.value > 0 ? (openBlock(), createBlock(_component_el_badge, {
                key: 0,
                value: hiddenFieldCount.value,
                max: 99,
                class: "btn-badge"
              }, null, 8, ["value"])) : createCommentVNode("", true)
            ])
          ]),
          createVNode(FieldRecycleBin, {
            modelValue: recycleBinVisible.value,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => recycleBinVisible.value = $event)
          }, null, 8, ["modelValue"]),
          createVNode(HiddenFieldDialog, {
            modelValue: hiddenFieldDialogVisible.value,
            "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => hiddenFieldDialogVisible.value = $event)
          }, null, 8, ["modelValue"])
        ]),
        _: 1
      });
    };
  }
};
const LayoutAside = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-b7e9472b"]]);
export {
  LayoutAside as default
};
