import{u as M,p as F,c as H,j as e,b as z,M as K}from"./index-C8aoN8t4.js";import{r as l}from"./vendor-ChGFRQAq.js";import{P as B}from"./PageHeader-D_F085dh.js";import{S as I}from"./StatCard-CgmwCM64.js";import{M as U}from"./ModernTable-DaMc_sWT.js";import{F as h,C as _,A as P,am as W,K as Y,V as O,bd as q,aE as G,an as b,b0 as X,ap as j,aq as y,ar as R,as as N,b1 as J,au as Q,av as Z,aw as ee,be as te,$ as ne,b3 as se,b4 as ae,Y as ie}from"./ui-wfmc48pO.js";import"./pdf-DdgWE7Gk.js";const ue=()=>{const{t:n}=M(),{employees:A,attendanceRecords:x}=F(),{theme:E}=H(),s=E.mode==="dark",[m,V]=l.useState("overview"),[c,w]=l.useState("week"),[p,k]=l.useState("all"),[u,$]=l.useState(""),f={backgroundColor:s?"#0f172a":"#ffffff",border:"none",borderRadius:"12px",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",fontSize:"12px",color:s?"#e2e8f0":"#334155"},d=l.useMemo(()=>{const t=new Date;return x.filter(a=>{const i=new Date(a.timestamp);let r=!0;return c==="today"?r=i.toDateString()===t.toDateString():c==="week"?r=i>=new Date(t.getTime()-7*24*60*60*1e3):c==="month"&&(r=i.getMonth()===t.getMonth()&&i.getFullYear()===t.getFullYear()),r&&(p==="all"||a.employeeId===p)&&(a.employeeName||"").toLowerCase().includes(u.toLowerCase())}).sort((a,i)=>new Date(i.timestamp).getTime()-new Date(a.timestamp).getTime())},[x,c,p,u]),o=l.useMemo(()=>{if(d.length===0)return{count:0,onTime:0,avgHours:0,late:0};const t=d.filter(r=>r.action==="clock_in"),a=t.filter(r=>new Date(r.timestamp).getHours()<9).length,i=t.length-a;return{count:d.length,onTime:t.length>0?a/t.length*100:100,late:t.length>0?i/t.length*100:0,avgHours:8.5}},[d]),v=l.useMemo(()=>{const t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],a={};return d.forEach(i=>{const r=t[new Date(i.timestamp).getDay()];a[r]=(a[r]||0)+1}),t.map(i=>({day:i,records:a[i]||0}))},[d]),D=[{name:n("attendance.charts.onTime"),value:o.onTime,color:"#10b981"},{name:n("attendance.charts.late"),value:o.late,color:"#f59e0b"},{name:n("attendance.charts.absent"),value:d.length===0?100:0,color:"#ef4444"}],T=()=>{const t=`${n("attendance.report.title")} - ${c} 

${n("attendance.report.generated")}: ${new Date().toLocaleString()} 

${n("attendance.report.summary")}: 
 - ${n("attendance.report.totalRecords")}: ${d.length} 
 - ${n("attendance.report.onTimeRate")}: ${o.onTime.toFixed(1)}%

${n("attendance.report.records")}: 
${d.map(g=>`${new Date(g.timestamp).toLocaleString()} - ${g.employeeName}: ${n("hr."+g.action.replace("_",""))}`).join(`
`)} `,a=new Blob([t],{type:"text/plain"}),i=URL.createObjectURL(a),r=document.createElement("a");r.href=i,r.download=`attendance-report - ${new Date().toISOString().split("T")[0]}.txt`,r.click(),URL.revokeObjectURL(i)},S=[{label:n("attendance.stats.totalRecords"),value:o.count,icon:h,gradient:"from-indigo-500 to-blue-600"},{label:n("attendance.stats.onTimeRate"),value:`${o.onTime.toFixed(0)}% `,icon:_,gradient:"from-emerald-500 to-teal-600"},{label:n("attendance.stats.lateRate"),value:`${o.late.toFixed(0)}% `,icon:P,gradient:"from-amber-500 to-orange-600"},{label:n("attendance.stats.avgHours"),value:`${o.avgHours} h`,icon:W,gradient:"from-violet-500 to-purple-600"}],C=[{key:"overview",label:n("attendance.tabs.overview"),icon:Y},{key:"detailed",label:n("attendance.tabs.detailed"),icon:h},{key:"analytics",label:n("attendance.tabs.analytics"),icon:O}],L=[{header:n("hr.employee"),accessor:"employeeName",render:t=>e.jsxDEV("div",{className:"flex items-center gap-3",children:[e.jsxDEV("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold ${s?"bg-indigo-900 text-indigo-300":"bg-indigo-100 text-indigo-700"} `,children:t.charAt(0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:105,columnNumber:11},void 0),e.jsxDEV("span",{className:"font-bold",children:t},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:108,columnNumber:11},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:104,columnNumber:9},void 0)},{header:n("hr.date"),accessor:"timestamp",render:t=>new Date(t).toLocaleDateString()},{header:n("attendance.table.time"),accessor:"timestamp",render:t=>new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},{header:n("attendance.table.action"),accessor:"action",render:t=>e.jsxDEV("span",{className:"capitalize",children:n(`hr.${t.replace("_","")} `)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:114,columnNumber:90},void 0)},{header:n("hr.status"),accessor:"id",render:(t,a)=>{const i=new Date(a.timestamp),r=a.action==="clock_in"&&i.getHours()>=9;return e.jsxDEV("span",{className:`inline-flex px-2 py-0.5 rounded-md text-xs font-bold uppercase ${r?s?"bg-amber-500/10 text-amber-400":"bg-amber-100 text-amber-700":s?"bg-emerald-500/10 text-emerald-400":"bg-emerald-100 text-emerald-700"} `,children:n(r?"attendance.table.late":"attendance.table.onTime")},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:120,columnNumber:11},void 0)}}];return e.jsxDEV("div",{className:"space-y-8 animate-fade-in pb-20",children:[e.jsxDEV(B,{title:n("attendance.reportsTitle"),subtitle:n("attendance.reportsSubtitle"),description:n("attendance.reportsDesc"),icon:q,gradient:"from-indigo-600 to-blue-600",action:e.jsxDEV(z,{onClick:T,icon:G,variant:"outline",size:"sm",children:n("attendance.exportReport")},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:140,columnNumber:11},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:133,columnNumber:7},void 0),e.jsxDEV("div",{className:"flex flex-col lg:flex-row justify-between items-start lg:items-center gap-4",children:[e.jsxDEV("div",{className:`p-1 rounded-xl flex ${s?"bg-slate-800":"bg-slate-100"} `,children:C.map(t=>{const a=t.icon,i=m===t.key;return e.jsxDEV("button",{onClick:()=>V(t.key),className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-bold transition-all ${i?"bg-white text-indigo-600 shadow-sm dark:bg-slate-700 dark:text-white":"text-slate-500 hover:text-slate-900 dark:text-slate-400 dark:hover:text-white"} `,children:[e.jsxDEV(a,{size:16},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:159,columnNumber:17},void 0),e.jsxDEV("span",{children:t.label},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:160,columnNumber:17},void 0)]},t.key,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:151,columnNumber:15},void 0)})},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:146,columnNumber:9},void 0),e.jsxDEV("div",{className:"flex gap-2 w-full lg:w-auto",children:[e.jsxDEV("select",{value:c,onChange:t=>w(t.target.value),className:`px-4 py-2 rounded-xl text-sm font-bold border outline-none cursor-pointer transition-colors ${s?"bg-slate-900 border-slate-700 text-white focus:border-indigo-500":"bg-white border-slate-200 text-slate-700 focus:border-indigo-500"} `,children:[e.jsxDEV("option",{value:"today",children:"Today"},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:175,columnNumber:13},void 0),e.jsxDEV("option",{value:"week",children:"This Week"},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:176,columnNumber:13},void 0),e.jsxDEV("option",{value:"month",children:"This Month"},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:177,columnNumber:13},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:167,columnNumber:11},void 0),e.jsxDEV("select",{value:p,onChange:t=>k(t.target.value),className:`px-4 py-2 rounded-xl text-sm font-bold border outline-none cursor-pointer transition-colors ${s?"bg-slate-900 border-slate-700 text-white focus:border-indigo-500":"bg-white border-slate-200 text-slate-700 focus:border-indigo-500"} `,children:[e.jsxDEV("option",{value:"all",children:"All Staff"},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:187,columnNumber:13},void 0),A.map(t=>e.jsxDEV("option",{value:t.id,children:t.name},t.id,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:188,columnNumber:35},void 0))]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:179,columnNumber:11},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:166,columnNumber:9},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:145,columnNumber:7},void 0),e.jsxDEV("div",{className:"min-h-[500px]",children:[m==="overview"&&e.jsxDEV("div",{className:"space-y-6",children:[e.jsxDEV("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:S.map((t,a)=>e.jsxDEV(I,{label:t.label,value:t.value,icon:t.icon,gradient:t.gradient},a,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:198,columnNumber:17},void 0))},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:196,columnNumber:13},void 0),e.jsxDEV("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxDEV("div",{className:`p-6 rounded-3xl border shadow-sm ${s?"bg-slate-900 border-slate-800":"bg-white border-slate-100"} `,children:[e.jsxDEV("h3",{className:`text-lg font-bold mb-6 ${s?"text-white":"text-slate-900"} `,children:n("attendance.charts.weeklyActivity")},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:204,columnNumber:17},void 0),e.jsxDEV("div",{className:"h-[300px]",children:e.jsxDEV(b,{width:"100%",height:"100%",children:e.jsxDEV(X,{data:v,children:[e.jsxDEV(j,{strokeDasharray:"3 3",vertical:!1,stroke:s?"#1e293b":"#f1f5f9"},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:208,columnNumber:23},void 0),e.jsxDEV(y,{dataKey:"day",axisLine:!1,tickLine:!1,tick:{fill:s?"#94a3b8":"#64748b"},dy:10},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:209,columnNumber:23},void 0),e.jsxDEV(R,{axisLine:!1,tickLine:!1,tick:{fill:s?"#94a3b8":"#64748b"}},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:210,columnNumber:23},void 0),e.jsxDEV(N,{contentStyle:f,cursor:{fill:s?"#334155":"#f8fafc"}},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:211,columnNumber:23},void 0),e.jsxDEV(J,{dataKey:"records",fill:"#6366f1",radius:[6,6,0,0],name:n("attendance.charts.scans"),barSize:32},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:212,columnNumber:23},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:207,columnNumber:21},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:206,columnNumber:19},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:205,columnNumber:17},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:203,columnNumber:15},void 0),e.jsxDEV("div",{className:`p-6 rounded-3xl border shadow-sm ${s?"bg-slate-900 border-slate-800":"bg-white border-slate-100"} `,children:[e.jsxDEV("h3",{className:`text-lg font-bold mb-6 ${s?"text-white":"text-slate-900"} `,children:n("attendance.charts.punctuality")},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:219,columnNumber:17},void 0),e.jsxDEV("div",{className:"h-[300px]",children:e.jsxDEV(b,{width:"100%",height:"100%",children:e.jsxDEV(Q,{children:[e.jsxDEV(Z,{data:D,cx:"50%",cy:"50%",innerRadius:80,outerRadius:110,paddingAngle:4,dataKey:"value",stroke:"none",children:D.map((t,a)=>e.jsxDEV(ee,{fill:t.color},a,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:224,columnNumber:63},void 0))},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:223,columnNumber:23},void 0),e.jsxDEV(N,{contentStyle:f},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:226,columnNumber:23},void 0),e.jsxDEV(te,{verticalAlign:"bottom",height:36,iconType:"circle"},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:227,columnNumber:23},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:222,columnNumber:21},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:221,columnNumber:19},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:220,columnNumber:17},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:218,columnNumber:15},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:202,columnNumber:13},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:195,columnNumber:11},void 0),m==="detailed"&&e.jsxDEV("div",{className:"space-y-6",children:[e.jsxDEV("div",{className:"w-full max-w-md",children:e.jsxDEV(K,{placeholder:"Search employee name...",value:u,onChange:t=>$(t.target.value),icon:ne},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:239,columnNumber:15},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:238,columnNumber:13},void 0),e.jsxDEV(U,{data:d,columns:L,keyField:"id",emptyMessage:"No attendance records found for this period."},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:247,columnNumber:13},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:237,columnNumber:11},void 0),m==="analytics"&&e.jsxDEV("div",{className:"space-y-6",children:[e.jsxDEV("div",{className:`p-6 rounded-3xl border shadow-sm ${s?"bg-slate-900 border-slate-800":"bg-white border-slate-100"} `,children:[e.jsxDEV("h3",{className:`text-lg font-bold mb-6 ${s?"text-white":"text-slate-900"} `,children:n("attendance.charts.trendAnalysis")},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:259,columnNumber:15},void 0),e.jsxDEV("div",{className:"h-[350px]",children:e.jsxDEV(b,{width:"100%",height:"100%",children:e.jsxDEV(se,{data:v,children:[e.jsxDEV(j,{strokeDasharray:"3 3",vertical:!1,stroke:s?"#1e293b":"#f1f5f9"},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:263,columnNumber:21},void 0),e.jsxDEV(y,{dataKey:"day",axisLine:!1,tickLine:!1,tick:{fill:s?"#94a3b8":"#64748b"},dy:10},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:264,columnNumber:21},void 0),e.jsxDEV(R,{axisLine:!1,tickLine:!1,tick:{fill:s?"#94a3b8":"#64748b"}},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:265,columnNumber:21},void 0),e.jsxDEV(N,{contentStyle:f},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:266,columnNumber:21},void 0),e.jsxDEV(ae,{type:"monotone",dataKey:"records",stroke:"#6366f1",strokeWidth:3,dot:{r:4,fill:"#6366f1",strokeWidth:2,stroke:"#fff"},activeDot:{r:6}},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:267,columnNumber:21},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:262,columnNumber:19},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:261,columnNumber:17},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:260,columnNumber:15},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:258,columnNumber:13},void 0),e.jsxDEV("div",{className:`p-6 rounded-3xl border ${s?"bg-indigo-900/10 border-indigo-500/20":"bg-indigo-50 border-indigo-100"} `,children:e.jsxDEV("div",{className:"flex gap-4",children:[e.jsxDEV("div",{className:`p-3 rounded-xl h-fit ${s?"bg-indigo-500/20 text-indigo-300":"bg-indigo-100 text-indigo-600"} `,children:e.jsxDEV(ie,{size:24},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:276,columnNumber:19},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:275,columnNumber:17},void 0),e.jsxDEV("div",{children:[e.jsxDEV("h4",{className:`text-lg font-bold mb-2 ${s?"text-indigo-300":"text-indigo-900"} `,children:n("attendance.security.biometricTitle")},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:279,columnNumber:19},void 0),e.jsxDEV("div",{className:`space-y - 1 text-sm ${s?"text-indigo-200/70":"text-indigo-800/70"} `,children:e.jsxDEV("p",{children:n("attendance.security.biometricDesc")},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:281,columnNumber:21},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:280,columnNumber:19},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:278,columnNumber:17},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:274,columnNumber:15},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:273,columnNumber:13},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:257,columnNumber:11},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:193,columnNumber:7},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/pages/admin/AttendanceReports.tsx",lineNumber:132,columnNumber:5},void 0)};export{ue as default};
