1import{z as re,j as t,b_ as se,b$ as ne,c0 as ie,aI as F,c1 as oe,c2 as le,c3 as ce,c4 as de,c5 as me,ae as pe,i as R,bj as he,U as ue,B as N,h as _,aM as ee,dd as G,cq as X,a as fe,aE as B,b1 as ge,b2 as xe,b3 as ye,b4 as je,q as we,b5 as be,e as z,L as Q,N as ve,_ as Ne,f as Ce,aF as Se,bb as Te,a_ as ke,bT as De,bU as Me,bc as Ae,X as Pe,bV as Ie,bd as Oe,a0 as A,a1 as P,a2 as I,a3 as O,a4 as E,a7 as H}from"./index-DGo-vssZ.js";import{r as v}from"./vendor-Qgthw7N1.js";import{d as Ee}from"./differenceInMonths-Cb0HIyJb.js";import{b as Fe}from"./index-B1ky1Hhc.js";import{T as Le}from"./timer-DEA0yRXX.js";import{E as Qe,R as Ue}from"./RepsClassificationSection-CqSsZHO1.js";import{C as qe}from"./circle-x--5-vDMIU.js";import{C as Ke}from"./calendar-days-COgXMVIl.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const tt=re("CircleArrowRight",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]]);function L(e){var i,s,o;if(!e)return"available";const a=e.hasLedgerEntry??((i=e.extendedProps)==null?void 0:i.hasLedgerEntry),r=e.approvalStatus??((s=e.extendedProps)==null?void 0:s.approvalStatus);if(a)return r==="approved"?"approved":"pending";const n=e.aiConfidence??((o=e.extendedProps)==null?void 0:o.aiConfidence)??0;return n>=90?"approved":n>=50?"pending":"available"}function $e(e){switch(e){case"approved":return{backgroundColor:"#dcfce7",borderColor:"#22c55e",textColor:"#166534"};case"pending":return{backgroundColor:"#fef3c7",borderColor:"#f59e0b",textColor:"#92400e"};case"available":default:return{backgroundColor:"#dbeafe",borderColor:"#3b82f6",textColor:"#1e40af"}}}function at({open:e,onOpenChange:a,onConfirm:r,isLoading:n,calendarProvider:i="unified"}){const o=(()=>{switch(i){case"google":return"Google Calendar";case"microsoft":return"Microsoft Calendar";case"unified":default:return"your calendar"}})();return t.jsx(se,{open:e,onOpenChange:a,children:t.jsxs(ne,{className:"max-w-md",children:[t.jsxs(ie,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/20",children:t.jsx(F,{className:"h-5 w-5 text-blue-600 dark:text-blue-400"})}),t.jsxs(oe,{className:"text-lg",children:["Sync from ",o,"?"]})]}),t.jsxs(le,{className:"space-y-3 pt-2",children:[t.jsxs("p",{className:"text-sm text-foreground/80",children:["This will fetch the latest events from ",o,"."]}),t.jsxs("div",{className:"rounded-lg bg-muted/50 p-3 text-xs space-y-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-muted-foreground mt-0.5",children:"â¢"}),t.jsx("span",{className:"text-muted-foreground",children:"Bypasses both frontend and backend cache"})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-muted-foreground mt-0.5",children:"â¢"}),t.jsxs("span",{className:"text-muted-foreground",children:["Fetches fresh data directly from ",o," API"]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-muted-foreground mt-0.5",children:"â¢"}),t.jsx("span",{className:"text-muted-foreground",children:"This may take a few seconds"})]})]}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Use this when you've added new events and want to see them immediately."})]})]}),t.jsxs(ce,{children:[t.jsx(de,{disabled:n,children:"Cancel"}),t.jsxs(me,{onClick:m=>{m.preventDefault(),r()},disabled:n,className:"flex items-center gap-2 min-w-[100px]",children:[n&&t.jsx(pe,{className:"h-4 w-4 animate-spin"}),n?"Syncing...":"Sync Now"]})]})]})})}function Ve({selectedEvent:e}){const a=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"UTC"}),r=e!=null&&e.start?a.format(new Date(e.start)):"Unknown";return t.jsxs("div",{className:"p-4 bg-white dark:bg-gray-900 rounded-xl border border-gray-200 dark:border-gray-700 shadow-sm",children:[t.jsx("h3",{className:"text-sm font-semibold text-gray-800 dark:text-gray-100 mb-3",children:"Event Details"}),t.jsxs("div",{className:"space-y-3 divide-y divide-gray-200 dark:divide-gray-700",children:[t.jsxs("div",{className:"grid grid-cols-[auto,1fr] gap-3 items-start pt-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(R,{className:"h-4 w-4 text-gray-500"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Start Time:"})]}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed text-right",children:r})]}),t.jsxs("div",{className:"grid grid-cols-[auto,1fr] gap-3 items-start pt-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Le,{className:"h-4 w-4 text-gray-500"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Duration:"})]}),t.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed text-right",children:[e.duration,"h"]})]}),e.location&&t.jsxs("div",{className:"grid grid-cols-[auto,1fr] gap-3 items-start pt-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(he,{className:"h-4 w-4 text-gray-500"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Location:"})]}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed text-right",children:e.location})]}),e.attendees&&e.attendees.length>0&&t.jsxs("div",{className:"grid grid-cols-[auto,1fr] gap-3 items-start pt-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(ue,{className:"h-4 w-4 text-gray-500 mt-1"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Attendees:"})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 leading-relaxed text-right",children:e.attendees.map(n=>typeof n=="string"?n:(n==null?void 0:n.email)??(n==null?void 0:n.name)??"").filter(
6Boolean).join(", ")})]})]})]})}function _e({eventStatus:e,selectedEvent:a,reviewFormData:r,evidenceFiles:n,newEvidenceFiles:i,setShowEventDialog:s,syncEventMutation:o,approveTimeEntryMutation:m,updateTimeEntryMutation:h}){return t.jsxs("div",{className:"mt-12 pt-6 border-t border-gray-200 dark:border-gray-700 flex items-center justify-between",children:[t.jsx(N,{variant:"outline",onClick:()=>s(!1),className:"px-6",children:e==="available"?"Cancel":"Close"}),t.jsxs("div",{className:"flex items-center gap-3",children:[e==="available"&&t.jsx(N,{onClick:()=>{a&&o.mutate({event:a,formData:r,evidenceFiles:n,newEvidenceFiles:i})},disabled:o.isPending,className:"px-6 bg-green-600 hover:bg-green-700 flex items-center gap-2 text-white",children:o.isPending?t.jsxs(t.Fragment,{children:[t.jsx(F,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(_,{className:"h-4 w-4"}),"Sync to Ledger"]})}),e==="pending"&&t.jsx(N,{onClick:()=>{a!=null&&a.duplicateTimeEntryId&&m.mutate(a.duplicateTimeEntryId)},disabled:m.isPending,className:"px-6 bg-green-600 hover:bg-green-700 flex items-center gap-2 text-white",children:m.isPending?t.jsxs(t.Fragment,{children:[t.jsx(F,{className:"h-4 w-4 animate-spin"}),"Approving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(_,{className:"h-4 w-4"}),"Approve Entry"]})}),e==="approved"&&t.jsx(N,{onClick:()=>{if(!(a!=null&&a.duplicateTimeEntryId)){console.error("â Missing duplicateTimeEntryId, cannot update");return}h.mutate({entryId:a.duplicateTimeEntryId,formData:r,evidenceFiles:n,newEvidenceFiles:i,event:a,onSuccess:()=>s(!1)})},disabled:h.isPending,className:"px-6 bg-blue-600 hover:bg-blue-700 flex items-center gap-2 text-white",children:h.isPending?t.jsxs(t.Fragment,{children:[t.jsx(F,{className:"h-4 w-4 animate-spin"}),"Updating..."]}):t.jsxs(t.Fragment,{children:[t.jsx(_,{className:"h-4 w-4"}),"Update Entry"]})})]})]})}function rt(e={}){const{days:a,startDate:r,endDate:n,dateRangeFilter:i,skipCache:s=!1,enabled:o=!0,calendarIds:m}=e,[h,p]=v.useState({events:[],isLoading:!1,isStreaming:!1,error:null,statusMessage:null,progress:null,stats:null}),f=v.useRef(null),w=r==null?void 0:r.toISOString(),x=n==null?void 0:n.toISOString(),T=m==null?void 0:m.sort().join(","),S=JSON.stringify(i),c=v.useCallback(async()=>{f.current&&f.current.abort();const l=new AbortController;f.current=l,p(d=>({...d,isLoading:!0,isStreaming:!0,error:null,events:d.events,statusMessage:"Initializing stream...",progress:null,stats:null}));try{const d={stream:!0,skipCache:s,calendarIds:m};if(i!=null&&i.from){const q=new Date(i.from.year,i.from.month,1),K=new Date(i.to?i.to.year:i.from.year,i.to?i.to.month+1:i.from.month+1,0);d.startDate=q.toISOString(),d.endDate=K.toISOString()}else r&&n?(d.startDate=r.toISOString(),d.endDate=n.toISOString()):a&&(d.days=a);const u=await fetch("/api/calendar/events/unified",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},body:JSON.stringify(d),signal:l.signal});if(!u.ok)throw new Error(`Stream failed: ${u.statusText}`);if(!u.body)throw new Error("No response body");const b=u.body.getReader(),te=new TextDecoder;let U="";for(;;){const{done:q,value:K}=await b.read();if(q)break;U+=te.decode(K,{stream:!0});const J=U.split(` 7`);U=J.pop()||"";for(const Y of J)if(Y.trim())try{const g=JSON.parse(Y);if(g.type==="events")p(j=>{const M=g.data,k=new Map(j.events.map(y=>[y.id,y]));for(const y of M)k.set(y.id,y);return{...j,isLoading:!1,events:Array.from(k.values()).sort((y,$)=>{const V=new Date(y.start).getTime();return new Date($.start).getTime()-V})}});else if(g.type==="event_update")p(j=>{const M=g.data,k=new Map(j.events.map(y=>[y.id,y]));return k.set(M.id,M),{...j,events:Array.from(k.values()).sort((y,$)=>{const V=new Date(y.start).getTime();return new Date($.start).getTime()-V})}});else if(g.type==="status")p(j=>({...j,statusMessage:g.message}));else if(g.type==="progress")p(j=>({...j,progress:{processed:g.processed,total:g.total}}));else if(g.type==="complete")p(j=>({...j,isStreaming:!1,isLoading:!1,stats:g.stats,statusMessage:"Sync complete"}));else if(g.type==="error")throw new Error(g.error)}catch(g){console.error("Error parsing stream chunk:",g)}}}catch(d){if(d.name==="AbortError")return;console.error("Stream error:",d),p(u=>({...u,isLoading:!1,isStreaming:!1,error:d}))}},[a,w,x,S,s,o,T]);return v.useEffect(()=>(o&&c(),()=>{f.current&&f.current.abort()}),[c,o]),{...h,refetch:c}}const D={async fetchUnifiedCalendarEvents(e){const a=await fetch("/api/calendar/events/unified",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,progressive:!0})});if(!a.ok){const r=await a.json();throw new Error(r.message||"Failed to fetch calendar events")}return a.json()},async checkCalendarLedgerStatus(e){const a=await fetch("/api/time-entries/calendar-ledger-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventIds:e}),credentials:"include"});if(!a.ok)throw new Error("Failed to check ledger status");return a.json()},async syncCalendarEvent(e){const a=await fetch("/api/calendar/convert/events",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok){const r=await a.json();throw new Error(r.message||"Failed to sync event")}return a.json()},async convertCalendarEventToLedger(e){const a=new FormData;a.append("eventId",e.eventId),a.append("source",e.source),a.append("title",e.formData.title),a.append("description",e.formData.description),a.append("activityType",e.formData.activityType),a.append("materialParticipation",String(e.formData.materialParticipation)),e.formData.isQualifiedNonMaterial!==void 0&&a.append("isQualifiedNonMaterial",String(e.formData.isQualifiedNonMaterial)),e.formData.propertyId&&a.append("propertyId",String(e.formData.propertyId)),a.append("category",e.formData.category),a.append("startDate",e.formData.startDate instanceof Date?e.formData.startDate.toISOString():e.formData.startDate),a.append("endDate",e.formData.endDate instanceof Date?e.formData.endDate.toISOString():e.formData.endDate),a.append("duration",String(e.formData.duration)),e.attachments&&a.append("attachments",JSON.stringify(e.attachments)),e.newEvidenceFiles&&e.newEvidenceFiles.forEac
7h(n=>{a.append("files",n)});const r=await fetch("/api/calendar/convert",{method:"POST",body:a});if(!r.ok){const n=await r.json();throw new Error(n.message||"Failed to convert calendar event")}return r.json()},async triggerAutoSync(){const e=await fetch("/api/sync/calendar/auto",{method:"POST",headers:{"Content-Type":"application/json"}});if(!e.ok){const a=await e.json();throw new Error(a.message||"Failed to trigger auto sync")}return e.json()},async triggerManualSync(){const e=await fetch("/api/sync/calendar/manual",{method:"POST",headers:{"Content-Type":"application/json"}});if(!e.ok){const a=await e.json();throw new Error(a.message||"Failed to trigger manual sync")}return e.json()},async getGoogleAuthUrl(){const e=await fetch("/api/calendar/auth-url");if(!e.ok){const r=await e.json();throw new Error(r.message||"Failed to get authorization URL")}return(await e.json()).authUrl},async disconnectGoogleCalendar(){const e=await fetch("/api/calendar/disconnect",{method:"POST"});if(!e.ok){const a=await e.json();throw new Error(a.message||"Failed to disconnect")}return e.json()},async processEvidenceFile(e){const a=await fetch("/api/evidence-files/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!a.ok)throw new Error("Failed to process evidence file");return a.json()},async getEvidenceFile(e){const a=await fetch(`/api/evidence-files/${e}`);if(!a.ok)throw new Error("Failed to fetch evidence file");return a.json()},async fetchProperties(){const e=await fetch("/api/properties");if(!e.ok)throw new Error("Failed to fetch properties");return e.json()},async updateTimeEntry(e,a){const r=new FormData;a.date&&r.append("date",a.date),a.hours&&r.append("hours",String(a.hours)),a.title&&r.append("title",a.title),a.description&&r.append("description",a.description),a.activityType&&r.append("activityType",a.activityType),a.materialParticipation!==void 0&&r.append("isMaterialParticipation",String(a.materialParticipation)),a.isQualifiedNonMaterial!==void 0&&r.append("isQualifiedNonMaterial",String(a.isQualifiedNonMaterial)),a.propertyId&&r.append("propertyId",String(a.propertyId)),a.newEvidenceFiles&&a.newEvidenceFiles.forEach(i=>{r.append("files",i)});const n=await fetch(`/api/time-entries/${e}`,{method:"PATCH",body:r});if(!n.ok){const i=await n.json();throw new Error(i.message||"Failed to update time entry")}return n.json()},async approveTimeEntry(e){const a=await fetch(`/api/time-entries/${e}/approve`,{method:"PATCH",headers:{"Content-Type":"application/json"}});if(!a.ok){const r=await a.json();throw new Error(r.message||"Failed to approve time entry")}return a.json()},async fetchCalendarEventsForMonth(e,a,r){const n=new Date(e,a,1),i=new Date(e,a+1,0),s=await fetch("/api/calendar/events/unified",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({startDate:n.toISOString().split("T")[0],endDate:i.toISOString().split("T")[0],skipCache:(r==null?void 0:r.skipCache)||!1,calendarIds:r==null?void 0:r.calendarIds,progressive:!0})});if(!s.ok){const o=await s.json();throw new Error(o.message||"Failed to fetch calendar events")}return s.json()},async getCalendarList(){const e=await fetch("/api/calendar/calendars",{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok){const a=await e.json();throw new Error(a.message||"Failed to fetch calendar list")}return e.json()}},st=Object.freeze(Object.defineProperty({__proto__:null,calendarViewService:D},Symbol.toStringTag,{value:"Module"})),C={all:["test-calendar"],events:()=>[...C.all,"events"],month:(e,a)=>[...C.events(),e,a],dateRange:(e,a)=>[...C.events(),"range",e,a],year:e=>[...C.events(),"year",e]};async function W(e,a,r){const i=(await D.fetchCalendarEventsForMonth(e,a,r)).events||[];
7if(i.length===0)return[];const s=await D.checkCalendarLedgerStatus(i.map(m=>m.id)),o=i.map(m=>{var h,p;return{...m,hasLedgerEntry:((h=s[m.id])==null?void 0:h.hasEntry)||!1,approvalStatus:((p=s[m.id])==null?void 0:p.approvalStatus)||null}});return o.filter(m=>m.hasLedgerEntry).length,o}function nt(e){const a=ee();v.useEffect(()=>{a.prefetchQuery({queryKey:[...C.month(e-1,11),"with-status"],queryFn:()=>W(e-1,11),staleTime:24*60*60*1e3}),a.prefetchQuery({queryKey:[...C.month(e+1,0),"with-status"],queryFn:()=>W(e+1,0),staleTime:24*60*60*1e3})},[e,a])}const Z=24;function it(){const[e,a]=v.useState({from:null,to:null}),[r,n]=v.useState(null);return{monthFilter:e,setMonthFilter:a,filterError:r,validateAndApply:()=>{const o=new Date,m=o.getFullYear(),h=o.getMonth();if(!e.from&&e.to){const p="Please select a 'From' date before setting a 'To' date";return n(p),{isValid:!1,error:p,fromDate:null,toDate:null}}if(!e.from&&!e.to){const p="Please select a date range";return n(p),{isValid:!1,error:p,fromDate:null,toDate:null}}if(e.from&&!e.to){const p=G(new Date(e.from.year,e.from.month)),f=X(new Date(m,h));return n(null),{isValid:!0,error:null,fromDate:p,toDate:f}}if(e.from&&e.to){const p=G(new Date(e.from.year,e.from.month)),f=X(new Date(e.to.year,e.to.month));if(f<p){const x="Invalid range: 'To' date cannot be earlier than 'From' date";return n(x),{isValid:!1,error:x,fromDate:null,toDate:null}}const w=Ee(f,p);if(w>Z){const x=`Date range too large: Maximum ${Z} months allowed (selected ${w} months)`;return n(x),{isValid:!1,error:x,fromDate:null,toDate:null}}return n(null),{isValid:!0,error:null,fromDate:p,toDate:f}}return{isValid:!1,error:"Invalid filter state",fromDate:null,toDate:null}},handleClear:()=>{a({from:null,to:null}),n(null)}}}function ot(){const{toast:e}=fe(),a=ee(),r=B({mutationFn:async s=>{if(!s.event.id)throw console.error("â Missing event ID:",s.event),new Error("Event ID is required for conversion");return s.event.source||console.warn("â ï¸ Missing event source, defaulting to google"),D.convertCalendarEventToLedger({eventId:s.event.id,source:s.event.source||"google",formData:{title:s.formData.title,description:s.formData.description,activityType:s.formData.activityType,materialParticipation:s.formData.materialParticipation,isQualifiedNonMaterial:s.formData.isQualifiedNonMaterial,propertyId:s.formData.propertyId,category:s.formData.category,startDate:s.event.start,endDate:s.event.end,duration:Be(s.event.start,s.event.end)},attachments:s.event.attachments||[],newEvidenceFiles:s.newEvidenceFiles})},onSuccess:()=>{e({title:"Event Synced!",description:"Successfully synced calendar event to your activity ledger."}),a.invalidateQueries({queryKey:["/api/time-entries"]}),a.invalidateQueries({queryKey:["/api/calendar/events"]}),a.invalidateQueries({queryKey:["/api/time-entries/recent"]}),a.invalidateQueries({queryKey:["/api/dashboard-data"]})},onError:s=>{e({title:"Sync Failed",description:s.message||"Failed to sync event to time entry.",variant:"destructive"})}}),n=B({mutationFn:async s=>{var h,p;const o=(h=s.event)!=null&&h.start?new Date(s.event.start).toISOString().split("T")[0]:void 0,m=((p=s.event)==null?void 0:p.duration)||0;return await D.updateTimeEntry(s.entryId,{date:o,hours:m,activityType:s.formData.activityType,description:s.formData.description,materialParticipation:s.formData.materialParticipation,isQualifiedNonMaterial:s.formData.isQualifiedNonMaterial,propertyId:s.formData.propertyId,newEvidenceFiles:s.newEvidenceFiles})},onSuccess:(s,o)=>{e({title:"Entry Updated!",description:"Successfully updated the time entry."}),a.invalidateQueries({queryKey:["time-entries"]}),a.invalidateQueries({queryKey:["/api/time-entries"]}),a.invalidateQueries({queryKey:C.events()}),o.onSuccess&&o.onSuccess()},onError:s=>{e({title:"Update Failed",description:s.message||"Failed to update time entry.",variant:"destructive"})}}),i=B({mutationFn:async s=>{const o=await fetch(`/api/time-entries/${s}/approve`,{method:"PATCH",headers:{"Content-Type":"application/json"}});if(!o.ok){const m=await o.json();throw new Error(m.message||"Failed to approve time entry")}return o.json()},onSuccess:()=>{e({title:"Entry Approved!",description:"Successfully approved the time entry."}),a.invalidateQueries({queryKey:["time-entries"]}),a.invalidateQueries({queryKey:["/api/time-entries"]})},onError:s=>
7{e({title:"Approval Failed",description:s.message||"Failed to approve time entry.",variant:"destructive"})}});return{syncEventMutation:r,updateTimeEntryMutation:n,approveTimeEntryMutation:i}}function Be(e,a){const r=new Date(e).getTime();return(new Date(a).getTime()-r)/(1e3*60*60)}function lt(e){return e.map(a=>{const r=(()=>{if(typeof a.start=="string"&&!a.start.includes("T"))return!0;const o=new Date(a.start),m=new Date(a.end),h=o.getUTCHours()===0&&o.getUTCMinutes()===0,p=m.getUTCHours()===0&&m.getUTCMinutes()===0;return h&&p})(),{backgroundColor:n,borderColor:i,textColor:s}=ze(a);return{id:a.id,title:a.title,start:a.start,end:a.end,allDay:r,backgroundColor:n,borderColor:i,textColor:s,classNames:[],extendedProps:{description:a.description,source:a.source,hasLedgerEntry:a.hasLedgerEntry,approvalStatus:a.approvalStatus,calendarName:a.calendarName,calendarColor:a.calendarColor,aiConfidence:a.aiConfidence,aiReasoning:a.aiReasoning,isRealEstateRelated:a.isRealEstateRelated,automationMatch:a.automationMatch,suggestedActivityType:a.suggestedActivityType,suggestedMaterialParticipation:a.suggestedMaterialParticipation,location:a.location,attendees:a.attendees,duration:a.duration,attachments:a.attachments,duplicateTimeEntryId:a.duplicateTimeEntryId}}})}function ze(e){return $e(L(e))}function He(e){return{available:e.filter(a=>L(a)==="available").length,pending:e.filter(a=>L(a)==="pending").length,approved:e.filter(a=>L(a)==="approved").length,total:e.length}}function ct(e,a){return{totalEvents:e.length,monthsCached:a.filter(r=>r.status==="success").length,monthsLoading:a.filter(r=>r.status==="loading").length,monthsFailed:a.filter(r=>r.status==="error").length,statusBreakdown:He(e)}}function dt({showEventDialog:e,setShowEventDialog:a,selectedEvent:r,reviewFormData:n,setReviewFormData:i,evidenceFiles:s,setEvidenceFiles:o,newEvidenceFiles:m,setNewEvidenceFiles:h,properties:p,syncEventMutation:f,approveTimeEntryMutation:w,updateTimeEntryMutation:x,processEvidenceFile:T,getEventStatus:S}){const c=r?S(r):"available";return t.jsx(ge,{open:e,onOpenChange:a,children:t.jsxs(xe,{className:"max-w-xl max-h-[90vh] overflow-y-auto p-6",children:[t.jsxs(ye,{className:"space-y-3 pb-4",children:[t.jsxs(je,{className:"text-xl font-semibold text-gray-900 dark:text-gray-100 flex items-center gap-2",children:[(r==null?void 0:r.source)==="google"?t.jsx(Fe,{className:"h-5 w-5 text-blue-600"}):(r==null?void 0:r.source)==="microsoft"?t.jsx("img",{src:"/outlook-icons/outlook-calendar.png",alt:"Outlook Calendar",className:"h-5 w-5"}):t.jsx(we,{className:"h-5 w-5 text-gray-500"}),c==="available"&&"Review Calendar Event",c==="pending"&&"Pending Time Entry",c==="approved"&&"Approved Time Entry"]}),t.jsxs(be,{className:"text-gray-600 dark:text-gray-400 leading-relaxed",children:[c==="available"&&"Review and sync this event to your REPS activity log",c==="pending"&&"This entry is pending approval. Review and approve to confirm.",c==="approved"&&"This entry has been approved. You can update the details if needed."]})]}),r&&t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[c==="available"&&t.jsx(z,{className:"bg-blue-500 text-white",children:"Available to Convert"}),c==="pending"&&t.jsx(z,{className:"bg-amber-500 text-white",children:"Pending Approval"}),c==="approved"&&t.jsx(z,{className:"bg-green-500 text-white",children:"Approved"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Q,{htmlFor:"event-title",className:"text-base font-medium text-gray-900 dark:text-gray-100",children:"Event Title"}),t.jsx(ve,{id:"event-title",placeholder:"Enter event title",value:n.title,onChange:l=>i(d=>({...d,title:l.target.value})),className:"text-sm text-gray-700 dark:text-gray-300","data-testid":"input-event-title",disabled:c==="pending"})]}),t.jsx(Ve,{selectedEvent:r}),(r==null?void 0:r.aiConfidence)!==void 0&&t.jsxs("div",{className:"border rounded-lg p-4 bg-blue-50 dark:bg-blue-950 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ne,{className:"h-5 w-5 text-blue-600"}),t.jsx("h4",{className:"font-semibold text-blue-900 dark:text-blue-100",children:"AI Analysis"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Confidence Score"}),t.jsxs("span",{className:`text-lg font-bold ${r.aiConfidence>=90?"text-green-600":r.aiConfidence>=50?"text-amber-600":"text-gray-600"}`,children:[r.aiConfidence,"%"]})]}),t.jsx("div",{className:"w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2.5",children:t.jsx("div",{className:`h-2.5 rounded-full transition-all ${r.aiConfidence>=90?"bg-green-600":r.aiConfidence>=50?"bg-amber-500":"bg-gray-400"}`,style:{width:`${r.aiConfidence}%`}})}),r.aiReasoning&&t.jsx("div",{className:"mt-3 p-3 bg-white dark:bg-gray-800 rounded-md border border-blue-200 dark:border-blue-800",children:t.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300 italic",children:['"',r.aiReasoning,'"']})}),t.jsx("div",{className:"mt-3 p-3 bg-white dark:bg-gray-800 rounded-md border border-blue-200 dark:border-blue-800",children:t.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 flex items-start gap-2",children:r.aiConfidence>=90?t.jsxs(t.Fragment,{children:[t.jsx(Ce,{className:"h-4 w-4 flex-shrink-0 text-green-600 mt-0.5"}),t.jsxs("span",{children:[t.jsx("strong",{className:"text-green-700 dark:text-green-400",children:"Auto-approved:"})," ","High confidence (â¥90%) events are automatically converted to approved time entries."]})]}):r.aiConfidence>=50?t.jsxs(t.Fragment,{children:[t.jsx(R,{className:"h-4 w-4 flex-shrink-0 text-amber-600 mt-0.5"}),t.jsxs("span",{children:[t.jsx("strong",{className:"text-amber-700 dark:text-amber-400",children:"Pending review:"})," ","Medium confidence (50-89%) events need manual review before approval."]})]}):t.jsxs(t.Fragment,{children:[t.jsx(qe,{className:"h-4 w-4 flex-shrink-0 text-gray-600 mt-0.5"}),t.jsxs("span",{children:[t.jsx("strong",{className:"text-gray-700 dark:text-gray-400",children:"Manual conversion:"})," ","Low confidence (<50%) events require manual review and conversion."]})]})})})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(Q,{className:"text-base font-medium text-gray-900 dark:text-gray-100",children:"Description"}),t.jsx(Se,{placeholder:"Add additional details about this event...",value:n.description,onChange:l=>{i(d=>({...d,description:l.target.value})),l.target.style.height="auto",l.target.style.height=l.target.scrollHeight+"px"},ref:l=>{l&&n.description&&(l.style.height="auto",l.style.height=l.scrollHeight+"px")},className:"text-sm resize-none text-gray-700 dark:text-gray-300 overflow-hidden",style:{minHeight:"100px"},"data-testid":"textarea-event-description"})]}),t.jsx(Qe,{evidenceFiles:s,setEvidenceFiles:o,newEvidenceFiles:m,setNewEvidenceFiles:h}),t.jsx(Ue,{reviewFormData:n,setReviewFormData:i,properties:p}),t.jsx(_e,{eventStatus:c,selectedEvent:r,reviewFormData:n,evidenceFiles:s,setShowEventDialog:a,syncEventMutation:f,approveTimeEntryMutation:w,updateTimeEntryMutation:x,newEvidenceFiles:m})]})]})})}function mt({dateRangeFilter:e,setDateRangeFilter:a,filterValidationError:r,handleRefreshEvents:n,validateDateRangeFilter:i,calendarRef:s}){var w,x,T,S;const[o,m]=v.useState(!1),h=(c,l)=>{const d=new Date(l,c);return H(d,"MMM yyyy")},p=()=>{a({from:null,to:null}),m(!1),n(),s.current&&s.current.getApi().gotoDate(new Date)},f=()=>{const c=i(e);if(c.isValid){if(m(!1),s.current){const l=c.normalizedFrom?new Date(c.normalizedFrom.year,c.normalizedFrom.month):new Date;s.current.getApi().gotoDate(l)}n(!0)}};return t.jsxs(Te,{open:o,onOpenChange:m,children:[t.jsx(ke,{children:t.jsxs(De,{children:[t.jsx(Me,{asChild:!0,children:t.jsx(Ae,{asChild:!0,children:t.jsxs(N,{variant:e.from||e.to?"default":"outline",size:"sm",className:e.from||e.to?"bg-purple-600 hover:bg-purple-700 text-white h-7 sm:h-10 text-xs":"sm:h-10 h-7 text-xs",children:[t.jsx(Ke,{className:"h-4 w-4 mr-1"}),e.from&&e.to?`${h(e.from.month,e.from.year)} - ${h(e.to.month,e.to.year)}`:e.from?`From ${h(e.from.month,e.from.year)}`:e.to?`To ${h(e.to.month,e.to.year)}`:null,(e.from||e.to)&&t.jsx(Pe,{className:"h-3 w-3 ml-1",onClick:c=>{c.stopPropagation(),p()}})]})})}),t.jsx(Ie,{children:t.jsx("p",{children:e.from||e.to?"Filtered by month/year range (Click X to clear)":"Filter events by month/year range"})})]})}),t.jsx(Oe,{className:"w-auto p-4",align:"start",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(Q,{className:"text-sm font-medium",children:"From Month/Year"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(A,{value:((w=e.from)==null?void 0:w.month.toString())||"",onValueChange:c=>{var u;const l=parseInt(c),d=((u=e.from)==null?void 0:u.year)||new Date().getFullYear();a(b=>({...b,from:{month:l,year:d}}))},children:[t.jsx(P,{className:"w-32",children:t.jsx(I,{placeholder:"Month"})}),t.jsx(O,{children:Array.from({length:12},(c,l)=>t.jsx(E,{value:l.toString(),children:H(new Date(2e3,l),"MMMM")},l))})]}),t.jsxs(A,{value:((x=e.from)==null?void 0:x.year.toString())||"",onValueChange:c=>{var u;const l=parseInt(c),d=((u=e.from)==null?void 0:u.month)||new Date().getMonth();a(b=>({...b,from:{month:d,year:l}}))},children:[t.jsx(P,{className:"w-24",children:t.jsx(I,{placeholder:"Year"})}),t.jsx(O,{children:Array.from({length:10},(c,l)=>{const d=new Date().getFullYear()-5+l;return t.jsx(E,{value:d.toString(),children:d},d)})})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs(Q,{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:["To Month/Year",!e.from&&t.jsx("span",{className:"ml-1 text-xs text-gray-500 dark:text-gray-400",children:"(Select From date first)"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(A,{value:((T=e.to)==null?void 0:T.month.toString())||"",onValueChange:c=>{var u;const l=parseInt(c),d=((u=e.to)==null?void 0:u.year)||new Date().getFullYear();a(b=>({...b,to:{month:l,year:d}}))},disabled:!e.from,children:[t.jsx(P,{className:"w-32",children:t.jsx(I,{placeholder:"Month"})}),t.jsx(O,{children:Array.from({length:12},(c,l)=>t.jsx(E,{value:l.toString(),children:H(new Date(2e3,l),"MMMM")},l))})]}),t.jsxs(A,{value:((S=e.to)==null?void 0:S.year.toString())||"",onValueChange:c=>{var u;const l=parseInt(c),d=((u=e.to)==null?void 0:u.month)||new Date().getMonth();a(b=>({...b,to:{month:d,year:l}}))},disabled:!e.from,children:[t.jsx(P,{className:"w-24",children:t.jsx(I,{placeholder:"Year"})}),t.jsx(O,{children:Array.from({length:10},(c,l)=>{const d=new Date().getFullYear()-5+l;return t.jsx(E,{value:d.toString(),children:d},d)})})]})]})]}),r&&t.jsx("div",{className:"p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-md",children:t.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:r})}),t.jsxs("div",{className:"flex gap-2 pt-2",children:[t.jsx(N,{variant:"outline",size:"sm",onClick:p,className:"flex-1",children:"Clear"}),t.jsx(N,{size:"sm",onClick:f,disabled:!e.from,className:"flex-1 bg-purple-600 hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed",children:"Apply"})]})]})})]})}export{mt as C,dt as E,nt as a,it as b,ot as c,tt as d,at as e,C as f,ct as g,L as h,Ve as i,_e as j,D as k,st as l,lt as t,rt as u};
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.