1import{u as G,y as J,z as K,r as s,j as e,b as Q,c as X,M as ee,L as ae,N as te,T as se,p as E,H as ce,e as le,P as re,I as ie}from"./index-U8D282DB.js";import{L as d,c as I,a as ne,f as S,b as oe}from"./LeafletMap-B3NP7ER2.js";import{B as de}from"./badge-BmpMbrZ9.js";import{g as ge}from"./osrm-CvNFBmGH.js";const xe=1e4,ue=3e4,M="Australia/Sydney";function B(n){return new Date(n).toLocaleTimeString("en-AU",{hour:"2-digit",minute:"2-digit",hour12:!0,timeZone:M})}function me(n){return new Date(n).toLocaleString("en-AU",{weekday:"short",day:"numeric",month:"short",hour:"2-digit",minute:"2-digit",hour12:!0,timeZone:M})}function Te(){G("Track Your Driver");const n=J(),U=K(),u=new URLSearchParams(U).get("token")||"",m=n.bookingId,[a,O]=s.useState(null),[v,p]=s.useState(null),[z,b]=s.useState(!0),o=s.useRef(null),f=s.useRef(null),h=s.useRef(null),k=s.useRef(null),T=s.useRef(null),[N,W]=s.useState(!1),[g,Z]=s.useState(null),[y,$]=s.useState(null),[x,V]=s.useState(null),w=s.useRef(0),L=s.useRef(!1),j=s.useCallback(async()=>{if(!(!m||!u))try{const t=await fetch(`/api/track/${m}?token=${u}`);if(!t.ok){const l=await t.json().catch(()=>({error:"Unknown error"}));p(l.error||`Error ${t.status}`),b(!1);return}const r=await t.json();O(r),p(null),b(!1)}catch(t){console.error("Fetch error:",t),p("Unable to load tracking data. Please try again."),b(!1)}},[m,u]);s.useEffect(()=>{j();const t=setInterval(j,xe);return()=>clearInterval(t)},[j]);const _=s.useCallback(t=>{o.current=t,W(!0)},[]),R=s.useCallback(async(t,r)=>{const l=Date.now();if(l-w.current<ue)return;w.current=l;const c=await ge(t,r);if(c){const i=Math.ceil(c.duration/60);Z({text:c.durationText,minutes:i}),$(c.distanceText),o.current&&(T.current?T.current.setLatLngs(c.geometry):T.current=d.polyline(c.geometry,{color:"#3b82f6",weight:5,opacity:.7}).addTo(o.current))}},[]);if(s.useEffect(()=>{if(!N||!o.current||!a)return;const t=o.current,r=a.pickupLat&&a.pickupLng?{lat:a.pickupLat,lng:a.pickupLng}:null,l=a.dropoffLat&&a.dropoffLng?{lat:a.dropoffLat,lng:a.dropoffLng}:null;if(r&&(h.current?h.current.setLatLng([r.lat,r.lng]):h.current=d.marker([r.lat,r.lng],{icon:I("#22c55e","Pickup"),zIndexOffset:100}).addTo(t)),l&&(k.current?k.current.setLatLng([l.lat,l.lng]):k.current=d.marker([l.lat,l.lng],{icon:I("#ef4444","Dropoff"),zIndexOffset:100}).addTo(t)),a.driverLocation){const i={lat:a.driverLocation.lat,lng:a.driverLocation.lng};f.current?f.current.setLatLng([i.lat,i.lng]):f.current=d.marker([i.lat,i.lng],{icon:ne("#3b82f6"),zIndexOffset:500}).addTo(t),V(new Date(a.driverLocation.updatedAt));const C=a.passengerOnBoardAt!=null?l:r;C&&R(i,C)}const c=[];if(r&&c.push(r),l&&c.push(l),a.driverLocation&&c.push({lat:a.driverLocation.lat,lng:a.driverLocation.lng}),c.length>0&&!L.current)S(t,c,60),L.current=!0;else if(c.length>0&&a.driverLocation){const i=d.latLng(a.driverLocation.lat,a.driverLocation.lng);t.getBounds().contains(i)||S(t,c,60)}},[a,N,R]),v)return e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:237",className:"min-h-screen bg-gradient-to-br from-slate-50 to-blue-50 flex items-center justify-center p-4",children:e.jsx(Q,{"data-loc":"client/src/pages/PublicTracking.tsx:238",className:"max-w-md w-full",children:e.jsxs(X,{"data-loc":"client/src/pages/PublicTracking.tsx:239",className:"pt-6 text-center",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:240",className:"w-16 h-16 mx-auto mb-4 rounded-full bg-red-100 flex items-center justify-center",children:e.jsx(ee,{"data-loc":"client/src/pages/PublicTracking.tsx:241",className:"h-8 w-8 text-red-500"})}),e.jsx("h2",{"data-loc":"client/src/pages/PublicTracking.tsx:243",className:"text-xl font-bold text-gray-900 mb-2",children:"Tracking Unavailable"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:244",className:"text-gray-600 mb-4",children:v}),e.jsxs("p",{"data-loc":"client/src/pages/PublicTracking.tsx:245",className:"text-sm text-gray-500",children:["If you need assistance, please call us at"," ",e.jsx("a",{"data-loc":"client/src/pages/PublicTracking.tsx:247",href:"tel:0408886230",className:"text-blue-600 font-medium",children:"0408 886 230"})]})]})})});if(z)return e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:258",className:"min-h-screen bg-gradient-to-br from-slate-50 to-blue-50 flex items-center justify-center",children:e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:259",className:"flex flex-col items-center gap-3",children:[e.jsx(ae,{"data-loc":"client/src/pages/PublicTracking.tsx:260",className:"h-8 w-8 animate-spin text-blue-600"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:261",className:"text-gray-600 font-medium",children:"Loading tracking data..."})]})});if(!a)return null;const P=a.passengerOnBoardAt!=null,D=a.driverArrivedAt!=null,A=a.driverEnRouteAt!=null,F=P?"In Transit":D?"Driver Arrived":A?"Driver On The Way":a.status==="assigned"?"Driver Assigned":a.status==="completed"?"Trip Completed":"Booking Pending",Y=P?"from-purple-600 to-purple-700":D?"from-amber-500 to-amber-600":A?"from-blue-600 to-blue-700":a.status==="completed"?"from-green-600 to-green-700":"from-gray-600 to-gray-700",H=P?"ETA to destination":"ETA to pickup",q={lat:a.pickupLat||-33.8688,lng:a.pickupLng||151.2093};return e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:303",className:"min-h-screen bg-gray-100 flex flex-col",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:305",className:`bg-gradient-to-r ${Y} text-white px-4 py-3 shadow-lg`,children:e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:306",className:"max-w-2xl mx-auto",children:e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:307",className:"flex items-center justify-between",children:[e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:308",className:"flex items-center gap-2",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:309",className:"w-8 h-8 rounded-full bg-white/20 flex items-center justify-center",children:e.jsx(te,{"data-loc":"client/src/pages/PublicTracking.tsx:310",className:"h-4 w-4"})}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:312",children:[e.jsx("h1",{"data-loc":"client/src/pages/PublicTracking.tsx:313",className:"font-bold text-lg leading-tight",children:"Drive4u"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:314",className:"text-xs text-white/80",children:"Live Trip Tracking"})]})]}),e.jsx(de,{"data-loc":"client/src/pages/PublicTracking.tsx:317",className:"bg-white/20 text-white border-white/30 hover:bg-white/30",children:F})]})})}),g&&a.driverLocation&&e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:326",className:"bg-white border-b shadow-sm",children:e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:327",className:"max-w-2xl mx-auto px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:328",className:"flex items-center gap-2",children:[e.jsx(se,{"data-loc":"client/src/pages/PublicTracking.tsx:329",className:"h-5 w-5 text-blue-600"}),e.jsx("span",{"data-loc":"client/src/pages/PublicTracking.tsx:330",className:"text-sm text-gray-600",children:H})]}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:332",className:"flex items-center gap-3",children:[e.jsxs("span",{"data-loc":"client/src/pages/PublicTracking.tsx:333",className:"text-xl font-bold text-blue-600",children:[g.minutes," min"]}),y&&e.jsx("span",{"data-loc":"client/src/pages/PublicTracking.tsx:335",className:"text-sm text-gray-500",children:y})]})]})}),x&&!g&&e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:344",className:"bg-white border-b shadow-sm",children:e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:345",className:"max-w-2xl mx-auto px-4 py-2 flex items-center justify-end gap-1.5",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:346",className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsxs("span",{"data-loc":"client/src/pages/PublicTracking.tsx:347",className:"text-xs text-gray-600",children:["Updated ",B(x.getTime())]})]})}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:355",className:"relative",style:{height:"50vh"},children:[e.jsx(oe,{"data-loc":"client/src/pages/PublicTracking.tsx:356",className:"w-full h-[50vh]",initialCenter:q,initialZoom:14,onMapReady:_}),!a.driverLocation&&a.status!=="completed"&&e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:365",className:"absolute inset-0 bg-black/30 flex items-center justify-center z-[1000]",children:e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:366",className:"bg-white rounded-xl p-6 mx-4 max-w-sm text-center shadow-xl",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:367",className:"w-14 h-14 mx-auto mb-3 rounded-full bg-blue-100 flex items-center justify-center",children:e.jsx(E,{"data-loc":"client/src/pages/PublicTracking.tsx:368",className:"h-7 w-7 text-blue-600"})}),e.jsx("h3",{"data-loc":"client/src/pages/PublicTracking.tsx:370",className:"font-bold text-gray-900 mb-1",children:"Waiting for Driver"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:371",className:"text-sm text-gray-600",children:"Your driver's location will appear here once they start heading your way. The map updates automatically."})]})}),a.status==="completed"&&e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:381",className:"absolute inset-0 bg-black/30 flex items-center justify-center z-[1000]",children:e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:382",className:"bg-white rounded-xl p-6 mx-4 max-w-sm text-center shadow-xl",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:383",className:"w-14 h-14 mx-auto mb-3 rounded-full bg-green-100 flex items-center justify-center",children:e.jsx("svg",{"data-loc":"client/src/pages/PublicTracking.tsx:384",className:"h-7 w-7 text-green-600",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{"data-loc":"client/src/pages/PublicTracking.tsx:385",strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),e.jsx("h3",{"data-loc":"client/src/pages/PublicTracking.tsx:388",className:"font-bold text-gray-900 mb-1",children:"Trip Completed"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:389",className:"text-sm text-gray-600",children:"Thank y
1ou for riding with Drive4u! We hope you had a great experience."})]})}),x&&g&&e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:398",className:"absolute top-3 right-3 bg-white/90 backdrop-blur-sm rounded-full px-3 py-1.5 shadow-md flex items-center gap-1.5 z-[1000]",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:399",className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"}),e.jsxs("span",{"data-loc":"client/src/pages/PublicTracking.tsx:400",className:"text-xs text-gray-600",children:["Updated ",B(x.getTime())]})]})]}),e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:408",className:"bg-white border-t shadow-lg",children:e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:409",className:"max-w-2xl mx-auto px-4 py-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:411",className:"flex gap-3 mb-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:412",className:"flex flex-col items-center gap-1 pt-1",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:413",className:"w-3 h-3 rounded-full bg-green-500 border-2 border-green-200"}),e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:414",className:"w-0.5 flex-1 bg-gray-200"}),e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:415",className:"w-3 h-3 rounded-full bg-red-500 border-2 border-red-200"})]}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:417",className:"flex-1 min-w-0",children:[e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:418",className:"mb-3",children:[e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:419",className:"text-xs text-gray-500 font-medium uppercase tracking-wide",children:"Pickup"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:420",className:"text-sm text-gray-900 font-medium truncate",children:a.pickupAddress})]}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:422",children:[e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:423",className:"text-xs text-gray-500 font-medium uppercase tracking-wide",children:"Dropoff"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:424",className:"text-sm text-gray-900 font-medium truncate",children:a.dropoffAddress})]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:430",className:"flex gap-4 pt-3 border-t",children:[a.driverName&&e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:432",className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:433",className:"w-9 h-9 rounded-full bg-blue-100 flex items-center justify-center",children:e.jsx(ce,{"data-loc":"client/src/pages/PublicTracking.tsx:434",className:"h-4 w-4 text-blue-600"})}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:436",children:[e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:437",className:"text-xs text-gray-500",children:"Driver"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:438",className:"text-sm font-semibold text-gray-900",children:a.driverName})]})]}),a.vehicleName&&e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:443",className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:444",className:"w-9 h-9 rounded-full bg-gray-100 flex items-center justify-center",children:e.jsx(E,{"data-loc":"client/src/pages/PublicTracking.tsx:445",className:"h-4 w-4 text-gray-600"})}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:447",children:[e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:448",className:"text-xs text-gray-500",children:"Vehicle"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:449",className:"text-sm font-semibold text-gray-900",children:a.vehicleName})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:453",className:"flex items-center gap-2",children:[e.jsx("div",{"data-loc":"client/src/pages/PublicTracking.tsx:454",className:"w-9 h-9 rounded-full bg-gray-100 flex items-center justify-center",children:e.jsx(le,{"data-loc":"client/src/pages/PublicTracking.tsx:455",className:"h-4 w-4 text-gray-600"})}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:457",children:[e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:458",className:"text-xs text-gray-500",children:"Scheduled"}),e.jsx("p",{"data-loc":"client/src/pages/PublicTracking.tsx:459",className:"text-sm font-semibold text-gray-900",children:me(a.scheduledAt)})]})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/PublicTracking.tsx:465",className:"mt-4 pt-3 border-t flex items-center justify-center gap-4",children:[e.jsxs("a",{"data-loc":"client/src/pages/PublicTracking.tsx:466",href:"tel:0408886230",className:"flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-700 font-medium",children:[e.jsx(re,{"data-loc":"client/src/pages/PublicTracking.tsx:470",className:"h-4 w-4"}),"Call Us"]}),e.jsx("span",{"data-loc":"client/src/pages/PublicTracking.tsx:473",className:"text-gray-300",children:"|"}),e.jsxs("a",{"data-loc":"client/src/pages/PublicTracking.tsx:474",href:"mailto:[email protected]",className:"flex items-center gap-1.5 text-sm text-blue-600 hover:text-blue-700 font-medium",children:[e.jsx(ie,{"data-loc":"client/src/pages/PublicTracking.tsx:478",className:"h-4 w-4"}),"Email"]})]})]})})]})}export{Te 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.