import { useMemo as f } from "react";
import { useTableContext as p } from "../context/index.js";
import "../../../context/index.js";
import "react/jsx-runtime";
const v = {
  ">": "major",
  ">=": "major",
  "<": "minor",
  "<=": "minor"
}, y = (s) => {
  const [e, m] = p((r) => r.pagination), c = (r) => {
    const n = e == null ? void 0 : e.filt, o = r.map((t) => t.param), l = r.filter((t) => !!t.value);
    if (n) {
      let t = [...n].filter((i) => !o.includes(i.param));
      t = [...t, ...l];
      const u = t.length > 0 ? t : void 0;
      m((i) => {
        i.pagination.filt = u;
      });
      return;
    }
    const a = l.length > 0 ? l : void 0;
    m((t) => {
      t.pagination = {
        ...t.pagination,
        filt: a
      };
    });
  };
  return { currentValue: f(() => {
    var o;
    const r = (o = e == null ? void 0 : e.filt) == null ? void 0 : o.filter((l) => l.param === s);
    let n = {};
    if (r && r.length)
      for (const l of r) {
        let a = v[l.signal];
        n[a] = l.value ?? "";
      }
    return n;
  }, [e == null ? void 0 : e.filt, s]), intervalSetFilter: c };
};
export {
  y as useGetIntervalFilterByParam
};
