import { jsxs as g, jsx as s } from "react/jsx-runtime";
import F from "react";
import { connect as I } from "react-redux";
import { Container as h, Icon as N } from "semantic-ui-react";
import { applyFilter as b, cleanFilter as A } from "../reducers/data.js";
const C = (n) => {
  const {
    appliedFilters: r,
    initialFilters: e,
    "data-group": t,
    onClean: d,
    onApply: u,
    "data-app": p = "csv",
    "data-reset-label": m = "Reset All Filters"
  } = n, f = F.useMemo(() => Object.keys(e).some((i) => {
    const a = e[i], l = (r[i] || []).filter((o) => o !== Number.MIN_SAFE_INTEGER);
    if (l.length === 0)
      return !1;
    if (a.length === 1 && a[0] === Number.MIN_SAFE_INTEGER && l.length > 0)
      return !0;
    const c = a.length !== l.length && !a.every((o) => l.includes(o));
    return console.log("res", c), c;
  }), [e, r]);
  return /* @__PURE__ */ g(
    h,
    {
      fluid: !0,
      className: `data-filters-reset ignore ${f ? "" : "disabled"}`,
      onClick: (i) => {
        d({ app: p, group: t }), u({ app: p, group: t });
      },
      children: [
        /* @__PURE__ */ s("span", { children: m }),
        /* @__PURE__ */ s("span", { children: /* @__PURE__ */ s(N, { name: "undo alternate", className: "custom-undo-icon" }) })
      ]
    }
  );
}, E = (n, r) => {
  const {
    "data-group": e,
    "data-app": t = "csv"
  } = r;
  return {
    appliedFilters: n.getIn(["data", "filters", t, e]) ? n.getIn(["data", "filters", t, e]).toJS() : {},
    initialFilters: n.getIn(["data", "filters", "initial", t, e]) ? n.getIn(["data", "filters", "initial", t, e]).toJS() : {}
  };
}, y = {
  onClean: A,
  onApply: b
}, M = I(E, y)(C);
export {
  M as default
};
