"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                                                               */
const Vue = require("vue");
const vueDraggablePlus = require("../../../../node_modules/vue-draggable-plus/dist/vue-draggable-plus.js");
const index$4 = require("../../../../node_modules/@element-plus/icons-vue/dist/index.js");
const common = require("../utils/common.js");
;/* empty css                        */
const _pluginVue_exportHelper = require("../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../node_modules/element-plus/es/components/switch/index.js");
const index$1 = require("../../../../node_modules/element-plus/es/components/input/index.js");
const index$2 = require("../../../../node_modules/element-plus/es/components/button/index.js");
const index$3 = require("../../../../node_modules/element-plus/es/components/icon/index.js");
const index$5 = require("../../../../node_modules/element-plus/es/components/link/index.js");
const _hoisted_1 = { class: "page-header-setting" };
const _hoisted_2 = { class: "setting-left" };
const _hoisted_3 = { class: "setting-right" };
const _hoisted_4 = ["onMouseenter", "onClick"];
const _sfc_main = {
  __name: "PageHeaderSetting",
  setup(__props) {
    const editConfigData = Vue.computed(() => {
      return common.getEditConfigData();
    });
    const pageHeaderConfig = Vue.computed(() => {
      return editConfigData.value.pageHeaderConfig || {
        enabled: true,
        canBack: true,
        title: "",
        subTitle: "",
        actions: []
      };
    });
    const btnTypeConfig = {
      custom: { type: "primary" },
      refresh: { icon: index$4.Refresh },
      export: { icon: index$4.Download },
      personalize: { icon: index$4.Setting }
    };
    function getBtnProps(item) {
      const data = btnTypeConfig[item.btnType] || {};
      if (!item.label) {
        data.class = "system";
      } else {
        data.class = "";
      }
      return data;
    }
    function addAction() {
      const newBtn = {
        id: Date.now(),
        label: "按钮",
        type: "pageHeaderBtn",
        btnType: "custom",
        btnStyle: "default"
      };
      if (!pageHeaderConfig.value.actions) {
        pageHeaderConfig.value.actions = [];
      }
      pageHeaderConfig.value.actions.push(newBtn);
    }
    function removeAction(item) {
      const index2 = pageHeaderConfig.value.actions.findIndex(
        (i) => i.id === item.id
      );
      if (index2 !== -1) {
        pageHeaderConfig.value.actions.splice(index2, 1);
      }
    }
    return (_ctx, _cache) => {
      const _component_el_switch = index.ElSwitch;
      const _component_el_input = index$1.ElInput;
      const _component_el_button = index$2.ElButton;
      const _component_el_icon = index$3.ElIcon;
      const _component_el_link = index$5.ElLink;
      return Vue.openBlock(), Vue.createElementBlock("div", _hoisted_1, [
        Vue.createElementVNode("div", _hoisted_2, [
          _cache[6] || (_cache[6] = Vue.createElementVNode("span", { class: "text-label" }, "启用页头", -1)),
          Vue.createVNode(_component_el_switch, {
            modelValue: pageHeaderConfig.value.enabled,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => pageHeaderConfig.value.enabled = $event),
            size: "small"
          }, null, 8, ["modelValue"]),
          _cache[7] || (_cache[7] = Vue.createElementVNode("div", { class: "setting-divider" }, null, -1)),
          _cache[8] || (_cache[8] = Vue.createElementVNode("span", { class: "text-label" }, "显示返回", -1)),
          Vue.createVNode(_component_el_switch, {
            modelValue: pageHeaderConfig.value.canBack,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => pageHeaderConfig.value.canBack = $event),
            size: "small"
          }, null, 8, ["modelValue"]),
          _cache[9] || (_cache[9] = Vue.createElementVNode("div", { class: "setting-divider" }, null, -1)),
          _cache[10] || (_cache[10] = Vue.createElementVNode("span", { class: "text-label" }, "标题", -1)),
          Vue.createVNode(_component_el_input, {
            modelValue: pageHeaderConfig.value.title,
            "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => pageHeaderConfig.value.title = $event),
            size: "small",
            placeholder: "请输入标题",
            style: { "width": "180px" }
          }, null, 8, ["modelValue"]),
          _cache[11] || (_cache[11] = Vue.createElementVNode("div", { class: "setting-divider" }, null, -1)),
          _cache[12] || (_cache[12] = Vue.createElementVNode("span", { class: "text-label" }, "描述", -1)),
          Vue.createVNode(_component_el_input, {
            modelValue: pageHeaderConfig.value.subTitle,
            "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => pageHeaderConfig.value.subTitle = $event),
            size: "small",
            placeholder: "请输入次标题",
            style: { "width": "220px" }
          }, null, 8, ["modelValue"])
        ]),
        Vue.createElementVNode("div", _hoisted_3, [
          Vue.createVNode(Vue.unref(vueDraggablePlus.VueDraggable), {
            modelValue: pageHeaderConfig.value.actions,
            "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => pageHeaderConfig.value.actions = $event),
            animation: 150,
            group: { name: "pageHeaderActions" },
            ghostClass: "ghost",
            class: "optBtnDraggable"
          }, {
            default: Vue.withCtx(() => [
              (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(pageHeaderConfig.value.actions, (item) => {
                return Vue.openBlock(), Vue.createElementBlock("div", {
                  class: Vue.normalizeClass(["optBtn", Vue.unref(common.getCurrentClass)(item)]),
                  onMouseenter: ($event) => Vue.unref(common.setHoverItem)(item),
                  onMouseleave: _cache[4] || (_cache[4] = ($event) => Vue.unref(common.setHoverItem)()),
                  onClick: Vue.withModifiers(($event) => Vue.unref(common.setSelectedItem)(item), ["stop"])
                }, [
                  Vue.createVNode(_component_el_button, Vue.mergeProps({
                    class: "elBtn",
                    ref_for: true
                  }, getBtnProps(item)), {
                    default: Vue.withCtx(() => [
                      Vue.createTextVNode(Vue.toDisplayString(item.label), 1)
                    ]),
                    _: 2
                  }, 1040),
                  Vue.createVNode(_component_el_icon, {
                    class: "delete-icon",
                    onClick: Vue.withModifiers(($event) => removeAction(item), ["stop"])
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createVNode(Vue.unref(index$4.Close))
                    ]),
                    _: 2
                  }, 1032, ["onClick"])
                ], 42, _hoisted_4);
              }), 256))
            ]),
            _: 1
          }, 8, ["modelValue"]),
          Vue.createVNode(_component_el_link, {
            class: "optBtn addLink",
            underline: "never",
            type: "primary",
            icon: Vue.unref(index$4.Plus),
            onClick: Vue.withModifiers(addAction, ["stop"])
          }, {
            default: Vue.withCtx(() => _cache[13] || (_cache[13] = [
              Vue.createTextVNode("按钮")
            ])),
            _: 1
          }, 8, ["icon"])
        ])
      ]);
    };
  }
};
const PageHeaderSetting = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-aeab999f"]]);
exports.default = PageHeaderSetting;
