import{j as e,b as q,a as I,u as le}from"./query-PJ0ZdjbV.js";import{f as St,a as S,O as Ct,k as bt,u as wt}from"./vendor-CWhr2lg4.js";import{a2 as ht,b0 as de,ar as Pt,bw as tt,a6 as kt,bz as Ye,bf as Et,ap as We,p as _,a4 as m,B as k,d as ie,h as re,e as $e,f as Ke,a as Ft,P as pe,s as z,t as U,v as H,w as L,x as h,aa as ge,ab as je,ac as fe,ad as ye,ae as _e,q as l,I as E,r as ce,af as ve,Q as Ne,V as Se,W as Ce,X as be,Y as we,Z as Pe,_ as ke,$ as Ee,a0 as Fe,ag as qe,ah as Ie,ai as Te,aj as K,ak as De,y as Ae,at as ne,o as qt}from"./index-BSPIaiZU.js";import{L as It}from"./layout-dashboard-pgzECxsO.js";import{F as Tt}from"./folder-open-BwrzuZcM.js";import{C as pt}from"./circle-check-Dgh1V3VA.js";import{C as Dt}from"./clipboard-list-DCTO70_z.js";import{H as st}from"./heart-polFWSKf.js";import{S as at}from"./shield-7SCLx_iT.js";import{S as nt}from"./shield-alert-1Mds4K4N.js";import{G as gt}from"./gift-DT0Mx4Cc.js";import{F as Ze}from"./file-chart-column-increasing-DonUpE5r.js";import{C as et}from"./chart-column-DbfNf7gS.js";import{B as X}from"./badge-C34iUAiA.js";import{P as me}from"./page-header-D8tSLbK0.js";import{T as At}from"./trending-up-Cognoqa9.js";import{A as ct}from"./arrow-right-Bmt6JCm_.js";import{u as xe,t as ue,o as he,c as Me,s as P,b as ae,e as oe,l as Vt,a as ze}from"./date-range-picker-BB0TgAn8.js";import{u as Ve}from"./use-data-table-state-CKRg6qY2.js";import{D as Oe}from"./data-table-D_-xOEqd.js";import{A as Ge}from"./async-select-BUbwdJEZ.js";import{i as Qe,w as it,a as rt}from"./date-validation-D9gNvaP9.js";import{E as Re}from"./ellipsis-DaNBIBaV.js";import{U as Ot}from"./user-check-B2v_CMeM.js";import{C as Xe}from"./circle-check-big-DY9NZlUS.js";import{S as Je}from"./status-badge-DPaiL_rL.js";import{E as Ue}from"./employee-select-DtUobKxP.js";import{U as Rt}from"./undo-2-CyjnlLm8.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 $t=ht("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
 * @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 Be=ht("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),Kt=[{heading:"Overview",items:[{to:"/health-safety",label:"Dashboard",description:"Safety overview",icon:It,permission:["health_safety","dashboard","read"]}]},{heading:"Incidents",items:[{to:"/health-safety/incidents",label:"Incidents",description:"Report & track",icon:Be,permission:["health_safety","incident","read"]},{to:"/health-safety/incident-categories",label:"Categories",description:"Incident types",icon:Tt,permission:["health_safety","incident_category","read"]},{to:"/health-safety/investigations",label:"Investigations",description:"Incident investigations",icon:Pt,permission:["health_safety","investigation","read"]},{to:"/health-safety/corrective-actions",label:"Corrective Actions",description:"Track actions",icon:pt,permission:["health_safety","corrective_action","read"]}]},{heading:"Safety Training",items:[{to:"/health-safety/safety-trainings",label:"Training Programs",description:"Safety courses",icon:tt,permission:["health_safety","safety_training","read"]},{to:"/health-safety/safety-training-records",label:"Training Records",description:"Employee records",icon:Dt,permission:["health_safety","safety_training_record","read"]}]},{heading:"Medical",items:[{to:"/health-safety/medical-fitness",label:"Medical Fitness",description:"Health records",icon:st,permission:["health_safety","medical_fitness","read"]}]},{heading:"PPE",items:[{to:"/health-safety/ppe-items",label:"PPE Items",description:"Equipment catalog",icon:at,permission:["health_safety","ppe_item","read"]},{to:"/health-safety/ppe-issues",label:"PPE Issues",description:"Issue & track",icon:$t,permission:["health_safety","ppe_issue","read"]}]},{heading:"Compliance",items:[{to:"/health-safety/posh-complaints",label:"POSH Complaints",description:"POSH management",icon:nt,permission:["health_safety","posh_complaint","read"]}]},{heading:"Welfare",items:[{to:"/health-safety/welfare-programs",label:"Programs",description:"Welfare schemes",icon:gt,permission:["health_safety","welfare_program","read"]},{to:"/health-safety/welfare-enrollments",label:"Enrollments",description:"Manage enrollments",icon:kt,permission:["health_safety","welfare_enrollment","read"]}]},{heading:"Configuration",items:[{to:"/health-safety/settings",label:"Settings",description:"Module config",icon:Ye,permission:["health_safety","settings","read"]}]},{heading:"Insights",items:[{to:"/health-safety/reports",label:"Reports",description:"Safety reports",icon:Ze,permission:["health_safety","report","read"]},{to:"/health-safety/analytics",label:"Analytics",description:"Trends & insights",icon:et,permission:["health_safety","analytics","read"]}]}];function Mt({item:a,isActive:s}){const n=a.icon;return e.jsxs(bt,{to:a.to,end:a.to==="/health-safety",className:We("group relative flex items-center gap-3 rounded-lg px-3 py-2.5 transition-all duration-150",s?"bg-primary-subtle/70":"hover:bg-slate-50"),children:[s&&e.jsx("span",{className:"absolute left-0 top-2.5 bottom-2.5 w-[3px] rounded-r-full bg-primary"}),e.jsx("div",{className:We("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors duration-150",s?"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(n,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:We("block text-[13px] truncate leading-tight",s?"font-medium text-primary":"font-medium text-slate-700 group-hover:text-slate-900"),children:a.label}),e.jsx("span",{className:We("block text-[11px] truncate leading-tight mt-0.5",s?"text-primary/60":"text-slate-400"),children:a.description})]})]})}function Ya(){const a=St(),s=S.useRef(null),{hasPermission:n}=de();S.useEffect(()=>{var u;(u=s.current)==null||u.scrollTo(0,0)},[a.pathname]);const d=S.useMemo(()=>Kt.map(u=>({...u,items:u.items.filter(x=>n(x.permission[0],x.permission[1],x.permission[2]))})).filter(u=>u.items.length>0),[n]);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:"Health, Safety & Welfare"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-slate-400",children:"Incidents, training, PPE & welfare"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-3 py-3 scrollbar-thin",children:d.map((u,x)=>e.jsxs("div",{className:We(x>0&&"mt-6"),children:[e.jsx("p",{className:"mb-2 px-3 text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400",children:u.heading}),e.jsx("div",{className:"space-y-0.5",children:u.items.map(C=>{const w=C.to==="/health-safety"?a.pathname==="/health-safety":Et(a.pathname,C.to);return e.jsx(Mt,{item:C,isActive:w},C.to)})})]},u.heading))})]}),e.jsx("main",{ref:s,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(Ct,{})})})]})}const v="/health-safety",j={settings:["health-safety","settings"],incidentCategories:["health-safety","incident-categories"],incidents:["health-safety","incidents"],incident:a=>["health-safety","incidents",a],investigations:["health-safety","investigations"],correctiveActions:["health-safety","corrective-actions"],safetyTrainings:["health-safety","safety-trainings"],safetyTrainingRecords:["health-safety","safety-training-records"],medicalFitness:["health-safety","medical-fitness"],ppeItems:["health-safety","ppe-items"],ppeIssues:["health-safety","ppe-issues"],poshComplaints:["health-safety","posh-complaints"],welfarePrograms:["health-safety","welfare-programs"],welfareEnrollments:["health-safety","welfare-enrollments"],dashboard:["health-safety","dashboard"],reports:["health-safety","reports"],analytics:["health-safety","analytics"]};function Qt(){return le({queryKey:j.settings,queryFn:()=>_.get(`${v}/settings/`).then(a=>a.data)})}function zt(){const a=q();return I({mutationFn:s=>_.patch(`${v}/settings/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.settings}),m.success("Settings updated")},onError:()=>m.error("Failed to update settings")})}function jt(a){return le({queryKey:[...j.incidentCategories,a],queryFn:()=>_.get(`${v}/incident-categories/`,{params:a}).then(s=>s.data)})}function Ut(){const a=q();return I({mutationFn:s=>_.post(`${v}/incident-categories/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.incidentCategories}),m.success("Incident category created")},onError:()=>m.error("Failed to create incident category")})}function Ht(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/incident-categories/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.incidentCategories}),m.success("Incident category updated")},onError:()=>m.error("Failed to update incident category")})}function Lt(){const a=q();return I({mutationFn:s=>_.delete(`${v}/incident-categories/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.incidentCategories}),m.success("Incident category deleted")},onError:()=>m.error("Failed to delete incident category")})}function lt(a){return le({queryKey:[...j.incidents,a],queryFn:()=>_.get(`${v}/incidents/`,{params:a}).then(s=>s.data)})}function Xa(a){return le({queryKey:j.incident(a),queryFn:()=>_.get(`${v}/incidents/${a}/`).then(s=>s.data),enabled:!!a})}function Gt(){const a=q();return I({mutationFn:s=>_.post(`${v}/incidents/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.incidents}),a.invalidateQueries({queryKey:j.dashboard}),m.success("Incident reported")},onError:()=>m.error("Failed to report incident")})}function Wt(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/incidents/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.incidents}),a.invalidateQueries({queryKey:j.dashboard}),m.success("Incident updated")},onError:()=>m.error("Failed to update incident")})}function Bt(){const a=q();return I({mutationFn:s=>_.delete(`${v}/incidents/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.incidents}),a.invalidateQueries({queryKey:j.dashboard}),m.success("Incident deleted")},onError:()=>m.error("Failed to delete incident")})}function Yt(){const a=q();return I({mutationFn:({id:s,assigned_to:n})=>_.post(`${v}/incidents/${s}/assign/`,{assigned_to:n}).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.incidents}),m.success("Incident assigned")},onError:()=>m.error("Failed to assign incident")})}function Xt(){const a=q();return I({mutationFn:({id:s,root_cause:n})=>_.post(`${v}/incidents/${s}/resolve/`,{root_cause:n}).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.incidents}),a.invalidateQueries({queryKey:j.dashboard}),m.success("Incident resolved")},onError:()=>m.error("Failed to resolve incident")})}function Jt(a){return le({queryKey:[...j.investigations,a],queryFn:()=>_.get(`${v}/investigations/`,{params:a}).then(s=>s.data)})}function Zt(){const a=q();return I({mutationFn:s=>_.post(`${v}/investigations/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.investigations}),a.invalidateQueries({queryKey:j.incidents}),m.success("Investigation created")},onError:()=>m.error("Failed to create investigation")})}function es(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/investigations/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.investigations}),m.success("Investigation updated")},onError:()=>m.error("Failed to update investigation")})}function ts(){const a=q();return I({mutationFn:s=>_.delete(`${v}/investigations/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.investigations}),m.success("Investigation deleted")},onError:()=>m.error("Failed to delete investigation")})}function ss(a){return le({queryKey:[...j.correctiveActions,a],queryFn:()=>_.get(`${v}/corrective-actions/`,{params:a}).then(s=>s.data)})}function as(){const a=q();return I({mutationFn:s=>_.post(`${v}/corrective-actions/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.correctiveActions}),m.success("Corrective action created")},onError:()=>m.error("Failed to create corrective action")})}function ns(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/corrective-actions/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.correctiveActions}),m.success("Corrective action updated")},onError:()=>m.error("Failed to update corrective action")})}function is(){const a=q();return I({mutationFn:s=>_.delete(`${v}/corrective-actions/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.correctiveActions}),m.success("Corrective action deleted")},onError:()=>m.error("Failed to delete corrective action")})}function rs(){const a=q();return I({mutationFn:({id:s,effectiveness_review:n})=>_.post(`${v}/corrective-actions/${s}/complete/`,{effectiveness_review:n}).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.correctiveActions}),a.invalidateQueries({queryKey:j.dashboard}),m.success("Corrective action completed")},onError:()=>m.error("Failed to complete corrective action")})}function ls(){const a=q();return I({mutationFn:s=>_.post(`${v}/corrective-actions/${s}/verify/`).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.correctiveActions}),m.success("Corrective action verified")},onError:()=>m.error("Failed to verify corrective action")})}function ft(a){return le({queryKey:[...j.safetyTrainings,a],queryFn:()=>_.get(`${v}/safety-trainings/`,{params:a}).then(s=>s.data)})}function cs(){const a=q();return I({mutationFn:s=>_.post(`${v}/safety-trainings/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.safetyTrainings}),m.success("Safety training created")},onError:()=>m.error("Failed to create safety training")})}function os(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/safety-trainings/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.safetyTrainings}),m.success("Safety training updated")},onError:()=>m.error("Failed to update safety training")})}function ds(){const a=q();return I({mutationFn:s=>_.delete(`${v}/safety-trainings/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.safetyTrainings}),m.success("Safety training deleted")},onError:()=>m.error("Failed to delete safety training")})}function ms(a){return le({queryKey:[...j.safetyTrainingRecords,a],queryFn:()=>_.get(`${v}/safety-training-records/`,{params:a}).then(s=>s.data)})}function xs(){const a=q();return I({mutationFn:s=>_.post(`${v}/safety-training-records/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.safetyTrainingRecords}),m.success("Training record created")},onError:()=>m.error("Failed to create training record")})}function us(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/safety-training-records/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.safetyTrainingRecords}),m.success("Training record updated")},onError:()=>m.error("Failed to update training record")})}function hs(){const a=q();return I({mutationFn:s=>_.delete(`${v}/safety-training-records/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.safetyTrainingRecords}),m.success("Training record deleted")},onError:()=>m.error("Failed to delete training record")})}function ps(){const a=q();return I({mutationFn:({id:s,score:n,result:d})=>_.post(`${v}/safety-training-records/${s}/complete/`,{score:n,result:d}).then(u=>u.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.safetyTrainingRecords}),a.invalidateQueries({queryKey:j.dashboard}),m.success("Training record completed")},onError:()=>m.error("Failed to complete training record")})}function gs(a){return le({queryKey:[...j.medicalFitness,a],queryFn:()=>_.get(`${v}/medical-fitness/`,{params:a}).then(s=>s.data)})}function js(){const a=q();return I({mutationFn:s=>_.post(`${v}/medical-fitness/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.medicalFitness}),m.success("Medical fitness record created")},onError:()=>m.error("Failed to create medical fitness record")})}function fs(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/medical-fitness/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.medicalFitness}),m.success("Medical fitness record updated")},onError:()=>m.error("Failed to update medical fitness record")})}function ys(){const a=q();return I({mutationFn:s=>_.delete(`${v}/medical-fitness/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.medicalFitness}),m.success("Medical fitness record deleted")},onError:()=>m.error("Failed to delete medical fitness record")})}function yt(a){return le({queryKey:[...j.ppeItems,a],queryFn:()=>_.get(`${v}/ppe-items/`,{params:a}).then(s=>s.data)})}function _s(){const a=q();return I({mutationFn:s=>_.post(`${v}/ppe-items/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.ppeItems}),m.success("PPE item created")},onError:()=>m.error("Failed to create PPE item")})}function vs(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/ppe-items/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.ppeItems}),m.success("PPE item updated")},onError:()=>m.error("Failed to update PPE item")})}function Ns(){const a=q();return I({mutationFn:s=>_.delete(`${v}/ppe-items/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.ppeItems}),m.success("PPE item deleted")},onError:()=>m.error("Failed to delete PPE item")})}function Ss(a){return le({queryKey:[...j.ppeIssues,a],queryFn:()=>_.get(`${v}/ppe-issues/`,{params:a}).then(s=>s.data)})}function Cs(){const a=q();return I({mutationFn:s=>_.post(`${v}/ppe-issues/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.ppeIssues}),m.success("PPE issued")},onError:()=>m.error("Failed to issue PPE")})}function bs(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/ppe-issues/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.ppeIssues}),m.success("PPE issue updated")},onError:()=>m.error("Failed to update PPE issue")})}function ws(){const a=q();return I({mutationFn:s=>_.delete(`${v}/ppe-issues/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.ppeIssues}),m.success("PPE issue deleted")},onError:()=>m.error("Failed to delete PPE issue")})}function Ps(){const a=q();return I({mutationFn:({id:s,condition_at_return:n})=>_.post(`${v}/ppe-issues/${s}/return_item/`,{condition_at_return:n}).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.ppeIssues}),a.invalidateQueries({queryKey:j.dashboard}),m.success("PPE returned")},onError:()=>m.error("Failed to return PPE")})}function ks(a){return le({queryKey:[...j.poshComplaints,a],queryFn:()=>_.get(`${v}/posh-complaints/`,{params:a}).then(s=>s.data)})}function Es(){const a=q();return I({mutationFn:s=>_.post(`${v}/posh-complaints/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.poshComplaints}),a.invalidateQueries({queryKey:j.dashboard}),m.success("POSH complaint filed")},onError:()=>m.error("Failed to file POSH complaint")})}function Fs(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/posh-complaints/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.poshComplaints}),m.success("POSH complaint updated")},onError:()=>m.error("Failed to update POSH complaint")})}function qs(){const a=q();return I({mutationFn:s=>_.delete(`${v}/posh-complaints/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.poshComplaints}),m.success("POSH complaint deleted")},onError:()=>m.error("Failed to delete POSH complaint")})}function Is(){const a=q();return I({mutationFn:s=>_.post(`${v}/posh-complaints/${s}/acknowledge/`).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.poshComplaints}),a.invalidateQueries({queryKey:j.dashboard}),m.success("POSH complaint acknowledged")},onError:()=>m.error("Failed to acknowledge POSH complaint")})}function _t(a){return le({queryKey:[...j.welfarePrograms,a],queryFn:()=>_.get(`${v}/welfare-programs/`,{params:a}).then(s=>s.data)})}function Ts(){const a=q();return I({mutationFn:s=>_.post(`${v}/welfare-programs/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.welfarePrograms}),m.success("Welfare program created")},onError:()=>m.error("Failed to create welfare program")})}function Ds(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/welfare-programs/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.welfarePrograms}),m.success("Welfare program updated")},onError:()=>m.error("Failed to update welfare program")})}function As(){const a=q();return I({mutationFn:s=>_.delete(`${v}/welfare-programs/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.welfarePrograms}),m.success("Welfare program deleted")},onError:()=>m.error("Failed to delete welfare program")})}function Vs(a){return le({queryKey:[...j.welfareEnrollments,a],queryFn:()=>_.get(`${v}/welfare-enrollments/`,{params:a}).then(s=>s.data)})}function Os(){const a=q();return I({mutationFn:s=>_.post(`${v}/welfare-enrollments/`,s).then(n=>n.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.welfareEnrollments}),m.success("Welfare enrollment created")},onError:()=>m.error("Failed to create welfare enrollment")})}function Rs(){const a=q();return I({mutationFn:({id:s,...n})=>_.patch(`${v}/welfare-enrollments/${s}/`,n).then(d=>d.data),onSuccess:()=>{a.invalidateQueries({queryKey:j.welfareEnrollments}),m.success("Welfare enrollment updated")},onError:()=>m.error("Failed to update welfare enrollment")})}function $s(){const a=q();return I({mutationFn:s=>_.delete(`${v}/welfare-enrollments/${s}/`),onSuccess:()=>{a.invalidateQueries({queryKey:j.welfareEnrollments}),m.success("Welfare enrollment deleted")},onError:()=>m.error("Failed to delete welfare enrollment")})}function Ks(){return le({queryKey:j.dashboard,queryFn:()=>_.get(`${v}/dashboard/`).then(a=>a.data)})}function Ja(a){return le({queryKey:[...j.reports,a],queryFn:()=>_.get(`${v}/reports/`,{params:a}).then(s=>s.data)})}function Za(){return le({queryKey:j.analytics,queryFn:()=>_.get(`${v}/analytics/`).then(a=>a.data)})}const Ms={reported:"warning",under_investigation:"default",corrective_action:"default",resolved:"success",closed:"secondary"},Qs={minor:"secondary",moderate:"default",serious:"warning",critical:"destructive",fatal:"destructive"};function en(){const a=wt(),{data:s,isLoading:n}=Ks();return e.jsxs("div",{children:[e.jsx(me,{title:"Health & Safety Dashboard",description:"Overview of incidents, safety compliance, PPE tracking, and welfare programs.",actions:e.jsxs(k,{size:"sm",onClick:()=>a("/health-safety/incidents"),children:[e.jsx(Be,{className:"mr-1.5 h-3.5 w-3.5"})," View Incidents"]})}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[e.jsx(ie,{children:e.jsx(re,{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-red-500/10",children:e.jsx(Be,{className:"h-4.5 w-4.5 text-red-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Open Incidents"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:n?"...":(s==null?void 0:s.open_incidents)??0})]})]})})}),e.jsx(ie,{children:e.jsx(re,{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(pt,{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:"Overdue Actions"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:n?"...":(s==null?void 0:s.overdue_corrective_actions)??0})]})]})})}),e.jsx(ie,{children:e.jsx(re,{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(At,{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:"Incidents This Month"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:n?"...":(s==null?void 0:s.incidents_this_month)??0})]})]})})}),e.jsx(ie,{children:e.jsx(re,{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-violet-500/10",children:e.jsx(nt,{className:"h-4.5 w-4.5 text-violet-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"POSH Pending"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:n?"...":(s==null?void 0:s.posh_pending)??0})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[e.jsx(ie,{children:e.jsx(re,{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-blue-500/10",children:e.jsx(tt,{className:"h-4.5 w-4.5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Trainings Due"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:n?"...":(s==null?void 0:s.safety_trainings_due)??0})]})]})})}),e.jsx(ie,{children:e.jsx(re,{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-orange-500/10",children:e.jsx(at,{className:"h-4.5 w-4.5 text-orange-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"PPE Replacements Due"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:n?"...":(s==null?void 0:s.ppe_replacements_due)??0})]})]})})}),e.jsx(ie,{children:e.jsx(re,{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(st,{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:"Total Incidents"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:n?"...":(s==null?void 0:s.total_incidents)??0})]})]})})}),e.jsx(ie,{children:e.jsx(re,{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-green-500/10",children:e.jsx(gt,{className:"h-4.5 w-4.5 text-green-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Active Welfare"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:n?"...":(s==null?void 0:s.active_welfare_programs)??0})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs(ie,{children:[e.jsx($e,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ke,{className:"text-[14px]",children:"Recent Incidents"}),e.jsxs(k,{variant:"ghost",size:"sm",className:"h-7 text-[12px] gap-1",onClick:()=>a("/health-safety/incidents"),children:["View all ",e.jsx(ct,{className:"h-3 w-3"})]})]})}),e.jsx(re,{children:n?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(d=>e.jsx("div",{className:"h-14 rounded-lg skeleton-shimmer"},d))}):((s==null?void 0:s.recent_incidents)??[]).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Be,{className:"h-8 w-8 text-slate-300 mb-2"}),e.jsx("p",{className:"text-[13px] text-slate-500",children:"No recent incidents"})]}):e.jsx("ul",{className:"space-y-2",children:((s==null?void 0:s.recent_incidents)??[]).slice(0,5).map(d=>e.jsxs("li",{className:"flex items-center justify-between rounded-lg border border-slate-100 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-800 truncate",children:d.title}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:[d.incident_number," · ",new Date(d.incident_date).toLocaleDateString("en-GB",{day:"numeric",month:"short"})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2",children:[e.jsx(X,{variant:Qs[d.severity],className:"text-[11px]",children:d.severity}),e.jsx(X,{variant:Ms[d.status],className:"text-[11px]",children:d.status.replace(/_/g," ")})]})]},d.id))})})]}),e.jsxs(ie,{children:[e.jsx($e,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ke,{className:"text-[14px]",children:"Upcoming Medical Checks"}),e.jsxs(k,{variant:"ghost",size:"sm",className:"h-7 text-[12px] gap-1",onClick:()=>a("/health-safety/medical-fitness"),children:["View all ",e.jsx(ct,{className:"h-3 w-3"})]})]})}),e.jsx(re,{children:n?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(d=>e.jsx("div",{className:"h-14 rounded-lg skeleton-shimmer"},d))}):((s==null?void 0:s.upcoming_medical_checks)??[]).length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(Ft,{className:"h-8 w-8 text-slate-300 mb-2"}),e.jsx("p",{className:"text-[13px] text-slate-500",children:"No upcoming medical checks"})]}):e.jsx("ul",{className:"space-y-2",children:((s==null?void 0:s.upcoming_medical_checks)??[]).slice(0,5).map(d=>e.jsxs("li",{className:"flex items-center justify-between rounded-lg border border-slate-100 px-3 py-2.5",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-800 truncate",children:d.employee_name}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:[d.examination_type.replace(/_/g," ")," ·"," ",d.next_due_date?new Date(d.next_due_date).toLocaleDateString("en-GB",{day:"numeric",month:"short"}):"--"]})]}),e.jsx(X,{variant:"outline",className:"ml-2 text-[11px] capitalize",children:d.fitness_status.replace(/_/g," ")})]},d.id))})})]})]})]})}const zs={reported:"warning",under_investigation:"default",corrective_action:"default",resolved:"success",closed:"secondary"},Us={minor:"secondary",moderate:"default",serious:"warning",critical:"destructive",fatal:"destructive"},ot=[{value:"minor",label:"Minor"},{value:"moderate",label:"Moderate"},{value:"serious",label:"Serious"},{value:"critical",label:"Critical"},{value:"fatal",label:"Fatal"}],Hs=[{value:"none",label:"None"},{value:"first_aid",label:"First Aid"},{value:"medical_treatment",label:"Medical Treatment"},{value:"lost_time",label:"Lost Time"},{value:"fatality",label:"Fatality"}],Ls=he({title:P().min(1,"Title is required"),description:P().min(1,"Description is required"),category:P().min(1,"Category is required"),incident_date:Qe("Date is required"),location:P().min(1,"Location is required"),severity:oe(["minor","moderate","serious","critical","fatal"]),injury_type:oe(["none","first_aid","medical_treatment","lost_time","fatality"]),immediate_action_taken:P().optional(),is_anonymous:ae().optional(),property_damage_cost:P().optional(),lost_work_days:Me.number().int().min(0).optional()});function tn(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),[A,O]=S.useState(""),{hasPermission:G,requirePermission:V}=de(),J=G("health_safety","incident","create"),$=G("health_safety","incident","update"),Q=G("health_safety","incident","delete"),{pagination:Z,setPagination:W,sorting:ee,setSorting:M,globalFilter:te,setGlobalFilter:b,queryParams:F}=Ve(),B={...F,...C&&{status:C},...A&&{severity:A}},{data:N,isLoading:D}=lt(B),[R,i]=S.useState(""),{data:Y}=jt({page_size:100,is_active:!0,search:R||void 0}),c=Gt(),p=Wt(),T=Bt(),se=Yt(),t=Xt(),f=xe({resolver:ue(Ls),defaultValues:{severity:"moderate",injury_type:"none",is_anonymous:!1}});function o(){V("health_safety","incident","create")&&(d(null),f.reset({severity:"moderate",injury_type:"none",title:"",description:"",category:"",incident_date:"",location:"",is_anonymous:!1}),s(!0))}function r(g){V("health_safety","incident","update")&&(d(g),f.reset({title:g.title,description:g.description,category:g.category,incident_date:g.incident_date,location:g.location,severity:g.severity,injury_type:g.injury_type,immediate_action_taken:g.immediate_action_taken,is_anonymous:g.is_anonymous,property_damage_cost:g.property_damage_cost,lost_work_days:g.lost_work_days}),s(!0))}function y(g){const Le={...g,immediate_action_taken:g.immediate_action_taken??"",property_damage_cost:g.property_damage_cost??"0",lost_work_days:g.lost_work_days??0,is_anonymous:g.is_anonymous??!1,reported_by:"",company:"",persons_involved:[],witnesses:[],root_cause:"",status:"reported",assigned_to:null,resolved_date:null,branch:null};n?p.mutate({id:n.id,...Le},{onSuccess:()=>{s(!1),f.reset()}}):c.mutate(Le,{onSuccess:()=>{s(!1),f.reset()}})}function He(g){w(g==="__all__"?"":g),W(Le=>({...Le,pageIndex:0}))}function vt(g){O(g==="__all__"?"":g),W(Le=>({...Le,pageIndex:0}))}const Nt=[{key:"title",header:"Incident",render:g=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:g.title}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:g.incident_number})]})},{key:"category_name",header:"Category",className:"w-32",render:g=>e.jsx("span",{className:"text-[12px] text-slate-600",children:g.category_name??"--"})},{key:"severity",header:"Severity",className:"w-24",render:g=>e.jsx(X,{variant:Us[g.severity],className:"text-[11px] capitalize",children:g.severity})},{key:"injury_type",header:"Injury",className:"w-28",render:g=>e.jsx("span",{className:"text-[12px] text-slate-600 capitalize",children:g.injury_type.replace(/_/g," ")})},{key:"status",header:"Status",className:"w-32",render:g=>e.jsx(X,{variant:zs[g.status],className:"text-[11px] capitalize",children:g.status.replace(/_/g," ")})},{key:"incident_date",header:"Date",className:"w-28",render:g=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(g.incident_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"actions",header:"",className:"w-10",render:g=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[$&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>r(g),children:"Edit"}),$&&g.status==="reported"&&e.jsxs(K,{className:"gap-2 text-[13px]",onClick:()=>se.mutate({id:g.id,assigned_to:""}),children:[e.jsx(Ot,{className:"h-3.5 w-3.5 text-slate-400"}),"Assign"]}),$&&(g.status==="under_investigation"||g.status==="corrective_action")&&e.jsxs(K,{className:"gap-2 text-[13px]",onClick:()=>t.mutate({id:g.id}),children:[e.jsx(Xe,{className:"h-3.5 w-3.5 text-slate-400"}),"Resolve"]}),Q&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(g),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"Incidents",description:"Report, track, and manage workplace incidents.",actions:J&&e.jsxs(k,{size:"sm",onClick:o,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," Report Incident"]})}),e.jsx(Oe,{actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(z,{value:C,onValueChange:He,children:[e.jsx(U,{className:"w-[150px] h-9",children:e.jsx(H,{placeholder:"All statuses"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"reported",children:"Reported"}),e.jsx(h,{value:"under_investigation",children:"Under Investigation"}),e.jsx(h,{value:"corrective_action",children:"Corrective Action"}),e.jsx(h,{value:"resolved",children:"Resolved"}),e.jsx(h,{value:"closed",children:"Closed"})]})]}),e.jsxs(z,{value:A,onValueChange:vt,children:[e.jsx(U,{className:"w-[140px] h-9",children:e.jsx(H,{placeholder:"All severities"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Severities"}),ot.map(g=>e.jsx(h,{value:g.value,children:g.label},g.value))]})]})]}),columns:Nt,data:(N==null?void 0:N.results)??[],isLoading:D,rowKey:g=>g.id,searchKeys:["title","incident_number"],searchPlaceholder:"Search incidents...",emptyMessage:"No incidents found",emptyDescription:"Report the first incident to get started.",totalCount:(N==null?void 0:N.count)??0,pagination:Z,onPaginationChange:W,sorting:ee,onSortingChange:M,globalFilter:te,onGlobalFilterChange:b}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Incident":"Report Incident"}),e.jsx(_e,{children:n?"Update incident details.":"Report a new workplace incident."})]}),e.jsxs("form",{onSubmit:f.handleSubmit(y),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Title *"}),e.jsx(E,{className:"mt-1.5",...f.register("title"),placeholder:"e.g. Slip and fall in warehouse"}),f.formState.errors.title&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:f.formState.errors.title.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Description *"}),e.jsx(ce,{className:"mt-1.5",...f.register("description"),rows:3,placeholder:"Detailed description of the incident..."}),f.formState.errors.description&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:f.formState.errors.description.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Category *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Ge,{value:f.watch("category")??null,onValueChange:g=>f.setValue("category",g,{shouldValidate:!0}),onSearch:i,selectedLabel:(n==null?void 0:n.category_name)??void 0,options:((Y==null?void 0:Y.results)??[]).map(g=>({value:g.id,label:g.name,hint:g.code})),placeholder:"Select category",searchPlaceholder:"Search categories..."})}),f.formState.errors.category&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:f.formState.errors.category.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Incident Date *"}),e.jsx(E,{className:"mt-1.5",type:"date",...f.register("incident_date")}),f.formState.errors.incident_date&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:f.formState.errors.incident_date.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Location *"}),e.jsx(E,{className:"mt-1.5",...f.register("location"),placeholder:"e.g. Warehouse B"}),f.formState.errors.location&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:f.formState.errors.location.message})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Severity *"}),e.jsxs(z,{value:f.watch("severity"),onValueChange:g=>f.setValue("severity",g),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:ot.map(g=>e.jsx(h,{value:g.value,children:g.label},g.value))})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Injury Type *"}),e.jsxs(z,{value:f.watch("injury_type"),onValueChange:g=>f.setValue("injury_type",g),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:Hs.map(g=>e.jsx(h,{value:g.value,children:g.label},g.value))})]})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Immediate Action Taken"}),e.jsx(ce,{className:"mt-1.5",...f.register("immediate_action_taken"),rows:2,placeholder:"Describe immediate actions..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Property Damage Cost"}),e.jsx(E,{className:"mt-1.5",...f.register("property_damage_cost"),placeholder:"e.g. 5000.00"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Lost Work Days"}),e.jsx(E,{className:"mt-1.5",type:"number",...f.register("lost_work_days"),placeholder:"0"})]})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:f.handleSubmit(y),disabled:c.isPending||p.isPending,children:c.isPending||p.isPending?"Saving...":n?"Update":"Report"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:g=>!g&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete Incident"}),e.jsxs(Pe,{children:["Are you sure you want to delete"," ",e.jsx("span",{className:"font-medium text-slate-700",children:u==null?void 0:u.title}),"? This action cannot be undone."]})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&T.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const Gs={minor:"secondary",moderate:"default",serious:"warning",critical:"destructive",fatal:"destructive"},Ws=[{value:"minor",label:"Minor"},{value:"moderate",label:"Moderate"},{value:"serious",label:"Serious"},{value:"critical",label:"Critical"},{value:"fatal",label:"Fatal"}],Bs=he({name:P().min(1,"Name is required"),code:P().min(1,"Code is required"),description:P().optional(),severity_level:oe(["minor","moderate","serious","critical","fatal"]),requires_investigation:ae(),is_reportable:ae(),is_active:ae()});function sn(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),{hasPermission:C,requirePermission:w}=de(),A=C("health_safety","incident_category","create"),O=C("health_safety","incident_category","update"),G=C("health_safety","incident_category","delete"),{pagination:V,setPagination:J,sorting:$,setSorting:Q,globalFilter:Z,setGlobalFilter:W,queryParams:ee}=Ve(),{data:M,isLoading:te}=jt(ee),b=Ut(),F=Ht(),B=Lt(),N=xe({resolver:ue(Bs),defaultValues:{severity_level:"moderate",requires_investigation:!1,is_reportable:!0,is_active:!0}});function D(){w("health_safety","incident_category","create")&&(d(null),N.reset({severity_level:"moderate",requires_investigation:!1,is_reportable:!0,is_active:!0,name:"",code:"",description:""}),s(!0))}function R(c){w("health_safety","incident_category","update")&&(d(c),N.reset({name:c.name,code:c.code,description:c.description,severity_level:c.severity_level,requires_investigation:c.requires_investigation,is_reportable:c.is_reportable,is_active:c.is_active}),s(!0))}function i(c){const p={...c,company:"",description:c.description??""};n?F.mutate({id:n.id,...p},{onSuccess:()=>{s(!1),N.reset()}}):b.mutate(p,{onSuccess:()=>{s(!1),N.reset()}})}const Y=[{key:"name",header:"Category",render:c=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:c.name}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:c.code})]})},{key:"severity_level",header:"Severity",className:"w-24",render:c=>e.jsx(X,{variant:Gs[c.severity_level],className:"text-[11px] capitalize",children:c.severity_level})},{key:"requires_investigation",header:"Investigation",className:"w-28",render:c=>e.jsx(X,{variant:c.requires_investigation?"warning":"secondary",className:"text-[11px]",children:c.requires_investigation?"Required":"Optional"})},{key:"is_reportable",header:"Reportable",className:"w-24",render:c=>e.jsx("span",{className:"text-[12px] text-slate-600",children:c.is_reportable?"Yes":"No"})},{key:"is_active",header:"Status",className:"w-24",render:c=>e.jsx(Je,{status:c.is_active?"active":"inactive"})},{key:"actions",header:"",className:"w-10",render:c=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[O&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>R(c),children:"Edit"}),G&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(c),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"Incident Categories",description:"Define and manage incident classification categories.",actions:A&&e.jsxs(k,{size:"sm",onClick:D,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," New Category"]})}),e.jsx(Oe,{columns:Y,data:(M==null?void 0:M.results)??[],isLoading:te,rowKey:c=>c.id,searchKeys:["name","code"],searchPlaceholder:"Search categories...",emptyMessage:"No incident categories found",emptyDescription:"Create your first incident category.",totalCount:(M==null?void 0:M.count)??0,pagination:V,onPaginationChange:J,sorting:$,onSortingChange:Q,globalFilter:Z,onGlobalFilterChange:W}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Category":"New Category"}),e.jsx(_e,{children:n?"Update category details.":"Create a new incident category."})]}),e.jsxs("form",{onSubmit:N.handleSubmit(i),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(E,{className:"mt-1.5",...N.register("name"),placeholder:"e.g. Slip and Fall"}),N.formState.errors.name&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:N.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(E,{className:"mt-1.5",...N.register("code"),placeholder:"e.g. INC-SF"}),N.formState.errors.code&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:N.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(ce,{className:"mt-1.5",...N.register("description"),rows:3,placeholder:"Category description..."})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Severity Level *"}),e.jsxs(z,{value:N.watch("severity_level"),onValueChange:c=>N.setValue("severity_level",c),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:Ws.map(c=>e.jsx(h,{value:c.value,children:c.label},c.value))})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Requires Investigation"}),e.jsx(ne,{checked:N.watch("requires_investigation"),onCheckedChange:c=>N.setValue("requires_investigation",c)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Is Reportable"}),e.jsx(ne,{checked:N.watch("is_reportable"),onCheckedChange:c=>N.setValue("is_reportable",c)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Active"}),e.jsx(ne,{checked:N.watch("is_active"),onCheckedChange:c=>N.setValue("is_active",c)})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:N.handleSubmit(i),disabled:b.isPending||F.isPending,children:b.isPending||F.isPending?"Saving...":n?"Update":"Create"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:c=>!c&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete Category"}),e.jsxs(Pe,{children:["Are you sure you want to delete ",e.jsx("span",{className:"font-medium text-slate-700",children:u==null?void 0:u.name}),"? This action cannot be undone."]})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&B.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const Ys={in_progress:"warning",completed:"success",reviewed:"default"},Xs=he({incident:P().min(1,"Incident is required"),investigator:P().min(1,"Investigator is required"),investigation_date:Qe("Date is required"),findings:P().min(1,"Findings are required"),root_cause_analysis:P().optional(),recommendations:P().optional(),status:oe(["in_progress","completed","reviewed"])});function an(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","investigation","create"),V=A("health_safety","investigation","update"),{pagination:J,setPagination:$,sorting:Q,setSorting:Z,globalFilter:W,setGlobalFilter:ee,queryParams:M}=Ve(),te={...M,...C&&{status:C}},{data:b,isLoading:F}=Jt(te),[B,N]=S.useState(""),{data:D}=lt({page_size:100,search:B||void 0}),R=Zt(),i=es(),Y=ts(),c=xe({resolver:ue(Xs),defaultValues:{status:"in_progress"}});function p(){O("health_safety","investigation","create")&&(d(null),c.reset({status:"in_progress",incident:"",investigator:"",investigation_date:"",findings:"",root_cause_analysis:"",recommendations:""}),s(!0))}function T(o){O("health_safety","investigation","update")&&(d(o),c.reset({incident:o.incident,investigator:o.investigator,investigation_date:o.investigation_date,findings:o.findings,root_cause_analysis:o.root_cause_analysis,recommendations:o.recommendations,status:o.status}),s(!0))}function se(o){const r={...o,company:"",root_cause_analysis:o.root_cause_analysis??"",recommendations:o.recommendations??"",contributing_factors:[],reviewed_by:null,reviewed_at:null};n?i.mutate({id:n.id,...r},{onSuccess:()=>{s(!1),c.reset()}}):R.mutate(r,{onSuccess:()=>{s(!1),c.reset()}})}function t(o){w(o==="__all__"?"":o),$(r=>({...r,pageIndex:0}))}const f=[{key:"incident",header:"Incident",render:o=>e.jsx("span",{className:"text-[13px] text-slate-700",children:o.incident})},{key:"investigator_name",header:"Investigator",className:"w-36",render:o=>e.jsx("span",{className:"text-[12px] text-slate-600",children:o.investigator_name??"--"})},{key:"investigation_date",header:"Date",className:"w-28",render:o=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(o.investigation_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"status",header:"Status",className:"w-28",render:o=>e.jsx(X,{variant:Ys[o.status],className:"text-[11px] capitalize",children:o.status.replace(/_/g," ")})},{key:"reviewed_by_name",header:"Reviewed By",className:"w-32",render:o=>e.jsx("span",{className:"text-[12px] text-slate-600",children:o.reviewed_by_name??"--"})},{key:"actions",header:"",className:"w-10",render:o=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>T(o),children:"Edit"}),V&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(o),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"Investigations",description:"Manage incident investigation reports.",actions:G&&e.jsxs(k,{size:"sm",onClick:p,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," New Investigation"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:t,children:[e.jsx(U,{className:"w-[150px] h-9",children:e.jsx(H,{placeholder:"All statuses"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"in_progress",children:"In Progress"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"reviewed",children:"Reviewed"})]})]}),columns:f,data:(b==null?void 0:b.results)??[],isLoading:F,rowKey:o=>o.id,searchKeys:["incident","findings"],searchPlaceholder:"Search investigations...",emptyMessage:"No investigations found",emptyDescription:"Create an investigation report for an incident.",totalCount:(b==null?void 0:b.count)??0,pagination:J,onPaginationChange:$,sorting:Q,onSortingChange:Z,globalFilter:W,onGlobalFilterChange:ee}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Investigation":"New Investigation"}),e.jsx(_e,{children:n?"Update investigation details.":"Create a new investigation report."})]}),e.jsxs("form",{onSubmit:c.handleSubmit(se),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Incident *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Ge,{value:c.watch("incident")??null,onValueChange:o=>c.setValue("incident",o,{shouldValidate:!0}),onSearch:N,options:((D==null?void 0:D.results)??[]).map(o=>({value:o.id,label:o.title,hint:o.incident_number})),placeholder:"Select incident",searchPlaceholder:"Search incidents..."})}),c.formState.errors.incident&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:c.formState.errors.incident.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Investigator *"}),e.jsx(Ue,{className:"mt-1.5",value:c.watch("investigator")??"",onValueChange:o=>c.setValue("investigator",o,{shouldValidate:!0}),placeholder:"Select employee"}),c.formState.errors.investigator&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:c.formState.errors.investigator.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Investigation Date *"}),e.jsx(E,{className:"mt-1.5",type:"date",...c.register("investigation_date")})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Findings *"}),e.jsx(ce,{className:"mt-1.5",...c.register("findings"),rows:3,placeholder:"Investigation findings..."}),c.formState.errors.findings&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:c.formState.errors.findings.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Root Cause Analysis"}),e.jsx(ce,{className:"mt-1.5",...c.register("root_cause_analysis"),rows:3,placeholder:"Root cause analysis..."})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Recommendations"}),e.jsx(ce,{className:"mt-1.5",...c.register("recommendations"),rows:2,placeholder:"Recommendations..."})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Status"}),e.jsxs(z,{value:c.watch("status"),onValueChange:o=>c.setValue("status",o),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsxs(L,{children:[e.jsx(h,{value:"in_progress",children:"In Progress"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"reviewed",children:"Reviewed"})]})]})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:c.handleSubmit(se),disabled:R.isPending||i.isPending,children:R.isPending||i.isPending?"Saving...":n?"Update":"Create"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:o=>!o&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete Investigation"}),e.jsx(Pe,{children:"Are you sure you want to delete this investigation? This action cannot be undone."})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&Y.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const Js={pending:"warning",in_progress:"default",completed:"success",overdue:"destructive",cancelled:"secondary"},Zs=[{value:"immediate",label:"Immediate"},{value:"short_term",label:"Short Term"},{value:"long_term",label:"Long Term"},{value:"preventive",label:"Preventive"}],ea=he({incident:P().min(1,"Incident is required"),description:P().min(1,"Description is required"),action_type:oe(["immediate","short_term","long_term","preventive"]),assigned_to:P().min(1,"Assignee is required"),due_date:Qe("Due date is required"),effectiveness_review:P().optional()});function nn(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","corrective_action","create"),V=A("health_safety","corrective_action","update"),{pagination:J,setPagination:$,sorting:Q,setSorting:Z,globalFilter:W,setGlobalFilter:ee,queryParams:M}=Ve(),te={...M,...C&&{status:C}},{data:b,isLoading:F}=ss(te),[B,N]=S.useState(""),{data:D}=lt({page_size:100,search:B||void 0}),R=as(),i=ns(),Y=is(),c=rs(),p=ls(),T=xe({resolver:ue(ea),defaultValues:{action_type:"immediate"}});function se(){O("health_safety","corrective_action","create")&&(d(null),T.reset({action_type:"immediate",incident:"",description:"",assigned_to:"",due_date:"",effectiveness_review:""}),s(!0))}function t(y){O("health_safety","corrective_action","update")&&(d(y),T.reset({incident:y.incident,description:y.description,action_type:y.action_type,assigned_to:y.assigned_to,due_date:y.due_date,effectiveness_review:y.effectiveness_review}),s(!0))}function f(y){const He={...y,company:"",effectiveness_review:y.effectiveness_review??"",investigation:null,status:"pending",completed_date:null,verified_by:null,verified_at:null};n?i.mutate({id:n.id,...He},{onSuccess:()=>{s(!1),T.reset()}}):R.mutate(He,{onSuccess:()=>{s(!1),T.reset()}})}function o(y){w(y==="__all__"?"":y),$(He=>({...He,pageIndex:0}))}const r=[{key:"description",header:"Description",render:y=>e.jsx("p",{className:"font-medium text-slate-900 truncate max-w-xs",children:y.description})},{key:"action_type",header:"Type",className:"w-28",render:y=>e.jsx(X,{variant:"outline",className:"text-[11px] capitalize",children:y.action_type.replace(/_/g," ")})},{key:"assigned_to_name",header:"Assigned To",className:"w-32",render:y=>e.jsx("span",{className:"text-[12px] text-slate-600",children:y.assigned_to_name??"--"})},{key:"due_date",header:"Due Date",className:"w-28",render:y=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(y.due_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"status",header:"Status",className:"w-28",render:y=>e.jsx(X,{variant:Js[y.status],className:"text-[11px] capitalize",children:y.status.replace(/_/g," ")})},{key:"actions",header:"",className:"w-10",render:y=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>t(y),children:"Edit"}),V&&(y.status==="pending"||y.status==="in_progress")&&e.jsxs(K,{className:"gap-2 text-[13px]",onClick:()=>c.mutate({id:y.id}),children:[e.jsx(Xe,{className:"h-3.5 w-3.5 text-slate-400"}),"Complete"]}),V&&y.status==="completed"&&!y.verified_by&&e.jsxs(K,{className:"gap-2 text-[13px]",onClick:()=>p.mutate(y.id),children:[e.jsx(qt,{className:"h-3.5 w-3.5 text-slate-400"}),"Verify"]}),V&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(y),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"Corrective Actions",description:"Track corrective and preventive actions for incidents.",actions:G&&e.jsxs(k,{size:"sm",onClick:se,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," New Action"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:o,children:[e.jsx(U,{className:"w-[150px] h-9",children:e.jsx(H,{placeholder:"All statuses"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"pending",children:"Pending"}),e.jsx(h,{value:"in_progress",children:"In Progress"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"overdue",children:"Overdue"}),e.jsx(h,{value:"cancelled",children:"Cancelled"})]})]}),columns:r,data:(b==null?void 0:b.results)??[],isLoading:F,rowKey:y=>y.id,searchKeys:["description"],searchPlaceholder:"Search actions...",emptyMessage:"No corrective actions found",emptyDescription:"Create a corrective action for an incident.",totalCount:(b==null?void 0:b.count)??0,pagination:J,onPaginationChange:$,sorting:Q,onSortingChange:Z,globalFilter:W,onGlobalFilterChange:ee}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Action":"New Action"}),e.jsx(_e,{children:n?"Update corrective action details.":"Create a new corrective action."})]}),e.jsxs("form",{onSubmit:T.handleSubmit(f),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Incident *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Ge,{value:T.watch("incident")??null,onValueChange:y=>T.setValue("incident",y,{shouldValidate:!0}),onSearch:N,options:((D==null?void 0:D.results)??[]).map(y=>({value:y.id,label:y.title,hint:y.incident_number})),placeholder:"Select incident",searchPlaceholder:"Search incidents..."})}),T.formState.errors.incident&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:T.formState.errors.incident.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Description *"}),e.jsx(ce,{className:"mt-1.5",...T.register("description"),rows:3,placeholder:"Action description..."}),T.formState.errors.description&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:T.formState.errors.description.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Action Type *"}),e.jsxs(z,{value:T.watch("action_type"),onValueChange:y=>T.setValue("action_type",y),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:Zs.map(y=>e.jsx(h,{value:y.value,children:y.label},y.value))})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Assigned To *"}),e.jsx(Ue,{className:"mt-1.5",value:T.watch("assigned_to")??"",onValueChange:y=>T.setValue("assigned_to",y,{shouldValidate:!0}),placeholder:"Select employee"}),T.formState.errors.assigned_to&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:T.formState.errors.assigned_to.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Due Date *"}),e.jsx(E,{className:"mt-1.5",type:"date",...T.register("due_date")}),T.formState.errors.due_date&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:T.formState.errors.due_date.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Effectiveness Review"}),e.jsx(ce,{className:"mt-1.5",...T.register("effectiveness_review"),rows:2,placeholder:"Review notes..."})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:T.handleSubmit(f),disabled:R.isPending||i.isPending,children:R.isPending||i.isPending?"Saving...":n?"Update":"Create"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:y=>!y&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete Corrective Action"}),e.jsx(Pe,{children:"Are you sure you want to delete this corrective action? This action cannot be undone."})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&Y.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const dt=[{value:"induction",label:"Induction"},{value:"periodic",label:"Periodic"},{value:"specialized",label:"Specialized"},{value:"emergency",label:"Emergency"},{value:"compliance",label:"Compliance"}],ta=he({name:P().min(1,"Name is required"),code:P().min(1,"Code is required"),description:P().optional(),training_type:oe(["induction","periodic","specialized","emergency","compliance"]),frequency_months:Me.number().int().min(1),duration_hours:P().optional(),is_mandatory:ae(),passing_score:P().optional(),certification_validity_months:Me.number().int().min(0).optional(),is_active:ae()});function rn(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","safety_training","create"),V=A("health_safety","safety_training","update"),J=A("health_safety","safety_training","delete"),{pagination:$,setPagination:Q,sorting:Z,setSorting:W,globalFilter:ee,setGlobalFilter:M,queryParams:te}=Ve(),b={...te,...C&&{training_type:C}},{data:F,isLoading:B}=ft(b),N=cs(),D=os(),R=ds(),i=xe({resolver:ue(ta),defaultValues:{training_type:"induction",frequency_months:12,is_mandatory:!1,is_active:!0}});function Y(){O("health_safety","safety_training","create")&&(d(null),i.reset({training_type:"induction",frequency_months:12,is_mandatory:!1,is_active:!0,name:"",code:"",description:""}),s(!0))}function c(t){O("health_safety","safety_training","update")&&(d(t),i.reset({name:t.name,code:t.code,description:t.description,training_type:t.training_type,frequency_months:t.frequency_months,duration_hours:t.duration_hours,is_mandatory:t.is_mandatory,passing_score:t.passing_score,certification_validity_months:t.certification_validity_months,is_active:t.is_active}),s(!0))}function p(t){const f={...t,company:"",description:t.description??"",duration_hours:t.duration_hours??"0",passing_score:t.passing_score??"0",certification_validity_months:t.certification_validity_months??0,applicable_departments:[],applicable_designations:[]};n?D.mutate({id:n.id,...f},{onSuccess:()=>{s(!1),i.reset()}}):N.mutate(f,{onSuccess:()=>{s(!1),i.reset()}})}function T(t){w(t==="__all__"?"":t),Q(f=>({...f,pageIndex:0}))}const se=[{key:"name",header:"Training",render:t=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:t.name}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:t.code})]})},{key:"training_type",header:"Type",className:"w-28",render:t=>e.jsx(X,{variant:"outline",className:"text-[11px] capitalize",children:t.training_type})},{key:"frequency_months",header:"Frequency",className:"w-28",render:t=>e.jsxs("span",{className:"text-[12px] text-slate-600",children:["Every ",t.frequency_months," mo"]})},{key:"is_mandatory",header:"Mandatory",className:"w-24",render:t=>e.jsx(X,{variant:t.is_mandatory?"warning":"secondary",className:"text-[11px]",children:t.is_mandatory?"Yes":"No"})},{key:"is_active",header:"Status",className:"w-24",render:t=>e.jsx(Je,{status:t.is_active?"active":"inactive"})},{key:"actions",header:"",className:"w-10",render:t=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>c(t),children:"Edit"}),J&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(t),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"Safety Training Programs",description:"Define and manage safety training programs.",actions:G&&e.jsxs(k,{size:"sm",onClick:Y,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," New Training"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:T,children:[e.jsx(U,{className:"w-[140px] h-9",children:e.jsx(H,{placeholder:"All types"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Types"}),dt.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))]})]}),columns:se,data:(F==null?void 0:F.results)??[],isLoading:B,rowKey:t=>t.id,searchKeys:["name","code"],searchPlaceholder:"Search trainings...",emptyMessage:"No safety trainings found",emptyDescription:"Create your first safety training program.",totalCount:(F==null?void 0:F.count)??0,pagination:$,onPaginationChange:Q,sorting:Z,onSortingChange:W,globalFilter:ee,onGlobalFilterChange:M}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Training":"New Training"}),e.jsx(_e,{children:n?"Update training details.":"Create a new safety training program."})]}),e.jsxs("form",{onSubmit:i.handleSubmit(p),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(E,{className:"mt-1.5",...i.register("name"),placeholder:"e.g. Fire Safety Training"}),i.formState.errors.name&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(E,{className:"mt-1.5",...i.register("code"),placeholder:"e.g. ST-FIRE-001"}),i.formState.errors.code&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(ce,{className:"mt-1.5",...i.register("description"),rows:3,placeholder:"Training description..."})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Training Type *"}),e.jsxs(z,{value:i.watch("training_type"),onValueChange:t=>i.setValue("training_type",t),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:dt.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Frequency (months) *"}),e.jsx(E,{className:"mt-1.5",type:"number",...i.register("frequency_months")})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Duration (hours)"}),e.jsx(E,{className:"mt-1.5",...i.register("duration_hours"),placeholder:"e.g. 8.0"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Passing Score"}),e.jsx(E,{className:"mt-1.5",...i.register("passing_score"),placeholder:"e.g. 70.00"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Cert Validity (months)"}),e.jsx(E,{className:"mt-1.5",type:"number",...i.register("certification_validity_months")})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Mandatory"}),e.jsx(ne,{checked:i.watch("is_mandatory"),onCheckedChange:t=>i.setValue("is_mandatory",t)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Active"}),e.jsx(ne,{checked:i.watch("is_active"),onCheckedChange:t=>i.setValue("is_active",t)})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:i.handleSubmit(p),disabled:N.isPending||D.isPending,children:N.isPending||D.isPending?"Saving...":n?"Update":"Create"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:t=>!t&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete Safety Training"}),e.jsxs(Pe,{children:["Are you sure you want to delete ",e.jsx("span",{className:"font-medium text-slate-700",children:u==null?void 0:u.name}),"? This action cannot be undone."]})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&R.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const sa={scheduled:"default",completed:"success",expired:"destructive",due:"warning"},aa={passed:"success",failed:"destructive",pending:"warning"},na=it(he({employee:P().min(1,"Employee is required"),safety_training:P().min(1,"Training is required"),training_date:Qe("Date is required"),expiry_date:rt(),score:P().optional(),result:oe(["passed","failed","pending"]),certificate_number:P().optional(),trainer_name:P().optional(),remarks:P().optional()}),"training_date","expiry_date");function ln(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","safety_training_record","create"),V=A("health_safety","safety_training_record","update"),{pagination:J,setPagination:$,sorting:Q,setSorting:Z,globalFilter:W,setGlobalFilter:ee,queryParams:M}=Ve(),te={...M,...C&&{status:C}},{data:b,isLoading:F}=ms(te),[B,N]=S.useState(""),{data:D}=ft({page_size:100,is_active:!0,search:B||void 0}),R=xs(),i=us(),Y=hs(),c=ps(),p=xe({resolver:ue(na),defaultValues:{result:"pending"}});function T(){O("health_safety","safety_training_record","create")&&(d(null),p.reset({result:"pending",employee:"",safety_training:"",training_date:""}),s(!0))}function se(r){O("health_safety","safety_training_record","update")&&(d(r),p.reset({employee:r.employee,safety_training:r.safety_training,training_date:r.training_date,expiry_date:r.expiry_date??"",score:r.score??"",result:r.result,certificate_number:r.certificate_number,trainer_name:r.trainer_name,remarks:r.remarks}),s(!0))}function t(r){const y={...r,company:"",expiry_date:r.expiry_date||null,score:r.score||null,certificate_number:r.certificate_number??"",certificate_file:"",trainer_name:r.trainer_name??"",remarks:r.remarks??"",status:"scheduled"};n?i.mutate({id:n.id,...y},{onSuccess:()=>{s(!1),p.reset()}}):R.mutate(y,{onSuccess:()=>{s(!1),p.reset()}})}function f(r){w(r==="__all__"?"":r),$(y=>({...y,pageIndex:0}))}const o=[{key:"employee_name",header:"Employee",render:r=>e.jsx("span",{className:"font-medium text-slate-900",children:r.employee_name??"--"})},{key:"safety_training_name",header:"Training",className:"w-40",render:r=>e.jsx("span",{className:"text-[12px] text-slate-600",children:r.safety_training_name??"--"})},{key:"training_date",header:"Date",className:"w-28",render:r=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(r.training_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"result",header:"Result",className:"w-24",render:r=>e.jsx(X,{variant:aa[r.result],className:"text-[11px] capitalize",children:r.result})},{key:"status",header:"Status",className:"w-28",render:r=>e.jsx(X,{variant:sa[r.status],className:"text-[11px] capitalize",children:r.status})},{key:"score",header:"Score",className:"w-20",render:r=>e.jsx("span",{className:"text-[12px] text-slate-600",children:r.score??"--"})},{key:"actions",header:"",className:"w-10",render:r=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>se(r),children:"Edit"}),V&&r.status==="scheduled"&&e.jsxs(K,{className:"gap-2 text-[13px]",onClick:()=>c.mutate({id:r.id,result:"passed"}),children:[e.jsx(Xe,{className:"h-3.5 w-3.5 text-slate-400"}),"Complete"]}),V&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(r),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"Safety Training Records",description:"Track employee safety training completion and certifications.",actions:G&&e.jsxs(k,{size:"sm",onClick:T,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," New Record"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:f,children:[e.jsx(U,{className:"w-[140px] h-9",children:e.jsx(H,{placeholder:"All statuses"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"scheduled",children:"Scheduled"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"expired",children:"Expired"}),e.jsx(h,{value:"due",children:"Due"})]})]}),columns:o,data:(b==null?void 0:b.results)??[],isLoading:F,rowKey:r=>r.id,searchKeys:["employee_name","safety_training_name"],searchPlaceholder:"Search records...",emptyMessage:"No training records found",emptyDescription:"Create the first training record.",totalCount:(b==null?void 0:b.count)??0,pagination:J,onPaginationChange:$,sorting:Q,onSortingChange:Z,globalFilter:W,onGlobalFilterChange:ee}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Record":"New Record"}),e.jsx(_e,{children:n?"Update training record.":"Create a new safety training record."})]}),e.jsxs("form",{onSubmit:p.handleSubmit(t),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Employee ID *"}),e.jsx(Ue,{className:"mt-1.5",value:p.watch("employee")??"",onValueChange:r=>p.setValue("employee",r,{shouldValidate:!0}),placeholder:"Select employee"}),p.formState.errors.employee&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:p.formState.errors.employee.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Safety Training *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Ge,{value:p.watch("safety_training")??null,onValueChange:r=>p.setValue("safety_training",r,{shouldValidate:!0}),onSearch:N,selectedLabel:(n==null?void 0:n.safety_training_name)??void 0,options:((D==null?void 0:D.results)??[]).map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select training",searchPlaceholder:"Search trainings..."})}),p.formState.errors.safety_training&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:p.formState.errors.safety_training.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Training Date *"}),e.jsx(E,{className:"mt-1.5",type:"date",...p.register("training_date"),max:p.watch("expiry_date")||void 0})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Expiry Date"}),e.jsx(E,{className:"mt-1.5",type:"date",...p.register("expiry_date"),min:p.watch("training_date")||void 0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Score"}),e.jsx(E,{className:"mt-1.5",...p.register("score"),placeholder:"e.g. 85.00"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Result"}),e.jsxs(z,{value:p.watch("result"),onValueChange:r=>p.setValue("result",r),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsxs(L,{children:[e.jsx(h,{value:"pending",children:"Pending"}),e.jsx(h,{value:"passed",children:"Passed"}),e.jsx(h,{value:"failed",children:"Failed"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Certificate Number"}),e.jsx(E,{className:"mt-1.5",...p.register("certificate_number"),placeholder:"e.g. CERT-001"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Trainer Name"}),e.jsx(E,{className:"mt-1.5",...p.register("trainer_name"),placeholder:"Trainer name"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Remarks"}),e.jsx(ce,{className:"mt-1.5",...p.register("remarks"),rows:2,placeholder:"Additional notes..."})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:p.handleSubmit(t),disabled:R.isPending||i.isPending,children:R.isPending||i.isPending?"Saving...":n?"Update":"Create"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:r=>!r&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete Training Record"}),e.jsx(Pe,{children:"Are you sure you want to delete this training record? This action cannot be undone."})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&Y.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const ia={fit:"success",fit_with_restrictions:"warning",temporarily_unfit:"destructive",permanently_unfit:"destructive"},mt=[{value:"pre_employment",label:"Pre-Employment"},{value:"periodic",label:"Periodic"},{value:"return_to_work",label:"Return to Work"},{value:"special",label:"Special"},{value:"exit",label:"Exit"}],ra=[{value:"fit",label:"Fit"},{value:"fit_with_restrictions",label:"Fit with Restrictions"},{value:"temporarily_unfit",label:"Temporarily Unfit"},{value:"permanently_unfit",label:"Permanently Unfit"}],la=it(he({employee:P().min(1,"Employee is required"),examination_type:oe(["pre_employment","periodic","return_to_work","special","exit"]),examination_date:Qe("Date is required"),next_due_date:rt(),examining_doctor:P().min(1,"Doctor is required"),hospital_clinic:P().optional(),fitness_status:oe(["fit","fit_with_restrictions","temporarily_unfit","permanently_unfit"]),restrictions:P().optional(),blood_group:P().optional(),remarks:P().optional(),is_confidential:ae()}),"examination_date","next_due_date");function cn(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","medical_fitness","create"),V=A("health_safety","medical_fitness","update"),J=A("health_safety","medical_fitness","delete"),{pagination:$,setPagination:Q,sorting:Z,setSorting:W,globalFilter:ee,setGlobalFilter:M,queryParams:te}=Ve(),b={...te,...C&&{examination_type:C}},{data:F,isLoading:B}=gs(b),N=js(),D=fs(),R=ys(),i=xe({resolver:ue(la),defaultValues:{examination_type:"periodic",fitness_status:"fit",is_confidential:!0}});function Y(){O("health_safety","medical_fitness","create")&&(d(null),i.reset({examination_type:"periodic",fitness_status:"fit",is_confidential:!0,employee:"",examination_date:"",examining_doctor:""}),s(!0))}function c(t){O("health_safety","medical_fitness","update")&&(d(t),i.reset({employee:t.employee,examination_type:t.examination_type,examination_date:t.examination_date,next_due_date:t.next_due_date??"",examining_doctor:t.examining_doctor,hospital_clinic:t.hospital_clinic,fitness_status:t.fitness_status,restrictions:t.restrictions,blood_group:t.blood_group,remarks:t.remarks,is_confidential:t.is_confidential}),s(!0))}function p(t){const f={...t,company:"",next_due_date:t.next_due_date||null,hospital_clinic:t.hospital_clinic??"",restrictions:t.restrictions??"",blood_group:t.blood_group??"",remarks:t.remarks??"",medical_conditions:[],report_file:""};n?D.mutate({id:n.id,...f},{onSuccess:()=>{s(!1),i.reset()}}):N.mutate(f,{onSuccess:()=>{s(!1),i.reset()}})}function T(t){w(t==="__all__"?"":t),Q(f=>({...f,pageIndex:0}))}const se=[{key:"employee_name",header:"Employee",render:t=>e.jsx("span",{className:"font-medium text-slate-900",children:t.employee_name??"--"})},{key:"examination_type",header:"Type",className:"w-32",render:t=>e.jsx(X,{variant:"outline",className:"text-[11px] capitalize",children:t.examination_type.replace(/_/g," ")})},{key:"examination_date",header:"Exam Date",className:"w-28",render:t=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(t.examination_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"fitness_status",header:"Fitness",className:"w-36",render:t=>e.jsx(X,{variant:ia[t.fitness_status],className:"text-[11px] capitalize",children:t.fitness_status.replace(/_/g," ")})},{key:"next_due_date",header:"Next Due",className:"w-28",render:t=>e.jsx("span",{className:"text-[12px] text-slate-400",children:t.next_due_date?new Date(t.next_due_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"--"})},{key:"examining_doctor",header:"Doctor",className:"w-32",render:t=>e.jsx("span",{className:"text-[12px] text-slate-600",children:t.examining_doctor})},{key:"actions",header:"",className:"w-10",render:t=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>c(t),children:"Edit"}),J&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(t),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"Medical Fitness",description:"Track employee medical examinations and fitness records.",actions:G&&e.jsxs(k,{size:"sm",onClick:Y,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," New Record"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:T,children:[e.jsx(U,{className:"w-[160px] h-9",children:e.jsx(H,{placeholder:"All types"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Types"}),mt.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))]})]}),columns:se,data:(F==null?void 0:F.results)??[],isLoading:B,rowKey:t=>t.id,searchKeys:["employee_name","examining_doctor"],searchPlaceholder:"Search records...",emptyMessage:"No medical fitness records found",emptyDescription:"Create the first medical fitness record.",totalCount:(F==null?void 0:F.count)??0,pagination:$,onPaginationChange:Q,sorting:Z,onSortingChange:W,globalFilter:ee,onGlobalFilterChange:M}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Record":"New Medical Record"}),e.jsx(_e,{children:n?"Update medical fitness record.":"Create a new medical fitness record."})]}),e.jsxs("form",{onSubmit:i.handleSubmit(p),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Employee ID *"}),e.jsx(Ue,{className:"mt-1.5",value:i.watch("employee")??"",onValueChange:t=>i.setValue("employee",t,{shouldValidate:!0}),placeholder:"Select employee"}),i.formState.errors.employee&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.employee.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Examination Type *"}),e.jsxs(z,{value:i.watch("examination_type"),onValueChange:t=>i.setValue("examination_type",t),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:mt.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Examination Date *"}),e.jsx(E,{className:"mt-1.5",type:"date",...i.register("examination_date"),max:i.watch("next_due_date")||void 0})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Next Due Date"}),e.jsx(E,{className:"mt-1.5",type:"date",...i.register("next_due_date"),min:i.watch("examination_date")||void 0})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Examining Doctor *"}),e.jsx(E,{className:"mt-1.5",...i.register("examining_doctor"),placeholder:"Dr. Name"}),i.formState.errors.examining_doctor&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.examining_doctor.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Hospital / Clinic"}),e.jsx(E,{className:"mt-1.5",...i.register("hospital_clinic"),placeholder:"e.g. City General Hospital"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Fitness Status *"}),e.jsxs(z,{value:i.watch("fitness_status"),onValueChange:t=>i.setValue("fitness_status",t),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:ra.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Restrictions"}),e.jsx(ce,{className:"mt-1.5",...i.register("restrictions"),rows:2,placeholder:"Any restrictions..."})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Blood Group"}),e.jsx(E,{className:"mt-1.5",...i.register("blood_group"),placeholder:"e.g. O+"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Remarks"}),e.jsx(ce,{className:"mt-1.5",...i.register("remarks"),rows:2,placeholder:"Additional notes..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Confidential"}),e.jsx(ne,{checked:i.watch("is_confidential"),onCheckedChange:t=>i.setValue("is_confidential",t)})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:i.handleSubmit(p),disabled:N.isPending||D.isPending,children:N.isPending||D.isPending?"Saving...":n?"Update":"Create"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:t=>!t&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete Medical Record"}),e.jsx(Pe,{children:"Are you sure you want to delete this medical record? This action cannot be undone."})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&R.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const xt=[{value:"head",label:"Head"},{value:"eye",label:"Eye"},{value:"ear",label:"Ear"},{value:"respiratory",label:"Respiratory"},{value:"hand",label:"Hand"},{value:"foot",label:"Foot"},{value:"body",label:"Body"},{value:"fall_protection",label:"Fall Protection"},{value:"other",label:"Other"}],ca=he({name:P().min(1,"Name is required"),code:P().min(1,"Code is required"),description:P().optional(),category:oe(["head","eye","ear","respiratory","hand","foot","body","fall_protection","other"]),standard_life_months:Me.number().int().min(1),is_mandatory:ae(),is_active:ae()});function on(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","ppe_item","create"),V=A("health_safety","ppe_item","update"),J=A("health_safety","ppe_item","delete"),{pagination:$,setPagination:Q,sorting:Z,setSorting:W,globalFilter:ee,setGlobalFilter:M,queryParams:te}=Ve(),b={...te,...C&&{category:C}},{data:F,isLoading:B}=yt(b),N=_s(),D=vs(),R=Ns(),i=xe({resolver:ue(ca),defaultValues:{category:"head",standard_life_months:12,is_mandatory:!1,is_active:!0}});function Y(){O("health_safety","ppe_item","create")&&(d(null),i.reset({category:"head",standard_life_months:12,is_mandatory:!1,is_active:!0,name:"",code:"",description:""}),s(!0))}function c(t){O("health_safety","ppe_item","update")&&(d(t),i.reset({name:t.name,code:t.code,description:t.description,category:t.category,standard_life_months:t.standard_life_months,is_mandatory:t.is_mandatory,is_active:t.is_active}),s(!0))}function p(t){const f={...t,company:"",description:t.description??"",applicable_departments:[]};n?D.mutate({id:n.id,...f},{onSuccess:()=>{s(!1),i.reset()}}):N.mutate(f,{onSuccess:()=>{s(!1),i.reset()}})}function T(t){w(t==="__all__"?"":t),Q(f=>({...f,pageIndex:0}))}const se=[{key:"name",header:"PPE Item",render:t=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:t.name}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:t.code})]})},{key:"category",header:"Category",className:"w-32",render:t=>e.jsx(X,{variant:"outline",className:"text-[11px] capitalize",children:t.category.replace(/_/g," ")})},{key:"standard_life_months",header:"Life",className:"w-24",render:t=>e.jsxs("span",{className:"text-[12px] text-slate-600",children:[t.standard_life_months," mo"]})},{key:"is_mandatory",header:"Mandatory",className:"w-24",render:t=>e.jsx(X,{variant:t.is_mandatory?"warning":"secondary",className:"text-[11px]",children:t.is_mandatory?"Yes":"No"})},{key:"is_active",header:"Status",className:"w-24",render:t=>e.jsx(Je,{status:t.is_active?"active":"inactive"})},{key:"actions",header:"",className:"w-10",render:t=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>c(t),children:"Edit"}),J&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(t),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"PPE Items",description:"Manage personal protective equipment catalog.",actions:G&&e.jsxs(k,{size:"sm",onClick:Y,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," New PPE Item"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:T,children:[e.jsx(U,{className:"w-[150px] h-9",children:e.jsx(H,{placeholder:"All categories"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Categories"}),xt.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))]})]}),columns:se,data:(F==null?void 0:F.results)??[],isLoading:B,rowKey:t=>t.id,searchKeys:["name","code"],searchPlaceholder:"Search PPE items...",emptyMessage:"No PPE items found",emptyDescription:"Add your first PPE item to the catalog.",totalCount:(F==null?void 0:F.count)??0,pagination:$,onPaginationChange:Q,sorting:Z,onSortingChange:W,globalFilter:ee,onGlobalFilterChange:M}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit PPE Item":"New PPE Item"}),e.jsx(_e,{children:n?"Update PPE item details.":"Add a new PPE item to the catalog."})]}),e.jsxs("form",{onSubmit:i.handleSubmit(p),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(E,{className:"mt-1.5",...i.register("name"),placeholder:"e.g. Safety Helmet"}),i.formState.errors.name&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(E,{className:"mt-1.5",...i.register("code"),placeholder:"e.g. PPE-HLM-001"}),i.formState.errors.code&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(ce,{className:"mt-1.5",...i.register("description"),rows:3,placeholder:"Item description..."})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Category *"}),e.jsxs(z,{value:i.watch("category"),onValueChange:t=>i.setValue("category",t),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:xt.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Standard Life (months) *"}),e.jsx(E,{className:"mt-1.5",type:"number",...i.register("standard_life_months")})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Mandatory"}),e.jsx(ne,{checked:i.watch("is_mandatory"),onCheckedChange:t=>i.setValue("is_mandatory",t)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Active"}),e.jsx(ne,{checked:i.watch("is_active"),onCheckedChange:t=>i.setValue("is_active",t)})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:i.handleSubmit(p),disabled:N.isPending||D.isPending,children:N.isPending||D.isPending?"Saving...":n?"Update":"Create"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:t=>!t&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete PPE Item"}),e.jsxs(Pe,{children:["Are you sure you want to delete ",e.jsx("span",{className:"font-medium text-slate-700",children:u==null?void 0:u.name}),"? This action cannot be undone."]})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&R.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const oa={active:"success",returned:"secondary",replaced:"default",lost:"destructive"},da=he({employee:P().min(1,"Employee is required"),ppe_item:P().min(1,"PPE item is required"),issue_date:Qe("Issue date is required"),quantity:Me.number().int().min(1),size:P().optional(),serial_number:P().optional(),condition_at_issue:oe(["new","refurbished"])});function dn(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","ppe_issue","create"),V=A("health_safety","ppe_issue","update"),{pagination:J,setPagination:$,sorting:Q,setSorting:Z,globalFilter:W,setGlobalFilter:ee,queryParams:M}=Ve(),te={...M,...C&&{status:C}},{data:b,isLoading:F}=Ss(te),[B,N]=S.useState(""),{data:D}=yt({page_size:100,is_active:!0,search:B||void 0}),R=Cs(),i=bs(),Y=ws(),c=Ps(),p=xe({resolver:ue(da),defaultValues:{condition_at_issue:"new",quantity:1}});function T(){O("health_safety","ppe_issue","create")&&(d(null),p.reset({condition_at_issue:"new",quantity:1,employee:"",ppe_item:"",issue_date:""}),s(!0))}function se(r){O("health_safety","ppe_issue","update")&&(d(r),p.reset({employee:r.employee,ppe_item:r.ppe_item,issue_date:r.issue_date,quantity:r.quantity,size:r.size,serial_number:r.serial_number,condition_at_issue:r.condition_at_issue}),s(!0))}function t(r){const y={...r,company:"",size:r.size??"",serial_number:r.serial_number??"",expected_replacement_date:null,returned_date:null,condition_at_return:null,status:"active",issued_by:null};n?i.mutate({id:n.id,...y},{onSuccess:()=>{s(!1),p.reset()}}):R.mutate(y,{onSuccess:()=>{s(!1),p.reset()}})}function f(r){w(r==="__all__"?"":r),$(y=>({...y,pageIndex:0}))}const o=[{key:"employee_name",header:"Employee",render:r=>e.jsx("span",{className:"font-medium text-slate-900",children:r.employee_name??"--"})},{key:"ppe_item_name",header:"PPE Item",className:"w-36",render:r=>e.jsx("span",{className:"text-[12px] text-slate-600",children:r.ppe_item_name??"--"})},{key:"issue_date",header:"Issue Date",className:"w-28",render:r=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(r.issue_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"quantity",header:"Qty",className:"w-16",render:r=>e.jsx("span",{className:"text-[12px] text-slate-600",children:r.quantity})},{key:"condition_at_issue",header:"Condition",className:"w-28",render:r=>e.jsx(X,{variant:"outline",className:"text-[11px] capitalize",children:r.condition_at_issue})},{key:"status",header:"Status",className:"w-24",render:r=>e.jsx(X,{variant:oa[r.status],className:"text-[11px] capitalize",children:r.status})},{key:"actions",header:"",className:"w-10",render:r=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>se(r),children:"Edit"}),V&&r.status==="active"&&e.jsxs(K,{className:"gap-2 text-[13px]",onClick:()=>c.mutate({id:r.id,condition_at_return:"good"}),children:[e.jsx(Rt,{className:"h-3.5 w-3.5 text-slate-400"}),"Return"]}),V&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(r),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"PPE Issues",description:"Track PPE issuance and returns for employees.",actions:G&&e.jsxs(k,{size:"sm",onClick:T,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," Issue PPE"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:f,children:[e.jsx(U,{className:"w-[140px] h-9",children:e.jsx(H,{placeholder:"All statuses"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"active",children:"Active"}),e.jsx(h,{value:"returned",children:"Returned"}),e.jsx(h,{value:"replaced",children:"Replaced"}),e.jsx(h,{value:"lost",children:"Lost"})]})]}),columns:o,data:(b==null?void 0:b.results)??[],isLoading:F,rowKey:r=>r.id,searchKeys:["employee_name","ppe_item_name"],searchPlaceholder:"Search PPE issues...",emptyMessage:"No PPE issues found",emptyDescription:"Issue PPE to employees to get started.",totalCount:(b==null?void 0:b.count)??0,pagination:J,onPaginationChange:$,sorting:Q,onSortingChange:Z,globalFilter:W,onGlobalFilterChange:ee}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit PPE Issue":"Issue PPE"}),e.jsx(_e,{children:n?"Update PPE issue details.":"Issue PPE to an employee."})]}),e.jsxs("form",{onSubmit:p.handleSubmit(t),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Employee ID *"}),e.jsx(Ue,{className:"mt-1.5",value:p.watch("employee")??"",onValueChange:r=>p.setValue("employee",r,{shouldValidate:!0}),placeholder:"Select employee"}),p.formState.errors.employee&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:p.formState.errors.employee.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"PPE Item *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Ge,{value:p.watch("ppe_item")??null,onValueChange:r=>p.setValue("ppe_item",r,{shouldValidate:!0}),onSearch:N,selectedLabel:(n==null?void 0:n.ppe_item_name)??void 0,options:((D==null?void 0:D.results)??[]).map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select PPE item",searchPlaceholder:"Search PPE items..."})}),p.formState.errors.ppe_item&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:p.formState.errors.ppe_item.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Issue Date *"}),e.jsx(E,{className:"mt-1.5",type:"date",...p.register("issue_date")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Quantity *"}),e.jsx(E,{className:"mt-1.5",type:"number",...p.register("quantity")})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Size"}),e.jsx(E,{className:"mt-1.5",...p.register("size"),placeholder:"e.g. L, XL"})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Serial Number"}),e.jsx(E,{className:"mt-1.5",...p.register("serial_number"),placeholder:"e.g. SN-12345"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Condition at Issue *"}),e.jsxs(z,{value:p.watch("condition_at_issue"),onValueChange:r=>p.setValue("condition_at_issue",r),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsxs(L,{children:[e.jsx(h,{value:"new",children:"New"}),e.jsx(h,{value:"refurbished",children:"Refurbished"})]})]})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:p.handleSubmit(t),disabled:R.isPending||i.isPending,children:R.isPending||i.isPending?"Saving...":n?"Update":"Issue"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:r=>!r&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete PPE Issue"}),e.jsx(Pe,{children:"Are you sure you want to delete this PPE issue record? This action cannot be undone."})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&Y.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const ma={filed:"warning",acknowledged:"default",investigation:"default",hearing:"default",decision:"warning",appeal:"destructive",closed:"secondary"},xa={low:"secondary",medium:"default",high:"warning",critical:"destructive"},ua=[{value:"sexual_harassment",label:"Sexual Harassment"},{value:"hostile_environment",label:"Hostile Environment"},{value:"quid_pro_quo",label:"Quid Pro Quo"},{value:"retaliation",label:"Retaliation"},{value:"other",label:"Other"}],ha=he({complainant:P().min(1,"Complainant is required"),respondent:P().min(1,"Respondent is required"),incident_date:Qe("Date is required"),incident_location:P().min(1,"Location is required"),description:P().min(1,"Description is required"),complaint_type:oe(["sexual_harassment","hostile_environment","quid_pro_quo","retaliation","other"]),severity:oe(["low","medium","high","critical"]),is_anonymous:ae(),is_confidential:ae()});function mn(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","posh_complaint","create"),V=A("health_safety","posh_complaint","update"),{pagination:J,setPagination:$,sorting:Q,setSorting:Z,globalFilter:W,setGlobalFilter:ee,queryParams:M}=Ve(),te={...M,...C&&{status:C}},{data:b,isLoading:F}=ks(te),B=Es(),N=Fs(),D=qs(),R=Is(),i=xe({resolver:ue(ha),defaultValues:{complaint_type:"sexual_harassment",severity:"medium",is_anonymous:!1,is_confidential:!0}});function Y(){O("health_safety","posh_complaint","create")&&(d(null),i.reset({complaint_type:"sexual_harassment",severity:"medium",is_anonymous:!1,is_confidential:!0,complainant:"",respondent:"",incident_date:"",incident_location:"",description:""}),s(!0))}function c(t){O("health_safety","posh_complaint","update")&&(d(t),i.reset({complainant:t.complainant,respondent:t.respondent,incident_date:t.incident_date,incident_location:t.incident_location,description:t.description,complaint_type:t.complaint_type,severity:t.severity,is_anonymous:t.is_anonymous,is_confidential:t.is_confidential}),s(!0))}function p(t){const f={...t,company:"",status:"filed",committee_members:[],investigation_findings:"",decision:"",decision_date:null,action_taken:"",appeal_filed:!1,appeal_remarks:""};n?N.mutate({id:n.id,...f},{onSuccess:()=>{s(!1),i.reset()}}):B.mutate(f,{onSuccess:()=>{s(!1),i.reset()}})}function T(t){w(t==="__all__"?"":t),$(f=>({...f,pageIndex:0}))}const se=[{key:"complaint_number",header:"Complaint",render:t=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:t.complaint_number}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5 capitalize",children:t.complaint_type.replace(/_/g," ")})]})},{key:"complainant_name",header:"Complainant",className:"w-32",render:t=>e.jsx("span",{className:"text-[12px] text-slate-600",children:t.is_anonymous?"Anonymous":t.complainant_name??"--"})},{key:"respondent_name",header:"Respondent",className:"w-32",render:t=>e.jsx("span",{className:"text-[12px] text-slate-600",children:t.respondent_name??"--"})},{key:"severity",header:"Severity",className:"w-24",render:t=>e.jsx(X,{variant:xa[t.severity],className:"text-[11px] capitalize",children:t.severity})},{key:"status",header:"Status",className:"w-28",render:t=>e.jsx(X,{variant:ma[t.status],className:"text-[11px] capitalize",children:t.status})},{key:"incident_date",header:"Date",className:"w-28",render:t=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(t.incident_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"actions",header:"",className:"w-10",render:t=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>c(t),children:"Edit"}),V&&t.status==="filed"&&e.jsxs(K,{className:"gap-2 text-[13px]",onClick:()=>R.mutate(t.id),children:[e.jsx(Xe,{className:"h-3.5 w-3.5 text-slate-400"}),"Acknowledge"]}),V&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(t),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"POSH Complaints",description:"Manage complaints under Prevention of Sexual Harassment.",actions:G&&e.jsxs(k,{size:"sm",onClick:Y,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," File Complaint"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:T,children:[e.jsx(U,{className:"w-[150px] h-9",children:e.jsx(H,{placeholder:"All statuses"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"filed",children:"Filed"}),e.jsx(h,{value:"acknowledged",children:"Acknowledged"}),e.jsx(h,{value:"investigation",children:"Investigation"}),e.jsx(h,{value:"hearing",children:"Hearing"}),e.jsx(h,{value:"decision",children:"Decision"}),e.jsx(h,{value:"appeal",children:"Appeal"}),e.jsx(h,{value:"closed",children:"Closed"})]})]}),columns:se,data:(b==null?void 0:b.results)??[],isLoading:F,rowKey:t=>t.id,searchKeys:["complaint_number","complainant_name"],searchPlaceholder:"Search complaints...",emptyMessage:"No POSH complaints found",emptyDescription:"No complaints have been filed.",totalCount:(b==null?void 0:b.count)??0,pagination:J,onPaginationChange:$,sorting:Q,onSortingChange:Z,globalFilter:W,onGlobalFilterChange:ee}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Complaint":"File Complaint"}),e.jsx(_e,{children:n?"Update complaint details.":"File a new POSH complaint."})]}),e.jsxs("form",{onSubmit:i.handleSubmit(p),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Complainant *"}),e.jsx(Ue,{className:"mt-1.5",value:i.watch("complainant")??"",onValueChange:t=>i.setValue("complainant",t,{shouldValidate:!0}),placeholder:"Select employee"}),i.formState.errors.complainant&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.complainant.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Respondent *"}),e.jsx(Ue,{className:"mt-1.5",value:i.watch("respondent")??"",onValueChange:t=>i.setValue("respondent",t,{shouldValidate:!0}),placeholder:"Select employee"}),i.formState.errors.respondent&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.respondent.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Incident Date *"}),e.jsx(E,{className:"mt-1.5",type:"date",...i.register("incident_date")})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Location *"}),e.jsx(E,{className:"mt-1.5",...i.register("incident_location"),placeholder:"e.g. Office Floor 3"})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Description *"}),e.jsx(ce,{className:"mt-1.5",...i.register("description"),rows:4,placeholder:"Describe the incident in detail..."}),i.formState.errors.description&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.description.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Complaint Type *"}),e.jsxs(z,{value:i.watch("complaint_type"),onValueChange:t=>i.setValue("complaint_type",t),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:ua.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Severity *"}),e.jsxs(z,{value:i.watch("severity"),onValueChange:t=>i.setValue("severity",t),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsxs(L,{children:[e.jsx(h,{value:"low",children:"Low"}),e.jsx(h,{value:"medium",children:"Medium"}),e.jsx(h,{value:"high",children:"High"}),e.jsx(h,{value:"critical",children:"Critical"})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Anonymous Complaint"}),e.jsx(ne,{checked:i.watch("is_anonymous"),onCheckedChange:t=>i.setValue("is_anonymous",t)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Confidential"}),e.jsx(ne,{checked:i.watch("is_confidential"),onCheckedChange:t=>i.setValue("is_confidential",t)})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:i.handleSubmit(p),disabled:B.isPending||N.isPending,children:B.isPending||N.isPending?"Saving...":n?"Update":"File"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:t=>!t&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete POSH Complaint"}),e.jsxs(Pe,{children:["Are you sure you want to delete complaint ",e.jsx("span",{className:"font-medium text-slate-700",children:u==null?void 0:u.complaint_number}),"? This action cannot be undone."]})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&D.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const ut=[{value:"health",label:"Health"},{value:"education",label:"Education"},{value:"recreation",label:"Recreation"},{value:"financial",label:"Financial"},{value:"family",label:"Family"},{value:"other",label:"Other"}],pa=it(he({name:P().min(1,"Name is required"),code:P().min(1,"Code is required"),description:P().optional(),program_type:oe(["health","education","recreation","financial","family","other"]),budget:P().optional(),start_date:Qe("Start date is required"),end_date:rt(),max_participants:Me.number().int().positive().optional().or(Vt("")),is_active:ae()}),"start_date","end_date");function xn(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","welfare_program","create"),V=A("health_safety","welfare_program","update"),J=A("health_safety","welfare_program","delete"),{pagination:$,setPagination:Q,sorting:Z,setSorting:W,globalFilter:ee,setGlobalFilter:M,queryParams:te}=Ve(),b={...te,...C&&{program_type:C}},{data:F,isLoading:B}=_t(b),N=Ts(),D=Ds(),R=As(),i=xe({resolver:ue(pa),defaultValues:{program_type:"health",is_active:!0}});function Y(){O("health_safety","welfare_program","create")&&(d(null),i.reset({program_type:"health",is_active:!0,name:"",code:"",description:"",start_date:""}),s(!0))}function c(t){O("health_safety","welfare_program","update")&&(d(t),i.reset({name:t.name,code:t.code,description:t.description,program_type:t.program_type,budget:t.budget,start_date:t.start_date,end_date:t.end_date??"",max_participants:t.max_participants??void 0,is_active:t.is_active}),s(!0))}function p(t){const f={...t,company:"",description:t.description??"",budget:t.budget??"0",end_date:t.end_date||null,max_participants:t.max_participants?Number(t.max_participants):null,eligibility_criteria:{}};n?D.mutate({id:n.id,...f},{onSuccess:()=>{s(!1),i.reset()}}):N.mutate(f,{onSuccess:()=>{s(!1),i.reset()}})}function T(t){w(t==="__all__"?"":t),Q(f=>({...f,pageIndex:0}))}const se=[{key:"name",header:"Program",render:t=>e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-slate-900",children:t.name}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:t.code})]})},{key:"program_type",header:"Type",className:"w-28",render:t=>e.jsx(X,{variant:"outline",className:"text-[11px] capitalize",children:t.program_type})},{key:"budget",header:"Budget",className:"w-28",render:t=>e.jsx("span",{className:"text-[12px] text-slate-600",children:t.budget})},{key:"dates",header:"Period",className:"w-36",render:t=>e.jsxs("span",{className:"text-[12px] text-slate-400",children:[new Date(t.start_date).toLocaleDateString("en-GB",{day:"numeric",month:"short"})," - ",t.end_date?new Date(t.end_date).toLocaleDateString("en-GB",{day:"numeric",month:"short"}):"Ongoing"]})},{key:"is_active",header:"Status",className:"w-24",render:t=>e.jsx(Je,{status:t.is_active?"active":"inactive"})},{key:"actions",header:"",className:"w-10",render:t=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>c(t),children:"Edit"}),J&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(t),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"Welfare Programs",description:"Create and manage employee welfare programs.",actions:G&&e.jsxs(k,{size:"sm",onClick:Y,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," New Program"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:T,children:[e.jsx(U,{className:"w-[140px] h-9",children:e.jsx(H,{placeholder:"All types"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Types"}),ut.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))]})]}),columns:se,data:(F==null?void 0:F.results)??[],isLoading:B,rowKey:t=>t.id,searchKeys:["name","code"],searchPlaceholder:"Search programs...",emptyMessage:"No welfare programs found",emptyDescription:"Create your first welfare program.",totalCount:(F==null?void 0:F.count)??0,pagination:$,onPaginationChange:Q,sorting:Z,onSortingChange:W,globalFilter:ee,onGlobalFilterChange:M}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Program":"New Program"}),e.jsx(_e,{children:n?"Update welfare program details.":"Create a new welfare program."})]}),e.jsxs("form",{onSubmit:i.handleSubmit(p),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(E,{className:"mt-1.5",...i.register("name"),placeholder:"e.g. Employee Health Insurance"}),i.formState.errors.name&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(E,{className:"mt-1.5",...i.register("code"),placeholder:"e.g. WP-HI-001"}),i.formState.errors.code&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:i.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(ce,{className:"mt-1.5",...i.register("description"),rows:3,placeholder:"Program description..."})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Program Type *"}),e.jsxs(z,{value:i.watch("program_type"),onValueChange:t=>i.setValue("program_type",t),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsx(L,{children:ut.map(t=>e.jsx(h,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Budget"}),e.jsx(E,{className:"mt-1.5",...i.register("budget"),placeholder:"e.g. 100000.00"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Start Date *"}),e.jsx(E,{className:"mt-1.5",type:"date",...i.register("start_date"),max:i.watch("end_date")||void 0})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"End Date"}),e.jsx(E,{className:"mt-1.5",type:"date",...i.register("end_date"),min:i.watch("start_date")||void 0})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Max Participants"}),e.jsx(E,{className:"mt-1.5",type:"number",...i.register("max_participants"),placeholder:"Leave empty for unlimited"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Active"}),e.jsx(ne,{checked:i.watch("is_active"),onCheckedChange:t=>i.setValue("is_active",t)})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:i.handleSubmit(p),disabled:N.isPending||D.isPending,children:N.isPending||D.isPending?"Saving...":n?"Update":"Create"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:t=>!t&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete Welfare Program"}),e.jsxs(Pe,{children:["Are you sure you want to delete ",e.jsx("span",{className:"font-medium text-slate-700",children:u==null?void 0:u.name}),"? This action cannot be undone."]})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&R.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const ga={enrolled:"default",active:"success",completed:"success",withdrawn:"secondary",expired:"destructive"},ja=he({welfare_program:P().min(1,"Program is required"),employee:P().min(1,"Employee is required"),enrollment_date:Qe("Date is required"),status:oe(["enrolled","active","completed","withdrawn","expired"]),benefit_amount:P().optional(),remarks:P().optional()});function un(){const[a,s]=S.useState(!1),[n,d]=S.useState(null),[u,x]=S.useState(null),[C,w]=S.useState(""),{hasPermission:A,requirePermission:O}=de(),G=A("health_safety","welfare_enrollment","create"),V=A("health_safety","welfare_enrollment","update"),{pagination:J,setPagination:$,sorting:Q,setSorting:Z,globalFilter:W,setGlobalFilter:ee,queryParams:M}=Ve(),te={...M,...C&&{status:C}},{data:b,isLoading:F}=Vs(te),[B,N]=S.useState(""),{data:D}=_t({page_size:100,is_active:!0,search:B||void 0}),R=Os(),i=Rs(),Y=$s(),c=xe({resolver:ue(ja),defaultValues:{status:"enrolled"}});function p(){O("health_safety","welfare_enrollment","create")&&(d(null),c.reset({status:"enrolled",welfare_program:"",employee:"",enrollment_date:""}),s(!0))}function T(o){O("health_safety","welfare_enrollment","update")&&(d(o),c.reset({welfare_program:o.welfare_program,employee:o.employee,enrollment_date:o.enrollment_date,status:o.status,benefit_amount:o.benefit_amount,remarks:o.remarks}),s(!0))}function se(o){const r={...o,company:"",benefit_amount:o.benefit_amount??"0",remarks:o.remarks??""};n?i.mutate({id:n.id,...r},{onSuccess:()=>{s(!1),c.reset()}}):R.mutate(r,{onSuccess:()=>{s(!1),c.reset()}})}function t(o){w(o==="__all__"?"":o),$(r=>({...r,pageIndex:0}))}const f=[{key:"employee_name",header:"Employee",render:o=>e.jsx("span",{className:"font-medium text-slate-900",children:o.employee_name??"--"})},{key:"welfare_program_name",header:"Program",className:"w-40",render:o=>e.jsx("span",{className:"text-[12px] text-slate-600",children:o.welfare_program_name??"--"})},{key:"enrollment_date",header:"Enrolled",className:"w-28",render:o=>e.jsx("span",{className:"text-[12px] text-slate-400",children:new Date(o.enrollment_date).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})})},{key:"benefit_amount",header:"Benefit",className:"w-24",render:o=>e.jsx("span",{className:"text-[12px] text-slate-600",children:o.benefit_amount})},{key:"status",header:"Status",className:"w-24",render:o=>e.jsx(X,{variant:ga[o.status],className:"text-[11px] capitalize",children:o.status})},{key:"actions",header:"",className:"w-10",render:o=>e.jsxs(qe,{children:[e.jsx(Ie,{asChild:!0,children:e.jsxs(k,{variant:"ghost",size:"icon-sm",children:[e.jsx(Re,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Actions"})]})}),e.jsxs(Te,{align:"end",className:"w-44",children:[V&&e.jsx(K,{className:"gap-2 text-[13px]",onClick:()=>T(o),children:"Edit"}),V&&e.jsxs(e.Fragment,{children:[e.jsx(De,{}),e.jsxs(K,{className:"gap-2 text-[13px] text-red-600 focus:text-red-600 focus:bg-red-50",onClick:()=>x(o),children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),"Delete"]})]})]})]})}];return e.jsxs("div",{children:[e.jsx(me,{title:"Welfare Enrollments",description:"Manage employee enrollments in welfare programs.",actions:G&&e.jsxs(k,{size:"sm",onClick:p,children:[e.jsx(pe,{className:"mr-1.5 h-3.5 w-3.5"})," New Enrollment"]})}),e.jsx(Oe,{actions:e.jsxs(z,{value:C,onValueChange:t,children:[e.jsx(U,{className:"w-[140px] h-9",children:e.jsx(H,{placeholder:"All statuses"})}),e.jsxs(L,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"enrolled",children:"Enrolled"}),e.jsx(h,{value:"active",children:"Active"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"withdrawn",children:"Withdrawn"}),e.jsx(h,{value:"expired",children:"Expired"})]})]}),columns:f,data:(b==null?void 0:b.results)??[],isLoading:F,rowKey:o=>o.id,searchKeys:["employee_name","welfare_program_name"],searchPlaceholder:"Search enrollments...",emptyMessage:"No welfare enrollments found",emptyDescription:"Enroll employees in welfare programs.",totalCount:(b==null?void 0:b.count)??0,pagination:J,onPaginationChange:$,sorting:Q,onSortingChange:Z,globalFilter:W,onGlobalFilterChange:ee}),e.jsx(ge,{open:a,onOpenChange:s,children:e.jsxs(je,{children:[e.jsxs(fe,{children:[e.jsx(ye,{children:n?"Edit Enrollment":"New Enrollment"}),e.jsx(_e,{children:n?"Update enrollment details.":"Enroll an employee in a welfare program."})]}),e.jsxs("form",{onSubmit:c.handleSubmit(se),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Welfare Program *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Ge,{value:c.watch("welfare_program")??null,onValueChange:o=>c.setValue("welfare_program",o,{shouldValidate:!0}),onSearch:N,selectedLabel:(n==null?void 0:n.welfare_program_name)??void 0,options:((D==null?void 0:D.results)??[]).map(o=>({value:o.id,label:o.name,hint:o.code})),placeholder:"Select program",searchPlaceholder:"Search programs..."})}),c.formState.errors.welfare_program&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:c.formState.errors.welfare_program.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Employee ID *"}),e.jsx(Ue,{className:"mt-1.5",value:c.watch("employee")??"",onValueChange:o=>c.setValue("employee",o,{shouldValidate:!0}),placeholder:"Select employee"}),c.formState.errors.employee&&e.jsx("p",{className:"text-[12px] text-red-600 mt-1",children:c.formState.errors.employee.message})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Enrollment Date *"}),e.jsx(E,{className:"mt-1.5",type:"date",...c.register("enrollment_date")})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Status"}),e.jsxs(z,{value:c.watch("status"),onValueChange:o=>c.setValue("status",o),children:[e.jsx(U,{className:"mt-1.5 h-9 text-[13px]",children:e.jsx(H,{})}),e.jsxs(L,{children:[e.jsx(h,{value:"enrolled",children:"Enrolled"}),e.jsx(h,{value:"active",children:"Active"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"withdrawn",children:"Withdrawn"}),e.jsx(h,{value:"expired",children:"Expired"})]})]})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Benefit Amount"}),e.jsx(E,{className:"mt-1.5",...c.register("benefit_amount"),placeholder:"e.g. 5000.00"})]}),e.jsxs("div",{children:[e.jsx(l,{className:"text-[12px] font-medium text-slate-500",children:"Remarks"}),e.jsx(ce,{className:"mt-1.5",...c.register("remarks"),rows:2,placeholder:"Additional notes..."})]})]}),e.jsxs(ve,{children:[e.jsx(k,{type:"button",variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(k,{onClick:c.handleSubmit(se),disabled:R.isPending||i.isPending,children:R.isPending||i.isPending?"Saving...":n?"Update":"Enroll"})]})]})}),e.jsx(Ne,{open:!!u,onOpenChange:o=>!o&&x(null),children:e.jsxs(Se,{children:[e.jsx(Ce,{children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(be,{variant:"destructive"}),e.jsxs("div",{children:[e.jsx(we,{children:"Delete Enrollment"}),e.jsx(Pe,{children:"Are you sure you want to delete this enrollment? This action cannot be undone."})]})]})}),e.jsxs(ke,{children:[e.jsx(Ee,{onClick:()=>x(null),children:"Cancel"}),e.jsx(Fe,{variant:"destructive",onClick:()=>{u&&Y.mutate(u.id),x(null)},children:"Delete"})]})]})})]})}const fa=he({incident_reporting_enabled:ae(),anonymous_incident_reporting:ae(),auto_notify_safety_officer:ae(),safety_training_mandatory:ae(),medical_check_frequency_months:Me.number().int().min(1),medical_check_mandatory:ae(),ppe_tracking_enabled:ae(),ppe_replacement_reminder_days:Me.number().int().min(1),posh_enabled:ae(),posh_committee_min_members:Me.number().int().min(1),welfare_programs_enabled:ae(),incident_sla_days:Me.number().int().min(1)});function hn(){const{data:a,isLoading:s}=Qt(),n=zt(),{hasPermission:d}=de(),u=d("health_safety","settings","update"),x=xe({resolver:ue(fa),defaultValues:{incident_reporting_enabled:!0,anonymous_incident_reporting:!1,auto_notify_safety_officer:!0,safety_training_mandatory:!0,medical_check_frequency_months:12,medical_check_mandatory:!0,ppe_tracking_enabled:!0,ppe_replacement_reminder_days:30,posh_enabled:!0,posh_committee_min_members:4,welfare_programs_enabled:!0,incident_sla_days:7}});S.useEffect(()=>{a&&x.reset({incident_reporting_enabled:a.incident_reporting_enabled,anonymous_incident_reporting:a.anonymous_incident_reporting,auto_notify_safety_officer:a.auto_notify_safety_officer,safety_training_mandatory:a.safety_training_mandatory,medical_check_frequency_months:a.medical_check_frequency_months,medical_check_mandatory:a.medical_check_mandatory,ppe_tracking_enabled:a.ppe_tracking_enabled,ppe_replacement_reminder_days:a.ppe_replacement_reminder_days,posh_enabled:a.posh_enabled,posh_committee_min_members:a.posh_committee_min_members,welfare_programs_enabled:a.welfare_programs_enabled,incident_sla_days:a.incident_sla_days})},[a,x]);function C(w){n.mutate(w)}return s?e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[16px] font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(Ye,{className:"h-5 w-5 text-primary"})," Health & Safety Settings"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure health, safety & welfare module"})]})}),e.jsx("div",{className:"space-y-4",children:[1,2,3,4,5,6].map(w=>e.jsx("div",{className:"h-32 rounded-lg skeleton-shimmer"},w))})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[16px] font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(Ye,{className:"h-5 w-5 text-primary"})," Health & Safety Settings"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure health, safety & welfare module"})]}),u&&e.jsx(k,{size:"sm",disabled:!x.formState.isDirty||n.isPending,onClick:x.handleSubmit(C),children:n.isPending?"Saving...":"Save Changes"})]}),e.jsxs("form",{onSubmit:x.handleSubmit(C),className:"space-y-4",children:[e.jsxs(ie,{children:[e.jsx($e,{children:e.jsxs(Ke,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4 text-slate-400"})," Incident Reporting"]})}),e.jsxs(re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Enable Incident Reporting"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Allow employees to report incidents"})]}),e.jsx(ze,{name:"incident_reporting_enabled",control:x.control,render:({field:w})=>e.jsx(ne,{checked:w.value,onCheckedChange:w.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Anonymous Reporting"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Allow anonymous incident reports"})]}),e.jsx(ze,{name:"anonymous_incident_reporting",control:x.control,render:({field:w})=>e.jsx(ne,{checked:w.value,onCheckedChange:w.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Auto-notify Safety Officer"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Automatically notify safety officer on new incidents"})]}),e.jsx(ze,{name:"auto_notify_safety_officer",control:x.control,render:({field:w})=>e.jsx(ne,{checked:w.value,onCheckedChange:w.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Incident SLA Days"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Maximum days to resolve an incident"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(E,{className:"w-20 text-center",type:"number",min:1,...x.register("incident_sla_days")}),e.jsx("span",{className:"text-[12px] text-slate-400",children:"days"})]})]})]})]}),e.jsxs(ie,{children:[e.jsx($e,{children:e.jsxs(Ke,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(tt,{className:"h-4 w-4 text-slate-400"})," Safety Training"]})}),e.jsx(re,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Mandatory Safety Training"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Require safety training for all employees"})]}),e.jsx(ze,{name:"safety_training_mandatory",control:x.control,render:({field:w})=>e.jsx(ne,{checked:w.value,onCheckedChange:w.onChange})})]})})]}),e.jsxs(ie,{children:[e.jsx($e,{children:e.jsxs(Ke,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(st,{className:"h-4 w-4 text-slate-400"})," Medical Checks"]})}),e.jsxs(re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Mandatory Medical Checks"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Require periodic medical fitness checks"})]}),e.jsx(ze,{name:"medical_check_mandatory",control:x.control,render:({field:w})=>e.jsx(ne,{checked:w.value,onCheckedChange:w.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Check Frequency"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Months between medical checks"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(E,{className:"w-20 text-center",type:"number",min:1,...x.register("medical_check_frequency_months")}),e.jsx("span",{className:"text-[12px] text-slate-400",children:"months"})]})]})]})]}),e.jsxs(ie,{children:[e.jsx($e,{children:e.jsxs(Ke,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(at,{className:"h-4 w-4 text-slate-400"})," PPE Tracking"]})}),e.jsxs(re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Enable PPE Tracking"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Track PPE issuance and returns"})]}),e.jsx(ze,{name:"ppe_tracking_enabled",control:x.control,render:({field:w})=>e.jsx(ne,{checked:w.value,onCheckedChange:w.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Replacement Reminder"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Days before PPE expiry to send reminders"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(E,{className:"w-20 text-center",type:"number",min:1,...x.register("ppe_replacement_reminder_days")}),e.jsx("span",{className:"text-[12px] text-slate-400",children:"days"})]})]})]})]}),e.jsxs(ie,{children:[e.jsx($e,{children:e.jsxs(Ke,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(nt,{className:"h-4 w-4 text-slate-400"})," POSH Compliance"]})}),e.jsxs(re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Enable POSH Module"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Enable POSH complaint management"})]}),e.jsx(ze,{name:"posh_enabled",control:x.control,render:({field:w})=>e.jsx(ne,{checked:w.value,onCheckedChange:w.onChange})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Min Committee Members"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Minimum POSH committee members required"})]}),e.jsx(E,{className:"w-20 text-center",type:"number",min:1,...x.register("posh_committee_min_members")})]})]})]}),e.jsxs(ie,{children:[e.jsx($e,{children:e.jsxs(Ke,{className:"text-[14px] font-semibold flex items-center gap-2",children:[e.jsx(Ye,{className:"h-4 w-4 text-slate-400"})," Welfare Programs"]})}),e.jsx(re,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(l,{className:"text-[13px] font-medium text-slate-700",children:"Enable Welfare Programs"}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:"Enable employee welfare program management"})]}),e.jsx(ze,{name:"welfare_programs_enabled",control:x.control,render:({field:w})=>e.jsx(ne,{checked:w.value,onCheckedChange:w.onChange})})]})})]})]})]})}function pn(){return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[16px] font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(Ze,{className:"h-5 w-5 text-primary"})," Safety Reports"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"View safety reports and compliance metrics"})]})}),e.jsxs(ie,{children:[e.jsx($e,{children:e.jsx(Ke,{className:"text-[14px] font-semibold",children:"Report Center"})}),e.jsx(re,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Ze,{className:"h-10 w-10 text-slate-300 mb-3"}),e.jsx("p",{className:"text-[14px] font-medium text-slate-600",children:"Coming Soon"}),e.jsx("p",{className:"text-[13px] text-slate-400 mt-1 max-w-sm",children:"Generate incident reports, safety compliance summaries, PPE utilization metrics, and welfare program analytics."})]})})]})]})}function gn(){return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"text-[16px] font-semibold text-slate-900 flex items-center gap-2",children:[e.jsx(et,{className:"h-5 w-5 text-primary"})," Safety Analytics"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Explore safety trends and compliance analytics"})]})}),e.jsxs(ie,{children:[e.jsx($e,{children:e.jsx(Ke,{className:"text-[14px] font-semibold",children:"Analytics Dashboard"})}),e.jsx(re,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(et,{className:"h-10 w-10 text-slate-300 mb-3"}),e.jsx("p",{className:"text-[14px] font-medium text-slate-600",children:"Coming Soon"}),e.jsx("p",{className:"text-[13px] text-slate-400 mt-1 max-w-sm",children:"Analyze incident trends, severity distributions, corrective action effectiveness, training compliance rates, and PPE utilization."})]})})]})]})}export{nn as CorrectiveActionsPage,gn as HealthSafetyAnalyticsPage,en as HealthSafetyDashboardPage,Ya as HealthSafetyLayout,pn as HealthSafetyReportsPage,hn as HealthSafetySettingsPage,sn as IncidentCategoriesPage,tn as IncidentsPage,an as InvestigationsPage,cn as MedicalFitnessPage,mn as POSHComplaintsPage,dn as PPEIssuesPage,on as PPEItemsPage,ln as SafetyTrainingRecordsPage,rn as SafetyTrainingsPage,un as WelfareEnrollmentsPage,xn as WelfareProgramsPage,Is as useAcknowledgePOSH,Yt as useAssignIncident,rs as useCompleteCorrectiveAction,ps as useCompleteSafetyTrainingRecord,ss as useCorrectiveActions,as as useCreateCorrectiveAction,Gt as useCreateIncident,Ut as useCreateIncidentCategory,Zt as useCreateInvestigation,js as useCreateMedicalFitness,Es as useCreatePOSHComplaint,Cs as useCreatePPEIssue,_s as useCreatePPEItem,cs as useCreateSafetyTraining,xs as useCreateSafetyTrainingRecord,Os as useCreateWelfareEnrollment,Ts as useCreateWelfareProgram,is as useDeleteCorrectiveAction,Bt as useDeleteIncident,Lt as useDeleteIncidentCategory,ts as useDeleteInvestigation,ys as useDeleteMedicalFitness,qs as useDeletePOSHComplaint,ws as useDeletePPEIssue,Ns as useDeletePPEItem,ds as useDeleteSafetyTraining,hs as useDeleteSafetyTrainingRecord,$s as useDeleteWelfareEnrollment,As as useDeleteWelfareProgram,Za as useHealthSafetyAnalytics,Ks as useHealthSafetyDashboard,Ja as useHealthSafetyReports,Qt as useHealthSafetySettings,jt as useIncidentCategories,Xa as useIncidentDetail,lt as useIncidents,Jt as useInvestigations,gs as useMedicalFitness,ks as usePOSHComplaints,Ss as usePPEIssues,yt as usePPEItems,Xt as useResolveIncident,Ps as useReturnPPE,ms as useSafetyTrainingRecords,ft as useSafetyTrainings,ns as useUpdateCorrectiveAction,zt as useUpdateHealthSafetySettings,Wt as useUpdateIncident,Ht as useUpdateIncidentCategory,es as useUpdateInvestigation,fs as useUpdateMedicalFitness,Fs as useUpdatePOSHComplaint,bs as useUpdatePPEIssue,vs as useUpdatePPEItem,os as useUpdateSafetyTraining,us as useUpdateSafetyTrainingRecord,Rs as useUpdateWelfareEnrollment,Ds as useUpdateWelfareProgram,ls as useVerifyCorrectiveAction,Vs as useWelfareEnrollments,_t as useWelfarePrograms};
