1import{d as p,a as _,j as e}from"./vendor-query-B-_nDQQY.js";import{L as k,u as E,o as L,n as g,m as f,U as C,b as j}from"./index-D8ww6b7J.js";/* empty css */import{M as I,T as S,a as T,P as M,L as x}from"./vendor-leaflet-CQpbWEOL.js";import{T as A}from"./TeamNav-BriM7U0R.js";import{N as O}from"./navigation-TAQUAeuu.js";import{H as U}from"./hammer-Burg9xO0.js";import{C as F}from"./car-D_76LGWF.js";import"./vendor-three-1K-S22da.js";import"./vendor-charts-i-522T5A.js";import"./vendor-react-BUIlT3ms.js";import"./vendor-pdf-Bwkk3Ew0.js";import"./vendor-radix-X0WMATEu.js";delete x.Icon.Default.prototype._getIconUrl;x.Icon.Default.mergeOptions({iconRetinaUrl:"https://unpkg.com/[email protected]/dist/images/marker-icon-2x.png",iconUrl:"https://unpkg.com/[email protected]/dist/images/marker-icon.png",shadowUrl:"https://unpkg.com/[email protected]/dist/images/marker-shadow.png"});const i={transit:{label:"In Transit",color:"#f59e0b",icon:F,short:"Moving between locations"},job_site:{label:"At the Job Site",color:"#84cc16",icon:U,short:"At a client or project location"},shop:{label:"In the Shop",color:"#3b82f6",icon:L,short:"At the company headquarters"},off_duty:{label:"Not Working",color:"#94a3b8",icon:E,short:"Off-duty or clocked out"}};function P(o){return o==="travel"?"transit":o==="on_site"||o==="installation"?"job_site":"shop"}function q(o){const c=i[o],d=o==="transit";return x.divIcon({html:`<div style=" 2 background: ${c.color}; 3 border: 3px solid white; 4 border-radius: 50%; 5 width: 20px; 6 height: 20px; 7 box-shadow: 0 2px 8px rgba(0,0,0,0.3); 8 ${d?"animation: pulse 1.5s infinite;":""} 9 "></div> 10 <style>@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }</style>`,className:"custom-marker",iconSize:[20,20],iconAnchor:[10,10]})}function X(){const{data:o=[],isLoading:c}=p({queryKey:["employees"],queryFn:()=>j.entities.Employee.list(),refetchInterval:15e3}),{data:d=[],isLoading:N}=p({queryKey:["time-entries-active"],queryFn:()=>j.entities.TimeEntry.filter({clock_out_time:null}),refetchInterval:15e3}),b=c||N,n=o.map(s=>{const t=d.find(l=>l.employee_id===s.id),r=t?P(t.entry_type):"off_duty";return{...s,status:r,activeEntry:t,lat:(t==null?void 0:t.clock_in_lat)||null,lng:(t==null?void 0:t.clock_in_lng)||null}}),y={transit:n.filter(s=>s.status==="transit").length,job_site:n.filter(s=>s.status==="job_site").length,shop:n.filter(s=>s.status==="shop").length,off_duty:n.filter(s=>s.status==="off_duty").length},m=n.filter(s=>s.lat&&s.lng),{mapCenter:v,zoom:w}=_.useMemo(()=>{const s=m.map(t=>[t.lat,t.lng]);if(s.length>0){const t=s.reduce((l,a)=>l+a[0],0)/s.length,r=s.reduce((l,a)=>l+a[1],0)/s.length;return{mapCenter:[t,r],zoom:11}}return{mapCenter:[28.5,-81.5],zoom:10}},[m]);return b?e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx(k,{className:"w-12 h-12 animate-spin mx-auto text-primary"}),e.jsx("p",{className:"text-muted-foreground",children:"Loading employee locations..."})]})}):e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("div",{className:"bg-primary text-primary-foreground p-4 sm:p-6",children:e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(O,{className:"w-6 h-6 sm:w-8 sm:h-8"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold",children:"Live Employee Tracking"}),e.jsx("p",{className:"text-xs sm:text-sm opacity-90",children:"Real-time GPS location & status updates"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 sm:gap-4",children:Object.entries(i).map(([s,t])=>{const r=t.icon;return e.jsxs("div",{className:"flex items-center gap-2 bg-white/10 px-2 sm:px-4 py-2 rounded-lg",children:[e.jsx(r,{className:"w-4 h-4 sm:w-5 sm:h-5 shrink-0",style:{color:t.color}}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] sm:text-xs opacity-80",children:t.label}),e.jsx("p",{className:"text-sm sm:text-lg font-bold",children:y[s]})]})]},s)})})]})})}),e.jsxs("div",{className:"max-w-7xl mx-auto p-3 sm:p-6 space-y-4",children:[e.jsx(A,{currentPath:"/employee-tracking"}),e.jsx("div",{className:"border rounded-xl overflow-hidden shadow-lg",style:{height:"400px"},children:e.jsxs(I,{center:v,zoom:w,style:{height:"100%",width:"100%"},scrollWheelZoom:!1,attributionControl:!1,children:[e.jsx(S,{url:"https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}",attribution:"© OpenStreetMap © CARTO"}),m.map(s=>{var l;const t=i[s.status],r=t.icon;return e.jsx(T,{position:[s.lat,s.lng],icon:q(s.status),children:e.jsx(M,{children:e.jsxs("div",{className:"text-sm space-y-2 min-w-[200px]",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-base",children:s.name}),s.role&&e.jsx("p",{className:"text-xs text-muted-foreground",children:s.role})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx(r,{className:"w-4 h-4",style:{color:t.color}}),e.jsx("span",{className:"font-medium",style:{color:t.color},children:t.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.short}),((l=s.activeEntry)==null?void 0:l.job_label)&&e.jsxs("div",{className:"pt-2 border-t",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Job"}),e.jsx("p",{className:"font-medium text-xs",children:s.activeEntry.job_label})]}),s.activeEntry&&e.jsx("div",{className:"pt-2 border-t",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(g,{className:"w-3 h-3"}),e.jsxs("span",{children:["Clocked in: ",new Date(s.activeEntry.clock_in_time).toLocaleTimeString()]})]})})]})})},s.id)})]})}),e.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-4 text-xs sm:text-sm",children:[Object.entries(i).map(([s,t])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 sm:w-4 sm:h-4 roun
10ded-full border-2 border-white shadow",style:{backgroundColor:t.color}}),e.jsx("span",{className:"text-muted-foreground",children:t.label})]},s)),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Updates every 15 seconds"})]}),Object.entries(i).map(([s,t])=>{const r=n.filter(a=>a.status===s);if(r.length===0)return null;const l=t.icon;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(l,{className:"w-4 h-4",style:{color:t.color}}),e.jsx("h3",{className:"text-sm font-semibold",children:t.label}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",r.length,")"]}),e.jsxs("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:["â ",t.short]})]}),e.jsx("div",{className:"grid gap-3 sm:gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",children:r.map(a=>{var h,u;return e.jsxs("div",{className:"border rounded-xl p-3 sm:p-4 bg-card",style:{borderLeftColor:t.color,borderLeftWidth:3},children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-sm sm:text-base truncate",children:a.name}),a.role&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:a.role})]}),e.jsx(l,{className:"w-4 h-4 sm:w-5 sm:h-5 shrink-0",style:{color:t.color}})]}),e.jsxs("div",{className:"space-y-2 text-xs sm:text-sm",children:[a.lat&&a.lng?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{className:"w-3 h-3 sm:w-4 sm:h-4 text-muted-foreground shrink-0"}),e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:[a.lat.toFixed(4),", ",a.lng.toFixed(4)]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(f,{className:"w-3 h-3 sm:w-4 sm:h-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No GPS data"})]}),((h=a.activeEntry)==null?void 0:h.clock_in_time)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{className:"w-3 h-3 sm:w-4 sm:h-4 text-muted-foreground shrink-0"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Since ",new Date(a.activeEntry.clock_in_time).toLocaleTimeString()]})]}),((u=a.activeEntry)==null?void 0:u.job_label)&&e.jsxs("div",{className:"pt-2 mt-2 border-t",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assigned to"}),e.jsx("p",{className:"font-medium text-xs truncate",children:a.activeEntry.job_label})]})]})]},a.id)})})]},s)}),n.length===0&&e.jsxs("div",{className:"text-center py-12 sm:py-16",children:[e.jsx(C,{className:"w-12 h-12 sm:w-16 sm:h-16 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"text-base sm:text-lg font-semibold mb-2",children:"No Employees"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Add employees to see them on the map"})]})]})]})}export{X 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.