"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../node_modules/element-plus/es/index.js");
;/* empty css                                                       */
;/* empty css                                                            */
const Vue = require("vue");
const index$1 = require("../../../node_modules/@element-plus/icons-vue/dist/index.js");
const useOnlyFlowDialog = require("../packages/event/useOnlyFlowDialog.js");
;/* empty css                          */
const _pluginVue_exportHelper = require("../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../node_modules/element-plus/es/components/button/index.js");
const index$2 = require("../../../node_modules/element-plus/es/components/icon/index.js");
const index$3 = require("../../../node_modules/element-plus/es/components/message-box/index.js");
const _hoisted_1 = { class: "condition-config-wrapper" };
const _hoisted_2 = {
  key: 0,
  class: "condition-desc"
};
const _sfc_main = {
  __name: "OnlyFLowConfigButton",
  props: {
    item: {
      type: Object,
      default: null
    },
    config: {
      type: Object,
      default: null
    },
    title: {
      type: String,
      default: "事件配置"
    },
    description: {
      type: String,
      default: ""
    },
    width: {
      type: String,
      default: "100%"
    },
    size: {
      type: String,
      default: "default"
    },
    onConfirm: Function
  },
  setup(__props) {
    const props = __props;
    const eventConfig = Vue.computed(() => {
      return props.config;
    });
    const { onlyFlowDialogVisible, openOnlyFlowDialog, OnlyFlowDialog } = useOnlyFlowDialog.useOnlyFlowDialog();
    const isConfigured = Vue.computed(() => {
      var _a;
      return eventConfig.value && ((_a = eventConfig.value.next) == null ? void 0 : _a.id) != "end";
    });
    const buttonText = Vue.computed(() => {
      return isConfigured.value ? `已设置事件` : "点击配置事件";
    });
    function eventConfirm(data) {
      props.onConfirm && props.onConfirm(data, props.item);
    }
    function handleDelete() {
      if (!isConfigured.value) {
        return;
      }
      index$3.ElMessageBox.confirm("确定要删除当前的事件配置吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        props.onConfirm && props.onConfirm(null, props.item);
      }).catch(() => {
      });
    }
    return (_ctx, _cache) => {
      const _component_Edit = Vue.resolveComponent("Edit");
      const _component_el_icon = index$2.ElIcon;
      const _component_el_button = index.ElButton;
      return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
        Vue.createElementVNode("div", _hoisted_1, [
          Vue.createVNode(_component_el_button, {
            style: Vue.normalizeStyle({ width: __props.width }),
            icon: Vue.unref(index$1.Setting),
            class: Vue.normalizeClass(["setting-btn", { "is-configured": Vue.unref(isConfigured) }]),
            onClick: Vue.unref(openOnlyFlowDialog),
            size: __props.size
          }, {
            default: Vue.withCtx(() => [
              Vue.createTextVNode(Vue.toDisplayString(Vue.unref(buttonText)) + " ", 1),
              Vue.createVNode(_component_el_icon, { class: "edit-btn" }, {
                default: Vue.withCtx(() => [
                  Vue.createVNode(_component_Edit)
                ]),
                _: 1
              }),
              Vue.createVNode(_component_el_icon, {
                class: "delete-btn",
                onClick: Vue.withModifiers(handleDelete, ["stop"])
              }, {
                default: Vue.withCtx(() => [
                  Vue.createVNode(Vue.unref(index$1.Delete))
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["style", "icon", "class", "onClick", "size"]),
          __props.description ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_2, Vue.toDisplayString(__props.description), 1)) : Vue.createCommentVNode("", true)
        ]),
        Vue.createVNode(Vue.unref(OnlyFlowDialog), {
          modelValue: Vue.unref(onlyFlowDialogVisible),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(onlyFlowDialogVisible) ? onlyFlowDialogVisible.value = $event : null),
          eventConfig: Vue.unref(eventConfig),
          onConfirm: eventConfirm,
          title: __props.title
        }, null, 8, ["modelValue", "eventConfig", "title"])
      ], 64);
    };
  }
};
const OnlyFLowConfigButton = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-b83e4b73"]]);
exports.default = OnlyFLowConfigButton;
