import { ref, watch, computed, createBlock, openBlock, unref } from "vue";
import AdvancedFilter from "./AdvancedFilter.vue2.mjs";
import { getEditConfigDataFields, getEditConfigData } from "../utils/common.mjs";
const _sfc_main = {
  __name: "index",
  props: {
    filterConfigData: {
      type: Object,
      default: () => ({})
    }
  },
  setup(__props) {
    const props = __props;
    const filterConfigData = ref(
      props.filterConfigData || { operator: "and", conditions: [], groups: [] }
    );
    watch(
      () => props.filterConfigData,
      (newVal) => {
        if (newVal) {
          filterConfigData.value = newVal;
        }
      },
      { immediate: true, deep: true }
    );
    const fieldsData = computed(() => {
      return getEditConfigDataFields();
    });
    computed(() => {
      const editConfigData = getEditConfigData();
      return (editConfigData == null ? void 0 : editConfigData.hiddenFields) || [];
    });
    const fields = computed(() => {
      const formFields = fieldsData.value.map((item) => ({
        ...item,
        type: converFieldType(item.fieldType),
        value: "",
        options: item.options || [],
        isHidden: false
      }));
      return formFields;
    });
    function converFieldType(fieldType) {
      switch (fieldType) {
        case "text":
          return "input";
        case "radio":
        case "checkbox":
        case "multipleSelection":
          return "select";
        case "switch":
          return "boolean";
        default:
          return fieldType;
      }
    }
    return (_ctx, _cache) => {
      return openBlock(), createBlock(AdvancedFilter, {
        modelValue: props.filterConfigData,
        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => props.filterConfigData = $event),
        filterFields: unref(fields)
      }, null, 8, ["modelValue", "filterFields"]);
    };
  }
};
export {
  _sfc_main as default
};
