import{t as e}from"./useQuery-Dt4yOFcF.js";import{x as t}from"./index-t_-MMk0R.js";function n(){return e({queryKey:[`items`],queryFn:async()=>{let{data:e,error:n}=await t.from(`items_master`).select(`*`).order(`sort_order`);if(n)throw n;return e??[]}})}function r(){return e({queryKey:[`uploads`],queryFn:async()=>{let{data:e,error:n}=await t.from(`uploads`).select(`*`).order(`year`,{ascending:!1}).order(`month`,{ascending:!1});if(n)throw n;return e??[]}})}function i(){let{data:e,...t}=r(),n=new Map;return(e??[]).forEach(e=>{n.has(e.division)||n.set(e.division,{division:e.division,month:e.month,year:e.year})}),{data:Array.from(n.values()),...t}}function a(n=`AEN`){let{data:r}=i();return e({queryKey:[`facts-latest`,n,r.map(e=>`${e.division}-${e.year}-${e.month}`).join(`|`)],enabled:r.length>0,queryFn:async()=>{let e=[];for(let i of r){let{data:r,error:a}=await t.from(`fact_progress`).select(`*`).eq(`division`,i.division).eq(`month`,i.month).eq(`year`,i.year).eq(`level`,n);if(a)throw a;e.push(...r??[])}return e}})}function o(n){return e({queryKey:[`facts`,n],enabled:!!n,queryFn:async()=>{let{data:e,error:r}=await t.from(`fact_progress`).select(`*`).eq(`upload_id`,n).order(`aen`).order(`sse`,{nullsFirst:!0}).order(`item_sr_no`);if(r)throw r;return e??[]}})}export{r as i,n,a as r,o as t};