import{j as e,b as $,a as k,u as oe}from"./query-PJ0ZdjbV.js";import{f as un,a as h,O as pn,k as hn,u as hs,j as $s,L as xs,l as As}from"./vendor-CWhr2lg4.js";import{a2 as Qt,b0 as et,b_ as Na,bz as ws,bf as jn,ap as es,p as j,a4 as l,B as P,d as Ft,h as Pt,e as Tt,f as Vt,a as ba,P as Ue,s as Ce,t as Se,v as we,w as ke,x as q,aa as De,ab as Ee,ac as Te,ad as Ve,ae as Ie,q as o,I as b,r as Ae,b as Lt,af as Qe,Q as mt,V as xt,W as ut,Y as pt,Z as ht,_ as jt,$ as gt,a0 as vt,ag as it,ah as rt,ai as lt,aj as B,ak as We,y as ft,at as rs,N as $t,aT as ls,aU as gn,bU as fn,U as _n,T as vn,av as bt,ax as Ct,ay as St,az as wt,a6 as Wt,cn as Ns,aA as Yt,al as ms,a$ as bs,C as yn,a5 as Nn,L as bn,bu as Cn,a8 as Sn,ba as Ca,bb as Sa,bc as ts,bd as ss,z as wa,au as ka,co as wn,b$ as Rs,aL as Ds,bY as kn,G as qn,H as Fn,J as ia,K as Gt,O as Pn,a1 as Ht}from"./index-BSPIaiZU.js";import{L as $n}from"./layout-dashboard-pgzECxsO.js";import{F as kt}from"./file-text-BeBoTfpI.js";import{L as ns}from"./layers-DdTlMVfO.js";import{D as qa}from"./dollar-sign-yf9aN9ug.js";import{U as Es}from"./users-round-Co0Z9sI2.js";import{U as us}from"./user-check-B2v_CMeM.js";import{C as Ts}from"./calendar-clock-ZqVNPbD8.js";import{G as Vs}from"./gift-DT0Mx4Cc.js";import{M as as}from"./message-square-CrQ4L-TW.js";import{C as Os}from"./clipboard-list-DCTO70_z.js";import{B as Fa}from"./briefcase-ChU_EMgZ.js";import{G as Pa}from"./git-branch-DrD8zRaR.js";import{L as Ls}from"./list-ordered-Dn0jhaqK.js";import{F as ks}from"./file-chart-column-increasing-DonUpE5r.js";import{C as qs}from"./chart-column-DbfNf7gS.js";import{B as le}from"./badge-C34iUAiA.js";import{P as An}from"./page-header-D8tSLbK0.js";import{A as $a}from"./arrow-right-Bmt6JCm_.js";import{T as Rn}from"./trending-up-Cognoqa9.js";import{u as Ye,t as nt,o as ct,g as Aa,s as C,p as Cs,c as Me,b as ge,e as Ra,a as Pe,l as Dn}from"./date-range-picker-BB0TgAn8.js";import{A as me}from"./async-select-BUbwdJEZ.js";import{u as tt}from"./use-data-table-state-CKRg6qY2.js";import{u as Ut,a as En,B as Da,i as Tn,N as Vn,J as Ea,F as On}from"./system-admin.api-BT5u-_A_.js";import{D as st}from"./data-table-D_-xOEqd.js";import{a as Is,i as Ta,w as Ln}from"./date-validation-D9gNvaP9.js";import{L as ps}from"./lock-mVL2BhFn.js";import{E as ot}from"./ellipsis-DaNBIBaV.js";import{E as Et}from"./eye-DlIcvqP-.js";import{P as at}from"./pencil-Dl5fXQYl.js";import{S as Kt}from"./send-hExJQKXK.js";import{A as Va,D as be}from"./approval-detail-layout-CcJbUOlS.js";import{C as It}from"./circle-check-big-DY9NZlUS.js";import{C as cs}from"./circle-x-C0sF-Oht.js";import{R as Oa}from"./rotate-ccw-u1EtXcFp.js";import{B as In}from"./ban-B36B5PRf.js";import{a as js,a3 as Kn}from"./core-hr.api-MChaGqvv.js";import{R as Fs}from"./refresh-cw-DkxP9YPQ.js";import{p as zn}from"./payroll.api-CdAqb0T2.js";import{A as Mn}from"./approval-status-pill-FaqYhoSe.js";import{R as Qn}from"./rich-text-editor-DrppaLvL.js";import{S as is}from"./star-DLH_J9Ff.js";import{H as Un}from"./handshake-CnzSMc0F.js";import{A as ra}from"./arrow-left-right-Ds_pa_I7.js";import{H as la}from"./history-BtMjBzl1.js";import{S as Bn}from"./skeleton-CfUgaIb_.js";import{G as Gn}from"./globe-BTv0oSL0.js";import{F as Hn}from"./filter-C3JUOujf.js";import{F as Jn}from"./file-check-CTWievMk.js";import{S as Wn}from"./shield-7SCLx_iT.js";import{S as La}from"./status-badge-DPaiL_rL.js";import{C as Ia}from"./circle-check-Dgh1V3VA.js";import{M as Yn}from"./message-circle-DRPiqW4z.js";import{f as Zn}from"./format-Bw_hER4B.js";import{p as Xn}from"./parseISO-CsaAlwIQ.js";import{A as ei}from"./arrow-left-CtkbIigo.js";import"./ui-aO-W1bxx.js";import"./chevron-left-DLFf1YD2.js";import"./circle-alert-9pjtMKqA.js";import"./with-selector-CmGJjsAK.js";import"./index-Dh4i1-J3.js";import"./link-2-zJB3uZzB.js";import"./undo-2-CyjnlLm8.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 Ks=Qt("BellRing",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]);/**
 * @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 ca=Qt("ClipboardPenLine",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",key:"1oijnt"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-.5",key:"1but9f"}],["path",{d:"M16 4h2a2 2 0 0 1 1.73 1",key:"1p8n7l"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M21.378 12.626a1 1 0 0 0-3.004-3.004l-4.01 4.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"2t3380"}]]);/**
 * @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 Ss=Qt("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
 * @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 ti=Qt("MessageSquareReply",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"m10 7-3 3 3 3",key:"1eugdv"}],["path",{d:"M17 13v-1a2 2 0 0 0-2-2H7",key:"ernfh3"}]]);/**
 * @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 si=Qt("SkipForward",[["polygon",{points:"5 4 15 12 5 20 5 4",key:"16p6eg"}],["line",{x1:"19",x2:"19",y1:"5",y2:"19",key:"futhcm"}]]);/**
 * @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 ai=Qt("StickyNote",[["path",{d:"M16 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V8Z",key:"qazsjp"}],["path",{d:"M15 3v4a2 2 0 0 0 2 2h4",key:"40519r"}]]);/**
 * @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 ni=Qt("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]),ii=[{heading:"Overview",items:[{to:"/recruitment",label:"Dashboard",description:"Recruitment overview",icon:$n,permission:["recruitment","dashboard","read"]}]},{heading:"Hiring",items:[{to:"/recruitment/requisitions",label:"Requisitions",description:"Hiring requests",icon:kt,permission:["recruitment","requisition","read"]},{to:"/recruitment/requisition-categories",label:"Categories",description:"Interview process groups",icon:ns,permission:["recruitment","requisition","read"]},{to:"/recruitment/cost-confirmations",label:"Cost Confirmations",description:"Cost justifications",icon:qa,permission:["recruitment","cost_confirmation","read"]},{to:"/recruitment/applications",label:"Applications",description:"Candidate pipeline",icon:Es,permission:["recruitment","application","read"]},{to:"/recruitment/candidates",label:"Candidates",description:"Talent pool",icon:us,permission:["recruitment","candidate","read"]}]},{heading:"Interviews",items:[{to:"/recruitment/interviews",label:"Interviews",description:"Schedule & track",icon:Ts,permission:["recruitment","interview","read"]},{to:"/recruitment/evaluations",label:"Evaluations",description:"Feedback & scores",icon:Na,permission:["recruitment","evaluation","read"]},{to:"/recruitment/assessments",label:"Assessment Ratings",description:"View & export ratings",icon:ca,permission:["recruitment","assessment","read"]}]},{heading:"Offers",items:[{to:"/recruitment/offers",label:"Offers",description:"Offer management",icon:Vs,permission:["recruitment","offer","read"]},{to:"/recruitment/offer-templates",label:"Offer Templates",description:"Letter templates",icon:kt,permission:["recruitment","offer_template","read"]},{to:"/recruitment/candidate-responses",label:"Candidate Responses",description:"Track offer responses",icon:as,permission:["recruitment","offer","read"]},{to:"/recruitment/negotiations",label:"Negotiations",description:"Counter offers",icon:as,permission:["recruitment","negotiation","read"]}]},{heading:"Onboarding",items:[{to:"/recruitment/onboarding",label:"Onboarding",description:"Pre-joining & onboarding",icon:Os,permission:["recruitment","offer","read"]}]},{heading:"Configuration",items:[{to:"/recruitment/settings",label:"Settings",description:"Module settings",icon:ws,permission:["recruitment","settings","read"]},{to:"/recruitment/business-needs",label:"Business Needs",description:"Hiring justifications",icon:Fa,permission:["recruitment","settings","read"]},{to:"/recruitment/pipeline-stages",label:"Application Stages",description:"ATS stages",icon:Pa,permission:["recruitment","pipeline","read"]},{to:"/recruitment/interview-rounds",label:"Interview Rounds",description:"Round definitions",icon:Ls,permission:["recruitment","interview","read"]},{to:"/recruitment/assessment-templates",label:"Assessment Templates",description:"Templates & domains",icon:ca,permission:["recruitment","assessment","read"]},{to:"/recruitment/position-levels",label:"Position Levels",description:"Assessment categories",icon:ns,permission:["recruitment","settings","read"]}]},{heading:"Insights",items:[{to:"/recruitment/reports",label:"Reports",description:"Recruitment reports",icon:ks,permission:["recruitment","report","read"]},{to:"/recruitment/analytics",label:"Analytics",description:"Trends & insights",icon:qs,permission:["recruitment","analytics","read"]}]}];function ri({item:s,isActive:t}){const a=s.icon;return e.jsxs(hn,{to:s.to,end:s.to==="/recruitment",className:es("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:es("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:es("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:es("block text-[11px] truncate leading-tight mt-0.5",t?"text-primary/60":"text-slate-400"),children:s.description})]})]})}function so(){const s=un(),t=h.useRef(null),{hasPermission:a}=et();h.useEffect(()=>{var i;(i=t.current)==null||i.scrollTo(0,0)},[s.pathname]);const n=h.useMemo(()=>ii.map(i=>({...i,items:i.items.filter(u=>a(u.permission[0],u.permission[1],u.permission[2]))})).filter(i=>i.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:"Recruitment"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-slate-400",children:"Requisitions, candidates & offers"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-3 py-3 scrollbar-thin",children:n.map((i,u)=>e.jsxs("div",{className:es(u>0&&"mt-6"),children:[e.jsx("p",{className:"mb-2 px-3 text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400",children:i.heading}),e.jsx("div",{className:"space-y-0.5",children:i.items.map(r=>{const N=r.to==="/recruitment"?s.pathname==="/recruitment":jn(s.pathname,r.to);return e.jsx(ri,{item:r,isActive:N},r.to)})})]},i.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(pn,{})})})]})}const g="/recruitment",p={settings:["recruitment","settings"],businessNeeds:["recruitment","business-needs"],requisitions:["recruitment","requisitions"],requisition:s=>["recruitment","requisitions",s],costConfirmations:["recruitment","cost-confirmations"],pipelineStages:["recruitment","pipeline-stages"],requisitionCategories:["recruitment","requisition-categories"],rejectionReasons:["recruitment","rejection-reasons"],candidates:["recruitment","candidates"],candidate:s=>["recruitment","candidates",s],postings:["recruitment","postings"],posting:s=>["recruitment","postings",s],applications:["recruitment","applications"],application:s=>["recruitment","applications",s],interviewRounds:["recruitment","interview-rounds"],evaluationForms:["recruitment","evaluation-forms"],interviews:["recruitment","interviews"],interview:s=>["recruitment","interviews",s],interviewPanels:["recruitment","interview-panels"],interviewEvaluations:["recruitment","interview-evaluations"],offerTemplates:["recruitment","offer-templates"],serviceContracts:["recruitment","service-contracts"],offers:["recruitment","offers"],offer:s=>["recruitment","offers",s],negotiations:["recruitment","negotiations"],bgvVendors:["recruitment","bgv-vendors"],verifications:["recruitment","verifications"],referenceChecks:["recruitment","reference-checks"],drives:["recruitment","drives"],campusPartners:["recruitment","campus-partners"],candidateActivities:s=>["recruitment","activities",s],candidateNotes:s=>["recruitment","notes",s],dashboard:["recruitment","dashboard"],positionLevels:["recruitment","position-levels"],assessmentTemplates:["recruitment","assessment-templates"],assessmentTemplate:s=>["recruitment","assessment-templates",s],assessmentDomains:s=>["recruitment","assessment-domains",s],assessments:["recruitment","assessments"],candidateAssessments:s=>["recruitment","assessments","candidate",s],assessment:s=>["recruitment","assessments",s]};function li(){return oe({queryKey:p.settings,queryFn:async()=>{var t;return((t=(await j.get(`${g}/settings/`)).data.results)==null?void 0:t[0])??null}})}function ci(){const s=$();return k({mutationFn:async t=>{var r;const{id:a,...n}=t;if(a)return j.patch(`${g}/settings/${a}/`,n).then(N=>N.data);const u=(r=(await j.get(`${g}/settings/`)).data.results)==null?void 0:r[0];return u?j.patch(`${g}/settings/${u.id}/`,n).then(N=>N.data):j.post(`${g}/settings/`,n).then(N=>N.data)},onSuccess:()=>{s.invalidateQueries({queryKey:p.settings}),l.success("Settings updated")},onError:()=>l.error("Failed to update settings")})}function Ka(s){return oe({queryKey:[...p.businessNeeds,s],queryFn:()=>j.get(`${g}/business-needs/`,{params:s}).then(t=>t.data)})}function oi(){const s=$();return k({mutationFn:t=>j.post(`${g}/business-needs/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.businessNeeds}),l.success("Business need created")},onError:()=>l.error("Failed to create business need")})}function di(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/business-needs/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.businessNeeds}),l.success("Business need updated")},onError:()=>l.error("Failed to update business need")})}function mi(){const s=$();return k({mutationFn:t=>j.delete(`${g}/business-needs/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.businessNeeds}),l.success("Business need deleted")},onError:()=>l.error("Failed to delete business need")})}function zs(s){return oe({queryKey:[...p.requisitions,s],queryFn:()=>j.get(`${g}/requisitions/`,{params:s}).then(t=>t.data)})}function Ps(s){return oe({queryKey:p.requisition(s),queryFn:()=>j.get(`${g}/requisitions/${s}/`).then(t=>t.data),enabled:!!s})}function xi(){const s=$();return k({mutationFn:t=>{const a=["annual_ctc","placement_consultant_cost","training_cost","other_costs","budget_min","budget_max"],n={...t};return a.forEach(i=>{(n[i]===""||n[i]===void 0)&&(n[i]="0")}),j.post(`${g}/requisitions/`,n).then(i=>i.data)},onSuccess:()=>{s.invalidateQueries({queryKey:p.requisitions}),l.success("Requisition created")},onError:t=>{var n;const a=(n=t==null?void 0:t.response)==null?void 0:n.data;if(a){const i=Object.entries(a).map(([u,r])=>`${u}: ${Array.isArray(r)?r.join(", "):String(r)}`).join("; ");l.error(i||"Failed to create requisition")}else l.error("Failed to create requisition")}})}function ui(){const s=$();return k({mutationFn:({id:t,...a})=>{const n=["annual_ctc","placement_consultant_cost","training_cost","other_costs","budget_min","budget_max"],i={...a};return n.forEach(u=>{(i[u]===""||i[u]===void 0)&&(i[u]="0")}),j.patch(`${g}/requisitions/${t}/`,i).then(u=>u.data)},onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.requisitions}),s.invalidateQueries({queryKey:p.requisition(a.id)}),l.success("Requisition updated")},onError:t=>{var n;const a=(n=t==null?void 0:t.response)==null?void 0:n.data;if(a){const i=Object.entries(a).map(([u,r])=>`${u}: ${Array.isArray(r)?r.join(", "):String(r)}`).join("; ");l.error(i||"Failed to update requisition")}else l.error("Failed to update requisition")}})}function pi(){const s=$();return k({mutationFn:t=>j.delete(`${g}/requisitions/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.requisitions}),l.success("Requisition deleted")},onError:()=>l.error("Failed to delete requisition")})}function hi(){const s=$();return k({mutationFn:t=>j.post(`${g}/requisitions/${t}/submit/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.requisitions}),l.success("Requisition submitted for approval")},onError:()=>l.error("Failed to submit requisition")})}function ao(){const s=$();return k({mutationFn:({id:t,action:a,remarks:n})=>j.post(`${g}/requisitions/${t}/${a}/`,{remarks:n}).then(i=>i.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.requisitions}),l.success(`Requisition ${a.action==="approve"?"approved":"rejected"}`)},onError:()=>l.error("Failed to process requisition")})}function no(){const s=$();return k({mutationFn:t=>j.post(`${g}/requisitions/${t}/publish/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.requisitions}),l.success("Requisition published")},onError:()=>l.error("Failed to publish requisition")})}function ji(){const s=$();return k({mutationFn:t=>j.post(`${g}/requisitions/${t}/close/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.requisitions}),l.success("Requisition closed")},onError:()=>l.error("Failed to close requisition")})}function gi(){const s=$();return k({mutationFn:t=>j.post(`${g}/requisitions/${t}/revert-to-draft/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.requisitions}),l.success("Requisition reverted to draft")},onError:()=>l.error("Failed to revert requisition")})}function fi(s){return oe({queryKey:[...p.costConfirmations,s],queryFn:()=>j.get(`${g}/cost-confirmations/`,{params:s}).then(t=>t.data)})}function _i(s){return oe({queryKey:[...p.costConfirmations,s],queryFn:()=>j.get(`${g}/cost-confirmations/${s}/`).then(t=>t.data),enabled:!!s})}function vi(){const s=$();return k({mutationFn:t=>{const a=["annual_ctc","placement_consultant_cost","training_cost","other_costs"],n={...t};return a.forEach(i=>{(n[i]===""||n[i]===void 0)&&(n[i]="0")}),j.post(`${g}/cost-confirmations/`,n).then(i=>i.data)},onSuccess:()=>{s.invalidateQueries({queryKey:p.costConfirmations}),l.success("Cost confirmation created")},onError:t=>{var n;const a=(n=t==null?void 0:t.response)==null?void 0:n.data;if(a){const i=Object.entries(a).map(([u,r])=>`${u}: ${Array.isArray(r)?r.join(", "):String(r)}`).join("; ");l.error(i||"Failed to create cost confirmation")}else l.error("Failed to create cost confirmation")}})}function yi(){const s=$();return k({mutationFn:({id:t,...a})=>{const n=["annual_ctc","placement_consultant_cost","training_cost","other_costs"],i={...a};return n.forEach(u=>{(i[u]===""||i[u]===void 0)&&(i[u]="0")}),j.patch(`${g}/cost-confirmations/${t}/`,i).then(u=>u.data)},onSuccess:()=>{s.invalidateQueries({queryKey:p.costConfirmations}),l.success("Cost confirmation updated")},onError:t=>{var n;const a=(n=t==null?void 0:t.response)==null?void 0:n.data;if(a){const i=Object.entries(a).map(([u,r])=>`${u}: ${Array.isArray(r)?r.join(", "):String(r)}`).join("; ");l.error(i||"Failed to update cost confirmation")}else l.error("Failed to update cost confirmation")}})}function Ni(){const s=$();return k({mutationFn:t=>j.delete(`${g}/cost-confirmations/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.costConfirmations}),l.success("Cost confirmation deleted")},onError:()=>l.error("Failed to delete cost confirmation")})}function bi(){const s=$();return k({mutationFn:t=>j.post(`${g}/cost-confirmations/${t}/submit/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.costConfirmations}),l.success("Cost confirmation submitted for approval")},onError:()=>l.error("Failed to submit cost confirmation")})}function Ci(){const s=$();return k({mutationFn:({id:t,action:a,remarks:n})=>j.post(`${g}/cost-confirmations/${t}/${a}/`,{remarks:n}).then(i=>i.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.costConfirmations}),l.success(`Cost confirmation ${a.action==="approve"?"approved":"rejected"}`)},onError:()=>l.error("Failed to process cost confirmation")})}function Ms(s){return oe({queryKey:[...p.requisitionCategories,s],queryFn:()=>j.get(`${g}/requisition-categories/`,{params:s}).then(t=>t.data)})}function Si(){const s=$();return k({mutationFn:t=>j.post(`${g}/requisition-categories/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.requisitionCategories}),l.success("Category created")},onError:()=>l.error("Failed to create category")})}function wi(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/requisition-categories/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.requisitionCategories}),l.success("Category updated")},onError:()=>l.error("Failed to update category")})}function ki(){const s=$();return k({mutationFn:t=>j.delete(`${g}/requisition-categories/${t}/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.requisitionCategories}),l.success("Category deleted")},onError:()=>l.error("Failed to delete category")})}function za(s){return oe({queryKey:[...p.pipelineStages,s],queryFn:()=>j.get(`${g}/pipeline-stages/`,{params:s}).then(t=>t.data)})}function qi(){const s=$();return k({mutationFn:t=>j.post(`${g}/pipeline-stages/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.pipelineStages}),l.success("Application stage created")},onError:()=>l.error("Failed to create application stage")})}function Fi(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/pipeline-stages/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.pipelineStages}),l.success("Application stage updated")},onError:()=>l.error("Failed to update application stage")})}function Pi(){const s=$();return k({mutationFn:t=>j.delete(`${g}/pipeline-stages/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.pipelineStages}),l.success("Application stage deleted")},onError:()=>l.error("Failed to delete application stage")})}function io(s){return oe({queryKey:[...p.rejectionReasons,s],queryFn:()=>j.get(`${g}/rejection-reasons/`,{params:s}).then(t=>t.data)})}function ro(){const s=$();return k({mutationFn:t=>j.post(`${g}/rejection-reasons/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.rejectionReasons}),l.success("Rejection reason created")},onError:()=>l.error("Failed to create rejection reason")})}function lo(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/rejection-reasons/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.rejectionReasons}),l.success("Rejection reason updated")},onError:()=>l.error("Failed to update rejection reason")})}function co(){const s=$();return k({mutationFn:t=>j.delete(`${g}/rejection-reasons/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.rejectionReasons}),l.success("Rejection reason deleted")},onError:()=>l.error("Failed to delete rejection reason")})}function Qs(s){return oe({queryKey:[...p.candidates,s],queryFn:()=>j.get(`${g}/candidates/`,{params:s}).then(t=>t.data)})}function Ma(s){return oe({queryKey:p.candidate(s),queryFn:()=>j.get(`${g}/candidates/${s}/`).then(t=>t.data),enabled:!!s})}function $i(){const s=$();return k({mutationFn:t=>j.post(`${g}/candidates/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.candidates}),l.success("Candidate created")},onError:t=>{var i;const a=(i=t==null?void 0:t.response)==null?void 0:i.data,n=a?Object.entries(a).map(([u,r])=>`${u}: ${Array.isArray(r)?r.join(", "):String(r)}`).join("; "):"";l.error(n||"Failed to create candidate")}})}function Ai(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/candidates/${t}/`,a).then(n=>n.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.candidates}),s.invalidateQueries({queryKey:p.candidate(a.id)}),l.success("Candidate updated")},onError:t=>{var i;const a=(i=t==null?void 0:t.response)==null?void 0:i.data,n=a?Object.entries(a).map(([u,r])=>`${u}: ${Array.isArray(r)?r.join(", "):String(r)}`).join("; "):"";l.error(n||"Failed to update candidate")}})}function Ri(){const s=$();return k({mutationFn:t=>j.delete(`${g}/candidates/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.candidates}),l.success("Candidate deleted")},onError:()=>l.error("Failed to delete candidate")})}function Di(){const s=$();return k({mutationFn:({id:t,reason:a})=>j.post(`${g}/candidates/${t}/blacklist/`,{reason:a}).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.candidates}),l.success("Candidate blacklisted")},onError:()=>l.error("Failed to blacklist candidate")})}function Ei(){const s=$();return k({mutationFn:({id:t,status:a})=>j.patch(`${g}/candidates/${t}/`,{status:a}).then(n=>n.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.candidates}),s.invalidateQueries({queryKey:p.candidate(a.id)}),l.success(`Candidate status changed to ${a.status.replace(/_/g," ")}`)},onError:()=>l.error("Failed to change candidate status")})}function Ti(){const s=$();return k({mutationFn:({id:t,file:a})=>{const n=new FormData;return n.append("resume",a),j.post(`${g}/candidates/${t}/upload-resume/`,n,{headers:{"Content-Type":void 0}}).then(i=>i.data)},onSuccess:()=>{s.invalidateQueries({queryKey:p.candidates}),l.success("Resume uploaded")},onError:()=>l.error("Failed to upload resume")})}function oo(s){return oe({queryKey:[...p.postings,s],queryFn:()=>j.get(`${g}/postings/`,{params:s}).then(t=>t.data)})}function mo(s){return oe({queryKey:p.posting(s),queryFn:()=>j.get(`${g}/postings/${s}/`).then(t=>t.data),enabled:!!s})}function xo(){const s=$();return k({mutationFn:t=>j.post(`${g}/postings/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.postings}),l.success("Job posting created")},onError:()=>l.error("Failed to create posting")})}function uo(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/postings/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.postings}),l.success("Job posting updated")},onError:()=>l.error("Failed to update posting")})}function po(){const s=$();return k({mutationFn:t=>j.delete(`${g}/postings/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.postings}),l.success("Job posting deleted")},onError:()=>l.error("Failed to delete posting")})}function ho(){const s=$();return k({mutationFn:t=>j.post(`${g}/postings/${t}/publish/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.postings}),l.success("Posting published")},onError:()=>l.error("Failed to publish posting")})}function jo(){const s=$();return k({mutationFn:t=>j.post(`${g}/postings/${t}/pause/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.postings}),l.success("Posting paused")},onError:()=>l.error("Failed to pause posting")})}function go(){const s=$();return k({mutationFn:t=>j.post(`${g}/postings/${t}/close/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.postings}),l.success("Posting closed")},onError:()=>l.error("Failed to close posting")})}function gs(s){return oe({queryKey:[...p.applications,s],queryFn:()=>j.get(`${g}/applications/`,{params:s}).then(t=>t.data)})}function fo(s){return oe({queryKey:p.application(s),queryFn:()=>j.get(`${g}/applications/${s}/`).then(t=>t.data),enabled:!!s})}function Vi(){const s=$();return k({mutationFn:t=>j.post(`${g}/applications/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.applications}),s.invalidateQueries({queryKey:p.candidates}),s.invalidateQueries({queryKey:p.postings}),l.success("Application created")},onError:t=>{var n,i;const a=(n=t==null?void 0:t.response)==null?void 0:n.data;(i=a==null?void 0:a.error)!=null&&i.message?l.error(a.error.message):l.error("Failed to create application")}})}function Oi(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/applications/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.applications}),l.success("Application updated")},onError:()=>l.error("Failed to update application")})}function Li(){const s=$();return k({mutationFn:t=>j.delete(`${g}/applications/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.applications}),s.invalidateQueries({queryKey:p.candidates}),l.success("Application deleted")},onError:()=>l.error("Failed to delete application")})}function Ii(){const s=$();return k({mutationFn:({id:t,stage_id:a})=>j.post(`${g}/applications/${t}/move-stage/`,{stage_id:a}).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.applications}),l.success("Application moved to new stage")},onError:()=>l.error("Failed to move application stage")})}function Ki(){const s=$();return k({mutationFn:({id:t,rejection_remarks:a})=>j.post(`${g}/applications/${t}/reject/`,{rejection_remarks:a}).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.applications}),s.invalidateQueries({queryKey:p.interviews}),l.success("Application rejected")},onError:t=>{var n;const a=(n=t==null?void 0:t.response)==null?void 0:n.data;if(a){const i=Object.entries(a).map(([u,r])=>`${u}: ${Array.isArray(r)?r.join(", "):String(r)}`).join("; ");l.error(i||"Failed to reject application")}else l.error("Failed to reject application")}})}function zi(){const s=$();return k({mutationFn:t=>j.post(`${g}/applications/${t}/shortlist/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.applications}),l.success("Application shortlisted")},onError:()=>l.error("Failed to shortlist application")})}function Us(s){return oe({queryKey:[...p.interviewRounds,s],queryFn:()=>j.get(`${g}/interview-rounds/`,{params:s}).then(t=>t.data)})}function Mi(){const s=$();return k({mutationFn:t=>j.post(`${g}/interview-rounds/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviewRounds}),l.success("Interview round created")},onError:()=>l.error("Failed to create interview round")})}function Qi(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/interview-rounds/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviewRounds}),l.success("Interview round updated")},onError:()=>l.error("Failed to update interview round")})}function Ui(){const s=$();return k({mutationFn:t=>j.delete(`${g}/interview-rounds/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviewRounds}),l.success("Interview round deleted")},onError:()=>l.error("Failed to delete interview round")})}function _o(s){return oe({queryKey:[...p.evaluationForms,s],queryFn:()=>j.get(`${g}/evaluation-forms/`,{params:s}).then(t=>t.data)})}function vo(){const s=$();return k({mutationFn:t=>j.post(`${g}/evaluation-forms/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.evaluationForms}),l.success("Evaluation form created")},onError:()=>l.error("Failed to create evaluation form")})}function yo(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/evaluation-forms/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.evaluationForms}),l.success("Evaluation form updated")},onError:()=>l.error("Failed to update evaluation form")})}function No(){const s=$();return k({mutationFn:t=>j.delete(`${g}/evaluation-forms/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.evaluationForms}),l.success("Evaluation form deleted")},onError:()=>l.error("Failed to delete evaluation form")})}function Qa(s){return oe({queryKey:[...p.interviews,s],queryFn:()=>j.get(`${g}/interviews/`,{params:s}).then(t=>t.data)})}function Bi(s){return oe({queryKey:p.interview(s),queryFn:()=>j.get(`${g}/interviews/${s}/`).then(t=>t.data),enabled:!!s})}function Gi(){const s=$();return k({mutationFn:t=>j.post(`${g}/interviews/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviews}),s.invalidateQueries({queryKey:p.applications}),l.success("Interview scheduled")},onError:()=>l.error("Failed to schedule interview")})}function Hi(){const s=$();return k({mutationFn:t=>j.post(`${g}/interviews/bulk-schedule/`,t).then(a=>a.data),onSuccess:t=>{s.invalidateQueries({queryKey:p.interviews}),s.invalidateQueries({queryKey:p.applications});const{created_count:a,skipped_count:n}=t;n>0?l.warning(`Scheduled ${a}, skipped ${n}`):l.success(`Scheduled ${a} interview${a===1?"":"s"}`)},onError:()=>l.error("Failed to schedule interviews")})}function Ji(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/interviews/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviews}),l.success("Interview updated")},onError:()=>l.error("Failed to update interview")})}function Wi(){const s=$();return k({mutationFn:t=>j.post(`${g}/interviews/${t}/complete/`).then(a=>a.data),onSuccess:()=>{s.refetchQueries({queryKey:p.interviews}),l.success("Interview marked complete")},onError:()=>l.error("Failed to complete interview")})}function Yi(){const s=$();return k({mutationFn:({id:t,reason:a})=>j.post(`${g}/interviews/${t}/cancel/`,{cancellation_reason:a}).then(n=>n.data),onSuccess:()=>{s.refetchQueries({queryKey:p.interviews}),l.success("Interview cancelled")},onError:()=>l.error("Failed to cancel interview")})}function Zi(){const s=$();return k({mutationFn:({id:t,scheduled_date:a,start_time:n,end_time:i,reschedule_reason:u})=>j.post(`${g}/interviews/${t}/reschedule/`,{scheduled_date:a,start_time:n,end_time:i,reschedule_reason:u}).then(r=>r.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviews}),l.success("Interview rescheduled")},onError:()=>l.error("Failed to reschedule interview")})}function bo(s){return oe({queryKey:[...p.interviewPanels,s],queryFn:()=>j.get(`${g}/interview-panels/`,{params:s}).then(t=>t.data)})}function Co(){const s=$();return k({mutationFn:t=>j.post(`${g}/interview-panels/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviewPanels}),s.invalidateQueries({queryKey:p.interviews}),l.success("Panel member added")},onError:()=>l.error("Failed to add panel member")})}function So(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/interview-panels/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviewPanels}),l.success("Panel member updated")},onError:()=>l.error("Failed to update panel member")})}function wo(){const s=$();return k({mutationFn:t=>j.delete(`${g}/interview-panels/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviewPanels}),s.invalidateQueries({queryKey:p.interviews}),l.success("Panel member removed")},onError:()=>l.error("Failed to remove panel member")})}function oa(s){return oe({queryKey:[...p.interviewEvaluations,s],queryFn:()=>j.get(`${g}/evaluations/`,{params:s}).then(t=>t.data)})}function Xi(){const s=$();return k({mutationFn:t=>j.post(`${g}/evaluations/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviewEvaluations}),s.invalidateQueries({queryKey:p.interviews}),l.success("Evaluation submitted")},onError:()=>l.error("Failed to submit evaluation")})}function er(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/evaluations/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.interviewEvaluations}),l.success("Evaluation updated")},onError:()=>l.error("Failed to update evaluation")})}function Bs(s){return oe({queryKey:[...p.offerTemplates,s],queryFn:()=>j.get(`${g}/offer-templates/`,{params:s}).then(t=>t.data)})}function tr(){const s=$();return k({mutationFn:t=>j.post(`${g}/offer-templates/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.offerTemplates}),l.success("Offer template created")},onError:()=>l.error("Failed to create offer template")})}function sr(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/offer-templates/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.offerTemplates}),l.success("Offer template updated")},onError:()=>l.error("Failed to update offer template")})}function ar(){const s=$();return k({mutationFn:t=>j.delete(`${g}/offer-templates/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.offerTemplates}),l.success("Offer template deleted")},onError:()=>l.error("Failed to delete offer template")})}function nr(s="offer_letter"){return oe({queryKey:[...p.offerTemplates,"merge-fields",s],queryFn:()=>j.get(`${g}/offer-templates/merge-fields/`,{params:{document_type:s}}).then(t=>t.data),staleTime:3600*1e3})}function ir(s){return oe({queryKey:[...p.serviceContracts,s],queryFn:()=>j.get(`${g}/service-contracts/`,{params:s}).then(t=>t.data)})}function rr(){const s=$();return k({mutationFn:t=>j.post(`${g}/service-contracts/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.serviceContracts}),l.success("Service contract created")},onError:()=>l.error("Failed to create service contract")})}function lr(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/service-contracts/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.serviceContracts}),l.success("Service contract updated")},onError:()=>l.error("Failed to update service contract")})}function cr(){const s=$();return k({mutationFn:t=>j.delete(`${g}/service-contracts/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.serviceContracts}),l.success("Service contract deleted")},onError:()=>l.error("Failed to delete service contract")})}function da(s){const t=$();return k({mutationFn:a=>j.post(`${g}/service-contracts/${a}/${s}/`).then(n=>n.data),onSuccess:()=>{t.invalidateQueries({queryKey:p.serviceContracts}),l.success(s==="issue"?"Contract issued":"Acknowledgement recorded")},onError:()=>l.error(`Failed to ${s} contract`)})}function or(){return k({mutationFn:s=>j.get(`${g}/service-contracts/${s}/download-pdf/`,{responseType:"blob"}).then(t=>t.data),onError:()=>l.error("Failed to generate contract PDF")})}function dr(){return k({mutationFn:s=>j.get(`${g}/offer-templates/${s}/preview/`,{responseType:"blob"}).then(t=>t.data),onError:()=>l.error("Failed to generate preview")})}function Gs(s){return oe({queryKey:[...p.offers,s],queryFn:()=>j.get(`${g}/offers/`,{params:s}).then(t=>t.data)})}function mr(s){return oe({queryKey:p.offer(s),queryFn:()=>j.get(`${g}/offers/${s}/`).then(t=>t.data),enabled:!!s})}function xr(){const s=$();return k({mutationFn:t=>j.post(`${g}/offers/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.offers}),l.success("Offer created")},onError:()=>l.error("Failed to create offer")})}function ur(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/offers/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.offers}),l.success("Offer updated")},onError:()=>l.error("Failed to update offer")})}function pr(){const s=$();return k({mutationFn:t=>j.post(`${g}/offers/${t}/send/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.offers}),l.success("Offer sent to candidate")},onError:()=>l.error("Failed to send offer")})}function ko(){const s=$();return k({mutationFn:({id:t,action:a,remarks:n})=>j.post(`${g}/offers/${t}/${a}/`,{remarks:n}).then(i=>i.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.offers}),l.success(`Offer ${a.action==="approve"?"approved":"rejected"}`)},onError:()=>l.error("Failed to process offer")})}function hr(){const s=$();return k({mutationFn:({id:t,reason:a})=>j.post(`${g}/offers/${t}/withdraw/`,{reason:a}).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.offers}),l.success("Offer withdrawn")},onError:()=>l.error("Failed to withdraw offer")})}function jr(){return k({mutationFn:async s=>({blob:(await j.get(`${g}/offers/${s}/download-pdf/`,{responseType:"blob"})).data,offerId:s}),onError:()=>l.error("Failed to generate offer letter PDF")})}function Hs(){const s=$();return k({mutationFn:t=>j.post(`${g}/offers/${t}/send-pre-joining/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.offers}),l.success("Pre-joining form sent to candidate")},onError:()=>l.error("Failed to send pre-joining form")})}function Js(){return k({mutationFn:s=>j.post(`${g}/offers/${s}/send-joining-reminder/`).then(t=>t.data),onSuccess:()=>l.success("Joining reminder sent to administrator and reporting manager"),onError:s=>{var t,a;return l.error(((a=(t=s==null?void 0:s.response)==null?void 0:t.data)==null?void 0:a.detail)||"Failed to send joining reminder")}})}function gr(s){return oe({queryKey:[...p.offers,"candidate-responses",s],queryFn:()=>j.get(`${g}/offers/candidate-responses/`,{params:s}).then(t=>t.data)})}function Ua(){const s=$();return k({mutationFn:t=>j.post(`${g}/offers/${t}/resend-offer/`).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.offers}),l.success("Offer resent to candidate")},onError:()=>l.error("Failed to resend offer")})}function Ba(){const s=$();return k({mutationFn:({id:t,...a})=>j.post(`${g}/offers/${t}/admin-fill-pre-joining/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.offers}),l.success("Pre-joining form submitted. Employee onboarding initiated.")},onError:t=>{var a,n;return l.error(((n=(a=t==null?void 0:t.response)==null?void 0:a.data)==null?void 0:n.detail)||"Failed to submit pre-joining form")}})}function fr(){return k({mutationFn:s=>j.post(`${g}/offers/compute-breakup/`,s).then(t=>t.data)})}function Ga(s){return oe({queryKey:[...p.offers,s,"pre-joining-admin"],queryFn:()=>j.get(`${g}/offers/${s}/pre-joining-admin/`).then(t=>t.data),enabled:!!s,retry:!1})}function Ha(){const s=$();return k({mutationFn:t=>j.patch(`${g}/offers/${t}/pre-joining-admin/`).then(a=>a.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:[...p.offers,a,"pre-joining-admin"]}),s.invalidateQueries({queryKey:p.offers}),l.success("Pre-joining form marked as reviewed")},onError:()=>l.error("Failed to mark as reviewed")})}function _r(s){return oe({queryKey:[...p.negotiations,s],queryFn:()=>j.get(`${g}/offer-negotiations/`,{params:s}).then(t=>t.data)})}function Ja(s){return oe({queryKey:[...p.negotiations,"history",s],queryFn:()=>j.get(`${g}/offer-negotiations/history/${s}/`).then(t=>t.data),enabled:!!s})}function vr(){const s=$();return k({mutationFn:t=>j.post(`${g}/offer-negotiations/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.negotiations}),s.invalidateQueries({queryKey:p.offers}),l.success("Negotiation round added")},onError:t=>{var n;const a=(n=t==null?void 0:t.response)==null?void 0:n.data;if(a){const i=r=>typeof r=="string"?r:Array.isArray(r)?r.map(i).join(", "):typeof r=="object"&&r!==null?Object.values(r).map(i).join(", "):String(r),u=Object.values(a).map(i).join("; ");l.error(u||"Failed to add negotiation")}else l.error("Failed to add negotiation")}})}function yr(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/offer-negotiations/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.negotiations}),s.invalidateQueries({queryKey:p.offers}),l.success("Negotiation updated")},onError:()=>l.error("Failed to update negotiation")})}function Nr(){const s=$();return k({mutationFn:({id:t,...a})=>j.post(`${g}/offer-negotiations/${t}/hr-respond/`,a).then(n=>n.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.negotiations}),s.invalidateQueries({queryKey:p.offers});const n={approve:"approved",reject:"rejected",counter:"countered"};l.success(`Negotiation ${n[a.action]}`)},onError:()=>l.error("Failed to respond to negotiation")})}function br(){const s=$();return k({mutationFn:({id:t,...a})=>j.post(`${g}/offer-negotiations/${t}/add-comment/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.negotiations}),l.success("Comment added")},onError:()=>l.error("Failed to add comment")})}function qo(s){return oe({queryKey:[...p.bgvVendors,s],queryFn:()=>j.get(`${g}/bgv-vendors/`,{params:s}).then(t=>t.data)})}function Fo(){const s=$();return k({mutationFn:t=>j.post(`${g}/bgv-vendors/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.bgvVendors}),l.success("Vendor created")},onError:()=>l.error("Failed to create vendor")})}function Po(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/bgv-vendors/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.bgvVendors}),l.success("Vendor updated")},onError:()=>l.error("Failed to update vendor")})}function $o(){const s=$();return k({mutationFn:t=>j.delete(`${g}/bgv-vendors/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.bgvVendors}),l.success("Vendor deleted")},onError:()=>l.error("Failed to delete vendor")})}function Ao(s){return oe({queryKey:[...p.verifications,s],queryFn:()=>j.get(`${g}/verifications/`,{params:s}).then(t=>t.data)})}function Ro(){const s=$();return k({mutationFn:t=>j.post(`${g}/verifications/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.verifications}),l.success("Verification request created")},onError:()=>l.error("Failed to create verification")})}function Do(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/verifications/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.verifications}),l.success("Verification updated")},onError:()=>l.error("Failed to update verification")})}function Eo(){const s=$();return k({mutationFn:({id:t,result:a,findings:n})=>j.post(`${g}/verifications/${t}/complete/`,{result:a,findings:n}).then(i=>i.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.verifications}),l.success("Verification completed")},onError:()=>l.error("Failed to complete verification")})}function To(){const s=$();return k({mutationFn:({id:t,reason:a})=>j.post(`${g}/verifications/${t}/waive/`,{reason:a}).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.verifications}),l.success("Verification waived")},onError:()=>l.error("Failed to waive verification")})}function Vo(s){return oe({queryKey:[...p.referenceChecks,s],queryFn:()=>j.get(`${g}/reference-checks/`,{params:s}).then(t=>t.data)})}function Oo(){const s=$();return k({mutationFn:t=>j.post(`${g}/reference-checks/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.referenceChecks}),l.success("Reference check created")},onError:()=>l.error("Failed to create reference check")})}function Lo(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/reference-checks/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.referenceChecks}),l.success("Reference check updated")},onError:()=>l.error("Failed to update reference check")})}function Io(s){return oe({queryKey:[...p.drives,s],queryFn:()=>j.get(`${g}/drives/`,{params:s}).then(t=>t.data)})}function Ko(){const s=$();return k({mutationFn:t=>j.post(`${g}/drives/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.drives}),l.success("Drive created")},onError:()=>l.error("Failed to create drive")})}function zo(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/drives/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.drives}),l.success("Drive updated")},onError:()=>l.error("Failed to update drive")})}function Mo(){const s=$();return k({mutationFn:t=>j.delete(`${g}/drives/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.drives}),l.success("Drive deleted")},onError:()=>l.error("Failed to delete drive")})}function Qo(s){return oe({queryKey:[...p.campusPartners,s],queryFn:()=>j.get(`${g}/campus-partners/`,{params:s}).then(t=>t.data)})}function Uo(){const s=$();return k({mutationFn:t=>j.post(`${g}/campus-partners/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.campusPartners}),l.success("Campus partner created")},onError:()=>l.error("Failed to create campus partner")})}function Bo(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/campus-partners/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.campusPartners}),l.success("Campus partner updated")},onError:()=>l.error("Failed to update campus partner")})}function Go(){const s=$();return k({mutationFn:t=>j.delete(`${g}/campus-partners/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.campusPartners}),l.success("Campus partner deleted")},onError:()=>l.error("Failed to delete campus partner")})}function Ho(s,t){return oe({queryKey:[...p.candidateActivities(s),t],queryFn:()=>j.get(`${g}/activities/`,{params:{...t,candidate:s}}).then(a=>a.data),enabled:!!s})}function Cr(s,t){return oe({queryKey:[...p.candidateNotes(s),t],queryFn:()=>j.get(`${g}/candidate-notes/`,{params:{...t,candidate:s}}).then(a=>a.data),enabled:!!s})}function Sr(){const s=$();return k({mutationFn:t=>j.post(`${g}/candidate-notes/`,t).then(a=>a.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.candidateNotes(a.candidate)}),l.success("Note added")},onError:()=>l.error("Failed to add note")})}function Jo(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/candidate-notes/${t}/`,a).then(n=>n.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.candidateNotes(a.candidate)}),l.success("Note updated")},onError:()=>l.error("Failed to update note")})}function wr(){const s=$();return k({mutationFn:({id:t,candidateId:a})=>j.delete(`${g}/candidate-notes/${t}/`).then(()=>a),onSuccess:t=>{s.invalidateQueries({queryKey:p.candidateNotes(t)}),l.success("Note deleted")},onError:()=>l.error("Failed to delete note")})}function kr(){return oe({queryKey:p.dashboard,queryFn:()=>j.get(`${g}/dashboard/`).then(s=>s.data)})}function Wa(s){return oe({queryKey:[...p.positionLevels,s],queryFn:()=>j.get(`${g}/position-levels/`,{params:s}).then(t=>t.data)})}function qr(){const s=$();return k({mutationFn:t=>j.post(`${g}/position-levels/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.positionLevels}),l.success("Position level created")},onError:()=>l.error("Failed to create position level")})}function Fr(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/position-levels/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.positionLevels}),l.success("Position level updated")},onError:()=>l.error("Failed to update position level")})}function Pr(){const s=$();return k({mutationFn:t=>j.delete(`${g}/position-levels/${t}/`),onSuccess:()=>{s.invalidateQueries({queryKey:p.positionLevels}),l.success("Position level deleted")},onError:()=>l.error("Failed to delete position level")})}function Ws(s){return oe({queryKey:[...p.assessmentTemplates,s],queryFn:()=>j.get(`${g}/assessment-templates/`,{params:s}).then(t=>t.data)})}function $r(s){return oe({queryKey:p.assessmentTemplate(s),queryFn:()=>j.get(`${g}/assessment-templates/${s}/`).then(t=>t.data),enabled:!!s})}function Ar(){const s=$();return k({mutationFn:t=>j.post(`${g}/assessment-templates/`,t).then(a=>a.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.assessmentTemplates}),l.success("Template created")},onError:()=>l.error("Failed to create template")})}function Rr(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/assessment-templates/${t}/`,a).then(n=>n.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.assessmentTemplates}),s.invalidateQueries({queryKey:p.assessmentTemplate(a.id)}),l.success("Template updated")},onError:()=>l.error("Failed to update template")})}function Dr(){const s=$();return k({mutationFn:t=>j.delete(`${g}/assessment-templates/${t}/`).then(()=>t),onSuccess:()=>{s.invalidateQueries({queryKey:p.assessmentTemplates}),l.success("Template deleted")},onError:()=>l.error("Failed to delete template")})}function Er(s){return oe({queryKey:p.assessmentDomains(s),queryFn:()=>{const t=s?`?template=${s}`:"";return j.get(`${g}/assessment-domains/${t}`).then(a=>a.data)}})}function Tr(){const s=$();return k({mutationFn:t=>j.post(`${g}/assessment-domains/`,t).then(a=>a.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.assessmentDomains(a.template)}),s.invalidateQueries({queryKey:p.assessmentTemplates}),l.success("Domain added")},onError:()=>l.error("Failed to add domain")})}function Vr(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/assessment-domains/${t}/`,a).then(n=>n.data),onSuccess:()=>{s.invalidateQueries({queryKey:p.assessmentDomains()}),s.invalidateQueries({queryKey:p.assessmentTemplates}),l.success("Domain updated")},onError:()=>l.error("Failed to update domain")})}function Or(){const s=$();return k({mutationFn:({id:t,templateId:a})=>j.delete(`${g}/assessment-domains/${t}/`).then(()=>a),onSuccess:t=>{s.invalidateQueries({queryKey:p.assessmentDomains(t)}),s.invalidateQueries({queryKey:p.assessmentTemplates}),l.success("Domain deleted")},onError:()=>l.error("Failed to delete domain")})}function Lr(s){return oe({queryKey:p.candidateAssessments(s),queryFn:()=>j.get(`${g}/assessments/by-candidate/${s}/`).then(t=>t.data),enabled:!!s})}function Ir(s){return oe({queryKey:[...p.assessments,s],queryFn:()=>j.get(`${g}/assessments/`,{params:s}).then(t=>t.data)})}function Wo(s){return oe({queryKey:p.assessment(s),queryFn:()=>j.get(`${g}/assessments/${s}/`).then(t=>t.data),enabled:!!s})}function Kr(){const s=$();return k({mutationFn:t=>j.post(`${g}/assessments/`,t).then(a=>a.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.candidateAssessments(a.candidate)}),l.success("Assessment saved as draft")},onError:()=>l.error("Failed to create assessment")})}function Yo(){const s=$();return k({mutationFn:({id:t,...a})=>j.patch(`${g}/assessments/${t}/`,a).then(n=>n.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.assessment(a.id)}),s.invalidateQueries({queryKey:p.candidateAssessments(a.candidate)}),l.success("Assessment updated")},onError:()=>l.error("Failed to update assessment")})}function zr(){const s=$();return k({mutationFn:({id:t})=>j.post(`${g}/assessments/${t}/submit/`).then(a=>a.data),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.assessment(a.id)}),s.invalidateQueries({queryKey:p.candidateAssessments(a.candidateId)}),l.success("Assessment submitted")},onError:()=>l.error("Failed to submit assessment")})}function Ya(){return k({mutationFn:async s=>{const t=await j.get(`${g}/assessments/${s}/download-pdf/`,{responseType:"blob"}),a=window.URL.createObjectURL(t.data),n=document.createElement("a");n.href=a,n.download="assessment_report.pdf",document.body.appendChild(n),n.click(),n.remove(),window.URL.revokeObjectURL(a)},onSuccess:()=>l.success("PDF downloaded"),onError:()=>l.error("Failed to download PDF")})}function Mr(){const s=$();return k({mutationFn:({id:t,candidateId:a})=>j.delete(`${g}/assessments/${t}/`).then(()=>({id:t,candidateId:a})),onSuccess:(t,a)=>{s.invalidateQueries({queryKey:p.candidateAssessments(a.candidateId)}),l.success("Assessment deleted")},onError:()=>l.error("Failed to delete assessment")})}const Qr=[{key:"open_requisitions",label:"Open Requisitions",icon:kt,color:"text-primary",bgColor:"bg-primary/10"},{key:"active_candidates",label:"Active Candidates",icon:Es,color:"text-emerald-500",bgColor:"bg-emerald-500/10"},{key:"pending_interviews",label:"Pending Interviews",icon:Ts,color:"text-amber-500",bgColor:"bg-amber-500/10"},{key:"pending_offers",label:"Pending Offers",icon:Vs,color:"text-violet-500",bgColor:"bg-violet-500/10"}];function Zo(){const s=hs(),{data:t,isLoading:a}=kr();return e.jsxs("div",{children:[e.jsx(An,{title:"Recruitment Dashboard",description:"Overview of hiring activity, pipeline, and key metrics.",actions:e.jsxs(P,{size:"sm",onClick:()=>s("/recruitment/requisitions"),children:[e.jsx(kt,{className:"mr-1.5 h-3.5 w-3.5"})," New Requisition"]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4 mb-6",children:Qr.map(n=>{const i=n.icon;return e.jsx(Ft,{children:e.jsx(Pt,{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 ${n.bgColor}`,children:e.jsx(i,{className:`h-4.5 w-4.5 ${n.color}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:n.label}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:a?"...":(t==null?void 0:t[n.key])??0})]})]})})},n.key)})}),e.jsxs("div",{className:"grid grid-cols-2 gap-6 mb-6",children:[e.jsxs(Ft,{children:[e.jsx(Tt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Vt,{className:"text-[14px]",children:"Requisitions by Status"}),e.jsxs(P,{variant:"ghost",size:"sm",onClick:()=>s("/recruitment/requisitions"),children:["View All ",e.jsx($a,{className:"ml-1 h-3.5 w-3.5"})]})]})}),e.jsx(Pt,{children:a?e.jsx("div",{className:"space-y-3",children:Array.from({length:4}).map((n,i)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-24 rounded"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-8 rounded"})]},i))}):((t==null?void 0:t.requisitions_by_status)??[]).length===0?e.jsx("p",{className:"text-[13px] text-slate-400 py-4 text-center",children:"No requisition data."}):e.jsx("div",{className:"space-y-3",children:((t==null?void 0:t.requisitions_by_status)??[]).map(n=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] text-slate-600 capitalize",children:n.status.replace(/_/g," ")}),e.jsx(le,{variant:"secondary",className:"text-[11px]",children:n.count})]},n.status))})})]}),e.jsxs(Ft,{children:[e.jsx(Tt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Vt,{className:"text-[14px]",children:"Source Breakdown"}),e.jsxs(P,{variant:"ghost",size:"sm",onClick:()=>s("/recruitment/analytics"),children:["Analytics ",e.jsx(Rn,{className:"ml-1 h-3.5 w-3.5"})]})]})}),e.jsx(Pt,{children:a?e.jsx("div",{className:"space-y-3",children:Array.from({length:4}).map((n,i)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"skeleton-shimmer h-4 w-28 rounded"}),e.jsx("div",{className:"skeleton-shimmer h-4 w-8 rounded"})]},i))}):((t==null?void 0:t.source_breakdown)??[]).length===0?e.jsx("p",{className:"text-[13px] text-slate-400 py-4 text-center",children:"No source data."}):e.jsx("div",{className:"space-y-3",children:((t==null?void 0:t.source_breakdown)??[]).map(n=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[13px] text-slate-600 capitalize",children:n.source.replace(/_/g," ")}),e.jsx(le,{variant:"secondary",className:"text-[11px]",children:n.count})]},n.source))})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[e.jsx(Ft,{children:e.jsx(Pt,{className:"pt-5 pb-4 px-5",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-blue-500/10",children:e.jsx(ba,{className:"h-4.5 w-4.5 text-blue-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-slate-400 uppercase tracking-wider",children:"Avg Time-to-Hire"}),e.jsx("p",{className:"text-[22px] font-semibold text-slate-900 leading-tight",children:a?"...":`${(t==null?void 0:t.time_to_hire_avg_days)??0}d`})]})]})})}),e.jsxs(Ft,{className:"col-span-2",children:[e.jsx(Tt,{className:"pb-3",children:e.jsx(Vt,{className:"text-[14px]",children:"Recent Activity"})}),e.jsx(Pt,{children:a?e.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((n,i)=>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"})]},i))}):((t==null?void 0:t.recent_activities)??[]).length===0?e.jsx("p",{className:"text-[13px] text-slate-400 py-4 text-center",children:"No recent activity."}):e.jsx("div",{className:"divide-y divide-slate-100",children:((t==null?void 0:t.recent_activities)??[]).slice(0,5).map(n=>e.jsxs("div",{className:"flex items-center justify-between py-2.5",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[13px] text-slate-700",children:n.description}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:[n.candidate_name," ",n.performed_by_name?`by ${n.performed_by_name}`:""]})]}),e.jsx("span",{className:"text-[11px] text-slate-400 shrink-0 ml-3",children:new Date(n.created_at).toLocaleDateString()})]},n.id))})})]})]})]})}const ma={draft:"secondary",pending_approval:"warning",approved:"success",published:"default",on_hold:"warning",rejected:"destructive",cancelled:"secondary",closed:"secondary",filled:"success"},xa={draft:"Draft",pending_approval:"Pending Approval",approved:"Approved",published:"Published",on_hold:"On Hold",rejected:"Rejected",cancelled:"Cancelled",closed:"Closed",filled:"Filled"},ua={critical:"destructive",high:"warning",medium:"secondary",low:"default"},Ur=ct({title:C().min(1,"Title is required").regex(/^[a-zA-Z0-9][a-zA-Z0-9\s\-/,.()&]+$/,"Title must start with a letter or number and contain no special characters"),department:C().min(1,"Department is required"),company:C().min(1,"Company is required"),employment_type:C().optional(),requisition_type:C().optional(),category:C().optional().nullable(),priority:C().optional(),headcount_requested:Cs(s=>s===""||s===void 0?void 0:s,Me.number().min(1,"Headcount must be at least 1").optional()),budget_min:Cs(s=>s===""?void 0:s,C().optional()),budget_max:Cs(s=>s===""?void 0:s,C().optional()),budget_currency:C().nullable().optional(),target_joining_date:Is(),justification:C().optional(),description:C().optional(),business_needs:Aa(C()).optional()});function Xo(){var d;const s=hs(),[t,a]=$s(),[n,i]=h.useState("__all__"),[u,r]=h.useState("__all__"),[N,y]=h.useState(!1),[m,V]=h.useState(null),[F,M]=h.useState(null),[z,G]=h.useState(null),{hasPermission:ee,requirePermission:te}=et(),ie=ee("recruitment","requisition","create"),L=ee("recruitment","requisition","update"),re=ee("recruitment","requisition","delete"),{pagination:ne,setPagination:ce,sorting:J,setSorting:Q,globalFilter:R,setGlobalFilter:v,queryParams:S}=tt(),X={...S,...n&&n!=="__all__"&&{status:n},...u&&u!=="__all__"&&{priority:u}},{data:Z,isLoading:W}=zs(X),de=(Z==null?void 0:Z.results)??[],w=t.get("view"),{data:se}=Ps(w??"");h.useEffect(()=>{se&&!F&&(M(se),a({},{replace:!0}))},[se]);const{data:D}=Ps((F==null?void 0:F.id)??""),H=xi(),I=ui(),A=pi(),O=hi(),K=ji(),_e=gi(),T=Ye({resolver:nt(Ur),defaultValues:{title:"",department:"",company:"",employment_type:"permanent",requisition_type:"new_position",priority:"medium",headcount_requested:1,budget_min:"",budget_max:"",budget_currency:null,target_joining_date:"",justification:"",description:"",business_needs:[]}}),{data:qe}=Ut({page_size:100}),U=(qe==null?void 0:qe.results)??[],[ae,_]=h.useState(""),{data:ue}=En({search:ae||void 0}),pe=T.watch("company"),{data:fe}=Da({page_size:100,...pe&&{company:pe}}),{data:Ke}=Ms({page_size:100,is_active:!0}),Oe=(Ke==null?void 0:Ke.results)??[],E=(fe==null?void 0:fe.results)??[],{data:ye,isLoading:Re}=Ka({page_size:100,is_active:!0,...pe&&{company:pe}}),c=(ye==null?void 0:ye.results)??[];function Y(){te("recruitment","requisition","create")&&(V(null),T.reset({title:"",department:"",company:"",employment_type:"permanent",requisition_type:"new_position",priority:"medium",headcount_requested:1,budget_min:"",budget_max:"",budget_currency:null,target_joining_date:"",justification:"",description:"",business_needs:[]}),y(!0))}function ve(f){te("recruitment","requisition","update")&&(V(f),T.reset({title:f.title,department:f.department,company:f.company,employment_type:f.employment_type,requisition_type:f.requisition_type,category:f.category??null,priority:f.priority,headcount_requested:f.headcount_requested,budget_min:f.budget_min,budget_max:f.budget_max,budget_currency:f.budget_currency,target_joining_date:f.target_joining_date??"",justification:f.justification,description:f.description,business_needs:f.business_needs??[]}),y(!0))}function Be(f){const he=f;m?I.mutate({id:m.id,...he},{onSuccess:()=>y(!1)}):H.mutate(he,{onSuccess:()=>{y(!1),n!=="__all__"&&n!=="draft"&&i("draft")}})}function yt(){z&&A.mutate(z.id,{onSuccess:()=>G(null)})}function dt(f){i(f),ce(he=>({...he,pageIndex:0}))}function At(f){r(f),ce(he=>({...he,pageIndex:0}))}const Rt=[{key:"requisition_number",header:"Req #",render:f=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xs,{to:`/recruitment/requisitions/${f.id}`,className:"font-medium text-primary hover:underline text-[13px]",children:f.requisition_number}),f.is_confidential&&e.jsx(ps,{className:"h-3 w-3 text-slate-400"})]})},{key:"title",header:"Title",render:f=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:f.title}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:f.department_name})]})},{key:"employment_type",header:"Type",render:f=>e.jsx("span",{className:"text-[12px] text-slate-600 capitalize",children:f.employment_type})},{key:"headcount_requested",header:"Headcount",render:f=>e.jsx("span",{className:"text-[13px] text-slate-700",children:f.headcount_approved?f.headcount_filled>0?`${f.headcount_filled}/${f.headcount_approved}`:f.headcount_approved:f.headcount_requested})},{key:"priority",header:"Priority",render:f=>e.jsx(le,{variant:ua[f.priority],className:"capitalize text-[11px]",children:f.priority})},{key:"status",header:"Status",render:f=>e.jsx(le,{variant:ma[f.status],className:"text-[11px]",children:xa[f.status]})},{key:"applications_count",header:"Applications",render:f=>e.jsx("button",{type:"button",className:"text-[13px] text-primary hover:underline font-medium",onClick:()=>s(`/recruitment/applications?requisition=${f.id}`),children:f.applications_count})},{key:"created_at",header:"Created",render:f=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(f.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:f=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[e.jsxs(B,{onClick:()=>M(f),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View"]}),L&&(f.status==="draft"||f.status==="rejected")&&e.jsxs(e.Fragment,{children:[e.jsxs(B,{onClick:()=>ve(f),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),f.status==="draft"&&e.jsxs(B,{onClick:()=>O.mutate(f.id),children:[e.jsx(Kt,{className:"mr-2 h-3.5 w-3.5"})," Submit"]}),f.status==="rejected"&&e.jsxs(B,{onClick:()=>_e.mutate(f.id),children:[e.jsx(Kt,{className:"mr-2 h-3.5 w-3.5"})," Revert to Draft"]})]}),L&&(f.status==="approved"||f.status==="published")&&e.jsxs(B,{onClick:()=>K.mutate(f.id),children:[e.jsx(ps,{className:"mr-2 h-3.5 w-3.5"})," Close"]}),re&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{className:"text-red-600",onClick:()=>G(f),children:[e.jsx(ft,{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.jsx("h2",{className:"text-[16px] font-semibold text-slate-900",children:"Job Requisitions"}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Manage hiring requests and approvals"})]}),ie&&e.jsxs(P,{size:"sm",onClick:Y,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Requisition"]})]}),e.jsx(st,{actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ce,{value:n,onValueChange:dt,children:[e.jsx(Se,{className:"w-[150px] h-9",children:e.jsx(we,{placeholder:"All statuses"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"__all__",children:"All Statuses"}),e.jsx(q,{value:"draft",children:"Draft"}),e.jsx(q,{value:"pending_approval",children:"Pending Approval"}),e.jsx(q,{value:"approved",children:"Approved"}),e.jsx(q,{value:"published",children:"Published"}),e.jsx(q,{value:"on_hold",children:"On Hold"}),e.jsx(q,{value:"rejected",children:"Rejected"}),e.jsx(q,{value:"closed",children:"Closed"}),e.jsx(q,{value:"filled",children:"Filled"}),e.jsx(q,{value:"cancelled",children:"Cancelled"})]})]}),e.jsxs(Ce,{value:u,onValueChange:At,children:[e.jsx(Se,{className:"w-[130px] h-9",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"__all__",children:"All Priorities"}),e.jsx(q,{value:"critical",children:"Critical"}),e.jsx(q,{value:"high",children:"High"}),e.jsx(q,{value:"medium",children:"Medium"}),e.jsx(q,{value:"low",children:"Low"})]})]})]}),columns:Rt,data:de,isLoading:W,searchPlaceholder:"Search requisitions...",emptyMessage:"No requisitions",emptyDescription:"Create your first job requisition to start hiring.",totalCount:(Z==null?void 0:Z.count)??0,pagination:ne,onPaginationChange:ce,sorting:J,onSortingChange:Q,globalFilter:R,onGlobalFilterChange:v}),e.jsx(De,{open:N,onOpenChange:y,children:e.jsxs(Ee,{size:"lg",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:m?"Edit Requisition":"New Requisition"}),e.jsx(Ie,{children:m?"Update requisition details below.":"Fill in the details to create a new job requisition."})]}),e.jsxs("form",{onSubmit:T.handleSubmit(Be),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Title *"}),e.jsx(b,{...T.register("title"),className:"mt-1.5",placeholder:"e.g. Senior Software Engineer"}),T.formState.errors.title&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:T.formState.errors.title.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:T.watch("company")??null,onValueChange:f=>{T.setValue("company",f,{shouldValidate:!0}),T.setValue("department","")},options:U.map(f=>({value:f.id,label:f.name,hint:f.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Department *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:T.watch("department")??null,onValueChange:f=>T.setValue("department",f,{shouldValidate:!0}),options:E.map(f=>({value:f.id,label:f.name,hint:f.code})),selectedLabel:m==null?void 0:m.department_name,placeholder:"Select department",searchPlaceholder:"Search departments..."})})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Employment Type"}),e.jsxs(Ce,{value:T.watch("employment_type"),onValueChange:f=>T.setValue("employment_type",f),children:[e.jsx(Se,{className:"mt-1.5 h-9",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"permanent",children:"Permanent"}),e.jsx(q,{value:"contract",children:"Contract"}),e.jsx(q,{value:"intern",children:"Intern"}),e.jsx(q,{value:"consultant",children:"Consultant"}),e.jsx(q,{value:"temporary",children:"Temporary"})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Requisition Type"}),e.jsxs(Ce,{value:T.watch("requisition_type"),onValueChange:f=>T.setValue("requisition_type",f),children:[e.jsx(Se,{className:"mt-1.5 h-9",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"new_position",children:"New Position"}),e.jsx(q,{value:"replacement",children:"Replacement"}),e.jsx(q,{value:"expansion",children:"Expansion"}),e.jsx(q,{value:"succession",children:"Succession"}),e.jsx(q,{value:"project",children:"Project-Based"})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Category"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:T.watch("category")||null,onValueChange:f=>T.setValue("category",f||null),options:Oe.map(f=>({value:f.id,label:f.name,hint:f.code})),selectedLabel:m==null?void 0:m.category_name,placeholder:"Select category",searchPlaceholder:"Search categories..."})}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-400",children:"Sets the interview rounds for this opening."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Priority"}),e.jsxs(Ce,{value:T.watch("priority"),onValueChange:f=>T.setValue("priority",f),children:[e.jsx(Se,{className:"mt-1.5 h-9",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"critical",children:"Critical"}),e.jsx(q,{value:"high",children:"High"}),e.jsx(q,{value:"medium",children:"Medium"}),e.jsx(q,{value:"low",children:"Low"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Headcount"}),e.jsx(b,{type:"number",...T.register("headcount_requested"),className:"mt-1.5",placeholder:"Enter headcount"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Budget Min"}),e.jsx(b,{...T.register("budget_min"),className:"mt-1.5",placeholder:"0.00"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Budget Max"}),e.jsx(b,{...T.register("budget_max"),className:"mt-1.5",placeholder:"0.00"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Currency"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:T.watch("budget_currency")??null,onValueChange:f=>T.setValue("budget_currency",f),onSearch:_,selectedLabel:(d=m==null?void 0:m.budget_currency_detail)==null?void 0:d.code,options:((ue==null?void 0:ue.results)??[]).map(f=>({value:f.id,label:f.code,hint:f.name})),placeholder:"Select currency",searchPlaceholder:"Search currencies..."})})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Target Joining Date"}),e.jsx(b,{type:"date",...T.register("target_joining_date"),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Description"}),e.jsx(Ae,{...T.register("description"),className:"mt-1.5",rows:3})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Justification"}),e.jsx(Ae,{...T.register("justification"),className:"mt-1.5",rows:2})]}),e.jsxs("div",{className:"rounded-lg border border-slate-200 p-4 space-y-3",children:[e.jsx("p",{className:"text-[13px] font-semibold text-slate-700 border-b border-slate-100 pb-2",children:"Business Needs"}),pe?Re?e.jsx("div",{className:"h-8 rounded bg-slate-50 animate-pulse"}):c.length===0?e.jsx("p",{className:"text-[12.5px] text-slate-400",children:"No active business needs configured for this company."}):e.jsx("div",{className:"grid grid-cols-2 gap-2",children:c.map(f=>{const Ze=(T.watch("business_needs")??[]).includes(f.id);return e.jsxs("label",{className:"flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-slate-50 cursor-pointer",children:[e.jsx(Lt,{checked:Ze,onCheckedChange:Ge=>{const Nt=T.getValues("business_needs")??[];T.setValue("business_needs",Ge?[...Nt,f.id]:Nt.filter(Dt=>Dt!==f.id))}}),e.jsx("span",{className:"text-[13px] text-slate-700",children:f.name})]},f.id)})}):e.jsx("p",{className:"text-[12.5px] text-slate-400",children:"Select a company to see its business needs."})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(P,{onClick:T.handleSubmit(Be),disabled:H.isPending||I.isPending,children:m?"Update":"Create"})]})]})}),e.jsx(De,{open:!!F,onOpenChange:f=>!f&&M(null),children:e.jsxs(Ee,{size:"lg",children:[e.jsxs(Te,{children:[e.jsxs(Ve,{children:[F==null?void 0:F.requisition_number," — ",F==null?void 0:F.title]}),e.jsxs("div",{className:"mt-1 flex items-center gap-2",children:[e.jsx(le,{variant:ma[(F==null?void 0:F.status)??"draft"],className:"text-[11px]",children:xa[(F==null?void 0:F.status)??"draft"]}),e.jsx(le,{variant:ua[(F==null?void 0:F.priority)??"medium"],className:"capitalize text-[11px]",children:F==null?void 0:F.priority})]})]}),F&&(()=>{var he,Ze;const f=D??F;return e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4 text-[13px]",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Department"}),e.jsx("p",{className:"text-slate-800",children:f.department_name||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Employment Type"}),e.jsx("p",{className:"text-slate-800 capitalize",children:f.employment_type||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Requisition Type"}),e.jsx("p",{className:"text-slate-800 capitalize",children:((he=f.requisition_type)==null?void 0:he.replace(/_/g," "))||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Headcount"}),e.jsx("p",{className:"text-slate-800",children:f.headcount_approved?f.headcount_filled>0?`${f.headcount_filled}/${f.headcount_approved} filled`:`${f.headcount_approved} approved`:`${f.headcount_requested} requested`})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Budget"}),e.jsxs("p",{className:"text-slate-800",children:[((Ze=f.budget_currency_detail)==null?void 0:Ze.code)??""," ",f.budget_min," – ",f.budget_max]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Target Joining"}),e.jsx("p",{className:"text-slate-800",children:f.target_joining_date?new Date(f.target_joining_date).toLocaleDateString():"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Applications"}),e.jsx("p",{children:e.jsx("button",{type:"button",className:"text-primary hover:underline font-medium text-[13px]",onClick:()=>{M(null),s(`/recruitment/applications?requisition=${f.id}`)},children:f.applications_count})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Aging"}),e.jsxs("p",{className:"text-slate-800",children:[f.aging_days," days"]})]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Description"}),e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:f.description||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Justification"}),e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:f.justification||"—"})]}),f.approved_by_name&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Approved By"}),e.jsxs("p",{className:"text-slate-800",children:[f.approved_by_name," ",f.approved_at?`on ${new Date(f.approved_at).toLocaleDateString()}`:""]})]})]})})(),e.jsx(Qe,{children:e.jsx(P,{variant:"outline",onClick:()=>M(null),children:"Close"})})]})}),e.jsx(mt,{open:!!z,onOpenChange:f=>!f&&G(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Delete requisition?"}),e.jsxs(ht,{children:["This will permanently delete ",e.jsx("strong",{children:z==null?void 0:z.requisition_number})," — ",z==null?void 0:z.title,"."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:"destructive",onClick:yt,children:"Delete"})]})]})})]})}const Br=ct({name:C().min(1,"Name is required"),code:C().min(1,"Code is required"),company:C().min(1,"Company is required"),description:C().optional(),order:Me.number().min(0).optional(),is_active:ge().default(!0)});function ed(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),{hasPermission:r,requirePermission:N}=et(),y=r("recruitment","requisition","create"),m=r("recruitment","requisition","update"),V=r("recruitment","requisition","delete"),{pagination:F,setPagination:M,sorting:z,setSorting:G,globalFilter:ee,setGlobalFilter:te,queryParams:ie}=tt(),{data:L,isLoading:re}=Ms(ie),ne=(L==null?void 0:L.results)??[],ce=Si(),J=wi(),Q=ki(),{data:R}=Ut(),v=(R==null?void 0:R.results)??[],S=Ye({resolver:nt(Br),defaultValues:{is_active:!0,order:0}});function X(){N("recruitment","requisition","create")&&(n(null),S.reset({name:"",code:"",company:"",description:"",order:0,is_active:!0}),t(!0))}function Z(w){N("recruitment","requisition","update")&&(n(w),S.reset({name:w.name,code:w.code,company:w.company,description:w.description,order:w.order,is_active:w.is_active}),t(!0))}function W(w){const se=w,D={onSuccess:()=>t(!1)};a?J.mutate({id:a.id,...se},D):ce.mutate(se,D)}const de=[{key:"name",header:"Category",render:w=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900",children:w.name}),e.jsx("span",{className:"block font-mono text-[11px] text-slate-400",children:w.code})]})},{key:"description",header:"Description",render:w=>e.jsx("span",{className:"block max-w-[280px] truncate text-[13px] text-slate-500",children:w.description||"—"})},{key:"round_count",header:"Rounds",render:w=>e.jsx("span",{className:"tabular-nums text-[13px] text-slate-600",children:w.round_count})},{key:"is_active",header:"Status",render:w=>e.jsx(le,{variant:w.is_active?"success":"secondary",children:w.is_active?"Active":"Inactive"})},{key:"actions",header:"",className:"w-10",render:w=>m||V?e.jsxs(mt,{open:(i==null?void 0:i.id)===w.id,onOpenChange:se=>!se&&u(null),children:[e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[m&&e.jsxs(B,{onClick:()=>Z(w),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),V&&e.jsxs(B,{className:"text-red-600",onClick:()=>u(w),children:[e.jsx(ft,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]}),e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsxs(pt,{children:["Delete “",w.name,"”?"]}),e.jsxs(ht,{children:["Its ",w.round_count," interview round",w.round_count===1?"":"s"," will be deleted too, and requisitions using this category will lose their round set."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{className:"bg-red-600 hover:bg-red-700",onClick:()=>Q.mutate(w.id,{onSuccess:()=>u(null)}),children:"Delete"})]})]})]}):null}];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-2 text-[16px] font-semibold text-slate-900",children:[e.jsx(ns,{className:"h-5 w-5 text-primary"})," Requisition Categories"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-500",children:"Group openings that share one interview process — define the rounds once."})]}),y&&e.jsxs(P,{size:"sm",onClick:X,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Category"]})]}),e.jsx(st,{columns:de,data:ne,isLoading:re,totalCount:(L==null?void 0:L.count)??0,pagination:F,onPaginationChange:M,sorting:z,onSortingChange:G,globalFilter:ee,onGlobalFilterChange:te,searchPlaceholder:"Search categories..."}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{className:"flex flex-col",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Category":"New Requisition Category"}),e.jsx(Ie,{children:"Requisitions tagged to this category run its interview rounds."})]}),e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto px-6 py-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Name *"}),e.jsx(b,{...S.register("name"),className:"mt-1.5",placeholder:"Engineering"}),S.formState.errors.name&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:S.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Code *"}),e.jsx(b,{...S.register("code"),className:"mt-1.5 font-mono",placeholder:"ENGG"}),S.formState.errors.code&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:S.formState.errors.code.message})]})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:S.watch("company")||null,onValueChange:w=>S.setValue("company",w,{shouldValidate:!0}),options:v.map(w=>({value:w.id,label:w.name,hint:w.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),S.formState.errors.company&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:S.formState.errors.company.message})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Description"}),e.jsx(Ae,{...S.register("description"),className:"mt-1.5",rows:3})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Display Order"}),e.jsx(b,{type:"number",min:0,...S.register("order"),className:"mt-1.5 w-32"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(rs,{checked:S.watch("is_active"),onCheckedChange:w=>S.setValue("is_active",w)}),e.jsx("span",{className:"text-[13px] text-slate-600",children:"Active — only active categories can be tagged on a requisition."})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:S.handleSubmit(W),disabled:ce.isPending||J.isPending,children:a?"Save Changes":"Create Category"})]})]})})]})}const Gr={draft:"secondary",pending_approval:"warning",approved:"success",published:"success",on_hold:"secondary",rejected:"destructive",cancelled:"secondary",closed:"default",filled:"success"};function td(){const{id:s}=As(),{data:t,isLoading:a,refetch:n}=Ps(s??"");return e.jsx(Va,{recordId:t==null?void 0:t.id,title:t?`${t.requisition_number} — ${t.title}`:"Requisition",subtitle:t==null?void 0:t.department_name,backTo:"/recruitment/requisitions",notFoundText:"Requisition not found.",isLoading:a,found:!!t,onDecided:()=>n(),children:t&&e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[e.jsx("div",{className:"col-span-2 space-y-4",children:e.jsxs(Ft,{children:[e.jsx(Tt,{className:"pb-3",children:e.jsx(Vt,{className:"text-[14px]",children:"Requisition Details"})}),e.jsxs(Pt,{className:"grid grid-cols-2 gap-4",children:[e.jsx(be,{label:"Title",value:t.title}),e.jsx(be,{label:"Department",value:t.department_name}),e.jsx(be,{label:"Designation",value:t.designation_name}),e.jsx(be,{label:"Branch",value:t.branch_name}),e.jsx(be,{label:"Employment Type",value:t.employment_type}),e.jsx(be,{label:"Priority",value:t.priority}),e.jsx(be,{label:"Headcount",value:t.headcount_requested}),e.jsx(be,{label:"Approved Headcount",value:t.headcount_approved}),e.jsx(be,{label:"Budget Min",value:t.budget_min}),e.jsx(be,{label:"Budget Max",value:t.budget_max}),e.jsx(be,{label:"Justification",value:t.justification})]})]})}),e.jsx("div",{className:"space-y-4",children:e.jsxs(Ft,{children:[e.jsx(Tt,{className:"pb-3",children:e.jsx(Vt,{className:"text-[14px]",children:"Summary"})}),e.jsxs(Pt,{className:"space-y-3",children:[e.jsx(be,{label:"Req No.",value:t.requisition_number}),e.jsx(be,{label:"Applications",value:t.applications_count}),e.jsx(be,{label:"Approved By",value:t.approved_by_name}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-slate-400",children:"Status"}),e.jsx(le,{variant:Gr[t.status]??"secondary",className:"mt-1",children:t.status.replace(/_/g," ")})]})]})]})})]})})}const Hr={active:"success",hired:"success",rejected:"destructive",withdrawn:"secondary",blacklisted:"destructive"},Jr=ct({first_name:C().min(1,"First name is required"),last_name:C().min(1,"Last name is required"),email:C().trim().min(1,"Email is required").refine(s=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s),"Enter a valid email address"),company:C().min(1,"Company is required"),phone:C().optional().refine(s=>!s||/^\d{10}$/.test(s),"Phone number must be exactly 10 digits"),alternate_phone:C().optional().refine(s=>!s||/^\d{10}$/.test(s),"Phone number must be exactly 10 digits"),date_of_birth:C().optional(),gender:C().optional(),current_location:C().optional(),source:C().optional(),linkedin_url:C().optional().refine(s=>!s||/^https?:\/\/.+/.test(s),"Must start with http:// or https://"),current_company:C().optional(),current_designation:C().optional(),total_experience_years:C().optional().refine(s=>!s||Number(s)>=0&&Number(s)<=60,{message:"Experience must be between 0 and 60 years"}),relevant_experience_years:C().optional().refine(s=>!s||Number(s)>=0&&Number(s)<=60,{message:"Experience must be between 0 and 60 years"}),notice_period_days:C().optional(),current_ctc:C().optional(),expected_ctc:C().optional(),resume_file:C().optional()});function sd(){const s=hs(),[t,a]=$s(),[n,i]=h.useState(""),[u,r]=h.useState(""),[N,y]=h.useState(!1),[m,V]=h.useState(null),[F,M]=h.useState(null),[z,G]=h.useState(null),ee=h.useRef(null),{hasPermission:te,requirePermission:ie}=et(),L=te("recruitment","candidate","create"),re=te("recruitment","candidate","update"),ne=te("recruitment","candidate","delete"),{pagination:ce,setPagination:J,sorting:Q,setSorting:R,globalFilter:v,setGlobalFilter:S,queryParams:X}=tt(),Z={...X,...n&&{status:n},...u&&{source:u}},{data:W,isLoading:de}=Qs(Z),w=(W==null?void 0:W.results)??[],{data:se}=Ut({page_size:100}),D=(se==null?void 0:se.results)??[],H=$i(),I=Ai(),A=Ri(),O=Di(),K=Ei(),_e=Ti(),T=Ye({resolver:nt(Jr),defaultValues:{first_name:"",last_name:"",email:"",company:"",phone:"",alternate_phone:"",date_of_birth:"",gender:"",current_location:"",source:"direct",linkedin_url:"",current_company:"",current_designation:"",total_experience_years:"",relevant_experience_years:"",notice_period_days:"",current_ctc:"",expected_ctc:"",resume_file:""}});function qe(){ie("recruitment","candidate","create")&&(V(null),G(null),T.reset({first_name:"",last_name:"",email:"",company:"",phone:"",alternate_phone:"",date_of_birth:"",gender:"",current_location:"",source:"direct",linkedin_url:"",current_company:"",current_designation:"",total_experience_years:"",relevant_experience_years:"",notice_period_days:"",current_ctc:"",expected_ctc:"",resume_file:""}),y(!0))}function U(E){ie("recruitment","candidate","update")&&(V(E),G(null),T.reset({first_name:E.first_name,last_name:E.last_name,email:E.email,company:E.company,phone:E.phone,alternate_phone:E.alternate_phone??"",date_of_birth:E.date_of_birth??"",gender:E.gender??"",current_location:E.current_location??"",source:E.source,linkedin_url:E.linkedin_url,current_company:E.current_company??"",current_designation:E.current_designation??"",total_experience_years:String(E.total_experience_years??""),relevant_experience_years:String(E.relevant_experience_years??""),notice_period_days:E.notice_period_days!=null?String(E.notice_period_days):"",current_ctc:String(E.current_ctc??""),expected_ctc:String(E.expected_ctc??""),resume_file:E.resume_file}),y(!0))}const ae=t.get("edit"),{data:_}=Ma(ae??"");h.useEffect(()=>{if(ae&&_){U(_);const E=new URLSearchParams(t);E.delete("edit"),a(E,{replace:!0})}},[ae,_]);function ue(E){const ye=Object.fromEntries(Object.entries(E).filter(([Re,c])=>c!==""&&c!==void 0&&Re!=="resume_file"));m?I.mutate({id:m.id,...ye},{onSuccess:()=>{z&&_e.mutate({id:m.id,file:z}),y(!1)}}):H.mutate(ye,{onSuccess:Re=>{z&&(Re!=null&&Re.id)&&_e.mutate({id:Re.id,file:z}),y(!1)}})}function pe(){F&&A.mutate(F.id,{onSuccess:()=>M(null)})}function fe(E){i(E==="__all__"?"":E),J(ye=>({...ye,pageIndex:0}))}function Ke(E){r(E==="__all__"?"":E),J(ye=>({...ye,pageIndex:0}))}const Oe=[{key:"full_name",header:"Name",render:E=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:E.full_name})},{key:"email",header:"Email",render:E=>e.jsx("span",{className:"text-[13px] text-slate-600",children:E.email})},{key:"phone",header:"Phone",render:E=>e.jsx("span",{className:"text-[13px] text-slate-600",children:E.phone||"-"})},{key:"source",header:"Source",render:E=>e.jsx("span",{className:"text-[12px] text-slate-600 capitalize",children:E.source.replace(/_/g," ")})},{key:"status",header:"Status",render:E=>e.jsx(le,{variant:Hr[E.status],className:"capitalize text-[11px]",children:E.status.replace(/_/g," ")})},{key:"applications_count",header:"Apps",render:E=>e.jsx("span",{className:"text-[13px] text-slate-600",children:E.applications_count})},{key:"created_at",header:"Created",render:E=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(E.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:E=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[e.jsxs(B,{onClick:()=>s(`/recruitment/candidates/${E.id}`),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View Profile"]}),re&&e.jsxs(e.Fragment,{children:[e.jsxs(B,{onClick:()=>U(E),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),E.status!=="hired"&&e.jsxs(B,{onClick:()=>K.mutate({id:E.id,status:"hired"}),children:[e.jsx(It,{className:"mr-2 h-3.5 w-3.5"})," Mark Hired"]}),E.status!=="rejected"&&e.jsxs(B,{onClick:()=>K.mutate({id:E.id,status:"rejected"}),children:[e.jsx(cs,{className:"mr-2 h-3.5 w-3.5"})," Mark Rejected"]}),E.status!=="withdrawn"&&e.jsxs(B,{onClick:()=>K.mutate({id:E.id,status:"withdrawn"}),children:[e.jsx(fn,{className:"mr-2 h-3.5 w-3.5"})," Mark Withdrawn"]}),E.status!=="active"&&e.jsxs(B,{onClick:()=>K.mutate({id:E.id,status:"active"}),children:[e.jsx(Oa,{className:"mr-2 h-3.5 w-3.5"})," Reactivate"]}),!E.is_blacklisted&&e.jsxs(B,{onClick:()=>O.mutate({id:E.id,reason:"Manual blacklist"}),children:[e.jsx(In,{className:"mr-2 h-3.5 w-3.5"})," Blacklist"]})]}),ne&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{className:"text-red-600",onClick:()=>M(E),children:[e.jsx(ft,{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(us,{className:"h-5 w-5 text-primary"})," Candidates"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Manage your talent pool and candidate profiles"})]}),L&&e.jsxs(P,{size:"sm",onClick:qe,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Add Candidate"]})]}),e.jsx(st,{actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ce,{value:n,onValueChange:fe,children:[e.jsx(Se,{className:"w-[150px] h-9",children:e.jsx(we,{placeholder:"All statuses"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"__all__",children:"All Statuses"}),e.jsx(q,{value:"active",children:"Active"}),e.jsx(q,{value:"hired",children:"Hired"}),e.jsx(q,{value:"rejected",children:"Rejected"}),e.jsx(q,{value:"withdrawn",children:"Withdrawn"}),e.jsx(q,{value:"blacklisted",children:"Blacklisted"})]})]}),e.jsxs(Ce,{value:u,onValueChange:Ke,children:[e.jsx(Se,{className:"w-[150px] h-9",children:e.jsx(we,{placeholder:"All sources"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"__all__",children:"All Sources"}),e.jsx(q,{value:"direct",children:"Direct"}),e.jsx(q,{value:"career_page",children:"Career Page"}),e.jsx(q,{value:"referral",children:"Referral"}),e.jsx(q,{value:"job_board",children:"Job Board"}),e.jsx(q,{value:"social_media",children:"Social Media"}),e.jsx(q,{value:"campus",children:"Campus"}),e.jsx(q,{value:"walk_in",children:"Walk-In"}),e.jsx(q,{value:"agency",children:"Agency"}),e.jsx(q,{value:"internal",children:"Internal"})]})]})]}),columns:Oe,data:w,isLoading:de,searchPlaceholder:"Search candidates...",emptyMessage:"No candidates",emptyDescription:"Add your first candidate to start building your talent pool.",totalCount:(W==null?void 0:W.count)??0,pagination:ce,onPaginationChange:J,sorting:Q,onSortingChange:R,globalFilter:v,onGlobalFilterChange:S}),e.jsx(De,{open:N,onOpenChange:y,children:e.jsxs(Ee,{size:"md",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:m?"Edit Candidate":"Add Candidate"}),e.jsx(Ie,{children:m?"Update candidate profile details.":"Add a new candidate to your talent pool."})]}),e.jsxs("form",{onSubmit:T.handleSubmit(ue),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(o,{className:"text-[12px] font-medium text-slate-500",children:"First Name *"}),e.jsx(b,{...T.register("first_name"),className:"mt-1.5",placeholder:"First name"}),T.formState.errors.first_name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:T.formState.errors.first_name.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Last Name *"}),e.jsx(b,{...T.register("last_name"),className:"mt-1.5",placeholder:"Last name"}),T.formState.errors.last_name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:T.formState.errors.last_name.message})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Email *"}),e.jsx(b,{...T.register("email"),className:"mt-1.5",placeholder:"email@example.com"}),T.formState.errors.email&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:T.formState.errors.email.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:T.watch("company")??null,onValueChange:E=>T.setValue("company",E,{shouldValidate:!0}),options:D.map(E=>({value:E.id,label:E.name,hint:E.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),T.formState.errors.company&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:T.formState.errors.company.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Phone"}),e.jsx(b,{...T.register("phone"),className:"mt-1.5",placeholder:"9876543210",maxLength:10,inputMode:"numeric",onInput:E=>{E.currentTarget.value=E.currentTarget.value.replace(/\D/g,"")}}),T.formState.errors.phone&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:T.formState.errors.phone.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Alternate Phone"}),e.jsx(b,{...T.register("alternate_phone"),className:"mt-1.5",placeholder:"9876543210",maxLength:10,inputMode:"numeric",onInput:E=>{E.currentTarget.value=E.currentTarget.value.replace(/\D/g,"")}}),T.formState.errors.alternate_phone&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:T.formState.errors.alternate_phone.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Date of Birth"}),e.jsx(b,{type:"date",...T.register("date_of_birth"),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Gender"}),e.jsxs(Ce,{value:T.watch("gender")||"__unset__",onValueChange:E=>T.setValue("gender",E==="__unset__"?"":E),children:[e.jsx(Se,{className:"mt-1.5 h-9",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"__unset__",children:"Not specified"}),e.jsx(q,{value:"male",children:"Male"}),e.jsx(q,{value:"female",children:"Female"}),e.jsx(q,{value:"other",children:"Other"}),e.jsx(q,{value:"prefer_not_to_say",children:"Prefer Not to Say"})]})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Location"}),e.jsx(b,{...T.register("current_location"),className:"mt-1.5",placeholder:"e.g. Bengaluru, India"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Source"}),e.jsxs(Ce,{value:T.watch("source"),onValueChange:E=>T.setValue("source",E),children:[e.jsx(Se,{className:"mt-1.5 h-9",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"direct",children:"Direct Application"}),e.jsx(q,{value:"career_page",children:"Career Page"}),e.jsx(q,{value:"referral",children:"Employee Referral"}),e.jsx(q,{value:"job_board",children:"Job Board"}),e.jsx(q,{value:"social_media",children:"Social Media"}),e.jsx(q,{value:"campus",children:"Campus"}),e.jsx(q,{value:"walk_in",children:"Walk-In"}),e.jsx(q,{value:"agency",children:"Recruitment Agency"}),e.jsx(q,{value:"internal",children:"Internal Candidate"})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"LinkedIn URL"}),e.jsx(b,{...T.register("linkedin_url"),className:"mt-1.5",placeholder:"https://linkedin.com/in/..."})]}),e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400 pt-1",children:"Previous / Current Experience"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Current / Previous Employer"}),e.jsx(b,{...T.register("current_company"),className:"mt-1.5",placeholder:"e.g. Acme Corp"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Designation"}),e.jsx(b,{...T.register("current_designation"),className:"mt-1.5",placeholder:"e.g. Senior Engineer"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Total Exp (yrs)"}),e.jsx($t,{...T.register("total_experience_years"),decimal:!0,className:"mt-1.5",placeholder:"e.g. 5",maxLength:4})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Relevant Exp (yrs)"}),e.jsx($t,{...T.register("relevant_experience_years"),decimal:!0,className:"mt-1.5",placeholder:"e.g. 3",maxLength:4})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Notice Period (days)"}),e.jsx($t,{...T.register("notice_period_days"),className:"mt-1.5",placeholder:"e.g. 30"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Current CTC"}),e.jsx($t,{...T.register("current_ctc"),decimal:!0,className:"mt-1.5",placeholder:"Annual CTC"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Expected CTC"}),e.jsx($t,{...T.register("expected_ctc"),decimal:!0,className:"mt-1.5",placeholder:"Expected CTC"})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Resume"}),e.jsxs("div",{className:"mt-1.5",children:[(m==null?void 0:m.resume_file)&&!z&&e.jsxs("div",{className:"flex items-center gap-2 mb-2 rounded-md border border-slate-200 bg-slate-50 px-3 py-2",children:[e.jsx(kt,{className:"h-4 w-4 text-primary shrink-0"}),e.jsx("a",{href:m.resume_file,target:"_blank",rel:"noreferrer",className:"text-[12px] text-primary underline truncate flex-1",children:"Current Resume"})]}),z?e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50 px-3 py-2",children:[e.jsx(kt,{className:"h-4 w-4 text-emerald-600 shrink-0"}),e.jsx("span",{className:"text-[12px] text-slate-700 truncate flex-1",children:z.name}),e.jsx("button",{type:"button",onClick:()=>{G(null),ee.current&&(ee.current.value="")},className:"text-slate-400 hover:text-slate-600",children:e.jsx(ls,{className:"h-3.5 w-3.5"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var E;return(E=ee.current)==null?void 0:E.click()},className:"flex items-center gap-2 w-full rounded-md border-2 border-dashed border-slate-200 bg-slate-50/40 px-3 py-3 text-[12px] text-slate-500 hover:border-slate-300 hover:bg-slate-50 transition-colors",children:[e.jsx(gn,{className:"h-4 w-4"}),m!=null&&m.resume_file?"Replace resume...":"Attach resume (PDF, DOC, DOCX)"]}),e.jsx("input",{ref:ee,type:"file",accept:".pdf,.doc,.docx",className:"sr-only",onChange:E=>{var Re;const ye=(Re=E.target.files)==null?void 0:Re[0];if(ye){if(ye.size>5*1024*1024){alert("File size must be under 5 MB");return}G(ye)}}})]})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>y(!1),children:"Cancel"}),e.jsx(P,{onClick:T.handleSubmit(ue),disabled:H.isPending||I.isPending,children:m?"Update":"Create"})]})]})}),e.jsx(mt,{open:!!F,onOpenChange:E=>!E&&M(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Delete candidate?"}),e.jsxs(ht,{children:["This will permanently delete ",e.jsx("strong",{children:F==null?void 0:F.full_name})," and all associated data."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:"destructive",onClick:pe,children:"Delete"})]})]})})]})}const Wr={new:"default",screening:"warning",shortlisted:"success",interview:"default",evaluation:"warning",offer:"success",hired:"success",rejected:"destructive",withdrawn:"secondary",on_hold:"warning"},Yr=ct({candidate:C().min(1,"Candidate is required"),requisition:C().min(1,"Requisition is required")});function ad(){const[s,t]=$s(),[a,n]=h.useState(""),[i,u]=h.useState(s.get("requisition")??""),[r,N]=h.useState(!1),[y,m]=h.useState(null),[V,F]=h.useState(null),[M,z]=h.useState(null),[G,ee]=h.useState(""),[te,ie]=h.useState(null),[L,re]=h.useState(""),[ne,ce]=h.useState(null),{hasPermission:J,requirePermission:Q}=et(),R=J("recruitment","application","create"),v=J("recruitment","application","update"),{pagination:S,setPagination:X,sorting:Z,setSorting:W,globalFilter:de,setGlobalFilter:w,queryParams:se}=tt(),D={...se,...a&&{status:a},...i&&{requisition:i}},{data:H,isLoading:I}=gs(D),A=(H==null?void 0:H.results)??[],O=Vi(),K=Oi(),_e=Li(),T=Ii(),qe=zi(),U=Ki(),ae=Ye({resolver:nt(Yr),defaultValues:{candidate:"",requisition:""}}),[_,ue]=h.useState(""),{data:pe}=Qs({page_size:100,search:_||void 0}),fe=(pe==null?void 0:pe.results)??[],[Ke,Oe]=h.useState(""),{data:E,isLoading:ye}=zs({page_size:100,search:Ke||void 0}),Re=(E==null?void 0:E.results)??[],{data:c}=za({page_size:100,ordering:"order",is_active:!0}),Y=(c==null?void 0:c.results)??[];function ve(){Q("recruitment","application","create")&&(m(null),ae.reset({candidate:"",requisition:""}),N(!0))}function Be(d){Q("recruitment","application","update")&&(m(d),ae.reset({candidate:d.candidate,requisition:d.requisition}),N(!0))}function yt(d){const f=d;y?K.mutate({id:y.id,...f},{onSuccess:()=>N(!1)}):O.mutate(f,{onSuccess:()=>N(!1)})}function dt(d){n(d==="__all__"?"":d),X(f=>({...f,pageIndex:0}))}function At(d){const f=d==="__all__"?"":d;u(f),X(he=>({...he,pageIndex:0})),t(f?{requisition:f}:{})}const Rt=[{key:"candidate_name",header:"Candidate",render:d=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:d.candidate_name}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:d.candidate_email})]})},{key:"requisition_number",header:"Requisition",render:d=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:d.requisition_number}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:d.requisition_title})]})},{key:"stage_name",header:"Stage",render:d=>e.jsx("span",{className:"text-[13px] text-slate-600",children:d.stage_name||"-"})},{key:"status",header:"Status",render:d=>e.jsx(le,{variant:Wr[d.status],className:"capitalize text-[11px]",children:d.status.replace(/_/g," ")})},{key:"application_date",header:"Applied",render:d=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(d.application_date).toLocaleDateString()})},{key:"days_in_stage",header:"Days in Stage",render:d=>e.jsxs("span",{className:"text-[13px] text-slate-600",children:[d.days_in_stage,"d"]})},{key:"actions",header:"",className:"w-10",render:d=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[v&&e.jsxs(B,{disabled:d.status==="hired",onClick:()=>Be(d),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),d.status==="rejected"&&d.rejection_remarks&&e.jsxs(B,{onClick:()=>ce(d),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View Rejection Reason"]}),v&&!["rejected","withdrawn","hired"].includes(d.status)&&e.jsxs(e.Fragment,{children:[e.jsxs(B,{onClick:()=>{z(d),ee("")},children:[e.jsx($a,{className:"mr-2 h-3.5 w-3.5"})," Move Stage"]}),e.jsxs(B,{onClick:()=>qe.mutate(d.id),children:[e.jsx(It,{className:"mr-2 h-3.5 w-3.5"})," Shortlist"]}),e.jsxs(B,{onClick:()=>{ie(d),re("")},children:[e.jsx(cs,{className:"mr-2 h-3.5 w-3.5"})," Reject"]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{disabled:d.status==="hired",className:"text-red-600",onClick:()=>F(d),children:[e.jsx(ft,{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(Es,{className:"h-5 w-5 text-primary"})," Applications"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Track candidate applications through the hiring pipeline"})]}),R&&e.jsxs(P,{size:"sm",onClick:ve,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Application"]})]}),e.jsx(st,{actions:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(me,{value:i,onValueChange:At,onSearch:Oe,isLoading:ye,options:[{value:"__all__",label:"All Requisitions"},...Re.map(d=>({value:d.id,label:`${d.requisition_number} — ${d.title}`}))],placeholder:"All requisitions",searchPlaceholder:"Search requisitions...",className:"w-[200px]"}),e.jsxs(Ce,{value:a,onValueChange:dt,children:[e.jsx(Se,{className:"w-[150px] h-9",children:e.jsx(we,{placeholder:"All statuses"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"__all__",children:"All Statuses"}),e.jsx(q,{value:"new",children:"New"}),e.jsx(q,{value:"screening",children:"Screening"}),e.jsx(q,{value:"shortlisted",children:"Shortlisted"}),e.jsx(q,{value:"interview",children:"Interview"}),e.jsx(q,{value:"evaluation",children:"Evaluation"}),e.jsx(q,{value:"offer",children:"Offer"}),e.jsx(q,{value:"hired",children:"Hired"}),e.jsx(q,{value:"rejected",children:"Rejected"}),e.jsx(q,{value:"withdrawn",children:"Withdrawn"}),e.jsx(q,{value:"on_hold",children:"On Hold"})]})]})]}),columns:Rt,data:A,isLoading:I,searchPlaceholder:"Search applications...",emptyMessage:"No applications",emptyDescription:"No applications found matching your criteria.",totalCount:(H==null?void 0:H.count)??0,pagination:S,onPaginationChange:X,sorting:Z,onSortingChange:W,globalFilter:de,onGlobalFilterChange:w}),e.jsx(De,{open:r,onOpenChange:N,children:e.jsxs(Ee,{size:"md",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:y?"Edit Application":"New Application"}),e.jsx(Ie,{children:y?"Update application details.":"Link a candidate to a requisition to create a new application."})]}),e.jsxs("form",{onSubmit:ae.handleSubmit(yt),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Candidate *"}),y?e.jsx("p",{className:"mt-1.5 text-[13px] text-slate-900 border rounded-md px-3 py-2 bg-slate-50",children:y.candidate_name}):e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:ae.watch("candidate")??null,onValueChange:d=>ae.setValue("candidate",d,{shouldValidate:!0}),onSearch:ue,options:fe.map(d=>({value:d.id,label:d.full_name,hint:d.email})),placeholder:"Select candidate",searchPlaceholder:"Search candidates..."})}),!y&&ae.formState.errors.candidate&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:ae.formState.errors.candidate.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Requisition *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:ae.watch("requisition")??null,onValueChange:d=>ae.setValue("requisition",d,{shouldValidate:!0}),onSearch:Oe,isLoading:ye,options:Re.map(d=>({value:d.id,label:`${d.requisition_number} — ${d.title}`})),selectedLabel:y?`${y.requisition_number} — ${y.requisition_title}`:void 0,placeholder:"Select requisition",searchPlaceholder:"Search requisitions..."})}),ae.formState.errors.requisition&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:ae.formState.errors.requisition.message})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>N(!1),children:"Cancel"}),e.jsx(P,{onClick:ae.handleSubmit(yt),disabled:O.isPending||K.isPending,children:y?"Update":"Create"})]})]})}),e.jsx(mt,{open:!!V,onOpenChange:d=>!d&&F(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Delete application?"}),e.jsxs(ht,{children:["This will permanently delete the application for ",e.jsx("strong",{children:V==null?void 0:V.candidate_name})," to ",e.jsx("strong",{children:V==null?void 0:V.requisition_number}),"."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:"destructive",onClick:()=>{V&&_e.mutate(V.id,{onSuccess:()=>F(null)})},children:"Delete"})]})]})}),e.jsx(mt,{open:!!M,onOpenChange:d=>!d&&z(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Move Application Stage"}),e.jsxs(ht,{children:["Select the application stage to move ",e.jsx("strong",{children:M==null?void 0:M.candidate_name})," to."]})]}),e.jsxs("div",{className:"px-1 py-2",children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Application Stage"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:G||null,onValueChange:ee,options:Y.filter(d=>!(M!=null&&M.company)||d.company===M.company).map(d=>({value:d.id,label:d.name,hint:d.code})),placeholder:"Select stage",searchPlaceholder:"Search stages..."})})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{disabled:!G||T.isPending,onClick:d=>{d.preventDefault(),M&&G&&T.mutate({id:M.id,stage_id:G},{onSuccess:()=>z(null)})},children:T.isPending?"Moving…":"Move"})]})]})}),e.jsx(mt,{open:!!te,onOpenChange:d=>!d&&ie(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Reject Application"}),e.jsxs(ht,{children:["Reject the application for ",e.jsx("strong",{children:te==null?void 0:te.candidate_name})," to ",e.jsx("strong",{children:te==null?void 0:te.requisition_number}),"."]})]}),e.jsxs("div",{className:"px-1 py-2",children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Reason for rejection"}),e.jsx(Ae,{className:"mt-1.5",rows:3,placeholder:"Enter the reason for rejecting this application…",value:L,onChange:d=>re(d.target.value)})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:"destructive",disabled:U.isPending,onClick:d=>{d.preventDefault(),te&&U.mutate({id:te.id,rejection_remarks:L},{onSuccess:()=>ie(null)})},children:U.isPending?"Rejecting…":"Reject"})]})]})}),e.jsx(mt,{open:!!ne,onOpenChange:d=>!d&&ce(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Rejection Reason"}),e.jsxs(ht,{children:[e.jsx("strong",{children:ne==null?void 0:ne.candidate_name})," — ",ne==null?void 0:ne.requisition_number]})]}),e.jsx("div",{className:"px-1 py-2 text-[13px] text-slate-700 bg-slate-50 rounded-md p-3 border",children:(ne==null?void 0:ne.rejection_remarks)||"No reason provided."}),e.jsx(jt,{children:e.jsx(gt,{children:"Close"})})]})})]})}function Zr({open:s,onOpenChange:t}){var Re;const[a,n]=h.useState("many_candidates"),[i,u]=h.useState(""),[r,N]=h.useState([]),[y,m]=h.useState([]),[V,F]=h.useState(""),[M,z]=h.useState(""),[G,ee]=h.useState(""),[te,ie]=h.useState("10:00"),[L,re]=h.useState(15),[ne,ce]=h.useState("video"),[J,Q]=h.useState(""),[R,v]=h.useState(""),[S,X]=h.useState(""),[Z,W]=h.useState([]),[de,w]=h.useState(!1),[se,D]=h.useState(null),H=Hi(),{data:I}=gs({page_size:200}),A=h.useMemo(()=>((I==null?void 0:I.results)??[]).filter(c=>!["rejected","withdrawn","hired"].includes(c.status)),[I]),O=h.useMemo(()=>{const c=new Map;for(const Y of A)Y.requisition&&!c.has(Y.requisition)&&c.set(Y.requisition,Y.requisition_number??Y.requisition);return[...c].map(([Y,ve])=>({value:Y,label:ve}))},[A]),K=h.useMemo(()=>i?A.filter(c=>c.requisition===i):A,[A,i]),_e=a==="many_candidates"?i:((Re=A.find(c=>c.id===V))==null?void 0:Re.requisition)??"",{data:T}=Us({page_size:100,..._e?{for_requisition:_e}:{}}),qe=(T==null?void 0:T.results)??[],[U,ae]=h.useState(""),{data:_}=js({page_size:200,...U?{search:U}:{}}),ue=(_==null?void 0:_.results)??[],pe=c=>{const Y=ue.find(ve=>ve.id===c);return Y?`${Y.first_name} ${Y.last_name}`.trim():c},fe=h.useMemo(()=>a==="many_candidates"?M?r.map(c=>({application:c,round:M})):[]:V?qe.filter(c=>y.includes(c.id)).map((c,Y)=>({application:V,round:c.id,...de&&G?{scheduled_date:Xr(G,Y)}:{}})):[],[a,M,r,V,y,qe,de,G]);function Ke(){N([]),m([]),F(""),z(""),D(null)}function Oe(c){c||Ke(),t(c)}function E(){H.mutate({slots:fe,scheduled_date:G,start_time:te,gap_minutes:a==="many_candidates"?L:0,mode:ne,location:J,meeting_link:R,...S?{primary_interviewer:S}:{},...Z.length?{additional_interviewers:Z}:{}},{onSuccess:c=>{D(c),c.skipped_count===0&&Oe(!1)},onError:c=>{var ve;const Y=(ve=c==null?void 0:c.response)==null?void 0:ve.data;Y&&Array.isArray(Y.skipped)&&D(Y)}})}const ye=fe.length>0&&!!G&&!!te&&!H.isPending;return e.jsx(De,{open:s,onOpenChange:Oe,children:e.jsxs(Ee,{size:"lg",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:"Bulk Schedule Interviews"}),e.jsx(Ie,{children:"Schedule many interviews in one go. Slots are laid back-to-back from the start time using each round’s duration."})]}),e.jsxs("div",{className:"flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(pa,{active:a==="many_candidates",icon:e.jsx(_n,{className:"h-4 w-4"}),title:"Many candidates",subtitle:"One round, several applicants",onClick:()=>{n("many_candidates"),Ke()}}),e.jsx(pa,{active:a==="many_rounds",icon:e.jsx(Ls,{className:"h-4 w-4"}),title:"Many rounds",subtitle:"One applicant, full loop",onClick:()=>{n("many_rounds"),Ke()}})]}),a==="many_candidates"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Requisition"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:i||null,onValueChange:c=>{u(c),N([]),z("")},options:O,placeholder:"All requisitions",searchPlaceholder:"Search requisitions..."})}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-400",children:"Narrow the candidate list, and load the rounds for that opening."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Round *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:M||null,onValueChange:z,disabled:!i,options:qe.map(c=>({value:c.id,label:c.name,hint:`${c.duration_minutes}m${c.category_name?` · ${c.category_name}`:""}`})),placeholder:i?"Select round":"Select a requisition first",searchPlaceholder:"Search rounds..."})})]}),e.jsx(el,{applications:K,selected:r,onChange:N})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Application *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:V||null,onValueChange:c=>{F(c),m([])},options:A.map(c=>({value:c.id,label:`${c.candidate_name} — ${c.requisition_number}`})),placeholder:"Select application",searchPlaceholder:"Search applications..."})})]}),e.jsx(tl,{rounds:qe,selected:y,onChange:m,disabled:!V}),e.jsxs("label",{className:"flex items-center gap-2.5",children:[e.jsx(Lt,{checked:de,onCheckedChange:c=>w(c===!0)}),e.jsx("span",{className:"text-[13px] text-slate-600",children:"Spread across consecutive days (one round per day)"})]})]}),e.jsxs("div",{className:"space-y-4 rounded-lg border border-slate-200 p-4",children:[e.jsx("p",{className:"border-b border-slate-100 pb-2 text-[13px] font-semibold text-slate-700",children:"Schedule"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:a==="many_rounds"&&de?"First Date *":"Date *"}),e.jsx(b,{type:"date",value:G,onChange:c=>ee(c.target.value),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Start Time *"}),e.jsx(b,{type:"time",value:te,onChange:c=>ie(c.target.value),className:"mt-1.5"})]})]}),a==="many_candidates"&&e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Gap Between Interviews"}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsx(b,{type:"number",min:0,max:480,value:L,onChange:c=>re(Number(c.target.value)),className:"w-24"}),e.jsx("span",{className:"text-[12px] text-slate-500",children:"minutes"})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Mode"}),e.jsxs(Ce,{value:ne,onValueChange:c=>ce(c),children:[e.jsx(Se,{className:"mt-1.5 h-9",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"video",children:"Video"}),e.jsx(q,{value:"phone",children:"Phone"}),e.jsx(q,{value:"in_person",children:"In Person"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Location"}),e.jsx(b,{value:J,onChange:c=>Q(c.target.value),className:"mt-1.5",placeholder:"Office / Room"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Meeting Link"}),e.jsx(b,{value:R,onChange:c=>v(c.target.value),className:"mt-1.5",placeholder:"https://..."})]})]})]}),e.jsxs("div",{className:"space-y-4 rounded-lg border border-slate-200 p-4",children:[e.jsxs("p",{className:"border-b border-slate-100 pb-2 text-[13px] font-semibold text-slate-700",children:["Panel ",e.jsx("span",{className:"font-normal text-slate-400",children:"— applied to every interview"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Primary Interviewer"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:S||null,onValueChange:X,onSearch:ae,options:ue.map(c=>({value:c.id,label:`${c.first_name} ${c.last_name}`.trim(),hint:c.employee_id})),selectedLabel:S?pe(S):void 0,placeholder:"Select primary interviewer",searchPlaceholder:"Search employees..."})})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Additional Interviewers"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:null,onValueChange:c=>{c&&c!==S&&!Z.includes(c)&&W([...Z,c])},onSearch:ae,options:ue.filter(c=>c.id!==S&&!Z.includes(c.id)).map(c=>({value:c.id,label:`${c.first_name} ${c.last_name}`.trim(),hint:c.employee_id})),placeholder:"Add interviewer",searchPlaceholder:"Search employees..."})}),Z.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Z.map(c=>e.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-slate-100 px-2 py-0.5 text-[11px] text-slate-700",children:[pe(c),e.jsx("button",{type:"button",onClick:()=>W(Z.filter(Y=>Y!==c)),children:e.jsx(ls,{className:"h-3 w-3"})})]},c))})]})]}),se&&e.jsxs("div",{className:"space-y-3",children:[se.created_count>0&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-emerald-200 bg-emerald-50 p-3",children:[e.jsx(It,{className:"mt-0.5 h-4 w-4 shrink-0 text-emerald-600"}),e.jsxs("p",{className:"text-[13px] text-emerald-900",children:["Scheduled ",se.created_count," interview",se.created_count===1?"":"s","."]})]}),se.skipped_count>0&&e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-amber-200 pb-2",children:[e.jsx(vn,{className:"h-4 w-4 text-amber-600"}),e.jsxs("p",{className:"text-[13px] font-semibold text-amber-900",children:[se.skipped_count," not scheduled"]})]}),e.jsx("ul",{className:"mt-2 space-y-1.5",children:se.skipped.map(c=>e.jsxs("li",{className:"text-[12px] text-amber-900",children:[e.jsx("span",{className:"font-medium",children:c.label||`Row ${c.index+1}`}),e.jsx("span",{className:"block text-amber-700",children:c.reason})]},c.index))})]})]})]}),e.jsxs(Qe,{children:[e.jsx("div",{className:"mr-auto text-[12px] text-slate-500",children:fe.length>0?`${fe.length} interview${fe.length===1?"":"s"} will be created`:"Nothing selected yet"}),e.jsx(P,{variant:"outline",onClick:()=>Oe(!1),children:se?"Close":"Cancel"}),e.jsx(P,{onClick:E,disabled:!ye,children:H.isPending?"Scheduling…":`Schedule ${fe.length||""}`.trim()})]})]})})}function Xr(s,t){const a=new Date(`${s}T00:00:00`);return a.setDate(a.getDate()+t),a.toISOString().slice(0,10)}function pa({active:s,icon:t,title:a,subtitle:n,onClick:i}){return e.jsxs("button",{type:"button",onClick:i,className:`rounded-lg border p-3 text-left transition-colors ${s?"border-primary bg-primary/5":"border-slate-200 hover:border-slate-300 hover:bg-slate-50"}`,children:[e.jsxs("div",{className:`flex items-center gap-2 ${s?"text-primary":"text-slate-600"}`,children:[t,e.jsx("span",{className:"text-[13px] font-medium",children:a})]}),e.jsx("p",{className:"mt-0.5 text-[11px] text-slate-500",children:n})]})}function el({applications:s,selected:t,onChange:a}){const n=s.length>0&&t.length===s.length;function i(u){a(t.includes(u)?t.filter(r=>r!==u):[...t,u])}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs(o,{className:"text-[12px] font-medium text-slate-500",children:["Candidates * ",e.jsx(le,{variant:"secondary",className:"ml-1.5 text-[10px]",children:t.length})]}),s.length>0&&e.jsx("button",{type:"button",className:"text-[12px] text-primary hover:underline",onClick:()=>a(n?[]:s.map(u=>u.id)),children:n?"Clear all":"Select all"})]}),e.jsx("div",{className:"max-h-56 divide-y divide-slate-100 overflow-y-auto rounded-lg border border-slate-200",children:s.length===0?e.jsx("p",{className:"p-4 text-center text-[13px] text-slate-400",children:"No open applications to schedule."}):s.map(u=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 px-3 py-2 hover:bg-slate-50",children:[e.jsx(Lt,{checked:t.includes(u.id),onCheckedChange:()=>i(u.id)}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-[13px] text-slate-800",children:u.candidate_name}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:u.requisition_number})]}),e.jsx(le,{variant:"secondary",className:"text-[10px] capitalize",children:u.status.replace(/_/g," ")})]},u.id))})]})}function tl({rounds:s,selected:t,onChange:a,disabled:n}){const i=s.length>0&&t.length===s.length;function u(r){a(t.includes(r)?t.filter(N=>N!==r):[...t,r])}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between",children:[e.jsxs(o,{className:"text-[12px] font-medium text-slate-500",children:["Rounds * ",e.jsx(le,{variant:"secondary",className:"ml-1.5 text-[10px]",children:t.length})]}),!n&&s.length>0&&e.jsx("button",{type:"button",className:"text-[12px] text-primary hover:underline",onClick:()=>a(i?[]:s.map(r=>r.id)),children:i?"Clear all":"Select all"})]}),e.jsx("div",{className:"max-h-56 divide-y divide-slate-100 overflow-y-auto rounded-lg border border-slate-200",children:n?e.jsx("p",{className:"p-4 text-center text-[13px] text-slate-400",children:"Select an application first."}):s.length===0?e.jsx("p",{className:"p-4 text-center text-[13px] text-slate-400",children:"No rounds defined for this requisition’s category."}):s.map(r=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-3 px-3 py-2 hover:bg-slate-50",children:[e.jsx(Lt,{checked:t.includes(r.id),onCheckedChange:()=>u(r.id)}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:"block text-[13px] text-slate-800",children:r.name}),e.jsxs("span",{className:"block text-[11px] text-slate-400",children:[r.duration_minutes,"m",r.category_name?` · ${r.category_name}`:""]})]})]},r.id))})]})}const ha={scheduled:"default",confirmed:"default",in_progress:"warning",completed:"success",cancelled:"destructive",no_show:"destructive",rescheduled:"warning"},sl=ct({application:C().min(1,"Application is required"),round:C().min(1,"Round is required"),scheduled_date:Ta("Date is required"),start_time:C().min(1,"Start time is required"),end_time:C().min(1,"End time is required"),mode:C().optional(),location:C().optional(),meeting_link:C().optional(),primary_interviewer:C().optional(),additional_interviewers:Aa(C()).optional()});function nd(){var dt,At,Rt;const[s,t]=h.useState(!1),[a,n]=h.useState(!1),[i,u]=h.useState(null),[r,N]=h.useState(null),[y,m]=h.useState(null),[V,F]=h.useState(""),[M,z]=h.useState(""),[G,ee]=h.useState(""),[te,ie]=h.useState(""),{hasPermission:L,requirePermission:re}=et(),ne=L("recruitment","interview","create"),ce=L("recruitment","interview","update"),{pagination:J,setPagination:Q,sorting:R,setSorting:v,globalFilter:S,setGlobalFilter:X,queryParams:Z}=tt(),{data:W,isLoading:de}=Qa(Z),w=(W==null?void 0:W.results)??[],se=Gi(),D=Ji(),H=Wi(),I=Yi(),A=Zi(),O=Ye({resolver:nt(sl),defaultValues:{application:"",round:"",scheduled_date:"",start_time:"",end_time:"",mode:"video",location:"",meeting_link:"",primary_interviewer:"",additional_interviewers:[]}}),{data:K}=gs({page_size:100}),_e=((K==null?void 0:K.results)??[]).filter(d=>!["rejected","withdrawn","hired"].includes(d.status)),{data:T}=Qs({page_size:200}),qe=(T==null?void 0:T.results)??[],U=O.watch("application"),ae=_e.find(d=>d.id===U),{data:_}=Us({page_size:100,...ae!=null&&ae.requisition?{for_requisition:ae.requisition}:{}}),ue=(_==null?void 0:_.results)??[],[pe,fe]=h.useState(""),{data:Ke}=js({page_size:200,...ae!=null&&ae.company?{company:ae.company}:{},...pe?{search:pe}:{}}),Oe=(Ke==null?void 0:Ke.results)??[],[E,ye]=h.useState({});h.useEffect(()=>{Oe.length!==0&&ye(d=>{const f={...d};for(const he of Oe)f[he.id]=`${he.first_name} ${he.last_name}`.trim();return f})},[Oe]);function Re(){re("recruitment","interview","create")&&(u(null),O.reset({application:"",round:"",scheduled_date:"",start_time:"",end_time:"",mode:"video",location:"",meeting_link:"",primary_interviewer:"",additional_interviewers:[]}),t(!0))}function c(d){if(!re("recruitment","interview","update"))return;u(d);const f=d.panel_members_detail??[],he=f.find(Ge=>Ge.role==="lead"),Ze=f.filter(Ge=>Ge.role!=="lead").map(Ge=>Ge.interviewer);ye(Ge=>{const Nt={...Ge};for(const Dt of f)Dt.interviewer_name&&(Nt[Dt.interviewer]=Dt.interviewer_name);return Nt}),O.reset({application:d.application,round:d.round,scheduled_date:d.scheduled_date,start_time:d.start_time,end_time:d.end_time,mode:d.mode,location:d.location,meeting_link:d.meeting_link,primary_interviewer:(he==null?void 0:he.interviewer)??"",additional_interviewers:Ze}),t(!0)}function Y(d){const f=d;i?D.mutate({id:i.id,...f},{onSuccess:()=>t(!1)}):se.mutate(f,{onSuccess:()=>t(!1)})}function ve(d){if(!d)return"-";const f=d.split(":"),he=f[0]??"0",Ze=f[1]??"00",Ge=parseInt(he,10),Nt=Ge>=12?"PM":"AM";return`${Ge%12||12}:${Ze} ${Nt}`}function Be(d,f){if(!d||!f)return"-";const he=d.split(":").map(Number),Ze=f.split(":").map(Number);return`${(Ze[0]??0)*60+(Ze[1]??0)-((he[0]??0)*60+(he[1]??0))}m`}const yt=[{key:"candidate_name",header:"Candidate",render:d=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:d.candidate_name}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:d.requisition_number})]})},{key:"round_name",header:"Round",render:d=>e.jsx("span",{className:"text-[13px] text-slate-600",children:d.round_name})},{key:"mode",header:"Type",render:d=>e.jsx("span",{className:"text-[12px] text-slate-600 capitalize",children:d.mode.replace(/_/g," ")})},{key:"scheduled_date",header:"Date",render:d=>e.jsx("span",{className:"text-[12px] text-slate-600",children:new Date(d.scheduled_date).toLocaleDateString()})},{key:"start_time",header:"Time",render:d=>e.jsx("span",{className:"text-[12px] text-slate-600",children:ve(d.start_time)})},{key:"end_time",header:"Duration",render:d=>e.jsx("span",{className:"text-[12px] text-slate-600",children:Be(d.start_time,d.end_time)})},{key:"status",header:"Status",render:d=>e.jsx(le,{variant:ha[d.status],className:"capitalize text-[11px]",children:d.status.replace(/_/g," ")})},{key:"actions",header:"",className:"w-10",render:d=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[e.jsxs(B,{onClick:()=>N(d),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View"]}),ce&&["scheduled","confirmed","rescheduled"].includes(d.status)&&e.jsxs(e.Fragment,{children:[e.jsxs(B,{onClick:()=>c(d),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),e.jsxs(B,{onClick:()=>H.mutate(d.id),children:[e.jsx(It,{className:"mr-2 h-3.5 w-3.5"})," Complete"]}),e.jsxs(B,{onClick:()=>{m(d),F(d.scheduled_date),z(d.start_time),ee(d.end_time),ie("")},children:[e.jsx(Fs,{className:"mr-2 h-3.5 w-3.5"})," Reschedule"]}),e.jsx(We,{}),e.jsxs(B,{className:"text-red-600",onClick:()=>I.mutate({id:d.id,reason:""}),children:[e.jsx(cs,{className:"mr-2 h-3.5 w-3.5"})," Cancel"]})]}),ce&&d.status==="in_progress"&&e.jsxs(B,{onClick:()=>H.mutate(d.id),children:[e.jsx(It,{className:"mr-2 h-3.5 w-3.5"})," Complete"]})]})]})}];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"})," Interviews"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Schedule and track candidate interviews"})]}),ne&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>n(!0),children:[e.jsx(ns,{className:"mr-1.5 h-3.5 w-3.5"})," Bulk Schedule"]}),e.jsxs(P,{size:"sm",onClick:Re,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Schedule Interview"]})]})]}),e.jsx(st,{columns:yt,data:w,isLoading:de,searchPlaceholder:"Search interviews...",emptyMessage:"No interviews",emptyDescription:"Schedule your first interview to get started.",totalCount:(W==null?void 0:W.count)??0,pagination:J,onPaginationChange:Q,sorting:R,onSortingChange:v,globalFilter:S,onGlobalFilterChange:X}),e.jsx(Zr,{open:a,onOpenChange:n}),e.jsx(De,{open:!!r,onOpenChange:d=>!d&&N(null),children:e.jsxs(Ee,{size:"lg",children:[e.jsxs(Te,{children:[e.jsxs(Ve,{children:[r==null?void 0:r.candidate_name," — ",r==null?void 0:r.round_name]}),e.jsx(Ie,{children:e.jsx(le,{variant:ha[(r==null?void 0:r.status)??"scheduled"],className:"capitalize text-[11px]",children:(dt=r==null?void 0:r.status)==null?void 0:dt.replace(/_/g," ")})})]}),r&&e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4 text-[13px]",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Candidate"}),e.jsx("p",{className:"text-slate-800",children:r.candidate_name})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Email"}),e.jsx("p",{className:"text-slate-800",children:r.candidate_email})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Resume"}),r.candidate_resume?e.jsxs("a",{href:r.candidate_resume,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-[12px] text-primary bg-primary/5 border border-primary/20 rounded px-2.5 py-1.5 hover:bg-primary/10 transition-colors",children:[e.jsx(kt,{className:"h-4 w-4"})," View Resume"]}):e.jsx("p",{className:"text-slate-400 text-[13px]",children:"No resume attached"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Requisition"}),e.jsxs("p",{className:"text-slate-800",children:[r.requisition_number," — ",r.requisition_title]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Round"}),e.jsxs("p",{className:"text-slate-800 capitalize",children:[r.round_name," (",(At=r.round_type)==null?void 0:At.replace(/_/g," "),")"]})]})]}),e.jsxs("div",{className:"rounded-lg border border-slate-200 p-4 space-y-3",children:[e.jsx("p",{className:"text-[13px] font-semibold text-slate-700 border-b border-slate-100 pb-2",children:"Schedule"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Date"}),e.jsx("p",{className:"text-slate-800",children:new Date(r.scheduled_date).toLocaleDateString()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Time"}),e.jsxs("p",{className:"text-slate-800",children:[ve(r.start_time)," – ",ve(r.end_time)," (",Be(r.start_time,r.end_time),")"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Mode"}),e.jsx("p",{className:"text-slate-800 capitalize",children:(Rt=r.mode)==null?void 0:Rt.replace(/_/g," ")})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Timezone"}),e.jsx("p",{className:"text-slate-800",children:r.timezone||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Location"}),e.jsx("p",{className:"text-slate-800",children:r.location||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Meeting Link"}),r.meeting_link?e.jsx("a",{href:r.meeting_link,target:"_blank",rel:"noreferrer",className:"text-primary underline break-all",children:r.meeting_link}):e.jsx("p",{className:"text-slate-800",children:"—"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Candidate Confirmed"}),e.jsx("p",{className:"text-slate-800",children:r.candidate_confirmed?`Yes${r.candidate_confirmed_at?` (${new Date(r.candidate_confirmed_at).toLocaleDateString()})`:""}`:"No"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[12px]",children:"Panel Members"}),e.jsx("p",{className:"text-slate-800",children:r.panel_count})]})]}),(r.panel_members_detail??[]).length>0&&e.jsxs("div",{className:"rounded-lg border border-slate-200 p-4 space-y-2",children:[e.jsx("p",{className:"text-[13px] font-semibold text-slate-700 border-b border-slate-100 pb-2",children:"Panel"}),r.panel_members_detail.map(d=>e.jsxs("div",{className:"flex items-center justify-between text-[13px]",children:[e.jsx("span",{className:"text-slate-800",children:d.interviewer_name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{variant:"secondary",className:"capitalize text-[10px]",children:d.role}),e.jsx(le,{variant:d.response==="accepted"?"success":d.response==="declined"?"destructive":"warning",className:"capitalize text-[10px]",children:d.response})]})]},d.id))]}),(r.reschedule_count>0||r.reschedule_reason||r.status==="rescheduled")&&e.jsxs("div",{className:"rounded-lg border border-amber-200 bg-amber-50 p-4 space-y-2",children:[e.jsx("p",{className:"text-[13px] font-semibold text-amber-800 border-b border-amber-200 pb-2",children:"Reschedule Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-amber-600 text-[12px]",children:"Times Rescheduled"}),e.jsx("p",{className:"text-amber-900 font-medium",children:r.reschedule_count})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-amber-600 text-[12px]",children:"Reason"}),e.jsx("p",{className:"text-amber-900",children:r.reschedule_reason||"—"})]})]})]}),(r.status==="cancelled"||r.cancellation_reason)&&e.jsxs("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4 space-y-2",children:[e.jsx("p",{className:"text-[13px] font-semibold text-red-800 border-b border-red-200 pb-2",children:"Cancellation"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-red-600 text-[12px]",children:"Reason"}),e.jsx("p",{className:"text-red-900",children:r.cancellation_reason||"—"})]})]})]}),e.jsx(Qe,{children:e.jsx(P,{variant:"outline",onClick:()=>N(null),children:"Close"})})]})}),e.jsx(De,{open:!!y,onOpenChange:d=>{d||m(null)},children:e.jsxs(Ee,{size:"sm",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:"Reschedule Interview"}),e.jsxs(Ie,{children:[y==null?void 0:y.candidate_name," — ",y==null?void 0:y.round_name]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"New Date *"}),e.jsx(b,{type:"date",value:V,onChange:d=>F(d.target.value),className:"mt-1.5"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Start Time *"}),e.jsx(b,{type:"time",value:M,onChange:d=>z(d.target.value),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"End Time *"}),e.jsx(b,{type:"time",value:G,onChange:d=>ee(d.target.value),className:"mt-1.5"})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Reason"}),e.jsx(b,{value:te,onChange:d=>ie(d.target.value),className:"mt-1.5",placeholder:"Reason for rescheduling..."})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>m(null),children:"Cancel"}),e.jsx(P,{disabled:!V||!M||!G||A.isPending,onClick:()=>{y&&A.mutate({id:y.id,scheduled_date:V,start_time:M,end_time:G,reschedule_reason:te},{onSuccess:()=>m(null)})},children:"Reschedule"})]})]})}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"md",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:i?"Edit Interview":"Schedule Interview"}),e.jsx(Ie,{children:i?"Update interview details.":"Schedule a new interview for an application."})]}),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(o,{className:"text-[12px] font-medium text-slate-500",children:"Application *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:O.watch("application")??null,onValueChange:d=>{O.setValue("application",d,{shouldValidate:!0}),O.setValue("round","",{shouldValidate:!0})},options:_e.map(d=>({value:d.id,label:`${d.candidate_name} — ${d.requisition_number}`})),selectedLabel:i?`${i.candidate_name} — ${i.requisition_number}`:void 0,placeholder:"Select application",searchPlaceholder:"Search applications..."})}),O.formState.errors.application&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:O.formState.errors.application.message}),ae&&(()=>{const d=qe.find(f=>f.id===ae.candidate);return e.jsxs("div",{className:"mt-2 rounded-md border border-emerald-200 bg-emerald-50/50 p-3 space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(It,{className:"h-4 w-4 text-emerald-600 shrink-0"}),e.jsx("p",{className:"text-[13px] font-medium text-slate-800",children:ae.candidate_name})]}),e.jsx("p",{className:"text-[12px] text-slate-500 pl-6",children:ae.candidate_email}),e.jsxs("p",{className:"text-[12px] text-slate-500 pl-6",children:["Requisition: ",ae.requisition_number]}),e.jsx("div",{className:"pl-6",children:d!=null&&d.resume_file?e.jsxs("a",{href:d.resume_file,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 text-[12px] text-primary bg-primary/5 border border-primary/20 rounded px-2 py-1 hover:bg-primary/10 transition-colors",children:[e.jsx(kt,{className:"h-3.5 w-3.5"})," Resume Attached"]}):e.jsx("p",{className:"text-[12px] text-amber-600",children:"⚠ No resume attached"})})]})})()]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Round *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:O.watch("round")??null,onValueChange:d=>O.setValue("round",d,{shouldValidate:!0}),disabled:!U,options:ue.map(d=>({value:d.id,label:d.name,hint:d.category_name||d.requisition_number||void 0})),selectedLabel:i==null?void 0:i.round_name,placeholder:U?"Select round":"Select an application first",searchPlaceholder:"Search rounds..."})}),O.formState.errors.round&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:O.formState.errors.round.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Date *"}),e.jsx(b,{type:"date",...O.register("scheduled_date"),className:"mt-1.5"}),O.formState.errors.scheduled_date&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:O.formState.errors.scheduled_date.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Start Time *"}),e.jsx(b,{type:"time",...O.register("start_time"),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"End Time *"}),e.jsx(b,{type:"time",...O.register("end_time"),className:"mt-1.5"})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Mode"}),e.jsxs(Ce,{value:O.watch("mode"),onValueChange:d=>O.setValue("mode",d),children:[e.jsx(Se,{className:"mt-1.5 h-9",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"video",children:"Video"}),e.jsx(q,{value:"phone",children:"Phone"}),e.jsx(q,{value:"in_person",children:"In Person"})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Location"}),e.jsx(b,{...O.register("location"),className:"mt-1.5",placeholder:"Office / Room"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Meeting Link"}),e.jsx(b,{...O.register("meeting_link"),className:"mt-1.5",placeholder:"https://meet.google.com/..."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Primary Interviewer"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:O.watch("primary_interviewer")||null,onValueChange:d=>O.setValue("primary_interviewer",d),onSearch:fe,options:Oe.map(d=>({value:d.id,label:`${d.first_name} ${d.last_name}`.trim(),hint:d.employee_id})),selectedLabel:E[O.watch("primary_interviewer")??""],placeholder:"Select primary interviewer",searchPlaceholder:"Search employees..."})})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Additional Interviewers"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:null,onValueChange:d=>{const f=O.getValues("additional_interviewers")??[];d&&!f.includes(d)&&O.setValue("additional_interviewers",[...f,d])},onSearch:fe,options:Oe.filter(d=>d.id!==O.watch("primary_interviewer")).map(d=>({value:d.id,label:`${d.first_name} ${d.last_name}`.trim(),hint:d.employee_id})),placeholder:"Add interviewer",searchPlaceholder:"Search employees..."})}),(O.watch("additional_interviewers")??[]).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:(O.watch("additional_interviewers")??[]).map(d=>{const f=E[d];return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] bg-slate-100 text-slate-700 rounded px-2 py-0.5",children:[f??d,e.jsx("button",{type:"button",onClick:()=>{O.setValue("additional_interviewers",(O.getValues("additional_interviewers")??[]).filter(he=>he!==d))},children:e.jsx(ls,{className:"h-3 w-3"})})]},d)})})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:O.handleSubmit(Y),disabled:se.isPending||D.isPending,children:i?"Update":"Schedule"})]})]})})]})}function al(s){switch(s){case"approved":case"accepted":return"approved";case"declined":return"rejected";case"expired":return"expired";case"withdrawn":return"cancelled";case"sent":case"viewed":case"negotiating":return"in_progress";case"draft":case"pending_approval":default:return"pending"}}const nl=Ln(ct({application:C().min(1,"Application is required"),candidate:C().min(1,"Candidate is required"),requisition:C().min(1,"Requisition is required"),template:C().optional(),designation_offered:C().optional(),grade_offered:C().optional(),department:C().optional(),reporting_to:C().optional(),employee_category:C().optional(),salary_template:C().optional(),ctc_annual:C().optional(),joining_date_proposed:Ta("Date of joining is required"),location_offered:C().min(1,"Work location is required"),offer_valid_until:C().optional(),employment_type:C().optional(),probation_months:Me.number().min(0).optional(),notice_period_days:Me.number().min(0).optional(),special_conditions:C().optional(),variable_pay:C().optional(),signing_bonus:C().optional()}),"joining_date_proposed","offer_valid_until");function qt(s){const t=Number(s);return isNaN(t)?"0.00":t.toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})}function il({offer:s,adminFill:t,onClose:a}){var u,r;const n=Ye({defaultValues:{first_name:((u=s.candidate_name)==null?void 0:u.split(" ")[0])||"",last_name:((r=s.candidate_name)==null?void 0:r.split(" ").slice(1).join(" "))||"",date_of_birth:"",gender:"",blood_group:"",marital_status:"",nationality:"Indian",personal_email:s.candidate_email||"",personal_phone:"",current_address:"",permanent_address:"",same_as_current:!1,emergency_name:"",emergency_relationship:"",emergency_phone:"",bank_name:"",bank_account_number:"",bank_ifsc:"",bank_account_type:"savings",bank_branch:"",aadhaar_number:"",pan_number:"",passport_number:"",passport_expiry:""}});function i(N){t.mutate({id:s.id,...N},{onSuccess:()=>a()})}return e.jsxs(e.Fragment,{children:[e.jsxs("form",{onSubmit:n.handleSubmit(i),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"bg-blue-50 border border-blue-100 rounded-lg p-3 text-[13px] text-blue-800",children:["Filling joining form for ",e.jsx("strong",{children:s.candidate_name}),". This will create the employee and start onboarding."]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Personal"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"First Name *"}),e.jsx(b,{...n.register("first_name",{required:!0}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Last Name *"}),e.jsx(b,{...n.register("last_name",{required:!0}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Date of Birth"}),e.jsx(b,{type:"date",...n.register("date_of_birth"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Gender"}),e.jsxs(Ce,{value:n.watch("gender"),onValueChange:N=>n.setValue("gender",N),children:[e.jsx(Se,{className:"mt-1",children:e.jsx(we,{placeholder:"Select"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"male",children:"Male"}),e.jsx(q,{value:"female",children:"Female"}),e.jsx(q,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Blood Group"}),e.jsx(b,{...n.register("blood_group"),className:"mt-1",placeholder:"e.g. O+"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Marital Status"}),e.jsxs(Ce,{value:n.watch("marital_status"),onValueChange:N=>n.setValue("marital_status",N),children:[e.jsx(Se,{className:"mt-1",children:e.jsx(we,{placeholder:"Select"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"single",children:"Single"}),e.jsx(q,{value:"married",children:"Married"})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Nationality"}),e.jsx(b,{...n.register("nationality"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Email"}),e.jsx(b,{type:"email",...n.register("personal_email"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Phone"}),e.jsx($t,{value:n.watch("personal_phone"),onChange:N=>n.setValue("personal_phone",N.target.value.replace(/\D/g,"")),className:"mt-1",maxLength:10,placeholder:"10-digit number"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Address"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Current Address"}),e.jsx(b,{...n.register("current_address"),className:"mt-1"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-slate-600",children:[e.jsx("input",{type:"checkbox",...n.register("same_as_current"),className:"rounded"})," Same as current"]}),!n.watch("same_as_current")&&e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Permanent Address"}),e.jsx(b,{...n.register("permanent_address"),className:"mt-1"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Emergency Contact"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Name"}),e.jsx(b,{...n.register("emergency_name"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Relationship"}),e.jsx(b,{...n.register("emergency_relationship"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Phone"}),e.jsx($t,{value:n.watch("emergency_phone"),onChange:N=>n.setValue("emergency_phone",N.target.value.replace(/\D/g,"")),className:"mt-1",maxLength:10,placeholder:"10-digit number"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Bank Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Bank Name"}),e.jsx(b,{...n.register("bank_name"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Account Number"}),e.jsx($t,{...n.register("bank_account_number"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"IFSC"}),e.jsx(b,{...n.register("bank_ifsc"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Branch"}),e.jsx(b,{...n.register("bank_branch"),className:"mt-1"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Identity"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Aadhaar"}),e.jsx($t,{...n.register("aadhaar_number"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"PAN"}),e.jsx(b,{...n.register("pan_number"),className:"mt-1"})]})]})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:a,children:"Cancel"}),e.jsxs(P,{onClick:n.handleSubmit(i),disabled:t.isPending,children:[e.jsx(Wt,{className:"h-3.5 w-3.5 mr-1.5"}),t.isPending?"Onboarding...":"Submit & Onboard"]})]})]})}function id(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),[r,N]=h.useState([]),{hasPermission:y,requirePermission:m}=et(),V=y("recruitment","offer","create"),F=y("recruitment","offer","update"),{pagination:M,setPagination:z,sorting:G,setSorting:ee,globalFilter:te,setGlobalFilter:ie,queryParams:L}=tt(),{data:re,isLoading:ne}=Gs(L),ce=(re==null?void 0:re.results)??[],J=xr(),Q=ur(),R=pr(),v=hr(),S=Hs(),X=Js(),Z=Ua(),W=Ba(),[de,w]=h.useState(null),[se,D]=h.useState(null),[H,I]=h.useState(""),A=fr(),O=jr(),K=Ye({resolver:nt(nl),defaultValues:{application:"",candidate:"",requisition:"",template:"",designation_offered:"",grade_offered:"",department:"",reporting_to:"",employee_category:"",salary_template:"",ctc_annual:"",joining_date_proposed:"",location_offered:"",offer_valid_until:"",employment_type:"permanent",probation_months:6,notice_period_days:30,special_conditions:"",variable_pay:"0",signing_bonus:"0"}}),{data:_e}=gs({page_size:100}),T=(_e==null?void 0:_e.results)??[],{data:qe}=Tn({page_size:100}),U=(qe==null?void 0:qe.results)??[],{data:ae}=Vn({page_size:100}),_=(ae==null?void 0:ae.results)??[],{data:ue}=Da({page_size:100}),pe=(ue==null?void 0:ue.results)??[],{data:fe}=Ea({page_size:100}),Ke=(fe==null?void 0:fe.results)??[],{data:Oe}=On({page_size:100}),E=(Oe==null?void 0:Oe.results)??[],[ye,Re]=h.useState(""),{data:c}=js({page_size:200,...ye?{search:ye}:{}}),Y=(c==null?void 0:c.results)??[],ve=K.watch("employee_category"),{data:Be}=zn({page_size:100,...ve?{employee_category:ve}:{},is_active:!0}),yt=(Be==null?void 0:Be.results)??[],{data:dt,isLoading:At}=Bs({page_size:100,is_active:!0,document_type:"offer_letter"}),Rt=(dt==null?void 0:dt.results)??[],d=K.watch("application");h.useEffect(()=>{if(a)return;const x=T.find(xe=>xe.id===d);x&&(K.setValue("candidate",x.candidate),K.setValue("requisition",x.requisition))},[d,T,a]),h.useEffect(()=>{a||(K.setValue("salary_template",""),N([]))},[ve]);const f=r.filter(x=>x.component_type==="earning"),he=r.filter(x=>x.component_type==="employer_contribution"),Ze=r.filter(x=>x.component_type==="deduction"),Ge=f.reduce((x,xe)=>x+(parseFloat(xe.annual)||0),0),Nt=f.reduce((x,xe)=>x+(parseFloat(xe.monthly)||0),0),Dt=he.reduce((x,xe)=>x+(parseFloat(xe.annual)||0),0),Zt=he.reduce((x,xe)=>x+(parseFloat(xe.monthly)||0),0),Ot=Ze.reduce((x,xe)=>x+(parseFloat(xe.annual)||0),0),Ys=Ze.reduce((x,xe)=>x+(parseFloat(xe.monthly)||0),0),Zs=Ge+Dt,Xa=Nt+Zt,en=parseFloat(K.watch("variable_pay")||"0")||0,tn=parseFloat(K.watch("signing_bonus")||"0")||0,Xs=parseFloat(K.watch("ctc_annual")||"0")||0,ea=(Xs>0&&r.length>0?Xs:Zs)+en+tn;function sn(x,xe){N(He=>He.map((Ne,Le)=>{if(Le!==x)return Ne;const Je=parseFloat(xe)||0;return{...Ne,annual:xe,monthly:Je>0?(Je/12).toFixed(2):""}}))}function an(x,xe){N(He=>He.map((Ne,Le)=>{if(Le!==x)return Ne;const Je=parseFloat(xe)||0;return{...Ne,monthly:xe,annual:Je>0?(Je*12).toFixed(2):""}}))}function nn(){N(x=>[...x,{code:`custom_${Date.now()}`,label:"",annual:"",monthly:""}])}function rn(x){N(xe=>xe.filter((He,Ne)=>Ne!==x))}const fs=h.useCallback(()=>{const x=K.getValues("salary_template"),xe=K.getValues("ctc_annual"),He=parseFloat(xe||"0");!x||!He||A.mutate({template_id:x,ctc:He,requisition:K.getValues("requisition")||void 0},{onSuccess:Ne=>{const Le=Ne.components.map(Je=>({code:Je.code,label:Je.name,annual:Je.annual>0?String(Je.annual):"",monthly:Je.monthly>0?String(Je.monthly):"",component_type:Je.component_type}));N(Le)}})},[K,A]),os=K.watch("salary_template");h.useEffect(()=>{os&&K.getValues("ctc_annual")&&fs()},[os]);const _s=K.watch("ctc_annual");h.useEffect(()=>{if(!os||!_s||parseFloat(_s)<=0)return;const x=setTimeout(()=>{fs()},600);return()=>clearTimeout(x)},[_s,os]);function ln(){m("recruitment","offer","create")&&(n(null),N([]),K.reset({application:"",candidate:"",requisition:"",template:"",designation_offered:"",grade_offered:"",department:"",reporting_to:"",employee_category:"",salary_template:"",ctc_annual:"",joining_date_proposed:"",location_offered:"",offer_valid_until:"",employment_type:"permanent",probation_months:6,notice_period_days:30,special_conditions:"",variable_pay:"0",signing_bonus:"0"}),t(!0))}function cn(x){if(!m("recruitment","offer","update"))return;n(x);const xe=x.ctc_breakup??{};if(Object.keys(xe).length>0){const He=Object.entries(xe).map(([Ne,Le])=>({code:Ne,label:Le.label??Ne,annual:Le.annual!=null?String(Le.annual):"",monthly:Le.monthly!=null?String(Le.monthly):"",component_type:Le.component_type}));N(He)}else N([]);K.reset({application:x.application,candidate:x.candidate,requisition:x.requisition,designation_offered:x.designation_offered??"",grade_offered:x.grade_offered??"",department:x.department??"",reporting_to:x.reporting_to??"",employee_category:x.employee_category??"",salary_template:x.salary_template??"",template:x.template??"",ctc_annual:x.ctc_offered?String(x.ctc_offered):"",joining_date_proposed:x.joining_date_proposed??"",location_offered:x.location_offered??"",offer_valid_until:x.offer_valid_until??"",employment_type:x.employment_type,probation_months:x.probation_months??6,notice_period_days:x.notice_period_days??30,special_conditions:x.special_conditions,variable_pay:x.variable_pay??"0",signing_bonus:x.signing_bonus??"0"}),t(!0)}function ta(x){const xe={};r.forEach(Ne=>{(Ne.annual||Ne.monthly)&&(xe[Ne.code]={label:Ne.label,annual:parseFloat(Ne.annual)||0,monthly:parseFloat(Ne.monthly)||0,...Ne.component_type?{component_type:Ne.component_type}:{}})});const He={...x,ctc_offered:String(ea),ctc_breakup:xe,template:x.template||null,designation_offered:x.designation_offered||null,grade_offered:x.grade_offered||null,department:x.department||null,reporting_to:x.reporting_to||null,variable_pay:x.variable_pay,signing_bonus:x.signing_bonus,location_offered:x.location_offered||null,employee_category:x.employee_category||null,salary_template:x.salary_template||null,probation_months:x.probation_months,notice_period_days:x.notice_period_days};a?Q.mutate({id:a.id,...He},{onSuccess:()=>t(!1)}):J.mutate(He,{onSuccess:()=>t(!1)})}const on=[{key:"offer_number",header:"Offer #",render:x=>e.jsx(xs,{to:`/recruitment/offers/${x.id}`,className:"font-medium text-primary hover:underline text-[13px]",children:x.offer_number})},{key:"candidate_name",header:"Candidate",render:x=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:x.candidate_name}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:x.candidate_email})]})},{key:"requisition_number",header:"Requisition",render:x=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[13px] text-slate-600",children:x.requisition_number}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:x.requisition_title})]})},{key:"ctc_offered",header:"Offered CTC",render:x=>e.jsx("span",{className:"text-[13px] text-slate-700 font-medium",children:x.ctc_offered?`₹${qt(x.ctc_offered)}`:"-"})},{key:"status",header:"Status",render:x=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Mn,{status:al(x.status)}),e.jsx("span",{className:"text-[10.5px] text-[#94a3b8] capitalize",children:x.status.replace(/_/g," ")})]})},{key:"offer_valid_until",header:"Valid Until",render:x=>e.jsx("span",{className:"text-[12px] text-slate-500",children:x.offer_valid_until?new Date(x.offer_valid_until).toLocaleDateString():"-"})},{key:"actions",header:"",className:"w-10",render:x=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[e.jsxs(B,{onClick:()=>u(x),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View Offer"]}),e.jsxs(B,{onClick:()=>{O.mutate(x.id,{onSuccess:({blob:xe})=>{const He=URL.createObjectURL(xe);D(He),I(x.offer_number)}})},disabled:O.isPending,children:[e.jsx(Ss,{className:"mr-2 h-3.5 w-3.5"})," Download PDF"]}),F&&x.status==="draft"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{onClick:()=>cn(x),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),e.jsxs(B,{onClick:()=>R.mutate(x.id),children:[e.jsx(Kt,{className:"mr-2 h-3.5 w-3.5"})," Send to Candidate"]})]}),F&&x.status==="approved"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{onClick:()=>R.mutate(x.id),children:[e.jsx(Kt,{className:"mr-2 h-3.5 w-3.5"})," Send to Candidate"]})]}),F&&["sent","viewed","expired"].includes(x.status)&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{onClick:()=>Z.mutate(x.id),disabled:Z.isPending,children:[e.jsx(Fs,{className:"mr-2 h-3.5 w-3.5"})," Resend Offer"]})]}),F&&x.status==="accepted"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{onClick:()=>S.mutate(x.id),children:[e.jsx(Os,{className:"mr-2 h-3.5 w-3.5"})," Send Pre-Joining Form"]}),e.jsxs(B,{onClick:()=>X.mutate(x.id),children:[e.jsx(Ks,{className:"mr-2 h-3.5 w-3.5"})," Send Joining Reminder"]})]}),F&&!["declined","withdrawn","expired"].includes(x.status)&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{onClick:()=>w(x),children:[e.jsx(Wt,{className:"mr-2 h-3.5 w-3.5"})," Fill Joining Form & Onboard"]})]}),F&&!["withdrawn","expired","accepted","declined"].includes(x.status)&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{className:"text-red-600",onClick:()=>v.mutate({id:x.id}),children:[e.jsx(cs,{className:"mr-2 h-3.5 w-3.5"})," Withdraw"]})]})]})]})}];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(Vs,{className:"h-5 w-5 text-primary"})," Offers"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Create, approve, and track offer letters"})]}),V&&e.jsxs(P,{size:"sm",onClick:ln,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Offer"]})]}),e.jsx(st,{columns:on,data:ce,isLoading:ne,searchPlaceholder:"Search offers...",emptyMessage:"No offers",emptyDescription:"Create your first offer to extend to a candidate.",totalCount:(re==null?void 0:re.count)??0,pagination:M,onPaginationChange:z,sorting:G,onSortingChange:ee,globalFilter:te,onGlobalFilterChange:ie}),e.jsx(bt,{open:!!i,onOpenChange:x=>!x&&u(null),children:e.jsxs(Ct,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[e.jsx(St,{children:e.jsxs(wt,{children:["Offer Letter — ",i==null?void 0:i.offer_number]})}),i&&(()=>{const x=i.ctc_breakup??{},xe=Object.entries(x).filter(([,je])=>(je.annual??0)>0||(je.monthly??0)>0),He=xe.filter(([,je])=>je.component_type==="earning"),Ne=xe.filter(([,je])=>je.component_type==="employer_contribution"),Le=xe.filter(([,je])=>je.component_type==="deduction"),Je=He.reduce((je,[,Fe])=>je+(Fe.annual??0),0),Bt=He.reduce((je,[,Fe])=>je+(Fe.monthly??0),0),vs=Ne.reduce((je,[,Fe])=>je+(Fe.annual??0),0),dn=Ne.reduce((je,[,Fe])=>je+(Fe.monthly??0),0),sa=Le.reduce((je,[,Fe])=>je+(Fe.annual??0),0),aa=Le.reduce((je,[,Fe])=>je+(Fe.monthly??0),0),na=Je+vs,mn=Bt+dn,ds=parseFloat(String(i.variable_pay??"0"))||0,ys=parseFloat(String(i.signing_bonus??"0"))||0,xn=na+ds+ys,Xe=je=>je.toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2});return e.jsxs("div",{className:"space-y-4 text-[13px]",children:[e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[["Offer Number",i.offer_number],["Candidate",i.candidate_name],["Position",i.requisition_title],["Offer Template",i.template_name||"—"],["Designation",i.designation_offered_name||"—"],["Department",i.department_name||"—"],["Grade",i.grade_offered_name||"—"],["Reporting To",i.reporting_to_name||"—"],["Work Location",i.location_offered_name||"—"],["Employee Category",i.employee_category_name||"—"],["Employment Type",i.employment_type],["Date of Joining",i.joining_date_proposed?new Date(i.joining_date_proposed).toLocaleDateString("en-IN"):"—"],["Valid Until",i.offer_valid_until?new Date(i.offer_valid_until).toLocaleDateString("en-IN"):"—"],["Probation",i.probation_months?`${i.probation_months} months`:"—"],["Notice Period",i.notice_period_days?`${i.notice_period_days} days`:"—"],["Status",i.status.replace(/_/g," ")]].map(([je,Fe])=>e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-[11px] text-slate-400 uppercase tracking-wide font-medium",children:je}),e.jsx("p",{className:"font-semibold text-slate-800 mt-0.5 capitalize",children:Fe})]},je))}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-slate-700 mb-2",children:"Salary Breakup"}),e.jsxs("table",{className:"w-full border border-slate-200 rounded-lg overflow-hidden text-[12px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 border-b border-slate-200",children:[e.jsx("th",{className:"text-left px-3 py-2 text-slate-500 font-medium",children:"Component"}),e.jsx("th",{className:"text-right px-3 py-2 text-slate-500 font-medium",children:"Annual (₹)"}),e.jsx("th",{className:"text-right px-3 py-2 text-slate-500 font-medium",children:"Monthly (₹)"})]})}),e.jsx("tbody",{children:xe.length>0?He.map(([je,Fe])=>e.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[e.jsx("td",{className:"px-3 py-2 text-slate-700",children:Fe.label??je}),e.jsxs("td",{className:"px-3 py-2 text-right",children:["₹",Xe(Fe.annual??0)]}),e.jsxs("td",{className:"px-3 py-2 text-right text-slate-500",children:["₹",Xe(Fe.monthly??0)]})]},je)):e.jsx("tr",{children:e.jsx("td",{colSpan:3,className:"px-3 py-3 text-center text-slate-400",children:"No salary components"})})}),e.jsxs("tfoot",{children:[e.jsxs("tr",{className:"bg-slate-50 border-t-2 border-slate-200 font-semibold",children:[e.jsx("td",{className:"px-3 py-2 text-slate-700",children:"Gross Salary"}),e.jsxs("td",{className:"px-3 py-2 text-right",children:["₹",Xe(Je)]}),e.jsxs("td",{className:"px-3 py-2 text-right",children:["₹",Xe(Bt)]})]}),Ne.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"bg-blue-50/30 border-t border-slate-100 text-[11px] text-blue-600 font-semibold",children:e.jsx("td",{className:"px-3 py-1",colSpan:3,children:"Employer Contributions"})}),Ne.map(([je,Fe])=>e.jsxs("tr",{className:"border-b border-slate-100 bg-blue-50/10",children:[e.jsx("td",{className:"px-3 py-1.5 text-slate-600",children:Fe.label??je}),e.jsxs("td",{className:"px-3 py-1.5 text-right",children:["₹",Xe(Fe.annual??0)]}),e.jsxs("td",{className:"px-3 py-1.5 text-right text-slate-500",children:["₹",Xe(Fe.monthly??0)]})]},je))]}),e.jsxs("tr",{className:"bg-slate-50 border-t border-slate-200 font-semibold",children:[e.jsx("td",{className:"px-3 py-2 text-slate-800",children:"Total Fixed CTC"}),e.jsxs("td",{className:"px-3 py-2 text-right",children:["₹",Xe(na)]}),e.jsxs("td",{className:"px-3 py-2 text-right",children:["₹",Xe(mn)]})]}),Le.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"bg-red-50/30 border-t border-slate-100 text-[11px] text-red-600 font-semibold",children:e.jsx("td",{className:"px-3 py-1",colSpan:3,children:"Employee Deductions"})}),Le.map(([je,Fe])=>e.jsxs("tr",{className:"border-b border-slate-100 bg-red-50/10",children:[e.jsx("td",{className:"px-3 py-1.5 text-slate-600",children:Fe.label??je}),e.jsxs("td",{className:"px-3 py-1.5 text-right text-red-600",children:["₹",Xe(Fe.annual??0)]}),e.jsxs("td",{className:"px-3 py-1.5 text-right text-red-500",children:["₹",Xe(Fe.monthly??0)]})]},je)),e.jsxs("tr",{className:"border-t border-slate-100 text-[12px]",children:[e.jsx("td",{className:"px-3 py-1.5 text-slate-500",children:"Less: Total Deductions"}),e.jsxs("td",{className:"px-3 py-1.5 text-right text-red-600",children:["− ₹",Xe(sa)]}),e.jsxs("td",{className:"px-3 py-1.5 text-right text-red-500",children:["− ₹",Xe(aa)]})]}),e.jsxs("tr",{className:"bg-green-50/50 border-t border-slate-100 text-[12px] font-semibold",children:[e.jsx("td",{className:"px-3 py-2 text-slate-700",children:"Net Take Home"}),e.jsxs("td",{className:"px-3 py-2 text-right text-green-700",children:["₹",Xe(Je-sa)]}),e.jsxs("td",{className:"px-3 py-2 text-right text-green-700",children:["₹",Xe(Bt-aa)]})]})]}),ds>0&&e.jsxs("tr",{className:"border-t border-slate-100",children:[e.jsx("td",{className:"px-3 py-2 text-slate-600",children:"Variable Pay / Bonus"}),e.jsxs("td",{className:"px-3 py-2 text-right",children:["₹",Xe(ds)]}),e.jsxs("td",{className:"px-3 py-2 text-right text-slate-500",children:["₹",Xe(ds/12)]})]}),ys>0&&e.jsxs("tr",{className:"border-t border-slate-100",children:[e.jsx("td",{className:"px-3 py-2 text-slate-600",children:"Signing Bonus"}),e.jsxs("td",{className:"px-3 py-2 text-right",children:["₹",Xe(ys)]}),e.jsx("td",{className:"px-3 py-2 text-right text-slate-400 text-[11px]",children:"one-time"})]}),e.jsxs("tr",{className:"bg-primary/5 border-t-2 border-primary/20",children:[e.jsx("td",{className:"px-3 py-2 font-bold text-primary text-[13px]",children:"Total CTC (Annual)"}),e.jsxs("td",{className:"px-3 py-2 text-right font-bold text-primary text-[13px]",colSpan:2,children:["₹",Xe(xn)]})]})]})]})]}),i.special_conditions&&e.jsxs("div",{className:"bg-amber-50 border border-amber-100 rounded-lg p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-amber-700 mb-1",children:"Special Conditions"}),e.jsx("p",{className:"text-[13px] text-amber-800",children:i.special_conditions})]})]})})()]})}),e.jsx(bt,{open:!!se,onOpenChange:x=>{x||(se&&URL.revokeObjectURL(se),D(null),I(""))},children:e.jsxs(Ct,{className:"max-w-4xl h-[90vh] flex flex-col p-0",children:[e.jsx(St,{className:"px-6 pt-4 pb-2 border-b border-slate-100",children:e.jsxs(wt,{className:"flex items-center gap-2",children:[e.jsx(Ss,{className:"h-4 w-4 text-primary"})," Offer Letter — ",H]})}),se&&e.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[e.jsx("iframe",{src:se,className:"flex-1 w-full border-0",title:"Offer Letter Preview"}),e.jsx("div",{className:"px-6 py-3 border-t border-slate-100 flex justify-end gap-2",children:e.jsxs(P,{variant:"outline",size:"sm",onClick:()=>{const x=document.createElement("a");x.href=se,x.download=`offer_letter_${H}.pdf`,x.click()},children:[e.jsx(Ss,{className:"mr-1.5 h-3.5 w-3.5"})," Download"]})})]})]})}),e.jsx(De,{open:!!de,onOpenChange:x=>!x&&w(null),children:e.jsxs(Ee,{size:"xl",children:[e.jsxs(Te,{children:[e.jsxs(Ve,{className:"flex items-center gap-2",children:[e.jsx(Wt,{className:"h-4 w-4 text-primary"})," Fill Joining Form & Onboard"]}),e.jsxs(Ie,{children:[de==null?void 0:de.candidate_name," — ",de==null?void 0:de.requisition_title]})]}),de&&e.jsx(il,{offer:de,adminFill:W,onClose:()=>w(null)})]})}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"xl",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Offer":"New Offer"}),e.jsx(Ie,{children:a?"Update offer details.":"Create a new offer for a candidate."})]}),e.jsxs("form",{onSubmit:K.handleSubmit(ta),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Application *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:K.watch("application")??null,onValueChange:x=>K.setValue("application",x,{shouldValidate:!0}),options:T.map(x=>({value:x.id,label:`${x.candidate_name} — ${x.requisition_number}`})),selectedLabel:a?`${a.candidate_name} — ${a.requisition_number}`:void 0,placeholder:"Select application",searchPlaceholder:"Search applications..."})}),K.formState.errors.application&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:K.formState.errors.application.message})]}),e.jsxs("div",{className:"rounded-lg border border-slate-200 p-4 space-y-4 bg-slate-50/50",children:[e.jsx("p",{className:"text-[12px] font-semibold text-slate-600 uppercase tracking-wide",children:"Salary Structure"}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Employee Category *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:K.watch("employee_category")||null,onValueChange:x=>K.setValue("employee_category",x),options:_.map(x=>({value:x.id,label:x.name,hint:x.code})),selectedLabel:a==null?void 0:a.employee_category_name,placeholder:"Select category",searchPlaceholder:"Search categories..."})})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Salary Template"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:K.watch("salary_template")||null,onValueChange:x=>K.setValue("salary_template",x),disabled:!ve,options:yt.map(x=>({value:x.id,label:x.name})),placeholder:ve?"Select template":"Select category first",searchPlaceholder:"Search templates..."})})]})]})]}),e.jsxs("div",{className:"rounded-lg border border-slate-200 p-4 space-y-4 bg-slate-50/50",children:[e.jsx("p",{className:"text-[12px] font-semibold text-slate-600 uppercase tracking-wide",children:"Offer Letter"}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Letter Template"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:K.watch("template")||null,onValueChange:x=>K.setValue("template",x),isLoading:At,options:Rt.map(x=>({value:x.id,label:x.name,hint:x.code})),selectedLabel:a==null?void 0:a.template_name,placeholder:"Select a letter template",searchPlaceholder:"Search templates..."})}),!At&&Rt.length===0&&e.jsx("p",{className:"mt-1 text-[11px] text-amber-600",children:"No offer letter templates yet — create one under Recruitment → Offer Templates."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Annual CTC (₹)"}),e.jsxs("div",{className:"flex gap-2 mt-1.5",children:[e.jsx(Ns,{value:K.watch("ctc_annual"),onChange:x=>K.setValue("ctc_annual",x,{shouldValidate:!0}),placeholder:"e.g. 6,00,000",className:"flex-1"}),e.jsxs(P,{type:"button",variant:"outline",size:"sm",onClick:fs,disabled:!K.watch("salary_template")||!K.watch("ctc_annual")||A.isPending,className:"shrink-0",children:[e.jsx(Fs,{className:`h-3.5 w-3.5 mr-1.5 ${A.isPending?"animate-spin":""}`}),"Compute"]})]}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-1",children:"Salary breakup is calculated automatically when you enter a CTC value."})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Date of Joining *"}),e.jsx(b,{type:"date",...K.register("joining_date_proposed"),className:"mt-1.5",max:K.watch("offer_valid_until")||void 0}),K.formState.errors.joining_date_proposed&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:K.formState.errors.joining_date_proposed.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Offer Valid Until"}),e.jsx(b,{type:"date",...K.register("offer_valid_until"),className:"mt-1.5",min:K.watch("joining_date_proposed")||void 0})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Work Location *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:K.watch("location_offered")||null,onValueChange:x=>K.setValue("location_offered",x,{shouldValidate:!0}),options:U.map(x=>({value:x.id,label:x.name,hint:x.code})),selectedLabel:a==null?void 0:a.location_offered_name,placeholder:"Select work location",searchPlaceholder:"Search locations..."})}),K.formState.errors.location_offered&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:K.formState.errors.location_offered.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Employment Type"}),e.jsxs(Ce,{value:K.watch("employment_type"),onValueChange:x=>K.setValue("employment_type",x),children:[e.jsx(Se,{className:"mt-1.5 h-9",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"permanent",children:"Permanent"}),e.jsx(q,{value:"contract",children:"Contract"}),e.jsx(q,{value:"intern",children:"Intern"}),e.jsx(q,{value:"consultant",children:"Consultant"}),e.jsx(q,{value:"temporary",children:"Temporary"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Designation"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:K.watch("designation_offered")||null,onValueChange:x=>K.setValue("designation_offered",x),options:Ke.map(x=>({value:x.id,label:x.name,hint:x.code})),selectedLabel:a==null?void 0:a.designation_offered_name,placeholder:"Select designation",searchPlaceholder:"Search designations..."})})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Department"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:K.watch("department")||null,onValueChange:x=>K.setValue("department",x),options:pe.map(x=>({value:x.id,label:x.name,hint:x.code})),selectedLabel:a==null?void 0:a.department_name,placeholder:"Select department",searchPlaceholder:"Search departments..."})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Grade"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:K.watch("grade_offered")||null,onValueChange:x=>K.setValue("grade_offered",x),options:E.map(x=>({value:x.id,label:x.name,hint:x.code})),selectedLabel:a==null?void 0:a.grade_offered_name,placeholder:"Select grade",searchPlaceholder:"Search grades..."})})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Reporting To"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:K.watch("reporting_to")||null,onValueChange:x=>K.setValue("reporting_to",x),onSearch:Re,options:Y.map(x=>({value:x.id,label:`${x.first_name} ${x.last_name}`.trim(),hint:x.employee_id})),selectedLabel:a==null?void 0:a.reporting_to_name,placeholder:"Select reporting manager",searchPlaceholder:"Search employees..."})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Probation Period (months)"}),e.jsx(b,{type:"number",min:"0",...K.register("probation_months"),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Notice Period (days)"}),e.jsx(b,{type:"number",min:"0",...K.register("notice_period_days"),className:"mt-1.5"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs(o,{className:"text-[12px] font-medium text-slate-700",children:["Salary Breakup",r.length>0&&e.jsxs("span",{className:"ml-2 text-slate-400 font-normal",children:["(",r.length," components)"]})]}),e.jsxs("button",{type:"button",onClick:nn,className:"text-[11px] text-primary hover:underline flex items-center gap-1",children:[e.jsx(Ue,{className:"h-3 w-3"})," Add Component"]})]}),r.length===0?e.jsxs("div",{className:"border border-dashed border-slate-200 rounded-md p-6 text-center text-[12px] text-slate-400",children:["Select an employee category, template, enter CTC and click ",e.jsx("strong",{children:"Compute"})," to auto-fill salary components."]}):e.jsx("div",{className:"border border-slate-200 rounded-md overflow-hidden",children:e.jsxs("table",{className:"w-full text-[12px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 border-b border-slate-200",children:[e.jsx("th",{className:"text-left px-3 py-2 text-slate-500 font-medium w-[40%]",children:"Component"}),e.jsx("th",{className:"text-right px-3 py-2 text-slate-500 font-medium",children:"Annual (₹)"}),e.jsx("th",{className:"text-right px-3 py-2 text-slate-500 font-medium",children:"Monthly (₹)"}),e.jsx("th",{className:"w-8"})]})}),e.jsx("tbody",{children:r.map((x,xe)=>{const He=x.component_type==="deduction",Ne=x.component_type==="employer_contribution";return e.jsxs("tr",{className:`border-b border-slate-100 last:border-0 ${He?"bg-red-50/30":Ne?"bg-blue-50/20":""}`,children:[e.jsx("td",{className:"px-3 py-1.5",children:e.jsx(b,{value:x.label,onChange:Le=>N(Je=>Je.map((Bt,vs)=>vs===xe?{...Bt,label:Le.target.value}:Bt)),className:"h-7 text-[12px] border-0 shadow-none p-0 focus-visible:ring-0",placeholder:"Component name"})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx(b,{value:x.annual,onChange:Le=>sn(xe,Le.target.value),className:"h-7 text-[12px] text-right border-slate-200",placeholder:"0.00",type:"number",min:"0"})}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx(b,{value:x.monthly,onChange:Le=>an(xe,Le.target.value),className:"h-7 text-[12px] text-right border-slate-200",placeholder:"0.00",type:"number",min:"0"})}),e.jsx("td",{className:"px-2",children:e.jsx("button",{type:"button",onClick:()=>rn(xe),className:"text-slate-300 hover:text-red-500",children:e.jsx(ft,{className:"h-3.5 w-3.5"})})})]},x.code)})}),e.jsxs("tfoot",{children:[e.jsxs("tr",{className:"bg-slate-50 border-t-2 border-slate-200 font-semibold",children:[e.jsx("td",{className:"px-3 py-2 text-slate-700 text-[12px]",children:"Gross Salary"}),e.jsxs("td",{className:"px-3 py-2 text-right text-slate-800 text-[12px]",children:["₹",qt(Ge)]}),e.jsxs("td",{className:"px-3 py-2 text-right text-slate-800 text-[12px]",children:["₹",qt(Nt)]}),e.jsx("td",{})]}),he.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"bg-blue-50/30 border-t border-slate-100 text-[11px] text-blue-600 font-semibold",children:e.jsx("td",{className:"px-3 py-1",colSpan:4,children:"Employer Contributions"})}),e.jsxs("tr",{className:"bg-blue-50/10 border-t border-slate-100 font-semibold",children:[e.jsx("td",{className:"px-3 py-2 text-slate-700 text-[12px]",children:"Total Employer Contributions"}),e.jsxs("td",{className:"px-3 py-2 text-right text-slate-800 text-[12px]",children:["₹",qt(Dt)]}),e.jsxs("td",{className:"px-3 py-2 text-right text-slate-800 text-[12px]",children:["₹",qt(Zt)]}),e.jsx("td",{})]})]}),e.jsxs("tr",{className:"bg-slate-50 border-t border-slate-200 font-semibold",children:[e.jsx("td",{className:"px-3 py-2 text-slate-800 text-[12px]",children:"Total Fixed CTC"}),e.jsxs("td",{className:"px-3 py-2 text-right text-slate-900 text-[12px]",children:["₹",qt(Zs)]}),e.jsxs("td",{className:"px-3 py-2 text-right text-slate-900 text-[12px]",children:["₹",qt(Xa)]}),e.jsx("td",{})]}),Ze.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"bg-red-50/30 border-t border-slate-100 text-[11px] text-red-600 font-semibold",children:e.jsx("td",{className:"px-3 py-1",colSpan:4,children:"Employee Deductions"})}),e.jsxs("tr",{className:"border-t border-slate-100 text-[12px] text-red-600",children:[e.jsx("td",{className:"px-3 py-1.5 text-slate-500",children:"Less: Total Deductions"}),e.jsxs("td",{className:"px-3 py-1.5 text-right",children:["− ₹",qt(Ot)]}),e.jsxs("td",{className:"px-3 py-1.5 text-right",children:["− ₹",qt(Ys)]}),e.jsx("td",{})]}),e.jsxs("tr",{className:"bg-green-50/50 border-t border-slate-100 text-[12px] font-semibold",children:[e.jsx("td",{className:"px-3 py-2 text-slate-700",children:"Net Take Home"}),e.jsxs("td",{className:"px-3 py-2 text-right text-green-700",children:["₹",qt(Ge-Ot)]}),e.jsxs("td",{className:"px-3 py-2 text-right text-green-700",children:["₹",qt(Nt-Ys)]}),e.jsx("td",{})]})]})]})]})})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-700 mb-2 block",children:"Additional Benefits"}),e.jsx("div",{className:"border border-slate-200 rounded-md overflow-hidden",children:e.jsxs("table",{className:"w-full text-[12px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-slate-50 border-b border-slate-200",children:[e.jsx("th",{className:"text-left px-3 py-2 text-slate-500 font-medium w-[40%]",children:"Benefit"}),e.jsx("th",{className:"text-right px-3 py-2 text-slate-500 font-medium",children:"Annual (₹)"}),e.jsx("th",{className:"text-right px-3 py-2 text-slate-500 font-medium",children:"Monthly (₹)"})]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{className:"border-b border-slate-100",children:[e.jsx("td",{className:"px-3 py-1.5 text-slate-600",children:"Variable Pay / Bonus"}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx(Ns,{value:K.watch("variable_pay"),onChange:x=>K.setValue("variable_pay",x,{shouldValidate:!0}),className:"h-7 text-[12px] text-right border-slate-200",placeholder:"0.00"})}),e.jsxs("td",{className:"px-3 py-1.5 text-right text-slate-500",children:["₹",qt((parseFloat(K.watch("variable_pay")||"0")||0)/12)]})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"px-3 py-1.5 text-slate-600",children:"Signing Bonus (one-time)"}),e.jsx("td",{className:"px-3 py-1.5",children:e.jsx(Ns,{value:K.watch("signing_bonus"),onChange:x=>K.setValue("signing_bonus",x,{shouldValidate:!0}),className:"h-7 text-[12px] text-right border-slate-200",placeholder:"0.00"})}),e.jsx("td",{className:"px-3 py-1.5 text-right text-slate-400 text-[11px]",children:"one-time"})]})]}),e.jsx("tfoot",{children:e.jsxs("tr",{className:"bg-primary/5 border-t-2 border-primary/20 font-bold",children:[e.jsx("td",{className:"px-3 py-2 text-primary text-[13px]",children:"Total CTC (Annual)"}),e.jsxs("td",{className:"px-3 py-2 text-right text-primary text-[13px]",colSpan:2,children:["₹",qt(ea)]})]})})]})})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Special Conditions"}),e.jsx(b,{...K.register("special_conditions"),className:"mt-1.5",placeholder:"Any special terms"})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:K.handleSubmit(ta),disabled:J.isPending||Q.isPending,children:a?"Update":"Create Offer"})]})]})})]})}const rl=ct({name:C().min(1,"Name is required"),code:C().min(1,"Code is required"),document_type:Ra(["offer_letter","service_contract"]).default("offer_letter"),company:C().min(1,"Company is required"),designation:C().optional().nullable(),content_html:C().optional(),terms_conditions:C().optional(),header_image:C().optional(),footer_image:C().optional(),is_active:ge().default(!0)}),ll=/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g;function rd(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),[r,N]=h.useState([]),[y,m]=h.useState(null),{hasPermission:V,requirePermission:F}=et(),M=V("recruitment","offer_template","create"),z=V("recruitment","offer_template","update"),G=V("recruitment","offer_template","delete"),{pagination:ee,setPagination:te,sorting:ie,setSorting:L,globalFilter:re,setGlobalFilter:ne,queryParams:ce}=tt(),{data:J,isLoading:Q}=Bs(ce),R=(J==null?void 0:J.results)??[],v=tr(),S=sr(),X=ar(),Z=dr(),{data:W}=Ut(),de=(W==null?void 0:W.results)??[],{data:w}=Ea(),se=(w==null?void 0:w.results)??[],D=Ye({resolver:nt(rl),defaultValues:{is_active:!0,document_type:"offer_letter"}}),H=D.watch("document_type")??"offer_letter",{data:I=[]}=nr(H),A=D.watch("content_html")??"",O=h.useMemo(()=>{if(!A||I.length===0)return[];const _=new Set(I.map(pe=>pe.field)),ue=new Set;for(const pe of A.matchAll(ll))pe[1]&&ue.add(pe[1]);return[...ue].filter(pe=>!_.has(pe))},[A,I]);h.useEffect(()=>()=>{y&&URL.revokeObjectURL(y)},[y]);function K(){F("recruitment","offer_template","create")&&(n(null),N([]),D.reset({name:"",code:"",company:"",designation:null,document_type:"offer_letter",content_html:"",terms_conditions:"",header_image:"",footer_image:"",is_active:!0}),t(!0))}function _e(_){F("recruitment","offer_template","update")&&(n(_),N(cl(_.annexure_templates)),D.reset({name:_.name,code:_.code,company:_.company,document_type:_.document_type??"offer_letter",designation:_.designation,content_html:_.content_html,terms_conditions:_.terms_conditions,header_image:_.header_image,footer_image:_.footer_image,is_active:_.is_active}),t(!0))}function T(_){Z.mutate(_.id,{onSuccess:ue=>m(URL.createObjectURL(ue))})}function qe(){y&&URL.revokeObjectURL(y),m(null)}function U(_){const ue={..._,designation:_.designation||null,annexure_templates:r.map(fe=>fe.trim()).filter(Boolean)},pe={onSuccess:()=>t(!1)};a?S.mutate({id:a.id,...ue},pe):v.mutate(ue,pe)}const ae=[{key:"name",header:"Template",render:_=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900",children:_.name}),e.jsx("span",{className:"block font-mono text-[11px] text-slate-400",children:_.code})]})},{key:"document_type",header:"Type",render:_=>e.jsx(le,{variant:_.document_type==="service_contract"?"secondary":"outline",children:_.document_type==="service_contract"?"Service Contract":"Offer Letter"})},{key:"designation",header:"Designation",render:_=>e.jsx("span",{className:"text-[13px] text-slate-600",children:_.designation_name||"Any"})},{key:"is_active",header:"Status",render:_=>e.jsx(le,{variant:_.is_active?"success":"secondary",children:_.is_active?"Active":"Inactive"})},{key:"actions",header:"",className:"w-10",render:_=>e.jsxs(mt,{open:(i==null?void 0:i.id)===_.id,onOpenChange:ue=>!ue&&u(null),children:[e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[e.jsxs(B,{onClick:()=>T(_),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," Preview PDF"]}),z&&e.jsxs(B,{onClick:()=>_e(_),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),G&&e.jsxs(B,{className:"text-red-600",onClick:()=>u(_),children:[e.jsx(ft,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]}),e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsxs(pt,{children:["Delete “",_.name,"”?"]}),e.jsx(ht,{children:"Offers already generated from this template keep their letter. New offers will no longer be able to select it."})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{className:"bg-red-600 hover:bg-red-700",onClick:()=>X.mutate(_.id,{onSuccess:()=>u(null)}),children:"Delete"})]})]})]})}];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"flex items-center gap-2 text-[16px] font-semibold text-slate-900",children:[e.jsx(kt,{className:"h-5 w-5 text-primary"})," Offer Letter Templates"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-500",children:"Reusable letter wording. Pick one when creating an offer."})]}),M&&e.jsxs(P,{size:"sm",onClick:K,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Template"]})]}),e.jsx(st,{columns:ae,data:R,isLoading:Q,totalCount:(J==null?void 0:J.count)??0,pagination:ee,onPaginationChange:te,sorting:ie,onSortingChange:L,globalFilter:re,onGlobalFilterChange:ne,searchPlaceholder:"Search templates..."}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"lg",className:"flex flex-col",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Template":"New Offer Letter Template"}),e.jsx(Ie,{children:"Use merge fields in the body — they are replaced with the offer's values."})]}),e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto px-6 py-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Name *"}),e.jsx(b,{...D.register("name"),className:"mt-1.5",placeholder:"Standard Offer"}),D.formState.errors.name&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:D.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Code *"}),e.jsx(b,{...D.register("code"),className:"mt-1.5 font-mono",placeholder:"STD"}),D.formState.errors.code&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:D.formState.errors.code.message})]})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Document Type *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:H,onValueChange:_=>D.setValue("document_type",_||"offer_letter"),options:[{value:"offer_letter",label:"Offer Letter"},{value:"service_contract",label:"Service Contract"}],placeholder:"Select document type"})}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-400",children:"Decides which merge fields are available and where the template can be selected."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:D.watch("company")||null,onValueChange:_=>D.setValue("company",_,{shouldValidate:!0}),options:de.map(_=>({value:_.id,label:_.name,hint:_.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),D.formState.errors.company&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:D.formState.errors.company.message})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Designation"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:D.watch("designation")||null,onValueChange:_=>D.setValue("designation",_||null),options:se.map(_=>({value:_.id,label:_.name})),selectedLabel:(a==null?void 0:a.designation_name)||void 0,placeholder:"Any designation",searchPlaceholder:"Search designations..."})}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-400",children:"Leave blank to use this template for any role."})]})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Letter Body"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(Qn,{value:D.watch("content_html")??"",onChange:_=>D.setValue("content_html",_),placeholder:"Dear {{candidate_name}}, we are pleased to offer you…"})}),O.length>0&&e.jsxs("p",{className:"mt-2 text-[12px] text-amber-600",children:["Unrecognised ",O.length===1?"field":"fields",":"," ",e.jsx("span",{className:"font-mono",children:O.map(_=>`{{${_}}}`).join(", ")})," ","— these will print as-is."]}),e.jsx(ol,{fields:I})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Annexure Items"}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-slate-400",children:["Rendered where the body has ",e.jsx("code",{className:"font-mono",children:"{{annexures}}"})," — typically the joining-documents checklist."]}),e.jsxs("div",{className:"mt-1.5 space-y-2",children:[r.map((_,ue)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{value:_,onChange:pe=>N(r.map((fe,Ke)=>Ke===ue?pe.target.value:fe)),placeholder:"Copy of PAN Card"}),e.jsx(P,{variant:"ghost",size:"icon-sm",onClick:()=>N(r.filter((pe,fe)=>fe!==ue)),"aria-label":"Remove item",children:e.jsx(ls,{className:"h-4 w-4 text-slate-400"})})]},ue)),e.jsxs(P,{variant:"outline",size:"sm",onClick:()=>N([...r,""]),children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Add Item"]})]})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Terms & Conditions"}),e.jsxs("p",{className:"mt-0.5 text-[11px] text-slate-400",children:["Rendered where the body has ",e.jsx("code",{className:"font-mono",children:"{{terms_conditions}}"}),"."]}),e.jsx(Ae,{...D.register("terms_conditions"),className:"mt-1.5",rows:4})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Letterhead Image URL"}),e.jsx(b,{...D.register("header_image"),className:"mt-1.5",placeholder:"https://…/letterhead.png"}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-400",children:"Replaces the default company header on the PDF."})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Footer Image URL"}),e.jsx(b,{...D.register("footer_image"),className:"mt-1.5",placeholder:"https://…/footer.png"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(rs,{checked:D.watch("is_active"),onCheckedChange:_=>D.setValue("is_active",_)}),e.jsx("span",{className:"text-[13px] text-slate-600",children:"Active — only active templates appear when creating an offer."})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:D.handleSubmit(U),disabled:v.isPending||S.isPending,children:a?"Save Changes":"Create Template"})]})]})}),e.jsx(bt,{open:!!y,onOpenChange:_=>!_&&qe(),children:e.jsxs(Ct,{className:"max-w-4xl",children:[e.jsx(St,{children:e.jsx(wt,{children:"Template Preview"})}),e.jsx("p",{className:"text-[12px] text-slate-500",children:"Rendered with sample data — a real offer uses its own candidate and salary figures."}),y&&e.jsx("iframe",{src:y,title:"Offer letter preview",className:"h-[70vh] w-full rounded border"})]})})]})}function cl(s){if(!Array.isArray(s))return[];const t=[];for(const a of s)if(typeof a=="string")t.push(a);else if(a&&typeof a=="object"){const n=a.items;Array.isArray(n)&&t.push(...n.map(String))}return t}function ol({fields:s}){if(s.length===0)return null;const t=s.reduce((n,i)=>{var u;return(n[u=i.source]??(n[u]=[])).push(i),n},{});async function a(n){try{await navigator.clipboard.writeText(`{{${n}}}`)}catch{}}return e.jsxs("div",{className:"mt-2 space-y-2 rounded-lg border border-slate-200 bg-slate-50/60 p-3",children:[e.jsxs("p",{className:"text-[11px] font-semibold text-slate-600",children:["Merge fields",e.jsx("span",{className:"font-normal text-slate-400",children:" — click to copy"})]}),Object.entries(t).map(([n,i])=>e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-[10px] uppercase tracking-wide text-slate-400",children:n}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:i.map(u=>e.jsx("button",{type:"button",title:u.label+(u.example?` (e.g. ${u.example})`:""),onClick:()=>a(u.field),className:"rounded border border-slate-200 bg-white px-1.5 py-0.5 font-mono text-[11px] text-slate-600 transition-colors hover:border-primary/40 hover:text-primary",children:`{{${u.field}}}`},u.field))})]},n))]})}const dl={draft:"secondary",pending_approval:"warning",approved:"success",sent:"default",viewed:"default",accepted:"success",declined:"destructive",expired:"secondary",withdrawn:"secondary",negotiating:"warning"};function ld(){const{id:s}=As(),{data:t,isLoading:a,refetch:n}=mr(s??"");return e.jsx(Va,{recordId:t==null?void 0:t.id,title:t?`${t.offer_number} — ${t.candidate_name}`:"Offer",subtitle:t==null?void 0:t.requisition_title,backTo:"/recruitment/offers",notFoundText:"Offer not found.",isLoading:a,found:!!t,onDecided:()=>n(),children:t&&e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[e.jsx("div",{className:"col-span-2 space-y-4",children:e.jsxs(Ft,{children:[e.jsx(Tt,{className:"pb-3",children:e.jsx(Vt,{className:"text-[14px]",children:"Offer Details"})}),e.jsxs(Pt,{className:"grid grid-cols-2 gap-4",children:[e.jsx(be,{label:"Candidate",value:t.candidate_name}),e.jsx(be,{label:"Designation",value:t.designation_offered_name}),e.jsx(be,{label:"Department",value:t.department_name}),e.jsx(be,{label:"CTC Offered",value:t.ctc_offered}),e.jsx(be,{label:"Variable Pay",value:t.variable_pay}),e.jsx(be,{label:"Signing Bonus",value:t.signing_bonus}),e.jsx(be,{label:"Probation (months)",value:t.probation_months}),e.jsx(be,{label:"Notice Period (days)",value:t.notice_period_days}),e.jsx(be,{label:"Special Conditions",value:t.special_conditions})]})]})}),e.jsx("div",{className:"space-y-4",children:e.jsxs(Ft,{children:[e.jsx(Tt,{className:"pb-3",children:e.jsx(Vt,{className:"text-[14px]",children:"Summary"})}),e.jsxs(Pt,{className:"space-y-3",children:[e.jsx(be,{label:"Offer No.",value:t.offer_number}),e.jsx(be,{label:"Requisition",value:t.requisition_number}),e.jsx(be,{label:"Revision",value:t.revision_number}),e.jsx(be,{label:"Approved By",value:t.approved_by_name}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-slate-400",children:"Status"}),e.jsx(le,{variant:dl[t.status]??"secondary",className:"mt-1",children:t.status.replace(/_/g," ")})]})]})]})})]})})}const ml=[{value:"strong_hire",label:"Strong Hire"},{value:"hire",label:"Hire"},{value:"next_round",label:"Next Round"},{value:"hold",label:"Hold"},{value:"no_hire",label:"No Hire"},{value:"strong_no_hire",label:"Strong No Hire"}],ja={strong_hire:"success",hire:"success",next_round:"default",hold:"warning",no_hire:"destructive",strong_no_hire:"destructive"},xl=ct({interview:C().min(1,"Interview is required"),evaluator:C().min(1,"Evaluator is required"),overall_rating:C().optional(),recommendation:C().min(1,"Recommendation is required"),strengths:C().optional(),weaknesses:C().optional(),comments:C().optional()});function cd(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),{hasPermission:i,requirePermission:u}=et(),r=i("recruitment","evaluation","create"),N=i("recruitment","evaluation","update"),{pagination:y,setPagination:m,sorting:V,setSorting:F,globalFilter:M,setGlobalFilter:z,queryParams:G}=tt(),{data:ee,isLoading:te}=oa(G),ie=(ee==null?void 0:ee.results)??[],L=Ye({resolver:nt(xl),defaultValues:{interview:"",evaluator:"",overall_rating:"",recommendation:"hire",strengths:"",weaknesses:"",comments:""}}),{data:re}=Qa({page_size:200}),ne=(re==null?void 0:re.results)??[],ce=ne.filter(A=>{const O=A.panel_members_detail??[],K=O.length>0?O.filter(_e=>["lead","member"].includes(_e.role)).length:A.panel_count;return K===0||A.evaluations_count<K}),J=L.watch("interview"),{data:Q}=Bi(J||""),{data:R}=oa(J?{interview:J,page_size:50}:void 0),v=new Set(((R==null?void 0:R.results)??[]).filter(A=>!a||A.id!==a.id).map(A=>A.evaluator)),S=((Q==null?void 0:Q.panel_members_detail)??[]).filter(A=>["lead","member"].includes(A.role)&&!v.has(A.interviewer)),X=Xi(),Z=er();function W(){u("recruitment","evaluation","create")&&(n(null),L.reset({interview:"",evaluator:"",overall_rating:"",recommendation:"hire",strengths:"",weaknesses:"",comments:""}),t(!0))}function de(A){const O=ne.find(T=>T.id===A.interview);if(!O)return!1;const K=O.panel_members_detail??[],_e=K.length>0?K.filter(T=>["lead","member"].includes(T.role)).length:O.panel_count;return _e>0&&O.evaluations_count>=_e}function w(A){u("recruitment","evaluation","update")&&(de(A)||(n(A),L.reset({interview:A.interview,evaluator:A.evaluator,overall_rating:A.overall_rating,recommendation:A.recommendation,strengths:A.strengths,weaknesses:A.weaknesses,comments:A.comments}),t(!0)))}function se(A){const O=A;a?Z.mutate({id:a.id,...O},{onSuccess:()=>t(!1)}):X.mutate(O,{onSuccess:()=>t(!1)})}const[D,H]=h.useState(null),I=[{key:"candidate_name",header:"Candidate",render:A=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:A.candidate_name})},{key:"round_name",header:"Round",render:A=>e.jsx("span",{className:"text-[13px] text-slate-600",children:A.round_name})},{key:"evaluator_name",header:"Evaluator",render:A=>e.jsx("span",{className:"text-[13px] text-slate-600",children:A.evaluator_name})},{key:"overall_rating",header:"Score",render:A=>e.jsx("span",{className:"text-[13px] text-slate-600",children:A.overall_rating||"-"})},{key:"recommendation",header:"Recommendation",render:A=>e.jsx(le,{variant:ja[A.recommendation],className:"capitalize text-[11px]",children:A.recommendation.replace(/_/g," ")})},{key:"actions",header:"",className:"w-10",render:A=>{const O=de(A);return e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[e.jsxs(B,{onClick:()=>H(A),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View"]}),N&&e.jsxs(B,{onClick:()=>w(A),disabled:O,children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," ",O?"Fully Evaluated":"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(is,{className:"h-5 w-5 text-primary"})," Interview Evaluations"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Review and manage interview evaluation submissions"})]}),r&&e.jsxs(P,{size:"sm",onClick:W,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Add Evaluation"]})]}),e.jsx(st,{columns:I,data:ie,isLoading:te,searchPlaceholder:"Search evaluations...",emptyMessage:"No evaluations",emptyDescription:"Submit your first interview evaluation to start tracking candidate assessments.",totalCount:(ee==null?void 0:ee.count)??0,pagination:y,onPaginationChange:m,sorting:V,onSortingChange:F,globalFilter:M,onGlobalFilterChange:z}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"lg",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Evaluation":"New Evaluation"}),e.jsx(Ie,{children:a?"Update evaluation details.":"Submit an interview evaluation."})]}),e.jsxs("form",{onSubmit:L.handleSubmit(se),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Interview *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:L.watch("interview")??null,onValueChange:A=>{L.setValue("interview",A,{shouldValidate:!0}),L.setValue("evaluator","",{shouldValidate:!1})},options:ce.map(A=>({value:A.id,label:`${A.candidate_name} - ${A.round_name} (${new Date(A.scheduled_date).toLocaleDateString()})`})),selectedLabel:a?`${a.candidate_name} - ${a.round_name}`:void 0,placeholder:"Select interview",searchPlaceholder:"Search interviews..."})}),L.formState.errors.interview&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:L.formState.errors.interview.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Evaluator *"}),e.jsxs(Ce,{value:L.watch("evaluator"),onValueChange:A=>L.setValue("evaluator",A,{shouldValidate:!0}),disabled:!J,children:[e.jsx(Se,{className:"mt-1.5",children:e.jsx(we,{placeholder:J?"Select evaluator":"Select an interview first"})}),e.jsx(ke,{children:S.map(A=>e.jsxs(q,{value:A.interviewer,children:[A.interviewer_name," (",A.role==="lead"?"Primary":"Additional",")"]},A.interviewer))})]}),L.formState.errors.evaluator&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:L.formState.errors.evaluator.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Overall Score"}),e.jsx(b,{...L.register("overall_rating"),className:"mt-1.5",placeholder:"e.g. 4.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Recommendation *"}),e.jsxs(Ce,{value:L.watch("recommendation"),onValueChange:A=>L.setValue("recommendation",A,{shouldValidate:!0}),children:[e.jsx(Se,{className:"mt-1.5",children:e.jsx(we,{placeholder:"Select recommendation"})}),e.jsx(ke,{children:ml.map(A=>e.jsx(q,{value:A.value,children:A.label},A.value))})]}),L.formState.errors.recommendation&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:L.formState.errors.recommendation.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Strengths"}),e.jsx(Ae,{...L.register("strengths"),className:"mt-1.5",rows:3,placeholder:"Key strengths observed..."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Weaknesses"}),e.jsx(Ae,{...L.register("weaknesses"),className:"mt-1.5",rows:3,placeholder:"Areas of improvement..."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Comments"}),e.jsx(Ae,{...L.register("comments"),className:"mt-1.5",rows:3,placeholder:"Additional comments..."})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:L.handleSubmit(se),disabled:X.isPending||Z.isPending,children:a?"Update":"Submit"})]})]})}),e.jsx(bt,{open:!!D,onOpenChange:A=>!A&&H(null),children:e.jsxs(Ct,{className:"max-w-lg",children:[e.jsx(St,{children:e.jsxs(wt,{children:[D==null?void 0:D.candidate_name," — ",D==null?void 0:D.round_name]})}),D&&e.jsxs("div",{className:"space-y-3 text-[13px]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(le,{variant:ja[D.recommendation],className:"capitalize text-[11px]",children:D.recommendation.replace(/_/g," ")}),e.jsxs("span",{className:"text-[12px] text-slate-500",children:["Score: ",D.overall_rating||"—"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Evaluator"}),e.jsx("p",{className:"text-slate-800",children:D.evaluator_name||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Strengths"}),e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:D.strengths||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Weaknesses"}),e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:D.weaknesses||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Comments"}),e.jsx("p",{className:"text-slate-800 whitespace-pre-wrap",children:D.comments||"—"})]}),Array.isArray(D.evaluation_data)&&D.evaluation_data.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Criteria Ratings"}),e.jsx("div",{className:"mt-1 space-y-1",children:D.evaluation_data.map((A,O)=>{const K=A;return e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md bg-slate-50 px-3 py-1.5",children:[e.jsx("span",{className:"text-slate-700",children:K.criteria_name??`Criteria ${O+1}`}),e.jsx("span",{className:"text-slate-500 shrink-0",children:K.rating??"—"})]},O)})})]})]}),e.jsx(Yt,{children:e.jsx(P,{variant:"outline",onClick:()=>H(null),children:"Close"})})]})})]})}const ga={pending:"warning",under_review:"secondary",countered:"default",accepted:"success",rejected:"destructive"},fa={pending:"Pending",under_review:"Under Review",countered:"Countered",accepted:"Accepted",rejected:"Rejected"},ul=ct({offer:C().min(1,"Offer is required"),counter_ctc:C().optional(),counter_joining_date:Is(),counter_designation:C().optional(),counter_other:C().optional(),notes:C().optional()}),pl=ct({action:Ra(["approve","reject","counter"]),response_ctc:C().optional(),response_joining_date:Is(),response_notes:C().optional(),notes:C().optional()});function od(){var ue,pe,fe,Ke,Oe,E,ye,Re;const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),[r,N]=h.useState(null),[y,m]=h.useState(null),[V,F]=h.useState(""),{hasPermission:M,requirePermission:z}=et(),G=M("recruitment","negotiation","create"),ee=M("recruitment","negotiation","update"),{pagination:te,setPagination:ie,sorting:L,setSorting:re,globalFilter:ne,setGlobalFilter:ce,queryParams:J}=tt(),{data:Q,isLoading:R}=_r(J),v=(Q==null?void 0:Q.results)??[],[S,X]=h.useState(""),{data:Z,isLoading:W}=Gs({page_size:200,search:S||void 0}),de=(Z==null?void 0:Z.results)??[],w=vr(),se=yr(),D=Nr(),H=br(),{data:I}=Ja(r),A=Ye({resolver:nt(ul),defaultValues:{offer:"",counter_ctc:"",counter_joining_date:"",counter_designation:"",counter_other:"",notes:""}}),O=Ye({resolver:nt(pl),defaultValues:{action:"approve",response_ctc:"",response_joining_date:"",response_notes:"",notes:""}});function K(){z("recruitment","negotiation","create")&&(n(null),A.reset({offer:"",counter_ctc:"",counter_joining_date:"",counter_designation:"",counter_other:"",notes:""}),t(!0))}function _e(c){if(!z("recruitment","negotiation","update"))return;n(c);const Y=c.candidate_counter??{};A.reset({offer:c.offer,counter_ctc:Y.ctc??"",counter_joining_date:Y.joining_date??"",counter_designation:Y.designation??"",counter_other:Y.other??"",notes:c.notes??""}),t(!0)}function T(c){var ve,Be,yt,dt;const Y={offer:c.offer,...((ve=c.counter_ctc)==null?void 0:ve.trim())&&{counter_ctc:c.counter_ctc.trim()},...((Be=c.counter_joining_date)==null?void 0:Be.trim())&&{counter_joining_date:c.counter_joining_date.trim()},...((yt=c.counter_designation)==null?void 0:yt.trim())&&{counter_designation:c.counter_designation.trim()},...((dt=c.counter_other)==null?void 0:dt.trim())&&{counter_other:c.counter_other.trim()},notes:c.notes??""};a?se.mutate({id:a.id,...Y},{onSuccess:()=>t(!1)}):w.mutate(Y,{onSuccess:()=>t(!1)})}function qe(c){var Y,ve,Be;i&&D.mutate({id:i.id,action:c.action,...((Y=c.response_ctc)==null?void 0:Y.trim())&&{response_ctc:c.response_ctc.trim()},...((ve=c.response_joining_date)==null?void 0:ve.trim())&&{response_joining_date:c.response_joining_date.trim()},...((Be=c.response_notes)==null?void 0:Be.trim())&&{response_notes:c.response_notes.trim()},notes:c.notes??""},{onSuccess:()=>u(null)})}function U(){!y||!V.trim()||H.mutate({id:y,message:V.trim(),author_role:"hr"},{onSuccess:()=>F("")})}const ae=v.find(c=>c.id===y)||(I||[]).find(c=>c.id===y),_=[{key:"offer_number",header:"Offer",render:c=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:c.offer_number}),c.candidate_name&&e.jsx("p",{className:"text-[11px] text-slate-400",children:c.candidate_name})]})},{key:"round_number",header:"Round",render:c=>e.jsxs("span",{className:"text-[13px] text-slate-600",children:["#",c.round_number]})},{key:"candidate_counter",header:"Candidate Request",render:c=>{const Y=c.candidate_counter??{};return e.jsxs("div",{className:"text-[12px] text-slate-600 space-y-0.5",children:[Y.ctc&&e.jsxs("div",{children:["CTC: ₹",Number(Y.ctc).toLocaleString("en-IN")]}),Y.joining_date&&e.jsxs("div",{children:["Joining: ",Y.joining_date]}),Y.designation&&e.jsxs("div",{children:["Role: ",Y.designation]}),Y.other&&e.jsx("div",{className:"truncate max-w-[160px]",children:Y.other}),!Y.ctc&&!Y.joining_date&&!Y.designation&&!Y.other&&e.jsx("span",{className:"text-slate-400",children:"—"})]})}},{key:"company_response",header:"HR Response",render:c=>{const Y=c.company_response??{};return e.jsxs("div",{className:"text-[12px] text-slate-600 space-y-0.5",children:[Y.ctc&&e.jsxs("div",{children:["CTC: ₹",Number(Y.ctc).toLocaleString("en-IN")]}),Y.joining_date&&e.jsxs("div",{children:["Joining: ",Y.joining_date]}),Y.notes&&e.jsx("div",{className:"truncate max-w-[150px]",children:Y.notes}),!Y.ctc&&!Y.joining_date&&!Y.notes&&e.jsx("span",{className:"text-slate-400",children:"—"})]})}},{key:"handled_by_name",header:"Handled By",render:c=>e.jsx("span",{className:"text-[13px] text-slate-600",children:c.handled_by_name||"—"})},{key:"status",header:"Status",render:c=>e.jsx(le,{variant:ga[c.status],className:"capitalize text-[11px]",children:fa[c.status]})},{key:"comments_count",header:"Comments",render:c=>{var Y;return e.jsxs(P,{variant:"ghost",size:"icon-sm",onClick:()=>m(c.id),title:"View comments",children:[e.jsx(as,{className:"h-3.5 w-3.5"}),((Y=c.comments)==null?void 0:Y.length)>0&&e.jsx("span",{className:"ml-0.5 text-[10px]",children:c.comments.length})]})}},{key:"created_at",header:"Date",render:c=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(c.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:c=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[ee&&["pending","under_review"].includes(c.status)&&e.jsxs(B,{onClick:()=>{u(c),O.reset({action:"approve",response_ctc:"",response_joining_date:"",response_notes:"",notes:""})},children:[e.jsx(ra,{className:"mr-2 h-3.5 w-3.5"})," Respond"]}),ee&&e.jsxs(B,{onClick:()=>_e(c),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),e.jsxs(B,{onClick:()=>N(c.offer),children:[e.jsx(la,{className:"mr-2 h-3.5 w-3.5"})," View History"]}),e.jsxs(B,{onClick:()=>m(c.id),children:[e.jsx(as,{className:"mr-2 h-3.5 w-3.5"})," Comments"]})]})]})}];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(Un,{className:"h-5 w-5 text-primary"})," Offer Negotiations"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Track negotiation rounds, respond to candidate requests, and finalize offers"})]}),G&&e.jsxs(P,{size:"sm",onClick:K,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Round"]})]}),e.jsx(st,{columns:_,data:v,isLoading:R,searchPlaceholder:"Search negotiations...",emptyMessage:"No negotiations",emptyDescription:"Start tracking offer negotiations when candidates begin counter-offering.",totalCount:(Q==null?void 0:Q.count)??0,pagination:te,onPaginationChange:ie,sorting:L,onSortingChange:re,globalFilter:ne,onGlobalFilterChange:ce}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"md",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Negotiation":"New Negotiation Round"}),e.jsx(Ie,{children:a?"Update the candidate request details.":"Record the terms the candidate is requesting."})]}),e.jsxs("form",{onSubmit:A.handleSubmit(T),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Offer *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:A.watch("offer"),onValueChange:c=>A.setValue("offer",c,{shouldValidate:!0}),onSearch:X,isLoading:W,selectedLabel:a?`${a.offer_number}${a.candidate_name?` — ${a.candidate_name}`:""}`:void 0,options:de.map(c=>({value:c.id,label:`${c.offer_number} — ${c.candidate_name}`})),placeholder:"Select offer",searchPlaceholder:"Search offers..."})}),A.formState.errors.offer&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:A.formState.errors.offer.message})]}),e.jsx(ms,{}),e.jsx("p",{className:"text-[11px] font-semibold text-slate-400 uppercase tracking-wide -mb-2",children:"Candidate's Counter-Offer Terms"}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Requested CTC"}),e.jsx(b,{...A.register("counter_ctc"),type:"number",min:0,step:"1000",placeholder:"e.g. 1200000",className:"mt-1.5"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Annual CTC the candidate is requesting."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Requested Joining Date"}),e.jsx(b,{...A.register("counter_joining_date"),type:"date",className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Requested Designation"}),e.jsx(b,{...A.register("counter_designation"),placeholder:"e.g. Senior Software Engineer",className:"mt-1.5"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Title change requested, if any."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Other Requests"}),e.jsx(Ae,{...A.register("counter_other"),rows:3,placeholder:"e.g. Remote work 2 days/week, relocation allowance…",className:"mt-1.5"})]}),e.jsx(ms,{}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Internal Notes"}),e.jsx(Ae,{...A.register("notes"),rows:2,placeholder:"Candidate's reasoning or any internal remarks…",className:"mt-1.5"})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:A.handleSubmit(T),disabled:w.isPending||se.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(bt,{open:!!i,onOpenChange:c=>!c&&u(null),children:e.jsxs(Ct,{children:[e.jsxs(St,{children:[e.jsx(wt,{children:"Respond to Negotiation"}),e.jsxs(bs,{children:["Round #",i==null?void 0:i.round_number," — ",i==null?void 0:i.offer_number]})]}),i&&e.jsxs("div",{className:"space-y-4 text-[13px]",children:[e.jsxs("div",{className:"bg-amber-50 border border-amber-100 rounded-lg p-3 text-[12px]",children:[e.jsx("p",{className:"text-[11px] font-semibold text-amber-700 mb-2 uppercase tracking-wide",children:"Candidate Request"}),e.jsxs("div",{className:"space-y-1 text-slate-700",children:[((ue=i.candidate_counter)==null?void 0:ue.ctc)&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-400",children:"Requested CTC"}),e.jsxs("span",{className:"font-medium",children:["₹",Number(i.candidate_counter.ctc).toLocaleString("en-IN")]})]}),((pe=i.candidate_counter)==null?void 0:pe.joining_date)&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-400",children:"Joining Date"}),e.jsx("span",{children:i.candidate_counter.joining_date})]}),((fe=i.candidate_counter)==null?void 0:fe.designation)&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-slate-400",children:"Designation"}),e.jsx("span",{children:i.candidate_counter.designation})]}),((Ke=i.candidate_counter)==null?void 0:Ke.other)&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400",children:"Other: "}),e.jsx("span",{children:i.candidate_counter.other})]}),!((Oe=i.candidate_counter)!=null&&Oe.ctc)&&!((E=i.candidate_counter)!=null&&E.joining_date)&&!((ye=i.candidate_counter)!=null&&ye.designation)&&!((Re=i.candidate_counter)!=null&&Re.other)&&e.jsx("span",{className:"text-slate-400",children:"No specific terms provided."})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Action *"}),e.jsxs(Ce,{value:O.watch("action"),onValueChange:c=>O.setValue("action",c),children:[e.jsx(Se,{className:"mt-1.5",children:e.jsx(we,{})}),e.jsxs(ke,{children:[e.jsx(q,{value:"approve",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(yn,{className:"h-3.5 w-3.5 text-green-600"})," Approve — accept candidate's terms"]})}),e.jsx(q,{value:"counter",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ra,{className:"h-3.5 w-3.5 text-blue-600"})," Counter-Offer — propose revised terms"]})}),e.jsx(q,{value:"reject",children:e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ls,{className:"h-3.5 w-3.5 text-red-600"})," Reject — decline this counter-offer"]})})]})]})]}),O.watch("action")==="counter"&&e.jsxs("div",{className:"space-y-3 rounded-lg border border-blue-100 bg-blue-50 p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-blue-700 uppercase tracking-wide",children:"Your Counter-Offer Terms"}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Counter CTC"}),e.jsx(b,{...O.register("response_ctc"),type:"number",min:0,step:"1000",placeholder:"e.g. 1100000",className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Revised Joining Date"}),e.jsx(b,{...O.register("response_joining_date"),type:"date",className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Response Notes"}),e.jsx(Ae,{...O.register("response_notes"),rows:2,placeholder:"Justification or conditions for this counter…",className:"mt-1.5"})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Internal Notes"}),e.jsx(Ae,{...O.register("notes"),rows:2,placeholder:"Internal remarks (not shared with candidate)…",className:"mt-1.5"})]})]}),e.jsxs(Yt,{children:[e.jsx(P,{variant:"outline",onClick:()=>u(null),children:"Cancel"}),e.jsx(P,{onClick:O.handleSubmit(qe),disabled:D.isPending,children:"Submit Response"})]})]})}),e.jsx(bt,{open:!!r,onOpenChange:c=>!c&&N(null),children:e.jsxs(Ct,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(St,{children:[e.jsxs(wt,{className:"flex items-center gap-2",children:[e.jsx(la,{className:"h-4 w-4"})," Negotiation History"]}),e.jsx(bs,{children:"Complete timeline of all negotiation rounds"})]}),e.jsxs("div",{className:"space-y-4",children:[(I||[]).length===0&&e.jsx("p",{className:"text-[13px] text-slate-400 text-center py-8",children:"No negotiation history found."}),(I||[]).map(c=>{var Y,ve,Be,yt,dt,At,Rt,d,f,he,Ze,Ge,Nt,Dt,Zt;return e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[13px] font-semibold text-slate-900",children:["Round #",c.round_number]}),e.jsx(le,{variant:ga[c.status],className:"text-[10px]",children:fa[c.status]}),c.status==="accepted"&&e.jsx(ps,{className:"h-3 w-3 text-green-600"})]}),e.jsx("span",{className:"text-[11px] text-slate-400",children:new Date(c.created_at).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-[12px]",children:[e.jsxs("div",{className:"bg-amber-50 rounded-lg p-3",children:[e.jsx("p",{className:"font-semibold text-amber-700 mb-2 text-[11px] uppercase tracking-wide",children:"Candidate Request"}),e.jsxs("div",{className:"space-y-1 text-slate-600",children:[((Y=c.candidate_counter)==null?void 0:Y.ctc)&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400",children:"CTC: "}),"₹",Number(c.candidate_counter.ctc).toLocaleString("en-IN")]}),((ve=c.candidate_counter)==null?void 0:ve.joining_date)&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400",children:"Joining: "}),c.candidate_counter.joining_date]}),((Be=c.candidate_counter)==null?void 0:Be.designation)&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400",children:"Role: "}),c.candidate_counter.designation]}),((yt=c.candidate_counter)==null?void 0:yt.other)&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400",children:"Other: "}),c.candidate_counter.other]}),!((dt=c.candidate_counter)!=null&&dt.ctc)&&!((At=c.candidate_counter)!=null&&At.joining_date)&&!((Rt=c.candidate_counter)!=null&&Rt.designation)&&!((d=c.candidate_counter)!=null&&d.other)&&e.jsx("span",{className:"text-slate-400",children:"—"})]})]}),e.jsxs("div",{className:"bg-blue-50 rounded-lg p-3",children:[e.jsx("p",{className:"font-semibold text-blue-700 mb-2 text-[11px] uppercase tracking-wide",children:"HR Response"}),e.jsxs("div",{className:"space-y-1 text-slate-600",children:[((f=c.company_response)==null?void 0:f.ctc)&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400",children:"CTC: "}),"₹",Number(c.company_response.ctc).toLocaleString("en-IN")]}),((he=c.company_response)==null?void 0:he.joining_date)&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400",children:"Joining: "}),c.company_response.joining_date]}),((Ze=c.company_response)==null?void 0:Ze.notes)&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400",children:"Notes: "}),c.company_response.notes]}),!((Ge=c.company_response)!=null&&Ge.ctc)&&!((Nt=c.company_response)!=null&&Nt.joining_date)&&!((Dt=c.company_response)!=null&&Dt.notes)&&e.jsx("span",{className:"text-slate-400",children:"—"})]})]})]}),c.notes&&e.jsx("p",{className:"mt-2 text-[12px] text-slate-500 italic",children:c.notes}),c.handled_by_name&&e.jsxs("p",{className:"mt-1 text-[11px] text-slate-400",children:["Handled by: ",c.handled_by_name]}),((Zt=c.comments)==null?void 0:Zt.length)>0&&e.jsxs("div",{className:"mt-3 border-t pt-2",children:[e.jsxs("p",{className:"text-[11px] font-medium text-slate-500 mb-1",children:["Comments (",c.comments.length,")"]}),c.comments.map(Ot=>e.jsxs("div",{className:`text-[11px] p-1.5 rounded mb-1 ${Ot.author_role==="hr"?"bg-blue-50 text-blue-800":"bg-amber-50 text-amber-800"}`,children:[e.jsx("span",{className:"font-medium capitalize",children:Ot.author_role}),Ot.created_by_name&&e.jsxs("span",{className:"text-slate-400",children:[" (",Ot.created_by_name,")"]}),": ",Ot.message,e.jsx("span",{className:"text-slate-400 ml-2",children:new Date(Ot.created_at).toLocaleString()})]},Ot.id))]})]},c.id)})]})]})}),e.jsx(bt,{open:!!y,onOpenChange:c=>!c&&m(null),children:e.jsxs(Ct,{children:[e.jsxs(St,{children:[e.jsxs(wt,{className:"flex items-center gap-2",children:[e.jsx(as,{className:"h-4 w-4"})," Comments"]}),e.jsx(bs,{children:"Communication thread for this negotiation round"})]}),e.jsxs("div",{className:"max-h-[300px] overflow-y-auto space-y-2",children:[(!(ae!=null&&ae.comments)||ae.comments.length===0)&&e.jsx("p",{className:"text-[13px] text-slate-400 text-center py-4",children:"No comments yet."}),((ae==null?void 0:ae.comments)||[]).map(c=>e.jsxs("div",{className:`text-[12px] p-2 rounded ${c.author_role==="hr"?"bg-blue-50":"bg-amber-50"}`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[e.jsxs("span",{className:"font-medium capitalize",children:[c.author_role,c.created_by_name?` (${c.created_by_name})`:""]}),e.jsx("span",{className:"text-[10px] text-slate-400",children:new Date(c.created_at).toLocaleString()})]}),e.jsx("p",{className:"text-slate-700",children:c.message})]},c.id))]}),ee&&e.jsxs(e.Fragment,{children:[e.jsx(ms,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Ae,{value:V,onChange:c=>F(c.target.value),placeholder:"Type a message…",rows:2,className:"text-[12px]"}),e.jsx(P,{size:"sm",onClick:U,disabled:H.isPending||!V.trim(),children:e.jsx(Kt,{className:"h-3.5 w-3.5"})})]})]})]})})]})}const hl=ct({requisition_prefix:C(),requisition_auto_number:ge(),requisition_approval_required:ge(),requisition_budget_validation:ge(),requisition_aging_warning_days:Me.number().min(1).max(365),requisition_aging_critical_days:Me.number().min(1).max(365),career_page_enabled:ge(),internal_posting_first:ge(),internal_posting_days:Me.number().min(0).max(90),referral_program_enabled:ge(),default_referral_bonus:C(),screening_questions_enabled:ge(),auto_reject_knockout:ge(),duplicate_detection_enabled:ge(),candidate_consent_required:ge(),candidate_data_retention_days:Me.number().min(1).max(3650),resume_pool_enabled:ge(),candidate_portal_enabled:ge(),default_interview_duration_minutes:Me.number().min(15).max(480),self_scheduling_enabled:ge(),video_platform:C(),min_panel_size:Me.number().min(1).max(20),evaluation_mandatory_before_next_round:ge(),debrief_auto_schedule:ge(),offer_prefix:C(),offer_number_format:C(),offer_signatory_name:C(),offer_signatory_designation:C(),offer_signatory_department:C(),offer_approval_required:ge(),offer_validity_days:Me.number().min(1).max(365),digital_acceptance_enabled:ge(),offer_comparison_enabled:ge(),negotiation_tracking_enabled:ge(),max_negotiation_rounds:Me.number().min(1).max(20),md_approval_email:C().email("Enter a valid email").or(Dn("")),md_approval_required:ge(),bgv_enabled:ge(),bgv_block_onboarding:ge(),notify_candidate_stage_change:ge(),notify_interviewer_scheduled:ge(),notify_hiring_manager_new_application:ge()}),jl={requisition_prefix:"REQ",requisition_auto_number:!0,requisition_approval_required:!0,requisition_budget_validation:!1,requisition_aging_warning_days:30,requisition_aging_critical_days:60,career_page_enabled:!0,internal_posting_first:!1,internal_posting_days:7,referral_program_enabled:!0,default_referral_bonus:"0",screening_questions_enabled:!0,auto_reject_knockout:!1,duplicate_detection_enabled:!0,candidate_consent_required:!0,candidate_data_retention_days:365,resume_pool_enabled:!0,candidate_portal_enabled:!1,default_interview_duration_minutes:60,self_scheduling_enabled:!1,video_platform:"",min_panel_size:2,evaluation_mandatory_before_next_round:!0,debrief_auto_schedule:!1,offer_prefix:"OFR",offer_number_format:"{prefix}-{year}-{seq:05d}",offer_signatory_name:"",offer_signatory_designation:"",offer_signatory_department:"",offer_approval_required:!0,offer_validity_days:7,digital_acceptance_enabled:!0,offer_comparison_enabled:!1,negotiation_tracking_enabled:!1,max_negotiation_rounds:3,md_approval_email:"",md_approval_required:!0,bgv_enabled:!1,bgv_block_onboarding:!1,notify_candidate_stage_change:!0,notify_interviewer_scheduled:!0,notify_hiring_manager_new_application:!0};function $e({label:s,description:t,checked:a,onChange:n}){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(rs,{checked:a,onCheckedChange:n})]})}function zt({icon:s,title:t,description:a,children:n}){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:n})]})}function dd(){const{data:s,isLoading:t}=li(),a=ci(),{control:n,handleSubmit:i,reset:u,register:r,formState:{isDirty:N}}=Ye({resolver:nt(hl),defaultValues:jl});h.useEffect(()=>{s&&u({requisition_prefix:s.requisition_prefix,requisition_auto_number:s.requisition_auto_number,requisition_approval_required:s.requisition_approval_required,requisition_budget_validation:s.requisition_budget_validation,requisition_aging_warning_days:s.requisition_aging_warning_days,requisition_aging_critical_days:s.requisition_aging_critical_days,career_page_enabled:s.career_page_enabled,internal_posting_first:s.internal_posting_first,internal_posting_days:s.internal_posting_days,referral_program_enabled:s.referral_program_enabled,default_referral_bonus:s.default_referral_bonus,screening_questions_enabled:s.screening_questions_enabled,auto_reject_knockout:s.auto_reject_knockout,duplicate_detection_enabled:s.duplicate_detection_enabled,candidate_consent_required:s.candidate_consent_required,candidate_data_retention_days:s.candidate_data_retention_days,resume_pool_enabled:s.resume_pool_enabled,candidate_portal_enabled:s.candidate_portal_enabled,default_interview_duration_minutes:s.default_interview_duration_minutes,self_scheduling_enabled:s.self_scheduling_enabled,video_platform:s.video_platform,min_panel_size:s.min_panel_size,evaluation_mandatory_before_next_round:s.evaluation_mandatory_before_next_round,debrief_auto_schedule:s.debrief_auto_schedule,offer_prefix:s.offer_prefix,offer_number_format:s.offer_number_format??"{prefix}-{year}-{seq:05d}",offer_signatory_name:s.offer_signatory_name??"",offer_signatory_designation:s.offer_signatory_designation??"",offer_signatory_department:s.offer_signatory_department??"",offer_approval_required:s.offer_approval_required,offer_validity_days:s.offer_validity_days,digital_acceptance_enabled:s.digital_acceptance_enabled,offer_comparison_enabled:s.offer_comparison_enabled,negotiation_tracking_enabled:s.negotiation_tracking_enabled,max_negotiation_rounds:s.max_negotiation_rounds,md_approval_email:s.md_approval_email??"",md_approval_required:s.md_approval_required??!0,bgv_enabled:s.bgv_enabled,bgv_block_onboarding:s.bgv_block_onboarding,notify_candidate_stage_change:s.notify_candidate_stage_change,notify_interviewer_scheduled:s.notify_interviewer_scheduled,notify_hiring_manager_new_application:s.notify_hiring_manager_new_application})},[s,u]);function y(m){a.mutate({...m,id:s==null?void 0:s.id},{onSuccess:()=>u(m)})}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(ws,{className:"h-5 w-5 text-primary"})," Recruitment Settings"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure recruitment module settings"})]})}),e.jsx("div",{className:"space-y-6",children:Array.from({length:7}).map((m,V)=>e.jsx(Bn,{className:"h-48 w-full rounded-xl"},V))})]}):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(ws,{className:"h-5 w-5 text-primary"})," Recruitment Settings"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure recruitment module settings"})]})}),e.jsxs("form",{onSubmit:i(y),className:"space-y-6",children:[e.jsxs(zt,{icon:kt,title:"Requisition",description:"Configure job requisition numbering and approval workflows",children:[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:"Requisition Prefix"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Prefix used for auto-generated requisition numbers"})]}),e.jsx(b,{...r("requisition_prefix"),className:"w-[120px] h-8 text-[12px]"})]}),e.jsx(Pe,{name:"requisition_auto_number",control:n,render:({field:m})=>e.jsx($e,{label:"Auto Numbering",description:"Automatically generate sequential requisition numbers",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"requisition_approval_required",control:n,render:({field:m})=>e.jsx($e,{label:"Approval Required",description:"Require manager approval before a requisition can be published",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"requisition_budget_validation",control:n,render:({field:m})=>e.jsx($e,{label:"Budget Validation",description:"Validate requisition budget against department allocation",checked:m.value,onChange:m.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:"Aging Warning (days)"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Days before a requisition is flagged as aging"})]}),e.jsx(b,{type:"number",...r("requisition_aging_warning_days"),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:"Aging Critical (days)"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Days before a requisition is flagged as critical"})]}),e.jsx(b,{type:"number",...r("requisition_aging_critical_days"),className:"w-[100px] h-8 text-[12px]"})]})]}),e.jsxs(zt,{icon:Gn,title:"Posting & Sourcing",description:"Career page, internal posting, and referral program settings",children:[e.jsx(Pe,{name:"career_page_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Career Page",description:"Enable the public-facing career page for external candidates",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"internal_posting_first",control:n,render:({field:m})=>e.jsx($e,{label:"Internal Posting First",description:"Post jobs internally before making them public",checked:m.value,onChange:m.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:"Internal Posting Days"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Number of days a job is posted internally before going public"})]}),e.jsx(b,{type:"number",...r("internal_posting_days"),className:"w-[100px] h-8 text-[12px]"})]}),e.jsx(Pe,{name:"referral_program_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Referral Program",description:"Enable employee referral program for job postings",checked:m.value,onChange:m.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:"Default Referral Bonus"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Default bonus amount for successful referrals"})]}),e.jsx(b,{...r("default_referral_bonus"),className:"w-[120px] h-8 text-[12px]",placeholder:"0"})]})]}),e.jsxs(zt,{icon:Hn,title:"ATS & Screening",description:"Candidate tracking, screening, and data management settings",children:[e.jsx(Pe,{name:"screening_questions_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Screening Questions",description:"Enable screening questions on job applications",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"auto_reject_knockout",control:n,render:({field:m})=>e.jsx($e,{label:"Auto-Reject Knockout",description:"Automatically reject candidates who fail knockout screening questions",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"duplicate_detection_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Duplicate Detection",description:"Detect and flag duplicate candidate profiles",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"candidate_consent_required",control:n,render:({field:m})=>e.jsx($e,{label:"Candidate Consent Required",description:"Require candidates to give data processing consent",checked:m.value,onChange:m.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:"Data Retention (days)"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Number of days to retain candidate data after last activity"})]}),e.jsx(b,{type:"number",...r("candidate_data_retention_days"),className:"w-[100px] h-8 text-[12px]"})]}),e.jsx(Pe,{name:"resume_pool_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Resume Pool",description:"Enable a shared resume pool across requisitions",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"candidate_portal_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Candidate Portal",description:"Allow candidates to track their application status online",checked:m.value,onChange:m.onChange})})]}),e.jsxs(zt,{icon:ni,title:"Interview",description:"Interview scheduling, panel, and evaluation settings",children:[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 (minutes)"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Default interview slot duration in minutes"})]}),e.jsx(b,{type:"number",...r("default_interview_duration_minutes"),className:"w-[100px] h-8 text-[12px]"})]}),e.jsx(Pe,{name:"self_scheduling_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Self Scheduling",description:"Allow candidates to pick their own interview slot",checked:m.value,onChange:m.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:"Video Platform"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Default video conferencing platform for interviews"})]}),e.jsx(b,{...r("video_platform"),className:"w-[140px] h-8 text-[12px]",placeholder:"e.g. Zoom, Teams"})]}),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 Panel Size"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Minimum number of panelists required per interview"})]}),e.jsx(b,{type:"number",...r("min_panel_size"),className:"w-[100px] h-8 text-[12px]"})]}),e.jsx(Pe,{name:"evaluation_mandatory_before_next_round",control:n,render:({field:m})=>e.jsx($e,{label:"Mandatory Evaluation",description:"Require all panelists to submit evaluations before advancing to the next round",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"debrief_auto_schedule",control:n,render:({field:m})=>e.jsx($e,{label:"Auto-Schedule Debrief",description:"Automatically schedule a debrief meeting after interviews",checked:m.value,onChange:m.onChange})})]}),e.jsxs(zt,{icon:Jn,title:"Offer",description:"Offer letter generation, approval, and acceptance settings",children:[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:"Offer Prefix"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Prefix used for auto-generated offer numbers"})]}),e.jsx(b,{...r("offer_prefix"),className:"w-[120px] 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:"Offer Number Format"}),e.jsxs("p",{className:"text-[11px] text-slate-400 mt-0.5",children:["Placeholders: ",e.jsx("span",{className:"font-mono",children:"{prefix}"}),","," ",e.jsx("span",{className:"font-mono",children:"{company_code}"}),","," ",e.jsx("span",{className:"font-mono",children:"{year}"}),","," ",e.jsx("span",{className:"font-mono",children:"{fy}"})," (e.g. 26-27),"," ",e.jsx("span",{className:"font-mono",children:"{seq}"}),". For example"," ",e.jsx("span",{className:"font-mono",children:"{company_code}/OLE/{fy}/{seq:02d}"})," gives PIA/OLE/26-27/01"]})]}),e.jsx(b,{...r("offer_number_format"),className:"w-[260px] h-8 text-[12px] font-mono"})]}),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:"Letter Signatory"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Name printed above the signature on generated offer letters. Leave blank to use the person who created the offer."})]}),e.jsx(b,{...r("offer_signatory_name"),placeholder:"Offer creator",className:"w-[220px] 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:"Signatory Designation"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Shown under the signatory name"})]}),e.jsx(b,{...r("offer_signatory_designation"),placeholder:"Head — Human Resources",className:"w-[220px] 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:"Signatory Department"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Shown under the signatory, e.g. Human Resources"})]}),e.jsx(b,{...r("offer_signatory_department"),placeholder:"Human Resources",className:"w-[220px] h-8 text-[12px]"})]}),e.jsx(Pe,{name:"offer_approval_required",control:n,render:({field:m})=>e.jsx($e,{label:"Approval Required",description:"Require approval before an offer can be sent to a candidate",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"md_approval_required",control:n,render:({field:m})=>e.jsx($e,{label:"MD Final Approval",description:"Send offer to Managing Director for final approval via email",checked:m.value,onChange:m.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:"MD Email Address"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Managing Director email — receives offer approval request on every new offer"})]}),e.jsx(b,{...r("md_approval_email"),type:"email",placeholder:"md@company.com",className:"w-[220px] 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:"Offer Validity (days)"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Number of days an offer remains valid after being sent"})]}),e.jsx(b,{type:"number",...r("offer_validity_days"),className:"w-[100px] h-8 text-[12px]"})]}),e.jsx(Pe,{name:"digital_acceptance_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Digital Acceptance",description:"Allow candidates to accept offers digitally via the portal",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"offer_comparison_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Offer Comparison",description:"Enable side-by-side comparison of multiple offer revisions",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"negotiation_tracking_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Negotiation Tracking",description:"Track offer negotiation rounds and counter-offers",checked:m.value,onChange:m.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 Negotiation Rounds"}),e.jsx("p",{className:"text-[11px] text-slate-400 mt-0.5",children:"Maximum number of negotiation rounds allowed per offer"})]}),e.jsx(b,{type:"number",...r("max_negotiation_rounds"),className:"w-[100px] h-8 text-[12px]"})]})]}),e.jsxs(zt,{icon:Wn,title:"Verification",description:"Background verification and onboarding gate settings",children:[e.jsx(Pe,{name:"bgv_enabled",control:n,render:({field:m})=>e.jsx($e,{label:"Background Verification",description:"Enable background verification checks for candidates",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"bgv_block_onboarding",control:n,render:({field:m})=>e.jsx($e,{label:"Block Onboarding",description:"Block onboarding until all background checks are cleared",checked:m.value,onChange:m.onChange})})]}),e.jsxs(zt,{icon:Nn,title:"Notifications",description:"Configure recruitment notification preferences",children:[e.jsx(Pe,{name:"notify_candidate_stage_change",control:n,render:({field:m})=>e.jsx($e,{label:"Stage Change Notifications",description:"Notify candidates when their application moves to a new stage",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"notify_interviewer_scheduled",control:n,render:({field:m})=>e.jsx($e,{label:"Interviewer Scheduled",description:"Notify interviewers when they are assigned to an interview panel",checked:m.value,onChange:m.onChange})}),e.jsx(Pe,{name:"notify_hiring_manager_new_application",control:n,render:({field:m})=>e.jsx($e,{label:"New Application Alert",description:"Notify hiring managers when a new application is received",checked:m.value,onChange:m.onChange})})]}),e.jsx("div",{className:"flex justify-end pt-2 pb-4",children:e.jsx(P,{type:"submit",disabled:!N||a.isPending,className:"min-w-[120px]",children:a.isPending?e.jsxs(e.Fragment,{children:[e.jsx(bn,{className:"mr-2 h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})})]})]})}const gl=ct({name:C().min(1,"Name is required"),code:C().min(1,"Code is required"),company:C().min(1,"Company is required"),is_active:ge().optional()});function md(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),{hasPermission:r,requirePermission:N}=et(),y=r("recruitment","settings","create"),m=r("recruitment","settings","update"),{pagination:V,setPagination:F,sorting:M,setSorting:z,globalFilter:G,setGlobalFilter:ee,queryParams:te}=tt(),{data:ie,isLoading:L}=Ka(te),re=(ie==null?void 0:ie.results)??[],[ne,ce]=h.useState(""),{data:J,isLoading:Q}=Ut({search:ne||void 0}),R=oi(),v=di(),S=mi(),X=Ye({resolver:nt(gl),defaultValues:{name:"",code:"",company:"",is_active:!0}});function Z(){N("recruitment","settings","create")&&(n(null),X.reset({name:"",code:"",company:"",is_active:!0}),t(!0))}function W(D){N("recruitment","settings","update")&&(n(D),X.reset({name:D.name,code:D.code,company:D.company,is_active:D.is_active}),t(!0))}function de(D){const H=D;a?v.mutate({id:a.id,...H},{onSuccess:()=>t(!1)}):R.mutate(H,{onSuccess:()=>t(!1)})}function w(){i&&S.mutate(i.id,{onSuccess:()=>u(null)})}const se=[{key:"name",header:"Name",render:D=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:D.name})},{key:"code",header:"Code",render:D=>e.jsx("span",{className:"text-[13px] text-slate-600",children:D.code})},{key:"is_active",header:"Status",render:D=>e.jsx(La,{status:D.is_active?"active":"inactive"})},{key:"created_at",header:"Created",render:D=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(D.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:D=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[m&&e.jsxs(B,{onClick:()=>W(D),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),m&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{className:"text-red-600",onClick:()=>u(D),children:[e.jsx(ft,{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(Fa,{className:"h-5 w-5 text-primary"})," Business Needs"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Manage the master list of business justifications for hiring"})]}),y&&e.jsxs(P,{size:"sm",onClick:Z,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Add Business Need"]})]}),e.jsx(st,{columns:se,data:re,isLoading:L,searchPlaceholder:"Search business needs...",emptyMessage:"No business needs",emptyDescription:"Create your first business need to use in job requisitions.",totalCount:(ie==null?void 0:ie.count)??0,pagination:V,onPaginationChange:F,sorting:M,onSortingChange:z,globalFilter:G,onGlobalFilterChange:ee}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"md",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Business Need":"Add Business Need"}),e.jsx(Ie,{children:a?"Update business need details.":"Create a new business need for requisitions."})]}),e.jsxs("form",{onSubmit:X.handleSubmit(de),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(b,{...X.register("name"),className:"mt-1.5",placeholder:"e.g. Revenue Growth"}),X.formState.errors.name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:X.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(b,{...X.register("code"),className:"mt-1.5",placeholder:"e.g. REVENUE_GROWTH"}),X.formState.errors.code&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:X.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:X.watch("company"),onValueChange:D=>X.setValue("company",D),onSearch:ce,isLoading:Q,options:((J==null?void 0:J.results)??[]).map(D=>({value:D.id,label:D.name,hint:D.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),X.formState.errors.company&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:X.formState.errors.company.message})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:X.handleSubmit(de),disabled:R.isPending||v.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(mt,{open:!!i,onOpenChange:D=>!D&&u(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Delete business need?"}),e.jsxs(ht,{children:["This will permanently delete ",e.jsx("strong",{children:i==null?void 0:i.name}),"."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:"destructive",onClick:w,children:"Delete"})]})]})})]})}const fl=ct({name:C().min(1,"Name is required"),code:C().min(1,"Code is required"),company:C().min(1,"Company is required"),order:Me.number().min(0,"Order must be 0 or greater"),is_default:ge().optional(),is_rejection_stage:ge().optional(),is_active:ge().optional()});function xd(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),{hasPermission:r,requirePermission:N}=et(),y=r("recruitment","pipeline","create"),m=r("recruitment","pipeline","update"),V=r("recruitment","pipeline","delete"),{pagination:F,setPagination:M,sorting:z,setSorting:G,globalFilter:ee,setGlobalFilter:te,queryParams:ie}=tt(),{data:L,isLoading:re}=za(ie),ne=(L==null?void 0:L.results)??[],ce=qi(),J=Fi(),Q=Pi(),[R,v]=h.useState(""),{data:S,isLoading:X}=Ut({search:R||void 0}),Z=(S==null?void 0:S.results)??[],W=Ye({resolver:nt(fl),defaultValues:{name:"",code:"",company:"",order:0,is_default:!1,is_rejection_stage:!1,is_active:!0}});function de(){var I;N("recruitment","pipeline","create")&&(n(null),W.reset({name:"",code:"",company:((I=Z[0])==null?void 0:I.id)??"",order:0,is_default:!1,is_rejection_stage:!1,is_active:!0}),t(!0))}function w(I){N("recruitment","pipeline","update")&&(n(I),W.reset({name:I.name,code:I.code,company:I.company,order:I.order,is_default:I.is_default,is_rejection_stage:I.is_rejection_stage,is_active:I.is_active}),t(!0))}function se(I){const A=I;a?J.mutate({id:a.id,...A},{onSuccess:()=>t(!1)}):ce.mutate(A,{onSuccess:()=>t(!1)})}function D(){i&&Q.mutate(i.id,{onSuccess:()=>u(null)})}const H=[{key:"name",header:"Name",render:I=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:I.name})},{key:"code",header:"Code",render:I=>e.jsx("span",{className:"text-[13px] text-slate-600",children:I.code})},{key:"order",header:"Order",render:I=>e.jsx("span",{className:"text-[13px] text-slate-600",children:I.order})},{key:"is_default",header:"Default",render:I=>e.jsx(le,{variant:I.is_default?"success":"secondary",className:"text-[11px]",children:I.is_default?"Yes":"No"})},{key:"is_rejection_stage",header:"Rejection",render:I=>e.jsx(le,{variant:I.is_rejection_stage?"destructive":"secondary",className:"text-[11px]",children:I.is_rejection_stage?"Yes":"No"})},{key:"is_active",header:"Active",render:I=>e.jsx(le,{variant:I.is_active?"success":"secondary",className:"text-[11px]",children:I.is_active?"Yes":"No"})},{key:"actions",header:"",className:"w-10",render:I=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[m&&e.jsxs(B,{onClick:()=>w(I),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),V&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{className:"text-red-600",onClick:()=>u(I),children:[e.jsx(ft,{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(Pa,{className:"h-5 w-5 text-primary"})," Application Stages"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Configure ATS application stages and their order"})]}),y&&e.jsxs(P,{size:"sm",onClick:de,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Add Stage"]})]}),e.jsx(st,{columns:H,data:ne,isLoading:re,searchPlaceholder:"Search stages...",emptyMessage:"No application stages",emptyDescription:"Add your first application stage to configure your ATS workflow.",totalCount:(L==null?void 0:L.count)??0,pagination:F,onPaginationChange:M,sorting:z,onSortingChange:G,globalFilter:ee,onGlobalFilterChange:te}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"md",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Stage":"Add Stage"}),e.jsx(Ie,{children:a?"Update application stage details.":"Add a new application stage to your ATS workflow."})]}),e.jsxs("form",{onSubmit:W.handleSubmit(se),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(b,{...W.register("name"),className:"mt-1.5",placeholder:"e.g. Technical Interview"}),W.formState.errors.name&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:W.formState.errors.name.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(b,{...W.register("code"),className:"mt-1.5",placeholder:"e.g. TECH_INTERVIEW"}),W.formState.errors.code&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:W.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:W.watch("company"),onValueChange:I=>W.setValue("company",I),onSearch:v,isLoading:X,options:((S==null?void 0:S.results)??[]).map(I=>({value:I.id,label:I.name,hint:I.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),W.formState.errors.company&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:W.formState.errors.company.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Order *"}),e.jsx(b,{type:"number",...W.register("order"),className:"mt-1.5",placeholder:"0"}),W.formState.errors.order&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:W.formState.errors.order.message})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lt,{checked:W.watch("is_default"),onCheckedChange:I=>W.setValue("is_default",!!I)}),e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Default stage"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lt,{checked:W.watch("is_rejection_stage"),onCheckedChange:I=>W.setValue("is_rejection_stage",!!I)}),e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Rejection stage"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lt,{checked:W.watch("is_active"),onCheckedChange:I=>W.setValue("is_active",!!I)}),e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Active"})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:W.handleSubmit(se),disabled:ce.isPending||J.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(mt,{open:!!i,onOpenChange:I=>!I&&u(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Delete application stage?"}),e.jsxs(ht,{children:["This will permanently delete ",e.jsx("strong",{children:i==null?void 0:i.name}),"."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:"destructive",onClick:D,children:"Delete"})]})]})})]})}const _a={phone:"Phone Screen",video:"Video Call",in_person:"In-Person",take_home:"Take-Home Assignment",group_discussion:"Group Discussion",presentation:"Presentation",panel:"Panel Interview"},_l=ct({category:C().min(1,"Category is required"),name:C().min(1,"Name is required"),order:Me.number().min(0),round_type:C().min(1,"Round type is required"),duration_minutes:Me.number().min(1),interviewers_required:Me.number().min(1),is_mandatory:ge().optional(),is_elimination:ge().optional(),instructions:C().optional(),candidate_instructions:C().optional()});function ud(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),{hasPermission:r,requirePermission:N}=et(),y=r("recruitment","interview_round","create"),m=r("recruitment","interview_round","update"),V=r("recruitment","interview_round","delete"),{pagination:F,setPagination:M,sorting:z,setSorting:G,globalFilter:ee,setGlobalFilter:te,queryParams:ie}=tt(),{data:L,isLoading:re}=Us(ie),ne=(L==null?void 0:L.results)??[],{data:ce}=Ms({page_size:100,is_active:!0}),J=(ce==null?void 0:ce.results)??[],Q=Mi(),R=Qi(),v=Ui(),S=Ye({resolver:nt(_l),defaultValues:{category:"",name:"",order:0,round_type:"video",duration_minutes:60,interviewers_required:1,is_mandatory:!0,is_elimination:!1,instructions:"",candidate_instructions:""}});function X(){N("recruitment","interview_round","create")&&(n(null),S.reset({category:"",name:"",order:0,round_type:"video",duration_minutes:60,interviewers_required:1,is_mandatory:!0,is_elimination:!1,instructions:"",candidate_instructions:""}),t(!0))}function Z(w){N("recruitment","interview_round","update")&&(n(w),S.reset({category:w.category??"",name:w.name,order:w.order,round_type:w.round_type,duration_minutes:w.duration_minutes,interviewers_required:w.interviewers_required,is_mandatory:w.is_mandatory,is_elimination:w.is_elimination,instructions:w.instructions,candidate_instructions:w.candidate_instructions}),t(!0))}function W(w){const se=w;a?R.mutate({id:a.id,...se},{onSuccess:()=>t(!1)}):Q.mutate(se,{onSuccess:()=>t(!1)})}const de=[{key:"name",header:"Round Name",render:w=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:w.name})},{key:"category_name",header:"Category",render:w=>e.jsx("span",{className:"text-[13px] text-slate-600",children:w.category_name||w.requisition_number||"—"})},{key:"round_type",header:"Type",render:w=>e.jsx(le,{variant:"outline",className:"text-[11px]",children:_a[w.round_type]??w.round_type})},{key:"order",header:"Order",render:w=>e.jsx("span",{className:"text-[13px] text-slate-600",children:w.order})},{key:"duration_minutes",header:"Duration",render:w=>e.jsxs("span",{className:"text-[13px] text-slate-600",children:[w.duration_minutes," min"]})},{key:"is_mandatory",header:"Mandatory",render:w=>e.jsx(le,{variant:w.is_mandatory?"success":"secondary",className:"text-[11px]",children:w.is_mandatory?"Yes":"No"})},{key:"is_elimination",header:"Elimination",render:w=>e.jsx(le,{variant:w.is_elimination?"destructive":"secondary",className:"text-[11px]",children:w.is_elimination?"Yes":"No"})},{key:"actions",header:"",className:"w-10",render:w=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[m&&e.jsxs(B,{onClick:()=>Z(w),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),V&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{className:"text-red-600",onClick:()=>u(w),children:[e.jsx(ft,{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(Ls,{className:"h-5 w-5 text-primary"})," Interview Rounds"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Define interview rounds once per category — every requisition in it runs them"})]}),y&&e.jsxs(P,{size:"sm",onClick:X,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Add Round"]})]}),e.jsx(st,{columns:de,data:ne,isLoading:re,searchPlaceholder:"Search rounds...",emptyMessage:"No interview rounds",emptyDescription:"Add rounds to a category to define its hiring process once.",totalCount:(L==null?void 0:L.count)??0,pagination:F,onPaginationChange:M,sorting:z,onSortingChange:G,globalFilter:ee,onGlobalFilterChange:te}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"md",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Round":"Add Interview Round"}),e.jsx(Ie,{children:a?"Update interview round details.":"Define a new interview round for a category."})]}),e.jsxs("form",{onSubmit:S.handleSubmit(W),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Category *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:S.watch("category")??null,onValueChange:w=>S.setValue("category",w,{shouldValidate:!0}),disabled:!!a,options:J.map(w=>({value:w.id,label:w.name,hint:w.code})),selectedLabel:a==null?void 0:a.category_name,placeholder:"Select category",searchPlaceholder:"Search categories..."})}),S.formState.errors.category&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:S.formState.errors.category.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Round Name *"}),e.jsx(b,{...S.register("name"),className:"mt-1.5",placeholder:"e.g. Technical Interview"}),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(o,{className:"text-[12px] font-medium text-slate-500",children:"Round Type *"}),e.jsxs(Ce,{value:S.watch("round_type"),onValueChange:w=>S.setValue("round_type",w),children:[e.jsx(Se,{className:"mt-1.5 h-9",children:e.jsx(we,{})}),e.jsx(ke,{children:Object.entries(_a).map(([w,se])=>e.jsx(q,{value:w,children:se},w))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Order"}),e.jsx(b,{type:"number",...S.register("order"),className:"mt-1.5",min:0})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Duration (min)"}),e.jsx(b,{type:"number",...S.register("duration_minutes"),className:"mt-1.5",min:1})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Interviewers Required"}),e.jsx(b,{type:"number",...S.register("interviewers_required"),className:"mt-1.5",min:1})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lt,{checked:S.watch("is_mandatory"),onCheckedChange:w=>S.setValue("is_mandatory",!!w)}),e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Mandatory"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Lt,{checked:S.watch("is_elimination"),onCheckedChange:w=>S.setValue("is_elimination",!!w)}),e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Elimination round"})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Interviewer Instructions"}),e.jsx(Ae,{...S.register("instructions"),className:"mt-1.5",rows:2,placeholder:"Notes for interviewers..."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Candidate Instructions"}),e.jsx(Ae,{...S.register("candidate_instructions"),className:"mt-1.5",rows:2,placeholder:"What candidates should prepare..."})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:S.handleSubmit(W),disabled:Q.isPending||R.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(mt,{open:!!i,onOpenChange:w=>!w&&u(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Delete interview round?"}),e.jsxs(ht,{children:["This will permanently delete ",e.jsx("strong",{children:i==null?void 0:i.name}),"."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:"destructive",onClick:()=>{i&&v.mutate(i.id,{onSuccess:()=>u(null)})},children:"Delete"})]})]})})]})}function pd(){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(ks,{className:"h-5 w-5 text-primary"})," Reports"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"View recruitment reports and metrics"})]})}),e.jsxs(Ft,{children:[e.jsx(Tt,{children:e.jsx(Vt,{className:"text-[14px] font-semibold",children:"Recruitment Reports"})}),e.jsx(Pt,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(ks,{className:"h-10 w-10 text-slate-300 mb-3"}),e.jsx("p",{className:"text-[14px] font-medium text-slate-600",children:"Coming Soon"}),e.jsx("p",{className:"text-[13px] text-slate-400 mt-1 max-w-sm",children:"Generate detailed recruitment reports including time-to-hire, cost-per-hire, source effectiveness, and pipeline conversion rates."})]})})]})]})}function hd(){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(qs,{className:"h-5 w-5 text-primary"})," Analytics"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Explore recruitment trends and insights"})]})}),e.jsxs(Ft,{children:[e.jsx(Tt,{children:e.jsx(Vt,{className:"text-[14px] font-semibold",children:"Recruitment Analytics"})}),e.jsx(Pt,{children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(qs,{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 recruitment trends, funnel analytics, diversity metrics, and predictive hiring insights with interactive dashboards."})]})})]})]})}const vl=ct({employee:C().min(1,"Employee is required"),template:C().optional().nullable(),effective_date:C().optional().nullable(),probation_months:Me.number().min(0).max(24),notice_period_probation_days:Me.number().min(0).max(365),notice_period_confirmed_days:Me.number().min(0).max(365),non_solicit_years:Me.number().min(0).max(10),special_conditions:C().optional()}),yl={draft:"secondary",issued:"warning",acknowledged:"success",superseded:"secondary",cancelled:"destructive"};function Nl(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),[r,N]=h.useState(null),[y,m]=h.useState(null),{hasPermission:V,requirePermission:F}=et(),M=V("recruitment","service_contract","create"),z=V("recruitment","service_contract","update"),G=V("recruitment","service_contract","delete"),{pagination:ee,setPagination:te,sorting:ie,setSorting:L,globalFilter:re,setGlobalFilter:ne,queryParams:ce}=tt(),{data:J,isLoading:Q}=ir(ce),R=(J==null?void 0:J.results)??[],v=rr(),S=lr(),X=cr(),Z=da("issue"),W=da("acknowledge"),de=or(),{data:w}=js({page_size:200}),se=(w==null?void 0:w.results)??[],{data:D}=Bs({page_size:100,is_active:!0,document_type:"service_contract"}),H=(D==null?void 0:D.results)??[],I=Ye({resolver:nt(vl),defaultValues:{probation_months:3,notice_period_probation_days:30,notice_period_confirmed_days:60,non_solicit_years:3}});h.useEffect(()=>()=>{y&&URL.revokeObjectURL(y)},[y]);function A(){var U;F("recruitment","service_contract","create")&&(n(null),I.reset({employee:"",template:((U=H[0])==null?void 0:U.id)??null,effective_date:"",probation_months:3,notice_period_probation_days:30,notice_period_confirmed_days:60,non_solicit_years:3,special_conditions:""}),t(!0))}function O(U){F("recruitment","service_contract","update")&&(n(U),I.reset({employee:U.employee,template:U.template,effective_date:U.effective_date??"",probation_months:U.probation_months,notice_period_probation_days:U.notice_period_probation_days,notice_period_confirmed_days:U.notice_period_confirmed_days,non_solicit_years:U.non_solicit_years,special_conditions:U.special_conditions}),t(!0))}function K(U){de.mutate(U.id,{onSuccess:ae=>m(URL.createObjectURL(ae))})}function _e(){y&&URL.revokeObjectURL(y),m(null)}function T(U){const ae={...U,template:U.template||null,effective_date:U.effective_date||null},_={onSuccess:()=>t(!1)};a?S.mutate({id:a.id,...ae},_):v.mutate(ae,_)}const qe=[{key:"employee_name",header:"Employee",render:U=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[13px] font-medium text-slate-900",children:U.employee_name}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:U.employee_code})]})},{key:"contract_number",header:"Contract No.",render:U=>e.jsxs("div",{children:[e.jsx("span",{className:"font-mono text-[12px] text-slate-700",children:U.contract_number||"—"}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:U.designation_name})]})},{key:"effective_date",header:"Effective From",render:U=>e.jsx("span",{className:"text-[13px] text-slate-600",children:U.effective_date?new Date(U.effective_date).toLocaleDateString("en-IN",{dateStyle:"medium"}):"—"})},{key:"status",header:"Status",render:U=>e.jsx(le,{variant:yl[U.status]??"secondary",className:"capitalize text-[11px]",children:U.status})},{key:"actions",header:"",className:"w-10",render:U=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[e.jsxs(B,{onClick:()=>K(U),children:[e.jsx(Sn,{className:"mr-2 h-3.5 w-3.5"})," View / Download PDF"]}),z&&U.status==="draft"&&e.jsxs(B,{onClick:()=>Z.mutate(U.id),children:[e.jsx(Kt,{className:"mr-2 h-3.5 w-3.5"})," Issue to Employee"]}),z&&U.status==="issued"&&e.jsxs(B,{onClick:()=>N(U),children:[e.jsx(Ia,{className:"mr-2 h-3.5 w-3.5"})," Record Acknowledgement"]}),z&&!U.is_locked&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{onClick:()=>O(U),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]})]}),G&&!U.is_locked&&e.jsxs(B,{className:"text-red-600",onClick:()=>u(U),children:[e.jsx(ft,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})}];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("p",{className:"text-[13px] text-slate-400",children:"Appointment letters issued on joining. Locked once the employee acknowledges."}),M&&e.jsxs(P,{size:"sm",onClick:A,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," New Contract"]})]}),e.jsx(st,{columns:qe,data:R,isLoading:Q,searchPlaceholder:"Search employees...",emptyMessage:"No service contracts",emptyDescription:"Raise a contract once a candidate has joined.",totalCount:(J==null?void 0:J.count)??0,pagination:ee,onPaginationChange:te,sorting:ie,onSortingChange:L,globalFilter:re,onGlobalFilterChange:ne}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"lg",className:"flex flex-col",children:[e.jsxs(Te,{children:[e.jsxs(Ve,{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-4 w-4 text-primary"}),a?"Edit Service Contract":"New Service Contract"]}),e.jsx(Ie,{children:"The contract number is generated on save, using the format in Recruitment Settings."})]}),e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto px-6 py-5",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Employee *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:I.watch("employee")||null,onValueChange:U=>I.setValue("employee",U,{shouldValidate:!0}),options:se.map(U=>({value:U.id,label:`${U.first_name} ${U.last_name}`.trim(),hint:U.employee_id})),selectedLabel:a==null?void 0:a.employee_name,placeholder:"Select employee",searchPlaceholder:"Search employees...",disabled:!!a})}),I.formState.errors.employee&&e.jsx("p",{className:"mt-1 text-[12px] text-red-500",children:I.formState.errors.employee.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Contract Template"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:I.watch("template")||null,onValueChange:U=>I.setValue("template",U||null),options:H.map(U=>({value:U.id,label:U.name,hint:U.code})),selectedLabel:a==null?void 0:a.template_name,placeholder:"Select template",searchPlaceholder:"Search templates..."})}),H.length===0&&e.jsx("p",{className:"mt-1 text-[11px] text-amber-600",children:"No Service Contract templates yet — create one under Recruitment → Offer Templates."})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Effective From"}),e.jsx(b,{type:"date",...I.register("effective_date"),className:"mt-1.5"}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-400",children:"Defaults to the date of joining."})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Probation (months)"}),e.jsx(b,{type:"number",...I.register("probation_months"),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Non-Solicitation (years)"}),e.jsx(b,{type:"number",...I.register("non_solicit_years"),className:"mt-1.5"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{children:"Notice — During Probation (days)"}),e.jsx(b,{type:"number",...I.register("notice_period_probation_days"),className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Notice — After Confirmation (days)"}),e.jsx(b,{type:"number",...I.register("notice_period_confirmed_days"),className:"mt-1.5"})]})]}),e.jsxs("div",{children:[e.jsx(o,{children:"Special Conditions"}),e.jsx(Ae,{...I.register("special_conditions"),className:"mt-1.5",rows:3})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:I.handleSubmit(T),disabled:v.isPending||S.isPending,children:a?"Save Changes":"Create Contract"})]})]})}),e.jsx(mt,{open:!!r,onOpenChange:U=>!U&&N(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Record acknowledgement?"}),e.jsxs(ht,{children:["Confirms ",r==null?void 0:r.employee_name," has signed and returned the contract. The terms are locked afterwards and can no longer be edited."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{onClick:()=>{r&&W.mutate(r.id),N(null)},children:"Confirm"})]})]})}),e.jsx(mt,{open:!!i,onOpenChange:U=>!U&&u(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Delete this contract?"}),e.jsxs(ht,{children:[i==null?void 0:i.contract_number," for ",i==null?void 0:i.employee_name," will be removed. This cannot be undone."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{className:"bg-red-600 hover:bg-red-700",onClick:()=>{i&&X.mutate(i.id),u(null)},children:"Delete"})]})]})}),e.jsx(bt,{open:!!y,onOpenChange:U=>!U&&_e(),children:e.jsxs(Ct,{className:"max-w-4xl",children:[e.jsx(St,{children:e.jsx(wt,{children:"Service Contract"})}),y&&e.jsx("iframe",{src:y,title:"Service contract",className:"h-[70vh] w-full rounded border"})]})})]})}const Za={pending:"warning",submitted:"default",reviewed:"success"};function ze({label:s,value:t}){return t?e.jsxs("div",{className:"grid grid-cols-2 gap-1 py-1.5 border-b border-slate-100 last:border-0",children:[e.jsx("span",{className:"text-[12px] text-slate-400 font-medium",children:s}),e.jsx("span",{className:"text-[12px] text-slate-700",children:t})]}):null}function Xt({title:s,children:t}){return e.jsxs("div",{className:"mb-5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-2",children:s}),e.jsx("div",{className:"rounded-lg border border-slate-100 bg-slate-50/50 px-4 py-1",children:t})]})}function bl({offerId:s}){const{data:t,isLoading:a}=Ga(s),n=Ha();return a?e.jsx("div",{className:"px-6 py-10 text-center text-slate-400 text-[13px]",children:"Loading form data…"}):t?e.jsxs("div",{className:"px-6 py-5 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(le,{variant:Za[t.status]??"secondary",className:"capitalize",children:t.status}),t.status==="submitted"&&e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>n.mutate(s),disabled:n.isPending,children:[e.jsx(It,{className:"h-3.5 w-3.5 mr-1.5"})," Mark Reviewed"]})]}),t.submitted_at&&e.jsxs("p",{className:"text-[11px] text-slate-400 mb-4",children:["Submitted on ",new Date(t.submitted_at).toLocaleDateString("en-IN",{dateStyle:"long"})]}),e.jsxs(Xt,{title:"Personal Information",children:[e.jsx(ze,{label:"Full Name",value:`${t.first_name} ${t.last_name}`.trim()||void 0}),e.jsx(ze,{label:"Date of Birth",value:t.date_of_birth?new Date(t.date_of_birth).toLocaleDateString("en-IN"):null}),e.jsx(ze,{label:"Gender",value:t.gender}),e.jsx(ze,{label:"Blood Group",value:t.blood_group}),e.jsx(ze,{label:"Marital Status",value:t.marital_status}),e.jsx(ze,{label:"Nationality",value:t.nationality}),e.jsx(ze,{label:"Personal Email",value:t.personal_email}),e.jsx(ze,{label:"Personal Phone",value:t.personal_phone})]}),e.jsxs(Xt,{title:"Address",children:[e.jsx(ze,{label:"Current Address",value:t.current_address}),!t.same_as_current&&e.jsx(ze,{label:"Permanent Address",value:t.permanent_address}),t.same_as_current&&e.jsx("div",{className:"py-1.5 text-[12px] text-slate-400 italic",children:"Permanent same as current"})]}),e.jsxs(Xt,{title:"Emergency Contact",children:[e.jsx(ze,{label:"Name",value:t.emergency_name}),e.jsx(ze,{label:"Relationship",value:t.emergency_relationship}),e.jsx(ze,{label:"Phone",value:t.emergency_phone})]}),e.jsxs(Xt,{title:"Bank Details",children:[e.jsx(ze,{label:"Bank Name",value:t.bank_name}),e.jsx(ze,{label:"Account Number",value:t.bank_account_number}),e.jsx(ze,{label:"IFSC Code",value:t.bank_ifsc}),e.jsx(ze,{label:"Account Type",value:t.bank_account_type}),e.jsx(ze,{label:"Branch",value:t.bank_branch})]}),e.jsxs(Xt,{title:"Identity",children:[e.jsx(ze,{label:"Aadhaar Number",value:t.aadhaar_number}),e.jsx(ze,{label:"PAN Number",value:t.pan_number}),e.jsx(ze,{label:"Passport Number",value:t.passport_number}),e.jsx(ze,{label:"Passport Expiry",value:t.passport_expiry?new Date(t.passport_expiry).toLocaleDateString("en-IN"):null})]}),t.education&&t.education.length>0&&e.jsxs("div",{className:"mb-5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-2",children:"Education"}),e.jsx("div",{className:"space-y-2",children:t.education.map((i,u)=>e.jsxs("div",{className:"rounded-lg border border-slate-100 bg-slate-50/50 px-4 py-2 text-[12px]",children:[e.jsxs("p",{className:"font-medium text-slate-700",children:[i.degree," — ",i.institution]}),e.jsxs("p",{className:"text-slate-400 mt-0.5",children:[i.year,i.percentage?` · ${i.percentage}%`:""]})]},u))})]}),t.previous_employment&&t.previous_employment.length>0&&e.jsxs("div",{className:"mb-5",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-2",children:"Previous Employment"}),e.jsx("div",{className:"space-y-2",children:t.previous_employment.map((i,u)=>e.jsxs("div",{className:"rounded-lg border border-slate-100 bg-slate-50/50 px-4 py-2 text-[12px]",children:[e.jsxs("p",{className:"font-medium text-slate-700",children:[i.designation," at ",i.company]}),e.jsxs("p",{className:"text-slate-400 mt-0.5",children:[i.from_date," – ",i.to_date,i.salary?` · ₹${i.salary}`:""]}),i.reason&&e.jsxs("p",{className:"text-slate-400 mt-0.5",children:["Reason: ",i.reason]})]},u))})]})]}):e.jsx("div",{className:"px-6 py-10 text-center text-slate-400 text-[13px]",children:"No pre-joining form submitted yet."})}const va={pending:e.jsx(wn,{className:"h-3.5 w-3.5 text-slate-300"}),in_progress:e.jsx(ba,{className:"h-3.5 w-3.5 text-amber-500"}),completed:e.jsx(Ia,{className:"h-3.5 w-3.5 text-emerald-500"}),skipped:e.jsx(si,{className:"h-3.5 w-3.5 text-slate-400"})};function Cl({checklist:s}){const t=s.progress;return e.jsxs("div",{className:"px-6 py-5 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(le,{variant:s.status==="completed"?"success":"warning",className:"capitalize",children:s.status.replace(/_/g," ")}),e.jsxs("span",{className:"text-[13px] font-semibold text-primary",children:[t.percent,"%"]})]}),e.jsx(ka,{value:t.percent,className:"h-2 mb-4"}),e.jsxs("p",{className:"text-[12px] text-slate-400 mb-5",children:[t.completed," of ",t.total," tasks completed"]}),e.jsxs("div",{className:"space-y-2",children:[s.items.map(a=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-slate-100 bg-slate-50/50 px-4 py-3",children:[e.jsx("div",{className:"mt-0.5",children:va[a.status]??va.pending}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:`text-[13px] font-medium ${a.status==="completed"?"text-slate-400 line-through":"text-slate-800"}`,children:a.task_name}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-[11px] text-slate-400",children:[e.jsx("span",{className:"capitalize",children:a.assigned_role}),e.jsxs("span",{children:["Due: ",new Date(a.due_date).toLocaleDateString("en-IN",{dateStyle:"medium"})]}),a.completed_at&&e.jsxs("span",{className:"text-emerald-600",children:["Done ",new Date(a.completed_at).toLocaleDateString("en-IN",{dateStyle:"medium"})]})]})]}),e.jsx(le,{variant:a.status==="completed"?"success":a.status==="in_progress"?"warning":"secondary",className:"capitalize text-[10px] shrink-0",children:a.status.replace(/_/g," ")})]},a.id)),s.items.length===0&&e.jsx("p",{className:"text-[13px] text-slate-400 text-center py-6",children:"No checklist tasks found."})]})]})}function jd(){const[s,t]=h.useState(null),[a,n]=h.useState(null),[i,u]=h.useState("accepted"),{pagination:r,setPagination:N,sorting:y,setSorting:m,globalFilter:V,setGlobalFilter:F,queryParams:M}=tt(),z={...M,status:i||"accepted"},{data:G,isLoading:ee}=Gs(z),te=(G==null?void 0:G.results)??[],{data:ie}=Kn({page_size:200}),L=(ie==null?void 0:ie.results)??[],re=new Map;for(const v of te){const S=L.find(X=>X.employee_name===v.candidate_name);S&&re.set(v.id,S)}const ne=Hs(),ce=Js(),J=te.find(v=>v.id===s)??null,Q=L.find(v=>v.id===a)??null,R=[{key:"candidate_name",header:"Candidate",render:v=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:v.candidate_name}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:v.candidate_email})]})},{key:"requisition_title",header:"Position",render:v=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[13px] text-slate-700",children:v.requisition_title}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:v.requisition_number})]})},{key:"joining_date_proposed",header:"Joining Date",render:v=>e.jsx("span",{className:"text-[13px] text-slate-600",children:v.joining_date_proposed?new Date(v.joining_date_proposed).toLocaleDateString("en-IN",{dateStyle:"medium"}):"—"})},{key:"pre_joining_status",header:"Pre-Joining Form",render:v=>{const S=v.pre_joining_status;return S?e.jsx(le,{variant:Za[S]??"secondary",className:"capitalize text-[11px]",children:S}):e.jsx("span",{className:"text-[12px] text-slate-400 italic",children:"Not sent"})}},{key:"onboarding_progress",header:"Onboarding Progress",render:v=>{const S=re.get(v.id);if(!S)return e.jsx("span",{className:"text-[12px] text-slate-400 italic",children:"Not started"});const X=S.progress;return e.jsxs("button",{onClick:()=>n(S.id),className:"w-full text-left group",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("span",{className:"text-[12px] font-medium text-slate-700 group-hover:text-primary",children:[X.percent,"%"]}),e.jsxs("span",{className:"text-[11px] text-slate-400",children:[X.completed,"/",X.total]})]}),e.jsx(ka,{value:X.percent,className:"h-1.5"})]})}},{key:"actions",header:"",className:"w-10",render:v=>{const S=v.pre_joining_status;return e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[(!S||S==="pending")&&e.jsxs(B,{onClick:()=>ne.mutate(v.id),children:[e.jsx(Kt,{className:"mr-2 h-3.5 w-3.5"}),S==="pending"?"Resend Pre-Joining Form":"Send Pre-Joining Form"]}),S&&S!=="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(B,{onClick:()=>t(v.id),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View Submitted Data"]}),e.jsx(We,{})]}),e.jsxs(B,{onClick:()=>ce.mutate(v.id),children:[e.jsx(Ks,{className:"mr-2 h-3.5 w-3.5"})," Send Joining Reminder"]}),re.get(v.id)&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{onClick:()=>n(re.get(v.id).id),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View Onboarding Checklist"]})]})]})]})}}];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(us,{className:"h-5 w-5 text-primary"})," Onboarding"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Manage pre-joining forms and onboarding for accepted candidates"})]})}),e.jsxs(Ca,{defaultValue:"pre-joining",children:[e.jsxs(Sa,{className:"mb-4",children:[e.jsx(ts,{value:"pre-joining",children:"Pre-Joining"}),e.jsx(ts,{value:"contracts",children:"Service Contracts"})]}),e.jsx(ss,{value:"contracts",children:e.jsx(Nl,{})}),e.jsx(ss,{value:"pre-joining",children:e.jsx(st,{actions:e.jsxs(Ce,{value:i,onValueChange:v=>{u(v),N(S=>({...S,pageIndex:0}))},children:[e.jsx(Se,{className:"w-[160px] h-9",children:e.jsx(we,{placeholder:"Filter status"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"accepted",children:"Accepted"}),e.jsx(q,{value:"sent",children:"Sent"}),e.jsx(q,{value:"viewed",children:"Viewed"})]})]}),columns:R,data:te,isLoading:ee,searchPlaceholder:"Search candidates...",emptyMessage:"No onboarding candidates",emptyDescription:"Accepted candidates will appear here for onboarding management.",totalCount:(G==null?void 0:G.count)??0,pagination:r,onPaginationChange:N,sorting:y,onSortingChange:m,globalFilter:V,onGlobalFilterChange:F})})]}),e.jsx(De,{open:!!s,onOpenChange:v=>!v&&t(null),children:e.jsxs(Ee,{size:"lg",children:[e.jsxs(Te,{children:[e.jsxs(Ve,{className:"flex items-center gap-2",children:[e.jsx(wa,{className:"h-4 w-4 text-slate-400"}),"Pre-Joining Form"]}),e.jsxs(Ie,{children:[J==null?void 0:J.candidate_name," — ",J==null?void 0:J.requisition_title]})]}),s&&e.jsx(bl,{offerId:s,onClose:()=>t(null)})]})}),e.jsx(De,{open:!!a,onOpenChange:v=>!v&&n(null),children:e.jsxs(Ee,{size:"lg",children:[e.jsxs(Te,{children:[e.jsxs(Ve,{className:"flex items-center gap-2",children:[e.jsx(us,{className:"h-4 w-4 text-primary"}),"Onboarding Checklist"]}),e.jsx(Ie,{children:Q==null?void 0:Q.employee_name})]}),Q&&e.jsx(Cl,{checklist:Q,onClose:()=>n(null)})]})})]})}const Sl={sent:"default",viewed:"default",accepted:"success",declined:"destructive",negotiating:"warning",expired:"secondary"};function wl(s){return s?new Date(s).toLocaleDateString("en-IN",{day:"2-digit",month:"short",year:"numeric"}):"—"}function Jt(s){return s?new Date(s).toLocaleString("en-IN",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"}):"—"}function kl({offerId:s}){const{data:t,isLoading:a}=Ja(s);return e.jsxs(Ct,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[e.jsx(St,{children:e.jsx(wt,{children:"Negotiation History"})}),a&&e.jsx("p",{className:"text-center text-slate-400 py-6 text-[13px]",children:"Loading…"}),!a&&(!t||t.length===0)&&e.jsx("p",{className:"text-center text-slate-400 py-6 text-[13px]",children:"No negotiation rounds."}),t&&t.length>0&&e.jsx("div",{className:"space-y-4",children:t.map(n=>e.jsxs("div",{className:"border border-slate-200 rounded-lg p-4 text-[13px]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"font-semibold text-slate-700",children:["Round ",n.round_number]}),e.jsx(le,{variant:n.status==="accepted"?"success":n.status==="rejected"?"destructive":n.status==="countered"?"warning":"secondary",className:"capitalize text-[11px]",children:n.status.replace(/_/g," ")})]}),n.candidate_counter&&e.jsxs("div",{className:"bg-blue-50 rounded p-2 mb-2",children:[e.jsx("p",{className:"text-[11px] font-medium text-blue-600 mb-1",children:"Candidate Request"}),n.candidate_counter.ctc&&e.jsxs("p",{className:"text-slate-700",children:["CTC: ₹",n.candidate_counter.ctc]}),n.candidate_counter.joining_date&&e.jsxs("p",{className:"text-slate-700",children:["Joining: ",n.candidate_counter.joining_date]}),n.candidate_counter.other&&e.jsxs("p",{className:"text-slate-700",children:["Other: ",n.candidate_counter.other]})]}),n.company_response&&Object.keys(n.company_response).length>0&&e.jsxs("div",{className:"bg-green-50 rounded p-2 mb-2",children:[e.jsx("p",{className:"text-[11px] font-medium text-green-600 mb-1",children:"Company Response"}),n.company_response.ctc&&e.jsxs("p",{className:"text-slate-700",children:["CTC: ₹",n.company_response.ctc]}),n.company_response.joining_date&&e.jsxs("p",{className:"text-slate-700",children:["Joining: ",n.company_response.joining_date]}),n.company_response.notes&&e.jsxs("p",{className:"text-slate-700",children:["Notes: ",n.company_response.notes]})]}),n.handled_by_name&&e.jsxs("p",{className:"text-[11px] text-slate-400",children:["Handled by: ",n.handled_by_name]})]},n.id))})]})}function ql({offerId:s}){const{data:t,isLoading:a}=Ga(s),n=Ha(),i={pending:"warning",submitted:"default",reviewed:"success"};return a?e.jsx("div",{className:"px-6 py-10 text-center text-slate-400 text-[13px]",children:"Loading…"}):t?e.jsxs("div",{className:"px-6 py-5 overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx(le,{variant:i[t.status]??"secondary",className:"capitalize",children:t.status}),t.status==="submitted"&&e.jsxs(P,{size:"sm",variant:"outline",onClick:()=>n.mutate(s),disabled:n.isPending,children:[e.jsx(It,{className:"h-3.5 w-3.5 mr-1.5"})," Mark Reviewed"]})]}),t.submitted_at&&e.jsxs("p",{className:"text-[11px] text-slate-400 mb-4",children:["Submitted ",Jt(t.submitted_at)]}),e.jsx("div",{className:"space-y-3 text-[12px]",children:[["Name",`${t.first_name} ${t.last_name}`.trim()],["DOB",t.date_of_birth?wl(t.date_of_birth):""],["Gender",t.gender],["Blood Group",t.blood_group],["Marital Status",t.marital_status],["Nationality",t.nationality],["Email",t.personal_email],["Phone",t.personal_phone],["Current Address",t.current_address],["Permanent Address",t.same_as_current?"Same as current":t.permanent_address],["Emergency",`${t.emergency_name} (${t.emergency_relationship}) — ${t.emergency_phone}`],["Bank",`${t.bank_name} — ****${(t.bank_account_number||"").slice(-4)} — ${t.bank_ifsc}`],["Aadhaar",t.aadhaar_number],["PAN",t.pan_number]].filter(([,u])=>u).map(([u,r])=>e.jsxs("div",{className:"grid grid-cols-3 gap-1 py-1 border-b border-slate-100",children:[e.jsx("span",{className:"text-slate-400 font-medium",children:u}),e.jsx("span",{className:"col-span-2 text-slate-700",children:r})]},u))})]}):e.jsx("div",{className:"px-6 py-10 text-center text-slate-400 text-[13px]",children:"No pre-joining form submitted yet."})}function Fl({offerId:s,candidateName:t,onClose:a}){const n=Ba(),i=Ye({defaultValues:{first_name:"",last_name:"",date_of_birth:"",gender:"",blood_group:"",marital_status:"",nationality:"Indian",personal_email:"",personal_phone:"",current_address:"",permanent_address:"",same_as_current:!1,emergency_name:"",emergency_relationship:"",emergency_phone:"",bank_name:"",bank_account_number:"",bank_ifsc:"",bank_account_type:"savings",bank_branch:"",aadhaar_number:"",pan_number:"",passport_number:"",passport_expiry:""}});function u(r){n.mutate({id:s,...r},{onSuccess:()=>a()})}return e.jsxs(e.Fragment,{children:[e.jsxs("form",{onSubmit:i.handleSubmit(u),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{className:"bg-blue-50 border border-blue-100 rounded-lg p-3 text-[13px] text-blue-800",children:["Filling pre-joining form on behalf of ",e.jsx("strong",{children:t}),". This will create the employee record and start onboarding."]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Personal Information"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"First Name *"}),e.jsx(b,{...i.register("first_name",{required:!0}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Last Name *"}),e.jsx(b,{...i.register("last_name",{required:!0}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Date of Birth"}),e.jsx(b,{type:"date",...i.register("date_of_birth"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Gender"}),e.jsxs(Ce,{value:i.watch("gender"),onValueChange:r=>i.setValue("gender",r),children:[e.jsx(Se,{className:"mt-1",children:e.jsx(we,{placeholder:"Select"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"male",children:"Male"}),e.jsx(q,{value:"female",children:"Female"}),e.jsx(q,{value:"other",children:"Other"})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Blood Group"}),e.jsx(b,{...i.register("blood_group"),className:"mt-1",placeholder:"e.g. O+"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Marital Status"}),e.jsxs(Ce,{value:i.watch("marital_status"),onValueChange:r=>i.setValue("marital_status",r),children:[e.jsx(Se,{className:"mt-1",children:e.jsx(we,{placeholder:"Select"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"single",children:"Single"}),e.jsx(q,{value:"married",children:"Married"}),e.jsx(q,{value:"divorced",children:"Divorced"}),e.jsx(q,{value:"widowed",children:"Widowed"})]})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Nationality"}),e.jsx(b,{...i.register("nationality"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Personal Email"}),e.jsx(b,{type:"email",...i.register("personal_email"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Personal Phone"}),e.jsx($t,{...i.register("personal_phone"),className:"mt-1"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Address"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Current Address"}),e.jsx(b,{...i.register("current_address"),className:"mt-1",placeholder:"Line 1, City, State, PIN"})]}),e.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-slate-600",children:[e.jsx("input",{type:"checkbox",...i.register("same_as_current"),className:"rounded"})," Permanent address same as current"]}),!i.watch("same_as_current")&&e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Permanent Address"}),e.jsx(b,{...i.register("permanent_address"),className:"mt-1"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Emergency Contact"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Name"}),e.jsx(b,{...i.register("emergency_name"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Relationship"}),e.jsx(b,{...i.register("emergency_relationship"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Phone"}),e.jsx($t,{...i.register("emergency_phone"),className:"mt-1"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Bank Details"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Bank Name"}),e.jsx(b,{...i.register("bank_name"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Account Number"}),e.jsx($t,{...i.register("bank_account_number"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"IFSC Code"}),e.jsx(b,{...i.register("bank_ifsc"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Branch"}),e.jsx(b,{...i.register("bank_branch"),className:"mt-1"})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-widest text-slate-400 mb-3",children:"Identity Documents"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Aadhaar Number"}),e.jsx($t,{...i.register("aadhaar_number"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"PAN Number"}),e.jsx(b,{...i.register("pan_number"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Passport Number"}),e.jsx(b,{...i.register("passport_number"),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] text-slate-500",children:"Passport Expiry"}),e.jsx(b,{type:"date",...i.register("passport_expiry"),className:"mt-1"})]})]})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:a,children:"Cancel"}),e.jsxs(P,{onClick:i.handleSubmit(u),disabled:n.isPending,children:[e.jsx(Wt,{className:"h-3.5 w-3.5 mr-1.5"}),n.isPending?"Submitting…":"Submit & Onboard"]})]})]})}function gd(){const[s,t]=h.useState("all"),[a,n]=h.useState(null),[i,u]=h.useState(null),[r,N]=h.useState(null),[y,m]=h.useState(null),{pagination:V,setPagination:F,sorting:M,setSorting:z,globalFilter:G,setGlobalFilter:ee,queryParams:te}=tt(),ie={...te,response:s},{data:L,isLoading:re}=gr(ie),ne=(L==null?void 0:L.results)??[],ce=Hs(),J=Js(),Q=Ua(),R=[{key:"offer_number",header:"Offer",render:v=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:v.offer_number})},{key:"candidate_name",header:"Candidate",render:v=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:v.candidate_name}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:v.candidate_email})]})},{key:"requisition_title",header:"Position",render:v=>e.jsxs("div",{children:[e.jsx("span",{className:"text-[13px] text-slate-700",children:v.requisition_title}),e.jsx("span",{className:"block text-[11px] text-slate-400",children:v.requisition_number})]})},{key:"status",header:"Response",render:v=>e.jsxs("div",{children:[e.jsx(le,{variant:Sl[v.status]??"secondary",className:"capitalize text-[11px]",children:v.status==="sent"?"Awaiting":v.status==="viewed"?"Viewed":v.status.replace(/_/g," ")}),v.status==="negotiating"&&v.negotiation_count>0&&e.jsxs("span",{className:"ml-1.5 text-[11px] text-amber-600 font-medium",children:[v.negotiation_count," round",v.negotiation_count>1?"s":""]})]})},{key:"response_time",header:"Response Time",render:v=>v.accepted_at?e.jsx("span",{className:"text-[12px] text-green-600",children:Jt(v.accepted_at)}):v.declined_at?e.jsx("span",{className:"text-[12px] text-red-500",children:Jt(v.declined_at)}):v.viewed_at?e.jsxs("span",{className:"text-[12px] text-slate-500",children:["Viewed ",Jt(v.viewed_at)]}):e.jsxs("span",{className:"text-[12px] text-slate-400",children:["Sent ",Jt(v.sent_at)]})},{key:"pre_joining_status",header:"Pre-Joining",render:v=>{if(!v.pre_joining_status)return e.jsx("span",{className:"text-[11px] text-slate-400",children:"—"});const S={pending:"warning",submitted:"default",reviewed:"success"};return e.jsx(le,{variant:S[v.pre_joining_status]??"secondary",className:"capitalize text-[11px]",children:v.pre_joining_status})}},{key:"actions",header:"",className:"w-10",render:v=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[["sent","viewed","expired"].includes(v.status)&&e.jsxs(B,{onClick:()=>Q.mutate(v.id),children:[e.jsx(Oa,{className:"mr-2 h-3.5 w-3.5"})," Resend Offer"]}),v.status==="declined"&&v.decline_reason&&e.jsxs(B,{onClick:()=>N(v),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View Decline Reason"]}),v.status==="negotiating"&&e.jsxs(B,{onClick:()=>n(v.id),children:[e.jsx(Yn,{className:"mr-2 h-3.5 w-3.5"})," View Negotiations"]}),v.status==="accepted"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),(!v.pre_joining_status||v.pre_joining_status==="pending")&&e.jsxs(e.Fragment,{children:[e.jsxs(B,{onClick:()=>m(v),children:[e.jsx(Wt,{className:"mr-2 h-3.5 w-3.5"})," Fill Pre-Joining (Admin)"]}),e.jsxs(B,{onClick:()=>ce.mutate(v.id),children:[e.jsx(Os,{className:"mr-2 h-3.5 w-3.5"}),v.pre_joining_status==="pending"?"Resend to Candidate":"Send to Candidate"]})]}),v.pre_joining_status&&v.pre_joining_status!=="pending"&&e.jsxs(B,{onClick:()=>u(v.id),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View Pre-Joining Data"]}),e.jsxs(B,{onClick:()=>J.mutate(v.id),children:[e.jsx(Ks,{className:"mr-2 h-3.5 w-3.5"})," Send Joining Reminder"]})]})]})]})}];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(ti,{className:"h-5 w-5 text-primary"})," Candidate Responses"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Track and manage candidate responses to sent offers"})]})}),e.jsx(st,{actions:e.jsxs(Ce,{value:s,onValueChange:v=>{t(v),F(S=>({...S,pageIndex:0}))},children:[e.jsx(Se,{className:"w-[170px] h-9",children:e.jsx(we,{placeholder:"Filter response"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"all",children:"All Responses"}),e.jsx(q,{value:"pending",children:"Awaiting Response"}),e.jsx(q,{value:"accepted",children:"Accepted"}),e.jsx(q,{value:"declined",children:"Declined"}),e.jsx(q,{value:"negotiating",children:"Negotiating"}),e.jsx(q,{value:"expired",children:"Expired"})]})]}),columns:R,data:ne,isLoading:re,searchPlaceholder:"Search offers...",emptyMessage:"No candidate responses",emptyDescription:"Offers sent to candidates will appear here with their responses.",totalCount:(L==null?void 0:L.count)??0,pagination:V,onPaginationChange:F,sorting:M,onSortingChange:z,globalFilter:G,onGlobalFilterChange:ee}),e.jsx(bt,{open:!!r,onOpenChange:v=>!v&&N(null),children:e.jsxs(Ct,{className:"max-w-md",children:[e.jsx(St,{children:e.jsxs(wt,{children:["Decline Reason — ",r==null?void 0:r.offer_number]})}),e.jsxs("div",{className:"text-[13px] space-y-3",children:[e.jsxs("div",{className:"bg-slate-50 rounded-lg p-3",children:[e.jsx("p",{className:"text-[11px] text-slate-400 font-medium",children:"Candidate"}),e.jsx("p",{className:"font-semibold text-slate-800",children:r==null?void 0:r.candidate_name})]}),e.jsxs("div",{className:"bg-red-50 border border-red-100 rounded-lg p-3",children:[e.jsx("p",{className:"text-[11px] font-semibold text-red-600 mb-1",children:"Reason for Declining"}),e.jsx("p",{className:"text-red-800",children:(r==null?void 0:r.decline_reason)||"No reason provided."})]}),e.jsxs("p",{className:"text-[12px] text-slate-400",children:["Declined on ",Jt((r==null?void 0:r.declined_at)??null)]})]})]})}),e.jsx(bt,{open:!!a,onOpenChange:v=>!v&&n(null),children:a&&e.jsx(kl,{offerId:a})}),e.jsx(De,{open:!!i,onOpenChange:v=>!v&&u(null),children:e.jsxs(Ee,{size:"lg",children:[e.jsxs(Te,{children:[e.jsxs(Ve,{className:"flex items-center gap-2",children:[e.jsx(wa,{className:"h-4 w-4 text-slate-400"})," Pre-Joining Form"]}),e.jsx(Ie,{children:"Submitted candidate data"})]}),i&&e.jsx(ql,{offerId:i})]})}),e.jsx(De,{open:!!y,onOpenChange:v=>!v&&m(null),children:e.jsxs(Ee,{size:"xl",children:[e.jsxs(Te,{children:[e.jsxs(Ve,{className:"flex items-center gap-2",children:[e.jsx(Wt,{className:"h-4 w-4 text-primary"})," Fill Pre-Joining Form (Admin)"]}),e.jsxs(Ie,{children:[y==null?void 0:y.candidate_name," — ",y==null?void 0:y.requisition_title]})]}),y&&e.jsx(Fl,{offerId:y.id,candidateName:y.candidate_name,onClose:()=>m(null)})]})})]})}const Pl=ct({requisition:C().min(1,"Requisition is required"),annual_ctc:C().optional(),placement_consultant_cost:C().optional(),training_cost:C().optional(),other_costs:C().optional(),other_costs_description:C().optional(),negative_impact:C().optional(),financial_benefits:C().optional(),non_financial_benefits:C().optional(),remarks:C().optional()}),ya={draft:"default",submitted:"warning",approved:"success",rejected:"destructive"};function Mt(s){const t=Number(s);return isNaN(t)?"—":`₹${t.toLocaleString("en-IN")}`}function fd(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),[r,N]=h.useState(null),[y,m]=h.useState(null),[V,F]=h.useState(""),{hasPermission:M,requirePermission:z}=et(),G=M("recruitment","cost_confirmation","create"),ee=M("recruitment","cost_confirmation","update"),te=M("recruitment","cost_confirmation","delete"),{pagination:ie,setPagination:L,sorting:re,setSorting:ne,globalFilter:ce,setGlobalFilter:J,queryParams:Q}=tt(),{data:R,isLoading:v}=fi(Q),S=(R==null?void 0:R.results)??[],{data:X}=_i((r==null?void 0:r.id)??""),{data:Z}=zs({page_size:200}),W=(Z==null?void 0:Z.results)??[],de=new Set(S.map(_=>_.requisition)),w=W.filter(_=>!de.has(_.id)),se=vi(),D=yi(),H=Ni(),I=bi(),A=Ci(),O=Ye({resolver:nt(Pl),defaultValues:{requisition:"",annual_ctc:"0",placement_consultant_cost:"0",training_cost:"0",other_costs:"0",other_costs_description:"",negative_impact:"",financial_benefits:"",non_financial_benefits:"",remarks:""}});function K(){z("recruitment","cost_confirmation","create")&&(n(null),O.reset({requisition:"",annual_ctc:"0",placement_consultant_cost:"0",training_cost:"0",other_costs:"0",other_costs_description:"",negative_impact:"",financial_benefits:"",non_financial_benefits:"",remarks:""}),t(!0))}function _e(_){z("recruitment","cost_confirmation","update")&&(n(_),O.reset({requisition:_.requisition,annual_ctc:_.annual_ctc,placement_consultant_cost:_.placement_consultant_cost,training_cost:_.training_cost,other_costs:_.other_costs,other_costs_description:_.other_costs_description,negative_impact:_.negative_impact,financial_benefits:_.financial_benefits,non_financial_benefits:_.non_financial_benefits,remarks:_.remarks}),t(!0))}function T(_){const ue=_;a?D.mutate({id:a.id,...ue},{onSuccess:()=>t(!1)}):se.mutate(ue,{onSuccess:()=>t(!1)})}function qe(){i&&H.mutate(i.id,{onSuccess:()=>u(null)})}function U(){y&&A.mutate({id:y.item.id,action:y.action,remarks:V},{onSuccess:()=>{m(null),F("")}})}const ae=[{key:"requisition_number",header:"Requisition",render:_=>e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:_.requisition_number}),e.jsx("p",{className:"text-[11px] text-slate-400 truncate max-w-[200px]",children:_.requisition_title})]})},{key:"annual_ctc",header:"Annual CTC",render:_=>e.jsx("span",{className:"text-[13px] font-medium",children:Mt(_.annual_ctc)})},{key:"total_cost",header:"Total Cost",render:_=>e.jsx("span",{className:"text-[13px] font-semibold text-primary",children:Mt(_.total_cost)})},{key:"status",header:"Status",render:_=>e.jsx(le,{variant:ya[_.status]??"default",className:"text-[11px] capitalize",children:_.status.replace("_"," ")})},{key:"approved_by_name",header:"Approved By",render:_=>e.jsx("span",{className:"text-[12px] text-slate-500",children:_.approved_by_name||"—"})},{key:"created_at",header:"Created",render:_=>e.jsx("span",{className:"text-[12px] text-slate-500",children:new Date(_.created_at).toLocaleDateString()})},{key:"actions",header:"",className:"w-10",render:_=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[e.jsxs(B,{onClick:()=>N(_),children:[e.jsx(Et,{className:"mr-2 h-3.5 w-3.5"})," View"]}),ee&&_.status==="draft"&&e.jsxs(e.Fragment,{children:[e.jsxs(B,{onClick:()=>_e(_),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),e.jsxs(B,{onClick:()=>I.mutate(_.id),children:[e.jsx(Kt,{className:"mr-2 h-3.5 w-3.5"})," Submit"]})]}),ee&&_.status==="submitted"&&e.jsxs(e.Fragment,{children:[e.jsxs(B,{onClick:()=>{m({item:_,action:"approve"}),F("")},children:[e.jsx(It,{className:"mr-2 h-3.5 w-3.5 text-green-600"})," Approve"]}),e.jsxs(B,{onClick:()=>{m({item:_,action:"reject"}),F("")},children:[e.jsx(cs,{className:"mr-2 h-3.5 w-3.5 text-red-600"})," Reject"]})]}),te&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{className:"text-red-600",onClick:()=>u(_),children:[e.jsx(ft,{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(qa,{className:"h-5 w-5 text-primary"})," Cost Confirmations"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Manage cost justifications for job requisitions"})]}),G&&e.jsxs(P,{size:"sm",onClick:K,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Add Cost Confirmation"]})]}),e.jsx(st,{columns:ae,data:S,isLoading:v,searchPlaceholder:"Search by requisition...",emptyMessage:"No cost confirmations",emptyDescription:"Create a cost confirmation for a requisition to track hiring costs.",totalCount:(R==null?void 0:R.count)??0,pagination:ie,onPaginationChange:L,sorting:re,onSortingChange:ne,globalFilter:ce,onGlobalFilterChange:J}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"lg",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Cost Confirmation":"Add Cost Confirmation"}),e.jsx(Ie,{children:a?"Update cost details for this requisition.":"Enter cost justification for a requisition."})]}),e.jsxs("form",{onSubmit:O.handleSubmit(T),className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Requisition *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:O.watch("requisition")??null,onValueChange:_=>O.setValue("requisition",_,{shouldValidate:!0}),disabled:!!a,options:(a?W:w).map(_=>({value:_.id,label:`${_.requisition_number} — ${_.title}`})),selectedLabel:a?`${a.requisition_number} — ${a.requisition_title}`:void 0,placeholder:"Select requisition",searchPlaceholder:"Search requisitions..."})}),O.formState.errors.requisition&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:O.formState.errors.requisition.message})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Annual CTC (₹)"}),e.jsx(b,{...O.register("annual_ctc"),type:"number",step:"0.01",className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Placement Consultant Cost (₹)"}),e.jsx(b,{...O.register("placement_consultant_cost"),type:"number",step:"0.01",className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Training Cost (₹)"}),e.jsx(b,{...O.register("training_cost"),type:"number",step:"0.01",className:"mt-1.5"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Other Costs (₹)"}),e.jsx(b,{...O.register("other_costs"),type:"number",step:"0.01",className:"mt-1.5"})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Other Costs Description"}),e.jsx(Ae,{...O.register("other_costs_description"),className:"mt-1.5",rows:2,placeholder:"Describe other costs..."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Negative Impact if Not Filled"}),e.jsx(Ae,{...O.register("negative_impact"),className:"mt-1.5",rows:2,placeholder:"What happens if this position is not filled?"})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Financial Benefits"}),e.jsx(Ae,{...O.register("financial_benefits"),className:"mt-1.5",rows:2,placeholder:"Expected financial benefits..."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Non-Financial Benefits"}),e.jsx(Ae,{...O.register("non_financial_benefits"),className:"mt-1.5",rows:2,placeholder:"Expected non-financial benefits..."})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Remarks"}),e.jsx(Ae,{...O.register("remarks"),className:"mt-1.5",rows:2,placeholder:"Any additional remarks..."})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:O.handleSubmit(T),disabled:se.isPending||D.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(bt,{open:!!r,onOpenChange:_=>!_&&N(null),children:e.jsxs(Ct,{className:"max-w-lg",children:[e.jsx(St,{children:e.jsxs(wt,{children:["Cost Confirmation — ",r==null?void 0:r.requisition_number]})}),r&&(()=>{const _=X??r;return e.jsxs("div",{className:"space-y-3 text-[13px]",children:[e.jsx("p",{className:"text-slate-500",children:_.requisition_title}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 bg-slate-50 rounded-lg p-4",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Annual CTC"}),e.jsx("p",{className:"font-medium",children:Mt(_.annual_ctc)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Consultant Cost"}),e.jsx("p",{className:"font-medium",children:Mt(_.placement_consultant_cost)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Training Cost"}),e.jsx("p",{className:"font-medium",children:Mt(_.training_cost)})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Other Costs"}),e.jsx("p",{className:"font-medium",children:Mt(_.other_costs)})]}),e.jsxs("div",{className:"col-span-2 border-t pt-2",children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Total Cost"}),e.jsx("p",{className:"font-semibold text-primary text-[15px]",children:Mt(_.total_cost)})]})]}),_.other_costs_description&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Other Costs Description"}),e.jsx("p",{className:"whitespace-pre-wrap",children:_.other_costs_description})]}),_.negative_impact&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Negative Impact if Not Filled"}),e.jsx("p",{className:"whitespace-pre-wrap",children:_.negative_impact})]}),_.financial_benefits&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Financial Benefits"}),e.jsx("p",{className:"whitespace-pre-wrap",children:_.financial_benefits})]}),_.non_financial_benefits&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Non-Financial Benefits"}),e.jsx("p",{className:"whitespace-pre-wrap",children:_.non_financial_benefits})]}),_.remarks&&e.jsxs("div",{children:[e.jsx("span",{className:"text-slate-400 text-[11px]",children:"Remarks"}),e.jsx("p",{className:"whitespace-pre-wrap",children:_.remarks})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsx(le,{variant:ya[_.status]??"default",className:"capitalize",children:_.status}),_.approved_by_name&&e.jsxs("span",{className:"text-[12px] text-slate-500",children:["Approved by ",_.approved_by_name,_.approved_at?` on ${new Date(_.approved_at).toLocaleDateString()}`:""]})]})]})})(),e.jsx(Yt,{children:e.jsx(P,{variant:"outline",onClick:()=>N(null),children:"Close"})})]})}),e.jsx(mt,{open:!!y,onOpenChange:_=>!_&&m(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsxs(pt,{children:[(y==null?void 0:y.action)==="approve"?"Approve":"Reject"," cost confirmation?"]}),e.jsx(ht,{children:(y==null?void 0:y.action)==="approve"?`Approve cost confirmation for ${y==null?void 0:y.item.requisition_number}?`:`Reject cost confirmation for ${y==null?void 0:y.item.requisition_number}?`})]}),e.jsxs("div",{className:"px-6 pb-2",children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Remarks (optional)"}),e.jsx(Ae,{value:V,onChange:_=>F(_.target.value),className:"mt-1.5",rows:2,placeholder:"Add remarks..."})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:(y==null?void 0:y.action)==="reject"?"destructive":"default",onClick:U,disabled:A.isPending,children:(y==null?void 0:y.action)==="approve"?"Approve":"Reject"})]})]})}),e.jsx(mt,{open:!!i,onOpenChange:_=>!_&&u(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Delete cost confirmation?"}),e.jsxs(ht,{children:["This will permanently delete the cost confirmation for ",e.jsx("strong",{children:i==null?void 0:i.requisition_number}),"."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:"destructive",onClick:qe,children:"Delete"})]})]})})]})}function $l({candidateId:s,candidateName:t}){const{data:a,isLoading:n}=Lr(s),{hasPermission:i}=et(),u=i("recruitment","assessment","create"),r=h.useMemo(()=>(a==null?void 0:a.results)??[],[a]),[N,y]=h.useState(!1),[m,V]=h.useState(null);return n?e.jsx("div",{className:"space-y-4",children:[1,2].map(F=>e.jsx("div",{className:"h-32 rounded-lg bg-slate-100 animate-pulse"},F))}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h2",{className:"text-base font-semibold text-slate-900",children:["Assessments (",r.length,")"]}),u&&e.jsxs(P,{size:"sm",className:"gap-1.5",onClick:()=>y(!0),children:[e.jsx(Ue,{className:"h-4 w-4"})," New Assessment"]})]}),r.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-slate-300 bg-white p-12 text-center",children:[e.jsx(Al,{className:"mx-auto h-10 w-10 text-slate-300"}),e.jsx("p",{className:"mt-3 text-sm font-medium text-slate-600",children:"No assessments yet"}),e.jsx("p",{className:"mt-1 text-xs text-slate-400",children:u?"Start by creating a new assessment for this candidate.":"No assessments have been recorded for this candidate."})]}):e.jsx("div",{className:"space-y-3",children:r.map(F=>e.jsx(Rl,{assessment:F,expanded:m===F.id,onToggle:()=>V(m===F.id?null:F.id),candidateId:s,canEdit:u},F.id))}),N&&e.jsx(El,{candidateId:s,candidateName:t,onClose:()=>y(!1)})]})}function Al({className:s}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,className:s,children:[e.jsx("path",{d:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"}),e.jsx("rect",{x:"9",y:"3",width:"6",height:"4",rx:"1"}),e.jsx("path",{d:"m9 14 2 2 4-4"})]})}function Rl({assessment:s,expanded:t,onToggle:a,candidateId:n,canEdit:i}){const u=zr(),r=Mr(),N=Ya(),y=s.status==="submitted";return e.jsxs(Ft,{className:y?"opacity-90":"",children:[e.jsxs(Tt,{className:"cursor-pointer pb-3",onClick:a,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Vt,{className:"text-sm font-medium",children:s.template_name}),e.jsx(le,{variant:y?"default":"secondary",children:s.status}),s.final_score!==null&&e.jsxs(le,{variant:"outline",className:"font-mono",children:["Score: ",s.final_score]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-slate-400",children:s.date}),t?e.jsx(Rs,{className:"h-4 w-4 text-slate-400"}):e.jsx(Ds,{className:"h-4 w-4 text-slate-400"})]})]}),e.jsxs("p",{className:"text-xs text-slate-400 mt-1",children:["By ",s.interviewer_name||"N/A",s.position_title&&e.jsxs(e.Fragment,{children:[" · ",s.position_title]}),s.remarks&&e.jsxs(e.Fragment,{children:[" · ",s.remarks]})]})]}),t&&s.ratings.length>0&&e.jsxs(Pt,{className:"pt-0",children:[e.jsx("div",{className:"rounded-lg border border-slate-100 bg-slate-50/50",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-200 text-xs text-slate-500",children:[e.jsx("th",{className:"py-2 px-3 text-left font-medium",children:"Domain"}),e.jsx("th",{className:"py-2 px-3 text-center font-medium w-20",children:"Weight"}),e.jsx("th",{className:"py-2 px-3 text-center font-medium w-24",children:"Rating"}),e.jsx("th",{className:"py-2 px-3 text-center font-medium w-28",children:"Weighted"}),e.jsx("th",{className:"py-2 px-3 text-left font-medium",children:"Comments"})]})}),e.jsx("tbody",{children:s.ratings.map(m=>e.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[e.jsx("td",{className:"py-2 px-3 text-slate-700",children:m.domain_name}),e.jsx("td",{className:"py-2 px-3 text-center text-slate-500",children:m.domain_weight}),e.jsx("td",{className:"py-2 px-3 text-center",children:e.jsx(Dl,{value:m.rating})}),e.jsx("td",{className:"py-2 px-3 text-center font-mono text-slate-600",children:m.weighted_score??"—"}),e.jsx("td",{className:"py-2 px-3 text-slate-500 text-xs",children:m.comments||"—"})]},m.id))})]})}),!y&&i&&e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsxs(P,{size:"sm",className:"gap-1",onClick:()=>u.mutate({id:s.id,candidateId:n}),children:[e.jsx(Kt,{className:"h-3.5 w-3.5"})," Submit"]}),e.jsxs(P,{size:"sm",variant:"destructive",className:"gap-1",onClick:()=>{confirm("Delete this assessment?")&&r.mutate({id:s.id,candidateId:n})},children:[e.jsx(ft,{className:"h-3.5 w-3.5"})," Delete"]}),e.jsxs(P,{size:"sm",variant:"outline",className:"gap-1",onClick:()=>N.mutate(s.id),children:[e.jsx(kt,{className:"h-3.5 w-3.5"})," PDF"]})]}),y&&e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-slate-400",children:[e.jsx(ps,{className:"h-3 w-3"})," This assessment is locked"]}),e.jsxs(P,{size:"sm",variant:"outline",className:"gap-1 ml-auto",onClick:()=>N.mutate(s.id),children:[e.jsx(kt,{className:"h-3.5 w-3.5"})," Download PDF"]})]})]})]})}function Dl({value:s}){return e.jsx("span",{className:"inline-flex gap-0.5",children:[1,2,3,4,5].map(t=>e.jsx(is,{className:`h-3.5 w-3.5 ${t<=s?"fill-amber-400 text-amber-400":"text-slate-200"}`},t))})}function El({candidateId:s,candidateName:t,onClose:a}){const[n,i]=h.useState(""),{data:u,isLoading:r}=Ws({search:n||void 0}),N=h.useMemo(()=>(u==null?void 0:u.results)??[],[u]),[y,m]=h.useState(""),{data:V}=$r(y),[F,M]=h.useState(new Date().toISOString().slice(0,10)),[z,G]=h.useState(""),[ee,te]=h.useState({}),ie=Kr(),L=h.useMemo(()=>{const Q=((V==null?void 0:V.domains)??[]).filter(R=>R.is_active);return Q.sort((R,v)=>R.order-v.order),Q},[V]),re=h.useCallback((Q,R)=>{te(v=>({...v,[Q]:{...v[Q]??{rating:0,comments:""},rating:R}}))},[]),ne=h.useCallback((Q,R)=>{te(v=>({...v,[Q]:{...v[Q]??{rating:0,comments:""},comments:R}}))},[]),ce=h.useMemo(()=>{var v;let Q=0,R=0;for(const S of L){const X=((v=ee[S.id])==null?void 0:v.rating)??0;X>0&&(Q+=Number(S.weight),R+=X*Number(S.weight))}return Q>0?(R/Q).toFixed(2):"—"},[L,ee]);function J(){if(!y)return;const Q=L.filter(R=>{var v;return(((v=ee[R.id])==null?void 0:v.rating)??0)>0}).map(R=>{const v=ee[R.id];return{domain:R.id,rating:(v==null?void 0:v.rating)??0,comments:(v==null?void 0:v.comments)??""}});ie.mutate({candidate:s,template:y,date:F,remarks:z,ratings:Q},{onSuccess:a})}return e.jsx(bt,{open:!0,onOpenChange:a,children:e.jsxs(Ct,{className:"max-w-2xl max-h-[85vh] flex flex-col",children:[e.jsx(St,{children:e.jsxs(wt,{children:["New Assessment — ",t]})}),e.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5 pr-1",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs font-medium text-slate-500",children:"Template"}),e.jsx(me,{value:y,onValueChange:m,onSearch:i,isLoading:r,options:N.map(Q=>({value:Q.id,label:`${Q.name} (v${Q.version})`})),placeholder:"Select template...",searchPlaceholder:"Search templates..."})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs font-medium text-slate-500",children:"Date"}),e.jsx(b,{type:"date",value:F,onChange:Q=>M(Q.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{className:"text-xs font-medium text-slate-500",children:"Remarks"}),e.jsx(b,{value:z,onChange:Q=>G(Q.target.value),placeholder:"Optional remarks..."})]})]}),L.length>0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx(ms,{}),e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Rate each domain (1–5)"}),L.map(Q=>{var R,v;return e.jsx(Tl,{domain:Q,value:((R=ee[Q.id])==null?void 0:R.rating)??0,comment:((v=ee[Q.id])==null?void 0:v.comments)??"",onRatingChange:S=>re(Q.id,S),onCommentChange:S=>ne(Q.id,S)},Q.id)}),e.jsxs("div",{className:"flex items-center justify-between rounded-lg bg-primary/5 border border-primary/10 px-4 py-3",children:[e.jsx("span",{className:"text-sm font-medium text-slate-700",children:"Final Score"}),e.jsx("span",{className:"text-lg font-semibold font-mono text-primary",children:ce})]})]}),y&&L.length===0&&e.jsx("div",{className:"rounded-lg border border-dashed border-slate-300 p-6 text-center text-sm text-slate-400",children:"This template has no active domains."})]}),e.jsxs(Yt,{className:"pt-4 border-t",children:[e.jsx(P,{variant:"outline",onClick:a,children:"Cancel"}),e.jsx(P,{onClick:J,disabled:!y||ie.isPending,children:ie.isPending?"Saving...":"Save Draft"})]})]})})}function Tl({domain:s,value:t,comment:a,onRatingChange:n,onCommentChange:i}){return e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-800",children:s.name}),s.description?e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:s.description}):null,e.jsxs("p",{className:"text-xs text-slate-400",children:["Weight: ",s.weight]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[[1,2,3,4,5].map(u=>e.jsx("button",{type:"button",className:"p-0.5 transition-transform hover:scale-110",onClick:()=>n(u),children:e.jsx(is,{className:`h-6 w-6 transition-colors ${u<=t?"fill-amber-400 text-amber-400":"text-slate-200 hover:text-amber-200"}`})},u)),t>0&&e.jsxs("span",{className:"ml-2 text-sm font-mono text-slate-600",children:[t,"/5"]})]})]}),e.jsx(Ae,{value:a,onChange:u=>i(u.target.value),placeholder:"Comments (optional)...",className:"text-xs min-h-[60px] resize-none"})]})}const Vl=[{value:"general",label:"General"},{value:"screening",label:"Screening"},{value:"interview",label:"Interview"},{value:"internal",label:"Internal"}],Ol=[{value:"all",label:"Everyone"},{value:"recruiters_only",label:"Recruiters only"},{value:"hiring_team",label:"Hiring team"}];function Ll({candidateId:s}){const{data:t,isLoading:a}=Cr(s),n=(t==null?void 0:t.results)??[],i=Sr(),u=wr(),[r,N]=h.useState(""),[y,m]=h.useState("general"),[V,F]=h.useState("all");function M(){const z=r.trim();z&&i.mutate({candidate:s,note_text:z,note_type:y,visibility:V},{onSuccess:()=>N("")})}return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white p-4 space-y-3",children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Add a note"}),e.jsx(Ae,{value:r,onChange:z=>N(z.target.value),rows:3,placeholder:"Write a note about this candidate..."}),e.jsxs("div",{className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[11px] text-slate-400",children:"Type"}),e.jsxs(Ce,{value:y,onValueChange:z=>m(z),children:[e.jsx(Se,{className:"mt-1 h-9 w-40",children:e.jsx(we,{})}),e.jsx(ke,{children:Vl.map(z=>e.jsx(q,{value:z.value,children:z.label},z.value))})]})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[11px] text-slate-400",children:"Visibility"}),e.jsxs(Ce,{value:V,onValueChange:z=>F(z),children:[e.jsx(Se,{className:"mt-1 h-9 w-44",children:e.jsx(we,{})}),e.jsx(ke,{children:Ol.map(z=>e.jsx(q,{value:z.value,children:z.label},z.value))})]})]}),e.jsxs(P,{size:"sm",onClick:M,disabled:!r.trim()||i.isPending,className:"ml-auto",children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Add Note"]})]})]}),a?e.jsx("div",{className:"h-20 rounded-lg bg-slate-50 animate-pulse"}):n.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-slate-200 bg-white p-8 text-center text-slate-400",children:[e.jsx(ai,{className:"mx-auto h-7 w-7 text-slate-300"}),e.jsx("p",{className:"mt-2 text-[13px]",children:"No notes yet."})]}):e.jsx("div",{className:"space-y-3",children:n.map(z=>e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white p-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(le,{variant:"secondary",className:"capitalize text-[10.5px]",children:z.note_type}),e.jsx("span",{className:"text-[12px] text-slate-500",children:z.created_by_name||"Unknown"}),e.jsx("span",{className:"text-[11px] text-slate-400",children:z.created_at?Zn(Xn(z.created_at),"dd MMM yyyy, HH:mm"):""})]}),e.jsx(P,{variant:"ghost",size:"icon-sm",className:"text-red-500",onClick:()=>u.mutate({id:z.id,candidateId:s}),children:e.jsx(ft,{className:"h-3.5 w-3.5"})})]}),e.jsx("p",{className:"mt-2 text-[13px] text-slate-700 whitespace-pre-wrap",children:z.note_text})]},z.id))})]})}function _d(){var r,N;const{id:s}=As(),t=hs(),{data:a,isLoading:n}=Ma(s),{hasPermission:i}=et(),u=i("recruitment","candidate","update");return n?e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"h-9 w-32 rounded bg-slate-200 animate-pulse"}),e.jsx("div",{className:"rounded-xl border border-slate-200 bg-white p-6",children:e.jsxs("div",{className:"flex items-start gap-5",children:[e.jsx("div",{className:"h-16 w-16 rounded-full bg-slate-200 animate-pulse"}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"h-6 w-64 rounded bg-slate-200 animate-pulse"}),e.jsx("div",{className:"h-4 w-48 rounded bg-slate-100 animate-pulse"})]})]})}),e.jsx("div",{className:"h-10 w-full rounded bg-slate-100 animate-pulse"})]}):a?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(xs,{to:"/recruitment/candidates",children:e.jsxs(P,{variant:"ghost",size:"sm",className:"gap-1.5 text-slate-600",children:[e.jsx(ei,{className:"h-4 w-4"})," Candidates"]})}),u&&e.jsxs(P,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>t(`/recruitment/candidates?edit=${a.id}`),children:[e.jsx(at,{className:"h-3.5 w-3.5"})," Edit"]})]}),e.jsx("div",{className:"rounded-xl border border-slate-200 bg-white p-6",children:e.jsxs("div",{className:"flex items-start gap-5",children:[e.jsxs("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-primary/10 text-primary text-xl font-semibold",children:[(r=a.first_name)==null?void 0:r[0],(N=a.last_name)==null?void 0:N[0]]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h1",{className:"text-xl font-semibold text-slate-900",children:a.full_name}),e.jsx("p",{className:"mt-0.5 text-sm text-slate-500",children:a.email}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-x-6 gap-y-1 text-sm text-slate-600",children:[a.phone&&e.jsx("span",{children:a.phone}),a.current_designation&&e.jsx("span",{children:a.current_designation}),a.current_company&&e.jsxs("span",{children:["@ ",a.current_company]}),a.total_experience_years&&e.jsxs("span",{children:[a.total_experience_years," yrs exp"]})]})]})]})}),e.jsxs(Ca,{defaultValue:"assessments",className:"w-full",children:[e.jsxs(Sa,{className:"w-full justify-start border-b rounded-none bg-transparent p-0 h-auto",children:[e.jsxs(ts,{value:"assessments",className:"gap-1.5 rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none px-4 py-3 text-sm",children:[e.jsx(Na,{className:"h-3.5 w-3.5"})," Assessments"]}),e.jsxs(ts,{value:"notes",className:"gap-1.5 rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none px-4 py-3 text-sm",children:[e.jsx(kt,{className:"h-3.5 w-3.5"})," Notes"]}),e.jsxs(ts,{value:"profile",className:"gap-1.5 rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:shadow-none px-4 py-3 text-sm",children:[e.jsx(kn,{className:"h-3.5 w-3.5"})," Profile"]})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx(ss,{value:"assessments",children:e.jsx($l,{candidateId:a.id,candidateName:a.full_name})}),e.jsx(ss,{value:"notes",children:e.jsx(Ll,{candidateId:a.id})}),e.jsx(ss,{value:"profile",children:e.jsxs("div",{className:"rounded-lg border border-slate-200 bg-white p-6 space-y-6 text-[13px]",children:[e.jsxs("section",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400 mb-3",children:"Personal"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(_t,{label:"Phone",value:a.phone}),e.jsx(_t,{label:"Alternate Phone",value:a.alternate_phone}),e.jsx(_t,{label:"Date of Birth",value:a.date_of_birth}),e.jsx(_t,{label:"Gender",value:a.gender}),e.jsx(_t,{label:"Location",value:a.current_location})]})]}),e.jsxs("section",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400 mb-3",children:"Professional"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(_t,{label:"Current / Previous Employer",value:a.current_company}),e.jsx(_t,{label:"Designation",value:a.current_designation}),e.jsx(_t,{label:"Total Experience",value:a.total_experience_years?`${a.total_experience_years} yrs`:""}),e.jsx(_t,{label:"Relevant Experience",value:a.relevant_experience_years?`${a.relevant_experience_years} yrs`:""}),e.jsx(_t,{label:"Notice Period",value:a.notice_period_days?`${a.notice_period_days} days`:""}),e.jsx(_t,{label:"Current CTC",value:a.current_ctc}),e.jsx(_t,{label:"Expected CTC",value:a.expected_ctc})]})]}),e.jsxs("section",{children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-400 mb-3",children:"Sourcing"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[e.jsx(_t,{label:"Source",value:a.source}),e.jsx(_t,{label:"Status",value:a.status}),e.jsx(_t,{label:"LinkedIn",value:a.linkedin_url,link:!0})]})]})]})})]})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-slate-500",children:[e.jsx("p",{className:"text-lg font-medium",children:"Candidate not found"}),e.jsx(xs,{to:"/recruitment/candidates",className:"mt-2 text-primary hover:underline",children:"Back to candidates"})]})}function _t({label:s,value:t,link:a}){const n=t||"—";return e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] text-slate-400",children:s}),a&&t?e.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"text-[13px] text-primary hover:underline break-all",children:t}):e.jsx("p",{className:"text-[13px] text-slate-800 break-words",children:n})]})}function vd(){const{data:s,isLoading:t}=Ws(),a=h.useMemo(()=>(s==null?void 0:s.results)??[],[s]),n=Ar(),i=Rr(),u=Dr(),[r,N]=h.useState(!1),[y,m]=h.useState(null),[V,F]=h.useState(null);return t?e.jsx("div",{className:"space-y-4",children:[1,2].map(M=>e.jsx("div",{className:"h-24 rounded-lg bg-slate-100 animate-pulse"},M))}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-slate-900",children:"Assessment Templates"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Manage assessment templates and their domains"})]}),e.jsxs(P,{size:"sm",className:"gap-1.5",onClick:()=>{m(null),N(!0)},children:[e.jsx(Ue,{className:"h-4 w-4"})," New Template"]})]}),a.length===0?e.jsxs("div",{className:"rounded-lg border border-dashed border-slate-300 bg-white p-12 text-center",children:[e.jsx("p",{className:"text-sm text-slate-500",children:"No assessment templates yet."}),e.jsx("p",{className:"mt-1 text-xs text-slate-400",children:"Create a template to define assessment domains and weights."})]}):e.jsx("div",{className:"space-y-3",children:a.map(M=>{var z;return e.jsxs(Ft,{children:[e.jsx(Tt,{className:"cursor-pointer pb-3",onClick:()=>F(V===M.id?null:M.id),children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Vt,{className:"text-sm font-medium",children:M.name}),e.jsx(le,{variant:M.is_active?"default":"secondary",children:M.is_active?"Active":"Inactive"}),e.jsxs(le,{variant:"outline",children:["v",M.version]}),M.position_level_name&&e.jsx(le,{variant:"outline",className:"text-blue-600 border-blue-200 bg-blue-50",children:M.position_level_name}),e.jsxs("span",{className:"text-xs text-slate-400",children:[M.domain_count??((z=M.domains)==null?void 0:z.length)??0," domains"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:G=>{G.stopPropagation(),m(M),N(!0)},children:e.jsx(at,{className:"h-3.5 w-3.5"})}),e.jsx(P,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 text-destructive",onClick:G=>{G.stopPropagation(),confirm("Delete this template?")&&u.mutate(M.id)},children:e.jsx(ft,{className:"h-3.5 w-3.5"})}),V===M.id?e.jsx(Rs,{className:"h-4 w-4 text-slate-400"}):e.jsx(Ds,{className:"h-4 w-4 text-slate-400"})]})]})}),V===M.id&&e.jsx(Pt,{className:"pt-0",children:e.jsx(Il,{templateId:M.id})})]},M.id)})}),r&&e.jsx(Kl,{template:y,onClose:()=>{N(!1),m(null)},onSubmit:M=>{y?i.mutate({id:y.id,...M},{onSuccess:()=>N(!1)}):n.mutate(M,{onSuccess:()=>N(!1)})}})]})}function Il({templateId:s}){const{data:t}=Er(s),a=Tr(),n=Vr(),i=Or(),u=h.useMemo(()=>((t==null?void 0:t.results)??[]).sort((V,F)=>V.order-F.order),[t]),[r,N]=h.useState(!1),[y,m]=h.useState(null);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider text-slate-400",children:"Domains"}),e.jsxs(P,{size:"sm",variant:"outline",className:"gap-1 h-7 text-xs",onClick:()=>{m(null),N(!0)},children:[e.jsx(Ue,{className:"h-3 w-3"})," Add Domain"]})]}),u.length===0?e.jsx("p",{className:"text-xs text-slate-400 py-2",children:"No domains. Add one above."}):e.jsxs(qn,{children:[e.jsx(Fn,{children:e.jsxs(ia,{children:[e.jsx(Gt,{className:"text-xs",children:"Order"}),e.jsx(Gt,{className:"text-xs",children:"Name"}),e.jsx(Gt,{className:"text-xs",children:"Description"}),e.jsx(Gt,{className:"text-xs text-center",children:"Weight"}),e.jsx(Gt,{className:"text-xs text-center",children:"Active"}),e.jsx(Gt,{className:"text-xs text-right",children:"Actions"})]})}),e.jsx(Pn,{children:u.map(V=>e.jsxs(ia,{children:[e.jsx(Ht,{className:"text-xs",children:V.order}),e.jsx(Ht,{className:"text-sm font-medium",children:V.name}),e.jsx(Ht,{className:"text-xs text-slate-500 max-w-[200px] truncate",children:V.description||"—"}),e.jsx(Ht,{className:"text-center font-mono text-xs",children:V.weight}),e.jsx(Ht,{className:"text-center",children:e.jsx(le,{variant:V.is_active?"default":"secondary",className:"text-[10px]",children:V.is_active?"Yes":"No"})}),e.jsxs(Ht,{className:"text-right",children:[e.jsx(P,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{m(V),N(!0)},children:e.jsx(at,{className:"h-3 w-3"})}),e.jsx(P,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-destructive",onClick:()=>{confirm("Delete domain?")&&i.mutate({id:V.id,templateId:s})},children:e.jsx(ft,{className:"h-3 w-3"})})]})]},V.id))})]}),r&&e.jsx(zl,{templateId:s,domain:y,onClose:()=>{N(!1),m(null)},onSubmit:V=>{y?n.mutate({id:y.id,...V},{onSuccess:()=>N(!1)}):a.mutate(V,{onSuccess:()=>N(!1)})}})]})}function Kl({template:s,onClose:t,onSubmit:a}){const[n,i]=h.useState((s==null?void 0:s.name)??""),[u,r]=h.useState((s==null?void 0:s.position_level)??null),[N,y]=h.useState((s==null?void 0:s.is_active)??!0),{data:m}=Wa({page_size:100,is_active:!0}),V=(m==null?void 0:m.results)??[];return e.jsx(bt,{open:!0,onOpenChange:t,children:e.jsxs(Ct,{className:"max-w-md",children:[e.jsx(St,{children:e.jsx(wt,{children:s?"Edit Template":"New Template"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{children:"Name"}),e.jsx(b,{value:n,onChange:F=>i(F.target.value),placeholder:"e.g. Senior Developer Assessment"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{children:"Position Level"}),e.jsxs(Ce,{value:u??"__none__",onValueChange:F=>r(F==="__none__"?null:F),children:[e.jsx(Se,{children:e.jsx(we,{placeholder:"Select level"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"__none__",children:"None"}),V.map(F=>e.jsx(q,{value:F.id,children:F.name},F.id))]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(rs,{checked:N,onCheckedChange:y}),e.jsx(o,{children:"Active"})]})]}),e.jsxs(Yt,{children:[e.jsx(P,{variant:"outline",onClick:t,children:"Cancel"}),e.jsx(P,{onClick:()=>a({name:n,position_level:u,is_active:N}),disabled:!n.trim(),children:s?"Update":"Create"})]})]})})}function zl({templateId:s,domain:t,onClose:a,onSubmit:n}){const[i,u]=h.useState((t==null?void 0:t.name)??""),[r,N]=h.useState((t==null?void 0:t.description)??""),[y,m]=h.useState(String((t==null?void 0:t.weight)??1)),[V,F]=h.useState(String((t==null?void 0:t.order)??0)),[M,z]=h.useState((t==null?void 0:t.is_active)??!0);return e.jsx(bt,{open:!0,onOpenChange:a,children:e.jsxs(Ct,{className:"max-w-md",children:[e.jsx(St,{children:e.jsx(wt,{children:t?"Edit Domain":"New Domain"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{children:"Name"}),e.jsx(b,{value:i,onChange:G=>u(G.target.value),placeholder:"e.g. Problem Solving"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{children:"Description"}),e.jsx(Ae,{value:r,onChange:G=>N(G.target.value),placeholder:"What this domain evaluates...",className:"min-h-[70px] resize-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{children:"Weight"}),e.jsx(b,{type:"number",step:"0.1",min:"0",value:y,onChange:G=>m(G.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(o,{children:"Order"}),e.jsx(b,{type:"number",min:"0",value:V,onChange:G=>F(G.target.value)})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(rs,{checked:M,onCheckedChange:z}),e.jsx(o,{children:"Active"})]})]}),e.jsxs(Yt,{children:[e.jsx(P,{variant:"outline",onClick:a,children:"Cancel"}),e.jsx(P,{onClick:()=>n({template:s,name:i,description:r,weight:parseFloat(y)||1,order:parseInt(V)||0,is_active:M}),disabled:!i.trim(),children:t?"Update":"Add"})]})]})})}const Ml={draft:"secondary",submitted:"default"};function yd(){const{pagination:s,setPagination:t,sorting:a,setSorting:n,globalFilter:i,setGlobalFilter:u,queryParams:r}=tt(),[N,y]=h.useState(""),[m,V]=h.useState(""),[F,M]=h.useState(null),z=Ya(),[G,ee]=h.useState(""),{data:te,isLoading:ie}=Ws({search:G||void 0}),L=h.useMemo(()=>(te==null?void 0:te.results)??[],[te]),re=h.useMemo(()=>{const R={...r};return N&&(R.status=N),m&&(R.template=m),R},[r,N,m]),{data:ne,isLoading:ce}=Ir(re),J=(ne==null?void 0:ne.results)??[],Q=[{key:"candidate_name",header:"Candidate",render:R=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:R.candidate_name})},{key:"template_name",header:"Template",render:R=>e.jsx("span",{className:"text-[13px] text-slate-600",children:R.template_name})},{key:"date",header:"Date",render:R=>e.jsx("span",{className:"text-[13px] text-slate-500",children:R.date})},{key:"interviewer_name",header:"Interviewer",render:R=>e.jsx("span",{className:"text-[13px] text-slate-600",children:R.interviewer_name||"—"})},{key:"final_score",header:"Score",render:R=>e.jsx("span",{className:"text-[13px] font-mono font-medium text-slate-700",children:R.final_score!==null?R.final_score:"—"})},{key:"status",header:"Status",render:R=>e.jsx(le,{variant:Ml[R.status],className:"capitalize text-[11px]",children:R.status})},{key:"expand",header:"",className:"w-20",render:R=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(P,{variant:"ghost",size:"icon-sm",title:"Download PDF",onClick:()=>z.mutate(R.id),children:e.jsx(kt,{className:"h-4 w-4 text-slate-400 hover:text-primary"})}),e.jsx(P,{variant:"ghost",size:"icon-sm",onClick:()=>M(F===R.id?null:R.id),children:F===R.id?e.jsx(Rs,{className:"h-4 w-4 text-slate-400"}):e.jsx(Ds,{className:"h-4 w-4 text-slate-400"})})]})}];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(is,{className:"h-5 w-5 text-primary"})," Assessment Ratings"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"View and export all candidate assessment ratings"})]})}),e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsxs(Ce,{value:N,onValueChange:R=>y(R==="__all__"?"":R),children:[e.jsx(Se,{className:"w-[150px] h-9",children:e.jsx(we,{placeholder:"All statuses"})}),e.jsxs(ke,{children:[e.jsx(q,{value:"__all__",children:"All Statuses"}),e.jsx(q,{value:"draft",children:"Draft"}),e.jsx(q,{value:"submitted",children:"Submitted"})]})]}),e.jsx(me,{value:m,onValueChange:R=>V(R==="__all__"?"":R),onSearch:ee,isLoading:ie,options:[{value:"__all__",label:"All Templates"},...L.map(R=>({value:R.id,label:R.name}))],placeholder:"All templates",searchPlaceholder:"Search templates...",className:"w-[200px]"})]}),e.jsx(st,{columns:Q,data:J,isLoading:ce,searchPlaceholder:"Search assessments...",emptyMessage:"No assessments",emptyDescription:"Create assessments from the candidate profile page.",totalCount:(ne==null?void 0:ne.count)??0,pagination:s,onPaginationChange:t,sorting:a,onSortingChange:n,globalFilter:i,onGlobalFilterChange:u}),F&&(()=>{var v;const R=J.find(S=>S.id===F);return!R||!((v=R.ratings)!=null&&v.length)?null:e.jsxs("div",{className:"mt-4 rounded-lg border border-slate-200 bg-white overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3 bg-slate-50 border-b border-slate-200",children:e.jsxs("p",{className:"text-sm font-medium text-slate-700",children:[R.candidate_name," — ",R.template_name]})}),e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-200 text-xs text-slate-500",children:[e.jsx("th",{className:"py-2 px-4 text-left font-medium",children:"Domain"}),e.jsx("th",{className:"py-2 px-4 text-center font-medium w-20",children:"Weight"}),e.jsx("th",{className:"py-2 px-4 text-center font-medium w-28",children:"Rating"}),e.jsx("th",{className:"py-2 px-4 text-center font-medium w-28",children:"Weighted"}),e.jsx("th",{className:"py-2 px-4 text-left font-medium",children:"Comments"})]})}),e.jsx("tbody",{children:R.ratings.map(S=>e.jsxs("tr",{className:"border-b border-slate-100 last:border-0",children:[e.jsx("td",{className:"py-2 px-4 text-slate-700",children:S.domain_name}),e.jsx("td",{className:"py-2 px-4 text-center text-slate-500",children:S.domain_weight}),e.jsx("td",{className:"py-2 px-4 text-center",children:e.jsx("span",{className:"inline-flex gap-0.5",children:[1,2,3,4,5].map(X=>e.jsx(is,{className:`h-3.5 w-3.5 ${X<=S.rating?"fill-amber-400 text-amber-400":"text-slate-200"}`},X))})}),e.jsx("td",{className:"py-2 px-4 text-center font-mono text-slate-600",children:S.weighted_score??"—"}),e.jsx("td",{className:"py-2 px-4 text-slate-500 text-xs",children:S.comments||"—"})]},S.id))})]}),R.remarks&&e.jsxs("div",{className:"px-4 py-2 bg-slate-50 border-t border-slate-100 text-xs text-slate-500",children:["Remarks: ",R.remarks]})]})})()]})}const Ql=ct({name:C().min(1,"Name is required"),code:C().min(1,"Code is required"),company:C().min(1,"Company is required"),order:Me.number().min(0,"Order must be >= 0").optional(),is_active:ge().optional()});function Nd(){const[s,t]=h.useState(!1),[a,n]=h.useState(null),[i,u]=h.useState(null),{hasPermission:r,requirePermission:N}=et(),y=r("recruitment","position_level","create"),m=r("recruitment","position_level","update"),V=r("recruitment","position_level","delete"),{pagination:F,setPagination:M,sorting:z,setSorting:G,globalFilter:ee,setGlobalFilter:te,queryParams:ie}=tt(),{data:L,isLoading:re}=Wa(ie),ne=(L==null?void 0:L.results)??[],[ce,J]=h.useState(""),{data:Q,isLoading:R}=Ut({search:ce||void 0}),v=qr(),S=Fr(),X=Pr(),Z=Ye({resolver:nt(Ql),defaultValues:{name:"",code:"",company:"",order:0,is_active:!0}});function W(){N("recruitment","position_level","create")&&(n(null),Z.reset({name:"",code:"",company:"",order:0,is_active:!0}),t(!0))}function de(H){N("recruitment","position_level","update")&&(n(H),Z.reset({name:H.name,code:H.code,company:H.company,order:H.order,is_active:H.is_active}),t(!0))}function w(H){const I=H;a?S.mutate({id:a.id,...I},{onSuccess:()=>t(!1)}):v.mutate(I,{onSuccess:()=>t(!1)})}function se(){i&&X.mutate(i.id,{onSuccess:()=>u(null)})}const D=[{key:"name",header:"Name",render:H=>e.jsx("span",{className:"font-medium text-slate-900 text-[13px]",children:H.name})},{key:"code",header:"Code",render:H=>e.jsx("span",{className:"text-[13px] text-slate-600",children:H.code})},{key:"order",header:"Order",render:H=>e.jsx("span",{className:"text-[13px] text-slate-600",children:H.order})},{key:"is_active",header:"Status",render:H=>e.jsx(La,{status:H.is_active?"active":"inactive"})},{key:"actions",header:"",className:"w-10",render:H=>e.jsxs(it,{children:[e.jsx(rt,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon-sm",children:e.jsx(ot,{className:"h-4 w-4"})})}),e.jsxs(lt,{align:"end",children:[m&&e.jsxs(B,{onClick:()=>de(H),children:[e.jsx(at,{className:"mr-2 h-3.5 w-3.5"})," Edit"]}),V&&e.jsxs(e.Fragment,{children:[e.jsx(We,{}),e.jsxs(B,{className:"text-red-600",onClick:()=>u(H),children:[e.jsx(ft,{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(ns,{className:"h-5 w-5 text-primary"})," Position Levels"]}),e.jsx("p",{className:"mt-0.5 text-[13px] text-slate-400",children:"Manage position levels for assessment templates"})]}),y&&e.jsxs(P,{size:"sm",onClick:W,children:[e.jsx(Ue,{className:"mr-1.5 h-3.5 w-3.5"})," Add Position Level"]})]}),e.jsx(st,{columns:D,data:ne,isLoading:re,searchPlaceholder:"Search position levels...",emptyMessage:"No position levels",emptyDescription:"Create your first position level to categorize assessment templates.",totalCount:(L==null?void 0:L.count)??0,pagination:F,onPaginationChange:M,sorting:z,onSortingChange:G,globalFilter:ee,onGlobalFilterChange:te}),e.jsx(De,{open:s,onOpenChange:t,children:e.jsxs(Ee,{size:"md",children:[e.jsxs(Te,{children:[e.jsx(Ve,{children:a?"Edit Position Level":"Add Position Level"}),e.jsx(Ie,{children:a?"Update position level details.":"Create a new position level for assessment templates."})]}),e.jsxs("form",{onSubmit:Z.handleSubmit(w),className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Name *"}),e.jsx(b,{...Z.register("name"),className:"mt-1.5",placeholder:"e.g. Managerial"}),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(o,{className:"text-[12px] font-medium text-slate-500",children:"Code *"}),e.jsx(b,{...Z.register("code"),className:"mt-1.5",placeholder:"e.g. MANAGERIAL"}),Z.formState.errors.code&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:Z.formState.errors.code.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Company *"}),e.jsx("div",{className:"mt-1.5",children:e.jsx(me,{value:Z.watch("company"),onValueChange:H=>Z.setValue("company",H),onSearch:J,isLoading:R,options:((Q==null?void 0:Q.results)??[]).map(H=>({value:H.id,label:H.name,hint:H.code})),placeholder:"Select company",searchPlaceholder:"Search companies..."})}),Z.formState.errors.company&&e.jsx("p",{className:"text-[11px] text-red-500 mt-1",children:Z.formState.errors.company.message})]}),e.jsxs("div",{children:[e.jsx(o,{className:"text-[12px] font-medium text-slate-500",children:"Order"}),e.jsx(b,{type:"number",min:"0",...Z.register("order"),className:"mt-1.5"})]})]}),e.jsxs(Qe,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>t(!1),children:"Cancel"}),e.jsx(P,{onClick:Z.handleSubmit(w),disabled:v.isPending||S.isPending,children:a?"Update":"Create"})]})]})}),e.jsx(mt,{open:!!i,onOpenChange:H=>!H&&u(null),children:e.jsxs(xt,{children:[e.jsxs(ut,{children:[e.jsx(pt,{children:"Delete position level?"}),e.jsxs(ht,{children:["This will permanently delete ",e.jsx("strong",{children:i==null?void 0:i.name}),"."]})]}),e.jsxs(jt,{children:[e.jsx(gt,{children:"Cancel"}),e.jsx(vt,{variant:"destructive",onClick:se,children:"Delete"})]})]})})]})}export{ad as ApplicationsPage,vd as AssessmentTemplatesPage,yd as AssessmentsPage,md as BusinessNeedsPage,_d as CandidateDetailPage,gd as CandidateResponsesPage,sd as CandidatesPage,fd as CostConfirmationsPage,cd as EvaluationsPage,ud as InterviewRoundsPage,nd as InterviewsPage,od as NegotiationsPage,ld as OfferDetailPage,rd as OfferTemplatesPage,id as OffersPage,xd as PipelineStagesPage,Nd as PositionLevelsPage,hd as RecruitmentAnalyticsPage,Zo as RecruitmentDashboardPage,so as RecruitmentLayout,jd as RecruitmentOnboardingPage,pd as RecruitmentReportsPage,dd as RecruitmentSettingsPage,ed as RequisitionCategoriesPage,td as RequisitionDetailPage,Xo as RequisitionsPage,p as recruitmentKeys,Ba as useAdminFillPreJoining,Ir as useAllAssessments,fo as useApplication,gs as useApplications,Ci as useApproveCostConfirmation,ko as useApproveOffer,ao as useApproveRequisition,Wo as useAssessment,Er as useAssessmentDomains,$r as useAssessmentTemplate,Ws as useAssessmentTemplates,qo as useBGVVendors,Di as useBlacklistCandidate,Ka as useBusinessNeeds,Qo as useCampusPartners,Yi as useCancelInterview,Ma as useCandidate,Ho as useCandidateActivities,Lr as useCandidateAssessments,Cr as useCandidateNotes,gr as useCandidateResponses,Qs as useCandidates,go as useClosePosting,ji as useCloseRequisition,Wi as useCompleteInterview,Eo as useCompleteVerification,fi as useCostConfirmations,Vi as useCreateApplication,Kr as useCreateAssessment,Tr as useCreateAssessmentDomain,Ar as useCreateAssessmentTemplate,Fo as useCreateBGVVendor,oi as useCreateBusinessNeed,Uo as useCreateCampusPartner,$i as useCreateCandidate,Sr as useCreateCandidateNote,vi as useCreateCostConfirmation,Ko as useCreateDrive,vo as useCreateEvaluationForm,Gi as useCreateInterview,Xi as useCreateInterviewEvaluation,Co as useCreateInterviewPanel,Mi as useCreateInterviewRound,vr as useCreateNegotiation,xr as useCreateOffer,tr as useCreateOfferTemplate,qi as useCreatePipelineStage,qr as useCreatePositionLevel,xo as useCreatePosting,Oo as useCreateReferenceCheck,ro as useCreateRejectionReason,xi as useCreateRequisition,Ro as useCreateVerification,Mr as useDeleteAssessment,Or as useDeleteAssessmentDomain,Dr as useDeleteAssessmentTemplate,$o as useDeleteBGVVendor,mi as useDeleteBusinessNeed,Go as useDeleteCampusPartner,Ri as useDeleteCandidate,wr as useDeleteCandidateNote,Ni as useDeleteCostConfirmation,Mo as useDeleteDrive,No as useDeleteEvaluationForm,wo as useDeleteInterviewPanel,Ui as useDeleteInterviewRound,ar as useDeleteOfferTemplate,Pi as useDeletePipelineStage,Pr as useDeletePositionLevel,po as useDeletePosting,co as useDeleteRejectionReason,pi as useDeleteRequisition,Ya as useDownloadAssessmentPdf,Io as useDrives,_o as useEvaluationForms,Bi as useInterview,oa as useInterviewEvaluations,bo as useInterviewPanels,Us as useInterviewRounds,Qa as useInterviews,Ha as useMarkPreJoiningReviewed,Ii as useMoveApplicationStage,_r as useNegotiations,mr as useOffer,Bs as useOfferTemplates,Gs as useOffers,jo as usePausePosting,za as usePipelineStages,Wa as usePositionLevels,mo as usePosting,oo as usePostings,Ga as usePreJoiningAdmin,ho as usePublishPosting,no as usePublishRequisition,kr as useRecruitmentDashboard,li as useRecruitmentSettings,Vo as useReferenceChecks,Ki as useRejectApplication,io as useRejectionReasons,Ps as useRequisition,zs as useRequisitions,Zi as useRescheduleInterview,Ua as useResendOffer,gi as useRevertRequisitionToDraft,pr as useSendOffer,zi as useShortlistApplication,zr as useSubmitAssessment,bi as useSubmitCostConfirmation,hi as useSubmitRequisition,Oi as useUpdateApplication,Yo as useUpdateAssessment,Vr as useUpdateAssessmentDomain,Rr as useUpdateAssessmentTemplate,Po as useUpdateBGVVendor,di as useUpdateBusinessNeed,Bo as useUpdateCampusPartner,Ai as useUpdateCandidate,Jo as useUpdateCandidateNote,yi as useUpdateCostConfirmation,zo as useUpdateDrive,yo as useUpdateEvaluationForm,Ji as useUpdateInterview,er as useUpdateInterviewEvaluation,So as useUpdateInterviewPanel,Qi as useUpdateInterviewRound,yr as useUpdateNegotiation,ur as useUpdateOffer,sr as useUpdateOfferTemplate,Fi as useUpdatePipelineStage,Fr as useUpdatePositionLevel,uo as useUpdatePosting,ci as useUpdateRecruitmentSettings,Lo as useUpdateReferenceCheck,lo as useUpdateRejectionReason,ui as useUpdateRequisition,Do as useUpdateVerification,Ao as useVerifications,To as useWaiveVerification,hr as useWithdrawOffer};
