import { g as c } from "../.chunks/field-CyyFzM-Y.es.js";
const u = (t) => {
  const e = [];
  return Object.keys(t).forEach((s) => {
    const r = s, n = t[r];
    if (n === void 0) return;
    let a;
    r === "tags_ids" || r === "tags" ? N(r, e, n) : typeof n == "string" || typeof n == "number" || typeof n == "boolean" ? a = b(r, n) : (Array.isArray(n) || n instanceof Set) && (a = o(r, n)), a && e.push(a);
  }), e;
}, l = (t) => {
  let e = t, s = "EQUALS", r;
  switch ((t[1] === ":" || t[2] === ":") && ([r, e] = t.split(":")), r) {
    case ">":
      s = "GREATER_THAN", e = Number(e);
      break;
    case ">=":
      s = "GREATER_THAN_EQUALS", e = Number(e);
      break;
    case "<":
      s = "LESS_THAN", e = Number(e);
      break;
    case "<=":
      s = "LESS_THAN_EQUALS", e = Number(e);
      break;
    case "!=":
      s = "NOT_EQUALS", e.match(/^\d+$/) && (e = Number(e));
      break;
    case "%":
      s = "CONTAINS";
      break;
    case "!%":
      s = "DOES_NOT_CONTAIN";
      break;
    case "^":
      s = "STARTS_WITH";
      break;
    case "null":
      s = "IS_NULL";
      break;
    case "!null":
      s = "IS_NOT_NULL";
      break;
    case "~":
      s = "REGEXP";
      break;
    case "!~":
      s = "NOT_REGEXP";
      break;
  }
  return { value: e, operator: s };
}, N = (t, e, s) => {
  const r = [], n = [];
  s.forEach((a) => {
    a[0] === "-" ? n.push(a.substring(1)) : r.push(a);
  }), r.length && e.push(c(t, "IN", r)), n.length && e.push(c(t, "NOT_IN", n));
}, b = (t, e) => {
  let s = e, r = "EQUALS";
  return typeof e == "string" && ({ value: s, operator: r } = l(e)), typeof s == "boolean" && (s = s ? 1 : 0), c(t, r, [s]);
}, o = (t, e) => c(t, "IN", Array.isArray(e) ? e : [...e]);
export {
  o as genFilterIn,
  b as genFilterPrimitive,
  u as genFilters,
  N as pushFilterTagsIds
};
//# sourceMappingURL=additional.js.map
