import "../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                          */
/* empty css                                                             */
/* empty css                                                               */
/* empty css                                                               */
import { computed, createElementBlock, openBlock, createElementVNode, createVNode, unref, withCtx, Fragment, renderList, withModifiers, normalizeClass, mergeProps, createTextVNode, toDisplayString } from "vue";
import { VueDraggable as lo } from "../../../../node_modules/vue-draggable-plus/dist/vue-draggable-plus.mjs";
import { Close as close_default, Plus as plus_default } from "../../../../node_modules/@element-plus/icons-vue/dist/index.mjs";
import { getEditConfigData, setSelectedItem, setHoverItem, getCurrentClass } from "../utils/common.mjs";
/* empty css                        */
import _export_sfc from "../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElSwitch } from "../../../../node_modules/element-plus/es/components/switch/index.mjs";
import { ElButton } from "../../../../node_modules/element-plus/es/components/button/index.mjs";
import { ElIcon } from "../../../../node_modules/element-plus/es/components/icon/index.mjs";
import { ElLink } from "../../../../node_modules/element-plus/es/components/link/index.mjs";
const _hoisted_1 = { class: "page-footer-setting" };
const _hoisted_2 = { class: "setting-left" };
const _hoisted_3 = { class: "setting-center" };
const _hoisted_4 = ["onMouseenter", "onClick"];
const _sfc_main = {
  __name: "PageFooterSetting",
  setup(__props) {
    const editConfigData = computed(() => {
      return getEditConfigData();
    });
    const pageFooterConfig = computed(() => {
      return editConfigData.value.pageFooterConfig || {
        enabled: true,
        actions: []
      };
    });
    function getBtnProps(item) {
      return {
        type: item.btnType
      };
    }
    function addAction() {
      const newBtn = {
        id: Date.now(),
        label: "按钮",
        type: "pageFooterBtn",
        btnType: "primary"
      };
      if (!pageFooterConfig.value.actions) {
        pageFooterConfig.value.actions = [];
      }
      pageFooterConfig.value.actions.push(newBtn);
    }
    function removeAction(item) {
      const index = pageFooterConfig.value.actions.findIndex(
        (i) => i.id === item.id
      );
      if (index !== -1) {
        pageFooterConfig.value.actions.splice(index, 1);
      }
    }
    return (_ctx, _cache) => {
      const _component_el_switch = ElSwitch;
      const _component_el_button = ElButton;
      const _component_el_icon = ElIcon;
      const _component_el_link = ElLink;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          _cache[3] || (_cache[3] = createElementVNode("span", { class: "text-label" }, "启用页尾", -1)),
          createVNode(_component_el_switch, {
            modelValue: pageFooterConfig.value.enabled,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => pageFooterConfig.value.enabled = $event),
            size: "small"
          }, null, 8, ["modelValue"]),
          _cache[4] || (_cache[4] = createElementVNode("div", { class: "setting-divider" }, null, -1))
        ]),
        createElementVNode("div", _hoisted_3, [
          createVNode(unref(lo), {
            modelValue: pageFooterConfig.value.actions,
            "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => pageFooterConfig.value.actions = $event),
            animation: 150,
            group: { name: "pageFooterActions" },
            ghostClass: "ghost",
            class: "optBtnDraggable"
          }, {
            default: withCtx(() => [
              (openBlock(true), createElementBlock(Fragment, null, renderList(pageFooterConfig.value.actions, (item) => {
                return openBlock(), createElementBlock("div", {
                  class: normalizeClass(["optBtn", unref(getCurrentClass)(item)]),
                  onMouseenter: ($event) => unref(setHoverItem)(item),
                  onMouseleave: _cache[1] || (_cache[1] = ($event) => unref(setHoverItem)()),
                  onClick: withModifiers(($event) => unref(setSelectedItem)(item), ["stop"])
                }, [
                  createVNode(_component_el_button, mergeProps({
                    class: "elBtn",
                    ref_for: true
                  }, getBtnProps(item)), {
                    default: withCtx(() => [
                      createTextVNode(toDisplayString(item.label), 1)
                    ]),
                    _: 2
                  }, 1040),
                  createVNode(_component_el_icon, {
                    class: "delete-icon",
                    onClick: withModifiers(($event) => removeAction(item), ["stop"])
                  }, {
                    default: withCtx(() => [
                      createVNode(unref(close_default))
                    ]),
                    _: 2
                  }, 1032, ["onClick"])
                ], 42, _hoisted_4);
              }), 256))
            ]),
            _: 1
          }, 8, ["modelValue"]),
          createVNode(_component_el_link, {
            class: "optBtn addLink",
            underline: "never",
            type: "primary",
            icon: unref(plus_default),
            onClick: withModifiers(addAction, ["stop"])
          }, {
            default: withCtx(() => _cache[5] || (_cache[5] = [
              createTextVNode("按钮")
            ])),
            _: 1
          }, 8, ["icon"])
        ]),
        _cache[6] || (_cache[6] = createElementVNode("div", { class: "setting-right" }, null, -1))
      ]);
    };
  }
};
const PageFooterSetting = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-63bf2610"]]);
export {
  PageFooterSetting as default
};
