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, isRef } from "vue";
import { Setting as setting_default } from "../../../node_modules/@element-plus/icons-vue/dist/index.mjs";
import { useEventDialog } from "../packages/event/useEventDialog.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";
const _hoisted_1 = { class: "condition-config-wrapper" };
const _hoisted_2 = {
  key: 0,
  class: "condition-desc"
};
const _sfc_main = {
  __name: "EventConfigButton",
  props: {
    item: {
      type: Object,
      default: null
    },
    config: {
      type: Object,
      default: null
    },
    title: {
      type: String,
      default: "事件配置"
    },
    description: {
      type: String,
      default: ""
    },
    width: {
      type: String,
      default: "100%"
    },
    onConfirm: Function
  },
  setup(__props) {
    const props = __props;
    const eventConfig = computed(() => {
      return props.config;
    });
    const { eventDialogVisible, openEventDialog, EventDialog } = useEventDialog();
    const isConfigured = computed(() => {
      return eventConfig.value && eventConfig.value.length > 0;
    });
    const buttonText = computed(() => {
      return isConfigured.value ? `已设置(${eventConfig.value.length})个事件` : "点击配置事件";
    });
    function eventConfirm(data) {
      props.onConfirm && props.onConfirm(data, props.item);
    }
    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(openEventDialog)
          }, {
            default: withCtx(() => [
              createTextVNode(toDisplayString(unref(buttonText)) + " ", 1),
              createVNode(_component_el_icon, { class: "edit-btn" }, {
                default: withCtx(() => [
                  createVNode(_component_Edit)
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["style", "icon", "class", "onClick"]),
          __props.description ? (openBlock(), createElementBlock("div", _hoisted_2, toDisplayString(__props.description), 1)) : createCommentVNode("", true)
        ]),
        createVNode(unref(EventDialog), {
          modelValue: unref(eventDialogVisible),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(eventDialogVisible) ? eventDialogVisible.value = $event : null),
          eventConfig: unref(eventConfig),
          onConfirm: eventConfirm,
          title: __props.title
        }, null, 8, ["modelValue", "eventConfig", "title"])
      ], 64);
    };
  }
};
const EventConfigButton = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-db416ffc"]]);
export {
  EventConfigButton as default
};
