import{j as e,u as q,b as B,a as I}from"./query-PJ0ZdjbV.js";import{f as vs,a as D,O as Ns,k as bs,u as ae,l as as}from"./vendor-CWhr2lg4.js";import{a2 as Le,b0 as ns,bY as ee,T as Te,b_ as rs,aC as Fe,a as ve,U as pe,a5 as is,bf as ws,ap as fe,p as b,a4 as A,d as g,h as j,e as M,f as E,B as N,bV as ls,bW as _s,bX as cs,al as qe,P as te,aa as ne,ab as re,ac as ie,ad as le,ae as ce,q as C,s as K,t as Q,v as Y,w as H,x as T,y as Ss,I as se,af as oe,r as he,a8 as os,b as ds,a9 as ks,ar as Cs,au as As,aL as Ps,z as Ds,ck as qs,cl as Ls,cm as Ts,ba as Fs,bb as Rs,bc as ye,bd as $s,aq as Ms,bx as He}from"./index-BSPIaiZU.js";import{L as Es}from"./layout-dashboard-pgzECxsO.js";import{F as Ne}from"./file-pen-BsSJrcIJ.js";import{F as be}from"./file-text-BeBoTfpI.js";import{D as Re}from"./dollar-sign-yf9aN9ug.js";import{R as Bs}from"./receipt-CEyVv6aR.js";import{A as we}from"./award-BB4qCp8n.js";import{B as xe}from"./briefcase-ChU_EMgZ.js";import{N as ze}from"./network-BrXvPFyD.js";import{B as _}from"./badge-C34iUAiA.js";import{P}from"./page-header-D8tSLbK0.js";import{A as Is}from"./arrow-right-Bmt6JCm_.js";import{M as ms}from"./mail-Bu7DITgC.js";import{P as De}from"./phone-BsfOydnt.js";import{C as Ge}from"./calendar-BZ611BSN.js";import{H as Oe}from"./heart-polFWSKf.js";import{S as Me}from"./shield-7SCLx_iT.js";import{B as Ue}from"./building-2-boIK6K2k.js";import{M as Z}from"./map-pin-BhdxZDWP.js";import{u as J,t as W,o as V,g as xs,s as $,e as ue,b as us,f as Vs,c as zs}from"./date-range-picker-BB0TgAn8.js";import{D as X}from"./data-table-D_-xOEqd.js";import{u as de}from"./use-data-table-state-CKRg6qY2.js";import{A as Ke}from"./arrow-left-CtkbIigo.js";import{S as ps}from"./send-hExJQKXK.js";import{E as Gs}from"./employee-select-DtUobKxP.js";import{S as Os}from"./star-DLH_J9Ff.js";import{C as Je}from"./circle-check-Dgh1V3VA.js";import{N as Us}from"./payroll.api-CdAqb0T2.js";import{C as Ks}from"./calendar-check-BOVhup94.js";import{T as Qs}from"./trending-down-BqIHipUb.js";import{T as Ys}from"./timer-MJ1USQfz.js";import{C as Hs}from"./chart-column-DbfNf7gS.js";import{S as U}from"./skeleton-CfUgaIb_.js";import"./ui-aO-W1bxx.js";import"./chevron-left-DLFf1YD2.js";import"./core-hr.api-MChaGqvv.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Js=Le("CalendarX",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"m14 14-4 4",key:"rymu2i"}],["path",{d:"m10 14 4 4",key:"3sz06r"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ws=Le("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Qe=Le("Megaphone",[["path",{d:"m3 11 18-5v12L3 14v-3z",key:"n962bs"}],["path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6",key:"1yl0tm"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Xs=Le("Pin",[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]),Zs=[{heading:"Overview",items:[{to:"/ess",label:"Dashboard",description:"Self-service portal",icon:Es,permission:["ess","dashboard","read"]},{to:"/ess/my-profile",label:"My Profile",description:"View your details",icon:ee,permission:["ess","profile","read"]},{to:"/ess/announcements",label:"Announcements",description:"Company updates",icon:Qe,permission:["ess","announcement","read"]}]},{heading:"Requests",items:[{to:"/ess/profile-updates",label:"Profile Updates",description:"Request changes",icon:Ne,permission:["ess","profile_update","read"]},{to:"/ess/document-requests",label:"Documents",description:"Request documents",icon:be,permission:["ess","document_request","read"]},{to:"/ess/grievances",label:"Grievances",description:"Submit concerns",icon:Te,permission:["ess","grievance","read"]},{to:"/ess/salary-queries",label:"Salary Queries",description:"Payslip queries",icon:Re,permission:["ess","salary_query","read"]},{to:"/ess/declarations",label:"IT Declarations",description:"Tax investments",icon:rs,permission:["ess","declaration","read"]}]},{heading:"My Info",items:[{to:"/ess/my-leave-balance",label:"Leave Balance",description:"Leave overview",icon:Fe,permission:["ess","leave_balance","read"]},{to:"/ess/my-attendance",label:"Attendance",description:"Attendance summary",icon:ve,permission:["ess","attendance","read"]},{to:"/ess/my-payslips",label:"Payslips",description:"View payslips",icon:Bs,permission:["ess","payslip","read"]}]},{heading:"Community",items:[{to:"/ess/recognitions",label:"Recognitions",description:"Peer appreciation",icon:we,permission:["ess","recognition","read"]},{to:"/ess/job-postings",label:"Job Postings",description:"Internal openings",icon:xe,permission:["ess","job_posting","read"]},{to:"/ess/team-directory",label:"Team Directory",description:"Browse colleagues",icon:pe,permission:["ess","team_directory","read"]},{to:"/ess/org-chart",label:"Org Chart",description:"Reporting structure",icon:ze,permission:["ess","org_chart","read"]},{to:"/ess/notifications",label:"Notifications",description:"Alerts & updates",icon:is,permission:["ess","notification","read"]}]}];function et({item:s,isActive:t}){const a=s.icon;return e.jsxs(bs,{to:s.to,end:s.to==="/ess",className:fe("group relative flex items-center gap-3 rounded-lg px-3 py-2.5 transition-all duration-150",t?"bg-primary-subtle/70":"hover:bg-slate-50"),children:[t&&e.jsx("span",{className:"absolute left-0 top-2.5 bottom-2.5 w-[3px] rounded-r-full bg-primary"}),e.jsx("div",{className:fe("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors duration-150",t?"bg-primary/10 text-primary":"bg-slate-100 text-slate-400 group-hover:bg-slate-200/70 group-hover:text-slate-500"),children:e.jsx(a,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:fe("block text-[13px] truncate leading-tight",t?"font-medium text-primary":"font-medium text-slate-700 group-hover:text-slate-900"),children:s.label}),e.jsx("span",{className:fe("block text-[11px] truncate leading-tight mt-0.5",t?"text-primary/60":"text-slate-400"),children:s.description})]})]})}function rn(){const s=vs(),t=D.useRef(null),{hasPermission:a}=ns();D.useEffect(()=>{var r;(r=t.current)==null||r.scrollTo(0,0)},[s.pathname]);const d=D.useMemo(()=>Zs.map(r=>({...r,items:r.items.filter(i=>a(i.permission[0],i.permission[1],i.permission[2]))})).filter(r=>r.items.length>0),[a]);return e.jsxs("div",{className:"-m-6 flex h-[calc(100%+48px)]",children:[e.jsxs("aside",{className:"w-[260px] shrink-0 border-r border-slate-200/60 bg-white flex flex-col",children:[e.jsxs("div",{className:"shrink-0 px-5 pt-6 pb-4 border-b border-slate-100",children:[e.jsx("h1",{className:"text-[15px] font-semibold text-slate-900 tracking-tight",children:"Self Service"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-slate-400",children:"Profile, requests & community"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-3 py-3 scrollbar-thin",children:d.map((r,i)=>e.jsxs("div",{className:fe(i>0&&"mt-6"),children:[e.jsx("p",{className:"mb-2 px-3 text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400",children:r.heading}),e.jsx("div",{className:"space-y-0.5",children:r.items.map(c=>{const o=c.to==="/ess"?s.pathname==="/ess":ws(s.pathname,c.to);return e.jsx(et,{item:c,isActive:o},c.to)})})]},r.heading))})]}),e.jsx("main",{ref:t,className:"flex-1 min-w-0 overflow-y-auto bg-background scrollbar-thin",children:e.jsx("div",{className:"px-8 py-6 w-full",children:e.jsx(Ns,{})})})]})}const w="/ess",v={profileUpdates:["ess","profile-updates"],profileUpdate:s=>["ess","profile-updates",s],documentRequests:["ess","document-requests"],documentRequest:s=>["ess","document-requests",s],grievances:["ess","grievances"],grievance:s=>["ess","grievances",s],grievanceComments:s=>["ess","grievances",s,"comments"],salaryQueries:["ess","salary-queries"],salaryQuery:s=>["ess","salary-queries",s],recognitions:["ess","recognitions"],jobPostings:["ess","job-postings"],jobPosting:s=>["ess","job-postings",s],jobApplications:["ess","job-applications"],declarations:["ess","declarations"],declaration:s=>["ess","declarations",s],orgChart:["ess","org-chart"],notifications:["ess","notifications"],dashboard:["ess","dashboard"],myProfile:["ess","my-profile"],myLeaveBalance:["ess","my-leave-balance"],myAttendance:["ess","my-attendance"],myPayslips:["ess","my-payslips"],teamDirectory:["ess","team-directory"],announcements:["ess","announcements"]};function st(s){return q({queryKey:[...v.profileUpdates,s],queryFn:()=>b.get(`${w}/profile-updates/`,{params:s}).then(t=>t.data)})}function tt(){const s=B();return I({mutationFn:t=>b.post(`${w}/profile-updates/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.profileUpdates}),s.invalidateQueries({queryKey:v.dashboard}),A.success("Profile update request submitted")},onError:()=>A.error("Failed to submit profile update request")})}function at(s){return q({queryKey:[...v.documentRequests,s],queryFn:()=>b.get(`${w}/document-requests/`,{params:s}).then(t=>t.data)})}function nt(){const s=B();return I({mutationFn:t=>b.post(`${w}/document-requests/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.documentRequests}),s.invalidateQueries({queryKey:v.dashboard}),A.success("Document request submitted")},onError:()=>A.error("Failed to submit document request")})}function rt(s){return q({queryKey:[...v.grievances,s],queryFn:()=>b.get(`${w}/grievances/`,{params:s}).then(t=>t.data)})}function it(s){return q({queryKey:v.grievance(s),queryFn:()=>b.get(`${w}/grievances/${s}/`).then(t=>t.data),enabled:!!s})}function lt(){const s=B();return I({mutationFn:t=>b.post(`${w}/grievances/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.grievances}),s.invalidateQueries({queryKey:v.dashboard}),A.success("Grievance submitted successfully")},onError:()=>A.error("Failed to submit grievance")})}function ct(s){return q({queryKey:v.grievanceComments(s),queryFn:()=>b.get(`${w}/grievance-comments/`,{params:{grievance:s}}).then(t=>t.data),enabled:!!s})}function ot(){const s=B();return I({mutationFn:t=>b.post(`${w}/grievance-comments/`,t).then(a=>a.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:v.grievanceComments(a.grievance)}),A.success("Comment added")},onError:()=>A.error("Failed to add comment")})}function dt(s){return q({queryKey:[...v.salaryQueries,s],queryFn:()=>b.get(`${w}/salary-queries/`,{params:s}).then(t=>t.data)})}function mt(){const s=B();return I({mutationFn:t=>b.post(`${w}/salary-queries/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.salaryQueries}),s.invalidateQueries({queryKey:v.dashboard}),A.success("Salary query submitted")},onError:()=>A.error("Failed to submit salary query")})}function xt(s){return q({queryKey:[...v.recognitions,s],queryFn:()=>b.get(`${w}/recognitions/`,{params:s}).then(t=>t.data)})}function ut(){const s=B();return I({mutationFn:t=>b.post(`${w}/recognitions/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.recognitions}),s.invalidateQueries({queryKey:v.dashboard}),A.success("Recognition sent!")},onError:()=>A.error("Failed to send recognition")})}function pt(s){return q({queryKey:[...v.jobPostings,s],queryFn:()=>b.get(`${w}/job-postings/`,{params:s}).then(t=>t.data)})}function ht(s){return q({queryKey:v.jobPosting(s),queryFn:()=>b.get(`${w}/job-postings/${s}/`).then(t=>t.data),enabled:!!s})}function gt(s){return q({queryKey:[...v.jobApplications,s],queryFn:()=>b.get(`${w}/job-applications/`,{params:s}).then(t=>t.data)})}function jt(){const s=B();return I({mutationFn:t=>b.post(`${w}/job-applications/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.jobApplications}),s.invalidateQueries({queryKey:v.jobPostings}),A.success("Application submitted successfully")},onError:()=>A.error("Failed to submit application")})}function yt(){const s=B();return I({mutationFn:t=>b.post(`${w}/job-applications/${t}/withdraw/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.jobApplications}),s.invalidateQueries({queryKey:v.jobPostings}),A.success("Application withdrawn")},onError:()=>A.error("Failed to withdraw application")})}function ft(){return q({queryKey:v.dashboard,queryFn:()=>b.get(`${w}/dashboard/`).then(s=>s.data)})}function vt(){return q({queryKey:v.myProfile,queryFn:()=>b.get(`${w}/my-profile/`).then(s=>s.data)})}function hs(){return q({queryKey:v.myLeaveBalance,queryFn:()=>b.get(`${w}/my-leave-balance/`).then(s=>s.data)})}function gs(s){return q({queryKey:[...v.myAttendance,s],queryFn:()=>b.get(`${w}/my-attendance/`,{params:s}).then(t=>t.data)})}function Nt(s){return q({queryKey:[...v.myPayslips,s],queryFn:()=>b.get(`${w}/payslips/`,{params:s}).then(t=>t.data)})}function bt(s){return q({queryKey:[...v.teamDirectory,s],queryFn:()=>b.get(`${w}/team-directory/`,{params:s}).then(t=>t.data)})}function wt(s){return q({queryKey:[...v.announcements,s],queryFn:()=>b.get(`${w}/announcements/`,{params:s}).then(t=>t.data)})}function _t(s){return q({queryKey:[...v.declarations,s],queryFn:()=>b.get(`${w}/investment-declarations/`,{params:s}).then(t=>t.data)})}function St(){const s=B();return I({mutationFn:t=>b.post(`${w}/investment-declarations/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.declarations}),A.success("Declaration created")},onError:()=>A.error("Failed to create declaration")})}function kt(){const s=B();return I({mutationFn:({id:t,data:a})=>b.patch(`${w}/investment-declarations/${t}/`,a).then(d=>d.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.declarations}),A.success("Declaration updated")},onError:()=>A.error("Failed to update declaration")})}function Ct(){const s=B();return I({mutationFn:t=>b.post(`${w}/investment-declarations/submit/`,{id:t}).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:v.declarations}),A.success("Declaration submitted for verification")},onError:()=>A.error("Failed to submit declaration")})}function At(){return q({queryKey:v.orgChart,queryFn:()=>b.get(`${w}/org-chart/`).then(s=>s.data)})}const Pt=[{label:"Update Profile",icon:Ne,route:"/ess/profile-updates",color:"bg-blue-500/10 text-blue-500"},{label:"Request Document",icon:be,route:"/ess/document-requests",color:"bg-emerald-500/10 text-emerald-500"},{label:"File Grievance",icon:Te,route:"/ess/grievances",color:"bg-amber-500/10 text-amber-500"},{label:"Salary Query",icon:Re,route:"/ess/salary-queries",color:"bg-purple-500/10 text-purple-500"},{label:"Give Recognition",icon:we,route:"/ess/recognitions",color:"bg-pink-500/10 text-pink-500"},{label:"Job Postings",icon:xe,route:"/ess/job-postings",color:"bg-indigo-500/10 text-indigo-500"},{label:"Team Directory",icon:pe,route:"/ess/team-directory",color:"bg-teal-500/10 text-teal-500"},{label:"Announcements",icon:Qe,route:"/ess/announcements",color:"bg-orange-500/10 text-orange-500"}];function Dt(s){switch(s){case"profile_update":return Ne;case"document_request":return be;case"grievance":return Te;case"salary_query":return Re;case"recognition":return we;default:return ve}}function qt(s){switch(s){case"approved":case"resolved":case"ready":case"downloaded":return"success";case"pending":case"submitted":case"requested":case"open":case"investigating":return"warning";case"rejected":case"escalated":return"destructive";default:return"secondary"}}function ln(){const s=ae(),{data:t,isLoading:a}=ft(),{data:d,isLoading:r}=hs(),{data:i,isLoading:c}=gs(),o=t==null?void 0:t.stats,m=(t==null?void 0:t.recent_activity)??[],h=(t==null?void 0:t.announcements)??[],x=a||r||c;return e.jsxs("div",{children:[e.jsx(P,{title:"Self Service Portal",description:"Quick access to your profile, requests, and team information."}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"text-[14px] font-semibold text-slate-900 mb-3",children:"Quick Actions"}),e.jsx("div",{className:"grid grid-cols-4 gap-3",children:Pt.map(n=>{const l=n.icon;return e.jsxs("button",{onClick:()=>s(n.route),className:"flex items-center gap-3 rounded-xl border border-slate-200 bg-white px-4 py-3.5 text-left transition-all hover:shadow-sm hover:border-slate-300",children:[e.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${n.color}`,children:e.jsx(l,{className:"h-4.5 w-4.5"})}),e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:n.label})]},n.route)})})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[e.jsx(g,{children:e.jsx(j,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(Fe,{className:"h-4.5 w-4.5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Leave Balance"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:x?"...":(d==null?void 0:d.reduce((n,l)=>n+l.balance,0))??(o==null?void 0:o.leave_balance_total)??0})]})]})})}),e.jsx(g,{children:e.jsx(j,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-emerald-500/10",children:e.jsx(ve,{className:"h-4.5 w-4.5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Attendance"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:x?"...":`${(i==null?void 0:i.attendance_percentage)??(o==null?void 0:o.attendance_percentage)??0}%`})]})]})})}),e.jsx(g,{children:e.jsx(j,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-amber-500/10",children:e.jsx(Ne,{className:"h-4.5 w-4.5 text-amber-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Pending Requests"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:x?"...":((o==null?void 0:o.pending_profile_updates)??0)+((o==null?void 0:o.pending_document_requests)??0)+((o==null?void 0:o.open_grievances)??0)+((o==null?void 0:o.open_salary_queries)??0)})]})]})})}),e.jsx(g,{children:e.jsx(j,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-pink-500/10",children:e.jsx(we,{className:"h-4.5 w-4.5 text-pink-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Recognitions"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:x?"...":(o==null?void 0:o.recognitions_received)??0})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs(g,{children:[e.jsx(M,{className:"pb-3",children:e.jsx(E,{className:"text-[14px]",children:"Recent Activity"})}),e.jsx(j,{children:x?e.jsx("div",{className:"space-y-3",children:Array.from({length:4}).map((n,l)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"skeleton-shimmer h-8 w-8 rounded-lg"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-3/4 rounded mb-1"}),e.jsx("div",{className:"skeleton-shimmer h-3 w-1/2 rounded"})]})]},l))}):m.length===0?e.jsx("p",{className:"text-[13px] text-slate-400 py-6 text-center",children:"No recent activity."}):e.jsx("div",{className:"divide-y divide-slate-100",children:m.slice(0,6).map(n=>{const l=Dt(n.type);return e.jsxs("div",{className:"flex items-center gap-3 py-3",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-slate-100",children:e.jsx(l,{className:"h-3.5 w-3.5 text-slate-500"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700 truncate",children:n.title}),e.jsx("p",{className:"text-[11px] text-slate-400 truncate",children:n.description})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[n.status&&e.jsx(_,{variant:qt(n.status),className:"text-[10px]",children:n.status}),e.jsx("span",{className:"text-[10px] text-slate-400",children:new Date(n.timestamp).toLocaleDateString("en-GB",{day:"numeric",month:"short"})})]})]},n.id)})})})]}),e.jsxs(g,{children:[e.jsx(M,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(E,{className:"text-[14px]",children:"Announcements"}),e.jsxs(N,{variant:"ghost",size:"sm",onClick:()=>s("/ess/announcements"),children:["View All ",e.jsx(Is,{className:"ml-1 h-3.5 w-3.5"})]})]})}),e.jsx(j,{children:x?e.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((n,l)=>e.jsxs("div",{children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-3/4 rounded mb-1"}),e.jsx("div",{className:"skeleton-shimmer h-3 w-full rounded"})]},l))}):h.length===0?e.jsx("p",{className:"text-[13px] text-slate-400 py-6 text-center",children:"No announcements."}):e.jsx("div",{className:"divide-y divide-slate-100",children:h.slice(0,5).map(n=>e.jsxs("div",{className:"py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.is_pinned&&e.jsx(_,{variant:"default",className:"text-[10px] h-4 px-1.5",children:"Pinned"}),n.priority==="urgent"&&e.jsx(_,{variant:"destructive",className:"text-[10px] h-4 px-1.5",children:"Urgent"}),n.priority==="high"&&e.jsx(_,{variant:"warning",className:"text-[10px] h-4 px-1.5",children:"Important"}),e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:n.title})]}),e.jsx("p",{className:"text-[12px] text-slate-500 line-clamp-2",children:n.content}),e.jsxs("p",{className:"text-[10px] text-slate-400 mt-1",children:[new Date(n.published_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),n.author_name&&` by ${n.author_name}`]})]},n.id))})})]})]})]})}function k({icon:s,label:t,value:a}){return e.jsxs("div",{className:"flex items-start gap-3 py-2.5",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-slate-100",children:e.jsx(s,{className:"h-3.5 w-3.5 text-slate-400"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:t}),e.jsx("p",{className:"text-[13px] text-slate-700 mt-0.5",children:a||"--"})]})]})}function cn(){var r,i;const s=ae(),{data:t,isLoading:a}=vt(),d=t?`${((r=t.first_name)==null?void 0:r.charAt(0))??""}${((i=t.last_name)==null?void 0:i.charAt(0))??""}`:"";return e.jsxs("div",{children:[e.jsx(P,{title:"My Profile",description:"View your personal and employment details.",actions:e.jsxs(N,{size:"sm",onClick:()=>s("/ess/profile-updates"),children:[e.jsx(Ne,{className:"mr-1.5 h-3.5 w-3.5"}),"Request Update"]})}),a?e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{children:e.jsx(j,{className:"pt-6 pb-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"skeleton-shimmer h-16 w-16 rounded-full"}),e.jsxs("div",{children:[e.jsx("div",{className:"skeleton-shimmer h-5 w-40 rounded mb-2"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-56 rounded"})]})]})})}),Array.from({length:3}).map((c,o)=>e.jsx(g,{children:e.jsxs(j,{className:"pt-5 pb-4",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-32 rounded mb-4"}),Array.from({length:3}).map((m,h)=>e.jsx("div",{className:"skeleton-shimmer h-10 w-full rounded mb-2"},h))]})},o))]}):t?e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{children:e.jsx(j,{className:"pt-6 pb-5 px-6",children:e.jsxs("div",{className:"flex items-center gap-5",children:[e.jsxs(ls,{className:"h-16 w-16",children:[t.avatar&&e.jsx(_s,{src:t.avatar,alt:t.full_name}),e.jsx(cs,{className:"text-lg font-semibold bg-primary/10 text-primary",children:d})]}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-[18px] font-semibold text-slate-900",children:t.full_name}),e.jsxs("p",{className:"text-[13px] text-slate-500 mt-0.5",children:[t.designation_name??"No designation"," ",t.department_name?`- ${t.department_name}`:""]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[e.jsxs(_,{variant:"secondary",className:"text-[11px]",children:["ID: ",t.employee_id]}),t.employment_type&&e.jsx(_,{variant:"default",className:"text-[11px] capitalize",children:t.employment_type})]})]})]})})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs(g,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(E,{className:"text-[14px] flex items-center gap-2",children:[e.jsx(ee,{className:"h-4 w-4 text-slate-400"}),"Personal Information"]})}),e.jsx(j,{children:e.jsxs("div",{className:"divide-y divide-slate-100",children:[e.jsx(k,{icon:ms,label:"Email",value:t.email}),e.jsx(k,{icon:De,label:"Phone",value:t.phone}),e.jsx(k,{icon:Ge,label:"Date of Birth",value:t.date_of_birth}),e.jsx(k,{icon:ee,label:"Gender",value:t.gender}),e.jsx(k,{icon:Oe,label:"Marital Status",value:t.marital_status}),e.jsx(k,{icon:Me,label:"Blood Group",value:t.blood_group})]})})]}),e.jsxs(g,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(E,{className:"text-[14px] flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4 text-slate-400"}),"Employment Details"]})}),e.jsx(j,{children:e.jsxs("div",{className:"divide-y divide-slate-100",children:[e.jsx(k,{icon:Ue,label:"Department",value:t.department_name}),e.jsx(k,{icon:xe,label:"Designation",value:t.designation_name}),e.jsx(k,{icon:ee,label:"Reporting Manager",value:t.reporting_manager_name}),e.jsx(k,{icon:Ge,label:"Date of Joining",value:t.date_of_joining}),e.jsx(k,{icon:xe,label:"Employment Type",value:t.employment_type})]})})]}),e.jsxs(g,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(E,{className:"text-[14px] flex items-center gap-2",children:[e.jsx(Z,{className:"h-4 w-4 text-slate-400"}),"Address"]})}),e.jsx(j,{children:e.jsxs("div",{className:"divide-y divide-slate-100",children:[e.jsx(k,{icon:Z,label:"Address Line 1",value:t.address_line_1}),e.jsx(k,{icon:Z,label:"Address Line 2",value:t.address_line_2}),e.jsx(k,{icon:Z,label:"City",value:t.city}),e.jsx(k,{icon:Z,label:"State",value:t.state}),e.jsx(k,{icon:Z,label:"Country",value:t.country}),e.jsx(k,{icon:Z,label:"Postal Code",value:t.postal_code})]})})]}),e.jsxs(g,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(E,{className:"text-[14px] flex items-center gap-2",children:[e.jsx(De,{className:"h-4 w-4 text-slate-400"}),"Emergency Contact & Bank"]})}),e.jsxs(j,{children:[e.jsxs("div",{className:"divide-y divide-slate-100",children:[e.jsx(k,{icon:ee,label:"Emergency Contact",value:t.emergency_contact_name}),e.jsx(k,{icon:De,label:"Emergency Phone",value:t.emergency_contact_phone}),e.jsx(k,{icon:Oe,label:"Relationship",value:t.emergency_contact_relationship})]}),e.jsx(qe,{className:"my-3"}),e.jsxs("div",{className:"divide-y divide-slate-100",children:[e.jsx(k,{icon:Ue,label:"Bank Name",value:t.bank_name}),e.jsx(k,{icon:Me,label:"Account Number",value:t.bank_account_number?"****"+t.bank_account_number.slice(-4):void 0}),e.jsx(k,{icon:Me,label:"IFSC Code",value:t.bank_ifsc})]})]})]})]})]}):e.jsx(g,{children:e.jsxs(j,{className:"py-16 text-center",children:[e.jsx(ee,{className:"mx-auto h-10 w-10 text-slate-300 mb-3"}),e.jsx("p",{className:"text-[14px] font-medium text-slate-600",children:"Profile not found"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-1",children:"Unable to load your profile details."})]})})]})}const Lt={pending:"warning",approved:"success",rejected:"destructive"},Tt={personal:"Personal",contact:"Contact",emergency:"Emergency",bank_account:"Bank Account"},Ft=V({category:ue(["personal","contact","emergency","bank_account"]),changes:xs(V({field:$().min(1,"Field name required"),old_value:$(),new_value:$().min(1,"New value required")})).min(1,"At least one change is required")});function on(){var R;const[s,t]=D.useState(!1),{pagination:a,setPagination:d,sorting:r,setSorting:i,globalFilter:c,setGlobalFilter:o,queryParams:m}=de(),{data:h,isLoading:x}=st(m),n=tt(),l=J({resolver:W(Ft),defaultValues:{category:"personal",changes:[{field:"",old_value:"",new_value:""}]}}),f=l.watch("changes");function F(){l.setValue("changes",[...f,{field:"",old_value:"",new_value:""}])}function u(S){f.length>1&&l.setValue("changes",f.filter((L,G)=>G!==S))}function p(S){n.mutate(S,{onSuccess:()=>{t(!1),l.reset({category:"personal",changes:[{field:"",old_value:"",new_value:""}]})}})}const z=[{key:"category",header:"Category",render:S=>e.jsx(_,{variant:"secondary",className:"text-[11px] capitalize",children:Tt[S.category]})},{key:"changes",header:"Changes",render:S=>e.jsxs("div",{className:"space-y-0.5",children:[S.changes.slice(0,2).map((L,G)=>e.jsxs("p",{className:"text-[12px] text-slate-600",children:[e.jsx("span",{className:"font-medium",children:L.field}),": ",L.old_value||"(empty)"," → ",L.new_value]},G)),S.changes.length>2&&e.jsxs("p",{className:"text-[11px] text-slate-400",children:["+",S.changes.length-2," more changes"]})]})},{key:"status",header:"Status",className:"w-28",render:S=>e.jsx(_,{variant:Lt[S.status],className:"capitalize",children:S.status})},{key:"created_at",header:"Submitted",className:"w-32",render:S=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(S.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"approved_by_name",header:"Reviewed By",className:"w-36",render:S=>e.jsx("span",{className:"text-[12px] text-slate-500",children:S.approved_by_name??"--"})}];return e.jsxs("div",{children:[e.jsx(P,{title:"Profile Updates",description:"Request changes to your personal information. All updates require approval.",actions:e.jsxs(N,{size:"sm",onClick:()=>t(!0),children:[e.jsx(te,{className:"mr-1.5 h-3.5 w-3.5"}),"Request Update"]})}),e.jsx(X,{columns:z,data:(h==null?void 0:h.results)??[],isLoading:x,rowKey:S=>S.id,searchPlaceholder:"Search requests...",emptyMessage:"No profile update requests",emptyDescription:"Submit a request to update your personal details.",totalCount:(h==null?void 0:h.count)??0,pagination:a,onPaginationChange:d,sorting:r,onSortingChange:i,globalFilter:c,onGlobalFilterChange:o}),e.jsx(ne,{open:s,onOpenChange:t,children:e.jsxs(re,{children:[e.jsxs(ie,{children:[e.jsx(le,{children:"Request Profile Update"}),e.jsx(ce,{children:"Submit changes to your profile. An administrator will review and approve."})]}),e.jsxs("form",{onSubmit:l.handleSubmit(p),className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Category"}),e.jsxs(K,{value:l.watch("category"),onValueChange:S=>l.setValue("category",S),children:[e.jsx(Q,{children:e.jsx(Y,{})}),e.jsxs(H,{children:[e.jsx(T,{value:"personal",children:"Personal"}),e.jsx(T,{value:"contact",children:"Contact"}),e.jsx(T,{value:"emergency",children:"Emergency"}),e.jsx(T,{value:"bank_account",children:"Bank Account"})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(C,{children:"Changes"}),e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-7 gap-1 text-[12px]",onClick:F,children:[e.jsx(te,{className:"h-3.5 w-3.5"})," Add Field"]})]}),f.map((S,L)=>{var G,_e,Se,ge,ke,Ce,je,y;return e.jsxs("div",{className:"rounded-lg border border-slate-200 p-3 space-y-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] font-medium text-slate-400",children:["Change #",L+1]}),f.length>1&&e.jsx("button",{type:"button",onClick:()=>u(L),className:"rounded p-1 text-slate-400 hover:bg-red-50 hover:text-red-500 transition-colors",children:e.jsx(Ss,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-[12px]",children:"Field Name"}),e.jsx(se,{placeholder:"e.g. Phone Number",...l.register(`changes.${L}.field`)}),((_e=(G=l.formState.errors.changes)==null?void 0:G[L])==null?void 0:_e.field)&&e.jsx("p",{className:"text-[12px] text-red-600",children:(ge=(Se=l.formState.errors.changes[L])==null?void 0:Se.field)==null?void 0:ge.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-[12px]",children:"Current Value"}),e.jsx(se,{placeholder:"Current value",...l.register(`changes.${L}.old_value`)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-[12px]",children:"New Value"}),e.jsx(se,{placeholder:"New value",...l.register(`changes.${L}.new_value`)}),((Ce=(ke=l.formState.errors.changes)==null?void 0:ke[L])==null?void 0:Ce.new_value)&&e.jsx("p",{className:"text-[12px] text-red-600",children:(y=(je=l.formState.errors.changes[L])==null?void 0:je.new_value)==null?void 0:y.message})]})]})]},L)}),((R=l.formState.errors.changes)==null?void 0:R.message)&&e.jsx("p",{className:"text-[12px] text-red-600",children:l.formState.errors.changes.message})]})]}),e.jsxs(oe,{children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",disabled:n.isPending,children:n.isPending?"Submitting...":"Submit Request"})]})]})]})})]})}const Rt={requested:"warning",generating:"secondary",ready:"success",downloaded:"default"},We={salary_certificate:"Salary Certificate",experience_letter:"Experience Letter",employment_verification:"Employment Verification",relieving_letter:"Relieving Letter",bonafide_certificate:"Bonafide Certificate",noc:"No Objection Certificate",other:"Other"},$t=V({document_type:ue(["salary_certificate","experience_letter","employment_verification","relieving_letter","bonafide_certificate","noc","other"]),purpose:$().min(1,"Purpose is required").max(500)});function dn(){const[s,t]=D.useState(!1),{pagination:a,setPagination:d,sorting:r,setSorting:i,globalFilter:c,setGlobalFilter:o,queryParams:m}=de(),{data:h,isLoading:x}=at(m),n=nt(),l=J({resolver:W($t),defaultValues:{document_type:"salary_certificate",purpose:""}});function f(u){n.mutate(u,{onSuccess:()=>{t(!1),l.reset({document_type:"salary_certificate",purpose:""})}})}const F=[{key:"document_type",header:"Document Type",render:u=>e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:u.document_type_display??We[u.document_type]})},{key:"purpose",header:"Purpose",render:u=>e.jsx("p",{className:"text-[12px] text-slate-500 max-w-xs truncate",children:u.purpose})},{key:"status",header:"Status",className:"w-28",render:u=>e.jsx(_,{variant:Rt[u.status],className:"capitalize",children:u.status})},{key:"created_at",header:"Requested",className:"w-32",render:u=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(u.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"actions",header:"",className:"w-10",render:u=>u.status==="ready"&&u.file_url?e.jsx("a",{href:u.file_url,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(N,{variant:"ghost",size:"icon-sm",children:[e.jsx(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Download"})]})}):null}];return e.jsxs("div",{children:[e.jsx(P,{title:"Document Requests",description:"Request official documents such as salary certificates, experience letters, and more.",actions:e.jsxs(N,{size:"sm",onClick:()=>t(!0),children:[e.jsx(te,{className:"mr-1.5 h-3.5 w-3.5"}),"Request Document"]})}),e.jsx(X,{columns:F,data:(h==null?void 0:h.results)??[],isLoading:x,rowKey:u=>u.id,searchPlaceholder:"Search document requests...",emptyMessage:"No document requests",emptyDescription:"Request your first document to get started.",totalCount:(h==null?void 0:h.count)??0,pagination:a,onPaginationChange:d,sorting:r,onSortingChange:i,globalFilter:c,onGlobalFilterChange:o}),e.jsx(ne,{open:s,onOpenChange:t,children:e.jsxs(re,{children:[e.jsxs(ie,{children:[e.jsx(le,{children:"Request Document"}),e.jsx(ce,{children:"Select the type of document you need and provide the purpose."})]}),e.jsxs("form",{onSubmit:l.handleSubmit(f),className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Document Type"}),e.jsxs(K,{value:l.watch("document_type"),onValueChange:u=>l.setValue("document_type",u),children:[e.jsx(Q,{children:e.jsx(Y,{})}),e.jsx(H,{children:Object.entries(We).map(([u,p])=>e.jsx(T,{value:u,children:p},u))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Purpose"}),e.jsx(he,{placeholder:"e.g. Required for visa application",rows:4,...l.register("purpose")}),l.formState.errors.purpose&&e.jsx("p",{className:"text-[12px] text-red-600",children:l.formState.errors.purpose.message})]})]}),e.jsxs(oe,{children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",disabled:n.isPending,children:n.isPending?"Requesting...":"Submit Request"})]})]})]})})]})}const Mt={submitted:"warning",acknowledged:"secondary",investigating:"default",resolved:"success",escalated:"destructive",closed:"secondary"},Et={low:"success",medium:"default",high:"warning",critical:"destructive"},Xe={workplace:"Workplace",harassment:"Harassment",discrimination:"Discrimination",compensation:"Compensation",management:"Management",policy:"Policy",safety:"Safety",other:"Other"},Bt=V({category:ue(["workplace","harassment","discrimination","compensation","management","policy","safety","other"]),subject:$().min(1,"Subject is required").max(200),description:$().min(10,"Provide at least 10 characters of detail").max(5e3),severity:ue(["low","medium","high","critical"]),is_anonymous:us()});function mn(){const s=ae(),[t,a]=D.useState(!1),{pagination:d,setPagination:r,sorting:i,setSorting:c,globalFilter:o,setGlobalFilter:m,queryParams:h}=de(),{data:x,isLoading:n}=rt(h),l=lt(),f=J({resolver:W(Bt),defaultValues:{category:"workplace",subject:"",description:"",severity:"medium",is_anonymous:!1}});function F(p){l.mutate(p,{onSuccess:()=>{a(!1),f.reset()}})}const u=[{key:"subject",header:"Subject",render:p=>e.jsxs("button",{onClick:()=>s(`/ess/grievances/${p.id}`),className:"text-left hover:underline",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:p.subject}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:[Xe[p.category],p.is_anonymous&&" (Anonymous)"]})]})},{key:"severity",header:"Severity",className:"w-24",render:p=>e.jsx(_,{variant:Et[p.severity],className:"capitalize text-[11px]",children:p.severity})},{key:"status",header:"Status",className:"w-28",render:p=>e.jsx(_,{variant:Mt[p.status],className:"capitalize text-[11px]",children:p.status})},{key:"assigned_to_name",header:"Assigned To",className:"w-36",render:p=>e.jsx("span",{className:"text-[12px] text-slate-500",children:p.assigned_to_name??"Unassigned"})},{key:"created_at",header:"Filed",className:"w-28",render:p=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(p.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})}];return e.jsxs("div",{children:[e.jsx(P,{title:"Grievances",description:"Submit and track workplace concerns. Anonymous submissions are supported.",actions:e.jsxs(N,{size:"sm",onClick:()=>a(!0),children:[e.jsx(te,{className:"mr-1.5 h-3.5 w-3.5"}),"File Grievance"]})}),e.jsx(X,{columns:u,data:(x==null?void 0:x.results)??[],isLoading:n,rowKey:p=>p.id,searchPlaceholder:"Search grievances...",emptyMessage:"No grievances filed",emptyDescription:"You have not filed any grievances.",totalCount:(x==null?void 0:x.count)??0,pagination:d,onPaginationChange:r,sorting:i,onSortingChange:c,globalFilter:o,onGlobalFilterChange:m}),e.jsx(ne,{open:t,onOpenChange:a,children:e.jsxs(re,{size:"lg",children:[e.jsxs(ie,{children:[e.jsx(le,{children:"File Grievance"}),e.jsx(ce,{children:"Describe your concern in detail. You may choose to file anonymously."})]}),e.jsxs("form",{onSubmit:f.handleSubmit(F),className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Category"}),e.jsxs(K,{value:f.watch("category"),onValueChange:p=>f.setValue("category",p),children:[e.jsx(Q,{children:e.jsx(Y,{})}),e.jsx(H,{children:Object.entries(Xe).map(([p,z])=>e.jsx(T,{value:p,children:z},p))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Severity"}),e.jsxs(K,{value:f.watch("severity"),onValueChange:p=>f.setValue("severity",p),children:[e.jsx(Q,{children:e.jsx(Y,{})}),e.jsxs(H,{children:[e.jsx(T,{value:"low",children:"Low"}),e.jsx(T,{value:"medium",children:"Medium"}),e.jsx(T,{value:"high",children:"High"}),e.jsx(T,{value:"critical",children:"Critical"})]})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Subject"}),e.jsx(se,{placeholder:"Brief summary of your concern",...f.register("subject")}),f.formState.errors.subject&&e.jsx("p",{className:"text-[12px] text-red-600",children:f.formState.errors.subject.message})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Description"}),e.jsx(he,{placeholder:"Provide detailed information about your concern...",rows:6,...f.register("description")}),f.formState.errors.description&&e.jsx("p",{className:"text-[12px] text-red-600",children:f.formState.errors.description.message})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ds,{id:"anonymous",checked:f.watch("is_anonymous"),onCheckedChange:p=>f.setValue("is_anonymous",!!p)}),e.jsx(C,{htmlFor:"anonymous",className:"text-[13px] font-normal cursor-pointer",children:"Submit anonymously"})]})]}),e.jsxs(oe,{children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",onClick:()=>a(!1),children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",disabled:l.isPending,children:l.isPending?"Submitting...":"Submit Grievance"})]})]})]})})]})}const It={submitted:"warning",acknowledged:"secondary",investigating:"default",resolved:"success",escalated:"destructive",closed:"secondary"},Vt={low:"success",medium:"default",high:"warning",critical:"destructive"},zt=V({content:$().min(1,"Comment is required")});function xn(){const{id:s}=as(),t=ae(),{data:a,isLoading:d}=it(s??""),{data:r,isLoading:i}=ct(s??""),c=ot(),o=(r==null?void 0:r.results)??[],m=J({resolver:W(zt),defaultValues:{content:""}});function h(x){s&&c.mutate({grievance:s,content:x.content},{onSuccess:()=>m.reset()})}return d?e.jsxs("div",{children:[e.jsx(P,{title:"Grievance Details"}),e.jsx("div",{className:"space-y-4",children:e.jsx(g,{children:e.jsxs(j,{className:"pt-6 pb-4",children:[e.jsx("div",{className:"skeleton-shimmer h-5 w-64 rounded mb-3"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-full rounded mb-2"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-3/4 rounded"})]})})})]}):a?e.jsxs("div",{children:[e.jsx(P,{title:a.subject,description:`Filed on ${new Date(a.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})}`,actions:e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>t("/ess/grievances"),children:[e.jsx(Ke,{className:"mr-1.5 h-3.5 w-3.5"})," Back to Grievances"]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[e.jsxs("div",{className:"col-span-2 space-y-4",children:[e.jsxs(g,{children:[e.jsx(M,{className:"pb-2",children:e.jsx(E,{className:"text-[14px]",children:"Description"})}),e.jsx(j,{children:e.jsx("p",{className:"text-[13px] text-slate-600 whitespace-pre-wrap leading-relaxed",children:a.description})})]}),a.resolution_notes&&e.jsxs(g,{children:[e.jsx(M,{className:"pb-2",children:e.jsx(E,{className:"text-[14px]",children:"Resolution Notes"})}),e.jsx(j,{children:e.jsx("p",{className:"text-[13px] text-slate-600 whitespace-pre-wrap leading-relaxed",children:a.resolution_notes})})]}),e.jsxs(g,{children:[e.jsx(M,{className:"pb-2",children:e.jsxs(E,{className:"text-[14px]",children:["Discussion (",o.length,")"]})}),e.jsxs(j,{children:[i?e.jsx("div",{className:"space-y-3",children:Array.from({length:2}).map((x,n)=>e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"skeleton-shimmer h-8 w-8 rounded-full shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"skeleton-shimmer h-3 w-24 rounded mb-2"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-full rounded"})]})]},n))}):o.length===0?e.jsx("p",{className:"text-[13px] text-slate-400 py-4 text-center",children:"No comments yet."}):e.jsx("div",{className:"space-y-4",children:o.map(x=>{var n;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(ls,{className:"h-8 w-8 shrink-0",children:e.jsx(cs,{className:"text-[11px] bg-slate-100",children:((n=x.author_name)==null?void 0:n.charAt(0))??e.jsx(ee,{className:"h-3.5 w-3.5"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-medium text-slate-700",children:x.author_name??"Unknown"}),x.is_internal&&e.jsx(_,{variant:"secondary",className:"text-[10px] h-4 px-1.5",children:"Internal"}),e.jsx("span",{className:"text-[10px] text-slate-400",children:new Date(x.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"})})]}),e.jsx("p",{className:"text-[13px] text-slate-600 mt-1 whitespace-pre-wrap",children:x.content})]})]},x.id)})}),e.jsx(qe,{className:"my-4"}),e.jsxs("form",{onSubmit:m.handleSubmit(h),className:"space-y-3",children:[e.jsx(C,{className:"text-[12px]",children:"Add a comment"}),e.jsx(he,{placeholder:"Type your comment...",rows:3,...m.register("content")}),m.formState.errors.content&&e.jsx("p",{className:"text-[12px] text-red-600",children:m.formState.errors.content.message}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(N,{type:"submit",size:"sm",disabled:c.isPending,children:[e.jsx(ps,{className:"mr-1.5 h-3.5 w-3.5"}),c.isPending?"Sending...":"Send"]})})]})]})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs(g,{children:[e.jsx(M,{className:"pb-2",children:e.jsx(E,{className:"text-[14px]",children:"Details"})}),e.jsxs(j,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Status"}),e.jsx(_,{variant:It[a.status],className:"mt-1 capitalize",children:a.status})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Severity"}),e.jsx(_,{variant:Vt[a.severity],className:"mt-1 capitalize",children:a.severity})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Category"}),e.jsx("p",{className:"text-[13px] text-slate-700 mt-1 capitalize",children:a.category})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Anonymous"}),e.jsx("p",{className:"text-[13px] text-slate-700 mt-1",children:a.is_anonymous?"Yes":"No"})]}),e.jsx(qe,{}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Assigned To"}),e.jsx("p",{className:"text-[13px] text-slate-700 mt-1",children:a.assigned_to_name??"Unassigned"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Filed On"}),e.jsx("p",{className:"text-[13px] text-slate-700 mt-1",children:new Date(a.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]}),a.resolved_at&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Resolved On"}),e.jsx("p",{className:"text-[13px] text-slate-700 mt-1",children:new Date(a.resolved_at).toLocaleDateString("en-GB",{day:"numeric",month:"long",year:"numeric"})})]})]})]})})]})]}):e.jsxs("div",{children:[e.jsx(P,{title:"Grievance Not Found",actions:e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>t("/ess/grievances"),children:[e.jsx(Ke,{className:"mr-1.5 h-3.5 w-3.5"})," Back"]})}),e.jsx(g,{children:e.jsx(j,{className:"py-16 text-center",children:e.jsx("p",{className:"text-[14px] text-slate-500",children:"The requested grievance could not be found."})})})]})}const Gt={open:"secondary",investigating:"warning",resolved:"success",closed:"default"},Ot={open:"Open",investigating:"Investigating",resolved:"Resolved",closed:"Closed"},Ut=V({payslip:$().optional(),description:$().min(10,"Please provide at least 10 characters of detail").max(2e3)});function un(){const[s,t]=D.useState(!1),{pagination:a,setPagination:d,sorting:r,setSorting:i,globalFilter:c,setGlobalFilter:o,queryParams:m}=de(),{data:h,isLoading:x}=dt(m),n=mt(),l=J({resolver:W(Ut),defaultValues:{payslip:"",description:""}});function f(u){n.mutate({...u,payslip:u.payslip||void 0},{onSuccess:()=>{t(!1),l.reset()}})}const F=[{key:"payslip_period",header:"Payslip Period",render:u=>e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:u.payslip_period??"Not specified"})},{key:"description",header:"Description",render:u=>e.jsx("p",{className:"text-[12px] text-slate-500 max-w-xs truncate",children:u.description})},{key:"status",header:"Status",className:"w-28",render:u=>e.jsx(_,{variant:Gt[u.status],className:"text-[11px]",children:Ot[u.status]})},{key:"resolved_by_name",header:"Resolved By",className:"w-36",render:u=>e.jsx("span",{className:"text-[12px] text-slate-500",children:u.resolved_by_name??"-"})},{key:"created_at",header:"Submitted",className:"w-28",render:u=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(u.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})}];return e.jsxs("div",{children:[e.jsx(P,{title:"Salary Queries",description:"Raise and track salary discrepancy queries for any payslip period.",actions:e.jsxs(N,{size:"sm",onClick:()=>t(!0),children:[e.jsx(te,{className:"mr-1.5 h-3.5 w-3.5"}),"Raise Query"]})}),e.jsx(X,{columns:F,data:(h==null?void 0:h.results)??[],isLoading:x,rowKey:u=>u.id,searchPlaceholder:"Search salary queries...",emptyMessage:"No salary queries",emptyDescription:"You have not raised any salary queries yet.",totalCount:(h==null?void 0:h.count)??0,pagination:a,onPaginationChange:d,sorting:r,onSortingChange:i,globalFilter:c,onGlobalFilterChange:o}),e.jsx(ne,{open:s,onOpenChange:t,children:e.jsxs(re,{children:[e.jsxs(ie,{children:[e.jsx(le,{children:"Raise Salary Query"}),e.jsx(ce,{children:"Describe the discrepancy you noticed in your payslip."})]}),e.jsxs("form",{onSubmit:l.handleSubmit(f),className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Payslip Period (optional)"}),e.jsx(se,{placeholder:"e.g. January 2026",...l.register("payslip")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Description"}),e.jsx(he,{placeholder:"Describe the salary discrepancy in detail...",rows:6,...l.register("description")}),l.formState.errors.description&&e.jsx("p",{className:"text-[12px] text-red-600",children:l.formState.errors.description.message})]})]}),e.jsxs(oe,{children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",disabled:n.isPending,children:n.isPending?"Submitting...":"Submit Query"})]})]})]})})]})}const Ee={teamwork:{label:"Teamwork",color:"bg-blue-500/10 text-blue-600 border-blue-200",icon:pe},innovation:{label:"Innovation",color:"bg-purple-500/10 text-purple-600 border-purple-200",icon:Ws},leadership:{label:"Leadership",color:"bg-amber-500/10 text-amber-600 border-amber-200",icon:Os},above_beyond:{label:"Above & Beyond",color:"bg-emerald-500/10 text-emerald-600 border-emerald-200",icon:ks},customer_first:{label:"Customer First",color:"bg-pink-500/10 text-pink-600 border-pink-200",icon:Oe}},Ze=["teamwork","innovation","leadership","above_beyond","customer_first"],Kt=V({to_employee:$().min(1,"Recipient is required"),badge_type:ue(["teamwork","innovation","leadership","above_beyond","customer_first"]),message:$().min(5,"Message must be at least 5 characters").max(500),is_public:us()});function pn(){const[s,t]=D.useState(!1),[a,d]=D.useState("all"),r={};a!=="all"&&(r.badge_type=a);const{data:i,isLoading:c}=xt(r),o=ut(),m=J({resolver:W(Kt),defaultValues:{to_employee:"",badge_type:"teamwork",message:"",is_public:!0}});function h(n){o.mutate(n,{onSuccess:()=>{t(!1),m.reset()}})}const x=(i==null?void 0:i.results)??[];return e.jsxs("div",{children:[e.jsx(P,{title:"Peer Recognitions",description:"Celebrate your colleagues and recognize their contributions.",actions:e.jsxs(N,{size:"sm",onClick:()=>t(!0),children:[e.jsx(te,{className:"mr-1.5 h-3.5 w-3.5"}),"Give Recognition"]})}),e.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[e.jsx("span",{className:"text-[12px] font-medium text-slate-500 mr-1",children:"Filter:"}),e.jsx("button",{onClick:()=>d("all"),className:`rounded-full px-3 py-1 text-[12px] font-medium border transition-colors ${a==="all"?"bg-slate-900 text-white border-slate-900":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:"All"}),Ze.map(n=>{const l=Ee[n];return e.jsx("button",{onClick:()=>d(n),className:`rounded-full px-3 py-1 text-[12px] font-medium border transition-colors ${a===n?"bg-slate-900 text-white border-slate-900":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:l.label},n)})]}),c?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((n,l)=>e.jsx(g,{children:e.jsxs(j,{className:"p-5",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-3/4 rounded mb-3"}),e.jsx("div",{className:"skeleton-shimmer h-3 w-full rounded mb-2"}),e.jsx("div",{className:"skeleton-shimmer h-3 w-2/3 rounded mb-4"}),e.jsx("div",{className:"skeleton-shimmer h-5 w-20 rounded"})]})},l))}):x.length===0?e.jsx(g,{children:e.jsxs(j,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-slate-100",children:e.jsx(we,{className:"h-5 w-5 text-slate-400"})}),e.jsx("p",{className:"text-[13px] font-medium text-slate-600",children:"No recognitions yet"}),e.jsx("p",{className:"mt-1 text-[12px] text-slate-400 max-w-xs",children:"Be the first to recognize a colleague's contribution."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:x.map(n=>{const l=Ee[n.badge_type],f=l.icon;return e.jsx(g,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(j,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-3",children:[e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:n.from_employee_name??"Someone"}),e.jsx("span",{className:"text-[12px] text-slate-400",children:"recognized"}),e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:n.to_employee_name??"Someone"})]}),e.jsx("p",{className:"text-[12px] text-slate-500 leading-relaxed mb-4 line-clamp-3",children:n.message}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-[11px] font-medium border ${l.color}`,children:[e.jsx(f,{className:"h-3 w-3"}),l.label]}),n.points>0&&e.jsxs("span",{className:"text-[11px] font-medium text-amber-600",children:["+",n.points," pts"]})]}),e.jsx("span",{className:"text-[10px] text-slate-400",children:new Date(n.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"short"})})]})]})},n.id)})}),e.jsx(ne,{open:s,onOpenChange:t,children:e.jsxs(re,{children:[e.jsxs(ie,{children:[e.jsx(le,{children:"Give Recognition"}),e.jsx(ce,{children:"Recognize a colleague for their great work."})]}),e.jsxs("form",{onSubmit:m.handleSubmit(h),className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Recipient"}),e.jsx(Gs,{value:m.watch("to_employee")??"",onValueChange:n=>m.setValue("to_employee",n,{shouldValidate:!0})}),m.formState.errors.to_employee&&e.jsx("p",{className:"text-[12px] text-red-600",children:m.formState.errors.to_employee.message})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Badge Type"}),e.jsxs(K,{value:m.watch("badge_type"),onValueChange:n=>m.setValue("badge_type",n),children:[e.jsx(Q,{children:e.jsx(Y,{})}),e.jsx(H,{children:Ze.map(n=>e.jsx(T,{value:n,children:Ee[n].label},n))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Message"}),e.jsx(he,{placeholder:"Share what made their work stand out...",rows:4,...m.register("message")}),m.formState.errors.message&&e.jsx("p",{className:"text-[12px] text-red-600",children:m.formState.errors.message.message})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ds,{id:"is_public",checked:m.watch("is_public"),onCheckedChange:n=>m.setValue("is_public",!!n)}),e.jsx(C,{htmlFor:"is_public",className:"text-[13px] font-normal cursor-pointer",children:"Make this recognition public"})]})]}),e.jsxs(oe,{children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",disabled:o.isPending,children:o.isPending?"Sending...":"Send Recognition"})]})]})]})})]})}const Qt={open:"success",closed:"secondary",filled:"default",cancelled:"destructive"},Yt={open:"Open",closed:"Closed",filled:"Filled",cancelled:"Cancelled"};function hn(){const s=ae(),{pagination:t,setPagination:a,sorting:d,setSorting:r,globalFilter:i,setGlobalFilter:c,queryParams:o}=de(),{data:m,isLoading:h}=pt(o),x=[{key:"title",header:"Job Title",render:n=>e.jsxs("button",{onClick:()=>s(`/ess/job-postings/${n.id}`),className:"text-left hover:underline",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:n.title}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:n.company_name})]})},{key:"department_name",header:"Department",className:"w-36",render:n=>e.jsx("span",{className:"text-[12px] text-slate-500",children:n.department_name??"-"})},{key:"application_deadline",header:"Deadline",className:"w-28",render:n=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(n.application_deadline).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"status",header:"Status",className:"w-24",render:n=>e.jsx(_,{variant:Qt[n.status],className:"text-[11px]",children:Yt[n.status]})},{key:"applications_count",header:"Applications",className:"w-28",render:n=>e.jsx("span",{className:"text-[12px] text-slate-500",children:n.applications_count??0})},{key:"actions",header:"",className:"w-24",render:n=>e.jsxs(N,{variant:"outline",size:"sm",onClick:()=>s(`/ess/job-postings/${n.id}`),children:[e.jsx(xe,{className:"mr-1.5 h-3.5 w-3.5"}),"View"]})}];return e.jsxs("div",{children:[e.jsx(P,{title:"Internal Job Postings",description:"Browse open positions within the organization and apply for internal transfers."}),e.jsx(X,{columns:x,data:(m==null?void 0:m.results)??[],isLoading:h,rowKey:n=>n.id,searchPlaceholder:"Search job postings...",emptyMessage:"No job postings",emptyDescription:"There are currently no internal job postings available.",totalCount:(m==null?void 0:m.count)??0,pagination:t,onPaginationChange:a,sorting:d,onSortingChange:r,globalFilter:i,onGlobalFilterChange:c})]})}const Ht={open:"success",closed:"secondary",filled:"default",cancelled:"destructive"},Jt={applied:"secondary",shortlisted:"warning",interviewing:"default",selected:"success",rejected:"destructive",withdrawn:"secondary"},Wt=V({cover_letter:$().min(20,"Cover letter must be at least 20 characters").max(5e3)});function gn(){const{id:s}=as(),t=ae(),[a,d]=D.useState(!1),{data:r,isLoading:i}=ht(s??""),{data:c,isLoading:o}=gt({posting:s}),m=jt(),h=yt(),x=J({resolver:W(Wt),defaultValues:{cover_letter:""}});function n(p){s&&m.mutate({posting:s,cover_letter:p.cover_letter},{onSuccess:()=>{d(!1),x.reset()}})}const l=(c==null?void 0:c.results)??[],f=r?new Date(r.application_deadline)<new Date:!1,F=(r==null?void 0:r.status)==="open"&&!f,u=[{key:"employee_name",header:"Applicant",render:p=>e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:p.employee_name??"You"})},{key:"status",header:"Status",className:"w-28",render:p=>e.jsx(_,{variant:Jt[p.status],className:"capitalize text-[11px]",children:p.status})},{key:"applied_at",header:"Applied",className:"w-28",render:p=>e.jsx("span",{className:"text-[12px] text-slate-400",children:p.applied_at?new Date(p.applied_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):new Date(p.created_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"actions",header:"",className:"w-28",render:p=>p.status==="applied"?e.jsx(N,{variant:"outline",size:"sm",onClick:()=>h.mutate(p.id),disabled:h.isPending,children:"Withdraw"}):null}];return i?e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"skeleton-shimmer h-6 w-48 rounded mb-2"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-96 rounded"})]}),e.jsx(g,{children:e.jsx(j,{className:"p-6",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-full rounded"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-3/4 rounded"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-5/6 rounded"})]})})})]}):r?e.jsxs("div",{children:[e.jsx("div",{className:"mb-4",children:e.jsxs(N,{variant:"ghost",size:"sm",onClick:()=>t("/ess/job-postings"),children:[e.jsx(Ke,{className:"mr-1.5 h-3.5 w-3.5"}),"Back to Postings"]})}),e.jsx(P,{title:r.title,description:r.company_name,actions:F?e.jsx(N,{size:"sm",onClick:()=>d(!0),children:"Apply Now"}):void 0}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[e.jsx(g,{children:e.jsxs(j,{className:"pt-4 pb-3 px-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-slate-100",children:e.jsx(Ue,{className:"h-4 w-4 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wider",children:"Department"}),e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:r.department_name??"-"})]})]})}),e.jsx(g,{children:e.jsxs(j,{className:"pt-4 pb-3 px-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-slate-100",children:e.jsx(Ge,{className:"h-4 w-4 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wider",children:"Deadline"}),e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:new Date(r.application_deadline).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})]})]})}),e.jsx(g,{children:e.jsxs(j,{className:"pt-4 pb-3 px-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-slate-100",children:e.jsx(Je,{className:"h-4 w-4 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wider",children:"Status"}),e.jsx(_,{variant:Ht[r.status],className:"text-[11px] capitalize",children:r.status})]})]})}),e.jsx(g,{children:e.jsxs(j,{className:"pt-4 pb-3 px-4 flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-slate-100",children:e.jsx(pe,{className:"h-4 w-4 text-slate-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-medium text-slate-400 uppercase tracking-wider",children:"Applications"}),e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:r.applications_count??0})]})]})})]}),e.jsxs(g,{className:"mb-6",children:[e.jsx(M,{className:"pb-3",children:e.jsx(E,{className:"text-[14px]",children:"Description"})}),e.jsx(j,{children:e.jsx("p",{className:"text-[13px] text-slate-600 leading-relaxed whitespace-pre-wrap",children:r.description})})]}),r.requirements.length>0&&e.jsxs(g,{className:"mb-6",children:[e.jsx(M,{className:"pb-3",children:e.jsx(E,{className:"text-[14px]",children:"Requirements"})}),e.jsx(j,{children:e.jsx("ul",{className:"space-y-2",children:r.requirements.map((p,z)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx(Je,{className:"h-4 w-4 text-emerald-500 mt-0.5 shrink-0"}),e.jsx("span",{className:"text-[13px] text-slate-600",children:p})]},z))})})]}),e.jsx("div",{className:"mb-2",children:e.jsx("h2",{className:"text-[14px] font-semibold text-slate-900",children:"My Applications"})}),e.jsx(X,{columns:u,data:l,isLoading:o,rowKey:p=>p.id,emptyMessage:"No applications",emptyDescription:"You have not applied for this position yet.",enablePagination:!1}),e.jsx(ne,{open:a,onOpenChange:d,children:e.jsxs(re,{size:"lg",children:[e.jsxs(ie,{children:[e.jsxs(le,{children:["Apply for ",r.title]}),e.jsx(ce,{children:"Submit your cover letter to apply for this internal position."})]}),e.jsxs("form",{onSubmit:x.handleSubmit(n),className:"flex flex-col flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Cover Letter"}),e.jsx(he,{placeholder:"Explain why you are a good fit for this position...",rows:10,...x.register("cover_letter")}),x.formState.errors.cover_letter&&e.jsx("p",{className:"text-[12px] text-red-600",children:x.formState.errors.cover_letter.message})]})}),e.jsxs(oe,{children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",onClick:()=>d(!1),children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",disabled:m.isPending,children:m.isPending?"Submitting...":"Submit Application"})]})]})]})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("p",{className:"text-[13px] text-slate-500",children:"Job posting not found."}),e.jsx(N,{variant:"outline",size:"sm",className:"mt-4",onClick:()=>t("/ess/job-postings"),children:"Back to Postings"})]})}function Xt(s){return s.split(" ").map(t=>t[0]).filter(Boolean).slice(0,2).join("").toUpperCase()}const Be=["bg-blue-500/10 text-blue-600","bg-emerald-500/10 text-emerald-600","bg-purple-500/10 text-purple-600","bg-amber-500/10 text-amber-600","bg-pink-500/10 text-pink-600","bg-indigo-500/10 text-indigo-600","bg-teal-500/10 text-teal-600","bg-rose-500/10 text-rose-600"];function Zt(s){let t=0;for(let a=0;a<s.length;a++)t=s.charCodeAt(a)+((t<<5)-t);return Be[Math.abs(t)%Be.length]??Be[0]}function jn(){const[s,t]=D.useState(""),a={};s&&(a.search=s);const{data:d,isLoading:r}=bt(a),i=(d==null?void 0:d.results)??[];return e.jsxs("div",{children:[e.jsx(P,{title:"Team Directory",description:"Find and connect with colleagues across the organization."}),e.jsxs("div",{className:"relative mb-5 max-w-md",children:[e.jsx(Cs,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-slate-400"}),e.jsx(se,{placeholder:"Search by name, department, or designation...",value:s,onChange:c=>t(c.target.value),className:"pl-9"})]}),r?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:9}).map((c,o)=>e.jsx(g,{children:e.jsxs(j,{className:"p-5 flex items-center gap-4",children:[e.jsx("div",{className:"skeleton-shimmer h-12 w-12 rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-32 rounded mb-2"}),e.jsx("div",{className:"skeleton-shimmer h-3 w-24 rounded mb-1"}),e.jsx("div",{className:"skeleton-shimmer h-3 w-40 rounded"})]})]})},o))}):i.length===0?e.jsx(g,{children:e.jsxs(j,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-slate-100",children:e.jsx(pe,{className:"h-5 w-5 text-slate-400"})}),e.jsx("p",{className:"text-[13px] font-medium text-slate-600",children:"No team members found"}),e.jsx("p",{className:"mt-1 text-[12px] text-slate-400 max-w-xs",children:s?"Try adjusting your search criteria.":"No team members available."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:i.map(c=>e.jsx(g,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(j,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:`flex h-12 w-12 shrink-0 items-center justify-center rounded-full text-[14px] font-semibold ${Zt(c.full_name)}`,children:Xt(c.full_name)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700 truncate",children:c.full_name}),e.jsx("p",{className:"text-[12px] text-slate-500 truncate",children:c.designation_name??"No designation"}),e.jsx("p",{className:"text-[11px] text-slate-400 truncate",children:c.department_name??"No department"})]})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-slate-100 space-y-1.5",children:[c.email&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ms,{className:"h-3.5 w-3.5 text-slate-400 shrink-0"}),e.jsx("a",{href:`mailto:${c.email}`,className:"text-[12px] text-slate-500 hover:text-primary truncate",children:c.email})]}),c.phone&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(De,{className:"h-3.5 w-3.5 text-slate-400 shrink-0"}),e.jsx("a",{href:`tel:${c.phone}`,className:"text-[12px] text-slate-500 hover:text-primary",children:c.phone})]})]})]})},c.id))})]})}const ea={draft:"secondary",generated:"warning",published:"success"},sa={draft:"Draft",generated:"Generated",published:"Published"};function Ie(s){const t=typeof s=="string"?parseFloat(s):s;return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:0,maximumFractionDigits:0}).format(t)}function yn(){const{pagination:s,setPagination:t,sorting:a,setSorting:d,globalFilter:r,setGlobalFilter:i,queryParams:c}=de(),{data:o,isLoading:m}=Nt(c),h=Us();function x(l){h.mutate(l,{onSuccess:f=>{const F=window.URL.createObjectURL(f),u=document.createElement("a");u.href=F,u.download=`payslip_${l}.pdf`,document.body.appendChild(u),u.click(),document.body.removeChild(u),window.URL.revokeObjectURL(F)}})}const n=[{key:"period",header:"Period",render:l=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-slate-100",children:e.jsx(be,{className:"h-3.5 w-3.5 text-slate-500"})}),e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:l.period})]})},{key:"gross_salary",header:"Gross Salary",className:"w-32",render:l=>e.jsx("span",{className:"text-[12px] text-slate-600 font-medium",children:Ie(l.gross_salary)})},{key:"total_deductions",header:"Deductions",className:"w-32",render:l=>e.jsx("span",{className:"text-[12px] text-red-500",children:Ie(l.total_deductions)})},{key:"net_salary",header:"Net Salary",className:"w-32",render:l=>e.jsx("span",{className:"text-[13px] text-slate-700 font-semibold",children:Ie(l.net_salary)})},{key:"status",header:"Status",className:"w-28",render:l=>e.jsx(_,{variant:ea[l.status],className:"text-[11px]",children:sa[l.status]})},{key:"actions",header:"",className:"w-10",render:l=>e.jsxs(N,{variant:"ghost",size:"icon-sm",onClick:()=>x(l.id),disabled:h.isPending,title:"Download PDF",children:[e.jsx(os,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Download payslip"})]})}];return e.jsxs("div",{children:[e.jsx(P,{title:"My Payslips",description:"View and download your monthly payslips."}),e.jsx(X,{columns:n,data:(o==null?void 0:o.results)??[],isLoading:m,rowKey:l=>l.id,searchPlaceholder:"Search payslips...",emptyMessage:"No payslips available",emptyDescription:"Your payslips will appear here once they are published.",totalCount:(o==null?void 0:o.count)??0,pagination:s,onPaginationChange:t,sorting:a,onSortingChange:d,globalFilter:r,onGlobalFilterChange:i})]})}const es=[{value:"1",label:"January"},{value:"2",label:"February"},{value:"3",label:"March"},{value:"4",label:"April"},{value:"5",label:"May"},{value:"6",label:"June"},{value:"7",label:"July"},{value:"8",label:"August"},{value:"9",label:"September"},{value:"10",label:"October"},{value:"11",label:"November"},{value:"12",label:"December"}],Ye=new Date,ta=String(Ye.getMonth()+1),aa=String(Ye.getFullYear()),na=Array.from({length:5},(s,t)=>{const a=Ye.getFullYear()-t;return{value:String(a),label:String(a)}});function me({icon:s,label:t,value:a,color:d,isLoading:r}){return e.jsx(g,{children:e.jsx(j,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${d}`,children:e.jsx(s,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:t}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:r?"...":a})]})]})})})}function fn(){var o;const[s,t]=D.useState(ta),[a,d]=D.useState(aa),r={month:s,year:a},{data:i,isLoading:c}=gs(r);return e.jsxs("div",{children:[e.jsx(P,{title:"My Attendance",description:"View your attendance summary including present days, absences, and working hours."}),e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"w-40",children:e.jsxs(K,{value:s,onValueChange:t,children:[e.jsx(Q,{children:e.jsx(Y,{placeholder:"Month"})}),e.jsx(H,{children:es.map(m=>e.jsx(T,{value:m.value,children:m.label},m.value))})]})}),e.jsx("div",{className:"w-28",children:e.jsxs(K,{value:a,onValueChange:d,children:[e.jsx(Q,{children:e.jsx(Y,{placeholder:"Year"})}),e.jsx(H,{children:na.map(m=>e.jsx(T,{value:m.value,children:m.label},m.value))})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsx(me,{icon:Ks,label:"Present Days",value:(i==null?void 0:i.present_days)??0,color:"bg-emerald-500/10 text-emerald-500",isLoading:c}),e.jsx(me,{icon:Js,label:"Absent Days",value:(i==null?void 0:i.absent_days)??0,color:"bg-red-500/10 text-red-500",isLoading:c}),e.jsx(me,{icon:ve,label:"Late Arrivals",value:(i==null?void 0:i.late_arrivals)??0,color:"bg-amber-500/10 text-amber-500",isLoading:c}),e.jsx(me,{icon:Qs,label:"Early Departures",value:(i==null?void 0:i.early_departures)??0,color:"bg-orange-500/10 text-orange-500",isLoading:c}),e.jsx(me,{icon:Ys,label:"Avg Working Hours",value:(i==null?void 0:i.avg_working_hours)??"-",color:"bg-blue-500/10 text-blue-500",isLoading:c}),e.jsx(me,{icon:Hs,label:"Attendance %",value:i?`${i.attendance_percentage}%`:"0%",color:"bg-purple-500/10 text-purple-500",isLoading:c})]}),i&&e.jsx(g,{className:"mt-6",children:e.jsx(j,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Total Working Days"}),e.jsxs("p",{className:"text-[12px] text-slate-400 mt-0.5",children:["For ",(o=es.find(m=>m.value===s))==null?void 0:o.label," ",a]})]}),e.jsx("p",{className:"text-[20px] font-semibold text-slate-900",children:i.total_working_days})]})})})]})}const ra={CL:"bg-blue-500/10 text-blue-600",SL:"bg-emerald-500/10 text-emerald-600",EL:"bg-purple-500/10 text-purple-600",PL:"bg-pink-500/10 text-pink-600",ML:"bg-amber-500/10 text-amber-600",LWP:"bg-red-500/10 text-red-600",CO:"bg-teal-500/10 text-teal-600"};function ia(s){return ra[s]??"bg-slate-100 text-slate-600"}function la(s,t){if(t===0)return"default";const a=s/t*100;return a>=90?"destructive":a>=70?"warning":"success"}function vn(){const{data:s,isLoading:t}=hs();return e.jsxs("div",{children:[e.jsx(P,{title:"My Leave Balance",description:"View your leave allocation, usage, and remaining balance for each leave type."}),t?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((a,d)=>e.jsx(g,{children:e.jsxs(j,{className:"p-5",children:[e.jsx("div",{className:"skeleton-shimmer h-5 w-32 rounded mb-3"}),e.jsx("div",{className:"skeleton-shimmer h-2 w-full rounded mb-4"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx("div",{className:"skeleton-shimmer h-8 rounded"}),e.jsx("div",{className:"skeleton-shimmer h-8 rounded"}),e.jsx("div",{className:"skeleton-shimmer h-8 rounded"})]})]})},d))}):!s||s.length===0?e.jsx(g,{children:e.jsxs(j,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-slate-100",children:e.jsx(Fe,{className:"h-5 w-5 text-slate-400"})}),e.jsx("p",{className:"text-[13px] font-medium text-slate-600",children:"No leave balances"}),e.jsx("p",{className:"mt-1 text-[12px] text-slate-400 max-w-xs",children:"Leave balance data is not available yet."})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(a=>e.jsx(g,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(j,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-[12px] font-bold ${ia(a.leave_type_code)}`,children:a.leave_type_code}),e.jsx("div",{className:"min-w-0",children:e.jsx("p",{className:"text-[13px] font-medium text-slate-700 truncate",children:a.leave_type_name})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("span",{className:"text-[11px] text-slate-400",children:[a.used," of ",a.allocated," used"]}),e.jsxs("span",{className:"text-[11px] font-medium text-slate-600",children:[a.allocated>0?Math.round(a.used/a.allocated*100):0,"%"]})]}),e.jsx(As,{value:a.used,max:a.allocated||1,variant:la(a.used,a.allocated)})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{className:"rounded-lg bg-slate-50 px-2 py-2 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider",children:"Alloc"}),e.jsx("p",{className:"text-[14px] font-semibold text-slate-700",children:a.allocated})]}),e.jsxs("div",{className:"rounded-lg bg-slate-50 px-2 py-2 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider",children:"Used"}),e.jsx("p",{className:"text-[14px] font-semibold text-slate-700",children:a.used})]}),e.jsxs("div",{className:"rounded-lg bg-slate-50 px-2 py-2 text-center",children:[e.jsx("p",{className:"text-[10px] text-slate-400 uppercase tracking-wider",children:"Pend"}),e.jsx("p",{className:"text-[14px] font-semibold text-amber-600",children:a.pending})]}),e.jsxs("div",{className:"rounded-lg bg-emerald-50 px-2 py-2 text-center",children:[e.jsx("p",{className:"text-[10px] text-emerald-500 uppercase tracking-wider",children:"Bal"}),e.jsx("p",{className:"text-[14px] font-semibold text-emerald-600",children:a.balance})]})]}),a.carry_forward>0&&e.jsx("div",{className:"mt-3 pt-3 border-t border-slate-100",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] text-slate-400",children:"Carry Forward"}),e.jsxs("span",{className:"text-[12px] font-medium text-slate-600",children:[a.carry_forward," days"]})]})})]})},a.leave_type))})]})}const ca={low:"default",normal:"secondary",high:"warning",urgent:"destructive"},oa={low:"Low",normal:"Normal",high:"Important",urgent:"Urgent"};function Nn(){const{data:s,isLoading:t}=wt(),d=[...(s==null?void 0:s.results)??[]].sort((r,i)=>r.is_pinned&&!i.is_pinned?-1:!r.is_pinned&&i.is_pinned?1:new Date(i.published_at).getTime()-new Date(r.published_at).getTime());return e.jsxs("div",{children:[e.jsx(P,{title:"Announcements",description:"Stay up to date with the latest company news and updates."}),t?e.jsx("div",{className:"space-y-4",children:Array.from({length:5}).map((r,i)=>e.jsx(g,{children:e.jsxs(j,{className:"p-5",children:[e.jsx("div",{className:"skeleton-shimmer h-5 w-64 rounded mb-3"}),e.jsx("div",{className:"skeleton-shimmer h-3 w-full rounded mb-2"}),e.jsx("div",{className:"skeleton-shimmer h-3 w-3/4 rounded mb-3"}),e.jsx("div",{className:"skeleton-shimmer h-3 w-32 rounded"})]})},i))}):d.length===0?e.jsx(g,{children:e.jsxs(j,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-slate-100",children:e.jsx(Qe,{className:"h-5 w-5 text-slate-400"})}),e.jsx("p",{className:"text-[13px] font-medium text-slate-600",children:"No announcements"}),e.jsx("p",{className:"mt-1 text-[12px] text-slate-400 max-w-xs",children:"There are no announcements at this time."})]})}):e.jsx("div",{className:"space-y-4",children:d.map(r=>e.jsx(g,{className:`hover:shadow-sm transition-shadow ${r.is_pinned?"border-primary/30 bg-primary/[0.02]":""}`,children:e.jsxs(j,{className:"p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.is_pinned&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-medium text-primary",children:[e.jsx(Xs,{className:"h-3 w-3"}),"Pinned"]}),e.jsx(_,{variant:ca[r.priority],className:"text-[11px]",children:oa[r.priority]})]}),e.jsx("span",{className:"text-[11px] text-slate-400 shrink-0",children:new Date(r.published_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})]}),e.jsx("h3",{className:"text-[14px] font-semibold text-slate-800 mb-2",children:r.title}),e.jsx("p",{className:"text-[13px] text-slate-500 leading-relaxed line-clamp-3 mb-3",children:r.content}),r.author_name&&e.jsxs("p",{className:"text-[11px] text-slate-400",children:["Posted by ",r.author_name]})]})},r.id))})]})}const da={draft:"secondary",submitted:"warning",verified:"success",rejected:"destructive"},ma={draft:"Draft",submitted:"Submitted",verified:"Verified",rejected:"Rejected"},xa={"80C":"Section 80C (PPF, ELSS, LIC, etc.)","80D":"Section 80D (Medical Insurance)",24:"Section 24 (Home Loan Interest)",HRA:"HRA (House Rent Allowance)",LTA:"LTA (Leave Travel Allowance)",other:"Other Deductions"},Ve=["80C","80D","24","HRA","LTA","other"];function Pe(){const s=new Date,t=s.getMonth()>=3?s.getFullYear():s.getFullYear()-1;return`${t}-${t+1}`}function ss(){const s=new Date,t=s.getMonth()>=3?s.getFullYear()-1:s.getFullYear()-2;return`${t}-${t+1}`}function ts(s){return new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",minimumFractionDigits:0,maximumFractionDigits:0}).format(s)}const ua=V({section:ue(["80C","80D","24","HRA","LTA","other"]),declared_amount:zs.number().min(0,"Amount must be 0 or more")}),pa=V({financial_year:$().min(1,"Financial year is required"),sections:xs(ua).min(1)});function bn(){var je;const[s,t]=D.useState(!1),[a,d]=D.useState(null),{hasPermission:r}=ns(),i=r("ess","declaration","create"),{pagination:c,setPagination:o,sorting:m,setSorting:h,globalFilter:x,setGlobalFilter:n,queryParams:l}=de(),{data:f,isLoading:F}=_t(l),u=St(),p=kt(),z=Ct(),R=J({resolver:W(pa),defaultValues:{financial_year:Pe(),sections:Ve.map(y=>({section:y,declared_amount:0}))}}),{fields:S}=Vs({control:R.control,name:"sections"});function L(){d(null),R.reset({financial_year:Pe(),sections:Ve.map(y=>({section:y,declared_amount:0}))}),t(!0)}function G(y){d(y.id);const O=Ve.map(Ae=>{const $e=y.sections.find(fs=>fs.section===Ae);return{section:Ae,declared_amount:($e==null?void 0:$e.declared_amount)??0}});R.reset({financial_year:y.financial_year,sections:O}),t(!0)}function _e(y){const O={financial_year:y.financial_year,sections:y.sections.filter(Ae=>Ae.declared_amount>0)};a?p.mutate({id:a,data:O},{onSuccess:()=>{t(!1),d(null),R.reset()}}):u.mutate(O,{onSuccess:()=>{t(!1),R.reset()}})}function Se(y){z.mutate(y)}const ge=u.isPending||p.isPending,ke=[{key:"financial_year",header:"Financial Year",render:y=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-slate-100",children:e.jsx(rs,{className:"h-3.5 w-3.5 text-slate-500"})}),e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:y.financial_year})]})},{key:"total_declared",header:"Total Declared",className:"w-36",render:y=>e.jsx("span",{className:"text-[13px] text-slate-700 font-semibold",children:ts(y.total_declared)})},{key:"status",header:"Status",className:"w-28",render:y=>e.jsx(_,{variant:da[y.status],className:"text-[11px]",children:ma[y.status]})},{key:"submitted_at",header:"Submitted",className:"w-32",render:y=>e.jsx("span",{className:"text-[12px] text-slate-400",children:y.submitted_at?new Date(y.submitted_at).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"--"})},{key:"actions",header:"",className:"w-24",render:y=>e.jsx("div",{className:"flex items-center gap-1",children:y.status==="draft"&&e.jsxs(e.Fragment,{children:[e.jsx(N,{variant:"ghost",size:"sm",className:"text-[12px]",onClick:()=>G(y),children:"Edit"}),e.jsxs(N,{variant:"ghost",size:"icon-sm",onClick:()=>Se(y.id),disabled:z.isPending,children:[e.jsx(ps,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"sr-only",children:"Submit"})]})]})})}],Ce=((je=R.watch("sections"))==null?void 0:je.reduce((y,O)=>y+(Number(O.declared_amount)||0),0))??0;return e.jsxs("div",{children:[e.jsx(P,{title:"IT Declarations",description:"Declare your tax-saving investments for the financial year.",actions:i?e.jsxs(N,{size:"sm",onClick:L,children:[e.jsx(te,{className:"mr-1.5 h-3.5 w-3.5"}),"New Declaration"]}):void 0}),e.jsx(X,{columns:ke,data:(f==null?void 0:f.results)??[],isLoading:F,rowKey:y=>y.id,searchPlaceholder:"Search declarations...",emptyMessage:"No declarations",emptyDescription:"Create your first IT declaration to get started.",totalCount:(f==null?void 0:f.count)??0,pagination:c,onPaginationChange:o,sorting:m,onSortingChange:h,globalFilter:x,onGlobalFilterChange:n}),e.jsx(ne,{open:s,onOpenChange:t,children:e.jsxs(re,{size:"lg",children:[e.jsxs(ie,{children:[e.jsx(le,{children:a?"Edit Declaration":"New Declaration"}),e.jsx(ce,{children:"Enter your investment declarations under each section for the selected financial year."})]}),e.jsxs("form",{onSubmit:R.handleSubmit(_e),className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Financial Year"}),e.jsxs(K,{value:R.watch("financial_year"),onValueChange:y=>R.setValue("financial_year",y),children:[e.jsx(Q,{children:e.jsx(Y,{})}),e.jsxs(H,{children:[e.jsx(T,{value:Pe(),children:Pe()}),e.jsx(T,{value:ss(),children:ss()})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{className:"text-[13px] font-medium text-slate-700",children:"Investment Sections"}),S.map((y,O)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-[12px] font-medium text-slate-600",children:xa[y.section]})}),e.jsx("div",{className:"w-40",children:e.jsx(se,{type:"number",min:0,placeholder:"0",...R.register(`sections.${O}.declared_amount`,{valueAsNumber:!0})})})]},y.id))]}),e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-slate-50 p-3 flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] font-medium text-slate-600",children:"Total Declared"}),e.jsx("span",{className:"text-[14px] font-semibold text-slate-900",children:ts(Ce)})]})]}),e.jsxs(oe,{children:[e.jsx(N,{type:"button",variant:"outline",size:"sm",onClick:()=>t(!1),children:"Cancel"}),e.jsx(N,{type:"submit",size:"sm",disabled:ge,children:ge?"Saving...":a?"Update Declaration":"Save Declaration"})]})]})]})})]})}function ha(s){return s.split(" ").map(t=>t[0]).filter(Boolean).slice(0,2).join("").toUpperCase()}function js({node:s,level:t,isRoot:a}){const[d,r]=D.useState(t<2),i=s.children.length>0;return e.jsxs("div",{className:t>0?"ml-6 relative":"",children:[t>0&&e.jsx("div",{className:"absolute left-[-24px] top-0 bottom-0 w-px bg-slate-200"}),t>0&&e.jsx("div",{className:"absolute left-[-24px] top-5 w-6 h-px bg-slate-200"}),e.jsxs("div",{className:`
          group flex items-center gap-3 rounded-lg border px-4 py-3 transition-all duration-150
          ${a?"border-primary/30 bg-primary-subtle/30 shadow-sm":"border-slate-200 bg-white hover:border-slate-300 hover:shadow-sm"}
          ${i?"cursor-pointer":""}
        `,onClick:()=>i&&r(c=>!c),role:i?"button":void 0,tabIndex:i?0:void 0,onKeyDown:c=>{i&&(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),r(o=>!o))},children:[e.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center",children:i?d?e.jsx(Ps,{className:"h-4 w-4 text-slate-400"}):e.jsx(Ds,{className:"h-4 w-4 text-slate-400"}):e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-slate-300"})}),s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:s.name,className:"h-9 w-9 shrink-0 rounded-full object-cover"}):e.jsx("div",{className:`
              flex h-9 w-9 shrink-0 items-center justify-center rounded-full text-[12px] font-semibold
              ${a?"bg-primary/10 text-primary":"bg-slate-100 text-slate-500"}
            `,children:ha(s.name)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700 truncate",children:s.name}),s.employee_status==="on_notice"&&e.jsx(_,{variant:"warning",className:"text-[9px] px-1.5 py-0",children:"On Notice"}),s.employee_status==="separated"&&e.jsx(_,{variant:"destructive",className:"text-[9px] px-1.5 py-0",children:"Separated"})]}),e.jsxs("p",{className:"text-[11px] text-slate-400 truncate",children:[s.designation,s.department&&` · ${s.department}`]})]}),i&&e.jsxs("span",{className:"text-[11px] text-slate-400 shrink-0",children:[s.children.length," ",s.children.length===1?"report":"reports"]})]}),i&&d&&e.jsx("div",{className:"mt-1 space-y-1",children:s.children.map(c=>e.jsx(js,{node:c,level:t+1},c.id))})]})}function ga(){return e.jsx("div",{className:"space-y-3",children:Array.from({length:4}).map((s,t)=>e.jsxs("div",{className:`flex items-center gap-3 rounded-lg border border-slate-200 px-4 py-3 ${t>0?"ml-6":""}`,children:[e.jsx(U,{className:"h-5 w-5 rounded"}),e.jsx(U,{className:"h-9 w-9 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx(U,{className:"h-3.5 w-32"}),e.jsx(U,{className:"h-2.5 w-48"})]})]},t))})}function wn(){const{data:s,isLoading:t,isError:a}=At();return e.jsxs("div",{children:[e.jsx(P,{title:"Organization Chart",description:"View the reporting structure and organizational hierarchy."}),t&&e.jsx(ga,{}),a&&e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white px-6 py-12 text-center",children:[e.jsx(ze,{className:"mx-auto h-10 w-10 text-slate-300"}),e.jsx("p",{className:"mt-3 text-[14px] font-medium text-slate-700",children:"Unable to load org chart"}),e.jsx("p",{className:"mt-1 text-[12px] text-slate-400",children:"There was an error loading the organization chart. Please try again later."})]}),!t&&!a&&!s&&e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white px-6 py-12 text-center",children:[e.jsx(ze,{className:"mx-auto h-10 w-10 text-slate-300"}),e.jsx("p",{className:"mt-3 text-[14px] font-medium text-slate-700",children:"No data available"}),e.jsx("p",{className:"mt-1 text-[12px] text-slate-400",children:"The organization chart will appear once reporting relationships are configured."})]}),s&&e.jsx("div",{className:"space-y-1",children:e.jsx(js,{node:s,level:0,isRoot:!0})})]})}const ja={leave:Fe,attendance:ve,payroll:Re,core_hr:be,accounts:He,system:He,grievance:Te,workflow:pe},ya={leave:"bg-blue-50 text-blue-500",attendance:"bg-amber-50 text-amber-500",payroll:"bg-green-50 text-green-500",core_hr:"bg-purple-50 text-purple-500",accounts:"bg-slate-100 text-slate-500",system:"bg-slate-100 text-slate-500",grievance:"bg-red-50 text-red-500",workflow:"bg-teal-50 text-teal-500"};function ys(s){var a;return(typeof((a=s.extra)==null?void 0:a.event_code)=="string"?s.extra.event_code:"").split(".")[0]||"general"}function fa({notification:s,onClick:t,isMarking:a}){const d=ys(s),r=ja[d]??is,i=ya[d]??"bg-slate-100 text-slate-500";return e.jsxs("button",{className:`
        w-full text-left flex items-start gap-3 rounded-lg px-4 py-3 transition-colors duration-150
        ${s.is_read?"bg-white hover:bg-slate-50":"bg-blue-50/40 hover:bg-blue-50/60"}
        ${a?"opacity-60 pointer-events-none":""}
      `,onClick:()=>t(s),children:[e.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${i}`,children:e.jsx(r,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:`text-[13px] truncate ${s.is_read?"font-normal text-slate-600":"font-semibold text-slate-800"}`,children:s.title}),!s.is_read&&e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-primary"})]}),s.body&&e.jsx("p",{className:"mt-0.5 text-[12px] text-slate-500 line-clamp-2",children:s.body}),e.jsxs("p",{className:"mt-1 text-[11px] text-slate-400",children:[s.time_since," ago"]})]})]})}function va(){return e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((s,t)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg px-4 py-3",children:[e.jsx(U,{className:"h-9 w-9 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(U,{className:"h-3.5 w-48"}),e.jsx(U,{className:"h-3 w-full"}),e.jsx(U,{className:"h-2.5 w-20"})]})]},t))})}function _n(){const[s,t]=D.useState("all"),a=ae(),{data:d=[],isLoading:r}=qs(s==="unread"?{is_read:!1}:void 0),i=Ls(),c=Ts(),o=D.useMemo(()=>s==="leave"||s==="attendance"||s==="payroll"?d.filter(x=>ys(x)===s):d,[d,s]),m=d.filter(x=>!x.is_read).length;function h(x){x.is_read||i.mutate(x.id),x.action_url&&a(x.action_url)}return e.jsxs("div",{children:[e.jsx(P,{title:"Notifications",description:"Stay updated with your latest alerts and messages.",actions:m>0?e.jsx(N,{size:"sm",variant:"outline",onClick:()=>c.mutate(),disabled:c.isPending,children:c.isPending?"Marking...":"Mark All Read"}):void 0}),e.jsxs(Fs,{value:s,onValueChange:x=>t(x),children:[e.jsxs(Rs,{children:[e.jsxs(ye,{value:"all",children:["All",d.length>0&&e.jsx(_,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:d.length})]}),e.jsxs(ye,{value:"unread",children:["Unread",m>0&&e.jsx(_,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:m})]}),e.jsx(ye,{value:"leave",children:"Leave"}),e.jsx(ye,{value:"attendance",children:"Attendance"}),e.jsx(ye,{value:"payroll",children:"Payroll"})]}),e.jsxs($s,{value:s,className:"mt-4",children:[r&&e.jsx(va,{}),!r&&o.length===0&&e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white px-6 py-12 text-center",children:[e.jsx(Ms,{className:"mx-auto h-10 w-10 text-slate-300"}),e.jsx("p",{className:"mt-3 text-[14px] font-medium text-slate-700",children:"No notifications"}),e.jsx("p",{className:"mt-1 text-[12px] text-slate-400",children:s==="unread"?"You have read all your notifications.":"You have no notifications in this category."})]}),!r&&o.length>0&&e.jsx("div",{className:"rounded-lg border border-slate-200 bg-white overflow-hidden",children:o.map((x,n)=>e.jsxs(D.Fragment,{children:[e.jsx(fa,{notification:x,onClick:h,isMarking:i.isPending&&i.variables===x.id}),n<o.length-1&&e.jsx(qe,{})]},x.id))})]})]})]})}export{Nn as AnnouncementsPage,bn as DeclarationsPage,ln as ESSDashboardPage,dn as ESSDocumentRequestsPage,rn as ESSLayout,_n as ESSNotificationsPage,xn as GrievanceDetailPage,mn as GrievancesPage,gn as JobPostingDetailPage,hn as JobPostingsPage,fn as MyAttendancePage,vn as MyLeaveBalancePage,yn as MyPayslipsPage,cn as MyProfilePage,wn as OrgChartPage,on as ProfileUpdatesPage,pn as RecognitionsPage,un as SalaryQueriesPage,jn as TeamDirectoryPage};
