import{i as e,n as t,t as n}from"./jsx-runtime-bzQ4Vb5N.js";import{t as r}from"./link-HXBcj0tw.js";import{t as i}from"./page-header-CqpDR1d0.js";import{t as a}from"./utils-B6KiDbIe.js";import{n as o,t as s}from"./card-2XLQ4Sqm.js";import{l as c,r as l}from"./dist-ex3CQT46.js";import{a as u,i as d,n as f,r as p,t as m}from"./select-Brl3xHTL.js";import{t as h}from"./building-2-C36hfAPr.js";import{t as g}from"./chevron-right-BYJJVHf4.js";import{n as _,t as v}from"./calculations-Djz1Ahac.js";import{n as y}from"./fy-nH1xvncr.js";import{n as b,t as x}from"./aen-hooks-BIg43l8E.js";var S=e(t(),1),C=n(),w=`Progress`,T=100,[E,D]=c(w),[O,k]=E(w),A=S.forwardRef((e,t)=>{let{__scopeProgress:n,value:r=null,max:i,getValueLabel:a=N,...o}=e;(i||i===0)&&!I(i)&&console.error(R(`${i}`,`Progress`));let s=I(i)?i:T;r!==null&&!L(r,s)&&console.error(z(`${r}`,`Progress`));let c=L(r,s)?r:null,u=F(c)?a(c,s):void 0;return(0,C.jsx)(O,{scope:n,value:c,max:s,children:(0,C.jsx)(l.div,{"aria-valuemax":s,"aria-valuemin":0,"aria-valuenow":F(c)?c:void 0,"aria-valuetext":u,role:`progressbar`,"data-state":P(c,s),"data-value":c??void 0,"data-max":s,...o,ref:t})})});A.displayName=w;var j=`ProgressIndicator`,M=S.forwardRef((e,t)=>{let{__scopeProgress:n,...r}=e,i=k(j,n);return(0,C.jsx)(l.div,{"data-state":P(i.value,i.max),"data-value":i.value??void 0,"data-max":i.max,...r,ref:t})});M.displayName=j;function N(e,t){return`${Math.round(e/t*100)}%`}function P(e,t){return e==null?`indeterminate`:e===t?`complete`:`loading`}function F(e){return typeof e==`number`}function I(e){return F(e)&&!isNaN(e)&&e>0}function L(e,t){return F(e)&&!isNaN(e)&&e<=t&&e>=0}function R(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${T}\`.`}function z(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
  - a positive number
  - less than the value passed to \`max\` (or ${T} if no \`max\` prop is set)
  - \`null\` or \`undefined\` if the progress is indeterminate.

Defaulting to \`null\`.`}var B=A,V=M,H=S.forwardRef(({className:e,value:t,...n},r)=>(0,C.jsx)(B,{ref:r,className:a(`relative h-2 w-full overflow-hidden rounded-full bg-primary/20`,e),...n,children:(0,C.jsx)(V,{className:`h-full w-full flex-1 bg-primary transition-all`,style:{transform:`translateX(-${100-(t||0)}%)`}})}));H.displayName=B.displayName;function U(){let{data:e=[]}=b(),{data:t=[]}=x(),n=new Date,[a,c]=(0,S.useState)(n.getMonth()+1),[l,w]=(0,S.useState)(n.getFullYear()),T=y(new Date(l,a-1,1)),E=(0,S.useMemo)(()=>v.map(n=>{let r=e.filter(e=>e.division===n).length,i=new Set(t.filter(e=>e.division===n&&e.month===a&&e.year===l).map(e=>e.aen)).size;return{division:n,total:r,uploaded:i,pending:Math.max(0,r-i),pct:r>0?Math.round(i/r*100):0}}),[e,t,a,l]);return(0,C.jsxs)(`div`,{className:`p-6 max-w-[1400px] mx-auto`,children:[(0,C.jsx)(i,{title:`Data Upload`,subtitle:`AEN-wise monthly upload dashboard · FY ${T}`,right:(0,C.jsxs)(`div`,{className:`flex gap-2`,children:[(0,C.jsxs)(m,{value:String(a),onValueChange:e=>c(Number(e)),children:[(0,C.jsx)(d,{className:`w-40`,children:(0,C.jsx)(u,{})}),(0,C.jsx)(f,{children:_.map(e=>(0,C.jsx)(p,{value:String(e.v),children:e.label},e.v))})]}),(0,C.jsxs)(m,{value:String(l),onValueChange:e=>w(Number(e)),children:[(0,C.jsx)(d,{className:`w-28`,children:(0,C.jsx)(u,{})}),(0,C.jsx)(f,{children:[l+1,l,l-1,l-2].map(e=>(0,C.jsx)(p,{value:String(e),children:e},e))})]})]})}),(0,C.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-4`,children:E.map(e=>(0,C.jsx)(r,{to:`/upload/$division`,params:{division:e.division},className:`block group`,children:(0,C.jsx)(s,{className:`h-full transition hover:border-primary hover:shadow-md`,children:(0,C.jsxs)(o,{className:`p-5 space-y-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`grid h-11 w-11 place-items-center rounded-lg bg-primary/10 text-primary`,children:(0,C.jsx)(h,{className:`h-5 w-5`})}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`text-xs uppercase text-muted-foreground`,children:`Division`}),(0,C.jsx)(`div`,{className:`text-xl font-semibold`,children:e.division})]})]}),(0,C.jsx)(g,{className:`h-5 w-5 text-muted-foreground group-hover:text-primary`})]}),(0,C.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 text-center`,children:[(0,C.jsx)(W,{label:`Total AENs`,value:e.total}),(0,C.jsx)(W,{label:`Uploaded`,value:e.uploaded,tone:`success`}),(0,C.jsx)(W,{label:`Pending`,value:e.pending,tone:e.pending?`warning`:`muted`})]}),(0,C.jsxs)(`div`,{className:`space-y-1`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Completion`}),(0,C.jsxs)(`span`,{className:`font-medium`,children:[e.pct,`%`]})]}),(0,C.jsx)(H,{value:e.pct})]})]})})},e.division))})]})}function W({label:e,value:t,tone:n}){return(0,C.jsxs)(`div`,{className:`rounded-md border p-2`,children:[(0,C.jsx)(`div`,{className:`text-xl font-semibold ${n===`success`?`text-success`:n===`warning`?`text-warning`:`text-foreground`}`,children:t}),(0,C.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e})]})}export{U as component};