import { t as supabase } from "./client-_1GYITl-.mjs";
import { t as useQuery } from "../_libs/tanstack__react-query.mjs";
//#region node_modules/.nitro/vite/services/ssr/assets/aen-hooks-Bhg_u-Ij.js
function useDivisionAens(division) {
	return useQuery({
		queryKey: ["division_aens", division ?? "all"],
		queryFn: async () => {
			let q = supabase.from("division_aens").select("*").order("division").order("sort_order");
			if (division) q = q.eq("division", division);
			const { data, error } = await q;
			if (error) throw error;
			return data ?? [];
		}
	});
}
function useAenUploads(division, aen) {
	return useQuery({
		queryKey: [
			"aen_uploads",
			division ?? "all",
			aen ?? "all"
		],
		queryFn: async () => {
			let q = supabase.from("uploads").select("*").not("aen", "is", null).order("year", { ascending: false }).order("month", { ascending: false }).order("version", { ascending: false });
			if (division) q = q.eq("division", division);
			if (aen) q = q.eq("aen", aen);
			const { data, error } = await q;
			if (error) throw error;
			return data ?? [];
		}
	});
}
//#endregion
export { useDivisionAens as n, useAenUploads as t };
