import { jsx as f } from "react/jsx-runtime";
import u from "react";
import { connect as h } from "react-redux";
import { injectIntl as D } from "react-intl";
import "semantic-ui-react";
import { DataContext as S } from "../data/DataContext.js";
import { getData as I, setData as J } from "../reducers/data.js";
class v extends u.Component {
  constructor(t) {
    super(t), this.debounces = [];
  }
  componentDidMount() {
    const { app: t, useAncestor: e, parent: s, source: r, store: a, params: i, csv: d, group: n, editing: l, waitForFilters: p = !1 } = this.props;
    this.props.onLoadData({ app: t, source: r, store: a, params: i, group: n });
  }
  componentDidUpdate(t, e, s) {
    const { app: r, filters: a, useAncestor: i, parent: d, source: n, store: l, params: p, csv: c, group: g, editing: x } = this.props;
    (a != t.filters || JSON.stringify(p) != JSON.stringify(t.params) || r != t.app || JSON.stringify(t.source) != JSON.stringify(n) || c != t.csv) && this.props.onLoadData({ app: r, source: n, store: l, params: p, group: g });
  }
  componentWillUnmount() {
  }
  render() {
    const { data: t, style: e, loading: s, time: r, error: a, editing: i } = this.props;
    return /* @__PURE__ */ f(S.Provider, { value: t, children: this.props.children });
  }
}
const m = (o, t, e) => {
  const s = [t], r = o.getIn(["data", "filters-settings", e]) ? o.getIn(["data", "filters-settings", e]).toJS() : null;
  if (r) {
    const a = r[t];
    a && a.parent && s.push(...m(o, a.parent, e));
  }
  return s;
}, y = (o, t) => {
  const { store: e, readGroup: s, app: r, blockName: a, params: i, parent: d } = t;
  let n = { ...i };
  return d && m(o, d, r).forEach((p) => {
    const c = o.getIn(["data", "filters", r, p]);
    c && c.size > 0 && (n = { ...n, ...c.toJS() });
  }), {
    params: n,
    data: o.getIn(["data", ...e, "data"]),
    filters: o.getIn(["data", "filters", r, s]),
    error: o.getIn(["data", ...e, "error"]),
    loading: o.getIn(["data", ...e, "loading"])
  };
}, N = {
  onSetData: J,
  onLoadData: I
}, w = h(y, N)(D(v));
export {
  w as default
};
