import { useApiClient } from "./useApi.js";
import { c } from "react/compiler-runtime";
import { useQuery } from "@tanstack/react-query";
function getDocumentsCacheKey(e, i) {
	return [
		"documents",
		e,
		i
	];
}
function useFilterDocuments(a) {
	let o = c(15), { envKey: s, api: l } = useApiClient(), u;
	o[0] === a ? u = o[1] : (u = JSON.stringify({
		workflowId: a,
		isInvalidated: !1
	}), o[0] = a, o[1] = u);
	let d;
	o[2] === Symbol.for("react.memo_cache_sentinel") ? (d = JSON.stringify([{
		field: "index",
		order: "ASC"
	}]), o[2] = d) : d = o[2];
	let f;
	o[3] === u ? f = o[4] : (f = {
		filter: u,
		sortBy: d
	}, o[3] = u, o[4] = f);
	let p = f, m;
	o[5] !== s || o[6] !== a ? (m = getDocumentsCacheKey(s, a), o[5] = s, o[6] = a, o[7] = m) : m = o[7];
	let h;
	o[8] !== l || o[9] !== p ? (h = () => {
		if (!l) throw Error("API not available");
		return l.ApiV1DocumentsApi.documentControllerGetDocuments(p);
	}, o[8] = l, o[9] = p, o[10] = h) : h = o[10];
	let g = !!a, _;
	return o[11] !== m || o[12] !== h || o[13] !== g ? (_ = {
		queryKey: m,
		queryFn: h,
		enabled: g,
		select: _temp2
	}, o[11] = m, o[12] = h, o[13] = g, o[14] = _) : _ = o[14], useQuery(_);
}
function _temp2(e) {
	return e.data.data;
}
export { getDocumentsCacheKey, useFilterDocuments };
