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