1import{b as We,a as i,o as Ne,j as e,S as Ve,c as T,l as Ye,e as S}from"./index-n6n_qa9n.js";import{S as Ke}from"./SmoothDropdown-DTOlS5ni.js";import{f as we,o as Ie,u as Je,s as Ge,B as Qe,E as Xe,C as Ze}from"./index.esm-BRQfDFns.js";import{b as ea,g as aa,c as sa}from"./weekendSettings-B-FqTqBx.js";import"./iconBase-DGMjhFNK.js";const Q=c=>{const s=String(c||"").trim();return s?s.toLowerCase().replace(/\b\w/g,u=>u.toUpperCase()):"-"},ta=["annualLeaves","sickLeaves","casualLeaves","bereavementLeaves"],X=c=>{if(c==null||c==="")return 0;const s=typeof c=="string"?parseFloat(c.replace("%","").trim()):Number(c);return Number.isFinite(s)?s:0},na=(c,s)=>{if(!c||!s)return 0;const u=new Date(`${c}T00:00:00`),B=new Date(`${s}T00:00:00`),R=ea(aa()),U=sa();let j=0;for(const m=new Date(u);m<=B;m.setDate(m.getDate()+1)){const h=`${m.getFullYear()}-${String(m.getMonth()+1).padStart(2,"0")}-${String(m.getDate()).padStart(2,"0")}`;!R.has(m.getDay())&&!U.includes(h)&&(j+=1)}return j},la=c=>{const s=new Date(c);return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`},ra=c=>{const s=String(c||"").trim();if(!s)return"";if(/^\d{4}-\d{2}-\d{2}/.test(s))return s.slice(0,10);const u=s.match(/^(\d{2})[\/-](\d{2})[\/-](\d{4})$/);return u?`${u[3]}-${u[2]}-${u[1]}`:""},ce=(c,s)=>{if(!c||typeof c!="object")return;const u=s.replace("Leaves","");return c[s]??c[`remaining${u.charAt(0).toUpperCase()}${u.slice(1)}Leaves`]??c[`remaining_${s}`]},oe=(c={})=>{const s=c?.data&&!Array.isArray(c.data)?c.data:c,u=s?.leavesSummary?.remaining||s?.remaining||s?.remainingLeaves?.[0]||s?.remainingLeaves||s?.leaveBalance?.remaining||{},B=s?.leavesSummary?.totalAssigned||s?.totalAssigned||s?.assignedLeaves?.[0]||s?.allottedLeaves?.[0]||s?.leaveBalance?.assigned||s,R=s?.leavesSummary?.totalUsed||s?.totalUsed||s?.used||s?.usedLeaves?.[0]||s?.usedLeaves||s?.leaveBalance?.used||{};return ta.reduce((U,j)=>{const m=ce(u,j),h=X(ce(B,j)),de=X(ce(R,j)),ue=m!=null&&m!=="";return U[j]=ue?X(m):Math.max(0,h-de),U},{})},ia=1e3*30,ca=(c,s)=>`manualLeaveCache:${String(c||"unknown")}:${String(s||"unknown")}`,ke=new Map,ga=()=>{const c=We(),[s,u]=i.useState({userId:[],leaveType:"",startDate:"",endDate:"",reason:""}),[B,R]=i.useState({annualLeaves:0,sickLeaves:0,casualLeaves:0,bereavementLeaves:0}),[U,j]=i.useState([]),[m,h]=i.useState(!1),[de,ue]=i.useState(!0),[b,me]=i.useState([]);i.useEffect(()=>{},[s.userId,b]);const Z=localStorage.getItem("token"),Ce=Ne(JSON.stringify(Z)),ve=Ne(JSON.stringify(Z)),ee=ve?.id||"",N=ve?.userType||"",y="https://production-api.sstrack.io",z=ca(N,ee),w={Authorization:`Bearer ${Z}`},[O,D]=i.useState({annualLeaves:0,sickLeaves:0,casualLeaves:0,bereavementLeaves:0}),[v,ae]=i.useState(!1),[oa,pe]=i.useState({}),[_,se]=i.useState(!0),[te,H]=i.useState({}),[Ae,ne]=i.useState(!1),[f,Te]=i.useState(!1),[le,Ue]=i.useState("");i.useEffect(()=>{const a=()=>{Te(window.innerWidth<=768)};return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]);const d=a=>a===!0||a==="true"||a===1||a==="1",he=a=>String(a?._id||a?.id||a?.userId?._id||a?.userId||""),fe=a=>{const t=a?.userId||a||{},n=String(t?.userType||a?.userType||"").toLowerCase(),l=d(t?.isArchived)||d(t?.archived)||d(t?.isArchive)||d(a?.isArchived)||d(a?.archived)||d(a?.isArchive)||String(t?.status||a?.status||"").toLowerCase()==="archived",o=d(t?.inviteStatus)||d(a?.inviteStatus),r=d(t?.UserStatus)||d(a?.UserStatus);return!!t?._id&&!l&&!o&&!r&&n!=="owner"};i.useEffect(()=>{const a=Array.isArray(s.userId)?s.userId[0]:s.userId;if(a&&b.length>0){const t=b.find(n=>n?.userId?._id?.toString()===a?.toString());D(t?{annualLeaves:t.annualLeaves||0,sickLeaves:t.sickLeaves||0,casualLeaves:t.casualLeaves||0,bereavementLeaves:t.bereavementLeaves||0}:{annualLeaves:0,sickLeaves:0,casualLeaves:0,bereavementLeaves:0})}else D({annualLeaves:0,sickLeaves:0,casualLeaves:0,bereavementLeaves:0})},[s.userId,b]);const Fe=`${y}/api/v1/timetrack/getAllLeaves`;i.useEffect(()=>{if(!s.startDate||!s.endDate){H({});return}let a=!1;return(async()=>{ne(!0);try{const n=new Date(`${s.startDate}T00:00:00`),l=new Date(`${s.endDate}T00:00:00`),o=[],r=new Date(n.getFullYear(),n.getMonth(),1),x=new Date(l.getFullYear(),l.getMonth(),1);for(;r<=x;)o.push({year:r.getFullYear(),month:r.getMonth()+1}),r.setMonth(r.getMonth()+1);const g=await Promise.all(o.map(({year:p,month:Se})=>T.get(`${y}/api/v1/superAdmin/leave/getCountryPublicHolidays`,{params:{country:"Pakistan",month:Se,year:p},headers:w})));if(a)return;const L={};g.forEach(p=>
1{(p.data?.data?.holidays||p.data?.holidays||[]).forEach(G=>{const De=ra(G?.holidayDate||G?.date);De&&(L[De]=G?.holidayName||G?.holidayType||"Official holiday")})}),H(L)}catch{a||H({})}finally{a||ne(!1)}})(),()=>{a=!0}},[y,s.startDate,s.endDate]);const ge=i.useMemo(()=>{if(!s.startDate||!s.endDate)return[];const a=[],t=new Date(`${s.startDate}T00:00:00`),n=new Date(`${s.endDate}T00:00:00`);for(;t<=n;){const l=la(t);te[l]&&a.push({date:l,name:te[l]}),t.setDate(t.getDate()+1)}return a},[s.startDate,s.endDate,te]),[q,xe]=i.useState([]),[da,ua]=i.useState(""),I=i.useMemo(()=>(q||[]).filter(a=>{const t=a?.userId||{},n=String(t?.userType||"").toLowerCase();if(!t?._id||!t?.name||!t?.email)return!1;const l=d(t?.isArchived)||d(t?.archived)||d(t?.isArchive)||d(a?.isArchived)||d(a?.archived)||d(a?.isArchive),o=d(t?.inviteStatus)||d(a?.inviteStatus),r=d(t?.UserStatus)||d(a?.UserStatus);return!(l||o||r||String(t._id)===String(ee)||N==="admin"&&n==="owner"||N==="owner"&&n==="owner")}).sort((a,t)=>{const n=String(a?.userId?.name||"").toLowerCase(),l=String(t?.userId?.name||"").toLowerCase();return n.localeCompare(l,"en",{numeric:!0,sensitivity:"base"})}),[q,ee,N]);i.useMemo(()=>(I||[]).map(a=>({value:a?.userId?._id,label:Q(a?.userId?.name),shortLabel:Q(a?.userId?.name),secondaryLabel:a?.userId?.email})),[I]);const F=i.useMemo(()=>new Set((Array.isArray(s.userId)?s.userId:[]).map(String)),[s.userId]),$=i.useMemo(()=>{const a=le.trim().toLowerCase();return I.filter(t=>{const n=t?.userId||{};return!a||String(n.name||"").toLowerCase().includes(a)||String(n.department||t.department||"").toLowerCase().includes(a)})},[I,le]),$e=a=>{const t=String(a),n=Array.from(F),l=n.indexOf(t);l>=0?n.splice(l,1):n.push(t),C({target:{name:"userId",value:n}})},E=i.useMemo(()=>(Array.isArray(s.userId)?s.userId.map(String):s.userId?[String(s.userId)]:[]).map(t=>{const n=I.find(r=>String(r?.userId?._id)===t),l=b.find(r=>String(r?.userId?._id||r?.userId?.id||r?.userId)===t)||{},o=oe(n);return{id:t,name:Q(n?.userId?.name||l?.userId?.name),casualLeaves:l.casualLeaves??o.casualLeaves??0,sickLeaves:l.sickLeaves??o.sickLeaves??0,annualLeaves:l.annualLeaves??o.annualLeaves??0,bereavementLeaves:l.bereavementLeaves??o.bereavementLeaves??0}}),[s.userId,I,b]),k=i.useMemo(()=>na(s.startDate,s.endDate),[s.startDate,s.endDate]),P=i.useMemo(()=>E.map(a=>{const t=X(a[s.leaveType]),n=t-k;return{...a,available:t,afterLeave:n,sufficient:!k||n>=0}}),[E,s.leaveType,k]),M=P.filter(a=>!a.sufficient),W=P.filter(a=>a.sufficient),V=!!(s.leaveType&&E.length),Y=k>0,re=i.useMemo(()=>[{value:"casualLeaves",label:"Casual Leave"},{value:"sickLeaves",label:"Sick Leave"},{value:"annualLeaves",label:"Annual Leave"},{value:"bereavementLeaves",label:"Bereavement Leave"}],[]),ye=async({silent:a=!1}={})=>{a||se(!0);try{const t=Ce?.userType;let n="",l="";if(t==="admin"||t==="owner")n=`${y}/api/v1/superAdmin/getAllUserLeaves`,l=`${y}/api/v1/owner/companies`;else if(t==="manager")n=`${y}/api/v1/manager/getAllUserLeaves`,l=`${y}/api/v1/manager/employees`;else{console.warn("Unrecognized userType",t);return}const[o,r]=await Promise.all([T.get(n,{headers:w}),T.get(l,{headers:w})]),x=o.data?.data||[],g=r.data?.employees||r.data?.convertedEmployees||r.data?.data||[],L=new Set(g.filter(p=>fe(p)).map(p=>he(p?.userId||p)).filter(Boolean));xe(x.filter(p=>L.has(he(p?.userId||p))&&fe(p)))}catch(t){console.error("Error fetching manual leave users:",t)}finally{a||se(!1)}},Ee=async()=>{const t=(await T.get(Fe,{headers:w}))?.data;if(t?.success){const n=t?.remainingLeaves||[];me(n)}};i.useEffect(()=>{let a=!1;try{const t=ke.get(z);t&&Date.now()-Number(t?.ts||0)<ia&&t?.payload&&(a=!0,xe(t.payload?.allUsers||[]),me(t.payload?.remainingLeaves||[]),se(!1))}catch(t){console.error("Manual leave cache read error:",t)}ye({silent:a}),Ee()},[z]),i.useEffect(()=>{try{ke.set(z,{ts:Date.now(),payload:{allUsers:q,remainingLeaves:b}})}catch(a){console.error("Manual leave cache write error:",a)}},[z,q,b]);const C=a=>{const{name:t,value:n}=a.target;if((t==="startDate"||t==="endDate")&&(ne(!!n),H({})),t==="endDate"&&n&&s.startDate&&new Date(n)<new Date(s.startDate)){S("End date must be on or after start date.",{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"}});return}u(l=>{const o={...l,[t]:n};return t==="startDate"&&n&&l.endDate&&new Date(l.endDate)<new Date(n)&&(o.endDate=""),o})},Me=async a=>{a.preventDefault(),h(!0);const{leaveType:t,startDate:n,endDate:l,reason:o,userId:r}=s;
1if(!t||!n||!l||!o.trim()||!r?.length){S("Please fill in all fields before submitting",{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"}}),h(!1);return}if(new Date(n)>new Date(l)){S("Start date must be before end date",{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"}}),h(!1);return}if(Ae){h(!1);return}if(ge.length>0){S(`Leave cannot be assigned on ${ge.map(g=>`${g.date} (${g.name})`).join(", ")}.`,{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"}}),h(!1);return}const x=W.map(g=>g.id);if(x.length===0){S("No selected employees have enough leave balance.",{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"}}),h(!1);return}try{(await Promise.all(x.map(L=>T.post(`${y}/api/v1/superAdmin/addmanualLeave`,{...s,userId:L},{headers:w})))).every(L=>L.status===200||L.status===201)?(S("Manual leave submitted successfully",{variant:"success",anchorOrigin:{vertical:"top",horizontal:"right"}}),u({leaveType:"",startDate:"",endDate:"",reason:"",userId:[]}),ye()):S("Failed to submit manual leave",{variant:"error"})}catch(g){S(g.response?.data?.message||"Something went wrong",{variant:"error",anchorOrigin:{vertical:"top",horizontal:"right"}})}finally{h(!1)}};i.useEffect(()=>{(async()=>{const t=Array.isArray(s.userId)?s.userId.filter(Boolean):s.userId?[s.userId]:[];if(!t.length){ae(!1),pe({}),D({annualLeaves:0,sickLeaves:0,casualLeaves:0,bereavementLeaves:0});return}try{ae(!0);const n=await Promise.allSettled(t.map(r=>T.get(`${y}/api/v1/superAdmin/getAllottedLeavOfUser/${r}`,{headers:w}))),l={};n.forEach((r,x)=>{r.status==="fulfilled"&&(l[String(t[x])]=oe(r.value.data))}),pe(l);const o=[];if(Array.isArray(o)&&o.length>0){const r=o[0];D({annualLeaves:r.annualLeaves||0,sickLeaves:r.sickLeaves||0,casualLeaves:r.casualLeaves||0,bereavementLeaves:r.bereavementLeaves||0})}else D({annualLeaves:0,sickLeaves:0,casualLeaves:0,bereavementLeaves:0})}catch{D({annualLeaves:0,sickLeaves:0,casualLeaves:0,bereavementLeaves:0})}finally{ae(!1)}})()},[s.userId]);const Be={display:"flex",alignItems:f?"flex-start":"center",justifyContent:"space-between",gap:f?"12px":"0",marginBottom:"10px",flexDirection:f?"column":"row"},Re={color:"#0E4772",fontWeight:"700",fontSize:f?"26px":"34px",lineHeight:"1.05",margin:0},ze={display:"flex",gap:f?"18px":"16px",marginTop:"14px"},ie={display:"flex",alignItems:"flex-start",gap:"0",flexDirection:"column",marginBottom:"20px"},Le={padding:"10px 12px",border:"1px solid #D1D5DB",borderRadius:"8px",fontSize:"14px",color:"#374151",backgroundColor:"#fff",minHeight:"42px",width:"100%",transition:"border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease"},Oe={width:f?"100%":"72%",padding:"10px 12px",border:"1px solid #D1D5DB",borderRadius:"8px",fontSize:"14px",color:"#374151",resize:"none",minHeight:"110px",backgroundColor:"#fff"},_e={display:"flex",gap:"12px",flexWrap:"wrap",width:f?"100%":"auto",justifyContent:"flex-end"},je={padding:"10px 20px",borderRadius:"5px",fontWeight:"600",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"5px"},K=s.leaveType?s.userId?.length?!s.startDate||!s.endDate?3:s.reason?.trim()?V&&W.length>0?6:5:4:2:1,He=[Ge,Ie,we,Qe,Xe,Ze],A=(a,t,n)=>{const l=a<K,o=a===K;return e.jsxs("div",{className:`manual-leave-section-step ${l?"is-complete":""} ${o?"is-current":""}`,children:[e.jsxs("div",{className:"manual-leave-section-step-heading",children:[e.jsx("span",{className:"manual-leave-step-label",children:"Step"}),e.jsx("span",{className:"manual-leave-step-number",children:a}),e.jsx("span",{className:"manual-leave-step-arrow","aria-hidden":"true",children:"â"})]}),e.jsx("span",{className:"manual-leave-step-icon","aria-hidden":"true",children:Ye.createElement(He[a-1])}),e.jsxs("div",{className:"manual-leave-step-copy",children:[e.jsx("strong",{children:t}),e.jsx("span",{children:n})]})]})},qe={display:"flex",gap:"12px",flexDirection:f?"column":"row"},be={flex:"1",display:"flex",flexDirection:"column",gap:"6px",width:"100%"},Pe={display:"flex",alignItems:"center",gap:"10px",flexWrap:"wrap",width:f?"100%":"72%"},J={display:"inline-flex",alignItems:"center",gap:"8px",flex:"0 0 auto",whiteSpace:"nowrap"};return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{}),e.jsx("div",{className:"container-fluid ps-0",children:N==="owner"||N=="admin"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"userHeader",children:e.jsx("h5",{children:"Employee Leave Management"})}),e.jsx("div",{className:"mainwrapper ownerTeamContainer",style:{display:"flex",justifyContent:"center",paddingBottom:"90px"},children:e.jsxs("div",{className:"manual-leave-page",style:{width:"100%",borderRadius:"6px"},children:[e.jsxs("div",{style:Be,className:"mnualLvCntr manual-leave-hero",children:[e.jsxs("div",{className:"manual-leave-hero-title",children:[e.jsx("span",{className:"manual-leave-hero-icon","aria-hidden":"true",children:e.jsx(we,{})}),e.jsxs("div",{children:[e.jsx("h3",{style:Re,className:"mnualLvCntrtxt",children:"Manual Leave Approval"}),e.jsx("p",{children:"Approve leave requests for your team members"})]})]}),e.jsxs("div",{className:"manual-leave-hero-note",children:[e.jsx(Ie,{"aria-hidden":"true"}),e.jsxs("span",{children:["Manage and approve leave requests manually",e.jsx("br",{}),"for employees across your organization."]})]})]}),e.jsx("div",{className:"manual-leave-steps d-none","aria-label":"Manual leave steps",children:[].map((a,t)=>{const n=t+1,l=n<K,o=n===K;return e.jsxs("div",{className:`manual-leave-step ${l?"is-complete":""} ${o?"is-current":""}`,children:[e.jsxs("div",{className:"manual-leave-step-heading",children:[e.jsx("span",{className:"manual-leave-step-label",children:"Step"}),e.jsx("span",{className:"manual-leave-step-number",children:n}),t<manualLeaveSteps.length-1&&e.jsx("span",{className:"manual-leave-step-arrow","aria-hidden":"true",children:"â"})]}),e.jsxs("div",{className:"manual-leave-step-copy",children:[e.jsx("strong",{children:a.title}),e.jsx("span",{children:a.description})]})]},a.title)})}),e.jsxs("div",{style:ze,className:"manual-leave-form-grid",children:[e.jsxs("div",{className:"manual-leave-user-section",children:[e.jsxs("div",{className:"manual-leave-step-card manual-leave-step-card-type",children:[A(1,"Select Leave Type","Choose the type of leave you want to add."),e.jsx("div",{className:"manual-leave-inline-type",children:_?e.jsx("div",{className:"manual-leave-skeleton manual-leave-type-skeleton","aria-label":"Loading leave types"}):e.jsx(Ke,{value:s.leaveType,options:re,placeholder:"Select Type of Leave",onChange:a=>C({target:{name:"leaveType",value:a}}),ariaLabel:"Select manual leave type",variant:"manual-leave-type"})})]}),e.jsxs("div",{className:"manual-leave-step-card manual-leave-step-card-employees",children:[A(2,"Select Employees","Search for and select the employee(s) receiving leave."),e.jsxs("div",{className:"manual-leave-employee-picker",children:[e.jsxs("div",{className:"manual-leave-search",children:[e.jsx(Je,{"aria-hidden":"true"}),e.jsx("input",{value:le,onChange:a=>Ue(a.target.value),placeholder:"Search employees or department","aria-label":"Search employees"})]}),e.jsxs("div",{className:"slctalBal",style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{className:"manual-leave-select-all",children:[e.jsx("input",{type:"checkbox",checked:$.length>0&&$.every(a=>F.has(String(a?.userId?._id))),onChange:a=>{const t=a.target.checked?Array.from(new Set([...F,...$.map(n=>String(n?.userId?._id))])):Array.from(F).filter(n=>!$.some(l=>String(l?.userId?._id)===n));C({target:{name:"userId",value:t}})},disabled:_}),e.jsx("span",{children:"Select all"}),e.jsxs("b",{children:[s.userId.length," selected"]})]}),e.jsxs("div",{className:"manual-leave-balance-label",children:[re.find(a=>a.value===s.leaveType)?.label.replace(" Leave","")||"Leave"," balance"]})]}),e.jsx("div",{className:"manual-leave-employee-list",children:_?Array.from({length:6}).map((a,t)=>e.jsxs("div",{className:"manual-leave-employee manual-leave-employee-skeleton","aria-hidden":"true",children:[e.jsx("span",{className:"manual-leave-skeleton manual-leave-checkbox-skeleton"}),e.jsx("span",{className:"manual-leave-skeleton manual-leave-avatar-skeleton"}),e.jsxs("span",{className:"manual-leave-employee-name",children:[e.jsx("span",{className:"manual-leave-skeleton manual-leave-name-skeleton"}),e.jsx("span",{className:"manual-leave-skeleton manual-leave-department-skeleton"})]}),e.jsx("span",{className:"manual-leave-skeleton manual-leave-balance-value-skeleton"})]},`employee-skeleton-${t}`)):$.map(a=>{const t=a?.userId||{},n=String(t?._id||""),o=oe(a)?.[s.leaveType]??a[s.leaveType]??"â",r=String(t.name||"?").split(" ").map(x=>x[0]).join("").slice(0,2).toUpperCase();return e.jsxs("label",{className:"manual-leave-employee",children:[e.jsx("input",{type:"checkbox",checked:F.has(n),onChange:()=>$e(n)}),e.jsx("span",{className:"manual-leave-avatar",children:r}),e.jsx("span",{className:"manual-leave-employee-name",children:e.jsx("strong",{children:Q(t.name)})}),e.jsx("span",{className:"manual-leave-casual",children:s.leaveType?o:"â"})]},n)})})]})]})]}),e.jsxs("div",{className:"manual-leave-right-column",children:[e.jsxs("div",{style:ie,className:"manual-leave-period-section",children:[A(3,"Set Leave Period","Choose the start and end dates for the leave."),e.jsx("div",{style:{width:f?"100%":"72%",display:"flex",flexDirection:"column",gap:"6px"},children:e.jsxs("div",{style:qe,children:[e.jsxs("div",{style:be,children:[e.jsx("label",{className:"mnulLvsHd",style:{fontSize:"13px",color:"#123D63",fontWeight:"700"},children:"Start Date"}),e.jsx("input",{type:"date",name:"startDate",value:s.startDate,onChange:C,style:Le})]}),e.jsxs("div",{style:be,children:[e.jsx("label",{className:"mnulLvsHd",style:{fontSize:"13px",color:"#123D63",fontWeight:"700"},children:"End Date"}),e.jsx("input",{type:"date",name:"endDate",value:s.endDate,onChange:C,style:Le})]})]})})]}),e.jsxs("div",{style:ie,className:"manual-leave-reason-section",children:[A(4,"Add Leave Reason","Enter a concise explanation for the absence."),e.jsx("textarea",{name:"reason",value:s.reason,onChange:C,placeholder:"The concise explanation for leave, providing context for their absence",style:Oe})]}),e.jsxs("div",{style:ie,className:`manual-leave-check-section ${V?"has-balance-results":"is-empty"}`,children:[A(5,"Check Leave Balance","Review the balance and make sure the request is sufficient."),e.jsxs("div",{className:"manual-leave-balance-panel",children:[e.jsx("div",{className:"manual-leave-balance-title",children:"Remaining Leaves by Employee"}),E.length?e.jsx("div",{className:"manual-leave-balance-table-wrap",children:e.jsxs("table",{className:"manual-leave-balance-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Employee"}),e.jsx("th",{children:"Casual"}),e.jsx("th",{children:"Sick"}),e.jsx("th",{children:"Annual"}),e.jsx("th",{children:"Bereavement"})]})}),e.jsx("tbody",{children:E.map(a=>e.jsxs("tr",{children:[e.jsx("td",{children:a.name}),e.jsx("td",{children:v?"...":a.casualLeaves}),e.jsx("td",{children:v?"...":a.sickLeaves}),e.jsx("td",{children:v?"...":a.annualLeaves}),e.jsx("td",{children:v?"...":a.bereavementLeaves})]},a.id))})]})}):e.jsx("span",{className:"manual-leave-balance-empty",children:"Select employees to view their remaining leaves."})]}),e.jsx("div",{className:`manual-leave-balance-panel manual-leave-check-panel ${V?"has-balance-results":"is-empty"}`,children:_||v?e.jsxs("div",{className:"manual-leave-balance-skeleton","aria-label":"Checking leave balance",children:[e.jsx("span",{className:"manual-leave-skeleton manual-leave-skeleton-line short"}),e.jsx("span",{className:"manual-leave-skeleton manual-leave-skeleton-line"}),e.jsx("span",{className:"manual-leave-skeleton manual-leave-skeleton-line"}),e.jsx("span",{className:"manual-leave-skeleton manual-leave-skeleton-line"})]}):V?e.jsxs(e.Fragment,{children:[Y?e.jsxs("div",{className:"manual-leave-check-summary",children:[e.jsxs("span",{className:"manual-leave-days-pill",children:[k," ",k===1?"day":"days"," requested"]}),e.jsxs("span",{className:"manual-leave-summary-sufficient",children:[e.jsx("span",{className:"suffi",children:"â"})," ",P.filter(a=>a.sufficient).length," sufficient"]}),e.jsxs("span",{className:"manual-leave-summary-insufficient",children:[e.jsx("span",{className:"insuffi",children:"!"})," ",M.length," insufficient"]})]}):e.jsx("div",{className:"manual-leave-balance-empty manual-leave-period-hint",children:"Select start and end dates to calculate leave status."}),e.jsxs("div",{className:"manual-leave-balance-table-wrap",children:[M.length>0&&e.jsxs("div",{className:"manual-leave-warning",children:["â ",M.map(a=>a.name).join(", ")," ",M.length===1?"does":"do"," not have enough ",re.find(a=>a.value===s.leaveType)?.label||"leave"," balance."]}),e.jsxs("table",{className:"manual-leave-balance-table manual-leave-check-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Employee"}),e.jsx("th",{children:"Available"}),e.jsx("th",{children:"After leave"}),e.jsx("th",{children:"Status"})]})}),e.jsx("tbody",{children:P.map(a=>e.jsxs("tr",{children:[e.jsx("td",{children:a.name}),e.jsx("td",{children:a.available}),e.jsx("td",{className:Y&&!a.sufficient?"manual-leave-negative":"",children:Y?a.afterLeave:"â"}),e.jsx("td",{children:Y?e.jsx("span",{className:`manual-leave-status ${a.sufficient?"is-sufficient":"is-insufficient"}`,children:a.sufficient?"â Sufficient":"! Insufficient"}):e.jsx("span",{className:"manual-leave-status is-pending",children:"Pending"})})]},a.id))})]})]})]}):e.jsx("div",{className:"manual-leave-balance-empty",children:"Select employees and a leave type to view the balance check."})}),e.jsxs("div",{className:"rmngLvsCntr",style:{...Pe,display:"none"},children:[e.jsxs("div",{style:J,children:[e.jsx("span",{style:{fontWeight:"500",color:"#4F4F4F",fontSize:"14px"},children:"Casual"}),e.jsx("input",{value:v?"...":O.casualLeaves,readOnly:!0,"aria-busy":v,style:{width:"60px",padding:"8px",borderRadius:"8px",border:"1px solid #D1D5DB",textAlign:"center"}})]}),e.jsxs("div",{style:J,children:[e.jsx("span",{style:{fontWeight:"500",color:"#4F4F4F",fontSize:"14px"},children:"Sick"}),e.jsx("input",{value:v?"...":O.sickLeaves,readOnly:!0,"aria-busy":v,style:{width:"60px",padding:"8px",borderRadius:"8px",border:"1px solid #D1D5DB",textAlign:"center"}})]}),e.jsxs("div",{style:J,children:[e.jsx("span",{style:{fontWeight:"500",color:"#4F4F4F",fontSize:"14px"},children:"Annual"}),e.jsx("input",{value:v?"...":O.annualLeaves,readOnly:!0,"aria-busy":v,style:{width:"60px",padding:"8px",borderRadius:"8px",border:"1px solid #D1D5DB",textAlign:"center"}})]}),e.jsxs("div",{className:"mnulLvsHd",style:J,children:[e.jsx("span",{style:{fontWeight:"500",color:"#4F4F4F",fontSize:"14px"},children:"Bereavement"}),e.jsx("input",{value:v?"...":O.bereavementLeaves,readOnly:!0,"aria-busy":v,style:{width:"60px",padding:"8px",borderRadius:"8px",border:"1px solid #D1D5DB",textAlign:"center"}})]})]})]}),e.jsxs("div",{className:"lvbutonss",style:_e,children:[A(6,"Click Approve Leaves","Submit the manual leave request to finish."),e.jsxs("button",{className:"mnulLvsButn",style:{...je,backgroundColor:"#F9F9F9",color:"#7FC45B",border:"1px solid #D1D5DB"},onClick:()=>{c("/leave-management")},children:[e.jsx("span",{style:{fontSize:"16px"},children:"Ã"}),"Cancel"]}),e.jsx("button",{className:"mnulLvsButn",style:{...je,backgroundColor:"#7FC45B",color:"white",border:"none"},onClick:Me,disabled:m||W.length===0||v,children:m?"loading":M.length>0?`Approve ${W.length} Sufficient Leaves`:"Approve Leaves"})]})]})]})]})})]}):e.jsx("p",{children:"You are not authorized to submit leave requests."})})]})};export{ga as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.