import{j as e,u as se,b as R,a as F}from"./query-PJ0ZdjbV.js";import{f as Os,a as P,O as Us,k as Bs,u as Hs}from"./vendor-CWhr2lg4.js";import{a2 as ns,b0 as de,U as Ws,cz as as,b_ as Ys,cA as Zs,c3 as xs,T as is,bz as ds,bf as Js,ap as Ze,p as f,a4 as l,B as w,d as ze,h as Me,a as Xs,e as Je,f as Xe,au as hs,s as re,t as ne,v as ie,w as le,x as h,P as ye,aa as ve,ab as be,ac as Ne,ad as we,ae as Se,q as p,I as V,af as ke,ag as me,ah as pe,ai as ue,aj as Z,y as Fe,r as Ke,Q as Ee,V as De,W as $e,Y as Ve,Z as Ie,_ as Qe,$ as Le,a0 as Te,ak as Ue,b as Ae,a5 as et,L as st,at as tt}from"./index-BSPIaiZU.js";import{L as at}from"./layout-dashboard-pgzECxsO.js";import{R as gs}from"./rotate-ccw-u1EtXcFp.js";import{F as Ss}from"./file-text-BeBoTfpI.js";import{T as ks}from"./trending-up-Cognoqa9.js";import{B as fs}from"./book-open-CYSpU_-u.js";import{G as es}from"./git-branch-DrD8zRaR.js";import{M as Cs}from"./message-square-CrQ4L-TW.js";import{A as js}from"./award-BB4qCp8n.js";import{F as ms}from"./file-chart-column-increasing-DonUpE5r.js";import{A as ps}from"./activity-BBaZC8Hc.js";import{B as ce}from"./badge-C34iUAiA.js";import{P as He}from"./page-header-D8tSLbK0.js";import{A as cs}from"./arrow-right-Bmt6JCm_.js";import{u as xe,t as he,o as ge,e as Ce,s as q,a as ae,c as Pe,b as ee}from"./date-range-picker-BB0TgAn8.js";import{D as fe}from"./data-table-D_-xOEqd.js";import{u as je}from"./use-data-table-state-CKRg6qY2.js";import{w as ss,i as Ge,a as us}from"./date-validation-D9gNvaP9.js";import{E as _e}from"./ellipsis-DaNBIBaV.js";import{P as Re}from"./pencil-Dl5fXQYl.js";import{P as rt}from"./play-N42nmD6a.js";import{L as nt}from"./lock-mVL2BhFn.js";import{C as ls}from"./circle-x-C0sF-Oht.js";import{A as Ps}from"./approval-status-pill-FaqYhoSe.js";import{E as it}from"./eye-DlIcvqP-.js";import{S as qs}from"./send-hExJQKXK.js";import{C as Rs}from"./circle-check-Dgh1V3VA.js";import{A as qe}from"./async-select-BUbwdJEZ.js";import{E as Oe}from"./employee-select-DtUobKxP.js";import{u as rs,B as lt}from"./system-admin.api-BT5u-_A_.js";import{S as Ye}from"./status-badge-DPaiL_rL.js";import{C as Fs}from"./chart-column-DbfNf7gS.js";import{C as As}from"./clipboard-list-DCTO70_z.js";import{S as ct}from"./skeleton-CfUgaIb_.js";import{S as ot}from"./star-DLH_J9Ff.js";import"./ui-aO-W1bxx.js";import"./chevron-left-DLFf1YD2.js";import"./circle-alert-9pjtMKqA.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 dt=ns("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
 * @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 mt=ns("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);/**
 * @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 pt=ns("SlidersVertical",[["line",{x1:"4",x2:"4",y1:"21",y2:"14",key:"1p332r"}],["line",{x1:"4",x2:"4",y1:"10",y2:"3",key:"gb41h5"}],["line",{x1:"12",x2:"12",y1:"21",y2:"12",key:"hf2csr"}],["line",{x1:"12",x2:"12",y1:"8",y2:"3",key:"1kfi7u"}],["line",{x1:"20",x2:"20",y1:"21",y2:"16",key:"1lhrwl"}],["line",{x1:"20",x2:"20",y1:"12",y2:"3",key:"16vvfq"}],["line",{x1:"2",x2:"6",y1:"14",y2:"14",key:"1uebub"}],["line",{x1:"10",x2:"14",y1:"8",y2:"8",key:"1yglbp"}],["line",{x1:"18",x2:"22",y1:"16",y2:"16",key:"1jxqpz"}]]);/**
 * @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 ts=ns("Trophy",[["path",{d:"M6 9H4.5a2.5 2.5 0 0 1 0-5H6",key:"17hqa7"}],["path",{d:"M18 9h1.5a2.5 2.5 0 0 0 0-5H18",key:"lmptdp"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22",key:"1nw9bq"}],["path",{d:"M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22",key:"1np0yb"}],["path",{d:"M18 2H6v7a6 6 0 0 0 12 0V2Z",key:"u46fv3"}]]),ut=[{heading:"Overview",items:[{to:"/performance",label:"Dashboard",description:"Performance overview",icon:at,permission:["performance","dashboard","read"]}]},{heading:"Reviews",items:[{to:"/performance/review-cycles",label:"Review Cycles",description:"Manage cycles",icon:gs,permission:["performance","review_cycle","read"]},{to:"/performance/employee-reviews",label:"Employee Reviews",description:"Individual reviews",icon:Ws,permission:["performance","review","read"]},{to:"/performance/appraisal-forms",label:"Appraisal Forms",description:"Form templates",icon:Ss,permission:["performance","appraisal","read"]}]},{heading:"Goals",items:[{to:"/performance/goals",label:"Goals",description:"Goal management",icon:as,permission:["performance","goal","read"]},{to:"/performance/goal-progress",label:"Goal Progress",description:"Track progress",icon:ks,permission:["performance","goal","read"]}]},{heading:"KRAs & KPIs",items:[{to:"/performance/kra-library",label:"KRA Library",description:"Key result areas",icon:fs,permission:["performance","kra","read"]},{to:"/performance/kpi-library",label:"KPI Library",description:"Key indicators",icon:dt,permission:["performance","kpi","read"]},{to:"/performance/kra-assignments",label:"KRA Assignments",description:"Assign KRAs",icon:es,permission:["performance","kra_assignment","read"]}]},{heading:"Competencies",items:[{to:"/performance/competency-framework",label:"Competency Framework",description:"Define competencies",icon:Ys,permission:["performance","competency","read"]},{to:"/performance/competency-assignments",label:"Competency Assignments",description:"Assign & assess",icon:es,permission:["performance","competency_assignment","read"]}]},{heading:"Feedback",items:[{to:"/performance/feedback",label:"360 Feedback",description:"Multi-rater feedback",icon:Cs,permission:["performance","feedback","read"]},{to:"/performance/questionnaires",label:"Questionnaires",description:"Feedback forms",icon:Zs,permission:["performance","questionnaire","read"]}]},{heading:"Calibration",items:[{to:"/performance/calibration",label:"Calibration Sessions",description:"Rating calibration",icon:xs,permission:["performance","calibration","read"]}]},{heading:"PIP",items:[{to:"/performance/pip",label:"Improvement Plans",description:"Performance PIPs",icon:is,permission:["performance","pip","read"]}]},{heading:"Recognition",items:[{to:"/performance/programs",label:"Programs",description:"Recognition programs",icon:js,permission:["performance","recognition_program","read"]},{to:"/performance/badges",label:"Badges",description:"Manage badges",icon:mt,permission:["performance","badge","read"]},{to:"/performance/recognition",label:"Recognitions",description:"Give & receive",icon:ts,permission:["performance","recognition","read"]}]},{heading:"Configuration",items:[{to:"/performance/settings",label:"Settings",description:"Module settings",icon:ds,permission:["performance","settings","read"]},{to:"/performance/rating-scales",label:"Rating Scales",description:"Rating definitions",icon:pt,permission:["performance","rating_scale","read"]}]},{heading:"Insights",items:[{to:"/performance/reports",label:"Reports",description:"Performance reports",icon:ms,permission:["performance","report","read"]},{to:"/performance/analytics",label:"Analytics",description:"Trends & insights",icon:ps,permission:["performance","analytics","read"]}]}];function xt({item:s,isActive:t}){const a=s.icon;return e.jsxs(Bs,{to:s.to,end:s.to==="/performance",className:Ze("group relative flex items-center gap-3 rounded-lg px-3 py-2.5 transition-all duration-150",t?"bg-primary-subtle/70":"hover:bg-slate-50"),children:[t&&e.jsx("span",{className:"absolute left-0 top-2.5 bottom-2.5 w-[3px] rounded-r-full bg-primary"}),e.jsx("div",{className:Ze("flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors duration-150",t?"bg-primary/10 text-primary":"bg-slate-100 text-slate-400 group-hover:bg-slate-200/70 group-hover:text-slate-500"),children:e.jsx(a,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:Ze("block text-[13px] truncate leading-tight",t?"font-medium text-primary":"font-medium text-slate-700 group-hover:text-slate-900"),children:s.label}),e.jsx("span",{className:Ze("block text-[11px] truncate leading-tight mt-0.5",t?"text-primary/60":"text-slate-400"),children:s.description})]})]})}function en(){const s=Os(),t=P.useRef(null),{hasPermission:a}=de();P.useEffect(()=>{var d;(d=t.current)==null||d.scrollTo(0,0)},[s.pathname]);const m=P.useMemo(()=>ut.map(d=>({...d,items:d.items.filter(_=>a(_.permission[0],_.permission[1],_.permission[2]))})).filter(d=>d.items.length>0),[a]);return e.jsxs("div",{className:"-m-6 flex h-[calc(100%+48px)]",children:[e.jsxs("aside",{className:"w-[260px] shrink-0 border-r border-slate-200/60 bg-white flex flex-col",children:[e.jsxs("div",{className:"shrink-0 px-5 pt-6 pb-4 border-b border-slate-100",children:[e.jsx("h1",{className:"text-[15px] font-semibold text-slate-900 tracking-tight",children:"Performance Management"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-slate-400",children:"Reviews, goals & recognition"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-3 py-3 scrollbar-thin",children:m.map((d,_)=>e.jsxs("div",{className:Ze(_>0&&"mt-6"),children:[e.jsx("p",{className:"mb-2 px-3 text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400",children:d.heading}),e.jsx("div",{className:"space-y-0.5",children:d.items.map(v=>{const $=v.to==="/performance"?s.pathname==="/performance":Js(s.pathname,v.to);return e.jsx(xt,{item:v,isActive:$},v.to)})})]},d.heading))})]}),e.jsx("main",{ref:t,className:"flex-1 min-w-0 overflow-y-auto bg-background scrollbar-thin",children:e.jsx("div",{className:"px-8 py-6 w-full",children:e.jsx(Us,{})})})]})}const j="/performance",c={settings:["performance","settings"],ratingScales:["performance","rating-scales"],competencyFrameworks:["performance","competency-frameworks"],competencyAssignments:["performance","competency-assignments"],kraLibrary:["performance","kra-library"],kpiLibrary:["performance","kpi-library"],kraAssignments:["performance","kra-assignments"],kpiAssignments:["performance","kpi-assignments"],reviewCycles:["performance","review-cycles"],reviewCycle:s=>["performance","review-cycles",s],reviewStages:["performance","review-stages"],employeeReviews:["performance","employee-reviews"],employeeReview:s=>["performance","employee-reviews",s],goals:["performance","goals"],goal:s=>["performance","goals",s],goalProgress:["performance","goal-progress"],goalComments:s=>["performance","goal-comments",s],appraisalForms:["performance","appraisal-forms"],questionnaires:["performance","feedback-questionnaires"],feedbackRequests:["performance","feedback-requests"],feedbackResponses:["performance","feedback-responses"],calibrationSessions:["performance","calibration-sessions"],calibrationAdjustments:["performance","calibration-adjustments"],pips:["performance","pips"],pip:s=>["performance","pips",s],pipMilestones:["performance","pip-milestones"],pipReviews:["performance","pip-reviews"],recognitionPrograms:["performance","recognition-programs"],recognitionBadges:["performance","recognition-badges"],recognitions:["performance","recognitions"],recognitionReactions:["performance","recognition-reactions"],dashboard:["performance","dashboard"]};function ht(){return se({queryKey:c.settings,queryFn:()=>f.get(`${j}/settings/`).then(s=>s.data)})}function gt(){const s=R();return F({mutationFn:t=>f.patch(`${j}/settings/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.settings}),l.success("Performance settings updated")},onError:()=>l.error("Failed to update settings")})}function ft(s){return se({queryKey:[...c.ratingScales,s],queryFn:()=>f.get(`${j}/rating-scales/`,{params:s}).then(t=>t.data)})}function jt(){const s=R();return F({mutationFn:t=>f.post(`${j}/rating-scales/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.ratingScales}),l.success("Rating scale created")},onError:()=>l.error("Failed to create rating scale")})}function _t(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/rating-scales/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.ratingScales}),l.success("Rating scale updated")},onError:()=>l.error("Failed to update rating scale")})}function yt(){const s=R();return F({mutationFn:t=>f.delete(`${j}/rating-scales/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.ratingScales}),l.success("Rating scale deleted")},onError:()=>l.error("Failed to delete rating scale")})}function Ks(s){return se({queryKey:[...c.competencyFrameworks,s],queryFn:()=>f.get(`${j}/competency-frameworks/`,{params:s}).then(t=>t.data)})}function vt(){const s=R();return F({mutationFn:t=>f.post(`${j}/competency-frameworks/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.competencyFrameworks}),l.success("Competency framework created")},onError:()=>l.error("Failed to create competency framework")})}function bt(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/competency-frameworks/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.competencyFrameworks}),l.success("Competency framework updated")},onError:()=>l.error("Failed to update competency framework")})}function Nt(){const s=R();return F({mutationFn:t=>f.delete(`${j}/competency-frameworks/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.competencyFrameworks}),l.success("Competency framework deleted")},onError:()=>l.error("Failed to delete competency framework")})}function wt(s){return se({queryKey:[...c.competencyAssignments,s],queryFn:()=>f.get(`${j}/competency-assignments/`,{params:s}).then(t=>t.data)})}function St(){const s=R();return F({mutationFn:t=>f.post(`${j}/competency-assignments/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.competencyAssignments}),l.success("Competency assigned")},onError:()=>l.error("Failed to assign competency")})}function kt(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/competency-assignments/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.competencyAssignments}),l.success("Competency assignment updated")},onError:()=>l.error("Failed to update competency assignment")})}function Es(s){return se({queryKey:[...c.kraLibrary,s],queryFn:()=>f.get(`${j}/kra-library/`,{params:s}).then(t=>t.data)})}function Ct(){const s=R();return F({mutationFn:t=>f.post(`${j}/kra-library/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.kraLibrary}),l.success("KRA created")},onError:()=>l.error("Failed to create KRA")})}function Pt(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/kra-library/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.kraLibrary}),l.success("KRA updated")},onError:()=>l.error("Failed to update KRA")})}function qt(){const s=R();return F({mutationFn:t=>f.delete(`${j}/kra-library/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.kraLibrary}),l.success("KRA deleted")},onError:()=>l.error("Failed to delete KRA")})}function Rt(s){return se({queryKey:[...c.kpiLibrary,s],queryFn:()=>f.get(`${j}/kpi-library/`,{params:s}).then(t=>t.data)})}function Ft(){const s=R();return F({mutationFn:t=>f.post(`${j}/kpi-library/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.kpiLibrary}),l.success("KPI created")},onError:()=>l.error("Failed to create KPI")})}function At(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/kpi-library/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.kpiLibrary}),l.success("KPI updated")},onError:()=>l.error("Failed to update KPI")})}function Kt(){const s=R();return F({mutationFn:t=>f.delete(`${j}/kpi-library/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.kpiLibrary}),l.success("KPI deleted")},onError:()=>l.error("Failed to delete KPI")})}function Et(s){return se({queryKey:[...c.kraAssignments,s],queryFn:()=>f.get(`${j}/kra-assignments/`,{params:s}).then(t=>t.data)})}function Dt(){const s=R();return F({mutationFn:t=>f.post(`${j}/kra-assignments/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.kraAssignments}),l.success("KRA assigned")},onError:()=>l.error("Failed to assign KRA")})}function $t(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/kra-assignments/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.kraAssignments}),l.success("KRA assignment updated")},onError:()=>l.error("Failed to update KRA assignment")})}function Vt(){const s=R();return F({mutationFn:t=>f.delete(`${j}/kra-assignments/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.kraAssignments}),l.success("KRA assignment deleted")},onError:()=>l.error("Failed to delete KRA assignment")})}function sn(s){return se({queryKey:[...c.kpiAssignments,s],queryFn:()=>f.get(`${j}/kpi-assignments/`,{params:s}).then(t=>t.data)})}function tn(){const s=R();return F({mutationFn:t=>f.post(`${j}/kpi-assignments/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.kpiAssignments}),l.success("KPI assigned")},onError:()=>l.error("Failed to assign KPI")})}function We(s){return se({queryKey:[...c.reviewCycles,s],queryFn:()=>f.get(`${j}/review-cycles/`,{params:s}).then(t=>t.data)})}function It(){const s=R();return F({mutationFn:t=>f.post(`${j}/review-cycles/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.reviewCycles}),l.success("Review cycle created")},onError:()=>l.error("Failed to create review cycle")})}function Qt(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/review-cycles/${t}/`,a).then(m=>m.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:c.reviewCycles}),s.invalidateQueries({queryKey:c.reviewCycle(a.id)}),l.success("Review cycle updated")},onError:()=>l.error("Failed to update review cycle")})}function Lt(){const s=R();return F({mutationFn:t=>f.delete(`${j}/review-cycles/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.reviewCycles}),l.success("Review cycle deleted")},onError:()=>l.error("Failed to delete review cycle")})}function Tt(){const s=R();return F({mutationFn:t=>f.post(`${j}/review-cycles/${t}/launch/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.reviewCycles}),s.invalidateQueries({queryKey:c.employeeReviews}),l.success("Review cycle launched")},onError:()=>l.error("Failed to launch review cycle")})}function zt(){const s=R();return F({mutationFn:t=>f.post(`${j}/review-cycles/${t}/close/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.reviewCycles}),l.success("Review cycle closed")},onError:()=>l.error("Failed to close review cycle")})}function Mt(){const s=R();return F({mutationFn:t=>f.post(`${j}/review-cycles/${t}/lock-ratings/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.reviewCycles}),s.invalidateQueries({queryKey:c.employeeReviews}),l.success("Ratings locked")},onError:()=>l.error("Failed to lock ratings")})}function an(s){return se({queryKey:[...c.reviewStages,s],queryFn:()=>f.get(`${j}/review-stages/`,{params:s}).then(t=>t.data)})}function rn(){const s=R();return F({mutationFn:t=>f.post(`${j}/review-stages/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.reviewStages}),l.success("Review stage created")},onError:()=>l.error("Failed to create review stage")})}function nn(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/review-stages/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.reviewStages}),l.success("Review stage updated")},onError:()=>l.error("Failed to update review stage")})}function Ds(s){return se({queryKey:[...c.employeeReviews,s],queryFn:()=>f.get(`${j}/employee-reviews/`,{params:s}).then(t=>t.data)})}function ln(s){return se({queryKey:c.employeeReview(s),queryFn:()=>f.get(`${j}/employee-reviews/${s}/`).then(t=>t.data),enabled:!!s})}function cn(){const s=R();return F({mutationFn:t=>f.post(`${j}/employee-reviews/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.employeeReviews}),l.success("Employee review created")},onError:()=>l.error("Failed to create employee review")})}function on(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/employee-reviews/${t}/`,a).then(m=>m.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:c.employeeReviews}),s.invalidateQueries({queryKey:c.employeeReview(a.id)}),l.success("Employee review updated")},onError:()=>l.error("Failed to update employee review")})}function Gt(){const s=R();return F({mutationFn:t=>f.post(`${j}/employee-reviews/${t}/submit/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.employeeReviews}),s.invalidateQueries({queryKey:c.dashboard}),l.success("Review submitted")},onError:()=>l.error("Failed to submit review")})}function Ot(){const s=R();return F({mutationFn:({id:t,comments:a})=>f.post(`${j}/employee-reviews/${t}/approve/`,{comments:a}).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.employeeReviews}),s.invalidateQueries({queryKey:c.dashboard}),l.success("Review approved")},onError:()=>l.error("Failed to approve review")})}function Ut(){const s=R();return F({mutationFn:({id:t,comments:a})=>f.post(`${j}/employee-reviews/${t}/reject/`,{comments:a}).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.employeeReviews}),s.invalidateQueries({queryKey:c.dashboard}),l.success("Review rejected")},onError:()=>l.error("Failed to reject review")})}function ws(s){return se({queryKey:[...c.goals,s],queryFn:()=>f.get(`${j}/goals/`,{params:s}).then(t=>t.data)})}function dn(s){return se({queryKey:c.goal(s),queryFn:()=>f.get(`${j}/goals/${s}/`).then(t=>t.data),enabled:!!s})}function Bt(){const s=R();return F({mutationFn:t=>f.post(`${j}/goals/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.goals}),s.invalidateQueries({queryKey:c.dashboard}),l.success("Goal created")},onError:()=>l.error("Failed to create goal")})}function Ht(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/goals/${t}/`,a).then(m=>m.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:c.goals}),s.invalidateQueries({queryKey:c.goal(a.id)}),l.success("Goal updated")},onError:()=>l.error("Failed to update goal")})}function Wt(){const s=R();return F({mutationFn:t=>f.delete(`${j}/goals/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.goals}),s.invalidateQueries({queryKey:c.dashboard}),l.success("Goal deleted")},onError:()=>l.error("Failed to delete goal")})}function Yt(){const s=R();return F({mutationFn:({id:t,employee_ids:a})=>f.post(`${j}/goals/${t}/cascade/`,{employee_ids:a}).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.goals}),l.success("Goal cascaded successfully")},onError:()=>l.error("Failed to cascade goal")})}function Zt(s){return se({queryKey:[...c.goalProgress,s],queryFn:()=>f.get(`${j}/goal-progress/`,{params:s}).then(t=>t.data)})}function Jt(){const s=R();return F({mutationFn:t=>f.post(`${j}/goal-progress/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.goalProgress}),s.invalidateQueries({queryKey:c.goals}),l.success("Progress updated")},onError:()=>l.error("Failed to update progress")})}function Xt(){const s=R();return F({mutationFn:t=>f.delete(`${j}/goal-progress/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.goalProgress}),s.invalidateQueries({queryKey:c.goals}),l.success("Progress entry deleted")},onError:()=>l.error("Failed to delete progress entry")})}function mn(s){return se({queryKey:c.goalComments(s),queryFn:()=>f.get(`${j}/goal-comments/`,{params:{goal:s}}).then(t=>t.data),enabled:!!s})}function pn(){const s=R();return F({mutationFn:t=>f.post(`${j}/goal-comments/`,t).then(a=>a.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:c.goalComments(a.goal)}),l.success("Comment added")},onError:()=>l.error("Failed to add comment")})}function ea(s){return se({queryKey:[...c.appraisalForms,s],queryFn:()=>f.get(`${j}/appraisal-forms/`,{params:s}).then(t=>t.data)})}function sa(){const s=R();return F({mutationFn:t=>f.post(`${j}/appraisal-forms/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.appraisalForms}),l.success("Appraisal form created")},onError:()=>l.error("Failed to create appraisal form")})}function ta(){const s=R();return F({mutationFn:t=>f.post(`${j}/appraisal-forms/${t}/submit/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.appraisalForms}),s.invalidateQueries({queryKey:c.employeeReviews}),l.success("Appraisal submitted")},onError:()=>l.error("Failed to submit appraisal")})}function $s(s){return se({queryKey:[...c.questionnaires,s],queryFn:()=>f.get(`${j}/feedback-questionnaires/`,{params:s}).then(t=>t.data)})}function aa(){const s=R();return F({mutationFn:t=>f.post(`${j}/feedback-questionnaires/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.questionnaires}),l.success("Questionnaire created")},onError:()=>l.error("Failed to create questionnaire")})}function ra(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/feedback-questionnaires/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.questionnaires}),l.success("Questionnaire updated")},onError:()=>l.error("Failed to update questionnaire")})}function na(s){return se({queryKey:[...c.feedbackRequests,s],queryFn:()=>f.get(`${j}/feedback-requests/`,{params:s}).then(t=>t.data)})}function ia(){const s=R();return F({mutationFn:t=>f.post(`${j}/feedback-requests/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.feedbackRequests}),l.success("Feedback request sent")},onError:()=>l.error("Failed to send feedback request")})}function la(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/feedback-requests/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.feedbackRequests}),l.success("Feedback request updated")},onError:()=>l.error("Failed to update feedback request")})}function ca(){const s=R();return F({mutationFn:t=>f.delete(`${j}/feedback-requests/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.feedbackRequests}),l.success("Feedback request deleted")},onError:()=>l.error("Failed to delete feedback request")})}function un(s){return se({queryKey:[...c.feedbackResponses,s],queryFn:()=>f.get(`${j}/feedback-responses/`,{params:s}).then(t=>t.data)})}function xn(){const s=R();return F({mutationFn:t=>f.post(`${j}/feedback-responses/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.feedbackResponses}),s.invalidateQueries({queryKey:c.feedbackRequests}),l.success("Feedback submitted")},onError:()=>l.error("Failed to submit feedback")})}function oa(s){return se({queryKey:[...c.calibrationSessions,s],queryFn:()=>f.get(`${j}/calibration-sessions/`,{params:s}).then(t=>t.data)})}function da(){const s=R();return F({mutationFn:t=>f.post(`${j}/calibration-sessions/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.calibrationSessions}),l.success("Calibration session created")},onError:()=>l.error("Failed to create calibration session")})}function ma(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/calibration-sessions/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.calibrationSessions}),l.success("Calibration session updated")},onError:()=>l.error("Failed to update calibration session")})}function pa(){const s=R();return F({mutationFn:t=>f.delete(`${j}/calibration-sessions/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.calibrationSessions}),l.success("Calibration session deleted")},onError:()=>l.error("Failed to delete calibration session")})}function hn(){const s=R();return F({mutationFn:t=>f.post(`${j}/calibration-sessions/${t}/finalize/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.calibrationSessions}),s.invalidateQueries({queryKey:c.employeeReviews}),l.success("Calibration finalized")},onError:()=>l.error("Failed to finalize calibration")})}function gn(s){return se({queryKey:[...c.calibrationAdjustments,s],queryFn:()=>f.get(`${j}/calibration-adjustments/`,{params:s}).then(t=>t.data)})}function fn(){const s=R();return F({mutationFn:t=>f.post(`${j}/calibration-adjustments/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.calibrationAdjustments}),s.invalidateQueries({queryKey:c.employeeReviews}),l.success("Rating adjusted")},onError:()=>l.error("Failed to adjust rating")})}function ua(s){return se({queryKey:[...c.pips,s],queryFn:()=>f.get(`${j}/pips/`,{params:s}).then(t=>t.data)})}function xa(){const s=R();return F({mutationFn:t=>f.post(`${j}/pips/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.pips}),l.success("PIP created")},onError:()=>l.error("Failed to create PIP")})}function ha(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/pips/${t}/`,a).then(m=>m.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:c.pips}),s.invalidateQueries({queryKey:c.pip(a.id)}),l.success("PIP updated")},onError:()=>l.error("Failed to update PIP")})}function ga(){const s=R();return F({mutationFn:({id:t,final_outcome:a,outcome_action:m})=>f.post(`${j}/pips/${t}/close/`,{final_outcome:a,outcome_action:m}).then(d=>d.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.pips}),l.success("PIP closed")},onError:()=>l.error("Failed to close PIP")})}function jn(s){return se({queryKey:[...c.pipMilestones,s],queryFn:()=>f.get(`${j}/pip-milestones/`,{params:s}).then(t=>t.data)})}function _n(){const s=R();return F({mutationFn:t=>f.post(`${j}/pip-milestones/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.pipMilestones}),s.invalidateQueries({queryKey:c.pips}),l.success("PIP milestone created")},onError:()=>l.error("Failed to create milestone")})}function yn(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/pip-milestones/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.pipMilestones}),s.invalidateQueries({queryKey:c.pips}),l.success("Milestone updated")},onError:()=>l.error("Failed to update milestone")})}function vn(s){return se({queryKey:[...c.pipReviews,s],queryFn:()=>f.get(`${j}/pip-reviews/`,{params:s}).then(t=>t.data)})}function bn(){const s=R();return F({mutationFn:t=>f.post(`${j}/pip-reviews/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.pipReviews}),s.invalidateQueries({queryKey:c.pips}),l.success("PIP review submitted")},onError:()=>l.error("Failed to submit PIP review")})}function Vs(s){return se({queryKey:[...c.recognitionPrograms,s],queryFn:()=>f.get(`${j}/recognition-programs/`,{params:s}).then(t=>t.data)})}function fa(){const s=R();return F({mutationFn:t=>f.post(`${j}/recognition-programs/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.recognitionPrograms}),l.success("Recognition program created")},onError:()=>l.error("Failed to create recognition program")})}function ja(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/recognition-programs/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.recognitionPrograms}),l.success("Recognition program updated")},onError:()=>l.error("Failed to update recognition program")})}function Is(s){return se({queryKey:[...c.recognitionBadges,s],queryFn:()=>f.get(`${j}/recognition-badges/`,{params:s}).then(t=>t.data)})}function _a(){const s=R();return F({mutationFn:t=>f.post(`${j}/recognition-badges/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.recognitionBadges}),l.success("Badge created")},onError:()=>l.error("Failed to create badge")})}function ya(){const s=R();return F({mutationFn:({id:t,...a})=>f.patch(`${j}/recognition-badges/${t}/`,a).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.recognitionBadges}),l.success("Badge updated")},onError:()=>l.error("Failed to update badge")})}function va(){const s=R();return F({mutationFn:t=>f.delete(`${j}/recognition-badges/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:c.recognitionBadges}),l.success("Badge deleted")},onError:()=>l.error("Failed to delete badge")})}function ba(s){return se({queryKey:[...c.recognitions,s],queryFn:()=>f.get(`${j}/recognitions/`,{params:s}).then(t=>t.data)})}function Na(){const s=R();return F({mutationFn:t=>f.post(`${j}/recognitions/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.recognitions}),s.invalidateQueries({queryKey:c.dashboard}),l.success("Recognition sent")},onError:()=>l.error("Failed to send recognition")})}function wa(){const s=R();return F({mutationFn:({id:t,comments:a})=>f.post(`${j}/recognitions/${t}/approve/`,{comments:a}).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.recognitions}),l.success("Recognition approved")},onError:()=>l.error("Failed to approve recognition")})}function Sa(){const s=R();return F({mutationFn:({id:t,comments:a})=>f.post(`${j}/recognitions/${t}/reject/`,{comments:a}).then(m=>m.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.recognitions}),l.success("Recognition rejected")},onError:()=>l.error("Failed to reject recognition")})}function Nn(s){return se({queryKey:[...c.recognitionReactions,s],queryFn:()=>f.get(`${j}/recognition-reactions/`,{params:{recognition:s}}).then(t=>t.data),enabled:!!s})}function wn(){const s=R();return F({mutationFn:t=>f.post(`${j}/recognition-reactions/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:c.recognitionReactions}),s.invalidateQueries({queryKey:c.recognitions})},onError:()=>l.error("Failed to react")})}function ka(){return se({queryKey:c.dashboard,queryFn:()=>f.get(`${j}/dashboard/`).then(s=>s.data)})}const Ca={not_started:"secondary",self_assessment:"warning",manager_review:"warning",skip_level_review:"warning",peer_review:"warning",calibration:"default",completed:"success",acknowledged:"success"},Pa={draft:"secondary",active:"default",completed:"success",cancelled:"destructive",deferred:"warning"};function Sn(){var m,d,_;const s=Hs(),{data:t,isLoading:a}=ka();return e.jsxs("div",{children:[e.jsx(He,{title:"Performance Dashboard",description:"Overview of review cycles, goals, and recognition activity.",actions:e.jsxs(w,{size:"sm",onClick:()=>s("/performance/goals"),children:[e.jsx(as,{className:"mr-1.5 h-3.5 w-3.5"})," Manage Goals"]})}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[e.jsx(ze,{children:e.jsx(Me,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(gs,{className:"h-4.5 w-4.5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Active Cycles"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:a?"...":(t==null?void 0:t.active_cycles)??0})]})]})})}),e.jsx(ze,{children:e.jsx(Me,{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(Xs,{className:"h-4.5 w-4.5 text-amber-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Pending Reviews"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:a?"...":(t==null?void 0:t.pending_reviews)??0})]})]})})}),e.jsx(ze,{children:e.jsx(Me,{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(is,{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:"Goals At Risk"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:a?"...":(t==null?void 0:t.goals_at_risk)??0})]})]})})}),e.jsx(ze,{children:e.jsx(Me,{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(ts,{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:"Recognitions"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:a?"...":(t==null?void 0:t.recognition_count)??0})]})]})})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-6 mb-6",children:[e.jsxs(ze,{children:[e.jsx(Je,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Xe,{className:"text-[14px]",children:"My Reviews"}),e.jsxs(w,{variant:"ghost",size:"sm",onClick:()=>s("/performance/employee-reviews"),children:["View All ",e.jsx(cs,{className:"ml-1 h-3.5 w-3.5"})]})]})}),e.jsx(Me,{children:a?e.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((v,$)=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-32 rounded"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-16 rounded"})]},$))}):(m=t==null?void 0:t.my_reviews)!=null&&m.length?e.jsx("div",{className:"divide-y divide-slate-100",children:t.my_reviews.slice(0,5).map(v=>e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:v.review_cycle_name}),e.jsx("p",{className:"text-[11px] text-slate-400",children:v.final_rating?`Rating: ${v.final_rating}`:"Not rated yet"})]}),e.jsx(ce,{variant:Ca[v.status],children:v.status.replace(/_/g," ")})]},v.id))}):e.jsx("p",{className:"text-[13px] text-slate-400 py-4 text-center",children:"No active reviews."})})]}),e.jsxs(ze,{children:[e.jsx(Je,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Xe,{className:"text-[14px]",children:"My Goals"}),e.jsxs(w,{variant:"ghost",size:"sm",onClick:()=>s("/performance/goals"),children:["View All ",e.jsx(cs,{className:"ml-1 h-3.5 w-3.5"})]})]})}),e.jsx(Me,{children:a?e.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((v,$)=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-32 rounded"}),e.jsx("div",{className:"skeleton-shimmer h-2 w-full rounded"})]},$))}):(d=t==null?void 0:t.my_goals)!=null&&d.length?e.jsx("div",{className:"divide-y divide-slate-100",children:t.my_goals.slice(0,5).map(v=>e.jsxs("div",{className:"py-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-[13px] font-medium text-slate-700 truncate mr-2",children:v.title}),e.jsx(ce,{variant:Pa[v.status],className:"text-[10px] shrink-0",children:v.status})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(hs,{value:v.progress,className:"flex-1"}),e.jsxs("span",{className:"text-[11px] text-slate-500 w-8 text-right",children:[v.progress,"%"]})]})]},v.id))}):e.jsx("p",{className:"text-[13px] text-slate-400 py-4 text-center",children:"No active goals."})})]})]}),e.jsxs(ze,{children:[e.jsx(Je,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Xe,{className:"text-[14px]",children:"Recent Recognitions"}),e.jsxs(w,{variant:"ghost",size:"sm",onClick:()=>s("/performance/recognition"),children:["View All ",e.jsx(cs,{className:"ml-1 h-3.5 w-3.5"})]})]})}),e.jsx(Me,{children:a?e.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((v,$)=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-24 rounded"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-48 rounded"})]},$))}):(_=t==null?void 0:t.recent_recognitions)!=null&&_.length?e.jsx("div",{className:"divide-y divide-slate-100",children:t.recent_recognitions.slice(0,5).map(v=>e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ts,{className:"h-4 w-4 text-amber-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:v.title}),e.jsxs("p",{className:"text-[11px] text-slate-400",children:[v.giver_name," recognized ",v.receiver_name]})]})]}),v.badge_tier&&e.jsx(ce,{variant:"secondary",className:"text-[10px]",children:v.badge_tier})]},v.id))}):e.jsx("p",{className:"text-[13px] text-slate-400 py-4 text-center",children:"No recent recognitions."})})]})]})}const qa=ss(ss(ge({name:q().min(1,"Name is required"),code:q().min(1,"Code is required").max(20),cycle_type:Ce(["annual","semi_annual","quarterly","probation","confirmation","adhoc"]),period_start:Ge("Period start is required"),period_end:Ge("Period end is required"),review_start_date:Ge("Review start is required"),review_end_date:Ge("Review end is required")}),"period_start","period_end","Period end cannot be before period start"),"review_start_date","review_end_date","Review end cannot be before review start"),Ra={annual:"Annual",semi_annual:"Semi-Annual",quarterly:"Quarterly",probation:"Probation",confirmation:"Confirmation",adhoc:"Ad-hoc"},Fa={draft:"secondary",goal_setting:"default",self_review:"warning",manager_review:"warning",peer_review:"warning",skip_review:"warning",calibration:"warning",acknowledgment:"default",completed:"success",cancelled:"destructive"};function kn(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),[v,$]=P.useState(""),[Q,G]=P.useState(""),{hasPermission:L,requirePermission:i}=de(),O=L("performance","review_cycle","create"),U=L("performance","review_cycle","update"),M=L("performance","review_cycle","delete"),{pagination:E,setPagination:Y,sorting:H,setSorting:A,globalFilter:B,setGlobalFilter:k}=je(),{data:b,isLoading:z}=We({page:E.pageIndex+1,page_size:E.pageSize,search:B||void 0,...v&&{status:v},...Q&&{cycle_type:Q}}),I=It(),S=Qt(),u=Lt(),g=Tt(),K=zt(),X=Mt(),n=xe({resolver:he(qa),defaultValues:{cycle_type:"annual"}});function o(){i("performance","review_cycle","create")&&(m(null),n.reset({name:"",code:"",cycle_type:"annual",period_start:"",period_end:"",review_start_date:"",review_end_date:""}),t(!0))}function W(T){i("performance","review_cycle","update")&&(m(T),n.reset({name:T.name,code:T.code,cycle_type:T.cycle_type,period_start:T.period_start,period_end:T.period_end,review_start_date:T.review_start_date,review_end_date:T.review_end_date}),t(!0))}function C(T){a?S.mutate({id:a.id,...T},{onSuccess:()=>t(!1)}):I.mutate(T,{onSuccess:()=>t(!1)})}function y(){d&&u.mutate(d.id,{onSuccess:()=>_(null)})}const x=[{key:"name",header:"Cycle Name",render:T=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[13px] font-medium text-slate-800",children:T.name}),e.jsx("span",{className:"ml-2 text-[11px] font-mono text-slate-400",children:T.code})]})},{key:"cycle_type",header:"Type",render:T=>e.jsx(ce,{variant:"secondary",className:"text-[11px]",children:Ra[T.cycle_type]})},{key:"period_start",header:"Period",render:T=>e.jsxs("span",{className:"text-[12px] text-slate-500",children:[T.period_start," to ",T.period_end]})},{key:"employee_review_count",header:"Reviews",render:T=>e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{className:"text-[12px] text-slate-600",children:T.employee_review_count??0})})},{key:"status",header:"Status",render:T=>e.jsx(ce,{variant:Fa[T.status],className:"text-[11px]",children:T.status.replace(/_/g," ")})},{key:"actions",header:"",render:T=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[U&&e.jsxs(Z,{onClick:()=>W(T),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),U&&T.status==="draft"&&e.jsxs(Z,{onClick:()=>g.mutate(T.id),children:[e.jsx(rt,{className:"mr-2 h-3.5 w-3.5"})," Launch"]}),U&&(T.status==="calibration"||T.status==="acknowledgment")&&e.jsxs(Z,{onClick:()=>X.mutate(T.id),children:[e.jsx(nt,{className:"mr-2 h-3.5 w-3.5"})," Lock Ratings"]}),U&&T.status!=="completed"&&T.status!=="draft"&&e.jsxs(Z,{onClick:()=>K.mutate(T.id),children:[e.jsx(ls,{className:"mr-2 h-3.5 w-3.5"})," Close"]}),M&&T.status==="draft"&&e.jsxs(Z,{className:"text-red-600",onClick:()=>_(T),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}],r=(b==null?void 0:b.results)??[],D=I.isPending||S.isPending;return e.jsxs("div",{children:[e.jsx(He,{title:"Review Cycles",description:"Create and manage performance review cycles.",breadcrumbs:[{label:"Performance",href:"/performance"},{label:"Review Cycles"}]}),e.jsx(fe,{columns:x,data:r,isLoading:z,searchPlaceholder:"Search review cycles...",emptyMessage:"No review cycles found",emptyDescription:"Create a review cycle to get started.",totalCount:(b==null?void 0:b.count)??0,pagination:E,onPaginationChange:Y,sorting:H,onSortingChange:A,globalFilter:B,onGlobalFilterChange:k,actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(re,{value:v||"__all__",onValueChange:T=>$(T==="__all__"?"":T),children:[e.jsx(ne,{className:"h-8 w-[130px] text-[12px]",children:e.jsx(ie,{placeholder:"All Statuses"})}),e.jsxs(le,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"draft",children:"Draft"}),e.jsx(h,{value:"goal_setting",children:"Goal Setting"}),e.jsx(h,{value:"self_review",children:"Self Review"}),e.jsx(h,{value:"manager_review",children:"Manager Review"}),e.jsx(h,{value:"peer_review",children:"Peer Review"}),e.jsx(h,{value:"skip_review",children:"Skip Review"}),e.jsx(h,{value:"calibration",children:"Calibration"}),e.jsx(h,{value:"acknowledgment",children:"Acknowledgment"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"cancelled",children:"Cancelled"})]})]}),e.jsxs(re,{value:Q||"__all__",onValueChange:T=>G(T==="__all__"?"":T),children:[e.jsx(ne,{className:"h-8 w-[130px] text-[12px]",children:e.jsx(ie,{placeholder:"All Types"})}),e.jsxs(le,{children:[e.jsx(h,{value:"__all__",children:"All Types"}),e.jsx(h,{value:"annual",children:"Annual"}),e.jsx(h,{value:"semi_annual",children:"Semi-Annual"}),e.jsx(h,{value:"quarterly",children:"Quarterly"}),e.jsx(h,{value:"probation",children:"Probation"}),e.jsx(h,{value:"confirmation",children:"Confirmation"}),e.jsx(h,{value:"adhoc",children:"Ad-hoc"})]})]}),O&&e.jsxs(w,{size:"sm",onClick:o,children:[e.jsx(ye,{className:"h-3.5 w-3.5 mr-1.5"})," Add Cycle"]})]})}),d&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",children:e.jsxs("div",{className:"w-[400px] rounded-xl bg-white p-6 shadow-xl",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-slate-900",children:"Delete Review Cycle"}),e.jsxs("p",{className:"mt-2 text-[13px] text-slate-500",children:["Are you sure you want to delete ",e.jsx("span",{className:"font-medium text-slate-700",children:d.name}),"? This action cannot be undone."]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>_(null),children:"Cancel"}),e.jsx(w,{variant:"destructive",size:"sm",onClick:y,disabled:u.isPending,children:u.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"lg",className:"flex flex-col",children:[e.jsxs(Ne,{children:[e.jsxs(we,{className:"flex items-center gap-2",children:[e.jsx(gs,{className:"h-4.5 w-4.5 text-primary"}),a?"Edit Review Cycle":"New Review Cycle"]}),e.jsx(Se,{children:a?`Editing ${a.name}`:"Create a new performance review cycle."})]}),e.jsxs("form",{onSubmit:n.handleSubmit(C),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(V,{...n.register("name"),className:"mt-1.5",placeholder:"e.g. Annual Review 2026"}),n.formState.errors.name&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(V,{...n.register("code"),className:"mt-1.5",placeholder:"e.g. AR-2026"}),n.formState.errors.code&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.code.message})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Cycle Type *"}),e.jsxs(re,{value:n.watch("cycle_type"),onValueChange:T=>n.setValue("cycle_type",T),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"annual",children:"Annual"}),e.jsx(h,{value:"semi_annual",children:"Semi-Annual"}),e.jsx(h,{value:"quarterly",children:"Quarterly"}),e.jsx(h,{value:"probation",children:"Probation"}),e.jsx(h,{value:"confirmation",children:"Confirmation"}),e.jsx(h,{value:"adhoc",children:"Ad-hoc"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Period Start *"}),e.jsx(V,{type:"date",...n.register("period_start"),className:"mt-1.5",max:n.watch("period_end")||void 0}),n.formState.errors.period_start&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.period_start.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Period End *"}),e.jsx(V,{type:"date",...n.register("period_end"),className:"mt-1.5",min:n.watch("period_start")||void 0}),n.formState.errors.period_end&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.period_end.message})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Review Start *"}),e.jsx(V,{type:"date",...n.register("review_start_date"),className:"mt-1.5",max:n.watch("review_end_date")||void 0}),n.formState.errors.review_start_date&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.review_start_date.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Review End *"}),e.jsx(V,{type:"date",...n.register("review_end_date"),className:"mt-1.5",min:n.watch("review_start_date")||void 0}),n.formState.errors.review_end_date&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.review_end_date.message})]})]})]}),e.jsxs(ke,{children:[e.jsx(w,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:n.handleSubmit(C),disabled:D,children:D?"Saving...":a?"Save Changes":"Create Cycle"})]})]})})]})}function Aa(s){switch(s){case"completed":return"approved";case"not_started":return"pending";default:return"in_progress"}}const Ka={not_started:"Not Started",in_progress:"In Progress",completed:"Completed",disputed:"Disputed"};function Cn(){const[s,t]=P.useState(""),[a,m]=P.useState(""),{hasPermission:d}=de(),_=d("performance","review","update"),{pagination:v,setPagination:$,sorting:Q,setSorting:G,globalFilter:L,setGlobalFilter:i}=je(),{data:O,isLoading:U}=Ds({page:v.pageIndex+1,page_size:v.pageSize,search:L||void 0,...s&&{status:s},...a&&{review_cycle:a}}),{data:M}=We({page_size:100}),E=(M==null?void 0:M.results)??[],Y=Gt(),H=Ot(),A=Ut(),B=[{key:"employee_name",header:"Employee",render:b=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[13px] font-medium text-slate-800",children:b.employee_name}),b.employee_code&&e.jsx("div",{className:"text-[11px] text-slate-400",children:b.employee_code})]})},{key:"cycle_name",header:"Review Cycle",render:b=>e.jsx("span",{className:"text-[13px] text-slate-600",children:b.cycle_name})},{key:"manager_name",header:"Manager",render:b=>e.jsx("span",{className:"text-[12px] text-slate-500",children:b.manager_name??"-"})},{key:"overall_self_rating",header:"Self",render:b=>e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:b.overall_self_rating??"-"})},{key:"overall_manager_rating",header:"Manager",render:b=>e.jsx("span",{className:"text-[13px] font-medium text-slate-700",children:b.overall_manager_rating??"-"})},{key:"final_rating",header:"Final",render:b=>e.jsx("span",{className:"text-[13px] font-semibold text-primary",children:b.final_rating??"-"})},{key:"status",header:"Status",render:b=>e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Ps,{status:Aa(b.status)}),e.jsx("span",{className:"text-[10.5px] text-[#94a3b8]",children:Ka[b.status]})]})},{key:"actions",header:"",render:b=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[e.jsxs(Z,{children:[e.jsx(it,{className:"mr-2 h-3.5 w-3.5"})," View Details"]}),_&&b.status==="in_progress"&&e.jsxs(Z,{onClick:()=>Y.mutate(b.id),children:[e.jsx(qs,{className:"mr-2 h-3.5 w-3.5"})," Submit for Approval"]}),_&&b.status==="completed"&&e.jsxs(Z,{onClick:()=>H.mutate({id:b.id}),children:[e.jsx(Rs,{className:"mr-2 h-3.5 w-3.5"})," Approve"]}),_&&b.status==="completed"&&e.jsxs(Z,{onClick:()=>A.mutate({id:b.id}),children:[e.jsx(ls,{className:"mr-2 h-3.5 w-3.5"})," Reject"]})]})]})}],k=(O==null?void 0:O.results)??[];return e.jsxs("div",{children:[e.jsx(He,{title:"Employee Reviews",description:"Track and manage individual employee performance reviews.",breadcrumbs:[{label:"Performance",href:"/performance"},{label:"Employee Reviews"}]}),e.jsx(fe,{columns:B,data:k,isLoading:U,searchPlaceholder:"Search employees...",emptyMessage:"No employee reviews found",emptyDescription:"Reviews will appear once a review cycle is launched.",totalCount:(O==null?void 0:O.count)??0,pagination:v,onPaginationChange:$,sorting:Q,onSortingChange:G,globalFilter:L,onGlobalFilterChange:i,actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(re,{value:a||"__all__",onValueChange:b=>m(b==="__all__"?"":b),children:[e.jsx(ne,{className:"h-8 w-[180px] text-[12px]",children:e.jsx(ie,{placeholder:"All Cycles"})}),e.jsxs(le,{children:[e.jsx(h,{value:"__all__",children:"All Cycles"}),E.map(b=>e.jsx(h,{value:b.id,children:b.name},b.id))]})]}),e.jsxs(re,{value:s||"__all__",onValueChange:b=>t(b==="__all__"?"":b),children:[e.jsx(ne,{className:"h-8 w-[150px] text-[12px]",children:e.jsx(ie,{placeholder:"All Statuses"})}),e.jsxs(le,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"not_started",children:"Not Started"}),e.jsx(h,{value:"in_progress",children:"In Progress"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"disputed",children:"Disputed"})]})]})]})})]})}const Ea=[{value:"self",label:"Self"},{value:"manager",label:"Manager"},{value:"skip_manager",label:"Skip Manager"}],Da=ge({employee_review:q().min(1,"Employee review is required"),form_type:Ce(["self","manager","skip_manager"]),achievements:q().optional(),challenges:q().optional(),overall_comments:q().optional()}),$a={draft:"secondary",submitted:"default",acknowledged:"success"};function Pn(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),{hasPermission:v,requirePermission:$}=de(),Q=v("performance","appraisal","create"),G=v("performance","appraisal","update"),{pagination:L,setPagination:i,sorting:O,setSorting:U,globalFilter:M,setGlobalFilter:E,queryParams:Y}=je(),{data:H,isLoading:A}=ea(Y),B=(H==null?void 0:H.results)??[],[k,b]=P.useState(""),{data:z,isLoading:I}=Ds({page_size:100,search:k||void 0}),S=(z==null?void 0:z.results)??[],u=sa(),g=ta(),K=xe({resolver:he(Da),defaultValues:{employee_review:"",form_type:"self",achievements:"",challenges:"",overall_comments:""}});function X(){$("performance","appraisal","create")&&(K.reset({employee_review:"",form_type:"self",achievements:"",challenges:"",overall_comments:""}),t(!0))}function n(C){const y={employee_review:C.employee_review,form_type:C.form_type,achievements:C.achievements||void 0,challenges:C.challenges||void 0,overall_comments:C.overall_comments||void 0};u.mutate(y,{onSuccess:()=>t(!1)})}function o(){d&&g.mutate(d.id,{onSuccess:()=>_(null)})}const W=[{key:"employee_name",header:"Employee",render:C=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:C.employee_name??"-"})},{key:"cycle_name",header:"Review Cycle",render:C=>e.jsx("span",{className:"text-[13px] text-slate-600",children:C.cycle_name??"-"})},{key:"form_type",header:"Form Type",render:C=>e.jsx(ce,{variant:"secondary",className:"text-[11px] capitalize",children:(C.form_type_display??C.form_type??"").replace(/_/g," ")})},{key:"achievements",header:"Achievements",render:C=>e.jsx("span",{className:"text-[13px] text-slate-600 truncate max-w-[220px] inline-block",children:C.achievements||"-"})},{key:"submitted_at",header:"Submitted",render:C=>e.jsx("span",{className:"text-[12px] text-slate-500",children:C.submitted_at?new Date(C.submitted_at).toLocaleDateString():"-"})},{key:"status",header:"Status",render:C=>e.jsx(ce,{variant:$a[C.status]??"secondary",className:"text-[11px] capitalize",children:(C.status??"draft").replace(/_/g," ")})},{key:"actions",header:"",className:"w-10",render:C=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[G&&(C.status==="draft"||!C.status)&&e.jsxs(e.Fragment,{children:[e.jsxs(Z,{onClick:()=>_(C),children:[e.jsx(qs,{className:"mr-2 h-3.5 w-3.5"})," Submit"]}),e.jsx(Ue,{})]}),G&&e.jsxs(Z,{className:"text-red-600",onClick:()=>m(C),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}];return 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(Ss,{className:"h-5 w-5 text-primary"})," Appraisal Forms"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Create and manage appraisal form templates"})]}),Q&&e.jsxs(w,{size:"sm",onClick:X,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Appraisal Form"]})]}),e.jsx(fe,{columns:W,data:B,isLoading:A,searchPlaceholder:"Search appraisal forms...",emptyMessage:"No appraisal forms",emptyDescription:"Create your first appraisal form to start managing performance reviews.",totalCount:(H==null?void 0:H.count)??0,pagination:L,onPaginationChange:i,sorting:O,onSortingChange:U,globalFilter:M,onGlobalFilterChange:E}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:"Add Appraisal Form"}),e.jsx(Se,{children:"Create a new appraisal form for performance evaluation."})]}),e.jsxs("form",{onSubmit:K.handleSubmit(n),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Employee Review *"}),e.jsx(ae,{name:"employee_review",control:K.control,render:({field:C})=>e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:C.value,onValueChange:C.onChange,onSearch:b,isLoading:I,options:S.map(y=>({value:y.id,label:`${y.employee_name} — ${y.cycle_name}`,hint:y.employee_code})),placeholder:"Select employee review",searchPlaceholder:"Search employee reviews..."})})}),K.formState.errors.employee_review&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:K.formState.errors.employee_review.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Form Type *"}),e.jsx(ae,{name:"form_type",control:K.control,render:({field:C})=>e.jsxs(re,{value:C.value,onValueChange:C.onChange,children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{placeholder:"Select form type"})}),e.jsx(le,{children:Ea.map(y=>e.jsx(h,{value:y.value,children:y.label},y.value))})]})}),K.formState.errors.form_type&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:K.formState.errors.form_type.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Achievements"}),e.jsx(Ke,{...K.register("achievements"),className:"mt-1.5",placeholder:"Key achievements this period...",rows:3})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Challenges"}),e.jsx(Ke,{...K.register("challenges"),className:"mt-1.5",placeholder:"Challenges faced...",rows:3})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Overall Comments"}),e.jsx(Ke,{...K.register("overall_comments"),className:"mt-1.5",placeholder:"Overall comments...",rows:3})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:K.handleSubmit(n),disabled:u.isPending,children:"Create"})]})]})}),e.jsx(Ee,{open:!!d,onOpenChange:C=>!C&&_(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Submit appraisal?"}),e.jsx(Ie,{children:"This will submit the appraisal form for review. This action cannot be undone."})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{onClick:o,children:"Submit"})]})]})}),e.jsx(Ee,{open:!!a,onOpenChange:C=>!C&&m(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Delete appraisal form?"}),e.jsx(Ie,{children:"This will permanently delete this appraisal form and all associated data."})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{variant:"destructive",onClick:()=>m(null),children:"Delete"})]})]})})]})}const Va=ss(ge({title:q().min(1,"Title is required"),description:q().optional().default(""),employee:q().min(1,"Employee is required"),review_cycle:q().optional().default(""),parent_goal:q().optional().default(""),goal_type:Ce(["company","department","team","individual"]),category:Ce(["strategic","operational","development","project"]),priority:Ce(["critical","high","medium","low"]),start_date:us().default(""),end_date:us().default(""),target_metric:q().optional().default(""),target_value:q().optional().default("")}),"start_date","end_date"),Ia={draft:"secondary",pending_approval:"warning",active:"default",completed:"success",deferred:"warning",cancelled:"destructive"},Qa={strategic:"success",operational:"default",development:"warning",project:"secondary"},La={company:"success",department:"warning",team:"secondary",individual:"default"},Ta={low:"secondary",medium:"default",high:"warning",critical:"destructive"};function qn(){var vs,bs;const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),[v,$]=P.useState(""),[Q,G]=P.useState(""),{hasPermission:L,requirePermission:i}=de(),O=L("performance","goal","create"),U=L("performance","goal","update"),M=L("performance","goal","delete"),{pagination:E,setPagination:Y,sorting:H,setSorting:A,globalFilter:B,setGlobalFilter:k}=je(),{data:b,isLoading:z}=ws({page:E.pageIndex+1,page_size:E.pageSize,search:B||void 0,...v&&{status:v},...Q&&{goal_type:Q}}),[I,S]=P.useState(""),{data:u,isLoading:g}=We({page_size:100,search:I||void 0}),K=(u==null?void 0:u.results)??[],[X,n]=P.useState(""),{data:o,isLoading:W}=ws({page_size:200,search:X||void 0}),C=(o==null?void 0:o.results)??[],{data:y}=rs({page_size:1}),x=((bs=(vs=y==null?void 0:y.results)==null?void 0:vs[0])==null?void 0:bs.id)??"",r=Bt(),D=Ht(),T=Wt(),Qs=Yt(),te=xe({resolver:he(Va),defaultValues:{goal_type:"individual",category:"operational",priority:"medium",description:"",review_cycle:"",parent_goal:"",target_metric:"",target_value:""}});function Ls(){i("performance","goal","create")&&(m(null),te.reset({title:"",description:"",employee:"",review_cycle:"",parent_goal:"",goal_type:"individual",category:"operational",priority:"medium",start_date:"",end_date:"",target_metric:"",target_value:""}),t(!0))}function Ts(N){i("performance","goal","update")&&(m(N),te.reset({title:N.title,description:N.description||"",employee:N.employee,review_cycle:N.review_cycle??"",parent_goal:N.parent_goal??"",goal_type:N.goal_type,category:N.category,priority:N.priority,start_date:N.start_date??"",end_date:N.end_date??"",target_metric:N.target_metric||"",target_value:N.target_value??""}),t(!0))}function _s(N){const Ns={title:N.title,description:N.description,employee:N.employee,company:(a==null?void 0:a.company)??x,review_cycle:N.review_cycle||null,parent_goal:N.parent_goal||null,goal_type:N.goal_type,category:N.category,priority:N.priority,start_date:N.start_date||null,end_date:N.end_date||null,target_metric:N.target_metric||void 0,target_value:N.target_value||null};a?D.mutate({id:a.id,...Ns},{onSuccess:()=>t(!1)}):r.mutate(Ns,{onSuccess:()=>t(!1)})}function zs(){d&&T.mutate(d.id,{onSuccess:()=>_(null)})}const Ms=[{key:"title",header:"Goal",render:N=>e.jsxs("div",{className:"max-w-[280px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[N.parent_goal&&e.jsx(es,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-[13px] font-medium text-slate-800 truncate",children:N.title})]}),N.parent_goal_title&&e.jsxs("span",{className:"text-[11px] text-slate-400 truncate block",children:["Parent: ",N.parent_goal_title]})]})},{key:"employee_name",header:"Employee",render:N=>e.jsx("span",{className:"text-[12px] text-slate-600",children:N.employee_name})},{key:"goal_type",header:"Type",render:N=>e.jsx(ce,{variant:La[N.goal_type],className:"text-[11px] capitalize",children:N.goal_type})},{key:"category",header:"Category",render:N=>e.jsx(ce,{variant:Qa[N.category],className:"text-[11px] capitalize",children:N.category})},{key:"priority",header:"Priority",render:N=>e.jsx(ce,{variant:Ta[N.priority],className:"text-[11px] capitalize",children:N.priority})},{key:"progress_percentage",header:"Progress",render:N=>e.jsxs("div",{className:"flex items-center gap-2 min-w-[120px]",children:[e.jsx(hs,{value:N.progress_percentage,className:"flex-1"}),e.jsxs("span",{className:"text-[11px] text-slate-500 w-8 text-right",children:[N.progress_percentage,"%"]})]})},{key:"end_date",header:"Due Date",render:N=>e.jsx("span",{className:"text-[12px] text-slate-500",children:N.end_date??"-"})},{key:"status",header:"Status",render:N=>e.jsx(ce,{variant:Ia[N.status],className:"text-[11px] capitalize",children:N.status})},{key:"actions",header:"",render:N=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[U&&e.jsxs(Z,{onClick:()=>Ts(N),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),U&&N.goal_type!=="individual"&&e.jsxs(Z,{onClick:()=>Qs.mutate({id:N.id,employee_ids:[]}),children:[e.jsx(es,{className:"mr-2 h-3.5 w-3.5"})," Cascade"]}),M&&e.jsxs(Z,{className:"text-red-600",onClick:()=>_(N),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}],Gs=(b==null?void 0:b.results)??[],ys=r.isPending||D.isPending;return e.jsxs("div",{children:[e.jsx(He,{title:"Goals",description:"Set, track, and cascade performance goals across the organization.",breadcrumbs:[{label:"Performance",href:"/performance"},{label:"Goals"}]}),e.jsx(fe,{columns:Ms,data:Gs,isLoading:z,searchPlaceholder:"Search goals...",emptyMessage:"No goals found",emptyDescription:"Create a goal to get started.",totalCount:(b==null?void 0:b.count)??0,pagination:E,onPaginationChange:Y,sorting:H,onSortingChange:A,globalFilter:B,onGlobalFilterChange:k,actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(re,{value:Q||"__all__",onValueChange:N=>G(N==="__all__"?"":N),children:[e.jsx(ne,{className:"h-8 w-[140px] text-[12px]",children:e.jsx(ie,{placeholder:"All Types"})}),e.jsxs(le,{children:[e.jsx(h,{value:"__all__",children:"All Types"}),e.jsx(h,{value:"company",children:"Company"}),e.jsx(h,{value:"department",children:"Department"}),e.jsx(h,{value:"team",children:"Team"}),e.jsx(h,{value:"individual",children:"Individual"})]})]}),e.jsxs(re,{value:v||"__all__",onValueChange:N=>$(N==="__all__"?"":N),children:[e.jsx(ne,{className:"h-8 w-[130px] text-[12px]",children:e.jsx(ie,{placeholder:"All Statuses"})}),e.jsxs(le,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"draft",children:"Draft"}),e.jsx(h,{value:"pending_approval",children:"Pending Approval"}),e.jsx(h,{value:"active",children:"Active"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"deferred",children:"Deferred"}),e.jsx(h,{value:"cancelled",children:"Cancelled"})]})]}),O&&e.jsxs(w,{size:"sm",onClick:Ls,children:[e.jsx(ye,{className:"h-3.5 w-3.5 mr-1.5"})," Add Goal"]})]})}),d&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",children:e.jsxs("div",{className:"w-[400px] rounded-xl bg-white p-6 shadow-xl",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-slate-900",children:"Delete Goal"}),e.jsxs("p",{className:"mt-2 text-[13px] text-slate-500",children:["Are you sure you want to delete ",e.jsx("span",{className:"font-medium text-slate-700",children:d.title}),"?",(d.child_goals_count??0)>0&&e.jsxs("span",{className:"block mt-1 text-amber-600",children:["This goal has ",d.child_goals_count," cascaded child goal(s)."]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>_(null),children:"Cancel"}),e.jsx(w,{variant:"destructive",size:"sm",onClick:zs,disabled:T.isPending,children:T.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"lg",className:"flex flex-col",children:[e.jsxs(Ne,{children:[e.jsxs(we,{className:"flex items-center gap-2",children:[e.jsx(as,{className:"h-4.5 w-4.5 text-primary"}),a?"Edit Goal":"New Goal"]}),e.jsx(Se,{children:a?`Editing "${a.title}"`:"Define a new performance goal."})]}),e.jsxs("form",{onSubmit:te.handleSubmit(_s),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Title *"}),e.jsx(V,{...te.register("title"),className:"mt-1.5",placeholder:"e.g. Increase quarterly revenue by 15%"}),te.formState.errors.title&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:te.formState.errors.title.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx("textarea",{...te.register("description"),className:"mt-1.5 flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",placeholder:"Goal description..."})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Employee *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Oe,{value:te.watch("employee"),onValueChange:N=>te.setValue("employee",N,{shouldValidate:!0})})}),te.formState.errors.employee&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:te.formState.errors.employee.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Review Cycle"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:te.watch("review_cycle")||null,onValueChange:N=>te.setValue("review_cycle",N),onSearch:S,isLoading:g,selectedLabel:a==null?void 0:a.cycle_name,options:K.map(N=>({value:N.id,label:N.name,hint:N.code})),placeholder:"Select cycle",searchPlaceholder:"Search cycles..."})})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Parent Goal"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:te.watch("parent_goal")||null,onValueChange:N=>te.setValue("parent_goal",N),onSearch:n,isLoading:W,selectedLabel:a==null?void 0:a.parent_goal_title,options:C.filter(N=>!a||N.id!==a.id).map(N=>({value:N.id,label:N.title})),placeholder:"Select parent goal",searchPlaceholder:"Search goals..."})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Goal Type *"}),e.jsxs(re,{value:te.watch("goal_type"),onValueChange:N=>te.setValue("goal_type",N),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"company",children:"Company"}),e.jsx(h,{value:"department",children:"Department"}),e.jsx(h,{value:"team",children:"Team"}),e.jsx(h,{value:"individual",children:"Individual"})]})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Category *"}),e.jsxs(re,{value:te.watch("category"),onValueChange:N=>te.setValue("category",N),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"strategic",children:"Strategic"}),e.jsx(h,{value:"operational",children:"Operational"}),e.jsx(h,{value:"development",children:"Development"}),e.jsx(h,{value:"project",children:"Project"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Priority"}),e.jsxs(re,{value:te.watch("priority"),onValueChange:N=>te.setValue("priority",N),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"critical",children:"Critical"}),e.jsx(h,{value:"high",children:"High"}),e.jsx(h,{value:"medium",children:"Medium"}),e.jsx(h,{value:"low",children:"Low"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Start Date"}),e.jsx(V,{type:"date",...te.register("start_date"),className:"mt-1.5",max:te.watch("end_date")||void 0})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"End Date"}),e.jsx(V,{type:"date",...te.register("end_date"),className:"mt-1.5",min:te.watch("start_date")||void 0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Target Metric"}),e.jsx(V,{...te.register("target_metric"),className:"mt-1.5",placeholder:"e.g. Revenue, NPS"})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Target Value"}),e.jsx(V,{...te.register("target_value"),className:"mt-1.5",placeholder:"e.g. 100000"})]})]})]}),e.jsxs(ke,{children:[e.jsx(w,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:te.handleSubmit(_s),disabled:ys,children:ys?"Saving...":a?"Save Changes":"Create Goal"})]})]})})]})}const za=ge({goal:q().min(1,"Goal is required"),progress_percentage:Pe.number().min(0,"Must be >= 0").max(100,"Must be <= 100"),notes:q()});function Rn(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),{hasPermission:d,requirePermission:_}=de(),v=d("performance","goal","create"),$=d("performance","goal","delete"),{pagination:Q,setPagination:G,sorting:L,setSorting:i,globalFilter:O,setGlobalFilter:U,queryParams:M}=je(),{data:E,isLoading:Y}=Zt(M),H=(E==null?void 0:E.results)??[],A=Jt(),B=Xt(),k=xe({resolver:he(za),defaultValues:{goal:"",progress_percentage:0,notes:""}});function b(){_("performance","goal","create")&&(k.reset({goal:"",progress_percentage:0,notes:""}),t(!0))}function z(u){const g={goal:u.goal,progress_percentage:u.progress_percentage,notes:u.notes||void 0};A.mutate(g,{onSuccess:()=>t(!1)})}function I(){a&&B.mutate(a.id,{onSuccess:()=>m(null)})}const S=[{key:"goal_title",header:"Goal Title",render:u=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:u.goal_title})},{key:"progress_percentage",header:"Progress",render:u=>e.jsxs("span",{className:"text-[13px] text-slate-600",children:[u.progress_percentage,"%"]})},{key:"update_date",header:"Update Date",render:u=>e.jsx("span",{className:"text-[13px] text-slate-600",children:u.update_date?new Date(u.update_date).toLocaleDateString():"-"})},{key:"notes",header:"Notes",render:u=>e.jsx("span",{className:"text-[13px] text-slate-600 truncate max-w-[200px] inline-block",children:u.notes||"-"})},{key:"updated_by_name",header:"Updated By",render:u=>e.jsx("span",{className:"text-[13px] text-slate-600",children:u.updated_by_name})},{key:"created_at",header:"Created",render:u=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(u.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:u=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsx(ue,{align:"end",children:$&&e.jsxs(Z,{className:"text-red-600",onClick:()=>m(u),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})})]})}];return 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(ks,{className:"h-5 w-5 text-primary"})," Goal Progress"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Track and log goal progress updates"})]}),v&&e.jsxs(w,{size:"sm",onClick:b,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Log Progress"]})]}),e.jsx(fe,{columns:S,data:H,isLoading:Y,searchPlaceholder:"Search goal progress...",emptyMessage:"No progress entries",emptyDescription:"Log your first goal progress update to start tracking.",totalCount:(E==null?void 0:E.count)??0,pagination:Q,onPaginationChange:G,sorting:L,onSortingChange:i,globalFilter:O,onGlobalFilterChange:U}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:"Log Goal Progress"}),e.jsx(Se,{children:"Record a progress update for a goal."})]}),e.jsxs("form",{onSubmit:k.handleSubmit(z),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Goal *"}),e.jsx(V,{...k.register("goal"),className:"mt-1.5",placeholder:"Goal ID"}),k.formState.errors.goal&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:k.formState.errors.goal.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Progress (%) *"}),e.jsx(V,{type:"number",...k.register("progress_percentage",{valueAsNumber:!0}),className:"mt-1.5",placeholder:"0",min:0,max:100}),k.formState.errors.progress_percentage&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:k.formState.errors.progress_percentage.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Notes"}),e.jsx(Ke,{...k.register("notes"),className:"mt-1.5",placeholder:"Describe what was accomplished...",rows:3})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:k.handleSubmit(z),disabled:A.isPending,children:"Log Progress"})]})]})}),e.jsx(Ee,{open:!!a,onOpenChange:u=>!u&&m(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Delete progress entry?"}),e.jsxs(Ie,{children:["This will permanently delete the progress entry for ",e.jsx("strong",{children:a==null?void 0:a.goal_title}),"."]})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{variant:"destructive",onClick:I,children:"Delete"})]})]})})]})}const Ma=ge({name:q().min(1,"Name is required"),category:Ce(["financial","customer","process","learning_growth","operational","strategic"]),description:q().optional().default(""),default_weightage:Pe.number().min(0).max(100).default(0),is_active:ee().default(!0)}),Ga={financial:"Financial",customer:"Customer",process:"Process",learning_growth:"Learning & Growth",operational:"Operational",strategic:"Strategic"};function Fn(){var x,r;const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),[v,$]=P.useState(""),{hasPermission:Q,requirePermission:G}=de(),L=Q("performance","kra","create"),i=Q("performance","kra","update"),O=Q("performance","kra","delete"),{pagination:U,setPagination:M,sorting:E,setSorting:Y,globalFilter:H,setGlobalFilter:A}=je(),{data:B,isLoading:k}=Es({page:U.pageIndex+1,page_size:U.pageSize,search:H||void 0,...v&&{category:v}}),{data:b}=rs({page_size:1}),z=((r=(x=b==null?void 0:b.results)==null?void 0:x[0])==null?void 0:r.id)??"",I=Ct(),S=Pt(),u=qt(),g=xe({resolver:he(Ma),defaultValues:{category:"financial",is_active:!0,description:"",default_weightage:0}});function K(){G("performance","kra","create")&&(m(null),g.reset({name:"",category:"financial",description:"",default_weightage:0,is_active:!0}),t(!0))}function X(D){G("performance","kra","update")&&(m(D),g.reset({name:D.name,category:D.category,description:D.description||"",default_weightage:D.default_weightage,is_active:D.is_active}),t(!0))}function n(D){const T={...D,code:D.name.toLowerCase().replace(/\s+/g,"_").slice(0,20),company:(a==null?void 0:a.company)??z};a?S.mutate({id:a.id,...T},{onSuccess:()=>t(!1)}):I.mutate(T,{onSuccess:()=>t(!1)})}function o(){d&&u.mutate(d.id,{onSuccess:()=>_(null)})}const W=[{key:"name",header:"Name",render:D=>e.jsx("span",{className:"text-[13px] font-medium text-slate-800",children:D.name})},{key:"category",header:"Category",render:D=>e.jsx(ce,{variant:"secondary",className:"text-[11px] capitalize",children:Ga[D.category]})},{key:"default_weightage",header:"Weightage",render:D=>e.jsxs("span",{className:"text-[12px] text-slate-600",children:[D.default_weightage,"%"]})},{key:"kpi_count",header:"KPIs",render:D=>e.jsx("span",{className:"text-[12px] text-slate-500",children:D.kpi_count??0})},{key:"is_active",header:"Status",render:D=>e.jsx(Ye,{status:D.is_active?"active":"inactive"})},{key:"actions",header:"",render:D=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[i&&e.jsxs(Z,{onClick:()=>X(D),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),O&&e.jsxs(Z,{className:"text-red-600",onClick:()=>_(D),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}],C=(B==null?void 0:B.results)??[],y=I.isPending||S.isPending;return e.jsxs("div",{children:[e.jsx(He,{title:"KRA Library",description:"Define and manage Key Result Areas for performance evaluation.",breadcrumbs:[{label:"Performance",href:"/performance"},{label:"KRA Library"}]}),e.jsx(fe,{columns:W,data:C,isLoading:k,searchPlaceholder:"Search KRAs...",emptyMessage:"No KRAs found",emptyDescription:"Create a KRA to get started.",totalCount:(B==null?void 0:B.count)??0,pagination:U,onPaginationChange:M,sorting:E,onSortingChange:Y,globalFilter:H,onGlobalFilterChange:A,actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(re,{value:v||"__all__",onValueChange:D=>$(D==="__all__"?"":D),children:[e.jsx(ne,{className:"h-8 w-[140px] text-[12px]",children:e.jsx(ie,{placeholder:"All Categories"})}),e.jsxs(le,{children:[e.jsx(h,{value:"__all__",children:"All Categories"}),e.jsx(h,{value:"financial",children:"Financial"}),e.jsx(h,{value:"customer",children:"Customer"}),e.jsx(h,{value:"process",children:"Process"}),e.jsx(h,{value:"learning_growth",children:"Learning & Growth"}),e.jsx(h,{value:"operational",children:"Operational"}),e.jsx(h,{value:"strategic",children:"Strategic"})]})]}),L&&e.jsxs(w,{size:"sm",onClick:K,children:[e.jsx(ye,{className:"h-3.5 w-3.5 mr-1.5"})," Add KRA"]})]})}),d&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",children:e.jsxs("div",{className:"w-[400px] rounded-xl bg-white p-6 shadow-xl",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-slate-900",children:"Delete KRA"}),e.jsxs("p",{className:"mt-2 text-[13px] text-slate-500",children:["Are you sure you want to delete ",e.jsx("span",{className:"font-medium text-slate-700",children:d.name}),"? This action cannot be undone."]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx(w,{variant:"outline",size:"sm",onClick:()=>_(null),children:"Cancel"}),e.jsx(w,{variant:"destructive",size:"sm",onClick:o,disabled:u.isPending,children:u.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",className:"flex flex-col",children:[e.jsxs(Ne,{children:[e.jsxs(we,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4.5 w-4.5 text-primary"}),a?"Edit KRA":"New KRA"]}),e.jsx(Se,{children:a?`Editing ${a.name}`:"Create a new Key Result Area."})]}),e.jsxs("form",{onSubmit:g.handleSubmit(n),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(V,{...g.register("name"),className:"mt-1.5",placeholder:"e.g. Revenue Growth"}),g.formState.errors.name&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:g.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Category *"}),e.jsxs(re,{value:g.watch("category"),onValueChange:D=>g.setValue("category",D),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"financial",children:"Financial"}),e.jsx(h,{value:"customer",children:"Customer"}),e.jsx(h,{value:"process",children:"Process"}),e.jsx(h,{value:"learning_growth",children:"Learning & Growth"}),e.jsx(h,{value:"operational",children:"Operational"}),e.jsx(h,{value:"strategic",children:"Strategic"})]})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx("textarea",{...g.register("description"),className:"mt-1.5 flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",placeholder:"Optional description..."})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Default Weightage (%)"}),e.jsx(V,{type:"number",...g.register("default_weightage"),className:"mt-1.5",min:0,max:100})]}),e.jsx("div",{className:"flex items-center gap-6 pt-1",children:e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Ae,{checked:g.watch("is_active"),onCheckedChange:D=>g.setValue("is_active",!!D)}),e.jsx("span",{className:"text-[13px] text-slate-700",children:"Active"})]})})]}),e.jsxs(ke,{children:[e.jsx(w,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:g.handleSubmit(n),disabled:y,children:y?"Saving...":a?"Save Changes":"Create KRA"})]})]})})]})}const Oa=[{value:"percentage",label:"Percentage"},{value:"number",label:"Number"},{value:"currency",label:"Currency"},{value:"rating",label:"Rating"},{value:"boolean",label:"Boolean"},{value:"days",label:"Days"},{value:"hours",label:"Hours"}],Ua=ge({name:q().min(1,"Name is required"),code:q().min(1,"Code is required"),description:q().optional(),kra:q().min(1,"KRA is required"),unit_of_measurement:Ce(["percentage","number","currency","rating","boolean","days","hours"]),direction:Ce(["higher_is_better","lower_is_better","target_is_best"]),benchmark_value:q().optional(),is_active:ee()});function An(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),{hasPermission:v,requirePermission:$}=de(),Q=v("performance","kpi","create"),G=v("performance","kpi","update"),L=v("performance","kpi","delete"),{pagination:i,setPagination:O,sorting:U,setSorting:M,globalFilter:E,setGlobalFilter:Y,queryParams:H}=je(),{data:A,isLoading:B}=Rt(H),k=(A==null?void 0:A.results)??[],[b,z]=P.useState(""),{data:I,isLoading:S}=Es({page_size:200,search:b||void 0}),u=(I==null?void 0:I.results)??[],g=Ft(),K=At(),X=Kt(),n=xe({resolver:he(Ua),defaultValues:{name:"",code:"",description:"",kra:"",unit_of_measurement:"number",direction:"higher_is_better",benchmark_value:"",is_active:!0}});function o(){$("performance","kpi","create")&&(m(null),n.reset({name:"",code:"",description:"",kra:"",unit_of_measurement:"number",direction:"higher_is_better",benchmark_value:"",is_active:!0}),t(!0))}function W(r){$("performance","kpi","update")&&(m(r),n.reset({name:r.name,code:r.code,description:r.description,kra:r.kra,unit_of_measurement:r.unit_of_measurement,direction:r.direction,benchmark_value:r.benchmark_value??"",is_active:r.is_active}),t(!0))}function C(r){const D={name:r.name,code:r.code,description:r.description,kra:r.kra,unit_of_measurement:r.unit_of_measurement,direction:r.direction,benchmark_value:r.benchmark_value||null,is_active:r.is_active};a?K.mutate({id:a.id,...D},{onSuccess:()=>t(!1)}):g.mutate(D,{onSuccess:()=>t(!1)})}function y(){d&&X.mutate(d.id,{onSuccess:()=>_(null)})}const x=[{key:"name",header:"Name",render:r=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:r.name})},{key:"code",header:"Code",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.code})},{key:"kra_name",header:"KRA",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.kra_name??"-"})},{key:"unit_of_measurement",header:"Unit",render:r=>e.jsx(ce,{variant:"secondary",className:"text-[11px] capitalize",children:r.unit_of_measurement})},{key:"benchmark_value",header:"Benchmark",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.benchmark_value??"-"})},{key:"is_active",header:"Status",render:r=>e.jsx(Ye,{status:r.is_active?"active":"inactive"})},{key:"actions",header:"",className:"w-10",render:r=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[G&&e.jsxs(Z,{onClick:()=>W(r),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),G&&L&&e.jsx(Ue,{}),L&&e.jsxs(Z,{className:"text-red-600",onClick:()=>_(r),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}];return 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(Fs,{className:"h-5 w-5 text-primary"})," KPI Library"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Define and manage key performance indicators"})]}),Q&&e.jsxs(w,{size:"sm",onClick:o,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add KPI"]})]}),e.jsx(fe,{columns:x,data:k,isLoading:B,searchPlaceholder:"Search KPIs...",emptyMessage:"No KPIs defined",emptyDescription:"Add your first KPI to start measuring performance.",totalCount:(A==null?void 0:A.count)??0,pagination:i,onPaginationChange:O,sorting:U,onSortingChange:M,globalFilter:E,onGlobalFilterChange:Y}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit KPI":"Add KPI"}),e.jsx(Se,{children:a?"Update KPI details.":"Create a new key performance indicator."})]}),e.jsxs("form",{onSubmit:n.handleSubmit(C),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(V,{...n.register("name"),className:"mt-1.5",placeholder:"e.g. Revenue Growth Rate"}),n.formState.errors.name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(V,{...n.register("code"),className:"mt-1.5",placeholder:"e.g. KPI-REV-001"}),n.formState.errors.code&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(Ke,{...n.register("description"),className:"mt-1.5",placeholder:"Describe the KPI...",rows:3})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"KRA *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:n.watch("kra"),onValueChange:r=>n.setValue("kra",r,{shouldValidate:!0}),onSearch:z,isLoading:S,selectedLabel:(a==null?void 0:a.kra_name)??void 0,options:u.map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select KRA",searchPlaceholder:"Search KRAs..."})}),n.formState.errors.kra&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.kra.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Unit of Measurement *"}),e.jsxs(re,{value:n.watch("unit_of_measurement"),onValueChange:r=>n.setValue("unit_of_measurement",r),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{placeholder:"Select unit"})}),e.jsx(le,{children:Oa.map(r=>e.jsx(h,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Direction *"}),e.jsxs(re,{value:n.watch("direction"),onValueChange:r=>n.setValue("direction",r),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{placeholder:"Select direction"})}),e.jsxs(le,{children:[e.jsx(h,{value:"higher_is_better",children:"Higher is better"}),e.jsx(h,{value:"lower_is_better",children:"Lower is better"}),e.jsx(h,{value:"target_is_best",children:"Target is best"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Benchmark Value"}),e.jsx(V,{...n.register("benchmark_value"),className:"mt-1.5",placeholder:"e.g. 100"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(Ae,{id:"is_active",checked:n.watch("is_active"),onCheckedChange:r=>n.setValue("is_active",!!r)}),e.jsx(p,{htmlFor:"is_active",className:"text-[12px] font-medium text-slate-500 cursor-pointer",children:"Active"})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:n.handleSubmit(C),disabled:g.isPending||K.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(Ee,{open:!!d,onOpenChange:r=>!r&&_(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Delete KPI?"}),e.jsxs(Ie,{children:["This will permanently delete ",e.jsx("strong",{children:d==null?void 0:d.name})," and all associated data."]})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{variant:"destructive",onClick:y,children:"Delete"})]})]})})]})}const Ba={draft:"secondary",active:"success",archived:"default"},Ha=ge({employee:q().min(1,"Employee is required"),kra:q().min(1,"KRA is required"),review_cycle:q().min(1,"Review cycle is required"),weightage:Pe.number().min(0,"Must be >= 0").max(100,"Must be <= 100"),status:Ce(["draft","active","archived"])});function Kn(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),{hasPermission:v,requirePermission:$}=de(),Q=v("performance","kra_assignment","create"),G=v("performance","kra_assignment","update"),L=v("performance","kra_assignment","delete"),{pagination:i,setPagination:O,sorting:U,setSorting:M,globalFilter:E,setGlobalFilter:Y,queryParams:H}=je(),{data:A,isLoading:B}=Et(H),k=(A==null?void 0:A.results)??[],b=Dt(),z=$t(),I=Vt(),S=xe({resolver:he(Ha),defaultValues:{employee:"",kra:"",review_cycle:"",weightage:0,status:"draft"}});function u(){$("performance","kra_assignment","create")&&(m(null),S.reset({employee:"",kra:"",review_cycle:"",weightage:0,status:"draft"}),t(!0))}function g(o){$("performance","kra_assignment","update")&&(m(o),S.reset({employee:o.employee,kra:o.kra,review_cycle:o.review_cycle,weightage:o.weightage,status:o.status}),t(!0))}function K(o){const W={employee:o.employee,kra:o.kra,review_cycle:o.review_cycle,weightage:o.weightage,status:o.status};a?z.mutate({id:a.id,...W},{onSuccess:()=>t(!1)}):b.mutate(W,{onSuccess:()=>t(!1)})}function X(){d&&I.mutate(d.id,{onSuccess:()=>_(null)})}const n=[{key:"employee_name",header:"Employee Name",render:o=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:o.employee_name})},{key:"kra_name",header:"KRA Name",render:o=>e.jsx("span",{className:"text-[13px] text-slate-600",children:o.kra_name})},{key:"cycle_name",header:"Review Cycle",render:o=>e.jsx("span",{className:"text-[13px] text-slate-600",children:o.cycle_name??"-"})},{key:"weightage",header:"Weightage",render:o=>e.jsxs("span",{className:"text-[13px] text-slate-600",children:[o.weightage,"%"]})},{key:"status",header:"Status",render:o=>e.jsx(ce,{variant:Ba[o.status]??"secondary",className:"text-[11px] capitalize",children:o.status})},{key:"created_at",header:"Created",render:o=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(o.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:o=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[G&&e.jsxs(Z,{onClick:()=>g(o),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),G&&L&&e.jsx(Ue,{}),L&&e.jsxs(Z,{className:"text-red-600",onClick:()=>_(o),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}];return 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(As,{className:"h-5 w-5 text-primary"})," KRA Assignments"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Assign KRAs to employees and track weightage"})]}),Q&&e.jsxs(w,{size:"sm",onClick:u,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Assignment"]})]}),e.jsx(fe,{columns:n,data:k,isLoading:B,searchPlaceholder:"Search KRA assignments...",emptyMessage:"No KRA assignments",emptyDescription:"Assign KRAs to employees and track weightage distribution across review cycles.",totalCount:(A==null?void 0:A.count)??0,pagination:i,onPaginationChange:O,sorting:U,onSortingChange:M,globalFilter:E,onGlobalFilterChange:Y}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit KRA Assignment":"Add KRA Assignment"}),e.jsx(Se,{children:a?"Update KRA assignment details.":"Assign a KRA to an employee."})]}),e.jsxs("form",{onSubmit:S.handleSubmit(K),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Employee *"}),e.jsx(Oe,{className:"mt-1.5",value:S.watch("employee")??"",onValueChange:o=>S.setValue("employee",o,{shouldValidate:!0}),placeholder:"Select employee"}),S.formState.errors.employee&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:S.formState.errors.employee.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"KRA *"}),e.jsx(V,{...S.register("kra"),className:"mt-1.5",placeholder:"KRA ID"}),S.formState.errors.kra&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:S.formState.errors.kra.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Review Cycle *"}),e.jsx(V,{...S.register("review_cycle"),className:"mt-1.5",placeholder:"Review cycle ID"}),S.formState.errors.review_cycle&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:S.formState.errors.review_cycle.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Weightage (%) *"}),e.jsx(V,{type:"number",...S.register("weightage",{valueAsNumber:!0}),className:"mt-1.5",placeholder:"0"}),S.formState.errors.weightage&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:S.formState.errors.weightage.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Status"}),e.jsxs(re,{value:S.watch("status"),onValueChange:o=>S.setValue("status",o),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"draft",children:"Draft"}),e.jsx(h,{value:"active",children:"Active"}),e.jsx(h,{value:"archived",children:"Archived"})]})]})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:S.handleSubmit(K),disabled:b.isPending||z.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(Ee,{open:!!d,onOpenChange:o=>!o&&_(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Delete KRA assignment?"}),e.jsxs(Ie,{children:["This will permanently delete the KRA assignment for ",e.jsx("strong",{children:d==null?void 0:d.employee_name})," — ",e.jsx("strong",{children:d==null?void 0:d.kra_name}),"."]})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{variant:"destructive",onClick:X,children:"Delete"})]})]})})]})}const Wa=ge({name:q().min(1,"Name is required"),code:q().min(1,"Code is required"),description:q().optional(),is_active:ee()});function En(){var C,y;const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),{hasPermission:v,requirePermission:$}=de(),Q=v("performance","competency","create"),G=v("performance","competency","update"),L=v("performance","competency","delete"),{pagination:i,setPagination:O,sorting:U,setSorting:M,globalFilter:E,setGlobalFilter:Y,queryParams:H}=je(),{data:A,isLoading:B}=Ks(H),k=(A==null?void 0:A.results)??[],{data:b}=rs({page_size:1}),z=((y=(C=b==null?void 0:b.results)==null?void 0:C[0])==null?void 0:y.id)??"",I=vt(),S=bt(),u=Nt(),g=xe({resolver:he(Wa),defaultValues:{name:"",code:"",description:"",is_active:!0}});function K(){$("performance","competency","create")&&(m(null),g.reset({name:"",code:"",description:"",is_active:!0}),t(!0))}function X(x){$("performance","competency","update")&&(m(x),g.reset({name:x.name,code:x.code,description:x.description,is_active:x.is_active}),t(!0))}function n(x){const r={name:x.name,code:x.code,description:x.description,competencies:(a==null?void 0:a.competencies)??[],is_active:x.is_active,company:(a==null?void 0:a.company)??z};a?S.mutate({id:a.id,...r},{onSuccess:()=>t(!1)}):I.mutate(r,{onSuccess:()=>t(!1)})}function o(){d&&u.mutate(d.id,{onSuccess:()=>_(null)})}const W=[{key:"name",header:"Name",render:x=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:x.name})},{key:"code",header:"Code",render:x=>e.jsx("span",{className:"text-[13px] text-slate-600",children:x.code})},{key:"competency_count",header:"Competencies",render:x=>e.jsx("span",{className:"text-[13px] text-slate-600",children:x.competency_count??0})},{key:"is_active",header:"Status",render:x=>e.jsx(Ye,{status:x.is_active?"active":"inactive"})},{key:"created_at",header:"Created",render:x=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(x.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:x=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[G&&e.jsxs(Z,{onClick:()=>X(x),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),G&&L&&e.jsx(Ue,{}),L&&e.jsxs(Z,{className:"text-red-600",onClick:()=>_(x),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}];return 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(fs,{className:"h-5 w-5 text-primary"})," Competency Framework"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Define organizational competency frameworks"})]}),Q&&e.jsxs(w,{size:"sm",onClick:K,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Framework"]})]}),e.jsx(fe,{columns:W,data:k,isLoading:B,searchPlaceholder:"Search frameworks...",emptyMessage:"No competency frameworks",emptyDescription:"Add your first competency framework to define organizational competencies.",totalCount:(A==null?void 0:A.count)??0,pagination:i,onPaginationChange:O,sorting:U,onSortingChange:M,globalFilter:E,onGlobalFilterChange:Y}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit Framework":"Add Framework"}),e.jsx(Se,{children:a?"Update competency framework details.":"Create a new competency framework."})]}),e.jsxs("form",{onSubmit:g.handleSubmit(n),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(V,{...g.register("name"),className:"mt-1.5",placeholder:"e.g. Leadership Competencies"}),g.formState.errors.name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:g.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(V,{...g.register("code"),className:"mt-1.5",placeholder:"e.g. LEAD-COMP"}),g.formState.errors.code&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:g.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(Ke,{...g.register("description"),className:"mt-1.5",placeholder:"Describe the framework...",rows:3})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(Ae,{id:"is_active",checked:g.watch("is_active"),onCheckedChange:x=>g.setValue("is_active",!!x)}),e.jsx(p,{htmlFor:"is_active",className:"text-[12px] font-medium text-slate-500 cursor-pointer",children:"Active"})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:g.handleSubmit(n),disabled:I.isPending||S.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(Ee,{open:!!d,onOpenChange:x=>!x&&_(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Delete competency framework?"}),e.jsxs(Ie,{children:["This will permanently delete ",e.jsx("strong",{children:d==null?void 0:d.name})," and all associated data."]})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{variant:"destructive",onClick:o,children:"Delete"})]})]})})]})}const Ya=ge({employee:q().min(1,"Employee is required"),competency_framework:q().min(1,"Framework is required"),competency_id:q().min(1,"Competency is required"),review_cycle:q().min(1,"Review cycle is required"),expected_proficiency:Pe.number().int().min(1,"Expected level must be >= 1"),self_assessed_proficiency:Pe.number().int().min(0,"Must be >= 0")});function Dn(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),{hasPermission:d,requirePermission:_}=de(),v=d("performance","competency_assignment","create"),$=d("performance","competency_assignment","update"),{pagination:Q,setPagination:G,sorting:L,setSorting:i,globalFilter:O,setGlobalFilter:U,queryParams:M}=je(),{data:E,isLoading:Y}=wt(M),H=(E==null?void 0:E.results)??[],[A,B]=P.useState(""),{data:k,isLoading:b}=Ks({page_size:200,search:A||void 0}),z=(k==null?void 0:k.results)??[],[I,S]=P.useState(""),{data:u,isLoading:g}=We({page_size:200,search:I||void 0}),K=(u==null?void 0:u.results)??[],X=St(),n=kt(),o=xe({resolver:he(Ya),defaultValues:{employee:"",competency_framework:"",competency_id:"",review_cycle:"",expected_proficiency:3,self_assessed_proficiency:0}});function W(){_("performance","competency_assignment","create")&&(m(null),o.reset({employee:"",competency_framework:"",competency_id:"",review_cycle:"",expected_proficiency:3,self_assessed_proficiency:0}),t(!0))}function C(r){_("performance","competency_assignment","update")&&(m(r),o.reset({employee:r.employee,competency_framework:r.competency_framework,competency_id:r.competency_id,review_cycle:r.review_cycle,expected_proficiency:r.expected_proficiency,self_assessed_proficiency:r.self_assessed_proficiency??0}),t(!0))}function y(r){const D={employee:r.employee,competency_framework:r.competency_framework,competency_id:r.competency_id,review_cycle:r.review_cycle,expected_proficiency:r.expected_proficiency,self_assessed_proficiency:r.self_assessed_proficiency};a?n.mutate({id:a.id,...D},{onSuccess:()=>t(!1)}):X.mutate(D,{onSuccess:()=>t(!1)})}const x=[{key:"employee_name",header:"Employee",render:r=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:r.employee_name})},{key:"framework_name",header:"Framework",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.framework_name})},{key:"competency_id",header:"Competency",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.competency_id})},{key:"self_assessed_proficiency",header:"Current",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.self_assessed_proficiency??"-"})},{key:"expected_proficiency",header:"Expected",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.expected_proficiency})},{key:"gap",header:"Gap",render:r=>{const D=r.self_assessed_proficiency!=null?r.expected_proficiency-r.self_assessed_proficiency:null;return e.jsx(ce,{variant:D!=null&&D<=0?"success":"secondary",className:"text-[11px]",children:D!=null?D<=0?"Met":`-${D}`:"-"})}},{key:"actions",header:"",className:"w-10",render:r=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsx(ue,{align:"end",children:$&&e.jsxs(Z,{onClick:()=>C(r),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]})})]})}];return 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(as,{className:"h-5 w-5 text-primary"})," Competency Assignments"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Assign competencies to employees and assess proficiency"})]}),v&&e.jsxs(w,{size:"sm",onClick:W,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Assignment"]})]}),e.jsx(fe,{columns:x,data:H,isLoading:Y,searchPlaceholder:"Search competency assignments...",emptyMessage:"No competency assignments",emptyDescription:"Assign competencies to employees and track proficiency levels.",totalCount:(E==null?void 0:E.count)??0,pagination:Q,onPaginationChange:G,sorting:L,onSortingChange:i,globalFilter:O,onGlobalFilterChange:U}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit Competency Assignment":"Add Competency Assignment"}),e.jsx(Se,{children:a?"Update competency assignment details.":"Assign a competency framework to an employee."})]}),e.jsxs("form",{onSubmit:o.handleSubmit(y),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Employee *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Oe,{value:o.watch("employee"),onValueChange:r=>o.setValue("employee",r,{shouldValidate:!0})})}),o.formState.errors.employee&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:o.formState.errors.employee.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Competency Framework *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:o.watch("competency_framework")??null,onValueChange:r=>o.setValue("competency_framework",r,{shouldValidate:!0}),onSearch:B,isLoading:b,selectedLabel:a==null?void 0:a.framework_name,options:z.map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select framework",searchPlaceholder:"Search frameworks..."})}),o.formState.errors.competency_framework&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:o.formState.errors.competency_framework.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Competency *"}),e.jsx(V,{...o.register("competency_id"),className:"mt-1.5",placeholder:"Competency ID / key"}),o.formState.errors.competency_id&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:o.formState.errors.competency_id.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Review Cycle"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:o.watch("review_cycle")||null,onValueChange:r=>o.setValue("review_cycle",r,{shouldValidate:!0}),onSearch:S,isLoading:g,selectedLabel:a==null?void 0:a.cycle_name,options:K.map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select cycle",searchPlaceholder:"Search cycles..."})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Expected Proficiency *"}),e.jsx(V,{type:"number",...o.register("expected_proficiency",{valueAsNumber:!0}),className:"mt-1.5",placeholder:"3"}),o.formState.errors.expected_proficiency&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:o.formState.errors.expected_proficiency.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Self-Assessed"}),e.jsx(V,{type:"number",...o.register("self_assessed_proficiency",{valueAsNumber:!0}),className:"mt-1.5",placeholder:"0"}),o.formState.errors.self_assessed_proficiency&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:o.formState.errors.self_assessed_proficiency.message})]})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:o.handleSubmit(y),disabled:X.isPending||n.isPending,children:a?"Update":"Create"})]})]})})]})}const Za={pending:"warning",in_progress:"warning",completed:"success",declined:"destructive",expired:"secondary"},Ja=[{value:"self",label:"Self"},{value:"manager",label:"Manager"},{value:"peer",label:"Peer"},{value:"direct_report",label:"Direct Report"},{value:"cross_functional",label:"Cross-functional"},{value:"external",label:"External"}],Xa=ge({employee:q().min(1,"Employee is required"),reviewer:q().min(1,"Reviewer is required"),review_cycle:q().min(1,"Review cycle is required"),questionnaire:q(),reviewer_type:Ce(["self","manager","peer","direct_report","cross_functional","external"]),due_date:Ge()});function $n(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),[v,$]=P.useState(""),[Q,G]=P.useState(""),{hasPermission:L,requirePermission:i}=de(),O=L("performance","feedback","create"),U=L("performance","feedback","update"),{data:M}=We({search:v||void 0}),{data:E}=$s({search:Q||void 0}),{pagination:Y,setPagination:H,sorting:A,setSorting:B,globalFilter:k,setGlobalFilter:b,queryParams:z}=je(),{data:I,isLoading:S}=na(z),u=(I==null?void 0:I.results)??[],g=ia(),K=la(),X=ca(),n=xe({resolver:he(Xa),defaultValues:{employee:"",reviewer:"",review_cycle:"",questionnaire:"",reviewer_type:"peer",due_date:""}});function o(){i("performance","feedback","create")&&(m(null),n.reset({employee:"",reviewer:"",review_cycle:"",questionnaire:"",reviewer_type:"peer",due_date:""}),t(!0))}function W(r){i("performance","feedback","update")&&(m(r),n.reset({employee:r.employee,reviewer:r.reviewer,review_cycle:r.review_cycle,questionnaire:r.questionnaire??"",reviewer_type:r.reviewer_type,due_date:r.due_date??""}),t(!0))}function C(r){const D={employee:r.employee,reviewer:r.reviewer,review_cycle:r.review_cycle,questionnaire:r.questionnaire||null,reviewer_type:r.reviewer_type,due_date:r.due_date||null};a?K.mutate({id:a.id,...D},{onSuccess:()=>t(!1)}):g.mutate(D,{onSuccess:()=>t(!1)})}function y(){d&&X.mutate(d.id,{onSuccess:()=>_(null)})}const x=[{key:"employee_name",header:"Employee",render:r=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:r.employee_name})},{key:"reviewer_name",header:"Reviewer",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.reviewer_name})},{key:"reviewer_type",header:"Reviewer Type",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600 capitalize",children:(r.reviewer_type_display??r.reviewer_type).replace(/_/g," ")})},{key:"questionnaire_name",header:"Questionnaire",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.questionnaire_name??"-"})},{key:"due_date",header:"Due Date",render:r=>e.jsx("span",{className:"text-[12px] text-slate-500",children:r.due_date?new Date(r.due_date).toLocaleDateString():"-"})},{key:"status",header:"Status",render:r=>e.jsx(ce,{variant:Za[r.status]??"secondary",className:"text-[11px] capitalize",children:r.status.replace(/_/g," ")})},{key:"completed_at",header:"Completed At",render:r=>e.jsx("span",{className:"text-[12px] text-slate-500",children:r.completed_at?new Date(r.completed_at).toLocaleDateString():"-"})},{key:"actions",header:"",className:"w-10",render:r=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[U&&e.jsxs(Z,{onClick:()=>W(r),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),U&&e.jsxs(e.Fragment,{children:[e.jsx(Ue,{}),e.jsxs(Z,{className:"text-red-600",onClick:()=>_(r),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})]})}];return 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(Cs,{className:"h-5 w-5 text-primary"})," Feedback Requests"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Manage 360-degree multi-rater feedback requests"})]}),O&&e.jsxs(w,{size:"sm",onClick:o,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Feedback Request"]})]}),e.jsx(fe,{columns:x,data:u,isLoading:S,searchPlaceholder:"Search feedback requests...",emptyMessage:"No feedback requests",emptyDescription:"Create your first feedback request to start collecting 360-degree reviews.",totalCount:(I==null?void 0:I.count)??0,pagination:Y,onPaginationChange:H,sorting:A,onSortingChange:B,globalFilter:k,onGlobalFilterChange:b}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit Feedback Request":"Add Feedback Request"}),e.jsx(Se,{children:a?"Update feedback request details.":"Create a new 360-degree feedback request."})]}),e.jsxs("form",{onSubmit:n.handleSubmit(C),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Employee *"}),e.jsx(Oe,{className:"mt-1.5",value:n.watch("employee")??"",onValueChange:r=>n.setValue("employee",r,{shouldValidate:!0}),placeholder:"Select employee"}),n.formState.errors.employee&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.employee.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Reviewer *"}),e.jsx(Oe,{className:"mt-1.5",value:n.watch("reviewer")??"",onValueChange:r=>n.setValue("reviewer",r,{shouldValidate:!0}),placeholder:"Select reviewer"}),n.formState.errors.reviewer&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.reviewer.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Review Cycle *"}),e.jsx(qe,{className:"mt-1.5",value:n.watch("review_cycle")??null,onValueChange:r=>n.setValue("review_cycle",r,{shouldValidate:!0}),onSearch:$,selectedLabel:a==null?void 0:a.cycle_name,options:((M==null?void 0:M.results)??[]).map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select review cycle",searchPlaceholder:"Search review cycles..."}),n.formState.errors.review_cycle&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.review_cycle.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Questionnaire"}),e.jsx(qe,{className:"mt-1.5",value:n.watch("questionnaire")??null,onValueChange:r=>n.setValue("questionnaire",r,{shouldValidate:!0}),onSearch:G,selectedLabel:a==null?void 0:a.questionnaire_name,options:((E==null?void 0:E.results)??[]).map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select questionnaire (optional)",searchPlaceholder:"Search questionnaires..."})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Reviewer Type *"}),e.jsxs(re,{value:n.watch("reviewer_type"),onValueChange:r=>n.setValue("reviewer_type",r),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{})}),e.jsx(le,{children:Ja.map(r=>e.jsx(h,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Due Date"}),e.jsx(V,{type:"date",...n.register("due_date"),className:"mt-1.5"})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:n.handleSubmit(C),disabled:g.isPending||K.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(Ee,{open:!!d,onOpenChange:r=>!r&&_(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Delete feedback request?"}),e.jsxs(Ie,{children:["This will permanently delete the feedback request for ",e.jsx("strong",{children:d==null?void 0:d.employee_name}),"."]})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{variant:"destructive",onClick:y,children:"Delete"})]})]})})]})}const er=ge({name:q().min(1,"Name is required"),code:q().min(1,"Code is required"),reviewer_type:Ce(["self","manager","peer","direct_report","cross_functional","external"]),description:q().optional(),is_active:ee()});function Vn(){var K,X;const[s,t]=P.useState(!1),[a,m]=P.useState(null),{hasPermission:d,requirePermission:_}=de(),v=d("performance","questionnaire","create"),$=d("performance","questionnaire","update"),{pagination:Q,setPagination:G,sorting:L,setSorting:i,globalFilter:O,setGlobalFilter:U,queryParams:M}=je(),{data:E,isLoading:Y}=$s(M),H=(E==null?void 0:E.results)??[],{data:A}=rs({page_size:1}),B=((X=(K=A==null?void 0:A.results)==null?void 0:K[0])==null?void 0:X.id)??"",k=aa(),b=ra(),z=xe({resolver:he(er),defaultValues:{name:"",code:"",reviewer_type:"peer",is_active:!0}});function I(){_("performance","questionnaire","create")&&(m(null),z.reset({name:"",code:"",reviewer_type:"peer",is_active:!0}),t(!0))}function S(n){_("performance","questionnaire","update")&&(m(n),z.reset({name:n.name,code:n.code,reviewer_type:n.reviewer_type,is_active:n.is_active}),t(!0))}function u(n){const o={name:n.name,code:n.code,reviewer_type:n.reviewer_type,sections:(a==null?void 0:a.sections)??[],is_active:n.is_active,company:(a==null?void 0:a.company)??B};a?b.mutate({id:a.id,...o},{onSuccess:()=>t(!1)}):k.mutate(o,{onSuccess:()=>t(!1)})}const g=[{key:"name",header:"Name",render:n=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:n.name})},{key:"reviewer_type",header:"Reviewer Type",render:n=>e.jsx("span",{className:"text-[13px] text-slate-600 capitalize",children:(n.reviewer_type_display??n.reviewer_type).replace(/_/g," ")})},{key:"section_count",header:"Sections",render:n=>e.jsx("span",{className:"text-[13px] text-slate-600",children:n.section_count??0})},{key:"is_active",header:"Status",render:n=>e.jsx(Ye,{status:n.is_active?"active":"inactive"})},{key:"created_at",header:"Created",render:n=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(n.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:n=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsx(ue,{align:"end",children:$&&e.jsxs(Z,{onClick:()=>S(n),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]})})]})}];return 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(As,{className:"h-5 w-5 text-primary"})," Questionnaires"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Design feedback questionnaire templates"})]}),v&&e.jsxs(w,{size:"sm",onClick:I,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Questionnaire"]})]}),e.jsx(fe,{columns:g,data:H,isLoading:Y,searchPlaceholder:"Search questionnaires...",emptyMessage:"No questionnaires",emptyDescription:"Add your first questionnaire to collect structured feedback.",totalCount:(E==null?void 0:E.count)??0,pagination:Q,onPaginationChange:G,sorting:L,onSortingChange:i,globalFilter:O,onGlobalFilterChange:U}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit Questionnaire":"Add Questionnaire"}),e.jsx(Se,{children:a?"Update questionnaire details.":"Create a new feedback questionnaire template."})]}),e.jsxs("form",{onSubmit:z.handleSubmit(u),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(V,{...z.register("name"),className:"mt-1.5",placeholder:"e.g. 360 Feedback Survey"}),z.formState.errors.name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:z.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(Ke,{...z.register("description"),className:"mt-1.5",placeholder:"Describe the questionnaire...",rows:3})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(Ae,{id:"is_active",checked:z.watch("is_active"),onCheckedChange:n=>z.setValue("is_active",!!n)}),e.jsx(p,{htmlFor:"is_active",className:"text-[12px] font-medium text-slate-500 cursor-pointer",children:"Active"})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:z.handleSubmit(u),disabled:k.isPending||b.isPending,children:a?"Update":"Create"})]})]})})]})}const sr={draft:"secondary",scheduled:"secondary",in_progress:"warning",completed:"success",finalized:"success",cancelled:"default"},tr=ge({name:q().min(1,"Name is required"),review_cycle:q().min(1,"Review cycle is required"),facilitator:q().min(1,"Facilitator is required"),scheduled_date:Ge("Scheduled date is required"),department:q(),notes:q()});function In(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),[v,$]=P.useState(""),[Q,G]=P.useState(""),{hasPermission:L,requirePermission:i}=de(),O=L("performance","calibration","create"),U=L("performance","calibration","update"),{data:M}=We({search:v||void 0}),{data:E}=lt({search:Q||void 0}),{pagination:Y,setPagination:H,sorting:A,setSorting:B,globalFilter:k,setGlobalFilter:b,queryParams:z}=je(),{data:I,isLoading:S}=oa(z),u=(I==null?void 0:I.results)??[],g=da(),K=ma(),X=pa(),n=xe({resolver:he(tr),defaultValues:{name:"",review_cycle:"",facilitator:"",scheduled_date:"",department:"",notes:""}});function o(){i("performance","calibration","create")&&(m(null),n.reset({name:"",review_cycle:"",facilitator:"",scheduled_date:"",department:"",notes:""}),t(!0))}function W(r){i("performance","calibration","update")&&(m(r),n.reset({name:r.name,review_cycle:r.review_cycle,facilitator:r.facilitator??"",scheduled_date:r.scheduled_date??"",department:r.department??"",notes:r.notes}),t(!0))}function C(r){const D={name:r.name,review_cycle:r.review_cycle,facilitator:r.facilitator,scheduled_date:r.scheduled_date,department:r.department||null,notes:r.notes||void 0};a?K.mutate({id:a.id,...D},{onSuccess:()=>t(!1)}):g.mutate(D,{onSuccess:()=>t(!1)})}function y(){d&&X.mutate(d.id,{onSuccess:()=>_(null)})}const x=[{key:"name",header:"Name",render:r=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:r.name})},{key:"review_cycle_name",header:"Review Cycle",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.review_cycle_name??"-"})},{key:"facilitator_name",header:"Facilitator",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.facilitator_name})},{key:"department_name",header:"Department",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.department_name??"-"})},{key:"scheduled_date",header:"Scheduled Date",render:r=>e.jsx("span",{className:"text-[12px] text-slate-500",children:r.scheduled_date?new Date(r.scheduled_date).toLocaleDateString():"-"})},{key:"participants_count",header:"Participants",render:r=>e.jsx("span",{className:"text-[13px] text-slate-600",children:r.participants_count??0})},{key:"status",header:"Status",render:r=>e.jsx(ce,{variant:sr[r.status]??"secondary",className:"text-[11px] capitalize",children:r.status.replace(/_/g," ")})},{key:"created_at",header:"Created",render:r=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(r.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:r=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[U&&e.jsxs(Z,{onClick:()=>W(r),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),U&&e.jsxs(e.Fragment,{children:[e.jsx(Ue,{}),e.jsxs(Z,{className:"text-red-600",onClick:()=>_(r),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})]})}];return 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(xs,{className:"h-5 w-5 text-primary"})," Calibration Sessions"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Conduct rating calibration sessions to ensure fair evaluations"})]}),O&&e.jsxs(w,{size:"sm",onClick:o,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Calibration Session"]})]}),e.jsx(fe,{columns:x,data:u,isLoading:S,searchPlaceholder:"Search calibration sessions...",emptyMessage:"No calibration sessions",emptyDescription:"Create your first calibration session to ensure fair and consistent performance evaluations.",totalCount:(I==null?void 0:I.count)??0,pagination:Y,onPaginationChange:H,sorting:A,onSortingChange:B,globalFilter:k,onGlobalFilterChange:b}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit Calibration Session":"Add Calibration Session"}),e.jsx(Se,{children:a?"Update calibration session details.":"Create a new calibration session for rating alignment."})]}),e.jsxs("form",{onSubmit:n.handleSubmit(C),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(V,{...n.register("name"),className:"mt-1.5",placeholder:"e.g. Q4 2025 Engineering Calibration"}),n.formState.errors.name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Review Cycle *"}),e.jsx(qe,{className:"mt-1.5",value:n.watch("review_cycle")??null,onValueChange:r=>n.setValue("review_cycle",r,{shouldValidate:!0}),onSearch:$,selectedLabel:a==null?void 0:a.cycle_name,options:((M==null?void 0:M.results)??[]).map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select review cycle",searchPlaceholder:"Search review cycles..."}),n.formState.errors.review_cycle&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.review_cycle.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Facilitator *"}),e.jsx(Oe,{className:"mt-1.5",value:n.watch("facilitator")??"",onValueChange:r=>n.setValue("facilitator",r,{shouldValidate:!0}),placeholder:"Select facilitator"}),n.formState.errors.facilitator&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.facilitator.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Scheduled Date *"}),e.jsx(V,{type:"date",...n.register("scheduled_date"),className:"mt-1.5"}),n.formState.errors.scheduled_date&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:n.formState.errors.scheduled_date.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Department"}),e.jsx(qe,{className:"mt-1.5",value:n.watch("department")??null,onValueChange:r=>n.setValue("department",r,{shouldValidate:!0}),onSearch:G,selectedLabel:a==null?void 0:a.department_name,options:((E==null?void 0:E.results)??[]).map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select department (optional)",searchPlaceholder:"Search departments..."})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Notes"}),e.jsx(Ke,{...n.register("notes"),className:"mt-1.5",placeholder:"Session objectives and notes...",rows:3})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:n.handleSubmit(C),disabled:g.isPending||K.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(Ee,{open:!!d,onOpenChange:r=>!r&&_(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Delete calibration session?"}),e.jsxs(Ie,{children:["This will permanently delete ",e.jsx("strong",{children:d==null?void 0:d.name})," and all associated adjustments."]})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{variant:"destructive",onClick:y,children:"Delete"})]})]})})]})}const ar=ss(ge({employee:q().min(1,"Employee is required"),manager:q().min(1,"Manager is required"),review_cycle:q().optional().default(""),title:q().min(1,"Title is required"),description:q().optional().default(""),start_date:Ge("Start date is required"),end_date:Ge("End date is required"),improvement_areas:q().min(1,"Improvement areas are required"),success_criteria:q().min(1,"Success criteria is required"),support_provided:q().optional().default(""),consequences:q().optional().default("")}),"start_date","end_date"),rr={draft:"secondary",active:"success",review:"warning",completed:"success",cancelled:"destructive"};function Qn(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(""),{hasPermission:v,requirePermission:$}=de(),Q=v("performance","pip","create"),G=v("performance","pip","update"),{pagination:L,setPagination:i,sorting:O,setSorting:U,globalFilter:M,setGlobalFilter:E}=je(),{data:Y,isLoading:H}=ua({page:L.pageIndex+1,page_size:L.pageSize,search:M||void 0,...d&&{status:d}}),[A,B]=P.useState(""),{data:k,isLoading:b}=We({page_size:100,search:A||void 0}),z=(k==null?void 0:k.results)??[],I=xa(),S=ha(),u=ga(),g=xe({resolver:he(ar),defaultValues:{description:"",review_cycle:"",support_provided:"",consequences:""}});function K(){$("performance","pip","create")&&(m(null),g.reset({employee:"",manager:"",review_cycle:"",title:"",description:"",start_date:"",end_date:"",improvement_areas:"",success_criteria:"",support_provided:"",consequences:""}),t(!0))}function X(x){$("performance","pip","update")&&(m(x),g.reset({employee:x.employee,manager:x.manager,review_cycle:x.review_cycle??"",title:x.title,description:x.description||"",start_date:x.start_date,end_date:x.end_date,improvement_areas:x.improvement_areas,success_criteria:x.success_criteria,support_provided:x.support_provided||"",consequences:x.consequences||""}),t(!0))}function n(x){const r={...x,review_cycle:x.review_cycle||null};a?S.mutate({id:a.id,...r},{onSuccess:()=>t(!1)}):I.mutate(r,{onSuccess:()=>t(!1)})}function o(x){return x.milestone_count?Math.round((x.completed_milestones??0)/x.milestone_count*100):0}const W=[{key:"employee_name",header:"Employee",render:x=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[13px] font-medium text-slate-800",children:x.employee_name}),e.jsx("div",{className:"text-[11px] text-slate-400",children:x.employee_department})]})},{key:"title",header:"PIP Title",render:x=>e.jsx("span",{className:"text-[13px] text-slate-700",children:x.title})},{key:"review_cycle_name",header:"Trigger Cycle",render:x=>e.jsx("span",{className:"text-[12px] text-slate-500",children:x.review_cycle_name??"-"})},{key:"start_date",header:"Period",render:x=>e.jsxs("span",{className:"text-[12px] text-slate-500",children:[x.start_date," to ",x.end_date]})},{key:"status",header:"Status",render:x=>e.jsx(ce,{variant:rr[x.status]??"secondary",className:"text-[11px] capitalize",children:x.status})},{key:"progress",header:"Progress",render:x=>{const r=o(x);return e.jsxs("div",{className:"flex items-center gap-2 min-w-[120px]",children:[e.jsx(hs,{value:r,className:"flex-1"}),e.jsxs("span",{className:"text-[11px] text-slate-500 w-8 text-right",children:[r,"%"]})]})}},{key:"manager_name",header:"Mentor",render:x=>e.jsx("span",{className:"text-[12px] text-slate-500",children:x.manager_name})},{key:"actions",header:"",render:x=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[G&&e.jsxs(Z,{onClick:()=>X(x),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),G&&x.status==="active"&&e.jsxs(Z,{onClick:()=>u.mutate({id:x.id,final_outcome:"improved"}),children:[e.jsx(ls,{className:"mr-2 h-3.5 w-3.5"})," Close"]})]})]})}],C=(Y==null?void 0:Y.results)??[],y=I.isPending||S.isPending;return e.jsxs("div",{children:[e.jsx(He,{title:"Performance Improvement Plans",description:"Create and manage PIPs for employees requiring performance support.",breadcrumbs:[{label:"Performance",href:"/performance"},{label:"Improvement Plans"}]}),e.jsx(fe,{columns:W,data:C,isLoading:H,searchPlaceholder:"Search PIPs...",emptyMessage:"No PIPs found",emptyDescription:"Create a PIP to get started.",totalCount:(Y==null?void 0:Y.count)??0,pagination:L,onPaginationChange:i,sorting:O,onSortingChange:U,globalFilter:M,onGlobalFilterChange:E,actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(re,{value:d||"__all__",onValueChange:x=>_(x==="__all__"?"":x),children:[e.jsx(ne,{className:"h-8 w-[130px] text-[12px]",children:e.jsx(ie,{placeholder:"All Statuses"})}),e.jsxs(le,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"draft",children:"Draft"}),e.jsx(h,{value:"active",children:"Active"}),e.jsx(h,{value:"review",children:"Review"}),e.jsx(h,{value:"completed",children:"Completed"}),e.jsx(h,{value:"cancelled",children:"Cancelled"})]})]}),Q&&e.jsxs(w,{size:"sm",onClick:K,children:[e.jsx(ye,{className:"h-3.5 w-3.5 mr-1.5"})," Add PIP"]})]})}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"lg",className:"flex flex-col",children:[e.jsxs(Ne,{children:[e.jsxs(we,{className:"flex items-center gap-2",children:[e.jsx(is,{className:"h-4.5 w-4.5 text-primary"}),a?"Edit PIP":"New PIP"]}),e.jsx(Se,{children:a?`Editing PIP for ${a.employee_name}`:"Create a new Performance Improvement Plan."})]}),e.jsxs("form",{onSubmit:g.handleSubmit(n),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Title *"}),e.jsx(V,{...g.register("title"),className:"mt-1.5",placeholder:"e.g. Q1 Performance Improvement"}),g.formState.errors.title&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:g.formState.errors.title.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Employee *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Oe,{value:g.watch("employee"),onValueChange:x=>g.setValue("employee",x,{shouldValidate:!0})})}),g.formState.errors.employee&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:g.formState.errors.employee.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Mentor *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Oe,{value:g.watch("manager"),onValueChange:x=>g.setValue("manager",x,{shouldValidate:!0})})}),g.formState.errors.manager&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:g.formState.errors.manager.message})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Trigger Review Cycle"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:g.watch("review_cycle")||null,onValueChange:x=>g.setValue("review_cycle",x),onSearch:B,isLoading:b,selectedLabel:a==null?void 0:a.review_cycle_name,options:z.map(x=>({value:x.id,label:x.name,hint:x.code})),placeholder:"Select review cycle",searchPlaceholder:"Search cycles..."})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Start Date *"}),e.jsx(V,{type:"date",...g.register("start_date"),className:"mt-1.5",max:g.watch("end_date")||void 0}),g.formState.errors.start_date&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:g.formState.errors.start_date.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"End Date *"}),e.jsx(V,{type:"date",...g.register("end_date"),className:"mt-1.5",min:g.watch("start_date")||void 0}),g.formState.errors.end_date&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:g.formState.errors.end_date.message})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx("textarea",{...g.register("description"),className:"mt-1.5 flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",placeholder:"PIP description..."})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Improvement Areas *"}),e.jsx("textarea",{...g.register("improvement_areas"),className:"mt-1.5 flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",placeholder:"Describe areas needing improvement..."}),g.formState.errors.improvement_areas&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:g.formState.errors.improvement_areas.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Success Criteria *"}),e.jsx("textarea",{...g.register("success_criteria"),className:"mt-1.5 flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",placeholder:"Define measurable success criteria..."}),g.formState.errors.success_criteria&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:g.formState.errors.success_criteria.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Support Provided"}),e.jsx("textarea",{...g.register("support_provided"),className:"mt-1.5 flex min-h-[60px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",placeholder:"Training, mentorship, etc."})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Consequences"}),e.jsx("textarea",{...g.register("consequences"),className:"mt-1.5 flex min-h-[60px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",placeholder:"If goals not met..."})]})]})]}),e.jsxs(ke,{children:[e.jsx(w,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:g.handleSubmit(n),disabled:y,children:y?"Saving...":a?"Save Changes":"Create PIP"})]})]})})]})}const nr=ss(ge({name:q().min(1,"Name is required"),description:q().optional(),start_date:Ge("Start date is required"),end_date:us(),budget:q().optional(),points_enabled:ee(),peer_to_peer_enabled:ee(),manager_only:ee(),is_active:ee()}),"start_date","end_date");function Ln(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),{hasPermission:d,requirePermission:_}=de(),v=d("performance","recognition_program","create"),$=d("performance","recognition_program","update"),{pagination:Q,setPagination:G,sorting:L,setSorting:i,globalFilter:O,setGlobalFilter:U,queryParams:M}=je(),{data:E,isLoading:Y}=Vs(M),H=(E==null?void 0:E.results)??[],A=fa(),B=ja(),k=xe({resolver:he(nr),defaultValues:{name:"",description:"",start_date:"",end_date:"",budget:"",points_enabled:!1,peer_to_peer_enabled:!1,manager_only:!1,is_active:!0}});function b(){_("performance","recognition_program","create")&&(m(null),k.reset({name:"",description:"",start_date:"",end_date:"",budget:"",points_enabled:!1,peer_to_peer_enabled:!1,manager_only:!1,is_active:!0}),t(!0))}function z(u){_("performance","recognition_program","update")&&(m(u),k.reset({name:u.name,description:u.description,start_date:u.start_date,end_date:u.end_date??"",budget:u.budget??"",points_enabled:u.points_enabled,peer_to_peer_enabled:u.peer_to_peer_enabled,manager_only:u.manager_only,is_active:u.is_active}),t(!0))}function I(u){const g={name:u.name,description:u.description,start_date:u.start_date,end_date:u.end_date||null,budget:u.budget||null,points_enabled:u.points_enabled,peer_to_peer_enabled:u.peer_to_peer_enabled,manager_only:u.manager_only,is_active:u.is_active};a?B.mutate({id:a.id,...g},{onSuccess:()=>t(!1)}):A.mutate(g,{onSuccess:()=>t(!1)})}const S=[{key:"name",header:"Name",render:u=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:u.name})},{key:"start_date",header:"Start Date",render:u=>e.jsx("span",{className:"text-[13px] text-slate-600",children:new Date(u.start_date).toLocaleDateString()})},{key:"end_date",header:"End Date",render:u=>e.jsx("span",{className:"text-[13px] text-slate-600",children:u.end_date?new Date(u.end_date).toLocaleDateString():"-"})},{key:"budget",header:"Budget",render:u=>e.jsx("span",{className:"text-[13px] text-slate-600",children:u.budget??"-"})},{key:"is_active",header:"Status",render:u=>e.jsx(Ye,{status:u.is_active?"active":"inactive"})},{key:"points_enabled",header:"Points",render:u=>e.jsx(ce,{variant:u.points_enabled?"default":"secondary",className:"text-[11px]",children:u.points_enabled?"Enabled":"Disabled"})},{key:"actions",header:"",className:"w-10",render:u=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsx(ue,{align:"end",children:$&&e.jsxs(Z,{onClick:()=>z(u),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]})})]})}];return 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(ts,{className:"h-5 w-5 text-primary"})," Recognition Programs"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure recognition program structures"})]}),v&&e.jsxs(w,{size:"sm",onClick:b,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Program"]})]}),e.jsx(fe,{columns:S,data:H,isLoading:Y,searchPlaceholder:"Search programs...",emptyMessage:"No recognition programs",emptyDescription:"Add your first recognition program to reward and motivate employees.",totalCount:(E==null?void 0:E.count)??0,pagination:Q,onPaginationChange:G,sorting:L,onSortingChange:i,globalFilter:O,onGlobalFilterChange:U}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit Program":"Add Program"}),e.jsx(Se,{children:a?"Update recognition program details.":"Create a new recognition program."})]}),e.jsxs("form",{onSubmit:k.handleSubmit(I),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(V,{...k.register("name"),className:"mt-1.5",placeholder:"e.g. Employee of the Month"}),k.formState.errors.name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:k.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(Ke,{...k.register("description"),className:"mt-1.5",placeholder:"Describe the program...",rows:3})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Start Date *"}),e.jsx(V,{type:"date",...k.register("start_date"),className:"mt-1.5",max:k.watch("end_date")||void 0}),k.formState.errors.start_date&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:k.formState.errors.start_date.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"End Date"}),e.jsx(V,{type:"date",...k.register("end_date"),className:"mt-1.5",min:k.watch("start_date")||void 0})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Budget"}),e.jsx(V,{...k.register("budget"),className:"mt-1.5",placeholder:"e.g. 5000"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(Ae,{id:"points_enabled",checked:k.watch("points_enabled"),onCheckedChange:u=>k.setValue("points_enabled",!!u)}),e.jsx(p,{htmlFor:"points_enabled",className:"text-[12px] font-medium text-slate-500 cursor-pointer",children:"Points enabled"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(Ae,{id:"peer_to_peer_enabled",checked:k.watch("peer_to_peer_enabled"),onCheckedChange:u=>k.setValue("peer_to_peer_enabled",!!u)}),e.jsx(p,{htmlFor:"peer_to_peer_enabled",className:"text-[12px] font-medium text-slate-500 cursor-pointer",children:"Peer-to-peer enabled"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(Ae,{id:"manager_only",checked:k.watch("manager_only"),onCheckedChange:u=>k.setValue("manager_only",!!u)}),e.jsx(p,{htmlFor:"manager_only",className:"text-[12px] font-medium text-slate-500 cursor-pointer",children:"Manager only"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(Ae,{id:"is_active",checked:k.watch("is_active"),onCheckedChange:u=>k.setValue("is_active",!!u)}),e.jsx(p,{htmlFor:"is_active",className:"text-[12px] font-medium text-slate-500 cursor-pointer",children:"Active"})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:k.handleSubmit(I),disabled:A.isPending||B.isPending,children:a?"Update":"Create"})]})]})})]})}const ir=["bronze","silver","gold","platinum"],lr={bronze:"secondary",silver:"default",gold:"warning",platinum:"success"},cr=ge({name:q().min(1,"Name is required"),code:q().min(1,"Code is required"),description:q(),icon:q(),tier:Ce(["bronze","silver","gold","platinum"]),company:q().min(1,"Company is required"),is_active:ee()});function Tn(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),{hasPermission:v,requirePermission:$}=de(),Q=v("performance","badge","create"),G=v("performance","badge","update"),L=v("performance","badge","delete"),{pagination:i,setPagination:O,sorting:U,setSorting:M,globalFilter:E,setGlobalFilter:Y,queryParams:H}=je(),{data:A,isLoading:B}=Is(H),k=(A==null?void 0:A.results)??[],b=_a(),z=ya(),I=va(),[S,u]=P.useState(""),{data:g}=rs({search:S||void 0}),K=xe({resolver:he(cr),defaultValues:{name:"",code:"",description:"",icon:"",tier:"bronze",company:"",is_active:!0}});function X(){$("performance","badge","create")&&(m(null),K.reset({name:"",code:"",description:"",icon:"",tier:"bronze",company:"",is_active:!0}),t(!0))}function n(y){$("performance","badge","update")&&(m(y),K.reset({name:y.name,code:y.code,description:y.description,icon:y.icon,tier:y.tier,company:y.company,is_active:y.is_active}),t(!0))}function o(y){const x={name:y.name,code:y.code,description:y.description||void 0,icon:y.icon||void 0,tier:y.tier,company:y.company,is_active:y.is_active};a?z.mutate({id:a.id,...x},{onSuccess:()=>t(!1)}):b.mutate(x,{onSuccess:()=>t(!1)})}function W(){d&&I.mutate(d.id,{onSuccess:()=>_(null)})}const C=[{key:"name",header:"Name",render:y=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:y.name})},{key:"description",header:"Description",render:y=>e.jsx("span",{className:"text-[13px] text-slate-600 truncate max-w-[200px] inline-block",children:y.description||"-"})},{key:"icon",header:"Icon",render:y=>e.jsx("span",{className:"text-[13px] text-slate-600",children:y.icon||"-"})},{key:"tier",header:"Tier",render:y=>e.jsx(ce,{variant:lr[y.tier],className:"text-[11px] capitalize",children:y.tier})},{key:"code",header:"Code",render:y=>e.jsx("span",{className:"text-[13px] text-slate-600 font-mono",children:y.code})},{key:"company_name",header:"Company",render:y=>e.jsx("span",{className:"text-[13px] text-slate-600",children:y.company_name??"-"})},{key:"is_active",header:"Active",render:y=>e.jsx(Ye,{status:y.is_active?"active":"inactive"})},{key:"created_at",header:"Created",render:y=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(y.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:y=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[G&&e.jsxs(Z,{onClick:()=>n(y),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),G&&L&&e.jsx(Ue,{}),L&&e.jsxs(Z,{className:"text-red-600",onClick:()=>_(y),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}];return 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(js,{className:"h-5 w-5 text-primary"})," Recognition Badges"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Design and manage recognition badges with tiers and points"})]}),Q&&e.jsxs(w,{size:"sm",onClick:X,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Badge"]})]}),e.jsx(fe,{columns:C,data:k,isLoading:B,searchPlaceholder:"Search badges...",emptyMessage:"No recognition badges",emptyDescription:"Create your first recognition badge with tiers and point values.",totalCount:(A==null?void 0:A.count)??0,pagination:i,onPaginationChange:O,sorting:U,onSortingChange:M,globalFilter:E,onGlobalFilterChange:Y}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit Badge":"Add Badge"}),e.jsx(Se,{children:a?"Update recognition badge details.":"Create a new recognition badge."})]}),e.jsxs("form",{onSubmit:K.handleSubmit(o),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(V,{...K.register("name"),className:"mt-1.5",placeholder:"e.g. Star Performer"}),K.formState.errors.name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:K.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(V,{...K.register("code"),className:"mt-1.5",placeholder:"e.g. STAR_PERF"}),K.formState.errors.code&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:K.formState.errors.code.message})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:K.watch("company")??null,onValueChange:y=>K.setValue("company",y,{shouldValidate:!0}),onSearch:u,selectedLabel:a==null?void 0:a.company_name,options:((g==null?void 0:g.results)??[]).map(y=>({value:y.id,label:y.name,hint:y.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),K.formState.errors.company&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:K.formState.errors.company.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(Ke,{...K.register("description"),className:"mt-1.5",placeholder:"Describe the badge...",rows:3})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Icon"}),e.jsx(V,{...K.register("icon"),className:"mt-1.5",placeholder:"Icon name or URL"})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Tier *"}),e.jsxs(re,{value:K.watch("tier"),onValueChange:y=>K.setValue("tier",y),children:[e.jsx(ne,{className:"mt-1.5",children:e.jsx(ie,{})}),e.jsx(le,{children:ir.map(y=>e.jsx(h,{value:y,className:"capitalize",children:y},y))})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(Ae,{id:"is_active",checked:K.watch("is_active"),onCheckedChange:y=>K.setValue("is_active",!!y)}),e.jsx(p,{htmlFor:"is_active",className:"text-[12px] font-medium text-slate-500 cursor-pointer",children:"Active"})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:K.handleSubmit(o),disabled:b.isPending||z.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(Ee,{open:!!d,onOpenChange:y=>!y&&_(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Delete recognition badge?"}),e.jsxs(Ie,{children:["This will permanently delete the badge ",e.jsx("strong",{children:d==null?void 0:d.name}),"."]})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{variant:"destructive",onClick:W,children:"Delete"})]})]})})]})}const or=ge({receiver:q().min(1,"Receiver is required"),program:q().min(1,"Program is required"),badge:q().optional().default(""),title:q().min(1,"Title is required"),message:q().min(1,"Message is required"),points:Pe.number().min(0).default(0),is_public:ee().default(!0)});function dr(s){switch(s){case"approved":case"published":return"approved";case"rejected":return"rejected";case"pending":default:return"pending"}}function zn(){const[s,t]=P.useState(!1),[a,m]=P.useState(""),{hasPermission:d,requirePermission:_}=de(),v=d("performance","recognition","create"),$=d("performance","recognition","update"),{pagination:Q,setPagination:G,sorting:L,setSorting:i,globalFilter:O,setGlobalFilter:U}=je(),{data:M,isLoading:E}=ba({page:Q.pageIndex+1,page_size:Q.pageSize,search:O||void 0,...a&&{status:a}}),[Y,H]=P.useState(""),{data:A,isLoading:B}=Vs({page_size:100,search:Y||void 0}),k=(A==null?void 0:A.results)??[],[b,z]=P.useState(""),{data:I,isLoading:S}=Is({page_size:100,search:b||void 0}),u=(I==null?void 0:I.results)??[],g=Na(),K=wa(),X=Sa(),n=xe({resolver:he(or),defaultValues:{badge:"",points:0,is_public:!0}});function o(){_("performance","recognition","create")&&(n.reset({receiver:"",program:"",badge:"",title:"",message:"",points:0,is_public:!0}),t(!0))}function W(r){const D={...r,badge:r.badge||null};g.mutate(D,{onSuccess:()=>t(!1)})}const C=[{key:"giver_name",header:"From",render:r=>e.jsx("span",{className:"text-[13px] font-medium text-slate-800",children:r.giver_name})},{key:"receiver_name",header:"To",render:r=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[13px] font-medium text-slate-800",children:r.receiver_name}),e.jsx("div",{className:"text-[11px] text-slate-400",children:r.receiver_department})]})},{key:"program_name",header:"Program",render:r=>e.jsx("span",{className:"text-[12px] text-slate-600",children:r.program_name})},{key:"badge_name",header:"Badge",render:r=>r.badge_name?e.jsx(ce,{variant:"secondary",className:"text-[11px]",children:r.badge_name}):e.jsx("span",{className:"text-[12px] text-slate-400",children:"-"})},{key:"message",header:"Message",render:r=>e.jsx("span",{className:"text-[12px] text-slate-500 truncate max-w-[200px] block",children:r.message.length>60?`${r.message.slice(0,60)}...`:r.message})},{key:"status",header:"Status",render:r=>e.jsx(Ps,{status:dr(r.status)})},{key:"created_at",header:"Date",render:r=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(r.created_at).toLocaleDateString()})},{key:"actions",header:"",render:r=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[$&&r.status==="pending"&&e.jsxs(Z,{onClick:()=>K.mutate({id:r.id}),children:[e.jsx(Rs,{className:"mr-2 h-3.5 w-3.5"})," Approve"]}),$&&r.status==="pending"&&e.jsxs(Z,{onClick:()=>X.mutate({id:r.id}),children:[e.jsx(ls,{className:"mr-2 h-3.5 w-3.5"})," Reject"]})]})]})}],y=(M==null?void 0:M.results)??[],x=g.isPending;return e.jsxs("div",{children:[e.jsx(He,{title:"Recognitions",description:"Give and manage employee recognitions and awards.",breadcrumbs:[{label:"Performance",href:"/performance"},{label:"Recognitions"}]}),e.jsx(fe,{columns:C,data:y,isLoading:E,searchPlaceholder:"Search recognitions...",emptyMessage:"No recognitions found",emptyDescription:"Give a recognition to get started.",totalCount:(M==null?void 0:M.count)??0,pagination:Q,onPaginationChange:G,sorting:L,onSortingChange:i,globalFilter:O,onGlobalFilterChange:U,actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(re,{value:a||"__all__",onValueChange:r=>m(r==="__all__"?"":r),children:[e.jsx(ne,{className:"h-8 w-[130px] text-[12px]",children:e.jsx(ie,{placeholder:"All Statuses"})}),e.jsxs(le,{children:[e.jsx(h,{value:"__all__",children:"All Statuses"}),e.jsx(h,{value:"pending",children:"Pending"}),e.jsx(h,{value:"approved",children:"Approved"}),e.jsx(h,{value:"rejected",children:"Rejected"}),e.jsx(h,{value:"published",children:"Published"})]})]}),v&&e.jsxs(w,{size:"sm",onClick:o,children:[e.jsx(ye,{className:"h-3.5 w-3.5 mr-1.5"})," Give Recognition"]})]})}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",className:"flex flex-col",children:[e.jsxs(Ne,{children:[e.jsxs(we,{className:"flex items-center gap-2",children:[e.jsx(ts,{className:"h-4.5 w-4.5 text-primary"}),"Give Recognition"]}),e.jsx(Se,{children:"Recognize an employee for their great work."})]}),e.jsxs("form",{onSubmit:n.handleSubmit(W),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Title *"}),e.jsx(V,{...n.register("title"),className:"mt-1.5",placeholder:"e.g. Outstanding Q1 Performance"}),n.formState.errors.title&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.title.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Receiver *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Oe,{value:n.watch("receiver"),onValueChange:r=>n.setValue("receiver",r,{shouldValidate:!0})})}),n.formState.errors.receiver&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.receiver.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Program *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:n.watch("program")||"",onValueChange:r=>n.setValue("program",r,{shouldValidate:!0}),onSearch:H,isLoading:B,options:k.map(r=>({value:r.id,label:r.name,hint:r.code})),placeholder:"Select program",searchPlaceholder:"Search programs..."})}),n.formState.errors.program&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.program.message})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Badge"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(qe,{value:n.watch("badge")||"__none__",onValueChange:r=>n.setValue("badge",r==="__none__"?"":r),onSearch:z,isLoading:S,options:[{value:"__none__",label:"None"},...u.map(r=>({value:r.id,label:r.name,hint:r.code}))],placeholder:"Select badge",searchPlaceholder:"Search badges..."})})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Points"}),e.jsx(V,{type:"number",...n.register("points"),className:"mt-1.5",min:0})]})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Message *"}),e.jsx("textarea",{...n.register("message"),className:"mt-1.5 flex min-h-[100px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",placeholder:"Write a recognition message..."}),n.formState.errors.message&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:n.formState.errors.message.message})]}),e.jsx("div",{className:"flex items-center gap-6 pt-1",children:e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Ae,{checked:n.watch("is_public"),onCheckedChange:r=>n.setValue("is_public",!!r)}),e.jsx("span",{className:"text-[13px] text-slate-700",children:"Make this recognition public"})]})})]}),e.jsxs(ke,{children:[e.jsx(w,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:n.handleSubmit(W),disabled:x,children:x?"Sending...":"Send Recognition"})]})]})})]})}const mr=ge({kra_weightage_must_total_100:ee(),kpi_auto_populate_enabled:ee(),max_kras_per_employee:Pe.number().min(1).max(20),max_kpis_per_kra:Pe.number().min(1).max(20),goal_cascading_enabled:ee(),goal_progress_update_frequency:Ce(["weekly","biweekly","monthly"]),goal_approval_required:ee(),okr_framework_enabled:ee(),stretch_goals_enabled:ee(),self_review_mandatory:ee(),peer_review_enabled:ee(),peer_review_min_count:Pe.number().min(1).max(10),peer_selection_by:Ce(["employee","manager","hr","both"]),upward_review_enabled:ee(),skip_level_review_enabled:ee(),rating_justification_required:ee(),rating_diff_threshold:Pe.number().min(1).max(5),calibration_enabled:ee(),bell_curve_enforcement:Ce(["none","soft","hard"]),bell_curve_tolerance_pct:Pe.number().min(0).max(50),pip_enabled:ee(),pip_auto_trigger_rating:Pe.number().min(0).max(5),pip_default_duration_weeks:Pe.number().min(1).max(52),pip_review_frequency:Ce(["weekly","biweekly","monthly"]),recognition_enabled:ee(),peer_recognition_enabled:ee(),recognition_points_enabled:ee(),recognition_approval_required:ee(),rewards_catalog_enabled:ee(),notify_goal_check_in_reminder:ee(),notify_pip_milestone_reminder:ee()}),J={kra_weightage_must_total_100:!0,kpi_auto_populate_enabled:!1,max_kras_per_employee:8,max_kpis_per_kra:5,goal_cascading_enabled:!0,goal_progress_update_frequency:"monthly",goal_approval_required:!0,okr_framework_enabled:!1,stretch_goals_enabled:!0,self_review_mandatory:!0,peer_review_enabled:!1,peer_review_min_count:3,peer_selection_by:"both",upward_review_enabled:!1,skip_level_review_enabled:!1,rating_justification_required:!0,rating_diff_threshold:1,calibration_enabled:!1,bell_curve_enforcement:"none",bell_curve_tolerance_pct:5,pip_enabled:!0,pip_auto_trigger_rating:0,pip_default_duration_weeks:12,pip_review_frequency:"biweekly",recognition_enabled:!0,peer_recognition_enabled:!0,recognition_points_enabled:!1,recognition_approval_required:!1,rewards_catalog_enabled:!1,notify_goal_check_in_reminder:!0,notify_pip_milestone_reminder:!0};function oe({label:s,description:t,checked:a,onChange:m}){return e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3 first:pt-0 last:pb-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:s}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:t})]}),e.jsx(tt,{checked:a,onCheckedChange:m})]})}function Be({icon:s,title:t,description:a,children:m}){return e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white p-6",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-primary/10",children:e.jsx(s,{className:"h-4 w-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-[14px] font-semibold text-slate-800",children:t}),e.jsx("p",{className:"text-[12px] text-slate-400 mt-0.5",children:a})]})]}),e.jsx("div",{className:"divide-y divide-slate-100",children:m})]})}function Mn(){const{data:s,isLoading:t}=ht(),a=gt(),{hasPermission:m}=de(),d=m("performance","settings","update"),{control:_,handleSubmit:v,reset:$,register:Q,formState:{isDirty:G}}=xe({resolver:he(mr),defaultValues:J});P.useEffect(()=>{s&&$({kra_weightage_must_total_100:s.kra_weightage_must_total_100??J.kra_weightage_must_total_100,kpi_auto_populate_enabled:s.kpi_auto_populate_enabled??J.kpi_auto_populate_enabled,max_kras_per_employee:s.max_kras_per_employee??J.max_kras_per_employee,max_kpis_per_kra:s.max_kpis_per_kra??J.max_kpis_per_kra,goal_cascading_enabled:s.goal_cascading_enabled??J.goal_cascading_enabled,goal_progress_update_frequency:s.goal_progress_update_frequency??J.goal_progress_update_frequency,goal_approval_required:s.goal_approval_required??J.goal_approval_required,okr_framework_enabled:s.okr_framework_enabled??J.okr_framework_enabled,stretch_goals_enabled:s.stretch_goals_enabled??J.stretch_goals_enabled,self_review_mandatory:s.self_review_mandatory??J.self_review_mandatory,peer_review_enabled:s.peer_review_enabled??J.peer_review_enabled,peer_review_min_count:s.peer_review_min_count??J.peer_review_min_count,peer_selection_by:s.peer_selection_by??J.peer_selection_by,upward_review_enabled:s.upward_review_enabled??J.upward_review_enabled,skip_level_review_enabled:s.skip_level_review_enabled??J.skip_level_review_enabled,rating_justification_required:s.rating_justification_required??J.rating_justification_required,rating_diff_threshold:s.rating_diff_threshold??J.rating_diff_threshold,calibration_enabled:s.calibration_enabled??J.calibration_enabled,bell_curve_enforcement:s.bell_curve_enforcement??J.bell_curve_enforcement,bell_curve_tolerance_pct:s.bell_curve_tolerance_pct??J.bell_curve_tolerance_pct,pip_enabled:s.pip_enabled??J.pip_enabled,pip_auto_trigger_rating:s.pip_auto_trigger_rating??J.pip_auto_trigger_rating,pip_default_duration_weeks:s.pip_default_duration_weeks??J.pip_default_duration_weeks,pip_review_frequency:s.pip_review_frequency??J.pip_review_frequency,recognition_enabled:s.recognition_enabled??J.recognition_enabled,peer_recognition_enabled:s.peer_recognition_enabled??J.peer_recognition_enabled,recognition_points_enabled:s.recognition_points_enabled??J.recognition_points_enabled,recognition_approval_required:s.recognition_approval_required??J.recognition_approval_required,rewards_catalog_enabled:s.rewards_catalog_enabled??J.rewards_catalog_enabled,notify_goal_check_in_reminder:s.notify_goal_check_in_reminder??J.notify_goal_check_in_reminder,notify_pip_milestone_reminder:s.notify_pip_milestone_reminder??J.notify_pip_milestone_reminder})},[s,$]);function L(i){const O={kra_weightage_must_total_100:i.kra_weightage_must_total_100,kpi_auto_populate_enabled:i.kpi_auto_populate_enabled,max_kras_per_employee:i.max_kras_per_employee,max_kpis_per_kra:i.max_kpis_per_kra,goal_cascading_enabled:i.goal_cascading_enabled,goal_progress_update_frequency:i.goal_progress_update_frequency,goal_approval_required:i.goal_approval_required,okr_framework_enabled:i.okr_framework_enabled,stretch_goals_enabled:i.stretch_goals_enabled,self_review_mandatory:i.self_review_mandatory,peer_review_enabled:i.peer_review_enabled,peer_review_min_count:i.peer_review_min_count,peer_selection_by:i.peer_selection_by,upward_review_enabled:i.upward_review_enabled,skip_level_review_enabled:i.skip_level_review_enabled,rating_justification_required:i.rating_justification_required,rating_diff_threshold:i.rating_diff_threshold,calibration_enabled:i.calibration_enabled,bell_curve_enforcement:i.bell_curve_enforcement,bell_curve_tolerance_pct:i.bell_curve_tolerance_pct,pip_enabled:i.pip_enabled,pip_auto_trigger_rating:i.pip_auto_trigger_rating,pip_default_duration_weeks:i.pip_default_duration_weeks,pip_review_frequency:i.pip_review_frequency,recognition_enabled:i.recognition_enabled,peer_recognition_enabled:i.peer_recognition_enabled,recognition_points_enabled:i.recognition_points_enabled,recognition_approval_required:i.recognition_approval_required,rewards_catalog_enabled:i.rewards_catalog_enabled,notify_goal_check_in_reminder:i.notify_goal_check_in_reminder,notify_pip_milestone_reminder:i.notify_pip_milestone_reminder};a.mutate(O,{onSuccess:()=>$(i)})}return t?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(ds,{className:"h-5 w-5 text-primary"})," Performance Settings"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure performance management module settings"})]})}),e.jsx("div",{className:"space-y-6",children:Array.from({length:7}).map((i,O)=>e.jsx(ct,{className:"h-48 w-full rounded-xl"},O))})]}):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(ds,{className:"h-5 w-5 text-primary"})," Performance Settings"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure performance management module settings"})]})}),e.jsxs("form",{onSubmit:v(L),className:"space-y-6",children:[e.jsxs(Be,{icon:as,title:"KRA & KPI Settings",description:"Configure key result area and key performance indicator defaults",children:[e.jsx(ae,{name:"kra_weightage_must_total_100",control:_,render:({field:i})=>e.jsx(oe,{label:"KRA Weightage Must Total 100%",description:"Enforce that all KRA weights for an employee sum to 100%",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"kpi_auto_populate_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Auto-populate KPIs",description:"Automatically pull KPIs from system metrics like attendance",checked:i.value,onChange:i.onChange})}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Max KRAs per Employee"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Maximum number of KRAs that can be assigned to one employee"})]}),e.jsx(V,{type:"number",...Q("max_kras_per_employee"),className:"w-[100px] h-8 text-[12px]"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Max KPIs per KRA"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Maximum number of KPIs that can be linked to a single KRA"})]}),e.jsx(V,{type:"number",...Q("max_kpis_per_kra"),className:"w-[100px] h-8 text-[12px]"})]})]}),e.jsxs(Be,{icon:es,title:"Goal Settings",description:"Configure goal management and progress tracking",children:[e.jsx(ae,{name:"goal_cascading_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Goal Cascading",description:"Allow goals to cascade from company to department to individual level",checked:i.value,onChange:i.onChange})}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Progress Update Frequency"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"How often employees should update goal progress"})]}),e.jsx(ae,{name:"goal_progress_update_frequency",control:_,render:({field:i})=>e.jsxs(re,{value:i.value,onValueChange:i.onChange,children:[e.jsx(ne,{className:"w-[140px] h-8 text-[12px]",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"weekly",children:"Weekly"}),e.jsx(h,{value:"biweekly",children:"Bi-weekly"}),e.jsx(h,{value:"monthly",children:"Monthly"})]})]})})]}),e.jsx(ae,{name:"goal_approval_required",control:_,render:({field:i})=>e.jsx(oe,{label:"Goal Approval Required",description:"Goals must be approved by manager before becoming active",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"okr_framework_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"OKR Framework",description:"Enable Objectives and Key Results framework",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"stretch_goals_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Stretch Goals",description:"Allow employees to set stretch (aspirational) goals",checked:i.value,onChange:i.onChange})})]}),e.jsxs(Be,{icon:Fs,title:"Review Cycle Settings",description:"Configure how performance reviews are conducted",children:[e.jsx(ae,{name:"self_review_mandatory",control:_,render:({field:i})=>e.jsx(oe,{label:"Self Review Mandatory",description:"Require employees to complete self-assessment before manager review",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"peer_review_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Peer Review",description:"Enable peer-to-peer performance reviews",checked:i.value,onChange:i.onChange})}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Min Peer Reviewers"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Minimum number of peers required for peer review"})]}),e.jsx(V,{type:"number",...Q("peer_review_min_count"),className:"w-[100px] h-8 text-[12px]"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Peer Selection By"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Who selects the peer reviewers"})]}),e.jsx(ae,{name:"peer_selection_by",control:_,render:({field:i})=>e.jsxs(re,{value:i.value,onValueChange:i.onChange,children:[e.jsx(ne,{className:"w-[140px] h-8 text-[12px]",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"employee",children:"Employee"}),e.jsx(h,{value:"manager",children:"Manager"}),e.jsx(h,{value:"hr",children:"HR"}),e.jsx(h,{value:"both",children:"Both"})]})]})})]}),e.jsx(ae,{name:"upward_review_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Upward Review",description:"Allow employees to review their managers",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"skip_level_review_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Skip-level Review",description:"Enable skip-level manager reviews",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"rating_justification_required",control:_,render:({field:i})=>e.jsx(oe,{label:"Rating Justification Required",description:"Require comments when self vs manager rating differs beyond threshold",checked:i.value,onChange:i.onChange})}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Rating Difference Threshold"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Rating difference that triggers mandatory justification"})]}),e.jsx(V,{type:"number",...Q("rating_diff_threshold"),className:"w-[100px] h-8 text-[12px]"})]})]}),e.jsxs(Be,{icon:xs,title:"Calibration Settings",description:"Configure rating calibration and bell curve enforcement",children:[e.jsx(ae,{name:"calibration_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Calibration Enabled",description:"Enable calibration sessions for rating alignment across teams",checked:i.value,onChange:i.onChange})}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Bell Curve Enforcement"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"How strictly the bell curve distribution is enforced"})]}),e.jsx(ae,{name:"bell_curve_enforcement",control:_,render:({field:i})=>e.jsxs(re,{value:i.value,onValueChange:i.onChange,children:[e.jsx(ne,{className:"w-[160px] h-8 text-[12px]",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"none",children:"None"}),e.jsx(h,{value:"soft",children:"Soft Guideline"}),e.jsx(h,{value:"hard",children:"Hard Limit"})]})]})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Bell Curve Tolerance (%)"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Allowed variance from target distribution percentage"})]}),e.jsx(V,{type:"number",...Q("bell_curve_tolerance_pct"),className:"w-[100px] h-8 text-[12px]"})]})]}),e.jsxs(Be,{icon:is,title:"PIP Settings",description:"Configure Performance Improvement Plan defaults",children:[e.jsx(ae,{name:"pip_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"PIP Enabled",description:"Enable Performance Improvement Plans for underperforming employees",checked:i.value,onChange:i.onChange})}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Auto-trigger Rating"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Auto-suggest PIP below this rating (0 = disabled)"})]}),e.jsx(V,{type:"number",...Q("pip_auto_trigger_rating"),className:"w-[100px] h-8 text-[12px]"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"Default Duration (weeks)"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Default number of weeks for a PIP"})]}),e.jsx(V,{type:"number",...Q("pip_default_duration_weeks"),className:"w-[100px] h-8 text-[12px]"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-medium text-slate-700",children:"PIP Review Frequency"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"How often PIP progress is reviewed"})]}),e.jsx(ae,{name:"pip_review_frequency",control:_,render:({field:i})=>e.jsxs(re,{value:i.value,onValueChange:i.onChange,children:[e.jsx(ne,{className:"w-[140px] h-8 text-[12px]",children:e.jsx(ie,{})}),e.jsxs(le,{children:[e.jsx(h,{value:"weekly",children:"Weekly"}),e.jsx(h,{value:"biweekly",children:"Bi-weekly"}),e.jsx(h,{value:"monthly",children:"Monthly"})]})]})})]})]}),e.jsxs(Be,{icon:js,title:"Recognition & Rewards",description:"Configure employee recognition and rewards programs",children:[e.jsx(ae,{name:"recognition_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Recognition Enabled",description:"Enable the employee recognition system",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"peer_recognition_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Peer Recognition",description:"Allow employees to recognize each other",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"recognition_points_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Points System",description:"Enable point-based recognition tracking",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"recognition_approval_required",control:_,render:({field:i})=>e.jsx(oe,{label:"Approval Required",description:"Require manager approval for recognitions",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"rewards_catalog_enabled",control:_,render:({field:i})=>e.jsx(oe,{label:"Rewards Catalog",description:"Enable a catalog of redeemable rewards",checked:i.value,onChange:i.onChange})})]}),e.jsxs(Be,{icon:et,title:"Notifications",description:"Configure performance module notification preferences",children:[e.jsx(ae,{name:"notify_goal_check_in_reminder",control:_,render:({field:i})=>e.jsx(oe,{label:"Goal Check-in Reminder",description:"Send reminders for goal progress check-ins",checked:i.value,onChange:i.onChange})}),e.jsx(ae,{name:"notify_pip_milestone_reminder",control:_,render:({field:i})=>e.jsx(oe,{label:"PIP Milestone Reminder",description:"Send reminders when PIP milestones are approaching",checked:i.value,onChange:i.onChange})})]}),d&&e.jsx("div",{className:"flex justify-end pt-2 pb-4",children:e.jsx(w,{type:"submit",disabled:!G||a.isPending,className:"min-w-[120px]",children:a.isPending?e.jsxs(e.Fragment,{children:[e.jsx(st,{className:"mr-2 h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})})]})]})}const pr=ge({name:q().min(1,"Name is required"),code:q().min(1,"Code is required"),min_value:Pe.number().int().min(0,"Min value must be >= 0"),max_value:Pe.number().int().min(1,"Max value must be >= 1"),is_default:ee()}).refine(s=>s.max_value>s.min_value,{message:"Max value must be greater than min value",path:["max_value"]});function os(s){return Array.isArray(s.ratings)?s.ratings:[]}function Gn(){const[s,t]=P.useState(!1),[a,m]=P.useState(null),[d,_]=P.useState(null),{hasPermission:v,requirePermission:$}=de(),Q=v("performance","rating_scale","create"),G=v("performance","rating_scale","update"),L=v("performance","rating_scale","delete"),{pagination:i,setPagination:O,sorting:U,setSorting:M,globalFilter:E,setGlobalFilter:Y,queryParams:H}=je(),{data:A,isLoading:B}=ft(H),k=(A==null?void 0:A.results)??[],b=jt(),z=_t(),I=yt(),S=xe({resolver:he(pr),defaultValues:{name:"",code:"",min_value:1,max_value:5,is_default:!1}});function u(){$("performance","rating_scale","create")&&(m(null),S.reset({name:"",code:"",min_value:1,max_value:5,is_default:!1}),t(!0))}function g(o){if(!$("performance","rating_scale","update"))return;m(o);const W=os(o).map(C=>C.value);S.reset({name:o.name,code:o.code,min_value:W.length>0?Math.min(...W):1,max_value:W.length>0?Math.max(...W):5,is_default:o.is_default}),t(!0)}function K(o){const W=[];for(let y=o.min_value;y<=o.max_value;y++)W.push({value:y,label:`Level ${y}`,description:"",color:""});const C={name:o.name,code:o.code,ratings:W,is_default:o.is_default};a?z.mutate({id:a.id,...C},{onSuccess:()=>t(!1)}):b.mutate(C,{onSuccess:()=>t(!1)})}function X(){d&&I.mutate(d.id,{onSuccess:()=>_(null)})}const n=[{key:"name",header:"Name",render:o=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:o.name})},{key:"code",header:"Code",render:o=>e.jsx("span",{className:"text-[13px] text-slate-600",children:o.code||"-"})},{key:"min_value",header:"Min",render:o=>{const W=os(o).map(C=>C.value);return e.jsx("span",{className:"text-[13px] text-slate-600",children:W.length>0?Math.min(...W):"-"})}},{key:"max_value",header:"Max",render:o=>{const W=os(o).map(C=>C.value);return e.jsx("span",{className:"text-[13px] text-slate-600",children:W.length>0?Math.max(...W):"-"})}},{key:"is_default",header:"Default",render:o=>e.jsx(ce,{variant:o.is_default?"success":"secondary",className:"text-[11px]",children:o.is_default?"Yes":"No"})},{key:"created_at",header:"Created",render:o=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(o.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:o=>e.jsxs(me,{children:[e.jsx(pe,{asChild:!0,children:e.jsx(w,{variant:"ghost",size:"icon-sm",children:e.jsx(_e,{className:"h-4 w-4"})})}),e.jsxs(ue,{align:"end",children:[G&&e.jsxs(Z,{onClick:()=>g(o),children:[e.jsx(Re,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),G&&L&&e.jsx(Ue,{}),L&&e.jsxs(Z,{className:"text-red-600",onClick:()=>_(o),children:[e.jsx(Fe,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}];return 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(ot,{className:"h-5 w-5 text-primary"})," Rating Scales"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Define and customize rating scale definitions"})]}),Q&&e.jsxs(w,{size:"sm",onClick:u,children:[e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"})," Add Rating Scale"]})]}),e.jsx(fe,{columns:n,data:k,isLoading:B,searchPlaceholder:"Search rating scales...",emptyMessage:"No rating scales",emptyDescription:"Add your first rating scale to define performance evaluation criteria.",totalCount:(A==null?void 0:A.count)??0,pagination:i,onPaginationChange:O,sorting:U,onSortingChange:M,globalFilter:E,onGlobalFilterChange:Y}),e.jsx(ve,{open:s,onOpenChange:t,children:e.jsxs(be,{size:"md",children:[e.jsxs(Ne,{children:[e.jsx(we,{children:a?"Edit Rating Scale":"Add Rating Scale"}),e.jsx(Se,{children:a?"Update rating scale details.":"Create a new rating scale for performance evaluations."})]}),e.jsxs("form",{onSubmit:S.handleSubmit(K),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(V,{...S.register("name"),className:"mt-1.5",placeholder:"e.g. 5-Point Scale"}),S.formState.errors.name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:S.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(V,{...S.register("code"),className:"mt-1.5",placeholder:"e.g. RS-5PT"}),S.formState.errors.code&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:S.formState.errors.code.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Min Value *"}),e.jsx(V,{type:"number",...S.register("min_value",{valueAsNumber:!0}),className:"mt-1.5",placeholder:"1"}),S.formState.errors.min_value&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:S.formState.errors.min_value.message})]}),e.jsxs("div",{children:[e.jsx(p,{className:"text-[12px] font-medium text-slate-500",children:"Max Value *"}),e.jsx(V,{type:"number",...S.register("max_value",{valueAsNumber:!0}),className:"mt-1.5",placeholder:"5"}),S.formState.errors.max_value&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:S.formState.errors.max_value.message})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx(Ae,{id:"is_default",checked:S.watch("is_default"),onCheckedChange:o=>S.setValue("is_default",!!o)}),e.jsx(p,{htmlFor:"is_default",className:"text-[12px] font-medium text-slate-500 cursor-pointer",children:"Set as default rating scale"})]})]}),e.jsxs(ke,{children:[e.jsx(w,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(w,{onClick:S.handleSubmit(K),disabled:b.isPending||z.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(Ee,{open:!!d,onOpenChange:o=>!o&&_(null),children:e.jsxs(De,{children:[e.jsxs($e,{children:[e.jsx(Ve,{children:"Delete rating scale?"}),e.jsxs(Ie,{children:["This will permanently delete ",e.jsx("strong",{children:d==null?void 0:d.name})," and all associated data."]})]}),e.jsxs(Qe,{children:[e.jsx(Le,{children:"Cancel"}),e.jsx(Te,{variant:"destructive",onClick:X,children:"Delete"})]})]})})]})}function On(){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(ms,{className:"h-5 w-5 text-primary"})," Performance Reports"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"View performance reports and metrics"})]})}),e.jsxs(ze,{children:[e.jsx(Je,{children:e.jsx(Xe,{className:"text-[14px] font-semibold",children:"Reports Dashboard"})}),e.jsx(Me,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ms,{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:"View performance reports and metrics including rating distributions, completion rates, and department comparisons."})]})})]})]})}function Un(){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(ps,{className:"h-5 w-5 text-primary"})," Performance Analytics"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Explore performance trends and analytics"})]})}),e.jsxs(ze,{children:[e.jsx(Je,{children:e.jsx(Xe,{className:"text-[14px] font-semibold",children:"Analytics Dashboard"})}),e.jsx(Me,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ps,{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:"Explore performance trends and analytics with interactive charts, department benchmarks, and predictive insights."})]})})]})]})}export{Pn as AppraisalFormsPage,Tn as BadgesPage,In as CalibrationPage,Dn as CompetencyAssignmentsPage,En as CompetencyFrameworkPage,Cn as EmployeeReviewsPage,Rn as GoalProgressPage,qn as GoalsPage,An as KPILibraryPage,Kn as KRAAssignmentsPage,Fn as KRALibraryPage,Qn as PIPPage,Un as PerformanceAnalyticsPage,Sn as PerformanceDashboardPage,$n as PerformanceFeedbackPage,en as PerformanceLayout,On as PerformanceReportsPage,Mn as PerformanceSettingsPage,Vn as QuestionnairesPage,Gn as RatingScalesPage,zn as RecognitionPage,Ln as RecognitionProgramsPage,kn as ReviewCyclesPage,ea as useAppraisalForms,wa as useApproveRecognition,Ot as useApproveReview,gn as useCalibrationAdjustments,oa as useCalibrationSessions,Yt as useCascadeGoal,ga as useClosePIP,zt as useCloseReviewCycle,wt as useCompetencyAssignments,Ks as useCompetencyFrameworks,sa as useCreateAppraisalForm,fn as useCreateCalibrationAdjustment,da as useCreateCalibrationSession,St as useCreateCompetencyAssignment,vt as useCreateCompetencyFramework,cn as useCreateEmployeeReview,aa as useCreateFeedbackQuestionnaire,ia as useCreateFeedbackRequest,xn as useCreateFeedbackResponse,Bt as useCreateGoal,pn as useCreateGoalComment,Jt as useCreateGoalProgress,Ft as useCreateKPI,tn as useCreateKPIAssignment,Ct as useCreateKRA,Dt as useCreateKRAAssignment,xa as useCreatePIP,_n as useCreatePIPMilestone,bn as useCreatePIPReview,jt as useCreateRatingScale,Na as useCreateRecognition,_a as useCreateRecognitionBadge,fa as useCreateRecognitionProgram,wn as useCreateRecognitionReaction,It as useCreateReviewCycle,rn as useCreateReviewStage,pa as useDeleteCalibrationSession,Nt as useDeleteCompetencyFramework,ca as useDeleteFeedbackRequest,Wt as useDeleteGoal,Xt as useDeleteGoalProgress,Kt as useDeleteKPI,qt as useDeleteKRA,Vt as useDeleteKRAAssignment,yt as useDeleteRatingScale,va as useDeleteRecognitionBadge,Lt as useDeleteReviewCycle,ln as useEmployeeReviewDetail,Ds as useEmployeeReviews,$s as useFeedbackQuestionnaires,na as useFeedbackRequests,un as useFeedbackResponses,hn as useFinalizeCalibration,mn as useGoalComments,dn as useGoalDetail,Zt as useGoalProgressList,ws as useGoals,sn as useKPIAssignments,Rt as useKPILibrary,Et as useKRAAssignments,Es as useKRALibrary,Tt as useLaunchReviewCycle,Mt as useLockRatings,jn as usePIPMilestones,vn as usePIPReviews,ua as usePIPs,ka as usePerformanceDashboard,ht as usePerformanceSettings,ft as useRatingScales,Is as useRecognitionBadges,Vs as useRecognitionPrograms,Nn as useRecognitionReactions,ba as useRecognitions,We as useReviewCycles,an as useReviewStages,ta as useSubmitAppraisal,Gt as useSubmitReview,ma as useUpdateCalibrationSession,kt as useUpdateCompetencyAssignment,bt as useUpdateCompetencyFramework,on as useUpdateEmployeeReview,ra as useUpdateFeedbackQuestionnaire,la as useUpdateFeedbackRequest,Ht as useUpdateGoal,At as useUpdateKPI,Pt as useUpdateKRA,$t as useUpdateKRAAssignment,ha as useUpdatePIP,yn as useUpdatePIPMilestone,gt as useUpdatePerformanceSettings,_t as useUpdateRatingScale,ya as useUpdateRecognitionBadge,ja as useUpdateRecognitionProgram,Qt as useUpdateReviewCycle,nn as useUpdateReviewStage};
