"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 useEventDialog = require("../packages/event/useEventDialog.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 _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 = Vue.computed(() => {
      return props.config;
    });
    const { eventDialogVisible, openEventDialog, EventDialog } = useEventDialog.useEventDialog();
    const isConfigured = Vue.computed(() => {
      return eventConfig.value && eventConfig.value.length > 0;
    });
    const buttonText = Vue.computed(() => {
      return isConfigured.value ? `已设置(${eventConfig.value.length})个事件` : "点击配置事件";
    });
    function eventConfirm(data) {
      props.onConfirm && props.onConfirm(data, props.item);
    }
    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(openEventDialog)
          }, {
            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
              })
            ]),
            _: 1
          }, 8, ["style", "icon", "class", "onClick"]),
          __props.description ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_2, Vue.toDisplayString(__props.description), 1)) : Vue.createCommentVNode("", true)
        ]),
        Vue.createVNode(Vue.unref(EventDialog), {
          modelValue: Vue.unref(eventDialogVisible),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => Vue.isRef(eventDialogVisible) ? eventDialogVisible.value = $event : null),
          eventConfig: Vue.unref(eventConfig),
          onConfirm: eventConfirm,
          title: __props.title
        }, null, 8, ["modelValue", "eventConfig", "title"])
      ], 64);
    };
  }
};
const EventConfigButton = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-db416ffc"]]);
exports.default = EventConfigButton;
