import{r as a}from"./index-DlNZgIG9.js";import{u as p}from"./ArtDesignApi-xMaPHw7i.js";const l="CONFIRMED";function N(s){const d=new Map;s.forEach(r=>(r.images||[]).forEach(n=>{if(n.roundNo==null)return;let t=d.get(n.roundNo);t||(t={roundNo:n.roundNo,total:0,approved:0,rejected:0,pending:0,reviewed:!1},d.set(n.roundNo,t)),t.total+=1,n.status==="APPROVED"?t.approved+=1:n.status==="REJECTED"?t.rejected+=1:t.pending+=1}));const u=Array.from(d.values()).sort((r,n)=>r.roundNo-n.roundNo);return u.forEach(r=>{r.reviewed=r.total>0&&r.pending===0}),u}function P(s,d){const{data:u=[],isLoading:r}=p(s,{skip:!s}),n=a.useMemo(()=>N(d),[d]);return a.useMemo(()=>{const t=e=>u.filter(o=>o.imagePathId!=null&&o.roundNo===e).map(o=>({id:o.id,imagePathId:o.imagePathId,publicUrl:o.publicUrl,fileName:o.fileName})),f=e=>u.find(o=>o.imagePathId==null&&o.roundNo===e&&o.source!==l),i=e=>u.find(o=>o.roundNo===e&&o.source===l),c=n.filter(e=>e.reviewed&&!i(e.roundNo)).map(e=>e.roundNo);return{rounds:n,proofsByRound:t,autoProofFor:f,confirmationFor:i,roundsAwaitingConfirmation:c,totalProofs:u.filter(e=>e.imagePathId!=null&&e.roundNo!=null).length,isLoading:r}},[u,n,r])}export{P as u};
