"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                                                                     */
const Vue = require("vue");
const index$1 = require("../../../../../../node_modules/@element-plus/icons-vue/dist/index.js");
const getInstance = require("../../../utils/getInstance.js");
;/* empty css             */
const _pluginVue_exportHelper = require("../../../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../../../node_modules/element-plus/es/components/page-header/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/message-box/index.js");
const _hoisted_1 = { class: "fec-header__title" };
const _hoisted_2 = { class: "fec-header__subtitle" };
const _sfc_main = {
  __name: "Header",
  props: {
    pageHeaderConfig: {
      type: Object,
      required: true
    },
    isApproval: {
      type: Boolean,
      default: false
    },
    showBack: {
      type: Boolean,
      default: false
    }
  },
  emits: ["action-click"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const ctx = getInstance.getCurrentVueInstance();
    const emit = __emit;
    const canBack = Vue.computed(() => {
      var _a;
      if (props.showBack) {
        return !props.isApproval && ((_a = props.pageHeaderConfig) == null ? void 0 : _a.canBack);
      }
      return false;
    });
    const getButtonType = (btnStyle) => {
      return "primary";
    };
    const handleBack = async () => {
      var _a;
      if ((_a = props.pageHeaderConfig) == null ? void 0 : _a.backConfirm) {
        try {
          await index$3.ElMessageBox.confirm(
            props.pageHeaderConfig.backMessage || "确定要返回吗？",
            props.pageHeaderConfig.backTitle || "确认返回",
            {
              confirmButtonText: "确定",
              cancelButtonText: "取消",
              type: "warning",
              draggable: true,
              showClose: false
            }
          );
        } catch (error) {
          return;
        }
      }
      ctx.$router.go(-1);
    };
    const handleActionClick = (action) => {
      emit("action-click", action);
    };
    return (_ctx, _cache) => {
      var _a, _b, _c, _d, _e;
      const _component_el_button = index$2.ElButton;
      const _component_el_page_header = index.ElPageHeader;
      const _directive_fec_auth = Vue.resolveDirective("fec-auth");
      return ((_a = __props.pageHeaderConfig) == null ? void 0 : _a.enabled) && (Vue.unref(canBack) || ((_c = (_b = __props.pageHeaderConfig) == null ? void 0 : _b.actions) == null ? void 0 : _c.length) > 0) ? (Vue.openBlock(), Vue.createBlock(_component_el_page_header, {
        key: 0,
        icon: Vue.unref(canBack) ? Vue.unref(index$1.ArrowLeftBold) : null,
        onBack: handleBack,
        class: Vue.normalizeClass(["fec-header", { "can-not-back": !Vue.unref(canBack) }])
      }, Vue.createSlots({
        content: Vue.withCtx(() => {
          var _a2, _b2;
          return [
            Vue.createElementVNode("div", _hoisted_1, Vue.toDisplayString((_a2 = __props.pageHeaderConfig) == null ? void 0 : _a2.title), 1),
            Vue.createElementVNode("div", _hoisted_2, Vue.toDisplayString((_b2 = __props.pageHeaderConfig) == null ? void 0 : _b2.subTitle), 1)
          ];
        }),
        _: 2
      }, [
        ((_e = (_d = __props.pageHeaderConfig) == null ? void 0 : _d.actions) == null ? void 0 : _e.length) ? {
          name: "extra",
          fn: Vue.withCtx(() => {
            var _a2;
            return [
              (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList((_a2 = __props.pageHeaderConfig) == null ? void 0 : _a2.actions, (action) => {
                return Vue.withDirectives((Vue.openBlock(), Vue.createBlock(_component_el_button, {
                  key: action.id,
                  type: getButtonType(action.btnStyle),
                  onClick: ($event) => handleActionClick(action)
                }, {
                  default: Vue.withCtx(() => [
                    Vue.createTextVNode(Vue.toDisplayString(action.label), 1)
                  ]),
                  _: 2
                }, 1032, ["type", "onClick"])), [
                  [_directive_fec_auth, action.permission]
                ]);
              }), 128))
            ];
          }),
          key: "0"
        } : void 0
      ]), 1032, ["icon", "class"])) : Vue.createCommentVNode("", true);
    };
  }
};
const component = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-a55fc4ab"]]);
exports.default = component;
