import { useCallback as h } from "react";
import { useEnvironment as A } from "@m4l/core";
import { filterFieldsGenerator as C } from "../helpers/Fields/filterFields.js";
import { useDynamicFilterAndSort as S } from "../../../hooks/useDynamicFilterAndSort/useDynamicFilterAndSort.js";
import { getRawFiltersForNetwork as n } from "../../DynamicFilter/helpers/getRawFiltersForNetwork.js";
function b(l) {
  const { setBackendQueryParams: e, Refresh: r, otherApp: t = !1, resourceTypeId: s, resourceSerialId: o } = l, { host_static_assets: a, environment_assets: f } = A(), c = h((F) => {
    const p = [...[
      {
        n: "resourceTypeId",
        o: "c",
        o1: s,
        ft: "string"
      },
      {
        n: "resourceSerialId",
        o: "c",
        o1: o,
        ft: "string"
      }
    ], ...F.eventFilters?.rawFilters || []];
    e(t ? {
      f: n(p, "snakeCase")
    } : (i) => ({
      ...i,
      f: n(i.eventFilters?.rawFilters || [], "snakeCase")
    })), r();
  }, [r, e, t, s, o]), { leftActions: d, visibleCustomHeader: m, customHeaderComponent: u } = S({
    onChangeFilterSort: c,
    fields: C(`${a}/${f}`, t),
    withAllField: !0,
    visibleRefresh: !0,
    filterSortAutomatic: !1
  });
  return {
    leftActions: d,
    visibleCustomHeader: m,
    customHeaderComponent: u
  };
}
export {
  b as useFilterAndSort
};
