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 { useAdvancedFilterDialog } from "../packages/advancedFilter/useAdvancedFilterDialog.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: "ConditionConfigButton",
  props: {
    condition: {
      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 filterConfig = computed(() => {
      return props.condition;
    });
    const {
      advancedFilterDialogVisible,
      openAdvancedFilterDialog,
      AdvancedFilterDialog
    } = useAdvancedFilterDialog();
    const isConfigured = computed(() => {
      var _a, _b;
      if (!props.condition) return false;
      const conditionsLength = ((_a = props.condition.conditions) == null ? void 0 : _a.length) || 0;
      const groupsLength = ((_b = props.condition.groups) == null ? void 0 : _b.length) || 0;
      return conditionsLength + groupsLength > 0;
    });
    const buttonText = computed(() => {
      var _a, _b;
      if (!props.condition) return "点击配置条件";
      const conditionsLength = ((_a = props.condition.conditions) == null ? void 0 : _a.length) || 0;
      const groupsLength = ((_b = props.condition.groups) == null ? void 0 : _b.length) || 0;
      const totalCount = conditionsLength + groupsLength;
      return totalCount > 0 ? `已设置(${totalCount})个条件` : "点击配置条件";
    });
    function advancedConfirm(data) {
      props.onConfirm && props.onConfirm(data);
    }
    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(openAdvancedFilterDialog)
          }, {
            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(AdvancedFilterDialog), {
          modelValue: unref(advancedFilterDialogVisible),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(advancedFilterDialogVisible) ? advancedFilterDialogVisible.value = $event : null),
          filterConfig: unref(filterConfig),
          onConfirm: advancedConfirm,
          title: __props.title
        }, null, 8, ["modelValue", "filterConfig", "title"])
      ], 64);
    };
  }
};
const ConditionConfigButton = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-24627e56"]]);
export {
  ConditionConfigButton as default
};
