var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/dataSourceComponents/fields/utils.ts
var utils_exports = {};
__export(utils_exports, {
  formFieldFilterFuncMap: () => formFieldFilterFuncMap
});
module.exports = __toCommonJS(utils_exports);
var import_utils = require("@pisell/utils");
var formFieldFilterFuncMap = {
  // @ts-ignore
  Checkbox: (value) => {
    const key = value ? "$isTruly" : "$isFalsy";
    return {
      [key]: true
    };
  },
  ColorPicker: (value) => {
    return {
      $eq: value
    };
  },
  DatePicker: (value) => {
    const [start, end] = value;
    if (!start || !end) {
      return null;
    }
    const startDate = (0, import_utils.isString)(start) ? start : start.format("YYYY-MM-DD HH:mm:ss");
    const endDate = (0, import_utils.isString)(end) ? end : end.format("YYYY-MM-DD HH:mm:ss");
    return {
      $and: [
        {
          $dateAfter: startDate
        },
        {
          $dateBefore: endDate
        }
      ]
    };
  },
  Input: (value) => {
    return {
      $includes: value
    };
  },
  Radio: (value) => {
    return {
      $eq: value
    };
  },
  Select: (value, field) => {
    const key = field.type === "string" ? "$in" : "$anyOf";
    const formatValue = Array.isArray(value) ? value : [value];
    return {
      [key]: formatValue
    };
  },
  Percent: (value) => {
    return {
      $eq: value
    };
  },
  InputNumber: (value) => {
    return {
      $eq: value
    };
  },
  TimePicker: (value) => {
    return {
      $eq: value
    };
  },
  "Input.TextArea": (value) => {
    return {
      $includes: value
    };
  },
  "Input.JSON": (value) => {
    return {
      $includes: value
    };
  },
  "Input.URL": (value) => {
    return {
      $includes: value
    };
  },
  "Input.Password": (value) => {
    return {
      $includes: value
    };
  },
  DateRangePicker: (value) => {
    const [start, end] = value;
    const startDate = (0, import_utils.isString)(start) ? start : start.format("YYYY-MM-DD HH:mm:ss");
    const endDate = (0, import_utils.isString)(end) ? end : end.format("YYYY-MM-DD HH:mm:ss");
    return {
      $and: [
        {
          $dateAfter: startDate
        },
        {
          $dateBefore: endDate
        }
      ]
    };
  },
  "Radio.Group": (value) => {
    const formatValue = Array.isArray(value) ? value : [value];
    return {
      $in: formatValue
    };
  },
  "Checkbox.Group": (value) => {
    const formatValue = Array.isArray(value) ? value : [value];
    return {
      $anyOf: formatValue
    };
  }
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formFieldFilterFuncMap
});
