PageSourceSearch

https://repsshield.com/assets/CalendarDateRangeFilter-BVOXnJ7M.js

js repsshield.com collected 2026-09-24 14:19:07 UTC 31,486 bytes, 7 lines download raw bytes

1import{y as ae,j as t,bT as re,bU as se,bV as ne,aF as F,bW as ie,bX as oe,bY as le,bZ as ce,b_ as de,ac as me,i as Z,be as pe,U as he,B as N,h as V,aJ as R,d2 as Y,cj as G,a as ue,aC as _,aZ as ge,a_ as fe,a$ as ye,b0 as xe,m as je,b1 as we,e as B,L,K as be,W as ve,f as Ne,aD as Ce,b7 as Se,aW as Te,bO as ke,bP as De,b8 as Me,X as Ae,bQ as Ie,b9 as Pe,_ as A,$ as I,a0 as P,a1 as O,a2 as E,a5 as H}from"./index-Byg2HWAE.js";import{r as v}from"./vendor-Qgthw7N1.js";import{d as Oe}from"./differenceInMonths-CWoVTq_U.js";import{S as Ee}from"./index-Bs2JGf-v.js";import{T as Fe}from"./timer-B3GC1z8w.js";import{E as Le,R as Qe}from"./RepsClassificationSection-BliMW0iC.js";import{C as Ue}from"./circle-x-C3yul9_R.js";import{C as qe}from"./calendar-days-CZv4Giu2.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 Re=ae("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 et({open:e,onOpenChange:a,onConfirm:r,isLoading:n,calendarProvider:i="unified"}){const c=(()=>{switch(i){case"google":return"Google Calendar";case"microsoft":return"Microsoft Calendar";case"unified":default:return"your calendar"}})();return t.jsx(re,{open:e,onOpenChange:a,children:t.jsxs(se,{className:"max-w-md",children:[t.jsxs(ne,{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(ie,{className:"text-lg",children:["Sync from ",c,"?"]})]}),t.jsxs(oe,{className:"space-y-3 pt-2",children:[t.jsxs("p",{className:"text-sm text-foreground/80",children:["This will fetch the latest events from ",c,"."]}),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 ",c," 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(le,{children:[t.jsx(ce,{disabled:n,children:"Cancel"}),t.jsxs(de,{onClick:m=>{m.preventDefault(),r()},disabled:n,className:"flex items-center gap-2 min-w-[100px]",children:[n&&t.jsx(me,{className:"h-4 w-4 animate-spin"}),n?"Syncing...":"Sync Now"]})]})]})})}function Ke({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(Z,{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(Fe,{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(pe,{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(he,{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:c,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&&c.mutate({event:a,formData:r,evidenceFiles:n,newEvidenceFiles:i})},disabled:c.isPending,className:"px-6 bg-green-600 hover:bg-green-700 flex items-center gap-2 text-white",children:c.isPending?t.jsxs(t.Fragment,{children:[t.jsx(F,{className:"h-4 w-4 animate-spin"}),"Syncing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(V,{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(V,{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(V,{className:"h-4 w-4"}),"Update Entry"]})})]})]})}function tt(e={}){const{days:a,startDate:r,endDate:n,dateRangeFilter:i,skipCache:s=!1,enabled:c=!0,calendarIds:m}=e,[h,p]=v.useState({events:[],isLoading:!1,isStreaming:!1,error:null,statusMessage:null,progress:null,stats:null}),g=v.useRef(null),w=r==null?void 0:r.toISOString(),y=n==null?void 0:n.toISOString(),T=m==null?void 0:m.sort().join(","),S=JSON.stringify(i),l=v.useCallback(async()=>{g.current&&g.current.abort();const o=new AbortController;g.current=o,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 U=new Date(i.from.year,i.from.month,1),q=new Date(i.to?i.to.year:i.from.year,i.to?i.to.month+1:i.from.month+1,0);d.startDate=U.toISOString(),d.endDate=q.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:o.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(),ee=new TextDecoder;let Q="";for(;;){const{done:U,value:q}=await b.read();if(U)break;Q+=ee.decode(q,{stream:!0});const z=Q.split(`
7`);Q=z.pop()||"";for(const J of z)if(J.trim())try{const f=JSON.parse(J);if(f.type==="events")p(j=>{const M=f.data,k=new Map(j.events.map(x=>[x.id,x]));for(const x of M)k.set(x.id,x);return{...j,isLoading:!1,events:Array.from(k.values()).sort((x,K)=>{const $=new Date(x.start).getTime();return new Date(K.start).getTime()-$})}});else if(f.type==="event_update")p(j=>{const M=f.data,k=new Map(j.events.map(x=>[x.id,x]));return k.set(M.id,M),{...j,events:Array.from(k.values()).sort((x,K)=>{const $=new Date(x.start).getTime();return new Date(K.start).getTime()-$})}});else if(f.type==="status")p(j=>({...j,statusMessage:f.message}));else if(f.type==="progress")p(j=>({...j,progress:{processed:f.processed,total:f.total}}));else if(f.type==="complete")p(j=>({...j,isStreaming:!1,isLoading:!1,stats:f.stats,statusMessage:"Sync complete"}));else if(f.type==="error")throw new Error(f.error)}catch(f){console.error("Error parsing stream chunk:",f)}}}catch(d){if(d.name==="AbortError")return;console.error("Stream error:",d),p(u=>({...u,isLoading:!1,isStreaming:!1,error:d}))}},[a,w,y,S,s,c,T]);return v.useEffect(()=>(c&&l(),()=>{g.current&&g.current.abort()}),[l,c]),{...h,refetch:l}}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 c=await s.json();throw new Error(c.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()}},at=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)),c=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 c.filter(m=>m.hasLedgerEntry).length,c}function rt(e){const a=R();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 X=24;function st(){const[e,a]=v.useState({from:null,to:null}),[r,n]=v.useState(null);return{monthFilter:e,setMonthFilter:a,filterError:r,validateAndApply:()=>{const c=new Date,m=c.getFullYear(),h=c.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=Y(new Date(e.from.year,e.from.month)),g=G(new Date(m,h));return n(null),{isValid:!0,error:null,fromDate:p,toDate:g}}if(e.from&&e.to){const p=Y(new Date(e.from.year,e.from.month)),g=G(new Date(e.to.year,e.to.month));if(g<p){const y="Invalid range: 'To' date cannot be earlier than 'From' date";return n(y),{isValid:!1,error:y,fromDate:null,toDate:null}}const w=Oe(g,p);if(w>X){const y=`Date range too large: Maximum ${X} months allowed (selected ${w} months)`;return n(y),{isValid:!1,error:y,fromDate:null,toDate:null}}return n(null),{isValid:!0,error:null,fromDate:p,toDate:g}}return{isValid:!1,error:"Invalid filter state",fromDate:null,toDate:null}},handleClear:()=>{a({from:null,to:null}),n(null)}}}function nt(){const{toast:e}=ue(),a=R(),r=_({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:Ve(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=_({mutationFn:async s=>{var h,p;const c=(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:c,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,c)=>{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()}),c.onSuccess&&c.onSuccess()},onError:s=>{e({title:"Update Failed",description:s.message||"Failed to update time entry.",variant:"destructive"})}}),i=_({mutationFn:async s=>{const c=await fetch(`/api/time-entries/${s}/approve`,{method:"PATCH",headers:{"Content-Type":"application/json"}});if(!c.ok){const m=await c.json();throw new Error(m.message||"Failed to approve time entry")}return c.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 Ve(e,a){const r=new Date(e).getTime();return(new Date(a).getTime()-r)/(1e3*60*60)}function it(e){return e.map(a=>{const r=(()=>{if(typeof a.start=="string"&&!a.start.includes("T"))return!0;const s=new Date(a.start),c=new Date(a.end),m=s.getUTCHours()===0&&s.getUTCMinutes()===0,h=c.getUTCHours()===0&&c.getUTCMinutes()===0;return m&&h})(),{backgroundColor:n,borderColor:i}=_e(a);return{id:a.id,title:a.title,start:a.start,end:a.end,allDay:r,backgroundColor:n,borderColor:i,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 _e(e){return e.hasLedgerEntry?e.approvalStatus==="approved"?{backgroundColor:"#10b981",borderColor:"#10b981"}:{backgroundColor:"#f59e0b",borderColor:"#f59e0b"}:{backgroundColor:"#3b82f6",borderColor:"#3b82f6"}}function Be(e){return{available:e.filter(a=>!a.hasLedgerEntry).length,pending:e.filter(a=>a.hasLedgerEntry&&a.approvalStatus==="pending").length,approved:e.filter(a=>a.hasLedgerEntry&&a.approvalStatus==="approved").length,total:e.length}}function ot(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:Be(e)}}function lt({showEventDialog:e,setShowEventDialog:a,selectedEvent:r,reviewFormData:n,setReviewFormData:i,evidenceFiles:s,setEvidenceFiles:c,newEvidenceFiles:m,setNewEvidenceFiles:h,properties:p,syncEventMutation:g,approveTimeEntryMutation:w,updateTimeEntryMutation:y,processEvidenceFile:T,getEventStatus:S}){const l=r?S(r):"available";return t.jsx(ge,{open:e,onOpenChange:a,children:t.jsxs(fe,{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(xe,{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(Ee,{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(je,{className:"h-5 w-5 text-gray-500"}),l==="available"&&"Review Calendar Event",l==="pending"&&"Pending Time Entry",l==="approved"&&"Approved Time Entry"]}),t.jsxs(we,{className:"text-gray-600 dark:text-gray-400 leading-relaxed",children:[l==="available"&&"Review and sync this event to your REPS activity log",l==="pending"&&"This entry is pending approval. Review and approve to confirm.",l==="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:[l==="available"&&t.jsx(B,{className:"bg-blue-500 text-white",children:"Available to Convert"}),l==="pending"&&t.jsx(B,{className:"bg-amber-500 text-white",children:"Pending Approval"}),l==="approved"&&t.jsx(B,{className:"bg-green-500 text-white",children:"Approved"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(L,{htmlFor:"event-title",className:"text-base font-medium text-gray-900 dark:text-gray-100",children:"Event Title"}),t.jsx(be,{id:"event-title",placeholder:"Enter event title",value:n.title,onChange:o=>i(d=>({...d,title:o.target.value})),className:"text-sm text-gray-700 dark:text-gray-300","data-testid":"input-event-title",disabled:l==="pending"})]}),t.jsx(Ke,{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(ve,{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(Ne,{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(Z,{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(Ue,{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(L,{className:"text-base font-medium text-gray-900 dark:text-gray-100",children:"Description"}),t.jsx(Ce,{placeholder:"Add additional details about this event...",value:n.description,onChange:o=>{i(d=>({...d,description:o.target.value})),o.target.style.height="auto",o.target.style.height=o.target.scrollHeight+"px"},ref:o=>{o&&n.description&&(o.style.height="auto",o.style.height=o.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(Le,{evidenceFiles:s,setEvidenceFiles:c,newEvidenceFiles:m,setNewEvidenceFiles:h}),t.jsx(Qe,{reviewFormData:n,setReviewFormData:i,properties:p}),t.jsx($e,{eventStatus:l,selectedEvent:r,reviewFormData:n,evidenceFiles:s,setShowEventDialog:a,syncEventMutation:g,approveTimeEntryMutation:w,updateTimeEntryMutation:y,newEvidenceFiles:m})]})]})})}function ct({dateRangeFilter:e,setDateRangeFilter:a,filterValidationError:r,handleRefreshEvents:n,validateDateRangeFilter:i,calendarRef:s}){var w,y,T,S;const[c,m]=v.useState(!1),h=(l,o)=>{const d=new Date(o,l);return H(d,"MMM yyyy")},p=()=>{a({from:null,to:null}),m(!1),n(),s.current&&s.current.getApi().gotoDate(new Date)},g=()=>{const l=i(e);if(l.isValid){if(m(!1),s.current){const o=l.normalizedFrom?new Date(l.normalizedFrom.year,l.normalizedFrom.month):new Date;s.current.getApi().gotoDate(o)}n(!0)}};return t.jsxs(Se,{open:c,onOpenChange:m,children:[t.jsx(Te,{children:t.jsxs(ke,{children:[t.jsx(De,{asChild:!0,children:t.jsx(Me,{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(qe,{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(Ae,{className:"h-3 w-3 ml-1",onClick:l=>{l.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(Pe,{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(L,{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:l=>{var u;const o=parseInt(l),d=((u=e.from)==null?void 0:u.year)||new Date().getFullYear();a(b=>({...b,from:{month:o,year:d}}))},children:[t.jsx(I,{className:"w-32",children:t.jsx(P,{placeholder:"Month"})}),t.jsx(O,{children:Array.from({length:12},(l,o)=>t.jsx(E,{value:o.toString(),children:H(new Date(2e3,o),"MMMM")},o))})]}),t.jsxs(A,{value:((y=e.from)==null?void 0:y.year.toString())||"",onValueChange:l=>{var u;const o=parseInt(l),d=((u=e.from)==null?void 0:u.month)||new Date().getMonth();a(b=>({...b,from:{month:d,year:o}}))},children:[t.jsx(I,{className:"w-24",children:t.jsx(P,{placeholder:"Year"})}),t.jsx(O,{children:Array.from({length:10},(l,o)=>{const d=new Date().getFullYear()-5+o;return t.jsx(E,{value:d.toString(),children:d},d)})})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs(L,{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:l=>{var u;const o=parseInt(l),d=((u=e.to)==null?void 0:u.year)||new Date().getFullYear();a(b=>({...b,to:{month:o,year:d}}))},disabled:!e.from,children:[t.jsx(I,{className:"w-32",children:t.jsx(P,{placeholder:"Month"})}),t.jsx(O,{children:Array.from({length:12},(l,o)=>t.jsx(E,{value:o.toString(),children:H(new Date(2e3,o),"MMMM")},o))})]}),t.jsxs(A,{value:((S=e.to)==null?void 0:S.year.toString())||"",onValueChange:l=>{var u;const o=parseInt(l),d=((u=e.to)==null?void 0:u.month)||new Date().getMonth();a(b=>({...b,to:{month:d,year:o}}))},disabled:!e.from,children:[t.jsx(I,{className:"w-24",children:t.jsx(P,{placeholder:"Year"})}),t.jsx(O,{children:Array.from({length:10},(l,o)=>{const d=new Date().getFullYear()-5+o;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:g,disabled:!e.from,className:"flex-1 bg-purple-600 hover:bg-purple-700 disabled:opacity-50 disabled:cursor-not-allowed",children:"Apply"})]})]})})]})}export{ct as C,lt as E,rt as a,st as b,nt as c,Re as d,et as e,C as f,ot as g,Ke as h,$e as i,D as j,at as k,it as t,tt 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.