PageSourceSearch

https://horizoncrm.ca/_assets/dashboard.hr-B-PGlBZ0.js

js horizoncrm.ca collected 2026-10-02 01:19:56 UTC 239,973 bytes, 7 lines download raw bytes

1import{o as ie,s as I,S as w,g as nt,j as e,r as g,c5 as Kt,c6 as vt,w as Ee,l as Me,k as B,A as Be,cL as Vs,cU as Ft,ae as ka,aq as ne,dh as Et,di as Ta,bB as Ot,a_ as yt,aa as dt,a$ as Rt,b6 as us,dj as Da,b$ as Ia,q as lt,f as Le,R as Qe,ab as ms,d2 as Ws,bP as Gs,bL as hs,O as $a,a8 as Yt,aC as Xt,bU as ps,cm as Vt,an as Us,ap as gt,b2 as Ea,Y as Qs,$ as ut,X as Ba,dk as Pa,dl as _s,p as Ve,m as Jt,dm as qa,Z as xs,ac as Ra,dn as Wt,b1 as Aa,i as La,bH as Fa,by as js,dp as Oa,aN as Ks,dq as Ma,dr as za,ds as Ha,dt as Va,L as rs,bb as Wa,a3 as Zt,cH as Ys,cB as Ga,aE as Xs,du as Ua,dv as Qa,dw as Ka,dx as Ya,ao as Xa,bm as Ja,bh as Za,b5 as en,dy as Js,cE as tn,cn as sn,az as os,a4 as Ts,dz as an,bD as nn}from"./vendor-QOkwwy6v.js";import{T as Dt,a as It,b as Fe,c as Oe}from"./Tabs-CBAEMcZz.js";import{S as $,u as de,B as v,l as rn,a as Ne,P as mt,j as ht,k as pt,I as K,J as on,d as we,e as ke,f as Te,h as De,i as F,K as ln,M as ys,O as wt,Q as kt,U as Tt,T as es,V as Zs,W as is,X as We,b as ea}from"./index-B5Va5PI-.js";import{u as gs,a as cn,b as ta,c as dn,d as un,e as mn,f as hn}from"./useHrData-Yoqjw8iC.js";import{C as pn,B as _n,a as xn,X as jn,Y as yn,b as gn,c as fn,d as vn}from"./Chart-BEOv7TY9.js";import{T as ls}from"./TimesheetView-CV2WwjSa.js";import{u as At,a as bn,b as Nn,c as Cn}from"./useTimeTracking-D3cTP84N.js";import{u as Sn,T as sa,a as wn,b as kn,c as Tn,M as Ds}from"./MyHoursBankCard-BvEeulCp.js";import{s as Gt,e as aa,i as Is,a as Dn,C as Nt}from"./Calendar-Debztld0.js";import{e as cs}from"./endOfMonth-BVtcdqm2.js";import{f as Ct,s as na,a as ra,e as oa}from"./fr-D3zwhp_z.js";import{e as In}from"./eachDayOfInterval-ClhwXROI.js";import{s as ia}from"./subMonths-Ci3OtNxF.js";import{u as la}from"./useTeamMembers-DX3xw3hq.js";import{D as Ye,a as Xe,b as ot,c as Je,d as $t,e as ft,f as Lt}from"./Dialog-DxbQY_8i.js";import{u as Pt,F as qt,a as J,b as re,c as ee,d as oe}from"./Form-BXZpHtyo.js";import{E as fs,D as ca,f as Ut}from"./EmployeeDayTimeline-BgLCO_id.js";import{T as $n}from"./TimeEntryForm-CsV6pA3w.js";import{C as Bt}from"./Checkbox-CXKHcW99.js";import{f as vs}from"./formatDateOnly-D6mu1J3Q.js";import{u as da}from"./useCcqApplicable-CzlSN5FA.js";import{u as Mt}from"./useUsers-D7OaGi9J.js";import{u as En}from"./useProjects-B70TT_EM.js";import{P as ua,a as ma,b as bt,c as ha,d as Bn,e as pa}from"./Pagination-DgGgEOvo.js";import{T as Pn}from"./TimeEntryDetailsModal-DtE-KdjY.js";import{u as zt,s as bs}from"./zod-DShmKsvQ.js";import{N as Qt}from"./NumberInput-Br1Ab772.js";import{h as $s}from"./moment-BLMuvzoS.js";import"./fr-Ce55WW3S.js";import{g as qn}from"./reminder-stats_GET.schema-UrCvo72C.js";import{_ as St}from"./Command-CmSR9xH1.js";import{u as Rn}from"./useInventory-Cx9EQQi7.js";import{g as An}from"./list_GET.schema-BpkjBx97.js";import{u as Es}from"./useGuidedTourStatus-Dke71Z_p.js";import{M as Bs}from"./MyHoursBankHistory-89-nfTIA.js";import{W as Ps}from"./WeeklyHoursSummary-CA0FYA5J.js";import"./index-oBJ6QkNN.js";import"./findIndex-BLyLyeml.js";import"./useExportTimeEntries-CFVsJq9E.js";import"./RadioGroup-CrMoScSW.js";import"./useTaskCategories-C8sUfFYP.js";import"./parseDateOnly-99snuWAR.js";import"./useClients-CJ3-r0dJ.js";import"./AutoComplete-B8ARmB-h.js";import"./Collapsible-CgLaOtdD.js";import"./index-VX_ospmx.js";import"./useCcqEmployeeProfiles-CL9R9u7T.js";import"./index-ChVhUks9.js";import"./list_GET.schema-DJqK4Jq0.js";import"./en-CA-Duo2YcsU.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";ie({startDate:I(),endDate:I()});const Ln=async(s,n)=>{const t=new URLSearchParams;t.set("startDate",s.startDate),t.set("endDate",s.endDate);const a=await fetch(`/_api/hr/reports/team-weekly?${t.toString()}`,{method:"GET",...n});if(!a.ok){const r=w.parse(await a.text());throw new Error(r.error||"Une erreur inconnue s'est produite")}return w.parse(await a.text())};function Fn(s){return nt({queryKey:["hr","reports","teamWeekly",s],queryFn:()=>Ln(s),enabled:!!(s.startDate&&s.endDate),staleTime:1e3*60*5})}function Ke(s,n){if(s===0&&n?.dashForZero)return"-";const t=s<0,a=Math.abs(s);let r=Math.floor(a),o=Math.round((a-r)*60);o===60&&(r+=1,o=0);let d="";t?d="-":s>0&&n?.alwaysSign&&(d="+");const h=o.toString().padStart(2,"0");return`${d}${r}h ${h}min`}const On="_tableWrapper_290im_1",Mn="_table_290im_1",zn="_th_290im_16",Hn="_employeeCol_290im_29",Vn="_dayCol_290im_34",Wn="_totalCol_290im_38",Gn="_bankCol_290im_43",Un="_td_290im_47",Qn="_row_290im_55",Kn="_rowEven_290im_63",Yn="_rowOdd_290im_67",Xn="_employeeName_290im_76",Jn="_clickableName_290im_82",Zn="_hoursCell_290im_92",er="_overtimeCell_290im_97",tr="_totalCell_290im_104",sr="_bankPositive_290im_109",ar="_bankNegative_290im_115",nr="_bankNeutral_290im_121",rr="_skeletonRow_290im_125",or="_emptyCell_290im_129",ir="_teamTotalsRow_290im_136",lr="_teamTotalsLabel_290im_141",cr="_teamTotalsCell_290im_147",le={tableWrapper:On,table:Mn,th:zn,employeeCol:Hn,dayCol:Vn,totalCol:Wn,bankCol:Gn,td:Un,row:Qn,rowEven:Kn,rowOdd:Yn,employeeName:Xn,clickableName:Jn,hoursCell:Zn,overtimeCell:er,totalCell:tr,bankPositive:sr,bankNegative:ar,bankNeutral:nr,skeletonRow:rr,emptyCell:or,teamTotalsRow:ir,teamTotalsLabel:lr,teamTotalsCell:cr},dr={fr:["Lun","Mar","Mer","Jeu","Ven","Sam","Dim"],en:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]};function ur(s){return s===0?"-":s>0?Ke(s,{alwaysSign:!0,dashForZero:!0}):Ke(s,{dashForZero:!0})}function mr(s,n){return s>0?n.bankPositive:s<0?n.bankNegative:n.bankNeutral}function hr({employees:s,teamTotals:n,isLoading:t,language:a,className:r,onEmployeeClick:o}){const d=dr[a],h=a==="fr"?"Employé":"Employee",i="Total",c=a==="fr"?"Banque":"Bank",_=a==="fr"?"Totaux équipe":"Team Totals";return e.jsx("div",{className:`${le.tableWrapper} ${r??""}`,children:e.jsxs("table",{className:le.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:`${le.th} ${le.employeeCol}`,children:h}),d.map(p=>e.jsx("th",{className:`${le.th} ${le.dayCol}`,children:p},p)),e.jsx("th",{className:`${le.th} ${le.totalCol}`,children:i}),e.jsx("th",{className:`${le.th} ${le.bankCol}`,children:c})]})}),e.jsx("tbody",{children:t?Array.from({length:5}).map((p,y)=>e.jsxs("tr",{className:le.skeletonRow,children:[e.jsx("td",{className:le.td,children:e.jsx($,{style:{width:"120px",height:"1rem"}})}),Array.from({length:7}).map((f,S)=>e.jsx("td",{className:le.td,children:e.jsx($,{style:{width:"36px",height:"1rem"}})},S)),e.jsx("td",{className:le.td,children:e.jsx($,{style:{width:"40px",height:"1rem"}})}),e.jsx("td",{className:le.td,children:e.jsx($,{style:{width:"40px",height:"1rem"}})})]},y)):s.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:10,className:le.emptyCell,children:a==="fr"?"Aucune donnée pour cette période":"No data for this period"})}):s.map((p,y)=>e.jsxs("tr",{className:`${le.row} ${y%2===0?le.rowEven:le.rowOdd}`,children:[e.jsx("td",{className:`${le.td} ${le.employeeName} ${o?le.clickableName:""}`,onClick:()=>o?.(p.userId,p.displayName),children:p.displayName}),p.dailyHours.map((f,S)=>e.jsx("td",{className:`${le.td} ${le.hoursCell}`,children:Ke(f,{dashForZero:!0})},S)),e.jsx("td",{className:`${le.td} ${le.totalCell} ${p.weekTotal>40?le.overtimeCell:""}`,children:Ke(p.weekTotal)}),e.jsx("td",{className:`${le.td} ${mr(p.hoursBankBalance,le)}`,children:ur(p.hoursBankBalance)})]},p.userId))}),!t&&s.length>0&&e.jsx("tfoot",{children:e.jsxs("tr",{className:le.teamTotalsRow,children:[e.jsx("td",{className:`${le.td} ${le.teamTotalsLabel}`,children:_}),n.dailyTotals.map((p,y)=>e.jsx("td",{className:`${le.td} ${le.teamTotalsCell}`,children:Ke(p,{dashForZero:!0})},y)),e.jsx("td",{className:`${le.td} ${le.teamTotalsCell} ${le.totalCell}`,children:Ke(n.weekTotal)}),e.jsx("td",{className:`${le.td} ${le.teamTotalsCell}`,children:"—"})]})})]})})}const pr="_container_k1agp_2",_r="_header_k1agp_13",xr="_monthLabel_k1agp_20",jr="_tableWrapper_k1agp_27",yr="_table_k1agp_27",gr="_weekCol_k1agp_54",fr="_totalCol_k1agp_59",vr="_td_k1agp_64",br="_row_k1agp_72",Nr="_weekCell_k1agp_76",Cr="_hoursCell_k1agp_83",Sr="_mutedCell_k1agp_87",wr="_overtimeCell_k1agp_92",kr="_totalCell_k1agp_99",Tr="_emptyState_k1agp_104",Dr="_skeletonCell_
1k1agp_111",Ir="_footerRow_k1agp_118",$r="_footerLabelCell_k1agp_123",Er="_monthlySummary_k1agp_128",Br="_summaryTitle_k1agp_135",Pr="_summaryBreakdown_k1agp_140",qr="_regularBadge_k1agp_147",Rr="_overtimeBadge_k1agp_147",Ar="_doubleTimeBadge_k1agp_147",Lr="_holidayBadge_k1agp_147",Fr="_footerTotalCell_k1agp_173",_e={container:pr,header:_r,monthLabel:xr,tableWrapper:jr,table:yr,weekCol:gr,totalCol:fr,td:vr,row:br,weekCell:Nr,hoursCell:Cr,mutedCell:Sr,overtimeCell:wr,totalCell:kr,emptyState:Tr,skeletonCell:Dr,footerRow:Ir,footerLabelCell:$r,monthlySummary:Er,summaryTitle:Br,summaryBreakdown:Pr,regularBadge:qr,overtimeBadge:Rr,doubleTimeBadge:Ar,holidayBadge:Lr,footerTotalCell:Fr},qs=s=>new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),0,0,0,0)),Rs=s=>new Date(Date.UTC(s.getFullYear(),s.getMonth(),s.getDate(),23,59,59,999)),Or=s=>{const n=new Date(s);return new Date(n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate())},Mr={fr:{week:"Semaine",total:"Total",regular:"Régulier",overtime:"Temps supp. (1.5x)",doubleTime:"Temps double (2x)",holiday:"Férié",monthlyTotal:"Total mensuel",noData:"Aucune donnée pour ce mois.",days:["Lun","Mar","Mer","Jeu","Ven","Sam","Dim"]},en:{week:"Week",total:"Total",regular:"Regular",overtime:"Overtime (1.5x)",doubleTime:"Double time (2x)",holiday:"Stat Holiday",monthlyTotal:"Monthly Total",noData:"No data for this month.",days:["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]}},ds=({userId:s,className:n})=>{const{language:t}=de(),a=Mr[t],r=t==="fr"?ra:oa,[o,d]=g.useState(Gt(new Date)),h=Gt(o),i=cs(o),[c,_]=g.useState(!1);g.useEffect(()=>{const T=setTimeout(()=>{_(!0)},300);return()=>clearTimeout(T)},[o]);const{isFetching:p}=At({startDate:qs(h).toISOString(),endDate:Rs(i).toISOString(),userId:s,page:1},{enabled:!!s}),{data:y,isFetching:f}=Sn({userId:s,startDate:qs(h),endDate:Rs(i)},{enabled:!!s&&c}),S=()=>d(ia(o)),u=()=>d(Dn(o,1)),N=Ct(o,"MMMM yyyy",{locale:r}),C=p||c&&f||!c,q=g.useMemo(()=>{const T=[];let D=na(h,{weekStartsOn:1});for(;D<=i;){const G=aa(D,{weekStartsOn:1}),H=In({start:D,end:G});T.push({start:D,end:G,days:H});const Z=new Date(D);Z.setDate(Z.getDate()+7),D=Z}return T},[h,i]),l=T=>{if(!y||!Is(T,o))return null;const D=y.details.find(G=>Or(G.date).toDateString()===T.toDateString());return D?D.dayTotal:0},x=T=>T.reduce((D,G)=>D+(l(G)||0),0),b=(T,D)=>{const G=Ct(T,"d",{locale:r}),H=Ct(D,"d MMM",{locale:r});return`${G} - ${H}`};return e.jsxs("div",{className:`${_e.container} ${n||""}`,children:[e.jsxs("div",{className:_e.header,children:[e.jsx(v,{variant:"ghost",size:"icon-md",onClick:S,children:e.jsx(Kt,{})}),e.jsx("h3",{className:_e.monthLabel,children:N.charAt(0).toUpperCase()+N.slice(1)}),e.jsx(v,{variant:"ghost",size:"icon-md",onClick:u,children:e.jsx(vt,{})})]}),e.jsx("div",{className:_e.tableWrapper,children:e.jsxs("table",{className:_e.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:_e.weekCol,children:a.week}),a.days.map((T,D)=>e.jsx("th",{className:_e.dayCol,children:T},D)),e.jsx("th",{className:_e.totalCol,children:a.total})]})}),e.jsx("tbody",{children:C?Array.from({length:5}).map((T,D)=>e.jsxs("tr",{className:_e.skeletonRow,children:[e.jsx("td",{className:_e.td,children:e.jsx($,{className:_e.skeletonCell})}),Array.from({length:7}).map((G,H)=>e.jsx("td",{className:_e.td,children:e.jsx($,{className:_e.skeletonCell})},H)),e.jsx("td",{className:_e.td,children:e.jsx($,{className:_e.skeletonCell})})]},D)):q.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:9,className:_e.emptyState,children:a.noData})}):q.map((T,D)=>{const G=x(T.days);return e.jsxs("tr",{className:_e.row,children:[e.jsx("td",{className:`${_e.td} ${_e.weekCell}`,children:b(T.start,T.end)}),T.days.map((H,Z)=>{const m=l(H),R=m!==null&&m>8,E=Is(H,o);return e.jsx("td",{className:`
2                            ${_e.td} 
3                            ${_e.hoursCell} 
4                            ${E?"":_e.mutedCell}
5                            ${R?_e.overtimeCell:""}
6                          `,children:m!==null&&m>0?m.toFixed(1):"-"},Z)}),e.jsx("td",{className:`${_e.td} ${_e.totalCell}`,children:G>0?G.toFixed(1):"-"})]},D)})}),!C&&y&&e.jsx("tfoot",{children:e.jsxs("tr",{className:_e.footerRow,children:[e.jsx("td",{colSpan:8,className:_e.footerLabelCell,children:e.jsxs("div",{className:_e.monthlySummary,children:[e.jsx("span",{className:_e.summaryTitle,children:a.monthlyTotal}),e.jsxs("div",{className:_e.summaryBreakdown,children:[y.regularHours>0&&e.jsxs("span",{className:_e.regularBadge,children:[a.regular,": ",y.regularHours.toFixed(1),"h"]}),y.overtimeHours>
60&&e.jsxs("span",{className:_e.overtimeBadge,children:[a.overtime,": ",y.overtimeHours.toFixed(1),"h"]}),y.doubleTimeHours>0&&e.jsxs("span",{className:_e.doubleTimeBadge,children:[a.doubleTime,": ",y.doubleTimeHours.toFixed(1),"h"]}),y.statHolidayHours>0&&e.jsxs("span",{className:_e.holidayBadge,children:[a.holiday,": ",y.statHolidayHours.toFixed(1),"h"]})]})]})}),e.jsxs("td",{className:_e.footerTotalCell,children:[y.totalHours.toFixed(1),"h"]})]})})]})})]})};ie({userId:Ee.number().int().positive()});const zr=async(s,n)=>{const t=new URLSearchParams;t.set("userId",s.userId.toString());const a=await fetch(`/_api/payroll/hours-bank/statement?${t.toString()}`,{method:"GET",...n});if(!a.ok){const r=w.parse(await a.text());throw new Error(r?.error||"An unknown error occurred")}return w.parse(await a.text())},Hr=s=>nt({queryKey:["hours-bank-statement",s],queryFn:()=>{if(!s)throw new Error("userId is required to fetch hours bank statement");return zr({userId:s})},enabled:!!s}),Vr=ie({userId:B().int().positive(),startDate:I().datetime({offset:!0}).or(I().regex(/^\d{4}-\d{2}-\d{2}$/,"Must be YYYY-MM-DD")),endDate:I().datetime({offset:!0}).or(I().regex(/^\d{4}-\d{2}-\d{2}$/,"Must be YYYY-MM-DD")),language:Me(["fr","en"]).default("fr")}),Wr=async(s,n)=>{const t=Vr.parse(s),a=await fetch(`${rn()}/_api/hr/employee-report`,{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json"}});if(!a.ok){let r="Failed to generate report";try{r=w.parse(await a.text()).error}catch{}throw new Error(r)}return a.blob()};function Gr(){return Be({mutationFn:async s=>{const n=await Wr(s),t=window.URL.createObjectURL(n);if(/iPhone|iPad|iPod|Android/i.test(navigator.userAgent))window.open(t,"_blank"),setTimeout(()=>window.URL.revokeObjectURL(t),1e4);else{const r=document.createElement("a");r.href=t;const o=s.startDate.split("T")[0],d=s.endDate.split("T")[0];r.download=`rapport-heures-${s.userId}-${o}-${d}.pdf`,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(t),document.body.removeChild(r)}}})}const Ur="_container_aw05f_2",Qr="_header_aw05f_9",Kr="_headerTitle_aw05f_17",Yr="_backButton_aw05f_23",Xr="_title_aw05f_32",Jr="_subtitle_aw05f_40",Zr="_headerActions_aw05f_47",eo="_headerBadge_aw05f_54",to="_downloadBtn_aw05f_59",so="_downloadText_aw05f_64",ao="_popoverContent_aw05f_70",no="_reportForm_aw05f_74",ro="_reportTitle_aw05f_80",oo="_formGroup_aw05f_87",io="_formLabel_aw05f_93",lo="_select_aw05f_99",co="_customDatesRow_aw05f_118",uo="_dateInput_aw05f_127",mo="_generateBtn_aw05f_131",ho="_spinner_aw05f_136",po="_summaryRow_aw05f_150",_o="_statCard_aw05f_156",xo="_statIconWrapper_aw05f_167",jo="_statContent_aw05f_192",yo="_statLabel_aw05f_197",go="_statValue_aw05f_203",fo="_statSkeleton_aw05f_220",vo="_textSuccess_aw05f_227",bo="_textError_aw05f_231",No="_textMuted_aw05f_235",Co="_tableWrapper_aw05f_240",So="_table_aw05f_240",wo="_alignRight_aw05f_286",ko="_monoFont_aw05f_290",To="_dateCell_aw05f_296",Do="_dateMain_aw05f_303",Io="_timeSub_aw05f_307",$o="_descCell_aw05f_312",Eo="_descMain_aw05f_316",Bo="_descSub_aw05f_322",Po="_typeBadge_aw05f_328",qo="_balanceCell_aw05f_334",Ro="_emptyState_aw05f_339",Ao="_cellSkeleton_aw05f_346",Lo="_badgeSkeleton_aw05f_352",Fo="_colType_aw05f_373",k={container:Ur,header:Qr,headerTitle:Kr,backButton:Yr,title:Xr,subtitle:Jr,headerActions:Zr,headerBadge:eo,downloadBtn:to,downloadText:so,popoverContent:ao,reportForm:no,reportTitle:ro,formGroup:oo,formLabel:io,select:lo,customDatesRow:co,dateInput:uo,generateBtn:mo,spinner:ho,summaryRow:po,statCard:_o,statIconWrapper:xo,statContent:jo,statLabel:yo,statValue:go,statSkeleton:fo,textSuccess:vo,textError:bo,textMuted:No,tableWrapper:Co,table:So,alignRight:wo,monoFont:ko,dateCell:To,dateMain:Do,timeSub:Io,descCell:$o,descMain:Eo,descSub:Bo,typeBadge:Po,balanceCell:qo,emptyState:Ro,cellSkeleton:Ao,badgeSkeleton:Lo,colType:Fo},Oo={fr:{back:"Retour",title:"Relevé de banque d'heures",totalCredits:"Total Crédits",totalDebits:"Total Débits",currentBalance:"Solde Actuel",colDate:"Date",colDescription:"Description",colType:"Type",colCredit:"Crédit",colDebit:"Débit",colBalance:"Solde",typeAuto:"Auto",typeManual:"Manuel",noTransactions:"Aucune transaction trouvée pour cet employé.",hours:"h",systemNote:"Ajustement système",downloadReport:"Télécharger le rapport",generateReport:"Générer le rapport",period:"Période",thisWeek:"Cette semaine",thisMonth:"Ce mois",lastMonth:"Dernier mois",custom:"Personnalisé",startDate:"Date de début",endDate:"Date de fin",generating:"Génération en cours...",reportSuccess:"Rapport généré avec succès",reportError:"Erreur lors de la génération du rapport"},en:{back:"Back",title:"Hours Bank Statement",totalCredits:"Total Credits",totalDebits:"Total Debits",currentBalance:"Current Balance",colDate:"Date",colDe
6scription:"Description",colType:"Type",colCredit:"Credit",colDebit:"Debit",colBalance:"Balance",typeAuto:"Auto",typeManual:"Manual",noTransactions:"No transactions found for this employee.",hours:"h",systemNote:"System adjustment",downloadReport:"Download Report",generateReport:"Generate Report",period:"Period",thisWeek:"This week",thisMonth:"This month",lastMonth:"Last month",custom:"Custom",startDate:"Start Date",endDate:"End Date",generating:"Generating...",reportSuccess:"Report generated successfully",reportError:"Error generating report"}},_a=({userId:s,userName:n,onBack:t,className:a})=>{const{language:r}=de(),o=l=>Oo[r][l],d=r==="fr"?ra:oa,{data:h,isLoading:i,isError:c}=Hr(s),_=Gr(),[p,y]=g.useState(!1),[f,S]=g.useState("thisMonth"),[u,N]=g.useState(""),[C,q]=g.useState("");return e.jsxs("div",{className:`${k.container} ${a||""}`,children:[e.jsxs("div",{className:k.header,children:[e.jsxs("div",{className:k.headerTitle,children:[e.jsx(v,{variant:"ghost",size:"icon-md",onClick:t,className:k.backButton,title:o("back"),children:e.jsx(Vs,{size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:k.title,children:n}),e.jsx("p",{className:k.subtitle,children:o("title")})]})]}),e.jsxs("div",{className:k.headerActions,children:[h&&e.jsxs(Ne,{variant:h.summary.currentBalance>=0?"success":"destructive",className:k.headerBadge,children:[o("currentBalance"),": ",Ke(h.summary.currentBalance,{alwaysSign:!0})]}),e.jsxs(mt,{open:p,onOpenChange:y,children:[e.jsx(ht,{asChild:!0,children:e.jsxs(v,{variant:"outline",size:"sm",className:k.downloadBtn,children:[e.jsx(Ft,{size:16}),e.jsx("span",{className:k.downloadText,children:o("downloadReport")})]})}),e.jsx(pt,{align:"end",className:k.popoverContent,children:e.jsxs("div",{className:k.reportForm,children:[e.jsx("h3",{className:k.reportTitle,children:o("downloadReport")}),e.jsxs("div",{className:k.formGroup,children:[e.jsx("label",{className:k.formLabel,children:o("period")}),e.jsxs("select",{className:k.select,value:f,onChange:l=>S(l.target.value),children:[e.jsx("option",{value:"thisWeek",children:o("thisWeek")}),e.jsx("option",{value:"thisMonth",children:o("thisMonth")}),e.jsx("option",{value:"lastMonth",children:o("lastMonth")}),e.jsx("option",{value:"custom",children:o("custom")})]})]}),f==="custom"&&e.jsxs("div",{className:k.customDatesRow,children:[e.jsxs("div",{className:k.formGroup,children:[e.jsx("label",{className:k.formLabel,children:o("startDate")}),e.jsx(K,{type:"date",value:u,onChange:l=>N(l.target.value),className:k.dateInput})]}),e.jsxs("div",{className:k.formGroup,children:[e.jsx("label",{className:k.formLabel,children:o("endDate")}),e.jsx(K,{type:"date",value:C,onChange:l=>q(l.target.value),className:k.dateInput})]})]}),e.jsx(v,{variant:"primary",className:k.generateBtn,disabled:_.isPending||f==="custom"&&(!u||!C),onClick:()=>{const l=new Date;let x=l,b=l;if(f==="thisWeek")x=na(l,{weekStartsOn:1}),b=aa(l,{weekStartsOn:1});else if(f==="thisMonth")x=Gt(l),b=cs(l);else if(f==="lastMonth"){const T=ia(l);x=Gt(T),b=cs(T)}else if(f==="custom"){if(!u||!C)return;x=new Date(u+"T00:00:00"),b=new Date(C+"T23:59:59")}_.mutate({userId:s,startDate:x.toISOString(),endDate:b.toISOString(),language:r},{onSuccess:()=>{ne.success(o("reportSuccess")),y(!1)},onError:()=>{ne.error(o("reportError"))}})},children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ka,{size:16,className:k.spinner}),o("generating")]}):o("generateReport")})]})})]})]})]}),e.jsxs("div",{className:k.summaryRow,children:[e.jsxs("div",{className:k.statCard,children:[e.jsx("div",{className:k.statIconWrapper,"data-type":"credit",children:e.jsx(Et,{size:20})}),e.jsxs("div",{className:k.statContent,children:[e.jsx("span",{className:k.statLabel,children:o("totalCredits")}),i?e.jsx($,{className:k.statSkeleton}):e.jsx("span",{className:k.statValue,"data-type":"credit",children:Ke(h?.summary.totalCredits||0,{alwaysSign:!0})})]})]}),e.jsxs("div",{className:k.statCard,children:[e.jsx("div",{className:k.statIconWrapper,"data-type":"debit",children:e.jsx(Ta,{size:20})}),e.jsxs("div",{className:k.statContent,children:[e.jsx("span",{className:k.statLabel,children:o("totalDebits")}),i?e.jsx($,{className:k.statSkeleton}):e.jsx("span",{className:k.statValue,"data-type":"debit",children:Ke(h?.summary.totalDebits||0)})]})]}),e.jsxs("div",{className:k.statCard,children:[e.jsx("div",{className:k.statIconWrapper,"data-type":"balance",children:e.jsx(Ot,{size:20})}),e.jsxs("div",{className:k.statContent,children:[e.jsx("span",{className:k.statLabel,children:o("currentBalance")}),i?e.jsx($,{className:k.statSkeleton}):e.jsx("span",{className:`${k.statValue} ${(h?.summary.currentBalance||0)>=0?k.textSuccess:k.textError}`,children:Ke(h?.summary.currentBalance||0,{alwaysSign:!0})})]})]})]}),e.jsx("div",{className:k.tableWrapper,children:e.jsxs("table",{className:k.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:o("colDate")}),e.jsx("th",{children:o("colDescription")}),e.jsx("th",{className:k.colType,children:o("colType")}),e.jsx("th",{className:k.alignRight,children:o("colCredit")}),e.jsx("th",{className:k.alignRight,children:o("colDebit")}),e.jsx("th",{className:k.alignRight,children:o("colBalance")})]})}),e.jsx("tbody",{children:i?Array.from({length:5}).map((l,x)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx($,{className:k.cellSkeleton})}),e.jsx("td",{children:e.jsx($,{className:k.cellSkeleton})}),e.jsx("td",{className:k.colType,children:e.jsx($,{className:k.badgeSkeleton})}),e.jsx("td",{className:k.alignRight,children:e.jsx($,{className:k.cellSkeleton})}),e.jsx("td",{className:k.alignRight,children:e.jsx($,{className:k.cellSkeleton})}),e.jsx("td",{className:k.alignRight,children:e.jsx($,{className:k.cellSkeleton})})]},x)):c?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:k.emptyState,children:"Une erreur est survenue lors du chargement des données."})}):h?.entries.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:k.emptyState,children:o("noTransactions")})}):h?.entries.map(l=>e.jsxs("tr",{children:[e.jsxs("td",{className:k.dateCell,children:[e.jsx("span",{className:k.dateMain,children:Ct(new Date(l.createdAt),"dd MMM yyyy",{locale:d})}),e.jsx("span",{className:k.timeSub,children:Ct(new Date(l.createdAt),"HH:mm")}
6)]}),e.jsxs("td",{className:k.descCell,children:[e.jsx("div",{className:k.descMain,children:l.note||o("systemNote")}),e.jsxs("div",{className:k.descSub,children:["Par: ",l.createdByName]})]}),e.jsx("td",{className:k.colType,children:e.jsx(Ne,{variant:l.isAutomatic?"success":"default",className:k.typeBadge,children:l.isAutomatic?o("typeAuto"):o("typeManual")})}),e.jsx("td",{className:`${k.alignRight} ${k.monoFont}`,children:l.hours>0?e.jsx("span",{className:k.textSuccess,children:Ke(l.hours,{alwaysSign:!0})}):e.jsx("span",{className:k.textMuted,children:"-"})}),e.jsx("td",{className:`${k.alignRight} ${k.monoFont}`,children:l.hours<0?e.jsx("span",{className:k.textError,children:Ke(l.hours)}):e.jsx("span",{className:k.textMuted,children:"-"})}),e.jsx("td",{className:`${k.alignRight} ${k.monoFont} ${k.balanceCell}`,children:e.jsx("span",{className:l.runningBalance>=0?k.textSuccess:k.textError,children:Ke(l.runningBalance,{alwaysSign:!0})})})]},l.id))})]})})]})},Mo="_container_3ffzm_2",zo="_header_3ffzm_9",Ho="_titleRow_3ffzm_15",Vo="_backButton_3ffzm_21",Wo="_employeeName_3ffzm_31",Go="_tabsContainer_3ffzm_38",Uo="_tabsListWrapper_3ffzm_44",Qo="_contentArea_3ffzm_56",Ko="_tabContent_3ffzm_61",ct={container:Mo,header:zo,titleRow:Ho,backButton:Vo,employeeName:Wo,tabsContainer:Go,tabsListWrapper:Uo,contentArea:Qo,tabContent:Ko},Yo={fr:{week:"Semaine",month:"Mois",hoursBank:"Banque d'heures"},en:{week:"Week",month:"Month",hoursBank:"Hours Bank"}},Xo=({userId:s,userName:n,onBack:t,className:a})=>{const{language:r}=de(),o=Yo[r],[d,h]=g.useState("week");return e.jsxs("div",{className:`${ct.container} ${a||""}`,children:[e.jsx("div",{className:ct.header,children:e.jsxs("div",{className:ct.titleRow,children:[e.jsx(v,{variant:"ghost",size:"icon-md",onClick:t,className:ct.backButton,children:e.jsx(Vs,{size:20})}),e.jsx("h2",{className:ct.employeeName,children:n})]})}),e.jsxs(Dt,{value:d,onValueChange:h,className:ct.tabsContainer,children:[e.jsx("div",{className:ct.tabsListWrapper,children:e.jsxs(It,{children:[e.jsx(Fe,{value:"week",children:o.week}),e.jsx(Fe,{value:"month",children:o.month}),e.jsx(Fe,{value:"hoursBank",children:o.hoursBank})]})}),e.jsxs("div",{className:ct.contentArea,children:[e.jsx(Oe,{value:"week",className:ct.tabContent,children:e.jsx(ls,{userId:s})}),e.jsx(Oe,{value:"month",className:ct.tabContent,children:e.jsx(ds,{userId:s})}),e.jsx(Oe,{value:"hoursBank",className:ct.tabContent,children:e.jsx(_a,{userId:s,userName:n,onBack:()=>{}})})]})]})]})},Jo="_container_1t98m_2",Zo="_header_1t98m_10",ei="_title_1t98m_22",ti="_weekNav_1t98m_30",si="_weekLabel_1t98m_36",ai="_headerRight_1t98m_45",ni="_toggleContainer_1t98m_52",ri="_toggleLabel_1t98m_61",oi="_selectTrigger_1t98m_68",ii="_statsGrid_1t98m_73",li="_statCard_1t98m_79",ci="_cardIcon_1t98m_89",di="_cardContent_1t98m_101",ui="_cardTitle_1t98m_107",mi="_cardValue_1t98m_117",hi="_overtimeValue_1t98m_126",pi="_pendingValue_1t98m_130",_i="_chartCard_1t98m_135",xi="_chartHeader_1t98m_142",ji="_chartTitle_1t98m_150",yi="_chartContainer_1t98m_157",gi="_chartError_1t98m_161",fi="_chartEmpty_1t98m_168",$e={container:Jo,header:Zo,title:ei,weekNav:ti,weekLabel:si,headerRight:ai,toggleContainer:ni,toggleLabel:ri,selectTrigger:oi,statsGrid:ii,statCard:li,cardIcon:ci,cardContent:di,cardTitle:ui,cardValue:mi,overtimeValue:hi,pendingValue:pi,chartCard:_i,chartHeader:xi,chartTitle:ji,chartContainer:yi,chartError:gi,chartEmpty:fi},As={count:{label:"Count",color:"var(--primary)"}},Ht=({title:s,value:n,icon:t,isLoading:a,valueClassName:r})=>e.jsxs("div",{className:$e.statCard,children:[e.jsx("div",{className:$e.cardIcon,children:t}),e.jsxs("div",{className:$e.cardContent,children:[e.jsx("p",{className:$e.cardTitle,children:s}),a?e.jsx($,{style:{width:"80px",height:"1.75rem",marginTop:"0.25rem"}}):e.jsx("p",{className:`${$e.cardValue} ${r??""}`,children:n})]})]});function vi(s){const n=new Date(s);return n.setDate(s.getDate()+6),{startDate:s.toISOString().split("T")[0],endDate:n.toISOString().split("T")[0]}}function bi(s,n){const t=new Date(s);t.setDate(s.getDate()+6);const a=n==="fr"?"fr-CA":"en-US",r={day:"numeric",month:"short",year:"numeric"};return`${s.toLocaleDateString(a,r)} – ${t.toLocaleDateString(a,r)}`}function Ni(){const s=new Date,n=s.getDay(),t=n===0?-6:1-n,a=new Date(s);return a.setDate(s.getDate()+t),a.setHours(0,0,0,0),a}const Ci=({className:s})=>{const{t:n,language:t}=de(),[a,r]=g.useState(!0),[o,d]=g.useState(Ni),[h,i]=g.useState(null),[c,_]=g.useState(null),{data:p,isFetching:y}=gs({});g.useEffect(()=>{!a&&!h&&p?.periods&&p.periods.length>0&&i(p.periods[0].id)},[p,a,h]);const{startDate:f,endDate:S}=vi(o),{data:u,isFetching:N}=Fn({startDate:f,endDate:S}),C=(()=>
6{if(a)return{startDate:f,endDate:S};if(h)return{periodId:h}})(),{data:q,isFetching:l,error:x}=cn(C),b=()=>{d(xe=>{const Pe=new Date(xe);return Pe.setDate(Pe.getDate()-7),Pe})},T=()=>{d(xe=>{const Pe=new Date(xe);return Pe.setDate(Pe.getDate()+7),Pe})},D=u?.globalStats,G=u?.employees??[],H=u?.teamTotals??{dailyTotals:[0,0,0,0,0,0,0],weekTotal:0},Z=t==="fr"?"Récapitulatif Équipe":"Team Overview",m=t==="fr"?"Périodes de paie":"Pay Periods",R=t==="fr"?"Vue hebdomadaire":"Weekly view",E=t==="fr"?"Sélectionner une période":"Select a period",Ce=q?.statusCounts??[],Ge=l||!C;return c?e.jsx(Xo,{userId:c.userId,userName:c.userName,onBack:()=>_(null),className:s}):e.jsxs("div",{className:`${$e.container} ${s??""}`,children:[e.jsxs("div",{className:$e.header,children:[e.jsx("h2",{className:$e.title,children:Z}),e.jsxs("div",{className:$e.weekNav,children:[e.jsx(v,{variant:"outline",size:"icon-sm",onClick:b,"aria-label":"Previous week",children:e.jsx(Kt,{})}),e.jsx("span",{className:$e.weekLabel,children:bi(o,t)}),e.jsx(v,{variant:"outline",size:"icon-sm",onClick:T,"aria-label":"Next week",children:e.jsx(vt,{})})]}),e.jsxs("div",{className:$e.headerRight,children:[e.jsxs("div",{className:$e.toggleContainer,children:[e.jsx("span",{className:$e.toggleLabel,children:m}),e.jsx(on,{checked:a,onCheckedChange:r}),e.jsx("span",{className:$e.toggleLabel,children:R})]}),!a&&e.jsxs(we,{onValueChange:xe=>i(Number(xe)),value:h?.toString(),children:[e.jsx(ke,{className:$e.selectTrigger,disabled:y,children:e.jsx(Te,{placeholder:E})}),e.jsx(De,{children:p?.periods.map(xe=>e.jsxs(F,{value:xe.id.toString(),children:[new Date(xe.periodStart).toLocaleDateString(t==="fr"?"fr-CA":"en-US")," ","–"," ",new Date(xe.periodEnd).toLocaleDateString(t==="fr"?"fr-CA":"en-US")]},xe.id))})]})]})]}),e.jsxs("div",{className:$e.statsGrid,children:[e.jsx(Ht,{title:t==="fr"?"Total heures":"Total Hours",value:N?"—":(D?.totalHours??0).toFixed(1),icon:e.jsx(yt,{size:20}),isLoading:N}),e.jsx(Ht,{title:t==="fr"?"Heures supplémentaires":"Overtime Hours",value:N?"—":(D?.totalOvertime??0).toFixed(1),icon:e.jsx(dt,{size:20}),isLoading:N,valueClassName:$e.overtimeValue}),e.jsx(Ht,{title:t==="fr"?"En attente d'approbation":"Pending Approval",value:N?"—":D?.pendingApprovalCount??0,icon:e.jsx(Rt,{size:20}),isLoading:N,valueClassName:(D?.pendingApprovalCount??0)>0?$e.pendingValue:""}),e.jsx(Ht,{title:t==="fr"?"Employés actifs":"Active Employees",value:N?"—":D?.totalEmployees??0,icon:e.jsx(us,{size:20}),isLoading:N})]}),e.jsx(hr,{employees:G,teamTotals:H,isLoading:N,language:t,onEmployeeClick:(xe,Pe)=>_({userId:xe,userName:Pe})}),e.jsxs("div",{className:$e.chartCard,children:[e.jsxs("div",{className:$e.chartHeader,children:[e.jsx(Da,{size:18}),e.jsx("h4",{className:$e.chartTitle,children:n("hr_timesheet_status_overview")})]}),e.jsx("div",{className:$e.chartContainer,children:Ge?e.jsx($,{style:{height:"100%"}}):x?e.jsx("p",{className:$e.chartError,children:n("hr_chart_loading_error")}):Ce.length===0?e.jsxs("div",{className:$e.chartEmpty,children:[e.jsx(Ia,{size:32}),e.jsx("p",{children:t==="fr"?"Aucune donnée de statut pour cette période":"No status data for this period"})]}):e.jsx(pn,{config:{...As,count:{...As.count,label:n("common_count")}},children:e.jsxs(_n,{data:Ce,margin:{top:10,right:16,left:-20,bottom:4},children:[e.jsx(xn,{vertical:!1}),e.jsx(jn,{dataKey:"status",tickLine:!1,axisLine:!1,tick:{fontSize:12}}),e.jsx(yn,{tickLine:!1,axisLine:!1,tick:{fontSize:12}}),e.jsx(gn,{content:e.jsx(fn,{})}),e.jsx(vn,{dataKey:"count",fill:"var(--color-count)",radius:4})]})})})]})]})};ie({page:B().min(1).default(1),limit:B().min(1).max(100).default(20),userId:B().optional(),status:Me(["valid","expiring_soon","expired","pending"]).optional(),certificationType:I().optional(),search:I().optional()});const Si=async(s,n)=>{const t=new URLSearchParams;s.page&&t.set("page",s.page.toString()),s.limit&&t.set("limit",s.limit.toString()),s.userId&&t.set("userId",s.userId.toString()),s.status&&t.set("status",s.status),s.certificationType&&t.set("certificationType",s.certificationType),s.search&&t.set("search",s.search);const a=await fetch(`/_api/employee-certifications/list?${t.toString()}`,{method:"GET",...n,headers:{...n?.headers}});if(!a.ok){const r=w.parse(await a.text());throw new Error(r.error||"Failed to fetch employee certifications")}return w.parse(await a.text())};ie({});const wi=async s=>{const n=await fetch("/_api/employee-certifications/stats",{method:"GET",...s});if(!n.ok){const t=w.parse(await n.text());throw new Error(t.error||"Failed to fetch certification stats")}
6return w.parse(await n.text())};ie({userId:B(),certificationType:I(),customName:I().nullable().optional(),certificateNumber:I().nullable().optional(),issuingOrganization:I().nullable().optional(),dateObtained:lt().nullable().optional(),expiryDate:lt().nullable().optional(),reminderDaysBefore:B().nullable().optional(),documentUrl:I().nullable().optional(),notes:I().nullable().optional()});const ki=async(s,n)=>{const t=await fetch("/_api/employee-certifications/create",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json"}});if(!t.ok){const a=w.parse(await t.text());throw new Error(a.error||"Failed to create certification")}return w.parse(await t.text())};ie({id:B(),userId:B().optional(),certificationType:I().optional(),customName:I().nullable().optional(),certificateNumber:I().nullable().optional(),issuingOrganization:I().nullable().optional(),dateObtained:lt().nullable().optional(),expiryDate:lt().nullable().optional(),reminderDaysBefore:B().nullable().optional(),documentUrl:I().nullable().optional(),notes:I().nullable().optional()});const Ti=async(s,n)=>{const t=await fetch("/_api/employee-certifications/update",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json"}});if(!t.ok){const a=w.parse(await t.text());throw new Error(a.error||"Failed to update certification")}return w.parse(await t.text())};ie({id:B()});const Di=async(s,n)=>{const t=await fetch("/_api/employee-certifications/delete",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json"}});if(!t.ok){const a=w.parse(await t.text());throw new Error(a.error||"Failed to delete certification")}return w.parse(await t.text())},ts="employee-certifications-list",ss="employee-certifications-stats",Ii=s=>nt({queryKey:[ts,s],queryFn:()=>Si(s)}),$i=()=>nt({queryKey:[ss],queryFn:()=>wi()}),Ei=()=>{const s=Le();return Be({mutationFn:n=>ki(n),onSuccess:()=>{s.invalidateQueries({queryKey:[ts]}),s.invalidateQueries({queryKey:[ss]})}})},Bi=()=>{const s=Le();return Be({mutationFn:n=>Ti(n),onSuccess:()=>{s.invalidateQueries({queryKey:[ts]}),s.invalidateQueries({queryKey:[ss]})}})},Pi=()=>{const s=Le();return Be({mutationFn:n=>Di({id:n}),onSuccess:()=>{s.invalidateQueries({queryKey:[ts]}),s.invalidateQueries({queryKey:[ss]})}})},qi="_container_1j6vc_1",Ri="_statsGrid_1j6vc_7",Ai="_statCard_1j6vc_25",Li="_statCardActive_1j6vc_43",Fi="_statHeader_1j6vc_49",Oi="_statTitle_1j6vc_55",Mi="_statIconSuccess_1j6vc_61",zi="_statIconWarning_1j6vc_67",Hi="_statIconDestructive_1j6vc_73",Vi="_statIconSecondary_1j6vc_79",Wi="_statValue_1j6vc_85",Gi="_toolbar_1j6vc_92",Ui="_filters_1j6vc_106",Qi="_searchWrapper_1j6vc_120",Ki="_searchIcon_1j6vc_127",Yi="_searchInput_1j6vc_136",Xi="_filterSelect_1j6vc_140",Ji="_tableContainer_1j6vc_150",Zi="_table_1j6vc_150",el="_strongCell_1j6vc_188",tl="_actionsCell_1j6vc_192",sl="_deleteButton_1j6vc_197",al="_emptyState_1j6vc_206",nl="_pagination_1j6vc_213",rl="_pageInfo_1j6vc_221",ol="_modalContent_1j6vc_228",il="_formGrid_1j6vc_233",ll="_fullWidthItem_1j6vc_250",W={container:qi,statsGrid:Ri,statCard:Ai,statCardActive:Li,statHeader:Fi,statTitle:Oi,statIconSuccess:Mi,statIconWarning:zi,statIconDestructive:Hi,statIconSecondary:Vi,statValue:Wi,toolbar:Gi,filters:Ui,searchWrapper:Qi,searchIcon:Ki,searchInput:Yi,filterSelect:Xi,tableContainer:Ji,table:Zi,strongCell:el,actionsCell:tl,deleteButton:sl,emptyState:al,pagination:nl,pageInfo:rl,modalContent:ol,formGrid:il,fullWidthItem:ll},Ns={fr:{title:"Certifications et Formations",searchPlaceholder:"Rechercher un employé...",allTypes:"Tous les types",allStatuses:"Tous les statuts",add:"Ajouter",employee:"Employé",type:"Type",number:"Numéro",organization:"Organisation",obtained:"Obtenu le",expires:"Expire le",status:"Statut",actions:"Actions",valid:"Valide",expiring_soon:"Expire bientôt",expired:"Expiré",pending:"En attente",createTitle:"Ajouter une certification",editTitle:"Modifier la certification",deleteTitle:"Supprimer la certification",deleteConfirm:"Êtes-vous sûr de vouloir supprimer cette certification ? Cette action est irréversible.",cancel:"Annuler",save:"Enregistrer",delete:"Supprimer",noData:"Aucune certification trouvée.",prev:"Précédent",next:"Suivant",customName:"Nom personnalisé (si Autre)",documentUrl:"URL du document",reminderDays:"Jours de rappel avant expiration",notes:"Notes",selectEmployee:"Sélectionner un employé...",selectType:"Sélectionner un type...",page:"Page",of:"sur"},en:{title:"Certifications and Training",searchPlaceholder:"Search employee...",allTypes:"All types",allStatuses:"All statuses",add:"Add",employee:"Employee",type:"Type",number:"Number",organization:"Organization",obtained:"Obtained on",expires:"Expires on",status:"Status",actions:"Actions",valid:"Valid",expiring_soon:"Expiring soon",expired:"Expired",pending:"Pending",createTitle:"Add Certification",editTitle:"Edit Certification",deleteTitle:"Delete Certification",deleteConfirm:"Are you sure you want to delete this certification? This action cannot be undone.",cancel:"Cancel",save:"Save",delete:"Delete",noData:"No certifications foun
6d.",prev:"Previous",next:"Next",customName:"Custom Name (if Other)",documentUrl:"Document URL",reminderDays:"Reminder days before expiry",notes:"Notes",selectEmployee:"Select an employee...",selectType:"Select a type...",page:"Page",of:"of"}},Cs={asp_construction:{fr:"ASP Construction",en:"ASP Construction"},simdut:{fr:"SIMDUT/SGH",en:"WHMIS/GHS"},first_aid:{fr:"Premiers soins",en:"First Aid"},driving_license:{fr:"Permis de conduire",en:"Driver's License"},ccq_card:{fr:"Carte CCQ",en:"CCQ Card"},rbq_license:{fr:"Licence RBQ",en:"RBQ License"},electrical:{fr:"Électricité",en:"Electrical"},gas:{fr:"Gaz",en:"Gas"},welding:{fr:"Soudure",en:"Welding"},plumbing:{fr:"Plomberie",en:"Plumbing"},crane_operator:{fr:"Opérateur de grue",en:"Crane Operator"},scaffolding:{fr:"Échafaudage",en:"Scaffolding"},confined_space:{fr:"Espace clos",en:"Confined Space"},working_at_height:{fr:"Travail en hauteur",en:"Working at Height"},hazmat:{fr:"Matières dangereuses",en:"Hazardous Materials"},equipment_operator:{fr:"Opérateur d'équipement",en:"Equipment Operator"},other:{fr:"Autre",en:"Other"}},xa=ie({userId:I().min(1,"L'employé est requis / Employee is required"),certificationType:I().min(1,"Le type est requis / Type is required"),customName:I().optional(),certificateNumber:I().optional(),issuingOrganization:I().optional(),dateObtained:I().optional(),expiryDate:I().optional(),reminderDaysBefore:I().optional(),documentUrl:I().optional(),notes:I().optional()}),cl=()=>{const{language:s}=de(),n=Ns[s],[t,a]=g.useState(1),r=10,[o,d]=g.useState(""),h=ln(o,300),[i,c]=g.useState("__empty"),[_,p]=g.useState("__empty"),[y,f]=g.useState(!1),[S,u]=g.useState(null),[N,C]=g.useState(null),q=i==="__empty"?void 0:i,l=_==="__empty"?void 0:_,{data:x,isFetching:b}=Ii({page:t,limit:r,search:h||void 0,status:q,certificationType:l}),{data:T}=$i(),D=Pi();Qe.useEffect(()=>{a(1)},[h,i,_]);const G=()=>{N&&D.mutate(N,{onSuccess:()=>{C(null)}})},H=E=>{switch(E){case"valid":return e.jsx(Ne,{variant:"success",children:n.valid});case"expiring_soon":return e.jsx(Ne,{variant:"warning",children:n.expiring_soon});case"expired":return e.jsx(Ne,{variant:"destructive",children:n.expired});case"pending":return e.jsx(Ne,{variant:"secondary",children:n.pending});default:return e.jsx(Ne,{variant:"outline",children:E})}},Z=E=>Cs[E]?.[s]||E,m=E=>E?new Intl.DateTimeFormat(s==="fr"?"fr-CA":"en-CA",{year:"numeric",month:"short",day:"numeric"}).format(new Date(E)):"-",R=E=>{c(i===E?"__empty":E)};return e.jsxs("div",{className:W.container,children:[e.jsxs("div",{className:W.statsGrid,children:[e.jsxs("div",{className:`${W.statCard} ${i==="valid"?W.statCardActive:""}`,onClick:()=>R("valid"),children:[e.jsxs("div",{className:W.statHeader,children:[e.jsx("span",{className:W.statTitle,children:n.valid}),e.jsx(ms,{className:W.statIconSuccess})]}),e.jsx("div",{className:W.statValue,children:T?.counts.valid??0})]}),e.jsxs("div",{className:`${W.statCard} ${i==="expiring_soon"?W.statCardActive:""}`,onClick:()=>R("expiring_soon"),children:[e.jsxs("div",{className:W.statHeader,children:[e.jsx("span",{className:W.statTitle,children:n.expiring_soon}),e.jsx(yt,{className:W.statIconWarning})]}),e.jsx("div",{className:W.statValue,children:T?.counts.expiring_soon??0})]}),e.jsxs("div",{className:`${W.statCard} ${i==="expired"?W.statCardActive:""}`,onClick:()=>R("expired"),children:[e.jsxs("div",{className:W.statHeader,children:[e.jsx("span",{className:W.statTitle,children:n.expired}),e.jsx(dt,{className:W.statIconDestructive})]}),e.jsx("div",{className:W.statValue,children:T?.counts.expired??0})]}),e.jsxs("div",{className:`${W.statCard} ${i==="pending"?W.statCardActive:""}`,onClick:()=>R("pending"),children:[e.jsxs("div",{className:W.statHeader,children:[e.jsx("span",{className:W.statTitle,children:n.pending}),e.jsx(Ws,{className:W.statIconSecondary})]}),e.jsx("div",{className:W.statValue,children:T?.counts.pending??0})]})]}),e.jsxs("div",{className:W.toolbar,children:[e.jsxs("div",{className:W.filters,children:[e.jsxs("div",{className:W.searchWrapper,children:[e.jsx(Gs,{className:W.searchIcon,size:18}),e.jsx(K,{placeholder:n.searchPlaceholder,value:o,onChange:E=>d(E.target.value),className:W.searchInput})]}),e.jsxs(we,{value:_,onValueChange:p,children:[e.jsx(ke,{className:W.filterSelect,children:e.jsx(Te,{placeholder:n.allTypes})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:n.allTypes}),ys.map(E=>e.jsx(F,{value:E,children:Z(E)},E))]})]}),e.jsxs(we,{value:i,onValueChange:c,children:[e.jsx(ke,{className:W.filterSelect,children:e.jsx(Te,{placeholder:n.allStatuses})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:n.allStatuses}),e.jsx(F,{value:"valid",children:n.valid}),e.jsx(F,{value:"expiring_soon",children:n.expiring_soon}),e.jsx(F,{value:"expired",children:n.expired}),e.jsx(F,{value:"pending",children:n.pending})]})]})]}),e.jsxs(v,{onClick:()=>f(!0),variant:"primary",children:[e.jsx(hs,{size:16})," ",n.add]})]}),e.jsx("div",{className:W.tableContainer,children:e.jsxs("table",{className:W.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:n.employee}),e.jsx("th",{children:n.type}),e.jsx("th",{children:n.number}),e.jsx("th",{children:n.organization}),e.jsx("th",{children:n.obtained}),e.jsx("th",{children:n.expires}),e.jsx("th",{children:n.status}),e.jsx("th",{className:W.actionsCell,children:n.actions})]})}),e.jsx("tbody",{children:b?Array.from({length:5}).map((E,Ce)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx($,{})}),e.jsx("td",{children:e.jsx($,{})}),e.jsx("td",{children:e.jsx($,{})}),e.jsx("td",{children:e.jsx($,{})}),e.jsx("td",{children:e.jsx($,{})}),e.jsx("td",{children:e.jsx($,{})}),e.jsx("td",{children:e.jsx($,{})}),e.jsx("td",{children:e.jsx($,{})})]},Ce)):x?.items.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:W.emptyState,children:n.noData})}):x?.items.map(E=>e.jsxs("tr",{children:[e.jsx("td",{className:W.strongCell,children:E.userName||"-"}),e.jsxs("td",{children:[Z(E.certificationType),E.certificationType==="other"&&E.customName&&` (${E.customName})`]}),e.jsx("td",{children:E.certificateNumber||"-"}),e.jsx("td",{children:E.issuingOrganization||"-"}),e.jsx("td",{children:m(E.dateObtained)}),e.jsx("td",{children:m(E.expiryDate)}),e.jsx("td",{children:H(E.status)}),e.jsxs("td",{className:W.actionsCell,children:[e.jsx(v,{variant:"ghost",size:"icon-sm",onClick:()=>u(E),children:e.jsx($a,{size:16})}),e.jsx(v,{variant:"ghost",size:"icon-sm",onClick:()=>C(E.id),className:W.deleteButton,children:e.jsx(Yt,{size:16})})]})]},E.id))})]})}),x&&x.totalPages>1&&e.jsxs("div",{className:W.pagination,children:[e.jsx(v,{variant:"outline",size:"sm",onClick:()=>a(E=>Math.max(1,E-1)),disabled:t===1||b,children:n.prev}),e.jsxs("span",{className:W.pageInfo,children:[n.page," ",t," ",n.of," ",x.totalPages]}),e.jsx(v,{variant:"outline",size:"sm",onClick:()=>a(E=>Math.min(x.totalPages,E+1)),disabled:t===x.totalPages||b,children:n.next})]}),y&&e.jsx(dl,{onClose:()=>f(!1)}),S&&e.jsx(ul,{certification:S,onClose:()=>u(null)}),N&&e.jsx(Ye,{open:!0,onOpenChange:E=>!E&&C(null),children:e.jsxs(Xe,{children:[e.jsx(ot,{children:e.jsx(Je,{children:n.deleteTitle})}),e.jsx($t,{children:n.deleteConfirm}),e.jsxs(ft,{children:[e.jsx(v,{variant:"outline",onClick:()=>C(null),children:n.cancel}),e.jsx(v,{variant:"destructive",onClick:G,disabled:D.isPending,children:n.delete})]})]})})]})},dl=({onClose:s})=>{const{language:n}=de(),t=Ns[n],{data:a}=la(),r=Ei(),o=Pt({schema:xa,defaultValues:{userId:"",certificationType:"",customName:"",certificateNumber:"",issuingOrganization:"",dateObtained:"",expiryDate:"",reminderDaysBefore:"",documentUrl:"",notes:""}}),d=i=>{r.mutate({userId:parseInt(i.userId,10),certificationType:i.certificationType,customName:i.customName||null,certificateNumber:i.certificateNumber||null,issuingOrganization:i.issuingOrganization||null,dateObtained:i.dateObtained?new Date(i.dateObtained):null,expiryDate:i.expiryDate?new Date(i.expiryDate):null,reminderDaysBefore:i.reminderDaysBefore?parseInt(i.reminderDaysBefore,10):null,documentUrl:i.documentUrl||null,notes:i.notes||null},{onSuccess:()=>s()})},h=i=>Cs[i]?.[n]||i;return e.jsx(Ye,{open:!0,onOpenChange:i=>!i&&s(),children:e.jsxs(Xe,{className:W.modalContent,children:[e.jsx(ot,{children:e.jsx(Je,{children:t.createTitle})}),e.jsx(qt,{...o,children:e.jsxs("form",{onSubmit:o.handleSubmit(d),className:W.formGrid,children:[e.jsxs(J,{name:"userId",children:[e.jsx(re,{children:t.employee}),e.jsx(ee,{children:e.jsxs(we,{value:o.values.userId||"__empty",onValueChange:i=>o.setValues(c=>({...c,userId:i==="__empty"?"":i})),children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:t.selectEmployee})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:t.selectEmployee}),a?.map(i=>e.jsx(F,{value:i.id.toString(),children:i.displayName},i.id))]})]})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"certificationType",children:[e.jsx(re,{children:t.type}),e.jsx(ee,{children:e.jsxs(we,{value:o.values.certificationType||"__empty",onValueChange:i=>o.setValues(c=>({...c,certificationType:i==="__empty"?"":i})),children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:t.selectType})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:t.selectType}),ys.map(i=>e.jsx(F,{value:i,children:h(i)},i))]})]})}),e.jsx(oe,{})]}),o.values.certificationType==="other"&&e.jsxs(J,{name:"customName",children:[e.jsx(re,{children:t.customName}),e.jsx(ee,{children:e.jsx(K,{value:o.values.customName,onChange:i=>o.setValues(c=>({...c,customName:i.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"certificateNumber",children:[e.jsx(re,{children:t.number}),e.jsx(ee,{children:e.jsx(K,{value:o.values.certificateNumber,onChange:i=>o.setValues(c=>({...c,certificateNumber:i.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"issuingOrganization",children:[e.jsx(re,{children:t.organization}),e.jsx(ee,{children:e.jsx(K,{value:o.values.issuingOrganization,onChange:i=>o.setValues(c=>({...c,issuingOrganization:i.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"dateObtained",children:[e.jsx(re,{children:t.obtained}),e.jsx(ee,{children:e.jsx(K,{type:"date",value:o.values.dateObtained,onChange:i=>o.setValues(c=>({...c,dateObtained:i.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"expiryDate",children:[e.jsx(re,{children:t.expires}),e.jsx(ee,{children:e.jsx(K,{type:"date",value:o.values.expiryDate,onChange:i=>o.setValues(c=>({...c,expiryDate:i.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"reminderDaysBefore",children:[e.jsx(re,{children:t.reminderDays}),e.jsx(ee,{children:e.jsx(K,{type:"number",min:"0",value:o.values.reminderDaysBefore,onChange:i=>o.setValues(c=>({...c,reminderDaysBefore:i.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"documentUrl",className:W.fullWidthItem,children:[e.jsx(re,{children:t.documentUrl}),e.jsx(ee,{children:e.jsx(K,{type:"url",value:o.values.documentUrl,onChange:i=>o.setValues(c=>({...c,documentUrl:i.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"notes",className:W.fullWidthItem,children:[e.jsx(re,{children:t.notes}),e.jsx(ee,{children:e.jsx(K,{value:o.values.notes,onChange:i=>o.setValues(c=>({...c,notes:i.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(ft,{className:W.fullWidthItem,children:[e.jsx(v,{variant:"outline",onClick:s,type:"button",children:t.cancel}),e.jsx(v,{variant:"primary",type:"submit",disabled:r.isPending,children:t.save})]})]})})]})})},ul=({certification:s,onClose:n})=>{const{language:t}=de(),a=Ns[t],{data:r}=la(),o=Bi(),d=Pt({schema:xa,defaultValues:{userId:s.userId.toString(),certificationType:s.certificationType,customName:s.customName||"",certificateNumber:s.certificateNumber||"",issuingOrganization:s.issuingOrganization||"",dateObtained:s.dateObtained?new Date(s.dateObtained).toISOString().split("T")[0]:"",expiryDate:s.expiryDate?new Date(s.expiryDate).toISOString().split("T")[0]:"",reminderDaysBefore:s.reminderDaysBefore?.toString()||"",documentUrl:s.documentUrl||"",notes:s.notes||""}}),h=c=>{o.mutate({id:s.id,userId:parseInt(c.userId,10),certificationType:c.certificationType,customName:c.customName||null,certificateNumber:c.certificateNumber||null,issuingOrganization:c.issuingOrganization||null,dateObtained:c.dateObtained?new Date(c.dateObtained):null,expiryDate:c.expiryDate?new Date(c.expiryDate):null,reminderDaysBefore:c.reminderDaysBefore?parseInt(c.reminderDaysBefore,10):null,documentUrl:c.documentUrl||null,notes:c.notes||null},{onSuccess:()=>n()})},i=c=>Cs[c]?.[t]||c;return e.jsx(Ye,{open:!0,onOpenChange:c=>!c&&n(),children:e.jsxs(Xe,{className:W.modalContent,children:[e.jsx(ot,{children:e.jsx(Je,{children:a.editTitle})}),e.jsx(qt,{...d,children:e.jsxs("form",{onSubmit:d.handleSubmit(h),className:W.formGrid,children:[e.jsxs(J,{name:"userId",children:[e.jsx(re,{children:a.employee}),e.jsx(ee,{children:e.jsxs(we,{value:d.values.userId||"__empty",onValueChange:c=>d.setValues(_=>({..._,userId:c==="__empty"?"":c})),children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:a.selectEmployee})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:a.selectEmployee}),r?.map(c=>e.jsx(F,{value:c.id.toString(),children:c.displayName},c.id))]})]})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"certificationType",children:[e.jsx(re,{children:a.type}),e.jsx(ee,{children:e.jsxs(we,{value:d.values.certificationType||"__empty",onValueChange:c=>d.setValues(_=>({..._,certificationType:c==="__empty"?"":c})),children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:a.selectType})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:a.selectType}),ys.map(c=>e.jsx(F,{value:c,children:i(c)},c))]})]})}),e.jsx(oe,{})]}),d.values.certificationType==="other"&&e.jsxs(J,{name:"customName",children:[e.jsx(re,{children:a.customName}),e.jsx(ee,{children:e.jsx(K,{value:d.values.customName,onChange:c=>d.setValues(_=>({..._,customName:c.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"certificateNumber",children:[e.jsx(re,{children:a.number}),e.jsx(ee,{children:e.jsx(K,{value:d.values.certificateNumber,onChange:c=>d.setValues(_=>({..._,certificateNumber:c.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"issuingOrganization",children:[e.jsx(re,{children:a.organization}),e.jsx(ee,{children:e.jsx(K,{value:d.values.issuingOrganization,onChange:c=>d.setValues(_=>({..._,issuingOrganization:c.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"dateObtained",children:[e.jsx(re,{children:a.obtained}),e.jsx(ee,{children:e.jsx(K,{type:"date",value:d.values.dateObtained,onChange:c=>d.setValues(_=>({..._,dateObtained:c.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"expiryDate",children:[e.jsx(re,{children:a.expires}),e.jsx(ee,{children:e.jsx(K,{type:"date",value:d.values.expiryDate,onChange:c=>d.setValues(_=>({..._,expiryDate:c.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"reminderDaysBefore",children:[e.jsx(re,{children:a.reminderDays}),e.jsx(ee,{children:e.jsx(K,{type:"number",min:"0",value:d.values.reminderDaysBefore,onChange:c=>d.setValues(_=>({..._,reminderDaysBefore:c.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"documentUrl",className:W.fullWidthItem,children:[e.jsx(re,{children:a.documentUrl}),e.jsx(ee,{children:e.jsx(K,{type:"url",value:d.values.documentUrl,onChange:c=>d.setValues(_=>({..._,documentUrl:c.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"notes",className:W.fullWidthItem,children:[e.jsx(re,{children:a.notes}),e.jsx(ee,{children:e.jsx(K,{value:d.values.notes,onChange:c=>d.setValues(_=>({..._,notes:c.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(ft,{className:W.fullWidthItem,children:[e.jsx(v,{variant:"outline",onClick:n,type:"button",children:a.cancel}),e.jsx(v,{variant:"primary",type:"submit",disabled:o.isPending,children:a.save})]})]})})]})})},ml="_historyButton_lfy92_1",hl="_clickableBadge_lfy92_12",Ls={historyButton:ml,clickableBadge:hl},ja=({entry:s,className:n})=>{const{language:t}=de(),[a,r]=g.useState(!1),o=t==="en"?"Added manually by employee":"Ajouté manuellement par l'employé",d=t==="en"?"Corrected by employee":"Corrigé par l'employé",h=s.punchReviewReason?.trim(),i=s.revisionCount>0&&s.lastModifiedByUserId===s.userId;return e.jsxs(e.Fragment,{children:[s.addedInPunchReview&&(h?e.jsxs(wt,{children:[e.jsx(kt,{asChild:!0,children:e.jsx("span",{className:n,tabIndex:0,"aria-label":`${o}: ${h}`,children:e.jsx(Ne,{variant:"warning",children:o})})}),e.jsx(Tt,{children:h})]}):e.jsx(Ne,{variant:"warning",className:n,children:o})),i&&e.jsxs(e.Fragment,{children:[e.j
6sx("button",{type:"button",className:`${Ls.historyButton} ${n||""}`,onClick:()=>r(!0),"aria-label":d,children:e.jsx(Ne,{variant:"secondary",className:Ls.clickableBadge,children:d})}),e.jsx($n,{timeEntryId:s.id,isOpen:a,onClose:()=>r(!1)})]})]})},pl="_approvalInterface_fe5b2_1",_l="_header_fe5b2_11",xl="_actions_fe5b2_27",jl="_approveButton_fe5b2_32",yl="_rejectButton_fe5b2_42",gl="_notesSection_fe5b2_51",fl="_tableContainer_fe5b2_55",vl="_table_fe5b2_55",bl="_tableRow_fe5b2_84",Nl="_groupRow_fe5b2_92",Cl="_subRow_fe5b2_101",Sl="_groupUserCell_fe5b2_110",wl="_expandButton_fe5b2_117",kl="_userName_fe5b2_136",Tl="_groupEditButton_fe5b2_141",Dl="_projectSummary_fe5b2_151",Il="_totalHours_fe5b2_156",$l="_subCheckbox_fe5b2_160",El="_subCell_fe5b2_166",Bl="_subCellHours_fe5b2_172",Pl="_hoursWithWarning_fe5b2_177",ql="_unusualDurationBadge_fe5b2_183",Rl="_subEntryType_fe5b2_187",Al="_checkboxColumn_fe5b2_196",Ll="_actionsColumn_fe5b2_201",Fl="_actionButtons_fe5b2_206",Ol="_ccqInfoWrapper_fe5b2_212",Ml="_warningIcon_fe5b2_222",zl="_ccqInfoText_fe5b2_227",Hl="_noEntries_fe5b2_234",pe={approvalInterface:pl,header:_l,actions:xl,approveButton:jl,rejectButton:yl,notesSection:gl,tableContainer:fl,table:vl,tableRow:bl,groupRow:Nl,subRow:Cl,groupUserCell:Sl,expandButton:wl,userName:kl,groupEditButton:Tl,projectSummary:Dl,totalHours:Il,subCheckbox:$l,subCell:El,subCellHours:Bl,hoursWithWarning:Pl,unusualDurationBadge:ql,subEntryType:Rl,checkboxColumn:Al,actionsColumn:Ll,actionButtons:Fl,ccqInfoWrapper:Ol,warningIcon:Ml,ccqInfoText:zl,noEntries:Hl},Vl=({group:s,isExpanded:n,onToggleExpand:t,selectedIds:a,onSelectionChange:r,onGroupSelectionChange:o,onModify:d,onOpenEditor:h,onViewDay:i,language:c,isCcqApplicable:_,t:p})=>{const y=s.entries.length>0&&s.entries.every(l=>a.includes(l.id)),f=l=>l==="foreman_approved"?e.jsx(Ne,{variant:"secondary",children:c==="en"?"Foreman Approved":"Approuvé CM"}):l==="submitted"?e.jsx(Ne,{variant:"outline",children:c==="en"?"Submitted (No CM)":"Soumis (sans CM)"}):e.jsx(Ne,{variant:"default",children:l}),S=l=>{const x=[];if(l.tradeNameFr&&x.push(c==="en"&&l.tradeNameEn?l.tradeNameEn:l.tradeNameFr),l.ccqWorkerLevel&&(l.ccqWorkerLevel==="compagnon"?x.push(p("ccq_level_compagnon")):l.ccqWorkerLevel==="occupation"?x.push(p("ccq_level_occupation")):l.ccqWorkerLevel.startsWith("apprentice_")?x.push(`${p("ccq_level_apprentice")} ${l.ccqWorkerLevel.split("_")[1]}`):x.push(l.ccqWorkerLevel)),l.ccqSector){const b={civil_engineering:p("ccq_sector_civil"),industrial:p("ccq_sector_industrial"),institutional_commercial:p("ccq_sector_institutional"),residential_heavy:p("ccq_sector_residential_heavy"),residential_light:p("ccq_sector_residential_light")};b[l.ccqSector]&&x.push(b[l.ccqSector])}if(l.shiftType){const b={day:p("ccq_shift_day"),evening:p("ccq_shift_evening"),night:p("ccq_shift_night")};b[l.shiftType]&&x.push(b[l.shiftType])}return x.join(" • ")},u=s.entries.length,N=new Set(s.entries.map(l=>l.projectId).filter(Boolean)).size,C=c==="en"?`${u} entr${u!==1?"ies":"y"} / ${N} project${N!==1?"s":""}`:`${u} entrée${u!==1?"s":""} / ${N} projet${N!==1?"s":""}`,q=l=>l?new Date(l).toLocaleTimeString(c,{hour:"2-digit",minute:"2-digit"}):"";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`${pe.tableRow} ${pe.groupRow}`,children:[e.jsx("td",{children:e.jsx(Bt,{checked:y,onCheckedChange:l=>o(s,l===!0),"aria-label":c==="en"?`Select group for ${s.userName}`:`Sélectionner le groupe pour ${s.userName}`})}),e.jsx("td",{children:e.jsxs("div",{className:pe.groupUserCell,children:[e.jsx("button",{type:"button",className:pe.expandButton,onClick:t,"aria-label":c==="en"?"Toggle details":"Basculer les détails",children:n?e.jsx(Xt,{size:16}):e.jsx(vt,{size:16})}),e.jsx("span",{className:pe.userName,onClick:t,children:s.userName}),e.jsx(v,{size:"icon-sm",variant:"ghost",className:pe.groupEditButton,onClick:l=>{l.stopPropagation(),i(s)},title:c==="en"?"View timeline":"Voir la ligne du temps","aria-label":c==="en"?`View timeline for ${s.userName}`:`Voir la ligne du temps pour ${s.userName}`,children:e.jsx(ps,{size:14})}),e.jsx(v,{size:"icon-sm",variant:"ghost",className:pe.groupEditButton,onClick:l=>{l.stopPropagation(),h(s)},title:c==="en"?"Edit day":"Modifier la journée","aria-label":c==="en"?`Edit day for ${s.userName}`:`Modifier la journée pour ${s.userName}`,children:e.jsx(Vt,{size:14})})]})}),e.jsx("td",{children:e.jsx("span",{className:pe.projectSummary,children:C})}),e.jsx("td",{children:vs(s.date)}),e.jsx("td",{className:pe.totalHours,children:Ut(s.totalHours)}),e.jsx("td",{children:f(s.status)}),_&&e.jsx("td",{}),e.jsx("td",{})]}),n&&s.entries.map(l=>e.jsxs("tr",{className:`${pe.tableRow} ${pe.subRow}`,children:[e.jsx("td",{children:e.jsx("div",{className:pe.subCheckbox,children:e.jsx(Bt,{checked:a.includes(l.id),onCheckedChange:x=>r(l.id,x===!0),"aria-label":c==="en"?`Select entry ${l.id}`:`Sélectionner l'entrée ${l.id}`})})}),e.jsx("td",{className:pe.subCell,children:e.jsx("span",{className:pe.subEntryType,children:l.entryType==="travel"?c==="en"?"Travel":"Déplacement":l.entryType==="client_work"?c==="en"?"Client Work":"Travail Client":l.entryType})}),e.jsx("td",{className:pe.subCell,children:l.projectName||"-"}),e.jsxs("td",{className:pe.subCell,children:[q(l.startTime),l.endTime?` - ${q(l.endTime)}`:""]}),e.jsx("td",{className:pe.subCellHours,children:e.jsxs("div",{className:pe.hoursWithWarning,children:[Ut(l.hoursWorked),l.hoursWorked>12&&e.jsx(Ne,{variant:"warning",className:pe.unusualDurationBadge,children:c==="en"?"Unusual duration (>12 h) — forgotten punch?":"Durée inhabituelle (>12 h) — punch oublié ?"}),e.jsx(ja,{entry:l})]})}),e.jsx("td",{}),_&&e.jsx("td",{className:pe.subCell,children:e.jsxs("div",{className:pe.ccqInfoWrapper,children:[l.entryType==="client_work"&&(!l.ccqTradeId||!l.ccqWorkerLevel||!l.ccqSector)&&e.jsx("span",{title:c==="en"?"Missing CCQ information":"Informations CCQ manquantes",children:e.jsx(dt,{size:14,className:pe.warningIcon})}),e.jsx("span",{className:pe.ccqInfoText,title:S(l),children:S(l)||(c==="en"?"No CCQ data":"Aucune donnée CCQ")})]})}),e.jsx("td",{children:e.jsx("div",{className:pe.actionButtons,children:e.jsx(v,{size:"icon-sm",variant:"ghost",onClick:()=>d(l),"aria-label":c==="en"?`Modify entry for ${l.userName}`:`Modifier l'entrée pour ${l.userName}`,children:e.jsx(Vt,{size:14})})})})]},l.id))]})},Wl=({className:s})=>{const{t:n,language:t}=de(),{isCcqApplicable:a}=da(),[r,o]=g.useState([]),[d,h]=g.useState(new Set),[i,c]=g.useState(""),[_,p]=g.useState(!1),[y,f]=g.useState(null),[S,u]=g.useState(null),[N,C]=g.useState(!1),[q,l]=g.useState(null),[x,b]=g.useState(!1),{data:T,isFetching:D,refetch:G}=At({status:"foreman_approved",page:1}),{data:H,isFetching:Z,refetch:m}=At({status:"submitted",page:1}),R=bn(),E=g.useMemo(()=>{const M=new Map,U=T?.entries??[],ge=H?.entries??[];return[...U,...ge].forEach(se=>{const j=se.date?new Date(se.date).toISOString().split("T")[0]:"nodate",A=se.dayGroupId||`${se.userId}-${j}`;M.has(A)||M.set(A,{id:A,userId:se.userId,userName:se.userName,date:se.date,totalHours:0,entries:[],status:se.status||"submitted",hasSupervisor:se.hasSupervisor});const Ie=M.get(A);Ie.totalHours+=se.hoursWorked,Ie.entries.push(se)}),Array.from(M.values()).sort((se,j)=>{const A=se.date?new Date(se.date).getTime():0,Ie=j.date?new Date(j.date).getTime():0;return Ie!==A?Ie-A:se.userName.localeCompare(j.userName)})},[T,H]),Ce=g.useMemo(()=>E.flatMap(M=>M.entries.map(U=>U.id)),[E]),Ge=D||Z,xe=(M,U)=>{o(ge=>U?[...ge,M]:ge.filter(X=>X!==M))},Pe=(M,U)=>
6{const ge=M.entries.map(X=>X.id);o(X=>{if(U){const se=new Set([...X,...ge]);return Array.from(se)}else return X.filter(se=>!ge.includes(se))})},_t=M=>{h(U=>{const ge=new Set(U);return ge.has(M)?ge.delete(M):ge.add(M),ge})},me=M=>{o(M?Ce:[])},Ze=M=>{r.length!==0&&R.mutate({ids:r,status:M,approvalNotes:i||void 0},{onSuccess:()=>{o([]),c(""),G(),m()}})},xt=M=>{f(M),p(!0)},it=()=>{p(!1),f(null),G(),m()},P=()=>{p(!1),f(null)},te=M=>{u(M),C(!0)},ze=M=>{l(M),b(!0)},rt=g.useMemo(()=>Ce.length>0&&r.length===Ce.length,[Ce,r]),Re=R.isPending,qe={title:t==="en"?"Final Time Approval":"Approbation Finale des Heures",reject:t==="en"?"Reject Selected":"Rejeter la Sélection",approve:t==="en"?"Approve Selected":"Approuver la Sélection",notesPlaceholder:t==="en"?"Optional notes for approval or rejection...":"Notes optionnelles pour approbation ou rejet...",employee:t==="en"?"Employee":"Employé",project:t==="en"?"Project":"Projet",date:"Date",hours:t==="en"?"Hours":"Heures",status:t==="en"?"Status":"Statut",actions:"Actions",selectAll:t==="en"?"Select all entries":"Sélectionner toutes les entrées",noEntries:t==="en"?"No entries pending final approval.":"Aucune entrée en attente d'approbation finale."};return e.jsxs("div",{className:`${pe.approvalInterface} ${s||""}`,children:[e.jsxs("header",{className:pe.header,children:[e.jsx("h3",{children:qe.title}),e.jsxs("div",{className:pe.actions,children:[e.jsxs(v,{variant:"outline",onClick:()=>Ze("rejected"),disabled:r.length===0||Re,className:pe.rejectButton,children:[e.jsx(Ws,{size:16})," ",qe.reject]}),e.jsxs(v,{onClick:()=>Ze("approved"),disabled:r.length===0||Re,className:pe.approveButton,children:[e.jsx(Rt,{size:16})," ",qe.approve]})]})]}),e.jsx("div",{className:pe.notesSection,children:e.jsx(es,{placeholder:qe.notesPlaceholder,value:i,onChange:M=>c(M.target.value),disabled:Re})}),e.jsx("div",{className:pe.tableContainer,children:e.jsxs("table",{className:pe.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:pe.checkboxColumn,children:e.jsx(Bt,{checked:rt,onCheckedChange:M=>me(M===!0),"aria-label":qe.selectAll})}),e.jsx("th",{children:qe.employee}),e.jsx("th",{children:qe.project}),e.jsx("th",{children:qe.date}),e.jsx("th",{children:qe.hours}),e.jsx("th",{children:qe.status}),a&&e.jsx("th",{children:"CCQ"}),e.jsx("th",{className:pe.actionsColumn,children:qe.actions})]})}),e.jsx("tbody",{children:Ge?Array.from({length:5}).map((M,U)=>e.jsx("tr",{className:pe.tableRow,children:e.jsx("td",{colSpan:a?8:7,children:e.jsx($,{style:{height:"2rem"}})})},U)):E.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:a?8:7,className:pe.noEntries,children:qe.noEntries})}):E.map(M=>e.jsx(Vl,{group:M,isExpanded:d.has(M.id),onToggleExpand:()=>_t(M.id),selectedIds:r,onSelectionChange:xe,onGroupSelectionChange:Pe,onModify:xt,onOpenEditor:te,onViewDay:ze,language:t,isCcqApplicable:a,t:n},M.id))})]})}),e.jsx(sa,{entry:y,isOpen:_,onClose:P,onSuccess:it}),q&&e.jsx(fs,{isOpen:x,onClose:()=>b(!1),entries:q.entries,userName:q.userName,date:q.date,onOpenEditor:()=>{b(!1),te(q)}}),S&&e.jsx(ca,{isOpen:N,onClose:()=>C(!1),entries:S.entries,userName:S.userName,date:S.date,onSuccess:()=>{G(),m()}})]})},Gl=Us([gt("hours_by_project"),gt("hours_by_user"),gt("hours_by_task"),gt("detailed"),gt("payroll_by_employee")]),Ul=Us([gt("pdf"),gt("csv"),gt("json")]),Ql=ie({reportType:Gl,format:Ul,startDate:I().datetime(),endDate:I().datetime(),projectId:B().int().positive().optional(),userId:B().int().positive().optional()}),Kl=async(s,n)=>{const t=Ql.parse(s),a=await fetch("/_api/timetracking/reports/export",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json"}});if(!a.ok)try{const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):`Request failed with status ${a.status}`)}catch{throw new Error(`Request failed with status ${a.status}`)}return a},Yl={fr:{success:"Rapport exporté avec succès. Le téléchargement va commencer.",error:"Échec de l'exportation du rapport"},en:{success:"Report exported successfully. Download will begin shortly.",error:"Failed to export report"}},ya=(s="fr")=>{const n=Yl[s];return Be({mutationFn:t=>Kl(t),onSuccess:async t=>{try{const a=t.headers.get("content-disposition");let r="time-report.pdf";if(a){const i=a.match(/filename="(.+)"/);i&&i.length>1&&(r=i[1])}const o=await t.blob(),d=window.URL.createObjectURL(o),h=document.createElement("a");h.href=d,h.download=r,document.body.appendChild(h),h.click(),h.remove(),window.URL.revokeObjectURL(d),ne.success(n.success)}catch(a){console.error("Failed to process download:",a);const r=a instanceof Error?a.message:String(a);ne.error(`${n.error}: ${r}`)}},onError:t=>{console.error("Export mutation error:",t),ne.error(`${n.error}: ${t.message}`)}})},Xl="_container_17ytq_1",Jl="_header_17ytq_12",Zl="_titleSection_17ytq_20",ec="_loadingBadge_17ytq_33",tc="_actions_17ytq_41",sc="_filters_17ytq_46",ac="_filterGroup_17ytq_53",nc="_filterItem_17ytq_60",rc="_selectTrigger_17ytq_65",oc="_selectValue_17ytq_69",ic="_filterIcon_17ytq_75",lc="_dateButton_17ytq_79",cc="_placeholder_17ytq_86",dc="_clearButton_17ytq_90",uc="_tableContainer_17ytq_100",mc="_table_17ytq_100",hc="_tableRow_17ytq_130",pc="_employeeCell_17ytq_143",_c="_hoursCell_17ytq_148",xc="_categoryTag_17ytq_153",jc="_statusBadge_17ytq_162",yc="_chevronCell_17ytq_167",gc="_chevronButton_17ytq_173",fc="_chevron_17ytq_167",vc="_chevronExpanded_17ytq_201",bc="_groupRow_17ytq_205",Nc="_actionsCell_17ytq_215",Cc="_viewIcon_17ytq_220",Sc="_expanded_17ytq_232",wc="_entr
6iesCount_17ytq_241",kc="_subRowContainer_17ytq_256",Tc="_subRowCell_17ytq_260",Dc="_subTableWrapper_17ytq_264",Ic="_subTable_17ytq_264",$c="_subTableRow_17ytq_293",Ec="_noEntries_17ytq_306",Bc="_emptyState_17ytq_311",Pc="_emptyIcon_17ytq_319",qc="_skeletonText_17ytq_323",Rc="_skeletonBadge_17ytq_328",Ac="_skeletonIcon_17ytq_334",Lc="_pagination_17ytq_340",Fc="_disabledPagination_17ytq_346",Oc="_ellipsis_17ytq_351",Mc="_exportMenu_17ytq_356",zc="_exportOptions_17ytq_361",Hc="_exportOption_17ytq_361",Vc="_exportButton_17ytq_383",L={container:Xl,header:Jl,titleSection:Zl,loadingBadge:ec,actions:tc,filters:sc,filterGroup:ac,filterItem:nc,selectTrigger:rc,selectValue:oc,filterIcon:ic,dateButton:lc,placeholder:cc,clearButton:dc,tableContainer:uc,table:mc,tableRow:hc,employeeCell:pc,hoursCell:_c,categoryTag:xc,statusBadge:jc,chevronCell:yc,chevronButton:gc,chevron:fc,chevronExpanded:vc,groupRow:bc,actionsCell:Nc,viewIcon:Cc,expanded:Sc,entriesCount:wc,subRowContainer:kc,subRowCell:Tc,subTableWrapper:Dc,subTable:Ic,subTableRow:$c,noEntries:Ec,emptyState:Bc,emptyIcon:Pc,skeletonText:qc,skeletonBadge:Rc,skeletonIcon:Ac,pagination:Lc,disabledPagination:Fc,ellipsis:Oc,exportMenu:Mc,exportOptions:zc,exportOption:Hc,exportButton:Vc},Wc=({className:s})=>{const{t:n,language:t}=de(),[a,r]=g.useState(1),[o,d]=g.useState("_empty"),[h,i]=g.useState("_empty"),[c,_]=g.useState(),[p,y]=g.useState(!1),{data:f}=Mt(),{data:S}=En({page:1}),u={status:"approved",page:a,userId:o!=="_empty"?parseInt(o):void 0,projectId:h!=="_empty"?parseInt(h):void 0,startDate:c?.from?c.from.toISOString():void 0,endDate:c?.to?c.to.toISOString():void 0},{data:N,isFetching:C}=At(u),q=ya(t),[l,x]=g.useState(null),[b,T]=g.useState(!1),[D,G]=g.useState(new Set),[H,Z]=g.useState(null),[m,R]=g.useState(!1),E=g.useMemo(()=>{if(!N?.entries)return[];const P={};return N.entries.forEach(te=>{const ze=te.date?te.date instanceof Date?te.date.toISOString().split("T")[0]:String(te.date).split("T")[0]:"no-date",rt=te.dayGroupId?`dg-${te.dayGroupId}`:`${te.userId}-${ze}`;P[rt]||(P[rt]={key:rt,userId:te.userId,userName:te.userName,date:te.date,totalHours:0,entries:[]}),P[rt].entries.push(te),P[rt].totalHours+=te.hoursWorked||0}),Object.values(P)},[N?.entries]),Ce=P=>{const te=new Set(D);te.has(P)?te.delete(P):te.add(P),G(te)},Ge=P=>{Z(P),R(!0)},xe=P=>{const te=c?.from?c.from.toISOString():new Date(new Date().setDate(new Date().getDate()-30)).toISOString(),ze=c?.to?c.to.toISOString():new Date().toISOString();q.mutate({reportType:"detailed",format:P,startDate:te,endDate:ze,userId:u.userId,projectId:u.projectId}),y(!1)},Pe=()=>{d("_empty"),i("_empty"),_(void 0),r(1)},_t=o!=="_empty"||h!=="_empty"||c!==void 0,me={title:t==="en"?"Approved Entries History":"Historique des Approbations",employee:t==="en"?"Employee":"Employé",project:t==="en"?"Project":"Projet",date:"Date",hours:t==="en"?"Hours":"Heures",entriesCount:t==="en"?"Entries":"Entrées",category:t==="en"?"Category":"Catégorie",status:t==="en"?"Status":"Statut",approved:t==="en"?"Approved":"Approuvé",filterEmployee:t==="en"?"Filter by employee":"Filtrer par employé",filterProject:t==="en"?"Filter by project":"Filtrer par projet",selectDate:t==="en"?"Select dates":"Sélectionner dates",export:t==="en"?"Export":"Exporter",clearFilters:t==="en"?"Clear filters":"Effacer filtres",noEntries:t==="en"?"No approved entries found matching your criteria.":"Aucune entrée approuvée trouvée correspondant à vos critères.",loading:t==="en"?"Loading history...":"Chargement de l'historique...",allEmployees:t==="en"?"All Employees":"Tous les employés",allProjects:t==="en"?"All Projects":"Tous les projets",exportPdf:t==="en"?"Export as PDF":"Exporter en PDF",exportCsv:t==="en"?"Export as CSV":"Exporter en CSV",viewBreakdown:t==="en"?"View breakdown":"Voir l'explicatif",toggleDetails:t==="en"?"Toggle details":"Basculer les détails"},Ze=()=>t==="fr"?"fr-CA":"en-CA",xt={cleanup:{en:"Cleanup",fr:"Nettoyage"},demolition:{en:"Demolition",fr:"Démolition"},drywall:{en:"Drywall",fr:"Placoplâtre"},electrical:{en:"Electrical",fr:"Électricité"},excavation:{en:"Excavation",fr:"Excavation"},flooring:{en:"Flooring",fr:"Revêtement de sol"},foundation:{en:"Foundation",fr:"Fondation"},framing:{en:"Framing",fr:"Charpente"},hvac:{en:"HVAC",fr:"CVC"},insulation:{en:"Insulation",fr:"Isolation"},landscaping:{en:"Landscaping",fr:"Aménagement paysager"},management:{en:"Management",fr:"Gestion"},other:{en:"Other",fr:"Autre"},painting:{en:"Painting",fr:"Peinture"},plumbing:{en:"Plumbing",fr:"Plomberie"},roofing:{en:"Roofing",fr:"Toiture"},siding:{en:"Siding",fr:"Revêtement extérieur"},travel:{en:"Travel",fr:"Déplacement"}},it=P=>{if(!P)return"-";const te=P.toLowerCase();return xt[te]?t==="fr"?xt[te].fr:xt[te].en:P.charAt(0).toUpperCase()+P.slice(1)};return e.jsxs("div",{className:`${L.container} ${s||""}`,children:[e.jsxs("header",{className:L.header,children:[e.jsxs("div",{className:L.titleSection,children:[e.jsx("h3",{children:me.title}),C&&e.jsx("span",{className:L.loadingBadge,children:me.loading})]}),e.jsx("div",{className:L.actions,children:e.jsxs(mt,{open:p,onOpenChange:y,children:[e.jsx(ht,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:L.exportButton,disabled:q.isPending,children:[e.jsx(Ft,{size:16}),me.export]})}),e.jsx(pt,{align:"end",className:L.exportMenu,children:e.jsxs("div",{className:L.exportOptions,children:[e.jsx(v,{variant:"ghost",onClick:()=>xe("pdf"),className:L.exportOption,children:me.exportPdf}),e.jsx(v,{variant:"ghost",onClick:()=>xe("csv"),className:L.exportOption,children:me.exportCsv})]})})]})})]}),e.jsx("div",{className:L.filters,children:e.jsxs("div",{className:L.filterGroup,children:[e.jsx("div",{className:L.filterItem,children:e.jsxs(we,{value:o,onValueChange:d,children:[e.jsx(ke,{className:L.selectTrigger,children:e.jsxs("div",{className:L.selectValue,children:[e.jsx(Ea,{size:14,className:L.filterIcon}),e.jsx(Te,{placeholder:me.filterEmployee})]})}),e.jsxs(De,{children:[e.jsx(F,{value:"_empty",children:me.allEmployees}),f?.map(P=>e.jsx(F,{value:P.id.toString(),children:P.displayName},P.id))]})]})}),e.jsx("div",{className:L.filterItem,children:e.jsxs(we,{value:h,onValueChange:i,children:[e.jsx(ke,{className:L.selectTrigger,children:e.jsxs("div",{className:L.selectValue,children:[e.jsx(Qs,{size:14,className:L.filterIcon}),e.jsx(Te,{placeholder:me.filterProject})]})}),e.jsxs(De,{children:[e.jsx(F,{value:"_empty",children:me.allProjects}),S?.projects.map(P=>e.jsx(F,{value:P.id.toString(),children:P.name},P.id))]})]})}),e.jsx("div",{className:L.filterItem,children:e.jsxs(mt,{children:[e.jsx(ht,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:`${L.dateButton} ${c?"":L.placeholder}`,children:[e.jsx(ut,{size:14,className:L.filterIcon}),c?.from?c.to?e.jsxs(e.Fragment,{children:[new Intl.DateTimeFormat(Ze(),{day:"numeric",month:"short"}).format(c.from)," -"," ",new Intl.DateTimeFormat(Ze(),{day:"numeric",month:"short"}).format(c.to)]}):new Intl.DateTimeFormat(Ze(),{day:"numeric",month:"short",year:"numeric"}).format(c.from):e.jsx("span",{children:me.selectDate})]})}),e.jsx(pt,{className:L.calendarPopover,align:"start",children:e.jsx(Nt,{mode:"range",selected:c,onSelect:_,initialFocus:!0,numberOfMonths:2})})]})}),_t&&e.jsxs(v,{variant:"ghost",size:"sm",onClick:Pe,className:L.clearButton,children:[e.jsx(Ba,{size:14}),me.clearFilters]})]})}),e.jsx("div",{className:L.tableContainer,children:e.jsxs("table",{className:L.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:L.chevronCell}),e.jsx("th",{children:me.employee}),e.jsx("th",{children:me.date}),e.jsx("th",{children:me.hours}),e.jsx("th",{children:me.entriesCount}),e.jsx("th",{children:me.status}),e.jsx("th",{className:L.actionsCell})]})}),e.jsx("tbody",{children:C?Array.from({length:5}).map((P,te)=>e.jsxs("tr",{className:L.tableRow,children:[e.jsx("td",{children:e.jsx($,{className:L.skeletonIcon})}),e.jsx("td",{children:e.jsx($,{className:L.skeletonText})}),e.jsx("td",{children:e.jsx($,{className:L.skeletonText})}),e.jsx("td",{children:e.jsx($,{className:L.skeletonText})}),e.jsx("td",{children:e.jsx($,{className:L.skeletonBadge})}),e.jsx("td",{children:e.jsx($,{className:L.skeletonBadge})}),e.jsx("td",{children:e.jsx($,{className:L.skeletonIcon})})]},te)):N?.entries.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:L.noEntries,children:e.jsxs("div",{className:L.emptyState,children:[e.jsx(Pa,{size:32,className:L.emptyIcon}),e.jsx("p",{children:me.noEntries})]})})}):E.map(P=>{const te=D.has(P.key),ze=vs(P.date,t==="fr"?"fr-CA":"en-CA",{day:"2-digit",month:"short",year:"numeric"}),rt=t==="en"?`View breakdown for ${P.userName} on ${ze}`:`Voir l'explicatif pour ${P.userName} le ${ze}`;return e.jsxs(Qe.Fragment,{children:[e.jsxs("tr",{className:`${L.tableRow} ${L.groupRow} ${te?L.expanded:""}`,onClick:()=>Ge(P),onKeyDown:Re=>{(Re.key==="Enter"||Re.key===" ")&&(Re.preventDefault(),Ge(P))},role:"button",tabIndex:0,"aria-label":rt,title:me.viewBreakdown,children:[e.jsx("td",{className:L.chevronCell,children:e.jsx("button",{type:"button",className:L.chevronButton,onClick:Re=>{Re.stopPropagation(),Ce(P.key)},"aria-label":me.toggleDetails,"aria-expanded":te,children:e.jsx(vt,{size:16,className:`${L.chevron} ${te?L.chevronExpanded:""}`})})}),e.jsx("td",{className:L.employeeCell,children:e.jsx("span",{className:L.employeeName,children:P.userName})}),e.jsx("td",{children:ze}),e.jsx("td",{className:L.hoursCell,children:P.totalHours.toFixed(2)}),e.jsx("td",{children:e.jsx("span",{className:L.entriesCount,children:P.entries.length})}),e.jsx("td",{children:e.jsx(Ne,{variant:"success",className:L.statusBadge,children:me.approved})}),e.jsx("td",{className:L.actionsCell,children:e.jsx("span",{className:L.viewIcon,title:me.viewBreakdown,children:e.jsx(ps,{size:16})})})]}),te&&e.jsx("tr",{className:L.subRowContainer,children:e.jsx("td",{colSpan:7,className:L.subRowCell,children:e.jsx("div",{className:L.subTableWrapper,children:e.jsxs("table",{className:L.subTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:me.project}),e.jsx("th",{children:me.hours}),e.jsx("th",{children:me.category})]})}),e.jsx("tbody",{children:P.entries.map(Re=>e.jsxs("tr",{className:L.subTableRow,onClick:qe=>{qe.stopPropagation(),x(Re),T(!0)},children:[e.jsx("td",{children:Re.projectName||"-"}),e.jsx("td",{className:L.hoursCell,children:Re.hoursWorked.toFixed(2)}),e.jsx("td",{children:Re.taskCategory?e.jsx("span",{className:L.categoryTag,children:it(Re.taskCategory)}):"-"})]},Re.id))})]})})})})]},P.key)})})]})}),N&&N.totalPages>1&&e.jsx("div",{className:L.pagination,children:e.jsx(ua,{children:e.jsxs(ma,{children:[e.jsx(bt,{children:e.jsx(ha,{onClick:()=>r(P=>Math.max(1,P-1)),className:a===1?L.disabledPagination:""})}),Array.from({length:N.totalPages},(P,te)=>te+1).filter(P=>P===1||P===N.totalPages||Math.abs(a-P)<=1).map((P,te,ze)=>e.jsxs(Qe.Fragment,{children:[te>0&&ze[te-1]!==P-1&&e.jsx(bt,{children:e.jsx("span",{className:L.ellipsis,children:"..."})}),e.jsx(bt,{children:e.jsx(Bn,{isActive:a===P,onClick:()=>r(P),children:P})})]},P)),e.jsx(bt,{children:e.jsx(pa,{onClick:()=>r(P=>Math.min(N.totalPages,P+1)),className:a===N.totalPages?L.disabledPagination:""})})]})})}),e.jsx(Pn,{entry:l,isOpen:b,onClose:()=>{T(!1),setTimeout(()=>x(null),300)}}),H&&e.jsx(fs,{isOpen:m,onClose:()=>
6R(!1),entries:H.entries,userName:H.userName,date:H.date?new Date(H.date):null})]})},ga=ie({companyId:B().int().positive().optional(),periodStart:Ee.date(),periodEnd:Ee.date(),submissionDeadline:Ee.date().optional(),approvalDeadline:Ee.date().optional(),payDate:Ee.date().optional(),status:I().optional(),cycle:Me(["custom","bi-weekly","monthly"]).default("custom"),numberOfPeriods:B().int().min(1).max(52).default(1)}).refine(s=>s.cycle==="custom"?s.numberOfPeriods===1:!0,{message:"For 'custom' cycle, numberOfPeriods must be 1.",path:["numberOfPeriods"]}).refine(s=>s.cycle==="custom"?s.periodEnd>s.periodStart:!0,{message:"periodEnd must be after periodStart for custom cycles.",path:["periodEnd"]}),Gc=async(s,n)=>{const t=ga.parse(s),a=await fetch("/_api/hr/timesheets/periods/create",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())},Uc=ie({id:B().int().positive(),periodStart:Ee.date().optional(),periodEnd:Ee.date().optional(),submissionDeadline:Ee.date().optional(),approvalDeadline:Ee.date().optional(),payDate:Ee.date().optional(),status:I().optional()}),Qc=async(s,n)=>{const t=Uc.parse(s),a=await fetch("/_api/hr/timesheets/periods/update",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())},Kc=ie({id:B().int().positive()}),Yc=async(s,n)=>{const t=Kc.parse(s),a=await fetch("/_api/hr/timesheets/periods/delete",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())},Xc="_container_168h3_1",Jc="_header_168h3_8",Zc="_title_168h3_17",ed="_listContainer_168h3_33",td="_periodItem_168h3_39",sd="_periodInfo_168h3_49",ad="_periodActions_168h3_60",nd="_form_168h3_65",rd="_formGrid_168h3_72",od="_formLabel_168h3_78",id="_formField_168h3_84",ce={container:Xc,header:Jc,title:Zc,listContainer:ed,periodItem:td,periodInfo:sd,periodActions:ad,form:nd,formGrid:rd,formLabel:od,formField:id},ld=({setOpen:s})=>{const n=Le(),{t}=de(),{register:a,handleSubmit:r,formState:{errors:o}}=zt({resolver:bs(ga),defaultValues:{cycle:"custom",numberOfPeriods:1}}),d=Be({mutationFn:Gc,onSuccess:()=>{ne.success(t("hr_period_created_success")),n.invalidateQueries({queryKey:["hr","timesheetPeriods"]}),s(!1)},onError:i=>ne.error(i.message)}),h=i=>{const c={...i,periodStart:i.periodStart?new Date(i.periodStart):void 0,periodEnd:i.periodEnd?new Date(i.periodEnd):void 0,submissionDeadline:i.submissionDeadline?new Date(i.submissionDeadline):void 0,approvalDeadline:i.approvalDeadline?new Date(i.approvalDeadline):void 0,payDate:i.payDate?new Date(i.payDate):void 0};d.mutate(c)};return e.jsxs("form",{onSubmit:r(h),className:ce.form,children:[e.jsxs("div",{className:ce.formGrid,children:[e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"periodStart",className:ce.formLabel,children:t("hr_period_start")}),e.jsx(K,{id:"periodStart",type:"date",...a("periodStart")})]}),e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"periodEnd",className:ce.formLabel,children:t("hr_period_end")}),e.jsx(K,{id:"periodEnd",type:"date",...a("periodEnd")})]})]}),e.jsxs("div",{className:ce.formGrid,children:[e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"submissionDeadline",className:ce.formLabel,children:t("hr_submission_deadline")}),e.jsx(K,{id:"submissionDeadline",type:"date",...a("submissionDeadline")})]}),e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"approvalDeadline",className:ce.formLabel,children:t("hr_approval_deadline")}),e.jsx(K,{id:"approvalDeadline",type:"date",...a("approvalDeadline")})]})]}),e.jsxs("div",{className:ce.formGrid,children:[e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"payDate",className:ce.formLabel,children:t("hr_pay_date")}),e.jsx(K,{id:"payDate",type:"date",...a("payDate")})]}),e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"status",className:ce.formLabel,children:t("hr_col_status")}),e.jsxs(we,{defaultValue:"open",onValueChange:i=>a("status").onChange({target:{value:i}}),children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:t("hr_select_status")})}),e.jsxs(De,{children:[e.jsx(F,{value:"open",children:t("hr_status_open")}),e.jsx(F,{value:"closed",children:t("hr_status_closed")}),e.jsx(F,{value:"submitted",children:t("hr_validation_submitted")}),e.jsx(F,{value:"approved",children:t("hr_validation_approved")})]})]})]})]}),e.jsx(v,{type:"submit",disabled:d.isPending,children:d.isPending?t("hr_saving"):t("hr_save_period")})]})},cd=({period:s,setOpen:n})=>{const t=Le(),{t:a}=de(),{register:r,handleSubmit:o,formState:{errors:d},setValue:h}=zt({defaultValues:{id:s.id,periodStart:s.periodStart?new Date(s.periodStart).toISOString().split("T")[0]:"",periodEnd:s.periodEnd?new Date(s.periodEnd).toISOString().split("T")[0]:"",submissionDeadline:s.submissionDeadline?new Date(s.submissionDeadline).toISOString().split("T")[0]:"",approvalDeadline:s.approvalDeadline?new Date(s.approvalDeadline).toISOString().split("T")[0]:"",payDate:s.payDate?new Date(s.payDate).toISOString().split("T")[0]:"",status:s.status||""}}),i=Be({mutationFn:Qc,onSuccess:()=>{ne.success(a("hr_period_updated_success")),t.invalidateQueries({queryKey:["hr","timesheetPeriods"]}),n(!1)},onError:_=>ne.error(_.message)}),c=_=>{const p={id:s.id,periodStart:_.periodStart?new Date(_.periodStart):void 0,periodEnd:_.periodEnd?new Date(_.periodEnd):void 0,submissionDeadline:_.submissionDeadline?new Date(_.submissionDeadline):void 0,approvalDeadline:_.approvalDeadline?new Date(_.approvalDeadline):void 0,payDate:_.payDate?new Date(_.payDate):void 0,status:_.status};i.mutate(p)};return e.jsxs("form",{onSubmit:o(c),className:ce.form,children:[e.jsxs("div",{className:ce.formGrid,children:[e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"periodStart",className:ce.formLabel,children:a("hr_period_start")}),e.jsx(K,{id:"periodStart",type:"date",...r("periodStart")})]}),e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"periodEnd",className:ce.formLabel,children:a("hr_period_end")}),e.jsx(K,{id:"periodEnd",type:"date",...r("periodEnd")})]})]}),e.jsxs("div",{className:ce.formGrid,children:[e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"submissionDeadline",className:ce.formLabel,children:a("hr_submission_deadline")}),e.jsx(K,{id:"submissionDeadline",type:"date",...r("submissionDeadline")})]}),e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"approvalDeadline",className:ce.formLabel,children:a("hr_approval_deadline")}),e.jsx(K,{id:"approvalDeadline",type:"date",...r("approvalDeadline")})]})]}),e.jsxs("div",{className:ce.formGrid,children:[e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"payDate",className:ce.formLabel,children:a("hr_pay_date")}),e.jsx(K,{id:"payDate",type:"date",...r("payDate")})]}),e.jsxs("div",{className:ce.formField,children:[e.jsx("label",{htmlFor:"status",className:ce.formLabel,children:a("hr_col_status")}),e.jsxs(we,{defaultValue:s.status||"open",onValueChange:_=>h("status",_),children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:a("hr_select_status")})}),e.jsxs(De,{children:[e.jsx(F,{value:"open",children:a("hr_status_open")}),e.jsx(F,{value:"closed",children:a("hr_status_closed")}),e.jsx(F,{value:"submitted",children:a("hr_validation_submitted")}),e.jsx(F,{value:"approved",children:a("hr_validation_approved")})]})]})]})]}),e.jsx(v,{type:"submit",disabled:i.isPending,children:i.isPending?a("hr_saving"):a("hr_save_period")})]})},dd=({className:s})=>{const[n,t]=g.useState(!1),[a,r]=g.useState(void 0),o=Le(),{t:d}=de(),{data:h,isFetching:i,error:c}=gs({}),_=Be({mutationFn:Yc,onSuccess:()=>{ne.success(d("hr_period_deleted_success")),o.invalidateQueries({queryKey:["hr","timesheetPeriods"]})},onError:u=>ne.error(u.message)}),p=u=>{r(u),t(!0)},y=()=>{r(void 0),t(!0)},f=u=>{window.confirm(`${d("hr_delete_confirm")} ${d("hr_delete_warning")}`)&&_.mutate({id:u})},S=u=>{if(!u)return d("hr_period_not_set");switch(u){case"open":return d("hr_status_open");case"closed":return d("hr_status_closed");case"submitted":return d("hr_validation_submitted");case"approved":return d("hr_validation_approved");case"rejected":return d("hr_validation_rejected");default:return u}};return e.jsxs("div",{className:`${ce.container} ${s||""}`,children:[e.jsxs("header",{className:ce.header,children:[e.jsxs("div",{className:ce.title,children:[e.jsx(ut,{}),e.jsx("h3",{children:d("hr_period_manager_title")})]}),e.jsxs(Ye,{open:n,onOpenChange:u=>{u||r(void 0),t(u)},children:[e.jsx(Lt,{asChild:!0,children:e.jsxs(v,{onClick:y,children:[e.jsx(Et,{size:16})," ",d("hr_add_period")]})}),e.jsxs(Xe,{children:[e.jsx(ot,{children:e.jsx(Je,{children:d(a?"hr_edit_period_title":"hr_create_period_title")})}),a?e.jsx(cd,{period:a,setOpen:t}):e.jsx(ld,{setOpen:t})]})]})]}),e.jsx("div",{className:ce.listContainer,children:i?Array.from({length:4}).map((u,N)=>e.jsx($,{style:{height:"4rem"}},N)):c?e.jsx("p",{children:d("hr_periods_load_error")}):h?.periods.map(u=>e.jsxs("div",{className:ce.periodItem,children:[e.jsxs("div",{className:ce.periodInfo,
6children:[e.jsxs("strong",{children:[new Date(u.periodStart).toLocaleDateString()," - ",new Date(u.periodEnd).toLocaleDateString()]}),e.jsxs("span",{children:[d("hr_status_label")," ",S(u.status)]})]}),e.jsxs("div",{className:ce.periodActions,children:[e.jsx(v,{variant:"ghost",size:"icon-sm",onClick:()=>p(u),children:e.jsx(_s,{size:14})}),e.jsx(v,{variant:"ghost",size:"icon-sm",onClick:()=>f(u.id),disabled:_.isPending,children:e.jsx(Yt,{size:14})})]})]},u.id))})]})},ud="_container_18x48_1",md="_infoSection_18x48_7",hd="_infoRow_18x48_16",pd="_label_18x48_22",_d="_value_18x48_28",xd="_formSection_18x48_34",jd="_fieldGroup_18x48_40",yd="_helperText_18x48_46",gd="_selectTrigger_18x48_52",fd="_actions_18x48_56",vd="_dateButton_18x48_66",ye={container:ud,infoSection:md,infoRow:hd,label:pd,value:_d,formSection:xd,fieldGroup:jd,helperText:yd,selectTrigger:gd,actions:fd,dateButton:vd},bd=({reportType:s,dateRange:n,className:t,hideModeSelector:a=!1})=>{const{t:r,language:o}=de(),[d,h]=g.useState("pdf"),[i,c]=g.useState(s==="payroll_by_employee"?"payroll":s==="detailed"?"detailed":"summary"),[_,p]=g.useState(s==="detailed"||s==="payroll_by_employee"?"hours_by_project":s),[y,f]=g.useState("custom"),[S,u]=g.useState(void 0),[N,C]=g.useState("__all"),[q,l]=g.useState(n);g.useEffect(()=>{_!=="hours_by_user"&&i!=="payroll"&&C("__all")},[_,i]);const x=ya(o==="fr"?"fr":"en"),{data:b,isFetching:T}=Mt();g.useEffect(()=>{s==="payroll_by_employee"?(c("payroll"),h("pdf")):s==="detailed"?c("detailed"):(c("summary"),p(s))},[s]),g.useEffect(()=>{if(i==="payroll")if(y==="day"&&S)l({from:S,to:S});else if(y==="week"&&S){const m=S.getDay(),R=S.getDate()-m+(m===0?-6:1),E=new Date(S);E.setDate(R);const Ce=new Date(E);Ce.setDate(E.getDate()+6),l({from:E,to:Ce})}else y==="custom"&&(q.from||l(n))},[y,S,i]);const D={hours_by_project:r("time_reports_type_project"),hours_by_user:r("time_reports_type_user"),hours_by_task:r("time_reports_type_task")},G=(m,R,E)=>{const Ce=r(m);return Ce!==m?Ce:o==="fr"?R:E},H=()=>{if(!q.from||!q.to)return;let m;i==="payroll"?m="payroll_by_employee":i==="detailed"?m="detailed":m=_;const R={reportType:m,format:d,startDate:q.from.toISOString(),endDate:q.to.toISOString()};(i==="payroll"||i==="summary"&&_==="hours_by_user")&&N!=="__all"&&(R.userId=parseInt(N,10)),x.mutate(R)},Z=()=>q.from?q.to&&q.from.toDateString()!==q.to.toDateString()?`${q.from.toLocaleDateString()} - ${q.to.toLocaleDateString()}`:q.from.toLocaleDateString():r("time_reports_export_no_date");return e.jsxs("div",{className:`${ye.container} ${t||""}`,children:[e.jsx("div",{className:ye.infoSection,children:e.jsxs("div",{className:ye.infoRow,children:[e.jsx("label",{className:ye.label,children:r("time_reports_export_date_label")}),e.jsx("div",{className:ye.value,children:Z()})]})}),e.jsxs("div",{className:ye.formSection,children:[!a&&e.jsxs("div",{className:ye.fieldGroup,children:[e.jsx("label",{className:ye.label,children:G("time_reports_mode_label","Mode de rapport","Report Mode")}),e.jsxs(we,{value:i,onValueChange:m=>{c(m),m==="payroll"&&h("pdf")},children:[e.jsx(ke,{className:ye.selectTrigger,children:e.jsx(Te,{})}),e.jsxs(De,{children:[e.jsx(F,{value:"summary",children:G("time_reports_mode_summary","Rapport résumé","Summary Report")}),e.jsx(F,{value:"detailed",children:G("time_reports_mode_detailed","Rapport détaillé","Detailed Report")}),e.jsx(F,{value:"payroll",children:r("time_reports_type_payroll")})]})]})]}),i==="summary"&&e.jsxs("div",{className:ye.fieldGroup,children:[e.jsx("label",{className:ye.label,children:r("time_reports_export_type_label")}),e.jsxs(we,{value:_,onValueChange:m=>p(m),children:[e.jsx(ke,{className:ye.selectTrigger,children:e.jsx(Te,{})}),e.jsxs(De,{children:[e.jsx(F,{value:"hours_by_project",children:D.hours_by_project}),e.jsx(F,{value:"hours_by_user",children:D.hours_by_user}),e.jsx(F,{value:"hours_by_task",children:D.hours_by_task})]})]})]}),i==="payroll"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:ye.fieldGroup,children:[e.jsx("label",{className:ye.label,children:r("time_reports_period_type")}),e.jsxs(we,{value:y,onValueChange:m=>f(m),children:[e.jsx(ke,{className:ye.selectTrigger,children:e.jsx(Te,{})}),e.jsxs(De,{children:[e.jsx(F,{value:"day",children:r("time_reports_period_day")}),e.jsx(F,{value:"week",children:r("time_reports_period_week")}),e.jsx(F,{value:"custom",children:r("time_reports_period_custom")})]})]})]}),y==="day"&&e.jsxs("div",{className:ye.fieldGroup,children:[e.jsx("label",{className:ye.label,children:r("time_reports_select_day")}),e.jsxs(mt,{children:[e.jsx(ht,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:ye.dateButton,children:[e.jsx(ut,{size:16,style:{marginRight:"0.5rem"}}),S?S.toLocaleDateString():r("time_reports_pick_date")]})}
6),e.jsx(pt,{removeBackgroundAndPadding:!0,children:e.jsx(Nt,{mode:"single",selected:S,onSelect:m=>u(m)})})]})]}),y==="week"&&e.jsxs("div",{className:ye.fieldGroup,children:[e.jsx("label",{className:ye.label,children:r("time_reports_select_week")}),e.jsxs(mt,{children:[e.jsx(ht,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:ye.dateButton,children:[e.jsx(ut,{size:16,style:{marginRight:"0.5rem"}}),S?`${G("week_of","Semaine du","Week of")} ${S.toLocaleDateString()}`:r("time_reports_pick_date")]})}),e.jsx(pt,{removeBackgroundAndPadding:!0,children:e.jsx(Nt,{mode:"single",selected:S,onSelect:m=>u(m)})})]}),S&&e.jsx("p",{className:ye.helperText,children:Z()})]}),y==="custom"&&e.jsxs("div",{className:ye.fieldGroup,children:[e.jsx("label",{className:ye.label,children:r("time_reports_export_date_label")}),e.jsxs(mt,{children:[e.jsx(ht,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:ye.dateButton,children:[e.jsx(ut,{size:16,style:{marginRight:"0.5rem"}}),Z()]})}),e.jsx(pt,{removeBackgroundAndPadding:!0,children:e.jsx(Nt,{mode:"range",selected:q,onSelect:m=>{m&&l(m)}})})]})]})]}),(i==="payroll"||i==="summary"&&_==="hours_by_user")&&e.jsxs("div",{className:ye.fieldGroup,children:[e.jsx("label",{className:ye.label,children:r("time_reports_employee_filter")}),e.jsxs(we,{value:N,onValueChange:m=>C(m),disabled:T,children:[e.jsx(ke,{className:ye.selectTrigger,children:e.jsx(Te,{placeholder:r("time_reports_select_employee")})}),e.jsxs(De,{children:[e.jsx(F,{value:"__all",children:r("time_reports_all_employees")}),b&&b.map(m=>e.jsx(F,{value:m.id.toString(),children:m.displayName},m.id))]})]})]}),i!=="payroll"&&e.jsxs("div",{className:ye.fieldGroup,children:[e.jsx("label",{className:ye.label,children:r("time_reports_export_format_label")}),e.jsxs(we,{value:d,onValueChange:m=>h(m),children:[e.jsx(ke,{className:ye.selectTrigger,children:e.jsx(Te,{placeholder:r("time_reports_export_select_format")})}),e.jsxs(De,{children:[e.jsx(F,{value:"pdf",children:"PDF"}),e.jsx(F,{value:"csv",children:"CSV"}),e.jsx(F,{value:"json",children:"JSON"})]})]})]})]}),e.jsx("div",{className:ye.actions,children:e.jsx(v,{variant:"primary",onClick:H,disabled:x.isPending||!q.from||!q.to,children:x.isPending?r("time_reports_export_exporting"):r("time_reports_export_submit")})})]})};ie({periodId:B().int().positive(),userId:B().int().positive().optional()});ie({validationId:B().int().positive()});ie({validationId:B().int().positive(),action:Me(["approve","reject"]),rejectionReason:I().optional()}).refine(s=>s.action==="reject"?typeof s.rejectionReason=="string"&&s.rejectionReason.length>0:!0,{message:"Rejection reason is required when rejecting a timesheet.",path:["rejectionReason"]});const et=/^(?:2[0-3]|[01]?[0-9]):[0-5][0-9]$/,fa=ie({name:I().min(1,"Template name is required."),standardHoursPerDay:B().positive().optional().nullable(),standardHoursPerWeek:B().positive().optional().nullable(),standardBreakDuration:B().int().nonnegative().optional().nullable(),unpaidLunchDuration:B().int().nonnegative().optional().nullable(),mondayStart:I().regex(et).optional().nullable(),mondayEnd:I().regex(et).optional().nullable(),tuesdayStart:I().regex(et).optional().nullable(),tuesdayEnd:I().regex(et).optional().nullable(),wednesdayStart:I().regex(et).optional().nullable(),wednesdayEnd:I().regex(et).optional().nullable(),thursdayStart:I().regex(et).optional().nullable(),thursdayEnd:I().regex(et).optional().nullable(),fridayStart:I().regex(et).optional().nullable(),fridayEnd:I().regex(et).optional().nullable(),saturdayStart:I().regex(et).optional().nullable(),saturdayEnd:I().regex(et).optional().nullable(),sundayStart:I().regex(et).optional().nullable(),sundayEnd:I().regex(et).optional().nullable(),dailyOvertimeThreshold:B().positive().optional().nullable(),weeklyOvertimeThreshold:B().positive().optional().nullable(),overtimeMultiplier:B().positive().optional().nullable()}),Nd=async(s,n)=>{const t=fa.parse(s),a=await fetch("/_api/hr/schedules/templates",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())},va=ie({userId:B().int().positive(),scheduleTemplateId:B().int().positive(),effectiveFrom:I().datetime(),effectiveUntil:I().datetime().optional().nullable(),projectId:B().int().positive().optional().nullable()}),Cd=async(s,n)=>{const t=va.parse(s),a=await fetch("/_api/hr/schedules/assign",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())};ie({userId:B().int().positive(),startDate:I().datetime(),endDate:I().datetime()});const ba=ie({ruleName:I().min(1,"Le nom de la règle est requis."),ruleType:I().min(1,"Le type de règle est requis."),multiplier:B().positive(),hoursThreshold:B().positive().optional().nullable(),effectiveFrom:I().datetime(),effectiveUntil:I().datetime().optional().nullable(),appliesToRole:Jt(Me(Zs)).optional().nullable(),appliesMonday:Ve().optional().nullable(),appliesTuesday:Ve().optional().nullable(),appliesWednesday:Ve().optional().nullable(),appliesThursday:Ve().optional().nullable(),appliesFriday:Ve().optional().nullable(),appliesSaturday:Ve().optional().nullable(),appliesSunday:Ve().optional().nullable(),appliesStatutoryHolidays:Ve().optional().nullable()}),Sd=async(s,n)=>{const t=ba.parse(s),a=await fetch("/_api/hr/overtime/rules",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())},wd=ie({periodId:B().int().positive(),channel:Me(["manual","csv"]).optional().default("manual"),userIds:Jt(B().int().positive()).optional()}),kd=async(s,n)=>{const t=wd.parse(s),a=await fetch("/_api/hr/payroll/export",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())},Td=()=>{const s=Le();return Be({mutationFn:Nd,onSuccess:n=>{ne.success(n.message),s.invalidateQueries({queryKey:["hr","scheduleTemplates"]})},onError:n=>{ne.error(n.message)}})},Dd=()=>{const s=Le();return Be({mutationFn:Cd,onSuccess:n=>{ne.success(n.message),s.invalidateQueries({queryKey:["hr","userSchedule"]})},onError:n=>{ne.error(n.message)}})},Id=()=>{const s=Le();return Be({mutationFn:kd,onSuccess:n=>{ne.success(n.message),s.invalidateQueries({queryKey:["hr","payrollStatus"]}),s.invalidateQueries({queryKey:["hr","payrollSummary"]})},onError:n=>{ne.error(n.message)}})},$d="_container_1ha0z_1",Ed="_header_1ha0z_8",Bd="_actions_1ha0z_19",Pd="_content_1ha0z_24",qd="_list_1ha0z_34",Rd="_listItem_1ha0z_43",Ad="_mutedText_1ha0z_53",Ld="_form_1ha0z_58",Fd="_formGrid_1ha0z_64",Od="_formField_1ha0z_70",Md="_errorText_1ha0z_76",zd="_formLabel_1ha0z_82",Hd="_nativeSelect_1ha0z_88",be={container:$d,header:Ed,actions:Bd,c
6ontent:Pd,list:qd,listItem:Rd,mutedText:Ad,form:Ld,formGrid:Fd,formField:Od,errorText:Md,formLabel:zd,nativeSelect:Hd},Vd=({setOpen:s})=>{const{t:n}=de(),{register:t,handleSubmit:a,formState:{errors:r}}=zt({resolver:bs(fa)}),o=Td(),d=h=>{o.mutate(h,{onSuccess:()=>s(!1)})};return e.jsxs("form",{onSubmit:a(d),className:be.form,children:[e.jsxs("div",{className:be.formField,children:[e.jsx("label",{htmlFor:"name",className:be.formLabel,children:n("wsm_template_name")}),e.jsx(K,{id:"name",...t("name")}),r.name&&e.jsx("p",{className:be.errorText,children:r.name.message})]}),e.jsxs("div",{className:be.formGrid,children:[e.jsxs("div",{className:be.formField,children:[e.jsx("label",{htmlFor:"standardHoursPerDay",className:be.formLabel,children:n("wsm_std_hours_day")}),e.jsx(K,{id:"standardHoursPerDay",type:"number",step:"0.1",...t("standardHoursPerDay",{valueAsNumber:!0})})]}),e.jsxs("div",{className:be.formField,children:[e.jsx("label",{htmlFor:"standardHoursPerWeek",className:be.formLabel,children:n("wsm_std_hours_week")}),e.jsx(K,{id:"standardHoursPerWeek",type:"number",step:"0.1",...t("standardHoursPerWeek",{valueAsNumber:!0})})]})]}),e.jsx(v,{type:"submit",disabled:o.isPending,children:o.isPending?n("wsm_saving"):n("wsm_save_template")})]})},Wd=({setOpen:s})=>{const{t:n}=de(),{register:t,handleSubmit:a,formState:{errors:r}}=zt({resolver:bs(va)}),o=Dd(),{data:d}=ta(),h=i=>{o.mutate(i,{onSuccess:()=>s(!1)})};return e.jsxs("form",{onSubmit:a(h),className:be.form,children:[e.jsxs("div",{className:be.formField,children:[e.jsx("label",{htmlFor:"userId",className:be.formLabel,children:n("wsm_user_id")}),e.jsx(K,{id:"userId",type:"number",...t("userId",{valueAsNumber:!0})}),r.userId&&e.jsx("p",{className:be.errorText,children:r.userId.message})]}),e.jsxs("div",{className:be.formField,children:[e.jsx("label",{htmlFor:"scheduleTemplateId",className:be.formLabel,children:n("wsm_schedule_template")}),e.jsx("select",{id:"scheduleTemplateId",...t("scheduleTemplateId",{valueAsNumber:!0}),className:be.nativeSelect,children:d?.templates.map(i=>e.jsx("option",{value:i.id,children:i.name},i.id))}),r.scheduleTemplateId&&e.jsx("p",{className:be.errorText,children:r.scheduleTemplateId.message})]}),e.jsxs("div",{className:be.formField,children:[e.jsx("label",{htmlFor:"effectiveFrom",className:be.formLabel,children:n("wsm_effective_from")}),e.jsx(K,{id:"effectiveFrom",type:"date",...t("effectiveFrom")}),r.effectiveFrom&&e.jsx("p",{className:be.errorText,children:r.effectiveFrom.message})]}),e.jsx(v,{type:"submit",disabled:o.isPending,children:o.isPending?n("wsm_assigning"):n("wsm_assign_schedule")})]})},Gd=({className:s})=>{const{t:n}=de(),[t,a]=g.useState(!1),[r,o]=g.useState(!1),{data:d,isFetching:h,error:i}=ta();return e.jsx("div",{className:`${be.container} ${s||""}`,children:e.jsxs(Dt,{defaultValue:"templates",children:[e.jsxs("header",{className:be.header,children:[e.jsxs(It,{children:[e.jsxs(Fe,{value:"templates",children:[e.jsx(qa,{size:16})," ",n("wsm_templates_tab")]}),e.jsxs(Fe,{value:"assignments",children:[e.jsx(ut,{size:16})," ",n("wsm_assignments_tab")]})]}),e.jsxs("div",{className:be.actions,children:[e.jsxs(Ye,{open:t,onOpenChange:a,children:[e.jsx(Lt,{asChild:!0,children:e.jsxs(v,{variant:"outline",children:[e.jsx(Et,{size:16})," ",n("wsm_new_template_btn")]})}),e.jsxs(Xe,{children:[e.jsx(ot,{children:e.jsx(Je,{children:n("wsm_create_template_title")})}),e.jsx(Vd,{setOpen:a})]})]}),e.jsxs(Ye,{open:r,onOpenChange:o,children:[e.jsx(Lt,{asChild:!0,children:e.jsxs(v,{children:[e.jsx(Et,{size:16})," ",n("wsm_assign_schedule_btn")]})}),e.jsxs(Xe,{children:[e.jsx(ot,{children:e.jsx(Je,{children:n("wsm_assign_employee_title")})}),e.jsx(Wd,{setOpen:o})]})]})]})]}),e.jsxs(Oe,{value:"templates",className:be.content,children:[e.jsx("h4",{children:n("wsm_available_templates")}),h?e.jsx("div",{className:be.list,children:Array.from({length:3}).map((c,_)=>e.jsx($,{style:{height:"3rem"}},_))}):i?e.jsx("p",{className:be.errorText,children:n("wsm_load_error")}):e.jsx("ul",{className:be.list,children:d?.templates.map(c=>e.jsxs("li",{className:be.listItem,children:[e.jsx("span",{children:c.name}),e.jsxs("span",{className:be.mutedText,children:[c.standardHoursPerWeek||"N/A"," ",n("wsm_hrs_week")]})]},c.id))})]}),e.jsxs(Oe,{value:"assignments",className:be.content,children:[e.jsx("h4",{children:n("wsm_current_assignments")}),e.jsx("p",{className:be.mutedText,children:n("wsm_assignments_not_implemented")})]})]})})},Ud="_container_1e5tm_1",Qd="_header_1e5tm_9",Kd="_content_1e5tm_25",Yd="_rulesGrid_1e5tm_29",Xd="_ruleCard_1e5tm_35",Jd="_ruleCardHeader_1e5tm_50",Zd="_ruleName_1e5tm_57",eu="_ruleActions_1e5tm_64",tu="_deleteButton_1e5tm_70",su="_ruleCardBody_1e5tm_75",au="_ruleDetail_1e5tm_81",nu="_emptyState_1e5tm_92",ru="_errorState_1e5tm_93",ou="_errorMessage_1e5tm_117",iu="_dialogContent_1e5tm_126",lu="_formGrid_1e5tm_131",cu="_formItemSpan2_1e5tm_138",du="_formFooter_1e5tm_142",uu="_datePickerButton_1e5tm_151",Se={container:Ud,header:Qd,content:Kd,rulesGrid:Yd,ruleCard:Xd,ruleCardHeader:Jd,ruleName:Zd,ruleActions:eu,deleteButton:tu,ruleCardBody:su,ruleDetail:au,emptyState:nu,errorState:ru,errorMessage:ou,dialogContent:iu,formGrid:lu,formItemSpan2:cu,formFooter:du,datePickerButton:uu},Fs=({onSubmit:s,onCancel:n,isSubmitting:t,className:a,initialValues:r,mode:o="create"})=>{const{t:d}=de(),h=[{value:"weekly_threshold",label:d("ot_weekly_threshold")},{value:"daily_threshold",label:d("ot_daily_threshold")},{value:"weekend",label:d("ot_type_weekend_premium")},{value:"stat_holiday",label:d("ot_holiday")}],i=Pt({schema:ba.omit({appliesToRole:!0,appliesMonday:!0,appliesTuesday:!0,appliesWednesday:!0,appliesThursday:!0,appliesFriday:!0,appliesSaturday:!0,appliesSunday:!0,appliesStatutoryHolidays:!0}),defaultValues:{ruleName:r?.ruleName??"",ruleType:r?.ruleType??"",multiplier:r?.multiplier??1.5,hoursThreshold:r?.hoursThreshold??void 0,effectiveFrom:r?.effectiveFrom??new Date().toISOString(),effectiveUntil:r?.effectiveUntil??null}}),c=i.values.ruleType,_=c==="daily_threshold"||c==="weekly_threshold";return e.jsx(qt,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(s),className:`${Se.formGrid} ${a||""}`,children:[e.jsxs(J,{name:"ruleName",className:Se.formItemSpan2,children:[e.jsx(re,{children:d("ot_rule_name_label")}),e.jsx(ee,{children:e.jsx(K,{placeholder:d("ot_rule_name_placeholder"),value:i.values.ruleName||"",onChange:p=>i.setValues(y=>({...y,ruleName:p.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"ruleType",children:[e.jsx(re,{children:d("ot_rule_type_label")}),e.jsx(ee,{children:e.jsxs(we,{value:i.values.ruleType,onValueChange:p=>i.setValues(y=>({...y,ruleType:p,hoursThreshold:void 0})),children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:d("ot_select_type_placeholder")})}),e.jsx(De,{children:h.map(p=>e.jsx(F,{value:p.value,children:p.label},p.value))})]})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"multiplier",children:[e.jsx(re,{children:d("ot_multiplier_label_form")}),e.jsx(ee,{children:e.jsx(Qt,{min:1,maxDecimals:2,placeholder:d("ot_multiplier_placeholder"),value:i.values.multiplier,onValueChange:p=>i.setValues(y=>({...y,multiplier:p??y.multiplier})),emptyValue:1.5})}),e.jsx(oe,{})]}),_&&e.jsxs(J,{name:"hoursThreshold",className:Se.formItemSpan2,children:[e.jsx(re,{children:d("ot_hours_threshold_label")}),e.jsx(ee,{children:e.jsx(Qt,{min:0,maxDecimals:2,placeholder:d(c==="weekly_threshold"?"ot_threshold_placeholder_weekly":"ot_threshold_placeholder_daily"),value:i.values.hoursThreshold??null,onValueChange:p=>i.setValues(y=>({...y,hoursThreshold:p})),emptyValue:null})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"effectiveFrom",children:[e.jsx(re,{children:d("ot_effective_date_label")}),e.jsxs(mt,{children:[e.jsx(ht,{asChild:!0,children:e.jsx(ee,{children:e.jsxs(v,{variant:"outline",className:Se.datePickerButton,children:[e.jsx(ut,{size:16}),i.values.effectiveFrom?Ct(new Date(i.values.effectiveFrom),"PPP"):e.jsx("span",{children:d("ot_select_date_placeholder")})]})})}
6),e.jsx(pt,{removeBackgroundAndPadding:!0,children:e.jsx(Nt,{mode:"single",selected:i.values.effectiveFrom?new Date(i.values.effectiveFrom):void 0,onSelect:p=>i.setValues(y=>({...y,effectiveFrom:p?.toISOString()||y.effectiveFrom})),initialFocus:!0})})]}),e.jsx(oe,{})]}),e.jsxs(J,{name:"effectiveUntil",children:[e.jsx(re,{children:d("ot_end_date_label")}),e.jsxs(mt,{children:[e.jsx(ht,{asChild:!0,children:e.jsx(ee,{children:e.jsxs(v,{variant:"outline",className:Se.datePickerButton,children:[e.jsx(ut,{size:16}),i.values.effectiveUntil?Ct(new Date(i.values.effectiveUntil),"PPP"):e.jsx("span",{children:d("ot_select_date_placeholder")})]})})}),e.jsx(pt,{removeBackgroundAndPadding:!0,children:e.jsx(Nt,{mode:"single",selected:i.values.effectiveUntil?new Date(i.values.effectiveUntil):void 0,onSelect:p=>i.setValues(y=>({...y,effectiveUntil:p?.toISOString()||null}))})})]}),e.jsx(oe,{})]}),e.jsxs("div",{className:`${Se.formFooter} ${Se.formItemSpan2}`,children:[e.jsx(v,{type:"button",variant:"secondary",onClick:n,disabled:t,children:d("ot_cancel_btn")}),e.jsx(v,{type:"submit",disabled:t,children:d(t?o==="edit"?"ot_updating_btn":"ot_saving_btn":o==="edit"?"ot_update_rule_btn":"ot_save_rule_btn")})]})]})})},mu=ie({ruleId:B().int().positive(),ruleName:I().min(1,"Le nom de la règle est requis."),ruleType:I().min(1,"Le type de règle est requis."),multiplier:B().positive(),hoursThreshold:B().positive().optional().nullable(),effectiveFrom:I().datetime(),effectiveUntil:I().datetime().optional().nullable(),appliesToRole:Jt(Me(Zs)).optional().nullable(),appliesMonday:Ve().optional().nullable(),appliesTuesday:Ve().optional().nullable(),appliesWednesday:Ve().optional().nullable(),appliesThursday:Ve().optional().nullable(),appliesFriday:Ve().optional().nullable(),appliesSaturday:Ve().optional().nullable(),appliesSunday:Ve().optional().nullable(),appliesStatutoryHolidays:Ve().optional().nullable()}),hu=async(s,n)=>{const t=mu.parse(s),a=await fetch("/_api/hr/overtime/rules/update",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())},pu=ie({ruleId:B().int().positive()}),_u=async(s,n)=>{const t=pu.parse(s),a=await fetch("/_api/hr/overtime/rules/delete",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())},Na=["hr","overtimeRules"];function xu(){const s=Le();return Be({mutationFn:hu,onSuccess:n=>{ne.success(n.message),s.invalidateQueries({queryKey:Na})},onError:n=>{ne.error(n instanceof Error?n.message:"Erreur lors de la mise à jour de la règle")}})}function ju(){const s=Le();return Be({mutationFn:_u,onSuccess:n=>{ne.success(n.message),s.invalidateQueries({queryKey:Na})},onError:n=>{ne.error(n instanceof Error?n.message:"Erreur lors de la suppression de la règle")}})}const yu=({rule:s,onEdit:n,onDelete:t})=>{const{t:a}=de(),r=d=>{switch(d){case"daily_threshold":return a("ot_daily_threshold");case"weekly_threshold":return a("ot_weekly_threshold");case"daily":return a("ot_daily");case"weekly":return a("ot_weekly");case"weekend":return a("ot_weekend");case"stat_holiday":return a("ot_holiday");case"statutory_holiday":return a("ot_statutory_holiday");default:return d}},o=d=>d?new Date(d).toLocaleDateString():a("ot_na");return e.jsxs("div",{className:Se.ruleCard,children:[e.jsxs("div",{className:Se.ruleCardHeader,children:[e.jsx("h3",{className:Se.ruleName,children:s.ruleName}),e.jsxs("div",{className:Se.ruleActions,children:[e.jsx(v,{variant:"ghost",size:"icon-sm",onClick:()=>n(s),"aria-label":a("ot_edit_dialog_title"),children:e.jsx(_s,{size:16})}),e.jsx(v,{variant:"ghost",size:"icon-sm",onClick:()=>t(s),className:Se.deleteButton,"aria-label":a("ot_delete_confirm_title"),children:e.jsx(Yt,{size:16})})]})]}),e.jsxs("div",{className:Se.ruleCardBody,children:[e.jsxs("div",{className:Se.ruleDetail,children:[e.jsx("strong",{children:a("ot_type_label")})," ",r(s.ruleType)]}),e.jsxs("div",{className:Se.ruleDetail,children:[e.jsx("strong",{children:a("ot_multiplier_label")})," x",s.multiplier]}),s.hoursThreshold!==null&&e.jsxs("div",{className:Se.ruleDetail,children:[e.jsx("strong",{children:a("ot_threshold_label")})," ",s.hoursThreshold," ",a("ot_hours_unit")]}),e.jsxs("div",{className:Se.ruleDetail,children:[e.jsx("strong",{children:a("ot_effective_period_label")})," ",o(s.effectiveFrom)," - ",o(s.effectiveUntil)||a("ot_present")]})]})]})},gu=({className:s})=>{const[n,t]=g.useState(!1),[a,r]=g.useState(null),[o,d]=g.useState(null),{data:h,isFetching:i,error:c}=dn(),_=Le(),{t:p}=de(),y=Be({mutationFn:Sd,onSuccess:()=>
6{ne.success(p("ot_create_success")),_.invalidateQueries({queryKey:["hr","overtimeRules"]}),t(!1)},onError:l=>{const x=l instanceof Error?l.message:p("ot_unknown_error");ne.error(`${p("ot_create_error_prefix")} ${x}`),console.error("Failed to create overtime rule:",l)}}),f=xu(),S=ju(),u=l=>{const x={...l,appliesSaturday:l.ruleType==="weekend",appliesSunday:l.ruleType==="weekend",appliesStatutoryHolidays:l.ruleType==="stat_holiday"};y.mutate(x)},N=l=>{if(!a)return;const x={ruleId:a.id,...l,appliesSaturday:l.ruleType==="weekend",appliesSunday:l.ruleType==="weekend",appliesStatutoryHolidays:l.ruleType==="stat_holiday"};f.mutate(x,{onSuccess:()=>{r(null)}})},C=()=>{o&&S.mutate({ruleId:o.id},{onSuccess:()=>{d(null)}})},q=()=>i?e.jsx("div",{className:Se.rulesGrid,children:[...Array(3)].map((l,x)=>e.jsxs("div",{className:Se.ruleCard,children:[e.jsx($,{style:{height:"1.5rem",width:"60%",marginBottom:"var(--spacing-4)"}}),e.jsx($,{style:{height:"1rem",width:"80%",marginBottom:"var(--spacing-2)"}}),e.jsx($,{style:{height:"1rem",width:"50%",marginBottom:"var(--spacing-2)"}}),e.jsx($,{style:{height:"1rem",width:"70%"}})]},x))}):c?e.jsxs("div",{className:Se.errorState,children:[e.jsx(xs,{size:48}),e.jsx("p",{children:p("ot_load_error")}),e.jsx("p",{className:Se.errorMessage,children:c.message})]}):!h||h.rules.length===0?e.jsxs("div",{className:Se.emptyState,children:[e.jsx("p",{children:p("ot_no_rules_found")}),e.jsx("p",{children:p("ot_create_first_rule_prompt")}),e.jsxs(v,{onClick:()=>t(!0),children:[e.jsx(Et,{size:16}),p("ot_create_first_rule_btn")]})]}):e.jsx("div",{className:Se.rulesGrid,children:h.rules.map(l=>e.jsx(yu,{rule:l,onEdit:r,onDelete:d},l.id))});return e.jsxs("div",{className:`${Se.container} ${s||""}`,children:[e.jsxs("header",{className:Se.header,children:[e.jsx("h2",{children:p("ot_management_title")}),e.jsxs(Ye,{open:n,onOpenChange:t,children:[e.jsx(Lt,{asChild:!0,children:e.jsxs(v,{children:[e.jsx(Et,{size:16}),p("ot_add_rule_btn")]})}),e.jsxs(Xe,{className:Se.dialogContent,children:[e.jsxs(ot,{children:[e.jsx(Je,{children:p("ot_create_dialog_title")}),e.jsx($t,{children:p("ot_create_dialog_desc")})]}),e.jsx(Fs,{onSubmit:u,onCancel:()=>t(!1),isSubmitting:y.isPending})]})]}),e.jsx(Ye,{open:!!a,onOpenChange:l=>!l&&r(null),children:e.jsxs(Xe,{className:Se.dialogContent,children:[e.jsxs(ot,{children:[e.jsx(Je,{children:p("ot_edit_dialog_title")}),e.jsx($t,{children:p("ot_edit_dialog_desc")})]}),a&&e.jsx(Fs,{mode:"edit",initialValues:{ruleName:a.ruleName,ruleType:a.ruleType,multiplier:a.multiplier,hoursThreshold:a.hoursThreshold,effectiveFrom:a.effectiveFrom?new Date(a.effectiveFrom).toISOString():void 0,effectiveUntil:a.effectiveUntil?new Date(a.effectiveUntil).toISOString():null},onSubmit:N,onCancel:()=>r(null),isSubmitting:f.isPending})]})}),e.jsx(Ye,{open:!!o,onOpenChange:l=>!l&&d(null),children:e.jsxs(Xe,{children:[e.jsxs(ot,{children:[e.jsx(Je,{children:p("ot_delete_confirm_title")}),e.jsxs($t,{children:[p("ot_delete_confirm_desc"),o&&e.jsx("strong",{style:{display:"block",marginTop:"var(--spacing-2)"},children:o.ruleName})]})]}),e.jsxs(ft,{children:[e.jsx(v,{variant:"outline",onClick:()=>d(null),children:p("ot_cancel_btn")}),e.jsx(v,{variant:"destructive",onClick:C,disabled:S.isPending,children:S.isPending?p("ot_updating_btn"):p("ot_confirm_delete_btn")})]})]})})]}),e.jsx("div",{className:Se.content,children:q()})]})},fu="_container_o446v_1",vu="_header_o446v_11",bu="_form_o446v_25",Nu="_formLabel_o446v_34",Cu="_formField_o446v_40",Su="_reportContainer_o446v_46",wu="_reportGrid_o446v_50",ku="_reportCard_o446v_56",Tu="_cardHeader_o446v_63",Du="_reportList_o446v_78",Iu="_errorText_o446v_92",He={container:fu,header:vu,form:bu,formLabel:Nu,formField:Cu,reportContainer:Su,reportGrid:wu,reportCard:ku,cardHeader:Tu,reportList:Du,errorText:Iu},$u=({data:s})=>{const{t:n,language:t}=de();return e.jsxs("div",{className:He.reportGrid,children:[e.jsxs("div",{className:He.reportCard,children:[e.jsxs("div",{className:He.cardHeader,children:[e.jsx(dt,{}),e.jsx("h4",{children:n("hr_compliance_late_submissions",{count:s.reportData.lateSubmissions.length})})]}),e.jsx("ul",{className:He.reportList,children:s.reportData.lateSubmissions.length>0?s.reportData.lateSubmissions.map((a,r)=>
6e.jsx("li",{children:n("hr_compliance_submitted_details",{userName:a.userName,date:new Date(a.submittedAt).toLocaleDateString(t),deadline:new Date(a.submissionDeadline).toLocaleDateString(t)})},r)):e.jsx("p",{children:n("hr_compliance_no_late")})})]}),e.jsxs("div",{className:He.reportCard,children:[e.jsxs("div",{className:He.cardHeader,children:[e.jsx(Wt,{}),e.jsx("h4",{children:n("hr_compliance_missing_approvals",{count:s.reportData.missingApprovals.length})})]}),e.jsx("ul",{className:He.reportList,children:s.reportData.missingApprovals.length>0?s.reportData.missingApprovals.map((a,r)=>e.jsx("li",{children:n("hr_compliance_approval_needed",{userName:a.userName,date:new Date(a.periodEnd).toLocaleDateString(t)})},r)):e.jsx("p",{children:n("hr_compliance_no_missing")})})]})]})},Eu=({className:s})=>{const{register:n,handleSubmit:t}=zt(),[a,r]=g.useState(null),{t:o}=de(),{data:d,isFetching:h,error:i}=un(a||{startDate:"",endDate:""}),c=_=>{r({startDate:new Date(_.startDate).toISOString(),endDate:new Date(_.endDate).toISOString()})};return e.jsxs("div",{className:`${He.container} ${s||""}`,children:[e.jsxs("header",{className:He.header,children:[e.jsx(Ra,{}),e.jsx("h3",{children:o("hr_compliance_tracker_title")})]}),e.jsxs("form",{onSubmit:t(c),className:He.form,children:[e.jsxs("div",{className:He.formField,children:[e.jsx("label",{htmlFor:"startDate",className:He.formLabel,children:o("hr_compliance_start_date")}),e.jsx(K,{id:"startDate",type:"date",...n("startDate")})]}),e.jsxs("div",{className:He.formField,children:[e.jsx("label",{htmlFor:"endDate",className:He.formLabel,children:o("hr_compliance_end_date")}),e.jsx(K,{id:"endDate",type:"date",...n("endDate")})]}),e.jsx(v,{type:"submit",disabled:h,children:o("hr_compliance_generate_report")})]}),e.jsxs("div",{className:He.reportContainer,children:[h&&e.jsx($,{style:{height:"150px"}}),i&&e.jsx("p",{className:He.errorText,children:o("hr_compliance_load_error")}),d&&e.jsx($u,{data:d})]})]})},Bu=ie({companyId:B().int().positive().optional(),customMessage:I().optional()}),Pu=async(s,n)=>{const t=Bu.parse(s),a=await fetch("/_api/timetracking/daily-reminder",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json"}});if(!a.ok){const r=w.parse(await a.text()),o=r&&typeof r=="object"&&"error"in r?String(r.error):"Failed to trigger daily reminders";throw new Error(o)}return w.parse(await a.text())};ie({});const qu=async(s,n)=>{const t=await fetch("/_api/timetracking/reminder-history",{method:"GET",...n,headers:{"Content-Type":"application/json"}});if(!t.ok){const a=w.parse(await t.text()),r=a&&typeof a=="object"&&"error"in a?String(a.error):"Failed to fetch reminder history";throw new Error(r)}return w.parse(await t.text())},Ss="timesheetReminder",Os={fr:{success_sent:"{{count}} rappels envoyés avec succès.",info_all_submitted:"Tous les employés éligibles ont déjà soumis leurs feuilles de temps.",error_failed:"Échec de l'envoi des rappels : {{error}}"},en:{success_sent:"{{count}} reminders sent successfully.",info_all_submitted:"All eligible employees have submitted their timesheets.",error_failed:"Failed to send reminders: {{error}}"}},Ru=()=>nt({queryKey:[Ss,"stats"],queryFn:()=>qn({}),refetchInterval:6e4,staleTime:3e4}),Au=()=>nt({queryKey:[Ss,"history"],queryFn:()=>qu(),staleTime:3e4}),Lu=s=>{const n=Le(),t=(a,r)=>{let o=Os[s]?.[a]||Os.fr[a];return r&&Object.entries(r).forEach(([d,h])=>{o=o.replace(`{{${d}}}`,String(h))}),o};return Be({mutationFn:(a={})=>Pu({customMessage:a.customMessage}),onSuccess:a=>{a.remindersSent>0?is({type:"success",message:t("success_sent",{count:a.remindersSent})}):is({type:"info",message:t("info_all_submitted")}),n.invalidateQueries({queryKey:[Ss,"history"]})},onError:a=>{is({type:"error",message:t("error_failed",{error:a.message})})}})},Fu="_dialogContent_qhasv_1",Ou="_body_qhasv_6",Mu="_fieldGroup_qhasv_14",zu="_label_qhasv_20",Hu="_textarea_qhasv_26",Vu="_recipientsList_qhasv_31",Wu="_recipientBadge_qhasv_42",jt={dialogContent:Fu,body:Ou,fieldGroup:Mu,label:zu,textarea:Hu,recipientsList:Vu,recipientBadge:Wu},Gu={fr:{dialogTitle:"Envoyer un rappel SMS",dialogDescription:"Personnalisez le message qui sera envoyé aux employés manquants.",messageLabel:"Message à envoyer :",recipients:"Destinataires",cancel:"Annuler",send:"Envoyer"},en:{dialogTitle:"Send SMS Reminder",dialogDescription:"Customize the message that will be sent to missing employees.",messageLabel:"Message to send:",recipients:"Recipients",cancel:"Cancel",send:"Send"}},Uu=({open:s,onOpenChange:n,onConfirm:t,recipients:a,companyName:r,isSending:o})=>{const{language:d}=de(),h=y=>Gu[d][y],i=`Rappel : N'oubliez pas de saisir vos heures de travail pour aujourd'hui sur ${r}. Connectez-vous maintenant : https://www.horizoncrm.ca/`,[c,_]=g.useState(i);g.useEffect(()=>{s&&_(i)},[s,r,i]);const p=()=>{t(c)};return e.jsx(Ye,{open:s,onOpenChange:n,children:e.jsxs(Xe,{className:jt.dialogContent,children:[e.jsxs(ot,{children:[e.jsx(Je,{children:h("dialogTitle")}),e.jsx($t,{children:h("dialogDescription")})]}),e.jsxs("div",{className:jt.body,children:[e.jsxs("div",{className:jt.fieldGroup,children:[e.jsx("label",{className:jt.label,children:h("messageLabel")}),e.jsx(es,{value:c,onChange:y=>_(y.target.value),className:jt.textarea,rows:4})]}),e.jsxs("div",{className:jt.fieldGroup,children:[e.jsxs("label",{className:jt.label,children:[h("recipients")," (",a.length,")"]}),e.jsx("div",{className:jt.recipientsList,children:a.map(y=>e.jsx("div",{className:jt.recipientBadge,children:y.displayName},y.id))})]})]}),e.jsxs(ft,{children:[e.jsx(v,{variant:"secondary",onClick:()=>n(!1),disabled:o,children:h("cancel")}),e.jsxs(v,{onClick:p,disabled:o,children:[e.jsx(Aa,{size:16}),h("send")," (",a.length," SMS)"]})]})]})})},Qu="_container_1v4ye_1",Ku="_header_1v4ye_10",Yu="_content_1v4ye_25",Xu="_mainPanel_1v4ye_31",Ju="_sidebar_1v4ye_31",Zu="_section_1v4ye_37",em="_sectionHeader_1v4ye_43",tm="_statsGrid_1v4ye_57",sm="_statCard_1v4ye_63",am="_statCardSkeleton_1v4ye_70",nm="_statHeader_1v4ye_75",rm="_statValue_1v4ye_89",om="_icon_1v4ye_96",
6im="_successIcon_1v4ye_100",lm="_warningIcon_1v4ye_104",cm="_complianceCard_1v4ye_108",dm="_listsContainer_1v4ye_112",um="_userList_1v4ye_119",mm="_userListItem_1v4ye_145",hm="_warningIconWrapper_1v4ye_151",pm="_historyList_1v4ye_164",_m="_historyItem_1v4ye_173",xm="_historyItemSkeleton_1v4ye_183",jm="_historyDetails_1v4ye_188",ym="_historyDate_1v4ye_193",gm="_nonWorkingDay_1v4ye_199",fm="_error_1v4ye_215",vm="_emptyState_1v4ye_215",Y={container:Qu,header:Ku,content:Yu,mainPanel:Xu,sidebar:Ju,section:Zu,sectionHeader:em,statsGrid:tm,statCard:sm,statCardSkeleton:am,statHeader:nm,statValue:rm,icon:om,successIcon:im,warningIcon:lm,complianceCard:cm,listsContainer:dm,userList:um,userListItem:mm,warningIconWrapper:hm,historyList:pm,historyItem:_m,historyItemSkeleton:xm,historyDetails:jm,historyDate:ym,nonWorkingDay:gm,error:fm,emptyState:vm},bm=({className:s})=>{const{t:n,language:t}=de(),{data:a,isLoading:r,error:o}=Ru(),{data:d,isLoading:h,error:i}=Au(),{mutate:c,isPending:_}=Lu(t),[p,y]=g.useState(!1),f={fr:{reminder_reason_noPhoneNumber:"Pas de numéro de téléphone",reminder_reason_smsDisabled:"Alertes SMS désactivées",missing_summary_can_remind:"{{total}} manquants ({{remindable}} rappelables)",send_reminder_btn:"Envoyer rappel ({{count}})"},en:{reminder_reason_noPhoneNumber:"No phone number",reminder_reason_smsDisabled:"SMS alerts disabled",missing_summary_can_remind:"{{total}} missing ({{remindable}} remindable)",send_reminder_btn:"Send reminder ({{count}})"}},S=(T,D,G,H)=>T==="weekend"?n("tr_reason_weekend"):T==="holiday"?n("tr_reason_holiday",{name:(t==="en"?G:D)||""}):H||"",u=(T,D)=>{let G=f[t]?.[T]||f.fr[T];return D&&Object.entries(D).forEach(([H,Z])=>{G=G.replace(`{{${H}}}`,String(Z))}),G};$s.locale(t);const N=()=>{y(!0)},C=T=>{c({customMessage:T},{onSuccess:()=>{y(!1)}})},q=()=>{if(r)return e.jsxs("div",{className:Y.statsGrid,children:[e.jsx($,{className:Y.statCardSkeleton}),e.jsx($,{className:Y.statCardSkeleton}),e.jsx($,{className:Y.statCardSkeleton})]});if(o)return e.jsxs("p",{className:Y.error,children:[n("tr_error_loading_stats")," ",o.message]});if(!a)return null;if(!a.isWorkingDay)return e.jsxs("div",{className:Y.nonWorkingDay,children:[e.jsx(yt,{size:24}),e.jsx("p",{children:e.jsx("strong",{children:n("tr_non_working_day")})}),e.jsx("p",{children:S(a.reasonCode,a.holidayNameFr,a.holidayNameEn,a.reason)})]});const T=a.totalEligible>0?Math.round(a.usersWithEntries.length/a.totalEligible*100):100;return e.jsxs("div",{className:Y.statsGrid,children:[e.jsxs("div",{className:Y.statCard,children:[e.jsxs("div",{className:Y.statHeader,children:[e.jsx(us,{size:20,className:Y.icon}),e.jsx("h4",{children:n("tr_total_eligible")})]}),e.jsx("p",{className:Y.statValue,children:a.totalEligible})]}),e.jsxs("div",{className:Y.statCard,children:[e.jsxs("div",{className:Y.statHeader,children:[e.jsx(Rt,{size:20,className:`${Y.icon} ${Y.successIcon}`}),e.jsx("h4",{children:n("tr_submitted")})]}),e.jsx("p",{className:Y.statValue,children:a.usersWithEntries.length})]}),e.jsxs("div",{className:Y.statCard,children:[e.jsxs("div",{className:Y.statHeader,children:[e.jsx(Wt,{size:20,className:`${Y.icon} ${Y.warningIcon}`}),e.jsx("h4",{children:n("tr_missing")})]}),e.jsx("p",{className:Y.statValue,children:a.usersWithoutEntries.length})]}),e.jsxs("div",{className:`${Y.statCard} ${Y.complianceCard}`,children:[e.jsxs("div",{className:Y.statHeader,children:[e.jsx(js,{size:20,className:Y.icon}),e.jsx("h4",{children:n("tr_compliance_rate")})]}),e.jsxs("p",{className:Y.statValue,children:[T,"%"]})]})]})},l=()=>{if(r||!a||!a.isWorkingDay)return null;const T=new Set(a.usersNotRemindable.map(H=>H.id)),D=a.usersWithoutEntries.filter(H=>!T.has(H.id)).length,G=H=>{const Z=a.usersNotRemindable.find(m=>m.id===H);return Z?Z.reason:null};return e.jsxs("div",{className:Y.listsContainer,children:[e.jsxs("div",{className:Y.userList,children:[e.jsx("h5",{children:n("tr_submitted_count_header",{count:a.usersWithEntries.length})}),e.jsx("ul",{children:a.usersWithEntries.map(H=>e.jsx("li",{children:H.displayName},H.id))})]}),e.jsxs("div",{className:Y.userList,children:[e.jsx("h5",{children:u("missing_summary_can_remind",{total:a.usersWithoutEntries.length,remindable:D})}),e.jsx("ul",{children:a.usersWithoutEntries.map(H=>{const Z=G(H.id);return e.jsxs("li",{className:Y.userListItem,children:[e.jsx("span",{children:H.displayName}),Z&&e.jsxs(wt,{children:[e.jsx(kt,{asChild:!0,children:e.jsx("div",{className:Y.warningIconWrapper,children:e.jsx(dt,{size:14,className:Y.warningIcon})})}),e.jsx(Tt,{children:u(`reminder_reason_${Z}`)})]})]},H.id)})})]})]})},x=()=>h?Array.from({length:3}).map((T,D)=>e.jsx($,{className:Y.historyItemSkeleton},D)):i?e.jsxs("p",{className:Y.error,children:[n("tr_error_loading_history")," ",i.message]}):!d||d.length===0?e.jsx("p",{className:Y.emptyState,children:n("tr_no_reminders_recent")}
6):e.jsx("ul",{className:Y.historyList,children:d.map(T=>e.jsxs("li",{className:Y.historyItem,children:[e.jsxs("div",{className:Y.historyDetails,children:[e.jsxs("p",{children:[n("tr_reminder_sent_to")," ",e.jsx("strong",{children:T.userName})]}),e.jsx("p",{className:Y.historyDate,children:$s(T.sentAt).fromNow()})]}),e.jsx(Ne,{variant:T.status==="sent"?"success":"destructive",children:T.status})]},T.id))}),b=a?a.usersWithoutEntries.filter(T=>!a.usersNotRemindable.some(D=>D.id===T.id)).length:0;return e.jsxs("div",{className:`${Y.container} ${s||""}`,children:[e.jsxs("div",{className:Y.header,children:[e.jsx("h3",{children:n("tr_title")}),e.jsxs(v,{onClick:N,disabled:_||r||b===0,children:[e.jsx(La,{size:16}),_?n("tr_sending"):u("send_reminder_btn",{count:b})]})]}),e.jsx(Uu,{open:p,onOpenChange:y,onConfirm:C,recipients:a?.usersWithoutEntries||[],companyName:a?.companyName||"Horizon CRM",isSending:_}),e.jsxs("div",{className:Y.content,children:[e.jsx("div",{className:Y.mainPanel,children:e.jsxs("div",{className:Y.section,children:[e.jsxs("div",{className:Y.sectionHeader,children:[e.jsx(xs,{size:20}),e.jsx("h4",{children:n("tr_todays_status")})]}),q(),l()]})}),e.jsx("div",{className:Y.sidebar,children:e.jsxs("div",{className:Y.section,children:[e.jsxs("div",{className:Y.sectionHeader,children:[e.jsx(Fa,{size:20}),e.jsx("h4",{children:n("tr_recent_history_title")})]}),x()]})})]})]})},Nm="_card_bz3m6_2",Cm="_header_bz3m6_13",Sm="_titleWrapper_bz3m6_24",wm="_iconWrapper_bz3m6_30",km="_title_bz3m6_24",Tm="_totalBadge_bz3m6_49",Dm="_totalLabel_bz3m6_62",Im="_totalValue_bz3m6_67",$m="_textSuccess_bz3m6_72",Em="_textError_bz3m6_76",Bm="_totalSkeleton_bz3m6_80",Pm="_content_bz3m6_85",qm="_tableHeader_bz3m6_91",Rm="_colName_bz3m6_103",Am="_colBalance_bz3m6_108",Lm="_colDate_bz3m6_115",Fm="_colChevronHeader_bz3m6_122",Om="_list_bz3m6_126",Mm="_row_bz3m6_133",zm="_clickableRow_bz3m6_149",Hm="_employeeName_bz3m6_153",Vm="_hoursBadge_bz3m6_162",Wm="_dateWrapper_bz3m6_170",Gm="_dateIcon_bz3m6_178",Um="_noDate_bz3m6_182",Qm="_colChevron_bz3m6_122",Km="_chevronIcon_bz3m6_195",Ym="_emptyState_bz3m6_199",Xm="_nameSkeleton_bz3m6_208",Jm="_badgeSkeleton_bz3m6_213",Zm="_dateSkeleton_bz3m6_219",ue={card:Nm,header:Cm,titleWrapper:Sm,iconWrapper:wm,title:km,totalBadge:Tm,totalLabel:Dm,totalValue:Im,textSuccess:$m,textError:Em,totalSkeleton:Bm,content:Pm,tableHeader:qm,colName:Rm,colBalance:Am,colDate:Lm,colChevronHeader:Fm,list:Om,row:Mm,clickableRow:zm,employeeName:Hm,hoursBadge:Vm,dateWrapper:Wm,dateIcon:Gm,noDate:Um,colChevron:Qm,chevronIcon:Km,emptyState:Ym,nameSkeleton:Xm,badgeSkeleton:Jm,dateSkeleton:Zm},eh={fr:{title:"Résumé des banques d'heures",totalCompany:"Total Entreprise",employee:"Employé",balance:"Solde",lastUpdated:"Dernière MAJ",noData:"Aucune donnée disponible",hours:"h"},en:{title:"Hours Bank Summary",totalCompany:"Company Total",employee:"Employee",balance:"Balance",lastUpdated:"Last Updated",noData:"No data available",hours:"h"}},th=({className:s,onEmployeeClick:n})=>{const{language:t}=de(),a=i=>eh[t][i],r=t==="fr"?"fr-CA":"en-CA",{data:o,isLoading:d}=wn(),h=i=>i>0?"success":i<0?"destructive":"secondary";return e.jsxs("div",{className:`${ue.card} ${s||""}`,children:[e.jsxs("div",{className:ue.header,children:[e.jsxs("div",{className:ue.titleWrapper,children:[e.jsx("div",{className:ue.iconWrapper,children:e.jsx(Ot,{size:20})}),e.jsx("h3",{className:ue.title,children:a("title")})]}),e.jsxs("div",{className:ue.totalBadge,children:[e.jsxs("span",{className:ue.totalLabel,children:[a("totalCompany"),":"]}),d?e.jsx($,{className:ue.totalSkeleton}):e.jsx("span",{className:`${ue.totalValue} ${(o?.companyTotal||0)>=0?ue.textSuccess:ue.textError}`,children:Ke(o?.companyTotal||0,{alwaysSign:!0})})]})]}),e.jsxs("div",{className:ue.content,children:[e.jsxs("div",{className:ue.tableHeader,children:[e.jsx("div",{className:ue.colName,children:a("employee")}),e.jsx("div",{className:ue.colBalance,children:a("balance")}),e.jsx("div",{className:ue.colDate,children:a("lastUpdated")}),n&&e.jsx("div",{className:ue.colChevronHeader})]}),e.jsx("div",{className:ue.list,children:d?Array.from({length:3}).map((i,c)=>e.jsxs("div",{className:ue.row,children:[e.jsx("div",{className:ue.colName,children:e.jsx($,{className:ue.nameSkeleton})}),e.jsx("div",{className:ue.colBalance,children:e.jsx($,{className:ue.badgeSkeleton})}),e.jsx("div",{className:ue.colDate,children:e.jsx($,{className:ue.dateSkeleton})})]},c)):o?.employees.length===0?e.jsx("div",{className:ue.emptyState,children:a("noData")}):o?.employees.map(i=>e.jsxs("div",{className:`${ue.row} ${n?ue.clickableRow:""}`,onClick:()=>n?.(i.userId,i.userName),children:[e.jsx("div",{className:ue.colName,children:e.jsx("span",{className:ue.employeeName,children:i.userName})}),e.jsx("div",{className:ue.colBalance,children:e.jsx(Ne,{variant:h(i.totalHours),className:ue.hoursBadge,children:Ke(i.totalHours,{alwaysSign:!0})})}),e.jsx("div",{className:ue.colDate,children:i.lastUpdated?e.jsxs("div",{className:ue.dateWrapper,children:[e.jsx(yt,{size:12,className:ue.dateIcon}),e.jsx("span",{children:new Intl.DateTimeFormat(r,{day:"numeric",month:"short"}).format(new Date(i.lastUpdated))})]}):e.jsx("span",{className:ue.noDate,children:"-"})}),n&&e.jsx("div",{className:ue.colChevron,children:e.jsx(vt,{size:16,className:ue.chevronIcon})})]},i.userId))})]})]})},sh="_card_fy83v_2",ah="_header_fy83v_12",nh="_title_fy83v_18",rh="_form_fy83v_25",oh="_row_fy83v_32",ih="_halfWidth_fy83v_38",lh="_comboboxTrigger_fy83v_44",ch="_comboboxIcon_fy83v_50",dh="_popoverContent_fy83v_57",uh="_commandWrapper_fy83v_63",mh="_command_fy83v_63",hh="_commandInputWrapper_fy83v_77",ph="_searchIcon_fy83v_84",_h="_commandInput_fy83v_77",xh="_commandList_fy83v_102",jh="_commandEmpty_fy83v_108",yh="_commandItem_fy83v_115",gh="_checkIcon_fy83v_131",fh="_visible_fy83v_137",vh="_invisible_fy83v_141",bh="_toggleGroup_fy83v_146",Nh="_toggleButton_fy83v_154",Ch="_creditActive_fy83v_165",Sh="_debitActive_fy83v_171",wh="_summary_fy83v_178",kh="_summaryCredit_fy83v_185",Th="_summaryDebit_fy83v_191",Dh="_highlightHours_fy83v_197",Ih="_submitButton_fy83v_202",fe={card:sh,header:ah,title:nh,form:rh,row:oh,halfWidth:ih,comboboxTrigger:lh,comboboxIcon:ch,popoverContent:dh,commandWrapper:uh,command:mh,commandInputWrapper:hh,searchIcon:ph,commandInput:_h,commandList:xh,commandEmpty:jh,commandItem:yh,checkIcon:gh,visible:fh,invisible:vh,toggleGroup:bh,toggleButton:Nh,creditActive:Ch,debitActive:Sh,summary:wh,summaryCredit:kh,summaryDebit:Th,highlightHours:Dh,submitButton:Ih},$h={fr:{title:"Gérer les heures",selectEmployee:"Sélectionner un employé",searchEmployee:"Rechercher un employé...",noEmployeeFound:"Aucun employé trouvé.",hours:"Heures",type:"Type de transaction",credit:"Crédit (Ajout)",debit:"Débit (Retrait)",reason:"Motif / Note",reasonPlaceholder:"Ex: Heures supplémentaires projet X, Rattrapage...",submit:"Soumettre",summary:"Récapitulatif",summaryAdd:"Ajouter",summaryRemove:"Retirer",summaryTo:"à",summaryFrom:"de",success:"Transaction effectuée avec succès",hoursRequired:"Le nombre d'heures est requis",hoursPositive:"Le nombre d'heures doit être positif",userRequired:"Veuillez sélectionner un employé",noteRequired:"Une note est requise"},en:{title:"Manage Hours",selectEmployee:"Select an employee",searchEmployee:"Search employee...",noEmployeeFound:"No employee found.",hours:"Hours",type:"Transaction Type",credit:"Credit (Add)",debit:"Debit (Deduct)",reason:"Reason / Note",reasonPlaceholder:"Ex: Overtime project X, Catch up...",submit:"Submit",summary:"Summary",summaryAdd:"Add",summaryRemove:"Remove",summaryTo:"to",summaryFrom:"from",success:"Transaction completed successfully",hoursRequired:"Hours are required",hoursPositive:"Hours must be positive",userRequired:"Please select an employee",noteRequired:"A note is required"}},Eh=ie({userId:B({required_error:"Required"}).min(1,"Required"),hours:Ee.number().min(.1,"Must be greater than 0"),type:Me(["credit","debit"]),note:I().optional()}),Bh=({className:s})=>{const{language:n}=de(),t=f=>$h[n][f],{data:a=[]}=Mt(),r=kn(),[o,d]=g.useState(!1),h=Pt({defaultValues:{userId:0,hours:0,type:"credit",note:""},schema:Eh}),i=h.values.userId,c=a.find(f=>f.id===i),_=h.values.type,p=h.values.hours,y=f=>{const S=f.type==="debit"?-Math.abs(f.hours):Math.abs(f.hours);r.mutate({userId:f.userId,hours:S,note:f.note},{onSuccess:()=>{ne.success(t("success")),h.setValues({userId:0,hours:0,type:"credit",note:""})}})};return e.jsxs("div",{className:`${fe.card} ${s||""}`,children:[e.jsx("div",{className:fe.header,children:e.jsx("h3",{className:fe.title,children:t("title")})}),e.jsx(qt,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(y),className:fe.form,children:[e.jsxs(J,{name:"userId",children:[e.jsx(re,{children:t("selectEmployee")}),e.jsxs(mt,{open:o,onOpenChange:d,children:[e.jsx(ht,{asChild:!0,children:e.jsx(ee,{children:e.jsxs(v,{variant:"outline",role:"combobox","aria-expanded":o,className:fe.comboboxTrigger,children:[c?c.displayName:t("selectEmployee"),e.jsx(Oa,{className:fe.comboboxIcon})]})})}
6),e.jsx(pt,{className:fe.popoverContent,removeBackgroundAndPadding:!0,children:e.jsx("div",{className:fe.commandWrapper,children:e.jsxs(St,{className:fe.command,children:[e.jsxs("div",{className:fe.commandInputWrapper,children:[e.jsx(Gs,{className:fe.searchIcon}),e.jsx(St.Input,{placeholder:t("searchEmployee"),className:fe.commandInput})]}),e.jsxs(St.List,{className:fe.commandList,children:[e.jsx(St.Empty,{className:fe.commandEmpty,children:t("noEmployeeFound")}),e.jsx(St.Group,{children:a.map(f=>e.jsxs(St.Item,{value:f.displayName,onSelect:()=>{h.setValues(S=>({...S,userId:f.id})),d(!1)},className:fe.commandItem,children:[e.jsx(Ks,{className:`${fe.checkIcon} ${i===f.id?fe.visible:fe.invisible}`}),f.displayName]},f.id))})]})]})})})]}),e.jsx(oe,{})]}),e.jsxs("div",{className:fe.row,children:[e.jsxs(J,{name:"hours",className:fe.halfWidth,children:[e.jsx(re,{children:t("hours")}),e.jsx(ee,{children:e.jsx(Qt,{min:0,maxDecimals:2,placeholder:"0.00",value:h.values.hours,onValueChange:f=>h.setValues(S=>({...S,hours:f??0})),emptyValue:0})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"type",className:fe.halfWidth,children:[e.jsx(re,{children:t("type")}),e.jsxs("div",{className:fe.toggleGroup,children:[e.jsx("button",{type:"button",className:`${fe.toggleButton} ${_==="credit"?fe.creditActive:""}`,onClick:()=>h.setValues(f=>({...f,type:"credit"})),children:t("credit")}),e.jsx("button",{type:"button",className:`${fe.toggleButton} ${_==="debit"?fe.debitActive:""}`,onClick:()=>h.setValues(f=>({...f,type:"debit"})),children:t("debit")})]})]})]}),e.jsxs(J,{name:"note",children:[e.jsx(re,{children:t("reason")}),e.jsx(ee,{children:e.jsx(es,{placeholder:t("reasonPlaceholder"),value:h.values.note,onChange:f=>h.setValues(S=>({...S,note:f.target.value}))})}),e.jsx(oe,{})]}),c&&p>0&&e.jsx("div",{className:`${fe.summary} ${_==="credit"?fe.summaryCredit:fe.summaryDebit}`,children:e.jsxs("p",{children:[e.jsxs("strong",{children:[t("summary"),": "]}),t(_==="credit"?"summaryAdd":"summaryRemove")," ",e.jsxs("span",{className:fe.highlightHours,children:[p,"h"]})," ",t(_==="credit"?"summaryTo":"summaryFrom")," ",e.jsx("strong",{children:c.displayName})]})}),e.jsx(v,{type:"submit",className:fe.submitButton,disabled:r.isPending,children:r.isPending?"...":t("submit")})]})})]})};ie({page:Ee.number().int().positive().default(1),limit:Ee.number().int().positive().default(20),userId:Ee.number().int().positive().optional(),type:Me(["credit","debit"]).optional(),startDate:Ee.date().optional(),endDate:Ee.date().optional(),search:I().optional()});const Ph=async(s={},n)=>{const t=new URLSearchParams;s.page&&t.set("page",s.page.toString()),s.limit&&t.set("limit",s.limit.toString()),s.userId&&t.set("userId",s.userId.toString()),s.type&&t.set("type",s.type),s.startDate&&t.set("startDate",s.startDate.toISOString()),s.endDate&&t.set("endDate",s.endDate.toISOString()),s.search&&t.set("search",s.search);const a=await fetch(`/_api/payroll/hours-bank/history?${t.toString()}`,{method:"GET",...n});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"An unknown error occurred")}return w.parse(await a.text())},qh=["payroll","hours-bank","history"];function Rh(s={}){return nt({queryKey:[...qh,s],queryFn:()=>Ph(s),placeholderData:Ma,staleTime:3e4})}const Ah="_container_163zd_2",Lh="_header_163zd_10",Fh="_title_163zd_18",Oh="_statsGrid_163zd_26",Mh="_statCard_163zd_32",zh="_statIconWrapper_163zd_43",Hh="_statContent_163zd_67",Vh="_statLabel_163zd_72",Wh="_statValue_163zd_77",Gh="_textSuccess_163zd_91",Uh="_textError_163zd_95",Qh="_statSkeleton_163zd_99",Kh="_filters_163zd_106",Yh="_filterGroup_163zd_113",Xh="_filterSelect_163zd_120",Jh="_dateTrigger_163zd_124",Zh="_searchInput_163zd_130",ep="_calendarPopover_163zd_134",tp="_tableWrapper_163zd_140",sp="_table_163zd_140",ap="_dateCell_163zd_174",np="_timeLabel_163zd_180",rp="_employeeCell_163zd_185",op="_employeeName_163zd_192",ip="_roleBadge_163zd_196",lp="_hoursBadge_163zd_202",cp="_noteCell_163zd_207",dp="_creatorCell_163zd_215",up="_emptyState_163zd_220",mp="_cellSkeleton_163zd_226",hp="_paginationWrapper_163zd_232",pp="_pageInfo_163zd_238",_p="_disabledLink_163zd_244",Q={container:Ah,header:Lh,title:Fh,statsGrid:Oh,statCard:Mh,statIconWrapper:zh,statContent:Hh,statLabel:Vh,statValue:Wh,textSuccess:Gh,textError:Uh,statSkeleton:Qh,filters:Kh,filterGroup:Yh,filterSelect:Xh,dateTrigger:Jh,searchInput:Zh,calendarPopover:ep,tableWrapper:tp,table:sp,dateCell:ap,timeLabel:np,employeeCell:rp,employeeName:op,roleBadge:ip,hoursBadge:lp,noteCell:cp,creatorCell:dp,emptyState:up,cellSkeleton:mp,paginationWrapper:hp,pageInfo:pp,disabledLink:_p},xp={fr:{title:"Historique des transactions",export:"Exporter CSV",filterEmployee:"Tous les employés",filterType:"Tous les types",typeCredit:"Crédit",typeDebit:"Débit",searchPlaceholder:"Rechercher dans les notes...",dateRange:"Période",selectDate:"Sélectionner une date",totalCredits:"Total Crédits",totalDebits:"Total Débits",netBalance:"Solde Net",colDate:"Date",colEmployee:"Employé",colHours:"Heures",colNote:"Note",colBy:"Par",page:"Page",of:"sur",noData:"Aucune transaction trouvée",resetFilters:"Réinitialiser",role_admin:"Administrateur",role_company:"Entreprise",role_employee:"Employé",role_foreman:"Contremaître",role_subcontractor:"Sous-traitant"},en:{title:"Transaction History",export:"Export CSV",filterEmployee:"All Employees",filterType:"All Types",typeCredit:"Credit",typeDebit:"Debit",searchPlaceholder:"Search notes...",dateRange:"Period",selectDate:"Select date",totalCredits:"Total Credits",totalDebits:"Total Debits",netBalance:"Net Balance",colDate:"Date",colEmployee:"Employee",colHours:"Hours",colNote:"Note",colBy:"By",page:"Page",of:"of",noData:"No transactions foun
6d",resetFilters:"Reset",role_admin:"Admin",role_company:"Company",role_employee:"Employee",role_foreman:"Foreman",role_subcontractor:"Subcontractor"}},jp=({className:s})=>{const{language:n}=de(),t=b=>xp[n][b],a=()=>n==="fr"?"fr-CA":"en-CA",[r,o]=g.useState("all"),[d,h]=g.useState("all"),[i,c]=g.useState(),[_,p]=g.useState(""),[y,f]=g.useState(1),{data:S=[]}=Mt(),{data:u,isLoading:N,isPlaceholderData:C}=Rh({page:y,limit:10,userId:r!=="all"?parseInt(r):void 0,type:d!=="all"?d:void 0,startDate:i?.from,endDate:i?.to,search:_||void 0}),q=()=>{if(!u?.entries)return;const b=["Date","Employé","Heures","Note","Par"],T=u.entries.map(R=>{const E=new Date(R.createdAt);return[`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")} ${String(E.getHours()).padStart(2,"0")}:${String(E.getMinutes()).padStart(2,"0")}`,R.userName,R.hours.toString(),R.note||"",R.createdByName]}),D="\uFEFF"+[b.join(";"),...T.map(R=>R.map(E=>`"${E}"`).join(";"))].join(`
7`),G=new Blob([D],{type:"text/csv;charset=utf-8;"}),H=URL.createObjectURL(G),Z=document.createElement("a");Z.setAttribute("href",H);const m=new Date().toISOString().slice(0,10).replace(/-/g,"");Z.setAttribute("download",`export-banque-heures-${m}.csv`),document.body.appendChild(Z),Z.click(),document.body.removeChild(Z)},l=()=>{o("all"),h("all"),c(void 0),p(""),f(1)},x=r!=="all"||d!=="all"||i!==void 0||_!=="";return e.jsxs("div",{className:`${Q.container} ${s||""}`,children:[e.jsxs("div",{className:Q.header,children:[e.jsx("h2",{className:Q.title,children:t("title")}),e.jsxs(v,{variant:"outline",size:"sm",onClick:q,disabled:!u?.entries.length,children:[e.jsx(Ft,{size:16}),t("export")]})]}),e.jsxs("div",{className:Q.statsGrid,children:[e.jsxs("div",{className:Q.statCard,children:[e.jsx("div",{className:Q.statIconWrapper,"data-type":"credit",children:e.jsx(za,{size:20})}),e.jsxs("div",{className:Q.statContent,children:[e.jsx("span",{className:Q.statLabel,children:t("totalCredits")}),N?e.jsx($,{className:Q.statSkeleton}):e.jsxs("span",{className:Q.statValue,"data-type":"credit",children:["+",(u?.summary?.totalCredits??0).toFixed(2),"h"]})]})]}),e.jsxs("div",{className:Q.statCard,children:[e.jsx("div",{className:Q.statIconWrapper,"data-type":"debit",children:e.jsx(Ha,{size:20})}),e.jsxs("div",{className:Q.statContent,children:[e.jsx("span",{className:Q.statLabel,children:t("totalDebits")}),N?e.jsx($,{className:Q.statSkeleton}):e.jsxs("span",{className:Q.statValue,"data-type":"debit",children:[(u?.summary?.totalDebits??0).toFixed(2),"h"]})]})]}),e.jsxs("div",{className:Q.statCard,children:[e.jsx("div",{className:Q.statIconWrapper,"data-type":"net",children:e.jsx(Ot,{size:20})}),e.jsxs("div",{className:Q.statContent,children:[e.jsx("span",{className:Q.statLabel,children:t("netBalance")}),N?e.jsx($,{className:Q.statSkeleton}):e.jsxs("span",{className:`${Q.statValue} ${(u?.summary?.netBalance??0)>=0?Q.textSuccess:Q.textError}`,children:[(u?.summary?.netBalance??0).toFixed(2),"h"]})]})]})]}),e.jsx("div",{className:Q.filters,children:e.jsxs("div",{className:Q.filterGroup,children:[e.jsxs(we,{value:r,onValueChange:b=>{o(b),f(1)},children:[e.jsx(ke,{className:Q.filterSelect,children:e.jsx(Te,{placeholder:t("filterEmployee")})}),e.jsxs(De,{children:[e.jsx(F,{value:"all",children:t("filterEmployee")}),S.map(b=>e.jsx(F,{value:b.id.toString(),children:b.displayName},b.id))]})]}),e.jsxs(we,{value:d,onValueChange:b=>{h(b),f(1)},children:[e.jsx(ke,{className:Q.filterSelect,children:e.jsx(Te,{placeholder:t("filterType")})}),e.jsxs(De,{children:[e.jsx(F,{value:"all",children:t("filterType")}),e.jsx(F,{value:"credit",children:t("typeCredit")}),e.jsx(F,{value:"debit",children:t("typeDebit")})]})]}),e.jsxs(mt,{children:[e.jsx(ht,{asChild:!0,children:e.jsxs(v,{variant:"outline",className:Q.dateTrigger,children:[e.jsx(ut,{size:16}),i?.from?i.to?e.jsxs(e.Fragment,{children:[new Intl.DateTimeFormat(a(),{day:"2-digit",month:"short"}).format(i.from)," -"," ",new Intl.DateTimeFormat(a(),{day:"2-digit",month:"short"}).format(i.to)]}):new Intl.DateTimeFormat(a(),{day:"2-digit",month:"short"}).format(i.from):t("dateRange")]})}),e.jsx(pt,{className:Q.calendarPopover,align:"start",removeBackgroun
7dAndPadding:!0,children:e.jsx(Nt,{mode:"range",selected:i,onSelect:b=>{c(b),f(1)},numberOfMonths:1})})]}),e.jsx(K,{placeholder:t("searchPlaceholder"),value:_,onChange:b=>{p(b.target.value),f(1)},className:Q.searchInput}),x&&e.jsx(v,{variant:"ghost",size:"icon-md",onClick:l,title:t("resetFilters"),children:e.jsx(Va,{size:18})})]})}),e.jsx("div",{className:Q.tableWrapper,children:e.jsxs("table",{className:Q.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:t("colDate")}),e.jsx("th",{children:t("colEmployee")}),e.jsx("th",{children:t("colHours")}),e.jsx("th",{children:t("colNote")}),e.jsx("th",{children:t("colBy")})]})}),e.jsx("tbody",{children:N?Array.from({length:5}).map((b,T)=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx($,{className:Q.cellSkeleton})}),e.jsx("td",{children:e.jsx($,{className:Q.cellSkeleton})}),e.jsx("td",{children:e.jsx($,{className:Q.cellSkeleton})}),e.jsx("td",{children:e.jsx($,{className:Q.cellSkeleton})}),e.jsx("td",{children:e.jsx($,{className:Q.cellSkeleton})})]},T)):u?.entries.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:Q.emptyState,children:t("noData")})}):u?.entries.map(b=>e.jsxs("tr",{children:[e.jsxs("td",{className:Q.dateCell,children:[new Intl.DateTimeFormat(a(),{day:"2-digit",month:"short",year:"numeric"}).format(new Date(b.createdAt)),e.jsx("span",{className:Q.timeLabel,children:new Intl.DateTimeFormat(a(),{hour:"2-digit",minute:"2-digit",hour12:!1}).format(new Date(b.createdAt))})]}),e.jsx("td",{children:e.jsxs("div",{className:Q.employeeCell,children:[e.jsx("span",{className:Q.employeeName,children:b.userName}),e.jsx(Ne,{variant:"outline",className:Q.roleBadge,children:t(`role_${b.userRole}`)||b.userRole})]})}),e.jsx("td",{children:e.jsxs(Ne,{variant:b.hours>0?"success":"destructive",className:Q.hoursBadge,children:[b.hours>0?"+":"",b.hours,"h"]})}),e.jsx("td",{className:Q.noteCell,title:b.note||"",children:b.note||"-"}),e.jsx("td",{className:Q.creatorCell,children:b.createdByName})]},b.id))})]})}),u&&u.pagination.totalPages>1&&e.jsx("div",{className:Q.paginationWrapper,children:e.jsx(ua,{children:e.jsxs(ma,{children:[e.jsx(bt,{children:e.jsx(ha,{onClick:()=>f(b=>Math.max(1,b-1)),"aria-disabled":y===1,className:y===1?Q.disabledLink:void 0})}),e.jsx(bt,{children:e.jsxs("span",{className:Q.pageInfo,children:[t("page")," ",y," ",t("of")," ",u.pagination.totalPages]})}),e.jsx(bt,{children:e.jsx(pa,{onClick:()=>f(b=>Math.min(u.pagination.totalPages,b+1)),"aria-disabled":y===u.pagination.totalPages,className:y===u.pagination.totalPages?Q.disabledLink:void 0})})]})})})]})};ie({page:B().min(1).default(1),userId:B().optional(),periodStart:lt().optional(),periodEnd:lt().optional()});const yp=async(s,n)=>{const t=new URLSearchParams;t.set("page",s.page.toString()),s.userId&&t.set("userId",s.userId.toString()),s.periodStart&&t.set("periodStart",s.periodStart.toISOString()),s.periodEnd&&t.set("periodEnd",s.periodEnd.toISOString());const a=await fetch(`/_api/payroll/imported-stubs?${t.toString()}`,{method:"GET",...n,headers:{"Content-Type":"application/json"}});if(!a.ok){const r=w.parse(await a.text());throw new Error(r.error)}return w.parse(await a.text())};ie({periodId:B(),userIds:Jt(B()).optional()});const gp=async(s,n)=>{const t=await fetch("/_api/payroll/quickbooks-sync",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!t.ok){const a=w.parse(await t.text());throw new Error(a.error)}return w.parse(await t.text())};ie({periodStart:lt(),periodEnd:lt()});const fp=async(s,n)=>{const t=await fetch("/_api/payroll/quickbooks-import",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!t.ok){const a=w.parse(await t.text());throw new Error(a.error)}return w.parse(await t.text())},vp=ie({periodId:B().int().positive()}),bp=async(s,n)=>{const t=vp.parse(s),a=await fetch("/_api/hr/payroll/csv-export",{method:"POST",body:w.stringify(t),...n,headers:{"Content-Type":"application/json",...n?.headers??{}}});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite lors de l'export CSV")}return w.parse(await a.text())};ie({});const Np=async s=>{const n=await fetch("/_api/payroll/integration-status",{method:"GET",...s,headers:{"Content-Type":"application/json"}});if(!n.ok){const t=w.parse(await n.text());throw new Error(typeof t=="object"&&t!==null&&"error"in t?String(t.error):"Une erreur inconnue s'est produite")}return w.parse(await n.text())},Ca=["pay-stubs"],Sa=["payroll","integrationStatus"];function ws(){const s=Le();return()=>{s.invalidateQueries({queryKey:["hr","payrollStatus"]}),s.invalidateQueries({queryKey:["hr","payrollSummary"]}),s.invalidateQueries({queryKey:Ca}),s.invalidateQueries({queryKey:Sa})}}function Cp(){return nt({queryKey:Sa,queryFn:()=>Np()})}function Sp(){const s=ws();return Be({mutationFn:gp,onSuccess:s})}function wp(){const s=ws();return Be({mutationFn:fp,onSuccess:s})}function kp(){const s=ws();return Be({mutationFn:bp,onSuccess:s})}function Tp(s){return nt({queryKey:[...Ca,s],queryFn:()=>yp(s)})}const Dp="_container_yqohm_1",Ip="_header_yqohm_11",$p="_title_yqohm_19",Ep="_filters_yqohm_26",Bp="_tableContainer_yqohm_32",Pp="_table_yqohm_32",qp="_tableRow_yqohm_57",Rp="_messageCell_yqohm_61",Ap="_muted_yqohm_67",Lp="_pagination_yqohm_73",Fp="_pageInfo_yqohm_81",tt={container:Dp,header:Ip,title:$p,filters:Ep,tableContainer:Bp,table:Pp,tableRow:qp,messageCell:Rp,muted:Ap,pagination:Lp,pageInfo:Fp},Op=({className:s})=>{const{t:n,regionCode:t}=de(),[a,r]=g.useState(1),[o,d]=g.useState(""),[h,i]=g.useState(""),[c,_]=g.useState("all"),{data:p}=Mt(),{data:y,isFetching:f,error:S}=Tp({page:a,userId:c!=="all"?Number(c):void 0,periodStart:o?new Date(o):void 0,periodEnd:h?new Date(h):void 0}),u=(C,q)=>{C(q),r(1)},N=y?Math.ceil(y.total/20):1;return e.jsxs("div",{className:`${tt.container} ${s||""}`,children:[e.jsxs("div",{className:tt.header,children:[e.jsx("h4",{className:tt.title,children:n("payroll_stub_viewer")}),e.jsxs("div",{className:tt.filters,children:[e.jsx("div",{className:tt.filterControl,children:e.jsxs(we,{value:c,onValueChange:C=>u(_,C),children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:n("payroll_search_employee")})}),e.jsxs(De,{children:[e.jsx(F,{value:"all",children:n("payroll_all_employees")}),p?.map(C=>e.jsx(F,{value:C.id.toString(),children:C.displayName},C.id))]})]})}),e.jsx(K,{type:"date",value:o,onChange:C=>u(d,C.target.value)}),e.jsx(K,{type:"date",value:h,onChange:C=>u(i,C.target.value)})]})]}),e.jsx("div",{className:tt.tableContainer,children:e.jsxs("table",{className:tt.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:n("payroll_employee")}),e.jsx("th",{children:n("payroll_stub_period")}),e.jsx("th",{children:n("payroll_stub_gross")}),e.jsx("th",{children:n("payroll_stub_net")}),e.jsx("th",{children:n("payroll_stub_deductions")}),e.jsx("th",{children:n("payroll_stub_pdf")})]})}),e.jsx("tbody",{children:f?Array.from({length:3}).map((C,q)=>e.jsx("tr",{children:e.jsx("td",{colSpan:6,children:e.jsx($,{style:{height:"2rem"}})})},q)):S?e.jsx("tr",{children:e.jsxs("td",{colSpan:6,className:tt.messageCell,children:[e.jsx(dt,{size:16,className:tt.errorIcon})," ",S.message]})}):!y||y.stubs.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:tt.messageCell,children:n("payroll_empty_description")})}):y.stubs.map(C=>e.jsxs("tr",{className:tt.tableRow,children:[e.jsx("td",{children:C.userName}),e.jsxs("td",{children:[new Date(C.periodStart).toLocaleDateString()," - ",new Date(C.periodEnd).toLocaleDateString()]}),e.jsx("td",{children:We(Number(C.grossPay),t)}),e.jsx("td",{children:We(Number(C.netPay),t)}),e.jsx("td",{children:We(Number(C.deductions),t)}),e.jsx("td",{children:C.pdfUrl?e.jsx(v,{asChild:!0,variant:"ghost",size:"sm",children:e.jsx("a",{href:C.pdfUrl,target:"_blank",rel:"noopener noreferrer",children:e.jsx(Ft,{size:16})})}):e.jsx("span",{className:tt.muted,children:"N/A"})})]},C.id))})]})}),e.jsxs("div",{className:tt.pagination,children:[e.jsx(v,{variant:"outline",size:"sm",disabled:a===1,onClick:()=>r(C=>C-1),children:"Précédent"}),e.jsx("span",{className:tt.pageInfo,children:n("payroll_page_info",{page:a,total:N,count:y?.total||0})}),e.jsx(v,{variant:"outline",size:"sm",disabled:a>=N,onClick:()=>r(C=>C+1),children:"Suivant"})]})]})}
7,Mp="_container_ccd0v_1",zp="_integrationBanner_ccd0v_11",Hp="_connectionBadge_ccd0v_20",Vp="_syncErrorText_ccd0v_26",Wp="_header_ccd0v_32",Gp="_title_ccd0v_40",Up="_selectTrigger_ccd0v_57",Qp="_tabs_ccd0v_61",Kp="_actionsBar_ccd0v_67",Yp="_searchBox_ccd0v_76",Xp="_exportActions_ccd0v_82",Jp="_qbActions_ccd0v_88",Zp="_syncErrorsPanel_ccd0v_95",e_="_diagnosticPanel_ccd0v_119",t_="_diagnosticTitle_ccd0v_127",s_="_diagnosticDescription_ccd0v_137",a_="_diagnosticGrid_ccd0v_144",n_="_diagnosticColumn_ccd0v_150",r_="_diagnosticColumnTitle_ccd0v_157",o_="_diagnosticList_ccd0v_168",i_="_diagnosticListItem_ccd0v_176",l_="_diagName_ccd0v_184",c_="_diagEmail_ccd0v_190",d_="_diagCount_ccd0v_195",u_="_diagnosticEmpty_ccd0v_201",m_="_diagnosticTruncated_ccd0v_208",h_="_stubViewer_ccd0v_222",p_="_tableContainer_ccd0v_226",__="_table_ccd0v_226",x_="_sortableTh_ccd0v_251",j_="_tableRow_ccd0v_260",y_="_totalsRow_ccd0v_264",g_="_messageCell_ccd0v_273",f_="_errorIcon_ccd0v_283",v_="_employeeCell_ccd0v_287",b_="_smallBadge_ccd0v_293",N_="_emptyStateContent_ccd0v_298",V={container:Mp,integrationBanner:zp,connectionBadge:Hp,syncErrorText:Vp,header:Wp,title:Gp,selectTrigger:Up,tabs:Qp,actionsBar:Kp,searchBox:Yp,exportActions:Xp,qbActions:Jp,syncErrorsPanel:Zp,diagnosticPanel:e_,diagnosticTitle:t_,diagnosticDescription:s_,diagnosticGrid:a_,diagnosticColumn:n_,diagnosticColumnTitle:r_,diagnosticList:o_,diagnosticListItem:i_,diagName:l_,diagEmail:c_,diagCount:d_,diagnosticEmpty:u_,diagnosticTruncated:m_,stubViewer:h_,tableContainer:p_,table:__,sortableTh:x_,tableRow:j_,totalsRow:y_,messageCell:g_,errorIcon:f_,employeeCell:v_,smallBadge:b_,emptyStateContent:N_},Ms=s=>{const n=new Date(s);return`${n.getUTCFullYear()}-${String(n.getUTCMonth()+1).padStart(2,"0")}-${String(n.getUTCDate()).padStart(2,"0")}`},C_=({className:s})=>{const[n,t]=g.useState(null),[a,r]=g.useState(""),[o,d]=g.useState("userName"),[h,i]=g.useState(!1),[c,_]=g.useState([]),[p,y]=g.useState(!1),[f,S]=g.useState(null),{t:u,regionCode:N,language:C}=de(),{data:q,isFetching:l}=Cp(),{data:x,isFetching:b}=gs({status:"closed"}),{data:T,isFetching:D,error:G}=mn({periodId:n||0}),{data:H,isFetching:Z,error:m}=hn({periodId:n||0}),{mutate:R,isPending:E}=Sp(),{mutate:Ce,isPending:Ge}=wp(),{mutate:xe,isPending:Pe}=kp(),{mutate:_t,isPending:me}=Id(),Ze=j=>{t(Number(j))},xt=D||Z,it=q?.quickbooksConnected===!0,P=T?.deductionsApplied===!0,te=()=>{n&&(_([]),S(null),R({periodId:n},{onSuccess:j=>{const A=C==="fr";if(j.unmappedEmployeeCount>0&&S({unmappedEmployeeCount:j.unmappedEmployeeCount,unmappedEmployeeDetails:j.unmappedEmployeeDetails,quickbooksEmployeeCount:j.quickbooksEmployeeCount,quickbooksEmployeeNames:j.quickbooksEmployeeNames}),j.failed>0){ne.error(j.errors&&j.errors.length>0?j.errors[0]:A?"Erreur lors de la synchronisation.":"Error during synchronization."),_(j.errors||[]);return}if(j.synced===0&&j.unmappedEmployeeCount>0){ne.warning(A?`Aucune heure envoyée : ${j.unmappedEmployeeCount} employé(s) n'ont pas de fiche correspondante dans QuickBooks. Créez l'employé dans QuickBooks avec le même courriel (ou exactement le même nom d'affichage) que dans Horizon CRM, puis relancez.`:`No hours sent: ${j.unmappedEmployeeCount} employee(s) have no matching record in QuickBooks. Create the employee in QuickBooks with the same email (or exact display name) as in Horizon CRM, then retry.`,{duration:1e4}),j.errors&&j.errors.length>0&&_(j.errors);return}if(j.synced===0&&j.unmappedEmployeeCount===0&&j.alreadyExported===0){ne.info(A?"Aucune heure approuvée à exporter pour cette période.":"No approved hours to export for this period."),j.errors&&j.errors.length>0&&_(j.errors);return}let Ie="";j.synced>0&&(Ie+=A?`${j.synced} entrée(s) synchronisée(s). `:`${j.synced} entry(ies) synchronized. `),j.unmappedEmployeeCount>0&&(Ie+=A?`(${j.unmappedEmployeeCount} employé(s) ignoré(s) car introuvables dans QuickBooks). `:`(${j.unmappedEmployeeCount} employee(s) skipped because not found in QuickBooks). `),j.alreadyExported>0&&(Ie+=A?`${j.alreadyExported} entrée(s) déjà exportée(s) ignorée(s) (idempotence). `:`${j.alreadyExported} entry(ies) already exported skipped (idempotency). `),ne.success(Ie.trim()),j.errors&&j.errors.length>0&&_(j.errors)},onError:j=>ne.error(j.message)}))},ze=()=>{const j=x?.periods.find(A=>A.id===n);j&&(_([]),Ce({periodStart:new Date(j.periodStart),periodEnd:new Date(j.periodEnd)},{onSuccess:A=>{const Ie=u("payroll_toast_import_details",{matched:A.matchedEmployees,alreadyImported:A.alreadyImported,skipped:A.ski
7ppedNoMatch});A.imported>0?ne.success(`${u("payroll_toast_import_success")}: ${A.imported}. ${Ie}`):ne.info(`${u("payroll_toast_import_info")} ${Ie}`),A.errors&&A.errors.length>0&&_(A.errors)},onError:A=>ne.error(A.message)}))},rt=()=>{n&&xe({periodId:n},{onSuccess:j=>{const A=new Blob([j.csv],{type:"text/csv;charset=utf-8;"}),Ie=URL.createObjectURL(A),Ae=document.createElement("a");Ae.href=Ie,Ae.setAttribute("download",j.filename),document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),URL.revokeObjectURL(Ie),ne.success(u("payroll_toast_csv_export_success",{count:j.rowCount})),j.missingRateUsers.length>0&&ne.warning(u("payroll_missing_rate_warning"))},onError:j=>{ne.error(j.message)}})},Re=()=>{n&&_t({periodId:n,channel:"manual"},{onSuccess:()=>{y(!1)},onError:j=>{ne.error(j.message)}})},qe=j=>{if(!H?.statuses)return null;const A=H.statuses.filter(Ie=>Ie.userId===j);return A.length===0?null:A.sort((Ie,Ae)=>{const Ue=Ie.exportedAt?new Date(Ie.exportedAt).getTime():0;return(Ae.exportedAt?new Date(Ae.exportedAt).getTime():0)-Ue})[0]},M=g.useMemo(()=>{if(!T?.summary)return[];let j=T.summary.filter(A=>A.userName.toLowerCase().includes(a.toLowerCase()));return j=j.sort((A,Ie)=>{let Ae=A[o],Ue=Ie[o];return o==="status"?(Ae=qe(A.userId)?.exportStatus||"",Ue=qe(Ie.userId)?.exportStatus||""):typeof Ae=="string"&&typeof Ue=="string"&&(Ae=Ae.toLowerCase(),Ue=Ue.toLowerCase()),Ae<Ue?h?1:-1:Ae>Ue?h?-1:1:0}),j},[T,a,o,h,H]),U=g.useMemo(()=>M.reduce((j,A)=>(j.regularHours+=A.regularHours||0,j.overtimeHours+=A.overtimeHours||0,j.grossPay+=A.grossPay||0,j.deductions+=A.totalDeductions||0,j.netPay+=A.netPay||0,j),{regularHours:0,overtimeHours:0,grossPay:0,deductions:0,netPay:0}),[M]),ge=j=>{o===j?i(!h):(d(j),i(!1))},X=j=>o!==j?null:h?e.jsx(Xt,{size:14}):e.jsx(Xs,{size:14}),se=C==="fr";return e.jsxs("div",{className:`${V.container} ${s||""}`,children:[e.jsxs("div",{className:V.integrationBanner,children:[l?e.jsx($,{style:{width:200,height:24}}):it?e.jsxs(Ne,{variant:"success",className:V.connectionBadge,children:[e.jsx(Rt,{size:14})," ",u("payroll_integration_connected")]}):e.jsxs(Ne,{variant:"warning",className:V.connectionBadge,children:[e.jsx(dt,{size:14})," ",u("payroll_integration_disconnected")]}),!it&&e.jsx(v,{asChild:!0,variant:"link",size:"sm",children:e.jsx(rs,{to:"/dashboard/comptabilite",children:u("payroll_link_accounting")})}),q?.syncErrorMessage&&e.jsxs("span",{className:V.syncErrorText,children:[u("payroll_error_prefix")," ",q.syncErrorMessage]})]}),e.jsxs("header",{className:V.header,children:[e.jsxs("div",{className:V.title,children:[e.jsx(Wa,{size:24}),e.jsx("h3",{children:u("payroll_title")})]}),e.jsxs(we,{onValueChange:Ze,value:n?.toString(),children:[e.jsx(ke,{className:V.selectTrigger,children:e.jsx(Te,{placeholder:u("payroll_select_closed_period")})}),e.jsx(De,{children:x?.periods.map(j=>e.jsxs(F,{value:j.id.toString(),children:[Ms(j.periodStart)," - ",Ms(j.periodEnd)]},j.id))})]})]}),e.jsxs(Dt,{defaultValue:"overview",className:V.tabs,children:[e.jsxs(It,{children:[e.jsx(Fe,{value:"overview",children:u("payroll_summary_title")}),e.jsx(Fe,{value:"quickbooks",children:u("payroll_sync_qb")})]}),e.jsxs(Oe,{value:"overview",children:[e.jsxs("div",{className:V.actionsBar,children:[e.jsx("div",{className:V.searchBox,children:e.jsx(K,{placeholder:u("payroll_search_employee"),value:a,onChange:j=>r(j.target.value)})}),e.jsxs("div",{className:V.exportActions,children:[e.jsxs(v,{onClick:rt,variant:"outline",disabled:!n||Pe,children:[e.jsx(Zt,{size:16})," ",u("payroll_export_csv")]}),e.jsxs(Ye,{open:p,onOpenChange:y,children:[e.jsx(Lt,{asChild:!0,children:e.jsxs(v,{variant:"outline",disabled:!n||me,children:[e.jsx(Ys,{size:16})," ",u("payroll_mark_manual")]})}),e.jsxs(Xe,{children:[e.jsxs(ot,{children:[e.jsx(Je,{children:u("payroll_confirm_manual_title")}),e.jsx($t,{children:u("payroll_confirm_manual_desc")})]}),e.jsxs(ft,{children:[e.jsx(v,{variant:"secondary",onClick:()=>y(!1),children:u("payroll_cancel")}),e.jsx(v,{variant:"primary",onClick:Re,disabled:me,children:u("payroll_confirm")})]})]})]})]})]}),e.jsx("div",{className:V.tableContainer,children:e.jsxs("table",{className:V.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsxs("th",{onClick:()=>ge("userName"),className:V.sortableTh,children:[u("payroll_employee")," ",X("userName")]}),e.jsxs("th",{onClick:()=>ge("regularHours"),className:V.sortableTh,children:[u("payroll_regular_pay")," (h) ",X("regularHours")]}),e.jsxs("th",{onClick:()=>
7ge("overtimeHours"),className:V.sortableTh,children:[u("payroll_overtime")," (h) ",X("overtimeHours")]}),e.jsxs("th",{onClick:()=>ge("grossPay"),className:V.sortableTh,children:[u("payroll_gross_pay")," ",X("grossPay")]}),P&&e.jsxs("th",{onClick:()=>ge("totalDeductions"),className:V.sortableTh,children:[u("payroll_deductions_total")," ",X("totalDeductions")]}),P&&e.jsxs("th",{onClick:()=>ge("netPay"),className:V.sortableTh,children:[u("payroll_net_pay")," ",X("netPay")]}),e.jsxs("th",{onClick:()=>ge("status"),className:V.sortableTh,children:[u("payroll_export_status")," ",X("status")]})]})}),e.jsx("tbody",{children:xt?Array.from({length:5}).map((j,A)=>e.jsx("tr",{children:e.jsx("td",{colSpan:P?7:5,children:e.jsx($,{style:{height:"2rem"}})})},A)):G||m?e.jsx("tr",{children:e.jsxs("td",{colSpan:P?7:5,className:V.messageCell,children:[e.jsx(dt,{className:V.errorIcon}),G?.message||m?.message||u("payroll_load_error")]})}):!n&&x?.periods.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:P?7:5,className:V.messageCell,children:e.jsxs("div",{className:V.emptyStateContent,children:[e.jsx(yt,{size:32}),e.jsx("p",{children:e.jsx("strong",{children:u("payroll_no_closed_periods")})}),e.jsx(v,{asChild:!0,variant:"link",children:e.jsx(rs,{to:"/dashboard/hr?tab=timesheets",children:u("payroll_link_periods")})})]})})}):n?M.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:P?7:5,className:V.messageCell,children:[e.jsx(Rt,{})," ",u("payroll_no_data")]})}):e.jsxs(e.Fragment,{children:[M.map(j=>{const A=qe(j.userId),Ie=T?.missingRateUsers?.some(Ue=>Ue.userId===j.userId)||j.hasLaborRate===!1;let Ae=e.jsx(Ne,{variant:"default",children:u("payroll_status_not_exported")});if(A?.exportStatus==="failed")Ae=e.jsxs(wt,{children:[e.jsx(kt,{children:e.jsx(Ne,{variant:"destructive",children:u("payroll_status_failed")})}),e.jsx(Tt,{children:A.exportError})]});else if(A?.exportStatus==="exported"){let Ue=u("payroll_status_exported");A.exportChannel==="quickbooks"&&(Ue=u("payroll_status_exported_qb")),A.exportChannel==="csv"&&(Ue=u("payroll_status_exported_csv")),A.exportChannel==="manual"&&(Ue=u("payroll_status_exported_manual"));const ks=A.exportedAt?new Date(A.exportedAt).toLocaleDateString():"";Ae=e.jsx(Ne,{variant:"success",title:ks,children:Ue})}else A?.exportStatus==="pending"&&(Ae=e.jsx(Ne,{variant:"warning",children:u("payroll_status_pending")}));return e.jsxs("tr",{className:V.tableRow,children:[e.jsx("td",{children:e.jsxs("div",{className:V.employeeCell,children:[j.userName,Ie&&e.jsxs(wt,{children:[e.jsx(kt,{children:e.jsx(rs,{to:"/dashboard/users",children:e.jsx(Ne,{variant:"warning",className:V.smallBadge,children:u("payroll_missing_rate")})})}),e.jsx(Tt,{children:u("payroll_link_employee")})]})]})}),e.jsx("td",{children:j.regularHours.toFixed(2)}),e.jsx("td",{children:j.overtimeHours.toFixed(2)}),e.jsx("td",{children:We(j.grossPay,N)}),P&&e.jsx("td",{children:We(j.totalDeductions,N)}),P&&e.jsx("td",{children:We(j.netPay,N)}),e.jsx("td",{children:Ae})]},j.userId)}),M.length>0&&e.jsxs("tr",{className:V.totalsRow,children:[e.jsx("td",{children:e.jsx("strong",{children:u("payroll_total_row")})}),e.jsx("td",{children:e.jsx("strong",{children:U.regularHours.toFixed(2)})}),e.jsx("td",{children:e.jsx("strong",{children:U.overtimeHours.toFixed(2)})}),e.jsx("td",{children:e.jsx("strong",{children:We(U.grossPay,N)})}),P&&e.jsx("td",{children:e.jsx("strong",{children:We(U.deductions,N)})}),P&&e.jsx("td",{children:e.jsx("strong",{children:We(U.netPay,N)})}),e.jsx("td",{})]})]}):e.jsx("tr",{children:e.jsxs("td",{colSpan:P?7:5,className:V.messageCell,children:[e.jsx(yt,{})," ",u("payroll_select_period_prompt")]})})})]})})]}),e.jsxs(Oe,{value:"quickbooks",children:[e.jsxs("div",{className:V.qbActions,children:[e.jsxs(wt,{children:[e.jsx(kt,{asChild:!0,children:e.jsx("div",{children:e.jsxs(v,{onClick:te,disabled:!n||E||!it,children:[e.jsx(Ga,{size:16}),u("payroll_export_timesheets")]})})}),!it&&e.jsx(Tt,{children:u("payroll_integration_disconnected")})]}),e.jsxs(wt,{children:[e.jsx(kt,{asChild:!0,children:e.jsx("div",{children:e.jsxs(v,{onClick:ze,variant:"secondary",disabled:!n||Ge||!it,children:[e.jsx(Ft,{size:16}),u("payroll_import_stubs")]})})}),!it&&e.jsx(Tt,{children:u("payroll_integration_disconnected")})]})]}),c.length>0&&e.jsxs("div",{className:V.syncErrorsPanel,children:[e.jsxs("h4",{children:[e.jsx(dt,{size:16})," ",u("payroll_integration_errors")]}),e.jsx("ul",{children:c.map((j,A)=>e.jsx("li",{children:j},A))})]}),f&&f.unmappedEmployeeCount>0&&e.jsxs("div",{className:V.diagnosticPanel,children:[e.jsxs("h4",{className:V.diagnosticTitle,children:[e.jsx(Wt,{size:16}),se?"Employés non appariés dans QuickBooks":"Employees Unmatched in QuickBooks"]}),e.jsx("p",{className:V.diagnosticDescription,children:se?"Les employés ci-dessous n'ont pas de fiche QuickBooks correspondante. L'appariement se fait par courriel identique, sinon par nom d'affichage exactement identique.":"The employees below have no matching QuickBooks record. Matching is done by identical email, or by exactly identical display name."}),e.jsxs("div",{className:V.diagnosticGrid,children:[e.jsxs("div",{className:V.diagnosticColumn,children:[e.jsxs("h5",{className:V.diagnosticColumnTitle,children:[e.jsx(Wt,{size:14}),se?`Employés CRM (${f.unmappedEmployeeCount})`:`CRM Employees (${f.unmappedEmployeeCount})`]}),e.jsx("ul",{className:V.diagnosticList,children:f.unmappedEmployeeDetails.map((j,A)=>e.jsxs("li",{className:V.diagnosticListItem,children:[e.jsx("span",{className:V.diagName,children:j.name}),e.jsx("span",{className:V.diagEmail,children:j.email||(se?"Aucun courriel":"No email")}),e.jsx("span",{className:V.diagCount,children:se?`${j.entryCount} entrée(s)`:`${j.entryCount} entry(ies)`})]},A))})]}),e.jsxs("div",{className:V.diagnosticColumn,children:[e.jsxs("h5",{className:V.diagnosticColumnTitle,children:[e.jsx(us,{size:14}),se?`Employés QuickBooks (${f.quickbooksEmployeeCount})`:`QuickBooks Employees (${f.quickbooksEmployeeCount})`]}),f.quickbooksEmployeeCount===0?e.jsx("p",{className:V.diagnosticEmpty,children:se?"Aucun employé n'existe dans le fichier QuickBooks. Vous devez les créer d'abord.":"No employees exist in the QuickBooks file. You must create them first."}):e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:V.diagnosticList,children:f.quickbooksEmployeeNames.map((j,A)=>e.jsxs("li",{className:V.diagnosticListItem,children:[e.jsx("span",{className:V.diagName,children:j.name}),e.jsx("span",{className:V.diagEmail,children:j.email||(se?"Aucun courriel":"No email")})]},A))}),f.quickbooksEmployeeCount>50&&e.jsx("p",{className:V.diagnosticTruncated,children:se?`Liste tronquée aux 50 premiers sur ${f.quickbooksEmployeeCount}.`:`List truncated to first 50 of ${f.quickbooksEmployeeCount}.`})]})]})]})]}),e.jsx(Op,{className:V.stubViewer})]})]})]})};ie({periodId:Ee.number().int().positive().optional(),weekStartDate:I().optional()}).refine(s=>s.periodId!==void 0||s.weekStartDate!==void 0,{message:"Either periodId or weekStartDate must be provided"});const S_=async(s,n)=>{const t=new URLSearchParams;s.periodId!==void 0&&t.set("periodId",s.periodId.toString()),s.weekStartDate!==void 0&&t.set("weekStartDate",s.weekStartDate);const a=await fetch(`/_api/hr/payroll/closures/list?${t.toString()}`,{method:"GET",...n});if(!a.ok){const r=w.parse(await a.text());throw new Error(typeof r=="object"&&r!==null&&"error"in r?String(r.error):"Une erreur inconnue s'est produite")}return w.parse(await a.text())};ie({periodId:B().int().positive().optional(),weekStartDate:I().optional(),userId:B().int().positive(),regularHours:B(),overtimeHours:B(),hoursBanked:B(),totalHoursPaid:B(),hoursPaidOverride:B().optional(),notes:I().optional()}).refine(s=>s.periodId!==void 0||s.weekStartDate!==void 0,{message:"Either periodId or weekStartDate must be provided"});const w_=async(s,n)=>{const t=await fetch("/_api/hr/payroll/closures/close",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json"}});if(!t.ok){const a=w.parse(await t.text());throw new Error(typeof a=="object"&&a!==null&&"error"in a?String(a.error):"Une erreur inconnue s'est produite")}return w.parse(await t.text())};ie({closureId:B().int().positive()});const k_=async(s,n)=>{const t=await fetch("/_api/hr/payroll/closures/reopen",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json"}});if(!t.ok){const a=w.parse(await t.text());throw new Error(typeof a=="object"&&a!==null&&"error"in a?String(a.error):"Une erreur inconnue s'est produite")}return w.parse(await t.text())};ie({});const T_=async s=>{const n=await fetch("/_api/hr/payroll/unpaid-summary",{method:"GET",...s});if(!n.ok){const t=w.parse(await n.text());throw new Error(typeof t=="object"&&t!==null&&"error"in t?String(t.error):"Une erreur inconnue s'est produite")}return w.parse(await n.text())},D_=s=>nt({queryKey:["payroll","closures","week",s],queryFn:()=>S_({weekStartDate:s}),enabled:s.length>0,staleTime:3e4}),I_=()=>nt({queryKey:["payroll","unpaid"],queryFn:()=>T_(),staleTime:3e4}),wa=()=>{const s=Le(),{language:n}=de();return Be({mutationFn:t=>w_(t),onSuccess:()=>{s.invalidateQueries({queryKey:["payroll","closures"]}),s.invalidateQueries({queryKey:["payroll","unpaid"]}),s.invalidateQueries({queryKey:["hoursBank"]}),s.invalidateQueries({queryKey:["hoursBankSummary"]});const t=n==="fr"?"Paie clôturée avec succès":"Payroll closed successfully";ne.success(t)},onError:t=>{const a=n==="fr"?"Erreur: ":"Error: ";ne.error(`${a}${t.message}`)}})},$_=()=>{const s=Le(),{language:n}=de();return Be({mutationFn:t=>k_({closureId:t}),onSuccess:()=>{s.invalidateQueries({queryKey:["payroll","closures"]}),s.invalidateQueries({queryKey:["payroll","unpaid"]}),s.invalidateQueries({queryKey:["hoursBank"]}),s.invalidateQueries({queryKey:["hoursBankSummary"]});const t=n==="fr"?"Paie réouverte avec succès":"Payroll reopened successfully";ne.success(t)},onError:t=>{const a=n==="fr"?"Erreur: ":"Error: ";ne.error(`${a}${t.message}`)}})},E_="_container_1mnlf_2",B_="_header_1mnlf_12",P_="_titleWrapper_1mnlf_18",q_="_titleIcon_1mnlf_25",R_="_title_1mnlf_18",A_="_subtitle_1mnlf_38",L_="_content_1mnlf_44",F_="_tableHeader_1mnlf_49",O_="_row_1mnlf_61",M_="_c
7olName_1mnlf_77",z_="_colHours_1mnlf_82",H_="_colPeriods_1mnlf_89",V_="_employeeName_1mnlf_95",W_="_hoursValue_1mnlf_103",G_="_periodsCount_1mnlf_113",U_="_emptyState_1mnlf_122",Q_="_emptyIcon_1mnlf_132",K_="_errorState_1mnlf_138",Y_="_errorIcon_1mnlf_146",X_="_skeletonText_1mnlf_150",J_="_skeletonBadge_1mnlf_155",Z_="_skeletonTextSmall_1mnlf_161",ve={container:E_,header:B_,titleWrapper:P_,titleIcon:q_,title:R_,subtitle:A_,content:L_,tableHeader:F_,row:O_,colName:M_,colHours:z_,colPeriods:H_,employeeName:V_,hoursValue:W_,periodsCount:G_,emptyState:U_,emptyIcon:Q_,errorState:K_,errorIcon:Y_,skeletonText:X_,skeletonBadge:J_,skeletonTextSmall:Z_},ex={fr:{title:"Résumé des heures non payées",subtitle:"Aperçu global des heures approuvées en attente de paiement.",employee:"Employé",unpaidHours:"Heures non payées",periods:"Périodes concernées",noUnpaid:"Aucune heure en attente de paiement.",error:"Erreur lors du chargement des données."},en:{title:"Unpaid Hours Summary",subtitle:"Global overview of approved hours pending payment.",employee:"Employee",unpaidHours:"Unpaid hours",periods:"Affected periods",noUnpaid:"No hours pending payment.",error:"Error loading data."}},tx=({className:s})=>{const{language:n}=de(),t=d=>ex[n][d],{data:a,isFetching:r,error:o}=I_();return o?e.jsxs("div",{className:`${ve.container} ${ve.errorState} ${s||""}`,children:[e.jsx(dt,{className:ve.errorIcon}),e.jsx("p",{children:t("error")})]}):e.jsxs("div",{className:`${ve.container} ${s||""}`,children:[e.jsxs("div",{className:ve.header,children:[e.jsxs("div",{className:ve.titleWrapper,children:[e.jsx(xs,{className:ve.titleIcon}),e.jsx("h3",{className:ve.title,children:t("title")})]}),e.jsx("p",{className:ve.subtitle,children:t("subtitle")})]}),e.jsxs("div",{className:ve.content,children:[e.jsxs("div",{className:ve.tableHeader,children:[e.jsx("div",{className:ve.colName,children:t("employee")}),e.jsx("div",{className:ve.colHours,children:t("unpaidHours")}),e.jsx("div",{className:ve.colPeriods,children:t("periods")})]}),e.jsx("div",{className:ve.list,children:r?Array.from({length:3}).map((d,h)=>e.jsxs("div",{className:ve.row,children:[e.jsx("div",{className:ve.colName,children:e.jsx($,{className:ve.skeletonText})}),e.jsx("div",{className:ve.colHours,children:e.jsx($,{className:ve.skeletonBadge})}),e.jsx("div",{className:ve.colPeriods,children:e.jsx($,{className:ve.skeletonTextSmall})})]},h)):a?.employees.length===0?e.jsxs("div",{className:ve.emptyState,children:[e.jsx(yt,{className:ve.emptyIcon}),e.jsx("p",{children:t("noUnpaid")})]}):a?.employees.map(d=>e.jsxs("div",{className:ve.row,children:[e.jsx("div",{className:ve.colName,children:e.jsx("span",{className:ve.employeeName,children:d.userName})}),e.jsx("div",{className:ve.colHours,children:e.jsxs("span",{className:ve.hoursValue,children:[d.totalUnpaidHours.toFixed(2)," h"]})}),e.jsx("div",{className:ve.colPeriods,children:e.jsx("span",{className:ve.periodsCount,children:d.unpaidPeriodsCount})})]},d.userId))})]})]})},sx="_row_gdru7_2",ax="_editingRow_gdru7_16",nx="_colName_gdru7_26",rx="_employeeName_gdru7_33",ox="_colStats_gdru7_41",ix="_statGroup_gdru7_48",lx="_statLabel_gdru7_54",cx="_statValue_gdru7_62",dx="_colTotal_gdru7_75",ux="_totalDisplay_gdru7_81",mx="_colStatus_gdru7_88",hx="_statusWrapper_gdru7_94",px="_badge_gdru7_101",_x="_badgeIcon_gdru7_107",xx="_dateHint_gdru7_111",jx="_colActions_gdru7_116",yx="_colEditContent_gdru7_123",gx="_editForm_gdru7_129",fx="_formInputs_gdru7_136",vx="_compactFormItem_gdru7_143",bx="_inputGroup_gdru7_147",Nx="_inputLabel_gdru7_153",Cx="_numInput_gdru7_161",Sx="_readOnlyGroup_gdru7_168",wx="_readValue_gdru7_174",kx="_textSuccess_gdru7_185",Tx="_textError_gdru7_189",Dx="_textPrimary_gdru7_193",Ix="_notesItem_gdru7_197",$x="_actions_gdru7_209",z={row:sx,editingRow:ax,colName:nx,employeeName:rx,colStats:ox,statGroup:ix,statLabel:lx,statValue:cx,colTotal:dx,totalDisplay:ux,colStatus:mx,statusWrapper:hx,badge:px,badgeIcon:_x,dateHint:xx,colActions:jx,colEditContent:yx,editForm:gx,formInputs:fx,compactFormItem:vx,inputGroup:bx,inputLabel:Nx,numInput:Cx,readOnlyGroup:Sx,readValue:wx,textSuccess:kx,textError:Tx,textPrimary:Dx,notesItem:Ix,actions:$x},Ex={fr:{markPaid:"Marquer payé",reopen:"Réouvrir",cancel:"Annuler",save:"Enregistrer",paid:"Payé",pending:"En attente",regular:"Reg",overtime:"Sup",banked:"Banque",total:"Total",notes:"Notes optionnelles",hoursWorked:"Travaillées",bankBalance:"Solde banque",hoursToPay:"Heures à payer",bankAdjustment:"Ajust. banque",newBalance:"Nouveau solde",netHours:"Heures nettes"},en:{markPaid:"Mark Paid",reopen:"Reopen",cancel:"Cancel",save:"Save",paid:"Paid",pending:"Pending",regular:"Reg",overtime:"OT",banked:"Bank",total:"Total",notes:"Optional notes",hoursWorked:"Worked",bankBalance:"Bank Balance",hoursToPay:"Hours to Pay",bankAdjustment:"Bank Adj.",newBalance:"New Balance",netHours:"Net Hours"}},Bx=ie({hoursToPay:Ee.number().min(0,"Invalid"),notes:I().optional()}),Px=({weekStartDate:s,summary:n,closure:t})=>{const{language:a}
7=de(),r=D=>Ex[a][D],o=a==="fr"?"fr-CA":"en-CA",[d,h]=g.useState(!1),i=wa(),c=$_(),_=t?.status==="paid",p=Number(n.regularHours??0),y=Number(n.overtimeHours??0),f=Number(n.hoursBankBalance??0),S=p+y,u=t?.totalHoursPaid!=null?Number(t.totalHoursPaid):40,N=Pt({schema:Bx,defaultValues:{hoursToPay:u,notes:t?.notes||""}}),C=D=>{i.mutate({weekStartDate:s,userId:n.userId,regularHours:p,overtimeHours:y,hoursBanked:0,totalHoursPaid:D.hoursToPay,hoursPaidOverride:D.hoursToPay,notes:D.notes},{onSuccess:()=>{h(!1)}})},q=()=>{t?.id&&c.mutate(t.id)},l=D=>D?new Intl.DateTimeFormat(o,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(new Date(D)):"",x=Number(N.values.hoursToPay)||0,b=S-x,T=f+b;return d?e.jsxs("div",{className:`${z.row} ${z.editingRow}`,children:[e.jsx("div",{className:z.colName,children:e.jsx("span",{className:z.employeeName,children:n.userName})}),e.jsx("div",{className:z.colEditContent,children:e.jsx(qt,{...N,children:e.jsxs("form",{className:z.editForm,onSubmit:N.handleSubmit(C),children:[e.jsxs("div",{className:z.formInputs,children:[e.jsxs("div",{className:z.readOnlyGroup,children:[e.jsx("span",{className:z.inputLabel,children:r("hoursWorked")}),e.jsxs("span",{className:z.readValue,children:[S.toFixed(2),"h"]})]}),e.jsxs("div",{className:z.readOnlyGroup,children:[e.jsx("span",{className:z.inputLabel,children:r("bankBalance")}),e.jsxs("span",{className:`${z.readValue} ${f>=0?z.textSuccess:z.textError}`,children:[f.toFixed(2),"h"]})]}),e.jsxs(J,{name:"hoursToPay",className:z.compactFormItem,children:[e.jsxs("div",{className:z.inputGroup,children:[e.jsx("span",{className:z.inputLabel,children:r("hoursToPay")}),e.jsx(ee,{children:e.jsx(Qt,{min:0,maxDecimals:2,value:N.values.hoursToPay,onValueChange:D=>N.setValues(G=>({...G,hoursToPay:D??0})),emptyValue:0,className:z.numInput})})]}),e.jsx(oe,{})]}),e.jsxs("div",{className:z.readOnlyGroup,children:[e.jsx("span",{className:z.inputLabel,children:r("bankAdjustment")}),e.jsxs("span",{className:z.readValue,children:[b>0?"+":"",b.toFixed(2),"h"]})]}),e.jsxs("div",{className:z.readOnlyGroup,children:[e.jsx("span",{className:z.inputLabel,children:r("newBalance")}),e.jsxs("span",{className:`${z.readValue} ${T>=0?z.textSuccess:z.textError}`,children:[T.toFixed(2),"h"]})]}),e.jsx(J,{name:"notes",className:z.notesItem,children:e.jsx(ee,{children:e.jsx(K,{placeholder:r("notes"),value:N.values.notes,onChange:D=>N.setValues(G=>({...G,notes:D.target.value}))})})})]}),e.jsxs("div",{className:z.actions,children:[e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>{h(!1),N.setValues({hoursToPay:u,notes:t?.notes||""})},disabled:i.isPending,children:r("cancel")}),e.jsxs(v,{type:"submit",variant:"primary",size:"sm",disabled:i.isPending,children:[e.jsx(Ks,{size:14}),r("save")]})]})]})})})]}):e.jsxs("div",{className:z.row,children:[e.jsx("div",{className:z.colName,children:e.jsx("span",{className:z.employeeName,children:n.userName})}),e.jsxs("div",{className:z.colStats,children:[e.jsxs("div",{className:z.statGroup,children:[e.jsx("span",{className:z.statLabel,children:r("regular")}),e.jsxs("span",{className:z.statValue,children:[p.toFixed(2),"h"]})]}),e.jsxs("div",{className:z.statGroup,children:[e.jsx("span",{className:z.statLabel,children:r("overtime")}),e.jsxs("span",{className:z.statValue,children:[y.toFixed(2),"h"]})]}),e.jsxs("div",{className:z.statGroup,children:[e.jsx("span",{className:z.statLabel,children:r("banked")}),e.jsxs("span",{className:`${z.statValue} ${f>=0?z.textSuccess:z.textError}`,children:[f.toFixed(2),"h"]})]})]}),e.jsx("div",{className:z.colTotal,children:e.jsxs("span",{className:`${z.totalDisplay} ${z.textPrimary}`,children:[(_?u:S).toFixed(2),"h"]})}),e.jsx("div",{className:z.colStatus,children:_?e.jsxs("div",{className:z.statusWrapper,children:[e.jsxs(Ne,{variant:"success",className:z.badge,children:[e.jsx(ms,{size:12,className:z.badgeIcon}),r("paid")]}),t?.paidAt&&e.jsx("span",{className:z.dateHint,children:l(t.paidAt)})]}):e.jsxs(Ne,{variant:"warning",className:z.badge,children:[e.jsx(Ua,{size:12,className:z.badgeIcon}),r("pending")]})}),e.jsx("div",{className:z.colActions,children:_?e.jsxs(v,{variant:"outline",size:"sm",onClick:q,disabled:c.isPending,children:[e.jsx(Qa,{size:14}),r("reopen")]}):e.jsx(v,{variant:"primary",size:"sm",onClick:()=>h(!0),children:r("markPaid")})})]})},qx="_container_swq97_2",Rx="_header_swq97_9",Ax="_headerTitle_swq97_28",Lx="_iconWrapper_swq97_34",Fx="_title_swq97_45",Ox="_subtitle_swq97_52",Mx="_controls_swq97_58",zx="_weekNavigator_swq97_65",Hx="_weekDisplay_swq97_75",Vx="_weekDisplayIcon_swq97_86",Wx="_weekDisplayText_swq97_90",Gx="_todayButton_swq97_95",Ux="_bulkButton_swq97_99",Qx="_summarySection_swq97_103",Kx="_summaryToggle_swq97_109",Yx="_unpaidSection_swq97_121",Xx="_tableContainer_swq97_127",Jx="_tableHeader_swq97_136",Zx="_colName_swq97_149",ej="_colDetails_swq97_154",tj="_colTotal_swq97_159",sj="_colStatus_swq97_164",aj="_colActions_swq97_168",nj="_list_swq97_173",rj="_skeletonRow_swq97_178",oj="_skeletonItem_swq97_191",ij="_emptyState_swq97_196",lj="_emptyIcon_swq97_207",je={container:qx,header:Rx,headerTitle:Ax,iconWrapper:Lx,title:Fx,subtitle:Ox,controls:Mx,weekNavigator:zx,weekDisplay:Hx,weekDisplayIcon:Vx,weekDisplayText:Wx,todayButton:Gx,bulkButton:Ux,summarySection:Qx,summaryToggle:Kx,unpaidSection:Yx,tableContainer:Xx,tableHeader:Jx,colName:Zx,colDetails:ej,colTotal:tj,colStatus:sj,colActions:aj,list:nj,skeletonRow:rj,skeletonItem:oj,emptyState:ij,emptyIcon:lj},cj={fr:{title:"Clôture de la paie",subtitle:"Sélectionnez une semaine pour valider et clôturer les heures des employés.",bulkPay:"Marquer tous payés",noData:"Aucune donnée de paie disponible pour cette semaine.",loading:"Chargement...",confirmBulkPay:"Êtes-vous sûr de vouloir marquer tous les employés de cette semaine comme payés ?",bulkSuccess:"Toutes les paies ont été clôturées avec succès.",bulkError:"Une erreur est survenue lors de la clôture en lot.",colName:"Employé",colDetails:"Détails",colTotal:"Total à payer",colStatus:"Statut",colActions:"Actions",prevWeek:"Semaine précédente",nextWeek:"Semaine suivante",today:"Aujourd'hui",weekOf:"Semaine du",showSummary:"Afficher le résumé des heures non payées",hideSummary:"Masquer le résumé des heures non payées"},en:{title:"Payroll Closure",subtitle:"Select a week to validate and close employee hours.",bulkPay:"Mark all paid",noData:"No payroll data available for this week.",loading:"Loading...",confirmBulkPay:"Are you sure you want to mark all employees in this week as paid?",bulkSuccess:"All payrolls have been successfully closed.",bulkError:"An error occurred during bulk closure.",colName:"Employee",colDetails:"Details",colTotal:"Total to Pay",colStatus:"Status",colActions:"Actions",prevWeek:"Previous week",nextWeek:"Next week",today:"Today",weekOf:"Week of",showSummary:"Show unpaid hours summary",hideSummary:"Hide unpaid hours summary"}},zs=s=>{const n=new Date(s),t=n.getDay(),a=n.getDate()-t+(t===0?-6:1);return n.setDate(a),n.setHours(0,0,0,0),n},dj=s=>{const n=s.getFullYear(),t=String(s.getMonth()+1).padStart(2,"0"),a=String(s.getDate()).padStart(2,"0");return`${n}-${t}-${a}`},uj=({className:s})=>{const{language:n}=de(),t=l=>cj[n][l],[a,r]=g.useState(()=>zs(new Date)),[o,d]=g.useState(!1),[h,i]=g.useState(!1),c=dj(a),{data:_,isFetching:p}=D_(c),y=wa(),f=l=>{r(x=>{const b=new Date(x);return b.setDate(b.getDate()+l*7),b})},S=()=>{r(zs(new Date))},u=()=>{const l=new Date(a);l.setDate(l.getDate()+6);const x=n==="fr"?"fr-CA":"en-CA",b=new Intl.DateTimeFormat(x,{weekday:"short",day:"numeric",month:"short"}),T=new Intl.DateTimeFormat(x,{weekday:"short",day:"numeric",month:"short",year:"numeric"});return`${b.format(a)} - ${T.format(l)}`},N=async()=>
7{if(!(!_?.periodEmployees||!window.confirm(t("confirmBulkPay")))){d(!0);try{const x=_.periodEmployees.filter(b=>_?.closures.find(D=>D.userId===b.userId)?.status!=="paid").map(b=>{const T=Number(b.regularHours||0),D=Number(b.overtimeHours||0);return y.mutateAsync({weekStartDate:c,userId:b.userId,regularHours:T,overtimeHours:D,hoursBanked:0,totalHoursPaid:T+D})});await Promise.all(x),ne.success(t("bulkSuccess"))}catch{ne.error(t("bulkError"))}finally{d(!1)}}},C=p,q=_?.periodEmployees.some(l=>_?.closures.find(b=>b.userId===l.userId)?.status!=="paid");return e.jsxs("div",{className:`${je.container} ${s||""}`,children:[e.jsxs("header",{className:je.header,children:[e.jsxs("div",{className:je.headerTitle,children:[e.jsx("div",{className:je.iconWrapper,children:e.jsx(Ot,{size:20})}),e.jsxs("div",{children:[e.jsx("h2",{className:je.title,children:t("title")}),e.jsx("p",{className:je.subtitle,children:t("subtitle")})]})]}),e.jsxs("div",{className:je.controls,children:[e.jsxs("div",{className:je.weekNavigator,children:[e.jsx(v,{variant:"outline",size:"icon",onClick:()=>f(-1),title:t("prevWeek"),children:e.jsx(Kt,{size:16})}),e.jsxs("div",{className:je.weekDisplay,children:[e.jsx(ut,{size:14,className:je.weekDisplayIcon}),e.jsx("span",{className:je.weekDisplayText,children:u()})]}),e.jsx(v,{variant:"outline",size:"icon",onClick:()=>f(1),title:t("nextWeek"),children:e.jsx(vt,{size:16})}),e.jsx(v,{variant:"outline",onClick:S,className:je.todayButton,children:t("today")})]}),q&&e.jsxs(v,{variant:"primary",onClick:N,disabled:o||C,className:je.bulkButton,children:[e.jsx(ms,{size:16}),t("bulkPay")]})]})]}),e.jsxs("div",{className:je.summarySection,children:[e.jsxs(v,{variant:"ghost",className:je.summaryToggle,onClick:()=>i(!h),children:[h?e.jsx(Xs,{size:16}):e.jsx(Xt,{size:16}),t(h?"hideSummary":"showSummary")]}),h&&e.jsx("div",{className:je.unpaidSection,children:e.jsx(tx,{})})]}),e.jsx("div",{className:je.content,children:e.jsxs("div",{className:je.tableContainer,children:[e.jsxs("div",{className:je.tableHeader,children:[e.jsx("div",{className:je.colName,children:t("colName")}),e.jsx("div",{className:je.colDetails,children:t("colDetails")}),e.jsx("div",{className:je.colTotal,children:t("colTotal")}),e.jsx("div",{className:je.colStatus,children:t("colStatus")}),e.jsx("div",{className:je.colActions,children:t("colActions")})]}),e.jsx("div",{className:je.list,children:C?Array.from({length:4}).map((l,x)=>e.jsxs("div",{className:je.skeletonRow,children:[e.jsx($,{className:je.skeletonItem,style:{width:"20%"}}),e.jsx($,{className:je.skeletonItem,style:{width:"30%"}}),e.jsx($,{className:je.skeletonItem,style:{width:"10%"}}),e.jsx($,{className:je.skeletonItem,style:{width:"15%"}}),e.jsx($,{className:je.skeletonItem,style:{width:"15%"}})]},x)):_?.periodEmployees.length===0?e.jsxs("div",{className:je.emptyState,children:[e.jsx(yt,{size:32,className:je.emptyIcon}),e.jsx("p",{children:t("noData")})]}):_?.periodEmployees.map(l=>{const x=_?.closures.find(b=>b.userId===l.userId);return e.jsx(Px,{weekStartDate:c,summary:l,closure:x},l.userId)})})]})})]})},mj="_approvalInterface_vjri0_1",hj="_header_vjri0_11",pj="_actions_vjri0_27",_j="_approveButton_vjri0_32",xj="_rejectButton_vjri0_42",jj="_notesSection_vjri0_51",yj="_tableContainer_vjri0_55",gj="_table_vjri0_55",fj="_tableRow_vjri0_84",vj="_groupRow_vjri0_92",bj="_subRow_vjri0_101",Nj="_groupUserCell_vjri0_110",Cj="_expandButton_vjri0_117",Sj="_userName_vjri0_136",wj="_groupEditButton_vjri0_141",kj="_projectSummary_vjri0_151",Tj="_totalHours_vjri0_156",Dj="_subCheckbox_vjri0_160",Ij="_subCell_vjri0_166",$j="_subCellHours_vjri0_172",Ej="_hoursWithWarning_vjri0_177",Bj="_unusualDurationBadge_vjri0_183",Pj="_subEntryType_vjri0_187",qj="_checkboxColumn_vjri0_196",Rj="_actionsColumn_vjri0_201",Aj="_actionButtons_vjri0_206",Lj="_ccqInfoWrapper_vjri0_212",Fj="_warningIcon_vjri0_222",Oj="_ccqInfoText_vjri0_227",Mj="_error_vjri0_234",zj="_noEntries_vjri0_235",he={approvalInterface:mj,header:hj,actions:pj,approveButton:_j,rejectButton:xj,notesSection:jj,tableContainer:yj,table:gj,tableRow:fj,groupRow:vj,subRow:bj,groupUserCell:Nj,expandButton:Cj,userName:Sj,groupEditButton:wj,projectSummary:kj,totalHours:Tj,subCheckbox:Dj,subCell:Ij,subCellHours:$j,hoursWithWarning:Ej,unusualDurationBadge:Bj,subEntryType:Pj,checkboxColumn:qj,actionsColumn:Rj,actionButtons:Aj,ccqInfoWrapper:Lj,warningIcon:Fj,ccqInfoText:Oj,error:Mj,noEntries:zj},Hj=({group:s,isExpanded:n,onToggleExpand:t,selectedIds:a,onSelectionChange:r,onGroupSelectionChange:o,onModify:d,onOpenEditor:h,onViewDay:i,language:c,isCcqApplicable:_,t:p})=>{const y=s.entries.length>0&&s.entries.every(l=>a.includes(l.id)),f=l=>e.jsx(Ne,{variant:l==="submitted"?"warning":"default",children:l}),S=l=>{const x=[];if(l.tradeNameFr&&x.push(c==="en"&&l.tradeNameEn?l.tradeNameEn:l.tradeNameFr),l.ccqWorkerLevel&&(l.ccqWorkerLevel==="compagnon"?x.push(p("ccq_level_compagnon")):l.ccqWorkerLevel==="occupation"?x.push(p("ccq_level_occupation")):l.ccqWorkerLevel.startsWith("apprentice_")?x.push(`${p("ccq_level_apprentice")} ${l.ccqWorkerLevel.split("_")[1]}`):x.push(l.ccqWorkerLevel)),l.ccqSector){const b={civil_engineering:p("ccq_sector_civil"),industrial:p("ccq_sector_industrial"),institutional_commercial:p("ccq_sector_institutional"),residential_heavy:p("ccq_sector_residential_heavy"),residential_light:p("ccq_sector_residential_light")};b[l.ccqSector]&&x.push(b[l.ccqSector])}if(l.shiftType){const b={day:p("ccq_shift_day"),evening:p("ccq_shift_evening"),night:p("ccq_shift_night")};
7b[l.shiftType]&&x.push(b[l.shiftType])}return x.join(" • ")},u=s.entries.length,N=new Set(s.entries.map(l=>l.projectId).filter(Boolean)).size,C=c==="en"?`${u} entr${u!==1?"ies":"y"} / ${N} project${N!==1?"s":""}`:`${u} entrée${u!==1?"s":""} / ${N} projet${N!==1?"s":""}`,q=l=>l?new Date(l).toLocaleTimeString(c,{hour:"2-digit",minute:"2-digit"}):"";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`${he.tableRow} ${he.groupRow}`,children:[e.jsx("td",{children:e.jsx(Bt,{checked:y,onCheckedChange:l=>o(s,l===!0),"aria-label":c==="en"?`Select group for ${s.userName}`:`Sélectionner le groupe pour ${s.userName}`})}),e.jsx("td",{children:e.jsxs("div",{className:he.groupUserCell,children:[e.jsx("button",{type:"button",className:he.expandButton,onClick:t,"aria-label":c==="en"?"Toggle details":"Basculer les détails",children:n?e.jsx(Xt,{size:16}):e.jsx(vt,{size:16})}),e.jsx("span",{className:he.userName,onClick:t,children:s.userName}),e.jsx(v,{size:"icon-sm",variant:"ghost",className:he.groupEditButton,onClick:l=>{l.stopPropagation(),i(s)},title:c==="en"?"View timeline":"Voir la ligne du temps","aria-label":c==="en"?`View timeline for ${s.userName}`:`Voir la ligne du temps pour ${s.userName}`,children:e.jsx(ps,{size:14})}),e.jsx(v,{size:"icon-sm",variant:"ghost",className:he.groupEditButton,onClick:l=>{l.stopPropagation(),h(s)},title:c==="en"?"Edit day":"Modifier la journée","aria-label":c==="en"?`Edit day for ${s.userName}`:`Modifier la journée pour ${s.userName}`,children:e.jsx(Vt,{size:14})})]})}),e.jsx("td",{children:e.jsx("span",{className:he.projectSummary,children:C})}),e.jsx("td",{children:vs(s.date)}),e.jsx("td",{className:he.totalHours,children:Ut(s.totalHours)}),e.jsx("td",{children:f(s.status)}),_&&e.jsx("td",{}),e.jsx("td",{})]}),n&&s.entries.map(l=>e.jsxs("tr",{className:`${he.tableRow} ${he.subRow}`,children:[e.jsx("td",{children:e.jsx("div",{className:he.subCheckbox,children:e.jsx(Bt,{checked:a.includes(l.id),onCheckedChange:x=>r(l.id,x===!0),"aria-label":c==="en"?`Select entry ${l.id}`:`Sélectionner l'entrée ${l.id}`})})}),e.jsx("td",{className:he.subCell,children:e.jsx("span",{className:he.subEntryType,children:l.entryType==="travel"?c==="en"?"Travel":"Déplacement":l.entryType==="client_work"?c==="en"?"Client Work":"Travail Client":l.entryType})}),e.jsx("td",{className:he.subCell,children:l.projectName||"-"}),e.jsxs("td",{className:he.subCell,children:[q(l.startTime),l.endTime?` - ${q(l.endTime)}`:""]}),e.jsx("td",{className:he.subCellHours,children:e.jsxs("div",{className:he.hoursWithWarning,children:[Ut(l.hoursWorked),l.hoursWorked>12&&e.jsx(Ne,{variant:"warning",className:he.unusualDurationBadge,children:c==="en"?"Unusual duration (>12 h) — forgotten punch?":"Durée inhabituelle (>12 h) — punch oublié ?"}),e.jsx(ja,{entry:l})]})}),e.jsx("td",{}),_&&e.jsx("td",{className:he.subCell,children:e.jsxs("div",{className:he.ccqInfoWrapper,children:[l.entryType==="client_work"&&(!l.ccqTradeId||!l.ccqWorkerLevel||!l.ccqSector)&&e.jsx("span",{title:c==="en"?"Missing CCQ information":"Informations CCQ manquantes",children:e.jsx(dt,{size:14,className:he.warningIcon})}),e.jsx("span",{className:he.ccqInfoText,title:S(l),children:S(l)||(c==="en"?"No CCQ data":"Aucune donnée CCQ")})]})}),e.jsx("td",{children:e.jsx("div",{className:he.actionButtons,children:e.jsx(v,{size:"icon-sm",variant:"ghost",onClick:()=>d(l),"aria-label":c==="en"?`Modify entry for ${l.userName}`:`Modifier l'entrée pour ${l.userName}`,children:e.jsx(Vt,{size:14})})})})]},l.id))]})},Vj=({className:s})=>{const{t:n,language:t}=de(),{isCcqApplicable:a}=da(),[r,o]=g.useState([]),[d,h]=g.useState(new Set),[i,c]=g.useState(""),[_,p]=g.useState(!1),[y,f]=g.useState(null),[S,u]=g.useState(null),[N,C]=g.useState(!1),[q,l]=g.useState(null),[x,b]=g.useState(!1),{data:T,isFetching:D,error:G,refetch:H}=At({status:"submitted",page:1}),Z=Nn(),m=Cn(),{authState:R}=ea(),E=R.type==="authenticated"?R.user.id:null,Ce=g.useMemo(()=>{const U=new Map;return(T?.entries??[]).filter(X=>X.userId!==E).forEach(X=>{const se=X.date?new Date(X.date).toISOString().split("T")[0]:"nodate",j=X.dayGroupId||`${X.userId}-${se}`;U.has(j)||U.set(j,{id:j,userId:X.userId,userName:X.userName,date:X.date,totalHours:0,entries:[],status:X.status||"submitted",hasSupervisor:X.hasSupervisor});const A=U.get(j);A.totalHours+=X.hoursWorked,A.entries.push(X)}),Array.from(U.values()).sort((X,se)=>{const j=X.date?new Date(X.date).getTime():0,A=se.date?new Date(se.date).getTime():0;return A!==j?A-j:X.userName.localeCompare(se.userName)})},[T?.entries,E]),Ge=g.useMemo(()=>Ce.flatMap(U=>U.entries.map(ge=>ge.id)),[Ce]),xe=(U,ge)=>{o(X=>ge?[...X,U]:X.filter(se=>se!==U))},Pe=(U,ge)=>{const X=U.entries.map(se=>se.id);o(se=>{if(ge){const j=new Set([...se,...X]);return Array.from(j)}else return se.filter(j=>!X.includes(j))})},_t=U=>{h(ge=>{const X=new Set(ge);return X.has(U)?X.delete(U):X.add(U),X})},me=U=>{o(U?Ge:[])},Ze=()=>{r.length!==0&&Z.mutate({ids:r,approvalNotes:i||void 0},{onSuccess:()=>{o([]),c("")}})},xt=()=>{r.length!==0&&m.mutate({ids:r,approvalNotes:i||void 0},{onSuccess:()=>{o([]),c("")}})},it=U=>{f(U),p(!0)},P=()=>{p(!1),f(null),H()},te=()=>{p(!1),f(null)},ze=U=>{u(U),C(!0)},rt=U=>{l(U),b(!0)},Re=g.useMemo(()=>Ge.length>0&&r.length===Ge.length,[Ge,r]),qe=Z.isPending||m.isPending,M={title:t==="en"?"Pending Foreman Approval":"En Attente d'Approbation du Contremaître",reject:t==="en"?"Reject Selected":"Rejeter la Sélection",approve:t==="en"?"Approve Selected":"Approuver la Sélection",notesPlaceholder:t==="en"?"Optional notes for approval or rejection...":"Notes optionnelles pour approbation ou rejet...",employee:t==="en"?"Employee":"Employé",project:t==="en"?"Project":"Projet",date:"Date",hours:t==="en"?"Hours":"Heures",status:t==="en"?"Status":"Statut",actions:"Actions",selectAll:t==="en"?"Select all entries":"Sélectionner toutes les entrées",loadingError:t==="en"?"Failed to load entries.":"Échec du chargement des entrées.",noEntries:t==="en"?"No entries pending approval.":"Aucune entrée en attente d'approbation."};return e.jsxs("div",{className:`${he.approvalInterface} ${s||""}`,children:[e.jsxs("header",{className:he.header,children:[e.jsx("h3",{children:M.title}),e.jsxs("div",{className:he.actions,children:[e.jsxs(v,{variant:"outline",onClick:xt,disabled:r.length===0||qe,className:he.rejectButton,children:[e.jsx(Ka,{size:16})," ",M.reject]}),e.jsxs(v,{onClick:Ze,disabled:r.length===0||qe,className:he.approveButton,children:[e.jsx(Ya,{size:16})," ",M.approve]})]})]}),e.jsx("div",{className:he.notesSection,children:e.jsx(es,{placeholder:M.notesPlaceholder,value:i,onChange:U=>c(U.target.value),disabled:qe})}),e.jsx("div",{className:he.tableContainer,children:e.jsxs("table",{className:he.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:he.checkboxColumn,children:e.jsx(Bt,{checked:Re,onCheckedChange:U=>me(U===!0),"aria-label":M.selectAll})}),e.jsx("th",{children:M.employee}),e.jsx("th",{children:M.project}),e.jsx("th",{children:M.date}),e.jsx("th",{children:M.hours}),e.jsx("th",{children:M.status}),a&&e.jsx("th",{children:"CCQ"}),e.jsx("th",{className:he.actionsColumn,children:M.actions})]})}),e.jsx("tbody",{children:D?Array.from({length:5}).map((U,ge)=>e.jsx("tr",{className:he.tableRow,children:e.jsx("td",{colSpan:a?8:7,children:e.jsx($,{style:{height:"2rem"}})})},ge)):G?e.jsx("tr",{children:e.jsx("td",{colSpan:a?8:7,className:he.error,children:M.loadingError})}):Ce.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:a?8:7,className:he.noEntries,children:M.noEntries})}):Ce.map(U=>e.jsx(Hj,{group:U,isExpanded:d.has(U.id),onToggleExpand:()=>_t(U.id),selectedIds:r,onSelectionChange:xe,onGroupSelectionChange:Pe,onModify:it,onOpenEditor:ze,onViewDay:rt,language:t,isCcqApplicable:a,t:n},U.id))})]})}),e.jsx(sa,{entry:y,isOpen:_,onClose:te,onSuccess:P}),q&&e.jsx(fs,{isOpen:x,onClose:()=>
7b(!1),entries:q.entries,userName:q.userName,date:q.date,onOpenEditor:()=>{b(!1),ze(q)}}),S&&e.jsx(ca,{isOpen:N,onClose:()=>C(!1),entries:S.entries,userName:S.userName,date:S.date,onSuccess:()=>H()})]})};ie({page:B().int().min(1).default(1),limit:B().int().min(1).max(100).default(20),assetType:Me(["inventory_item","vehicle"]).optional(),depreciationMethod:Me(["declining_balance","straight_line"]).optional()});const Wj=async(s,n)=>{const t={};s.page&&(t.page=s.page.toString()),s.limit&&(t.limit=s.limit.toString()),s.assetType&&(t.assetType=s.assetType),s.depreciationMethod&&(t.depreciationMethod=s.depreciationMethod);const a=await fetch(`/_api/asset-depreciation/list?${new URLSearchParams(t).toString()}`,{method:"GET",...n,headers:{"Content-Type":"application/json"}});if(!a.ok){const r=w.parse(await a.text());throw new Error(r.error)}return w.parse(await a.text())},Gj=async s=>{const n=await fetch("/_api/asset-depreciation/summary",{method:"GET",...s,headers:{"Content-Type":"application/json"}});if(!n.ok){const t=w.parse(await n.text());throw new Error(t.error)}return w.parse(await n.text())};ie({assetType:Me(["inventory_item","vehicle"]),inventoryItemId:B().optional().nullable(),vehicleId:B().optional().nullable(),assetName:I().min(1),purchaseCost:B().min(0),residualValue:B().min(0).default(0),usefulLifeYears:B().min(1),depreciationMethod:Me(["declining_balance","straight_line"]),decliningRate:B().min(0).max(100).optional().nullable(),inServiceDate:lt(),disposalDate:lt().optional().nullable(),notes:I().optional().nullable()}).refine(s=>!(s.depreciationMethod==="declining_balance"&&!s.decliningRate),{message:"Declining rate is required for the declining balance method."});const Uj=async(s,n)=>{const t=await fetch("/_api/asset-depreciation/create",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json"}});if(!t.ok){const a=w.parse(await t.text());throw new Error(a.error)}return w.parse(await t.text())};ie({id:B().int().min(1),assetType:Me(["inventory_item","vehicle"]).optional(),inventoryItemId:B().optional().nullable(),vehicleId:B().optional().nullable(),assetName:I().min(1).optional(),purchaseCost:B().min(0).optional(),residualValue:B().min(0).optional(),usefulLifeYears:B().min(1).optional(),depreciationMethod:Me(["declining_balance","straight_line"]).optional(),decliningRate:B().min(0).max(100).optional().nullable(),inServiceDate:lt().optional(),disposalDate:lt().optional().nullable(),notes:I().optional().nullable()}).refine(s=>!(s.depreciationMethod==="declining_balance"&&!s.decliningRate),{message:"Declining rate is required for the declining balance method."});const Qj=async(s,n)=>{const t=await fetch("/_api/asset-depreciation/update",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json"}});if(!t.ok){const a=w.parse(await t.text());throw new Error(a.error)}return w.parse(await t.text())};ie({id:B().int().min(1)});const Kj=async(s,n)=>{const t=await fetch("/_api/asset-depreciation/delete",{method:"POST",body:w.stringify(s),...n,headers:{"Content-Type":"application/json"}});if(!t.ok){const a=w.parse(await t.text());throw new Error(a.error)}return w.parse(await t.text())},as="asset-depreciation-list",ns="asset-depreciation-summary";function Yj(s){return nt({queryKey:[as,s],queryFn:()=>Wj(s)})}function Xj(){return nt({queryKey:[ns],queryFn:()=>Gj()})}function Jj(){const s=Le();return Be({mutationFn:n=>Uj(n),onSuccess:()=>{s.invalidateQueries({queryKey:[as]}),s.invalidateQueries({queryKey:[ns]})}})}function Zj(){const s=Le();return Be({mutationFn:n=>Qj(n),onSuccess:()=>{s.invalidateQueries({queryKey:[as]}),s.invalidateQueries({queryKey:[ns]})}})}function ey(){const s=Le();return Be({mutationFn:n=>Kj(n),onSuccess:()=>{s.invalidateQueries({queryKey:[as]}),s.invalidateQueries({queryKey:[ns]})}})}const ty="_container_km7mn_2",sy="_summaryGrid_km7mn_8",ay="_summaryCard_km7mn_14",ny="_summaryLabel_km7mn_25",ry="_summaryValue_km7mn_31",oy="_skeletonValue_km7mn_38",iy="_toolbar_km7mn_44",ly="_filters_km7mn_52",cy="_tableContainer_km7mn_59",dy="_table_km7mn_59",uy="_skeletonRow_km7mn_96",my="_emptyState_km7mn_101",hy="_pagination_km7mn_107",py="_pageText_km7mn_116",_y="_actions_km7mn_121",xy="_deleteButton_km7mn_126",jy="_form_km7mn_134",yy="_grid2_km7mn_141",gy="_dialogContent_km7mn_147",fy="_deletePrompt_km7mn_152",vy="_optionalText_km7mn_157",ae={container:ty,summaryGrid:sy,summaryCard:ay,summaryLabel:ny,summaryValue:ry,skeletonValue:oy,toolbar:iy,filters:ly,tableContainer:cy,table:dy,skeletonRow:uy,emptyState:my,pagination:hy,pageText:py,actions:_y,deleteButton:xy,form:jy,grid2:yy,dialogContent:gy,deletePrompt:fy,optionalText:vy},Hs={fr:{totalAssets:"Total des actifs",purchaseCost:"Coût d'acquisition total",accumulatedDepreciation:"Amortissement cumulé",netBookValue:"Valeur nette comptable",annualExpense:"Charge annuelle",allTypes:"Tous les types",inventory:"Inventaire",vehicle:"Véhicule",allMethods:"Toutes les méthodes",straightLine:"Linéaire",decliningBalance:"Dégressif",addAsset:"Ajouter un actif",editAsset:"Modifier l'actif",assetName:"Nom de l'actif",type:"Type",method:"Méthode",purchaseCostLabel:"Coût d'acquisition",residualValue:"Valeur résiduelle",usefulLife:"Durée de vie (années)",rate:"Taux (%)",inService:"Mise en service",disposal:"Mise au rebut",notes:"Notes",actions:"Actions",cancel:"Annuler",save:"Enregistrer",delete:"Supprimer",confirmDeleteTitle:"Confirmer la suppression",confirmDeleteMsg:"Êtes-vous sûr de vouloir supprimer cet actif ?",page:"Page",of:"sur",noData:"Aucun actif trouvé",selectInventory:"Sélectionner un article",selectVehicle:"Sélectionner un véhicule",none:"Aucun",optional:"(Optionnel)"},en:{totalAssets:"Total Assets",purchaseCost:"Total Purchase Cost",accumulatedDepreciation:"Accumulated Depreciation",netBookValue:"Net Book Value",annualExpense:"Annual Expense",allTypes:"All Types",inventory:"Inventory",vehicle:"Vehicle",allMethods:"All Methods",straightLine:"Straight Line",decliningBalance:"Declining Balance",addAsset:"Add Asset",editAsset:"Edit Asset",assetName:"Asset Name",type:"Type",method:"Method",purchaseCostLabel:"Purchase Cost",residualValue:"Residual Value",usefulLife:"Useful Life (years)",rate:"Rate (%)",inService:"In Service",disposal:"Disposal",notes:"Notes",actions:"Actions",cancel:"Cancel",save:"Save",delete:"Delete",confirmDeleteTitle:"Confirm Deletion",confirmDeleteMsg:"Are you sure you want to delete this asset?",page:"Page",of:"of",noData:"No assets found",selectInventory:"Select item",selectVehicle:"Select vehicle",none:"None",optional:"(Optional)"}},by=ie({id:B().optional(),assetName:I().min(1,"Name required"),assetType:Me(["inventory_item","vehicle"]),inventoryItemId:B().nullable().optional(),vehicleId:B().nullable().optional(),purchaseCost:Ee.number().min(0),residualValue:Ee.number().min(0).default(0),usefulLifeYears:Ee.number().min(1),depreciationMethod:Me(["declining_balance","straight_line"]),decliningRate:Ee.number().min(0).max(100).nullable().optional(),inServiceDate:I().min(1,"Date required"),disposalDate:I().nullable().optional(),notes:I().nullable().optional()}).superRefine((s,n)=>{s.depreciationMethod==="declining_balance"&&(!s.decliningRate||s.decliningRate<=0)&&n.addIssue({code:Xa.custom,path:["decliningRate"],message:"Rate required for declining balance"})}),Ny=()=>{const{language:s,regionCode:n}=de(),t=Hs[s]||Hs.fr,[a,r]=g.useState(1),[o,d]=g.useState({}),{data:h,isLoading:i}=Xj(),{data:c,isLoading:_}=Yj({page:a,limit:20,assetType:o.assetType,depreciationMethod:o.depreciationMethod}),p=Jj(),y=Zj(),f=ey(),[S,u]=g.useState(!1),[N,C]=g.useState(!1),[q,l]=g.useState(null),x=Pt({schema:by,defaultValues:{assetType:"inventory_item",depreciationMethod:"straight_line",residualValue:0,usefulLifeYears:5}}),{data:b}=Rn({page:1,limit:1e3},{enabled:S&&x.values.assetType==="inventory_item"}),{data:T}=nt({queryKey:["vehicles-dropdown"],queryFn:()=>An({}),enabled:S&&x.values.assetType==="vehicle"}),D=m=>{x.setValues({id:m.id,assetName:m.assetName,assetType:m.assetType,inventoryItemId:m.inventoryItemId,vehicleId:m.vehicleId,purchaseCost:m.purchaseCost,residualValue:m.residualValue,usefulLifeYears:m.usefulLifeYears,depreciationMethod:m.depreciationMethod,decliningRate:m.decliningRate,inServiceDate:new Date(m.inServiceDate).toISOString().split("T")[0],disposalDate:m.dis
7posalDate?new Date(m.disposalDate).toISOString().split("T")[0]:"",notes:m.notes||""}),u(!0)},G=()=>{x.setValues({assetName:"",assetType:"inventory_item",inventoryItemId:null,vehicleId:null,purchaseCost:0,residualValue:0,usefulLifeYears:5,depreciationMethod:"straight_line",decliningRate:null,inServiceDate:new Date().toISOString().split("T")[0],disposalDate:"",notes:""}),u(!0)},H=m=>{const R={assetType:m.assetType,inventoryItemId:m.inventoryItemId||null,vehicleId:m.vehicleId||null,assetName:m.assetName,purchaseCost:Number(m.purchaseCost),residualValue:Number(m.residualValue),usefulLifeYears:Number(m.usefulLifeYears),depreciationMethod:m.depreciationMethod,decliningRate:m.decliningRate?Number(m.decliningRate):null,inServiceDate:new Date(m.inServiceDate),disposalDate:m.disposalDate?new Date(m.disposalDate):null,notes:m.notes||null};m.id?y.mutate({...R,id:m.id},{onSuccess:()=>{u(!1)}}):p.mutate(R,{onSuccess:()=>{u(!1)}})},Z=()=>{q&&f.mutate({id:q},{onSuccess:()=>{C(!1),l(null)}})};return e.jsxs("div",{className:ae.container,children:[e.jsxs("div",{className:ae.summaryGrid,children:[e.jsxs("div",{className:ae.summaryCard,children:[e.jsx("span",{className:ae.summaryLabel,children:t.totalAssets}),i?e.jsx($,{className:ae.skeletonValue}):e.jsx("span",{className:ae.summaryValue,children:h?.totalAssets||0})]}),e.jsxs("div",{className:ae.summaryCard,children:[e.jsx("span",{className:ae.summaryLabel,children:t.purchaseCost}),i?e.jsx($,{className:ae.skeletonValue}):e.jsx("span",{className:ae.summaryValue,children:We(h?.totalPurchaseCost,n)})]}),e.jsxs("div",{className:ae.summaryCard,children:[e.jsx("span",{className:ae.summaryLabel,children:t.accumulatedDepreciation}),i?e.jsx($,{className:ae.skeletonValue}):e.jsx("span",{className:ae.summaryValue,children:We(h?.totalAccumulatedDepreciation,n)})]}),e.jsxs("div",{className:ae.summaryCard,children:[e.jsx("span",{className:ae.summaryLabel,children:t.netBookValue}),i?e.jsx($,{className:ae.skeletonValue}):e.jsx("span",{className:ae.summaryValue,children:We(h?.totalNetBookValue,n)})]}),e.jsxs("div",{className:ae.summaryCard,children:[e.jsx("span",{className:ae.summaryLabel,children:t.annualExpense}),i?e.jsx($,{className:ae.skeletonValue}):e.jsx("span",{className:ae.summaryValue,children:We(h?.annualDepreciationExpense,n)})]})]}),e.jsxs("div",{className:ae.toolbar,children:[e.jsxs("div",{className:ae.filters,children:[e.jsxs(we,{value:o.assetType||"__empty",onValueChange:m=>{d(R=>({...R,assetType:m==="__empty"?void 0:m})),r(1)},children:[e.jsx(ke,{style:{width:"200px"},children:e.jsx(Te,{placeholder:t.type})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:t.allTypes}),e.jsx(F,{value:"inventory_item",children:t.inventory}),e.jsx(F,{value:"vehicle",children:t.vehicle})]})]}),e.jsxs(we,{value:o.depreciationMethod||"__empty",onValueChange:m=>{d(R=>({...R,depreciationMethod:m==="__empty"?void 0:m})),r(1)},children:[e.jsx(ke,{style:{width:"220px"},children:e.jsx(Te,{placeholder:t.method})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:t.allMethods}),e.jsx(F,{value:"straight_line",children:t.straightLine}),e.jsx(F,{value:"declining_balance",children:t.decliningBalance})]})]})]}),e.jsxs(v,{onClick:G,children:[e.jsx(hs,{size:16})," ",t.addAsset]})]}),e.jsxs("div",{className:ae.tableContainer,children:[e.jsxs("table",{className:ae.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:t.assetName}),e.jsx("th",{children:t.type}),e.jsx("th",{children:t.method}),e.jsx("th",{children:t.inService}),e.jsx("th",{children:t.purchaseCostLabel}),e.jsx("th",{children:t.accumulatedDepreciation}),e.jsx("th",{children:t.netBookValue}),e.jsx("th",{children:t.actions})]})}),e.jsx("tbody",{children:_?Array.from({length:5}).map((m,R)=>e.jsx("tr",{children:e.jsx("td",{colSpan:8,children:e.jsx($,{className:ae.skeletonRow})})},R)):c?.items&&c.items.length>0?c.items.map(m=>e.jsxs("tr",{children:[e.jsx("td",{children:m.assetName}),e.jsx("td",{children:m.assetType==="inventory_item"?t.inventory:t.vehicle}),e.jsx("td",{children:m.depreciationMethod==="straight_line"?t.straightLine:t.decliningBalance}),e.jsx("td",{children:new Date(m.inServiceDate).toLocaleDateString(s==="fr"?"fr-CA":"en-CA")}),e.jsx("td",{children:We(m.purchaseCost,n)}),e.jsx("td",{children:We(m.accumulatedDepreciation,n)}),e.jsx("td",{children:We(m.netBookValue,n)}),e.jsx("td",{children:e.jsxs("div",{className:ae.actions,children:[e.jsx(v,{variant:"ghost",size:"icon-sm",onClick:()=>D(m),children:e.jsx(_s,{size:16})}),e.jsx(v,{variant:"ghost",size:"icon-sm",className:ae.deleteButton,onClick:()=>{l(m.id),C(!0)},children:e.jsx(Yt,{size:16})})]})})]},m.id)):e.jsx("tr",{children:e.jsx("td",{colSpan:8,className:ae.emptyState,children:t.noData})})})]}),c&&c.totalCount>0&&e.jsxs("div",{className:ae.pagination,children:[e.jsx(v,{variant:"outline",size:"sm",onClick:()=>r(m=>Math.max(1,m-1)),disabled:a===1,children:e.jsx(Kt,{size:16})}),e.jsxs("span",{className:ae.pageText,children:[t.page," ",a," ",t.of," ",Math.
7ceil(c.totalCount/20)]}),e.jsx(v,{variant:"outline",size:"sm",onClick:()=>r(m=>m+1),disabled:a>=Math.ceil(c.totalCount/20),children:e.jsx(vt,{size:16})})]})]}),e.jsx(Ye,{open:S,onOpenChange:u,children:e.jsxs(Xe,{className:ae.dialogContent,children:[e.jsx(ot,{children:e.jsx(Je,{children:x.values.id?t.editAsset:t.addAsset})}),e.jsx(qt,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(H),className:ae.form,children:[e.jsxs(J,{name:"assetType",children:[e.jsx(re,{children:t.type}),e.jsx(ee,{children:e.jsxs(we,{value:x.values.assetType,onValueChange:m=>{x.setValues(R=>({...R,assetType:m,inventoryItemId:null,vehicleId:null})),x.validateField("assetType")},children:[e.jsx(ke,{children:e.jsx(Te,{})}),e.jsxs(De,{children:[e.jsx(F,{value:"inventory_item",children:t.inventory}),e.jsx(F,{value:"vehicle",children:t.vehicle})]})]})}),e.jsx(oe,{})]}),x.values.assetType==="inventory_item"&&e.jsxs(J,{name:"inventoryItemId",children:[e.jsxs(re,{children:[t.inventory," ",e.jsx("span",{className:ae.optionalText,children:t.optional})]}),e.jsx(ee,{children:e.jsxs(we,{value:x.values.inventoryItemId?.toString()||"__empty",onValueChange:m=>{x.setValues(R=>({...R,inventoryItemId:m==="__empty"?null:parseInt(m,10)}))},children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:t.selectInventory})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:t.none}),b?.items.map(m=>e.jsx(F,{value:m.id.toString(),children:m.name},m.id))]})]})}),e.jsx(oe,{})]}),x.values.assetType==="vehicle"&&e.jsxs(J,{name:"vehicleId",children:[e.jsxs(re,{children:[t.vehicle," ",e.jsx("span",{className:ae.optionalText,children:t.optional})]}),e.jsx(ee,{children:e.jsxs(we,{value:x.values.vehicleId?.toString()||"__empty",onValueChange:m=>{x.setValues(R=>({...R,vehicleId:m==="__empty"?null:parseInt(m,10)}))},children:[e.jsx(ke,{children:e.jsx(Te,{placeholder:t.selectVehicle})}),e.jsxs(De,{children:[e.jsx(F,{value:"__empty",children:t.none}),T?.vehicles.map(m=>e.jsxs(F,{value:m.id.toString(),children:[m.name," (",m.licensePlate,")"]},m.id))]})]})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"assetName",children:[e.jsx(re,{children:t.assetName}),e.jsx(ee,{children:e.jsx(K,{value:x.values.assetName||"",onChange:m=>x.setValues(R=>({...R,assetName:m.target.value}))})}),e.jsx(oe,{})]}),e.jsxs("div",{className:ae.grid2,children:[e.jsxs(J,{name:"purchaseCost",children:[e.jsx(re,{children:t.purchaseCostLabel}),e.jsx(ee,{children:e.jsx(K,{type:"number",step:"0.01",min:"0",value:x.values.purchaseCost||"",onChange:m=>x.setValues(R=>({...R,purchaseCost:parseFloat(m.target.value)}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"residualValue",children:[e.jsx(re,{children:t.residualValue}),e.jsx(ee,{children:e.jsx(K,{type:"number",step:"0.01",min:"0",value:x.values.residualValue||"",onChange:m=>x.setValues(R=>({...R,residualValue:parseFloat(m.target.value)}))})}),e.jsx(oe,{})]})]}),e.jsxs("div",{className:ae.grid2,children:[e.jsxs(J,{name:"usefulLifeYears",children:[e.jsx(re,{children:t.usefulLife}),e.jsx(ee,{children:e.jsx(K,{type:"number",step:"0.1",min:"1",value:x.values.usefulLifeYears||"",onChange:m=>x.setValues(R=>({...R,usefulLifeYears:parseFloat(m.target.value)}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"depreciationMethod",children:[e.jsx(re,{children:t.method}),e.jsx(ee,{children:e.jsxs(we,{value:x.values.depreciationMethod,onValueChange:m=>{x.setValues(R=>({...R,depreciationMethod:m}))},children:[e.jsx(ke,{children:e.jsx(Te,{})}),e.jsxs(De,{children:[e.jsx(F,{value:"straight_line",children:t.straightLine}),e.jsx(F,{value:"declining_balance",children:t.decliningBalance})]})]})}),e.jsx(oe,{})]})]}),x.values.depreciationMethod==="declining_balance"&&e.jsxs(J,{name:"decliningRate",children:[e.jsx(re,{children:t.rate}),e.jsx(ee,{children:e.jsx(K,{type:"number",step:"0.1",min:"0",max:"100",value:x.values.decliningRate||"",onChange:m=>x.setValues(R=>({...R,decliningRate:parseFloat(m.target.value)}))})}),e.jsx(oe,{})]}),e.jsxs("div",{className:ae.grid2,children:[e.jsxs(J,{name:"inServiceDate",children:[e.jsx(re,{children:t.inService}),e.jsx(ee,{children:e.jsx(K,{type:"date",value:x.values.inServiceDate||"",onChange:m=>x.setValues(R=>({...R,inServiceDate:m.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(J,{name:"disposalDate",children:[e.jsxs(re,{children:[t.disposal," ",e.jsx("span",{className:ae.optionalText,children:t.optional})]}),e.jsx(ee,{children:e.jsx(K,{type:"date",value:x.values.disposalDate||"",onChange:m=>x.setValues(R=>({...R,disposalDate:m.target.value||null}))})}),e.jsx(oe,{})]})]}),e.jsxs(J,{name:"notes",children:[e.jsxs(re,{children:[t.notes," ",e.jsx("span",{className:ae.optionalText,children:t.optional})]}),e.jsx(ee,{children:e.jsx(K,{value:x.values.notes||"",onChange:m=>x.setValues(R=>({...R,notes:m.target.value}))})}),e.jsx(oe,{})]}),e.jsxs(ft,{children:[e.jsx(v,{variant:"secondary",onClick:()=>u(!1),children:t.cancel}),e.jsx(v,{type:"submit",disabled:p.isPending||y.isPending,children:t.save})]})]})})]})}),e.jsx(Ye,{open:N,onOpenChange:C,children:e.jsxs(Xe,{children:[e.jsx(ot,{children:e.jsx(Je,{children:t.confirmDeleteTitle})}),e.jsx("div",{className:ae.deletePrompt,children:t.confirmDeleteMsg}),e.jsxs(ft,{children:[e.jsx(v,{variant:"secondary",onClick:()=>C(!1),children:t.cancel}),e.jsx(v,{variant:"destructive",onClick:Z,disabled:f.isPending,children:t.delete})]})]})})]})},Cy="_dialogContent_1fp2q_1",Sy="_content_1fp2q_9",wy="_fadeIn_1fp2q_17",ky="_fadeOut_1fp2q_22",Ty="_iconContainer_1fp2q_27",Dy="_title_1fp2q_44",Iy="_description_1fp2q_53",$y="_footer_1fp2q_61",Ey="_dots_1fp2q_69",By="_dot_1fp2q_69",Py="_active_1fp2q_84",qy="_actions_1fp2q_89",Ry="_progressText_1fp2q_96",Ay="_srOnly_1fp2q_103",st={dialogContent:Cy,content:Sy,fadeIn:wy,fadeOut:ky,iconContainer:Ty,title:Dy,description:Iy,footer:$y,dots:Ey,dot:By,active:Py,actions:qy,progressText:Ry,srOnly:Ay},Ly=({isOpen:s,onClose:n,startAtStep:t=0,className:a,onMarkCompleted:r})=>{const{language:o}=de(),[d,h]=g.useState(t),[i,c]=g.useState(!1);g.useEffect(()=>{s&&h(t)},[s,t]);const _=()=>{r?.();try{localStorage.setItem("guided-tour-completed-payroll","true")}catch(N){console.error("Failed to save Payroll tour completion status to localStorage",N)}n()},p=[{icon:Ja,title:o==="fr"?"Vue d'ensemble":"Overview",description:o==="fr"?"Gérez la paie de vos employés avec des calculs automatiques et des intégrations comptables.":"Manage your employees' payroll with automatic calculations and accounting integrations."},{icon:Za,title:o==="fr"?"Calcul automatique":"Automatic Calculation",description:o==="fr"?"Les salaires sont c
7alculés à partir des feuilles de temps validées (heures régulières, supplémentaires, primes).":"Salaries are calculated from validated timesheets (regular hours, overtime, bonuses)."},{icon:en,title:o==="fr"?"Intégration QuickBooks":"QuickBooks Integration",description:o==="fr"?"Synchronisez les données de paie avec QuickBooks pour une comptabilité simplifiée.":"Sync payroll data with QuickBooks for simplified accounting."},{icon:Zt,title:o==="fr"?"Bulletins de paie":"Payslips",description:o==="fr"?"Consultez et partagez les bulletins de paie détaillant heures, salaire brut, retenues et net.":"View and share detailed payslips showing hours, gross salary, deductions, and net."},{icon:yt,title:o==="fr"?"Heures supplémentaires":"Overtime",description:o==="fr"?"Les majorations (temps et demi, double) sont appliquées automatiquement selon les normes du travail.":"Premiums (time and a half, double) are automatically applied according to labor standards."}],y=N=>{c(!0),setTimeout(()=>{h(N),c(!1)},150)},f=()=>{d<p.length-1?y(d+1):_()},S=()=>{d>0&&y(d-1)},u=p[d].icon;return e.jsx(Ye,{open:s,onOpenChange:N=>!N&&_(),children:e.jsxs(Xe,{className:`${st.dialogContent} ${a??""}`,"aria-describedby":void 0,children:[e.jsx(Je,{className:st.srOnly,children:o==="fr"?"Visite guidée de la paie":"Payroll Guided Tour"}),e.jsxs("div",{className:`${st.content} ${i?st.fadeOut:st.fadeIn}`,children:[e.jsx("div",{className:st.iconContainer,children:e.jsx(u,{strokeWidth:1.5})}),e.jsx("h2",{className:st.title,children:p[d].title}),e.jsx("p",{className:st.description,children:p[d].description})]}),e.jsxs("div",{className:st.footer,children:[e.jsx("div",{className:st.dots,children:p.map((N,C)=>e.jsx("div",{className:`${st.dot} ${C===d?st.active:""}`,"aria-label":`Step ${C+1}`},C))}),e.jsxs("div",{className:st.actions,children:[d===0?e.jsx(v,{variant:"ghost",onClick:_,children:o==="fr"?"Passer":"Skip"}):e.jsx(v,{variant:"outline",onClick:S,children:o==="fr"?"Précédent":"Previous"}),e.jsxs("div",{className:st.progressText,children:[d+1," / ",p.length]}),e.jsx(v,{variant:"primary",onClick:f,children:d===p.length-1?o==="fr"?"Terminer":"Finish":o==="fr"?"Suivant":"Next"})]})]})]})})},Fy="_dialogContent_1fp2q_1",Oy="_content_1fp2q_9",My="_fadeIn_1fp2q_17",zy="_fadeOut_1fp2q_22",Hy="_iconContainer_1fp2q_27",Vy="_title_1fp2q_44",Wy="_description_1fp2q_53",Gy="_footer_1fp2q_61",Uy="_dots_1fp2q_69",Qy="_dot_1fp2q_69",Ky="_active_1fp2q_84",Yy="_actions_1fp2q_89",Xy="_progressText_1fp2q_96",Jy="_srOnly_1fp2q_103",at={dialogContent:Fy,content:Oy,fadeIn:My,fadeOut:zy,iconContainer:Hy,title:Vy,description:Wy,footer:Gy,dots:Uy,dot:Qy,active:Ky,actions:Yy,progressText:Xy,srOnly:Jy},Zy=({isOpen:s,onClose:n,startAtStep:t=0,className:a,onMarkCompleted:r})=>{const{language:o}=de(),[d,h]=g.useState(t),[i,c]=g.useState(!1);g.useEffect(()=>{s&&h(t)},[s,t]);const _=()=>{r?.();try{localStorage.setItem("guided-tour-completed-certifications","true")}catch(N){console.error("Failed to save certifications tour completion status to localStorage",N)}n()},p=[{icon:Js,title:o==="fr"?"Vue d'ensemble":"Overview",description:o==="fr"?"Gérez les certifications, permis et qualifications de vos employés depuis un seul tableau de bord.":"Manage certifications, licenses, and qualifications of your employees from a single dashboard."},{icon:hs,title:o==="fr"?"Ajouter une certification":"Add a certification",description:o==="fr"?"Cliquez sur Ajouter, sélectionnez l'employé, le type de certification et les dates de validité.":"Click Add, select the employee, the certification type, and validity dates."},{icon:js,title:o==="fr"?"Alertes d'expiration":"Expiration alerts",description:o==="fr"?"Le système envoie des alertes automatiques 30 jours avant expiration par email, SMS et notification.":"The system sends automatic alerts 30 days before expiration via email, SMS, and notification."},{icon:tn,title:o==="fr"?"Matrice de conformité":"Compliance matrix",description:o==="fr"?"Visualisez en un coup d'œil les certifications valides, expirant bientôt et expirées de toute votre équipe.":"See at a glance valid, expiring soon, and expired certifications for your entire team."},{icon:Zt,title:o==="fr"?"Documents joints":"Attached documents",description:o==="fr"?"Numérisez et attachez les certificats et documents justificatifs pour un suivi complet.":"Digitize and attach certificates and supporting documents for complete tracking."}],y=N=>{c(!0),setTimeout(()=>{h(N),c(!1)},150)},f=()=>{d<p.length-1?y(d+1):_()},S=()=>{d>0&&y(d-1)},u=p[d].icon;return e.jsx(Ye,{open:s,onOpenChange:N=>!N&&_(),children:e.jsxs(Xe,{className:`${at.dialogContent} ${a??""}`,"aria-describedby":void 0,children:[e.jsx(Je,{className:at.srOnly,children:o==="fr"?"Visite guidée des certifications":"Certifications Guided Tour"}),e.jsxs("div",{className:`${at.content} ${i?at.fadeOut:at.fadeIn}`,children:[e.jsx("div",{className:at.iconContainer,children:e.jsx(u,{strokeWidth:1.5})}),e.jsx("h2",{className:at.title,children:p[d].title}),e.jsx("p",{className:at.description,children:p[d].description})]}),e.jsxs("div",{className:at.footer,children:[e.jsx("div",{className:at.dots,children:p.map((N,C)=>e.jsx("div",{className:`${at.dot} ${C===d?at.active:""}`,"aria-label":`Step ${C+1}`},C))}),e.jsxs("div",{className:at.actions,children:[d===0?e.jsx(v,{variant:"ghost",onClick:_,children:o==="fr"?"Passer":"Skip"}):e.jsx(v,{variant:"outline",onClick:S,children:o==="fr"?"Précédent":"Previous"}),e.jsxs("div",{className:at.progressText,children:[d+1," / ",p.length]}),e.jsx(v,{variant:"primary",onClick:f,children:d===p.length-1?o==="fr"?"Terminer":"Finish":o==="fr"?"Suivant":"Next"})]})]})]})})},eg="_pageContainer_11iqd_1",tg="_pageHeader_11iqd_7",sg="_titleRow_11iqd_11",ag="_headerActions_11iqd_19",ng="_pageTitle_11iqd_26",rg="_pageSubtitle_11iqd_33",og="_summaryGrid_11iqd_40",ig="_tabsRoot_11iqd_47",lg="_tabsList_11iqd_54",cg="_tabContent_11iqd_63",dg="_grid_11iqd_69",ug="_sectionHeader_11iqd_77",mg="_timesheetsSection_11iqd_96",hg="_settingsSection_11iqd_97",pg="_hoursBankSection_11iqd_98",_g="_depreciationSection_11iqd_99",xg="_certificationsSection_11iqd_100",jg="_reportCard_11iqd_112",yg="_sectionIcon_11iqd_122",gg="_hoursBankGrid_11iqd_195",fg
7="_personalSection_11iqd_203",vg="_personalGrid_11iqd_207",bg="_personalMain_11iqd_215",Ng="_viewTabs_11iqd_221",Cg="_viewTabsHeader_11iqd_226",Sg="_viewTabsContent_11iqd_232",wg="_personalSidebar_11iqd_237",kg="_sectionSeparator_11iqd_244",O={pageContainer:eg,pageHeader:tg,titleRow:sg,headerActions:ag,pageTitle:ng,pageSubtitle:rg,summaryGrid:og,tabsRoot:ig,tabsList:lg,tabContent:cg,grid:dg,sectionHeader:ug,timesheetsSection:mg,settingsSection:hg,hoursBankSection:pg,depreciationSection:_g,certificationsSection:xg,reportCard:jg,sectionIcon:yg,hoursBankGrid:gg,personalSection:fg,personalGrid:vg,personalMain:bg,viewTabs:Ng,viewTabsHeader:Cg,viewTabsContent:Sg,personalSidebar:wg,sectionSeparator:kg},wf=()=>{const[s]=sn(),{authState:n}=ea(),{t,language:a}=de(),r=n.type==="authenticated"?n.user:null,[o,d]=Qe.useState(null),[h,i]=Qe.useState("week"),[c,_]=Qe.useState(!1);Qe.useEffect(()=>{const xe=setTimeout(()=>{_(!0)},1500);return()=>clearTimeout(xe)},[]);const{data:p,isFetching:y}=Tn({enabled:c}),f=["dashboard","timesheets","hoursBank","depreciation","certifications","settings"],S=r?.role==="admin"||r?.role==="company"||r?.role==="owner",u=s.get("tab"),N=u&&f.includes(u)?u:"dashboard",[C,q]=Qe.useState(N);Qe.useEffect(()=>{u&&f.includes(u)&&C!==u&&q(u)},[u]);const{isCompleted:l,isFetching:x,markCompleted:b}=Es("payroll"),[T,D]=Qe.useState(!1),G=Qe.useRef(!1);Qe.useEffect(()=>{!x&&!G.current&&(G.current=!0,l||D(!0))},[x,l]);const{isCompleted:H,isFetching:Z,markCompleted:m}=Es("certifications"),[R,E]=Qe.useState(!1),Ce=Qe.useRef(!1);Qe.useEffect(()=>{!Z&&!Ce.current&&(Ce.current=!0,H||E(!0))},[Z,H]);const Ge=g.useMemo(()=>{const xe=new Date,Pe=xe.getDay(),_t=xe.getDate()-Pe+(Pe===0?-6:1),me=new Date(xe);me.setDate(_t),me.setHours(0,0,0,0);const Ze=new Date(me);return Ze.setDate(me.getDate()+6),Ze.setHours(23,59,59,999),{from:me,to:Ze}},[]);return r?.role==="employee"?e.jsxs(e.Fragment,{children:[e.jsx(os,{children:e.jsx("title",{children:a==="fr"?"Mes Heures & Banque d'Heures":"My Hours & Hours Bank"})}),e.jsxs("div",{className:O.pageContainer,children:[e.jsx("header",{className:O.pageHeader,children:e.jsxs("div",{children:[e.jsx("h1",{className:O.pageTitle,children:a==="fr"?"Mes Heures & Banque d'Heures":"My Hours & Hours Bank"}),e.jsx("p",{className:O.pageSubtitle,children:a==="fr"?"Consultez le résumé de vos heures travaillées et votre solde de banque d'heures.":"View your worked hours summary and your hours bank balance."})]})}),e.jsxs("div",{className:O.summaryGrid,children:[e.jsx(Ps,{userId:r.id}),e.jsx(Ds,{balance:p?.balance,lastUpdated:p?.lastUpdated,isLoading:y,showHistoryLink:!1})]}),e.jsx("div",{className:O.personalSection,children:e.jsxs("div",{className:O.personalGrid,children:[e.jsx("div",{className:O.personalMain,children:e.jsxs(Dt,{value:h,onValueChange:xe=>i(xe),className:O.viewTabs,children:[e.jsx("div",{className:O.viewTabsHeader,children:e.jsxs(It,{"data-variant":"pill",children:[e.jsx(Fe,{value:"week",children:a==="fr"?"Semaine":"Week"}),e.jsx(Fe,{value:"month",children:a==="fr"?"Mois":"Month"})]})}),e.jsx(Oe,{value:"week",className:O.viewTabsContent,children:e.jsx(ls,{userId:r.id})}),e.jsx(Oe,{value:"month",className:O.viewTabsContent,children:e.jsx(ds,{userId:r.id})})]})}),e.jsx("div",{className:O.personalSidebar,children:e.jsx(Bs,{})})]})})]})]}):r?.role==="foreman"?e.jsxs(e.Fragment,{children:[e.jsx(os,{children:e.jsx("title",{children:a==="fr"?"Approbation des Heures":"Time Approval"})}),e.jsxs("div",{className:O.pageContainer,children:[e.jsx("header",{className:O.pageHeader,children:e.jsxs("div",{children:[e.jsx("h1",{className:O.pageTitle,children:a==="fr"?"Approbation des Heures":"Time Approval"}),e.jsx("p",{className:O.pageSubtitle,children:a==="fr"?"Examinez et approuvez les entrées de temps soumises par votre équipe.":"Review and approve time entries submitted by your team."})]})}),e.jsxs("div",{className:O.summaryGrid,children:[e.jsx(Ps,{userId:r.id}),e.jsx(Ds,{balance:p?.balance,lastUpdated:p?.lastUpdated,isLoading:y,showHistoryLink:!1})]}),e.jsxs("div",{className:O.personalSection,children:[e.jsx("div",{className:O.sectionHeader,children:e.jsx("h3",{children:a==="fr"?"Mon Résumé Personnel":"My Personal Summary"})}),e.jsxs("div",{className:O.personalGrid,children:[e.jsx("div",{className:O.personalMain,children:e.jsxs(Dt,{value:h,onValueChange:xe=>i(xe),className:O.viewTabs,children:[e.jsx("div",{className:O.viewTabsHeader,children:e.jsxs(It,{"data-variant":"pill",children:[e.jsx(Fe,{value:"week",children:a==="fr"?"Semaine":"Week"}),e.jsx(Fe,{value:"month",children:a==="fr"?"Mois":"Month"})]})}),e.jsx(Oe,{value:"week",className:O.viewTabsContent,children:e.jsx(ls,{userId:r.id})}),e.jsx(Oe,{value:"month",className:O.viewTabsContent,children:e.jsx(ds,{userId:r.id})})]})}),e.jsx("div",{className:O.personalSidebar,children:e.jsx(Bs,{})})]})]}),e.jsx("div",{className:O.sectionSeparator}),e.jsx("div",{className:O.sectionHeader,children:e.jsx("h3",{children:a==="fr"?"Approbation de l'Équipe":"Team Approval"})}),e.jsx(Vj,{})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(os,{children:[e.jsx("title",{children:t("hr_page_title")}),e.jsx("meta",{name:"description",content:t("hr_page_description")})]}),e.jsxs("div",{className:O.pageContainer,children:[e.jsx("header",{className:O.pageHeader,children:e.jsxs("div",{className:O.titleRow,children:[e.jsxs("div",{children:[e.jsx("h1",{className:O.pageTitle,children:t("hr_management_title")}),e.jsx("p",{className:O.pageSubtitle,children:t("hr_management_subtitle")})]}),e.jsx("div",{className:O.headerActions,children:e.jsx(v,{variant:"ghost",size:"icon-md",onClick:()=>D(!0),title:a==="fr"?"Visite guidée":"Guided tour",children:e.jsx(Ts,{size:18})})})]})}),e.jsxs(Dt,{value:C,onValueChange:q,className:O.tabsRoot,children:[e.jsxs(It,{className:O.tabsList,children:[e.jsxs(Fe,{value:"dashboard",children:[e.jsx(Qs,{size:16})," ",t("hr_dashboard")]}),e.jsxs(Fe,{value:"timesheets",children:[e.jsx(Ys,{size:16})," ",t("hr_timesheets")]}),e.jsxs(Fe,{value:"hoursBank",children:[e.jsx(Ot,{size:16})," ",a==="fr"?"Banque d'heures":"Hours Bank"]}),e.jsxs(Fe,{value:"depreciation",children:[e.jsx(an,{size:16})," ",a==="fr"?"Amortissements":"Depreciation"]}),e.jsxs(Fe,{value:"certifications",children:[e.jsx(Js,{size:16})," ","Certifications"]}),S&&e.jsxs(Fe,{value:"settings",children:[e.jsx(nn,{size:16})," ",a==="fr"?"Paramètres":"Settings"]})]}),e.jsx(Oe,{value:"dashboard",className:O.tabContent,children:C==="dashboard"&&e.jsxs(e.Fragment,{children:[e.jsx(Ci,{}),e.jsxs("div",{className:O.sectionHeader,style:{marginTop:"var(--spacing-8)"},children:[e.jsx("h3",{children:a==="fr"?"Clôture de paie par période":"Payroll Period Closure"}
7),e.jsx("p",{children:a==="fr"?"Gérez et validez les périodes de paie de vos employés.":"Manage and validate your employees' payroll periods."})]}),e.jsx("div",{style:{marginBottom:"var(--spacing-8)"},children:e.jsx(uj,{})})]})}),e.jsx(Oe,{value:"timesheets",className:O.tabContent,children:C==="timesheets"&&e.jsxs("div",{className:O.timesheetsSection,children:[e.jsxs("div",{className:O.sectionHeader,children:[e.jsx("h3",{children:t("hr_timesheet_management")}),e.jsx("p",{children:t("hr_timesheet_description")})]}),e.jsxs("div",{className:O.grid,children:[e.jsx(Wl,{}),e.jsx(Wc,{}),e.jsx(dd,{})]}),e.jsxs("div",{className:O.sectionHeader,style:{marginTop:"var(--spacing-8)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-2)"},children:[e.jsx(Zt,{size:20,className:O.sectionIcon}),e.jsx("h3",{children:a==="fr"?"Rapports et exports":"Reports & Export"})]}),e.jsx("p",{children:a==="fr"?"Générez et exportez des rapports de temps (résumé, détaillé, paie).":"Generate and export time reports (summary, detailed, payroll)."})]}),e.jsx("div",{className:O.reportCard,children:e.jsx(bd,{reportType:"payroll_by_employee",dateRange:Ge,hideModeSelector:!1})}),e.jsxs("div",{className:O.sectionHeader,style:{marginTop:"var(--spacing-8)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--spacing-2)"},children:[e.jsx(js,{size:20,className:O.sectionIcon}),e.jsx("h3",{children:a==="fr"?"Rappels de saisie":"Entry Reminders"})]}),e.jsx("p",{children:t("hr_entry_reminders_description")})]}),e.jsx(bm,{})]})}),e.jsx(Oe,{value:"hoursBank",className:O.tabContent,children:C==="hoursBank"&&e.jsx("div",{className:O.hoursBankSection,children:o?e.jsx(_a,{userId:o.userId,userName:o.userName,onBack:()=>d(null)}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:O.sectionHeader,children:[e.jsx("h3",{children:a==="fr"?"Gestion de la Banque d'Heures":"Hours Bank Management"}),e.jsx("p",{children:a==="fr"?"Gérez les crédits et débits d'heures pour vos employés.":"Manage hours credits and debits for your employees."})]}),e.jsx("div",{style:{marginBottom:"var(--spacing-6)"},children:e.jsx(th,{onEmployeeClick:(xe,Pe)=>d({userId:xe,userName:Pe})})}),e.jsxs("div",{className:O.hoursBankGrid,children:[e.jsx(Bh,{}),e.jsx(jp,{})]})]})})}),e.jsx(Oe,{value:"depreciation",className:O.tabContent,children:C==="depreciation"&&e.jsxs("div",{className:O.depreciationSection,children:[e.jsxs("div",{className:O.sectionHeader,children:[e.jsx("h3",{children:a==="fr"?"Gestion des amortissements":"Asset Depreciation Management"}),e.jsx("p",{children:a==="fr"?"Suivez l'amortissement de vos actifs (véhicules, équipements, outils) avec calculs linéaires ou dégressifs.":"Track depreciation of your assets (vehicles, equipment, tools) with straight-line or declining balance calculations."})]}),e.jsx(Ny,{})]})}),e.jsx(Oe,{value:"certifications",className:O.tabContent,children:C==="certifications"&&e.jsxs("div",{className:O.certificationsSection,children:[e.jsx("div",{className:O.sectionHeader,children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("h3",{children:a==="fr"?"Certifications et Formations":"Certifications and Training"}),e.jsx("p",{children:a==="fr"?"Gérez les certifications, les licences et les formations de vos employés.":"Manage employee certifications, licenses, and training."})]}),e.jsx(v,{variant:"ghost",size:"icon-md",onClick:()=>E(!0),title:a==="fr"?"Visite guidée":"Guided tour",children:e.jsx(Ts,{size:18})})]})}),e.jsx(cl,{})]})}),e.jsx(Oe,{value:"settings",className:O.tabContent,children:C==="settings"&&S&&e.jsxs("div",{className:O.settingsSection,children:[e.jsxs("div",{className:O.sectionHeader,children:[e.jsx("h3",{children:t("hr_schedule_management")}),e.jsx("p",{children:t("hr_schedule_description")})]}),e.jsx(Gd,{}),S&&e.jsxs("div",{className:O.sectionHeader,style:{marginTop:"var(--spacing-8)"},children:[e.jsx("h3",{children:a==="fr"?"Configuration des heures supplémentaires":"Overtime Configuration"}),e.jsx("p",{children:a==="fr"?"Définissez les règles de calcul des heures supplémentaires.":"Define overt
7ime calculation rules."})]}),S&&e.jsx(gu,{}),S&&e.jsxs("div",{className:O.sectionHeader,style:{marginTop:"var(--spacing-8)"},children:[e.jsx("h3",{children:a==="fr"?"Récapitulatif de paie":"Payroll Summary"}),e.jsx("p",{children:a==="fr"?"Résumé des heures travaillées et de la paie calculée pour chaque employé durant les périodes fermées.":"Summary of hours worked and calculated payroll for each employee during closed periods."})]}),S&&e.jsx(C_,{}),e.jsxs("div",{className:O.sectionHeader,style:{marginTop:"var(--spacing-8)"},children:[e.jsx("h3",{children:t("hr_compliance_tracking")}),e.jsx("p",{children:t("hr_compliance_description")})]}),e.jsx(Eu,{})]})})]}),e.jsx(Ly,{isOpen:T,onClose:()=>D(!1),onMarkCompleted:b}),e.jsx(Zy,{isOpen:R,onClose:()=>E(!1),onMarkCompleted:m})]})]})};export{wf 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.