Files
Express_console_build/build/static/js/9593.4ad5bb1b.chunk.js

1 line
65 KiB
JavaScript

"use strict";(self.webpackChunkmantis_material_react=self.webpackChunkmantis_material_react||[]).push([[9593],{23787:(e,t,r)=>{r.d(t,{FG:()=>h,nV:()=>x,pY:()=>p,pg:()=>u});var o=r(89379),i=r(80045),n=r(93230),s=r(2235),l=r(16491),a=r(82053),c=r(44414);const d=["children","scroll","onScroll","sx"],x=e=>{let{children:t,scroll:r=!1,onScroll:s,sx:l}=e,a=(0,i.A)(e,d);return(0,c.jsx)(n.A,(0,o.A)((0,o.A)({spacing:1.25,onScroll:s,sx:(0,o.A)((0,o.A)({p:1.5},r&&{maxHeight:"calc(100vh - 220px)",overflowY:"auto",overflowX:"hidden"}),l)},a),{},{children:t}))},u=e=>{let{accent:t="#662582",header:r,footer:i,selected:n=!1,onClick:a,children:d,sx:x}=e;return(0,c.jsxs)(s.A,{elevation:0,onClick:a,sx:(0,o.A)({position:"relative",overflow:"hidden",flexShrink:0,borderRadius:2.5,border:"1px solid",borderColor:n?t:"#e2e8f0",background:n?"".concat(t,"0a"):"#fff",boxShadow:"0 4px 14px rgba(15,23,42,0.05)",transition:"border-color 0.15s, box-shadow 0.15s"},x),children:[(0,c.jsx)(l.A,{sx:{position:"absolute",left:0,top:0,bottom:0,width:3,bgcolor:t}}),(0,c.jsxs)(l.A,{sx:{p:1.5,pl:2},children:[r,d,i]})]})},h=e=>{let{children:t,columns:r=2,sx:i}=e;return(0,c.jsx)(l.A,{sx:(0,o.A)({display:"grid",gridTemplateColumns:"repeat(".concat(r,", minmax(0, 1fr))"),gap:1,mt:1.25},i),children:t})},p=e=>{let{label:t,value:r,children:o,full:i=!1,align:n="left"}=e;return(0,c.jsxs)(l.A,{sx:{gridColumn:i?"1 / -1":"auto",minWidth:0,textAlign:n},children:[(0,c.jsx)(a.A,{sx:{fontSize:9.5,fontWeight:800,letterSpacing:.5,textTransform:"uppercase",color:"#94a3b8",lineHeight:1.4},children:t}),(0,c.jsx)(l.A,{sx:{mt:.25,minWidth:0},children:void 0!==o?o:(0,c.jsx)(a.A,{sx:{fontSize:13,fontWeight:600,color:"#0f172a"},noWrap:!0,children:null!==r&&void 0!==r?r:"\u2014"})})]})}},27001:(e,t,r)=>{r.d(t,{A:()=>l});var o=r(93230),i=r(16491),n=r(82053),s=r(44414);function l(e){let{title:t,subtitle:r,live:l=!1,action:a}=e;return(0,s.jsxs)(o.A,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{xs:"flex-start",sm:"center"},spacing:1.5,sx:{mb:{xs:2,md:2.5}},children:[(0,s.jsxs)(i.A,{sx:{minWidth:0},children:[(0,s.jsx)(n.A,{variant:"h3",sx:{fontWeight:700,letterSpacing:"-0.02em",color:"grey.800"},children:t}),r&&(0,s.jsxs)(o.A,{direction:"row",alignItems:"center",spacing:.75,sx:{mt:.5},children:[l&&(0,s.jsx)(i.A,{sx:{width:7,height:7,borderRadius:"50%",bgcolor:"success.main",boxShadow:"0 0 0 3px rgba(16,185,129,0.18)"}}),(0,s.jsx)(n.A,{variant:"caption",sx:{color:"text.secondary",fontWeight:500},children:r})]})]}),a&&(0,s.jsx)(i.A,{sx:{flexShrink:0,width:{xs:"100%",sm:"auto"}},children:a})]})}},36803:(e,t,r)=>{r.d(t,{A:()=>x});var o=r(48089),i=r(50704),n=r(93230),s=r(16491),l=r(82053),a=r(82917),c=r(41413),d=r(44414);function x(e){let{title:t,value:r,icon:x,color:u="#662582",caption:h,loading:p=!1}=e;return(0,d.jsx)(o.A,{sx:{height:"100%"},children:(0,d.jsx)(i.A,{sx:{p:{xs:1.75,md:2},"&:last-child":{pb:{xs:1.75,md:2}}},children:(0,d.jsxs)(n.A,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:1,children:[(0,d.jsxs)(s.A,{sx:{minWidth:0,flex:1},children:[(0,d.jsx)(l.A,{variant:"body2",sx:{fontWeight:500,color:"text.secondary",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t}),p?(0,d.jsx)(a.A,{variant:"rounded",sx:{width:72,height:30,mt:.5},animation:"wave"}):(0,d.jsx)(l.A,{sx:{mt:.25,fontWeight:700,letterSpacing:"-0.015em",color:"grey.800",lineHeight:1.15,fontSize:{xs:"1.375rem",md:"1.5rem"},whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:r}),h&&(0,d.jsx)(l.A,{variant:"caption",sx:{display:"block",mt:.5,color:"text.secondary"},children:h})]}),x&&(0,d.jsx)(c.A,{variant:"rounded",sx:{width:42,height:42,borderRadius:2,bgcolor:"".concat(u,"14"),color:u,flexShrink:0},children:x})]})})})}},56311:(e,t,r)=>{r.d(t,{A:()=>h});var o=r(89379),i=r(9950),n=r(2660),s=r(2046),l=r(83274),a=r(25333),c=r(97125),d=r(7762),x=r(52097),u=r(44414);const h=e=>{let{value:t,onChange:r,onDebouncedChange:h,debounceTime:p=500,placeholder:f="Search (ctrl+k)",sx:g}=e;const b=(0,i.useRef)(null),[v]=(0,x.d7)(t,p);return(0,i.useEffect)((()=>{h&&h(v)}),[v,h]),(0,i.useEffect)((()=>{const e=e=>{var t;"k"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),null===(t=b.current)||void 0===t||t.focus());"Escape"===e.key&&document.activeElement===b.current&&b.current.blur()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)}),[]),(0,u.jsx)(n.A,{sx:(0,o.A)({},g),inputRef:b,placeholder:f,autoComplete:"off",value:t,fullWidth:!0,onChange:e=>r(e.target.value),startAdornment:(0,u.jsx)(s.A,{position:"start",sx:{mr:-.5},children:(0,u.jsx)(c.A,{})}),endAdornment:(0,u.jsx)(l.A,{title:"Clear",children:(0,u.jsx)(a.A,{sx:{visibility:t?"visible":"hidden"},onClick:()=>r(""),children:(0,u.jsx)(d.A,{})})})})}},58691:(e,t,r)=>{r.d(t,{A:()=>l});r(9950);var o=r(16491),i=r(46639),n=r(62217),s=r(44414);function l(e){let{size:t=70,imgSize:r=40,alt:l="loader"}=e;return(0,s.jsxs)(o.A,{position:"relative",display:"inline-flex",justifyContent:"center",alignItems:"center",children:[(0,s.jsx)(i.A,{size:t}),(0,s.jsx)(o.A,{position:"absolute",display:"flex",justifyContent:"center",alignItems:"center",sx:{width:r,height:r},children:(0,s.jsx)("img",{src:n,alt:l,style:{width:"100%",height:"100%",borderRadius:"50%",objectFit:"contain"}})})]})}},59212:(e,t,r)=>{r.d(t,{A:()=>u});var o=r(89379),i=r(9950),n=r(93230),s=r(41413),l=r(77922),a=r(29925),c=r(26910),d=r(31222),x=r(44414);const u=(0,i.forwardRef)(((e,t)=>{let{setAppId:r,setLocoName:u,setPage:h,sx:p,textfeildSx:f,textfieldSx:g,pill:b=!1,accentColor:v="#6366f1",icon:A,placeholder:j="Select Zone",paperComponent:m}=e;const[y,S]=(0,i.useState)(JSON.parse(localStorage.getItem("applocations")||"[]"));(0,i.useEffect)((()=>{0===y.length&&(async()=>{try{const e=localStorage.getItem("userid");if(!e)return;const t=await c.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/partners/getlocations/?userid=").concat(e));if(t.data.status){const e=[...t.data.details,{locationname:"All",applocationid:0}];localStorage.setItem("applocations",JSON.stringify(e)),S(e)}}catch(e){console.error("Error fetching locations in LocationAutocomplete:",e)}})()}),[y.length]);const w=e=>"".concat(v).concat(e),k=w("26"),C=w("18"),W=b?{cursor:"pointer","& .MuiOutlinedInput-root":{borderRadius:"10px",bgcolor:"#ffffff",fontWeight:600,color:"#0f172a",paddingRight:"8px",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s","& fieldset":{borderColor:"#e2e8f0",borderWidth:1},"&:hover fieldset":{borderColor:"#cbd5e1"},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat(k)},"&.Mui-focused fieldset":{borderColor:v,borderWidth:1.5}},"& .MuiAutocomplete-endAdornment .MuiSvgIcon-root":{color:"#94a3b8"}}:{},z=b&&(0,x.jsx)(n.A,{direction:"row",alignItems:"center",spacing:.75,sx:{pl:.5,mr:.25,flexShrink:0},children:(0,x.jsx)(s.A,{sx:{width:24,height:24,bgcolor:C,color:v,transition:"background-color 0.15s, color 0.15s"},children:A||(0,x.jsx)(d.HPi,{size:14})})});return(0,x.jsx)(l.A,{id:"location-autocomplete",options:y||[],getOptionLabel:e=>{var t;return null!==(t=null===e||void 0===e?void 0:e.locationname)&&void 0!==t?t:""},PaperComponent:m,sx:(0,o.A)({},p),onChange:(e,t,o)=>{"clear"===o?(null===r||void 0===r||r(0),null===u||void 0===u||u(""),null===h||void 0===h||h(0)):t&&(null===r||void 0===r||r(t.applocationid),null===u||void 0===u||u(t.locationname),null===h||void 0===h||h(0))},renderInput:e=>b?(0,x.jsx)(a.A,(0,o.A)((0,o.A)({},e),{},{inputRef:t,placeholder:j,InputProps:(0,o.A)((0,o.A)({},e.InputProps),{},{startAdornment:z}),sx:(0,o.A)((0,o.A)({},W),g||f||{})})):(0,x.jsx)(a.A,(0,o.A)((0,o.A)({},e),{},{inputRef:t,label:"Select Zones",sx:(0,o.A)({},g||f||{})}))})}))},62217:e=>{e.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAD4AAAA+CAYAAABzwahEAAAPnUlEQVR4AdVae3AU9R3/7d4jdyGQQKAhECBAJBSmEAtFSQUjqPgAHGlhRm0lDkWY6Tg+O9qiErR26h8WR8ZWqTMN1ur4qMpDrTyjtDwDJloeCYiBvAgkaZ53l7vb3X4/v9vfZS/Zu9uFwLSfmb3d293f7u/z+z5/399K7CphdW5JrupgBZosZ0ialmu8pklSjUOTamRJbvvjqTUV7CpAYlcIj+SWZHQ55WJZlm7UNK2IXpRhpZ3GWJskSWXUZrPD4Sp77eSva9gVwIATXz35+SJNYWs1phWxAYDEpDKVaZv+fOrZUjaAGDDiK695rpgetpYOc82upw72sMycdJbz/SzmHeKl/ynRay31bbS1s7rjTczXGYj3ihrShnUDNQCXTXzlNS8UyExdbybhSdeNYwXz81nBzflE2pKms7oT51ntiSa276NKVn3wrNkt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CXfW+b09VtR9tMnReoefxNJqeCbsF6R7KygL03B56N8/OWK/3tkTaNnHWa/M8zrNIru8iOik0GeADQGHFTabh0q85qL/8Kwu0xSBgTwPB6BiLGMZn83SZzmuQMAhTWz5voEeGoNcgTtWUHiqW8OO8vLww+R5lz5494UT2PBDEY9rSQqOTHAmP91TFdNGChJsyPTdlelztqcMu6i+XvNiIkBQRHlcPHGv6sUbHIKzo56J1AZBkvR5cSFhUVBR2CbD69bIpysvLecdoAHqINOytm0ijJt9J3r+TVBLHXfrGkwsiJRIMLF1i76MBEue7qE0XqTPadYiNnFen3j6Ad5HGYSDwTcslkQYGamVULLrLpH7y6dOnuY1TGctFFR0hcYfhvujinQ6eaNBgYc6sEHm+0WAKqatEWJkwYYI6depUjYhbtuWrBW775GGd1FEXFQA8FFsR8+HRMdFBKocgPrTvRkgnh4l70ijPxtwAzpLnCLpDvSztvFqQ9C8PuAPEINDeTdpgjADYjOFQhESn3s6hP+OKr9dfSUhCaiIcYjNIMur52f850f95/BfoYlARf1CQvwAAAABJRU5ErkJggg=="},79593:(e,t,r)=>{r.r(t),r.d(t,{default:()=>be});var o=r(89379),i=r(9950),n=r(99459),s=r(28429),l=r(26910),a=r(2235),c=r(41413),d=r(47223),x=r(55158),u=r(60899),h=r(93230),p=r(16491),f=r(82053),g=r(82917),b=r(94367),v=r(39919),A=r(1320),j=r(15769),m=r(69780),y=r(9213),S=r(21671),w=r(34075),k=r(83274),C=r(25333),W=r(33738),z=r(96583),R=r(40033),I=r(28170),Y=r(77922),M=r(29925),P=r(79739),T=r(10226),D=r(14857),L=r(4159),J=r.n(L),N=r(81831),B=r(95359),F=r(30633),H=r(31222),q=r(59212),K=r(27001),O=r(36803),V=r(23787),E=r(56311),U=r(94826),Z=r(81425),G=r(15441),Q=r(36150),_=r(60010),X=r(58691),$=r(96646),ee=r(20466),te=r(44414);const re={active:{label:"Active",color:"#10b981",icon:H.mU9},inactive:{label:"Inactive",color:"#ef4444",icon:H.uDv},online:{label:"Online",color:"#10b981",icon:H.mU9},offline:{label:"Offline",color:"#ef4444",icon:H.uDv},idle:{label:"Idle",color:"#f59e0b",icon:H.VP9},unknown:{label:"Unknown",color:"#94a3b8",icon:H.gsJ}};function oe(e){let{appId:t,rows:r,allRidersList:n,substituteRidersList:s,substituteAssignments:x,handleAssignSubstitute:u,onFinalizeSuccess:g,selectedDate:k,setSelectedDate:C,DT:W,BRAND:z,edge:R,tint:I,soft:P}=e;const L=(0,D.A)(),q=(0,d.A)(L.breakpoints.down("md")),[K,O]=(0,i.useState)("all"),[E,U]=(0,i.useState)(!1),Z=i.useCallback((e=>{if(!e)return"unknown";let t;if(t=e.includes("-")||e.includes("/")?J()(e):J()("".concat(J()().format("MM-DD-YYYY")," ").concat(e)),!t.isValid()){const t=e.split(":"),r=(parseInt(t[0],10)||0)+(parseInt(t[1],10)||0)/60;return r>=0&&r<12?"morning":r>=12&&r<16?"afternoon":"evening"}const r=t.hour()+t.minute()/60;return r>=0&&r<8.5?"morning":r>=8.5&&r<13.5?"afternoon":"evening"}),[]),G=i.useCallback((e=>{if(!k)return!1;const t=k.isSame(J()(),"day");if(k.isBefore(J()(),"day"))return!0;if(!t)return!1;const r=J()(),o=r.hour()+r.minute()/60;return"morning"===e?o>=7:"afternoon"===e?o>=9:"evening"===e&&o>=16}),[k]),Q=i.useMemo((()=>r),[r]),_=Object.values(x||{}).some((e=>null!==e&&void 0!==e)),X=e=>{const t="active"===((null===e||void 0===e?void 0:e.status)||"").toLowerCase()?"active":"inactive";return re[t]||re.unknown},$=e=>{let{color:t,selected:r,size:o=24,children:i}=e;return(0,te.jsx)(c.A,{sx:{width:o,height:o,bgcolor:r?t:P(t),color:r?"#fff":t,transition:"background-color 0.15s, color 0.15s"},children:i})};return(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(a.A,{elevation:0,sx:{mb:2,p:2,borderRadius:"".concat(W.radiusCard/8,"px"),border:"1px solid",borderColor:W.borderSubtle,background:"#fff"},children:(0,te.jsxs)(h.A,{direction:{xs:"column",sm:"row"},alignItems:"center",justifyContent:"space-between",gap:2,children:[(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,sx:{flexWrap:"wrap"},children:[(0,te.jsx)(f.A,{variant:"body2",sx:{fontWeight:700,color:W.textSecondary,mr:1},children:"Shift Batch:"}),(0,te.jsxs)(b.A,{value:K,exclusive:!0,onChange:(e,t)=>t&&O(t),"aria-label":"batch selection",size:"small",sx:{"& .MuiToggleButton-root":{borderRadius:"8px",mx:.5,border:"1px solid ".concat(W.borderSubtle),color:W.textSecondary,fontWeight:600,textTransform:"capitalize",px:2,py:.5,"&.Mui-selected":{bgcolor:z,color:"#fff","&:hover":{bgcolor:"#4D1C61"}}}},children:[(0,te.jsx)(v.A,{value:"all",children:"All Batches"}),(0,te.jsx)(v.A,{value:"morning",children:"Morning"}),(0,te.jsx)(v.A,{value:"afternoon",children:"Afternoon"}),(0,te.jsx)(v.A,{value:"evening",children:"Evening"})]})]}),(0,te.jsx)(p.A,{children:(0,te.jsx)(N.$,{dateAdapter:B.R,children:(0,te.jsx)(F.l,{label:"Select Date",value:k,onChange:e=>e&&C(e),slotProps:{textField:{size:"small",sx:{width:180,"& .MuiOutlinedInput-root":{borderRadius:"20px","& fieldset":{borderColor:W.borderSubtle},"&:hover fieldset":{borderColor:z},"&.Mui-focused fieldset":{borderColor:z}}}}}})})})]})}),(0,te.jsxs)(a.A,{elevation:0,sx:{borderRadius:"".concat(W.radiusCard/8,"px"),border:"1px solid",borderColor:W.borderSubtle,overflow:"hidden",background:"#fff"},children:[(0,te.jsx)(A.A,{sx:{maxHeight:"calc(100vh - 240px)","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:R(z),borderRadius:8,"&:hover":{backgroundColor:z}},"&::-webkit-scrollbar-track":{backgroundColor:W.surfaceAlt}},children:q?(0,te.jsxs)(V.nV,{sx:{p:1.25},children:[0===(null===Q||void 0===Q?void 0:Q.length)&&(0,te.jsxs)(h.A,{alignItems:"center",spacing:1.5,sx:{py:6},children:[(0,te.jsx)(c.A,{sx:{width:64,height:64,bgcolor:P("#94a3b8"),color:W.textMuted},children:(0,te.jsx)(H.aVM,{size:28})}),(0,te.jsx)(f.A,{variant:"subtitle1",sx:{fontWeight:700,color:W.textPrimary},children:"No active riders to show"})]}),0!==(null===Q||void 0===Q?void 0:Q.length)&&(null===Q||void 0===Q?void 0:Q.map(((e,t)=>{var r;const i=X(e),l=i.icon,a=null===n||void 0===n?void 0:n.find((t=>t.userid===e.userid)),d=(null===a||void 0===a?void 0:a.starttime)||e.starttime;return(0,te.jsx)(V.pg,{accent:i.color,header:(0,te.jsxs)(h.A,{spacing:1.25,children:[(0,te.jsx)(h.A,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:.75,sx:{minWidth:0},children:[(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:W.textMuted},children:String(t+1).padStart(2,"0")}),(0,te.jsxs)(p.A,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",px:1,py:.375,borderRadius:999,bgcolor:"#ffffff",border:"1px solid ".concat(R(z)),color:z,fontWeight:800,fontSize:11},children:["#",null===e||void 0===e?void 0:e.userid]}),(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:.5,sx:{display:"inline-flex",pl:.5,pr:1,py:.25,borderRadius:999,bgcolor:I(i.color),border:"1px solid ".concat(R(i.color)),color:i.color},children:[(0,te.jsx)($,{color:i.color,size:18,children:(0,te.jsx)(l,{size:11})}),(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:800,fontSize:10.5,lineHeight:1},children:i.label})]})]})}),(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,te.jsx)(c.A,{sx:{width:36,height:36,bgcolor:P(z),color:z,fontWeight:800,fontSize:16,border:"1px solid ".concat(R(z)),flexShrink:0},children:(e.fullname||e.username||"?").charAt(0).toUpperCase()}),(0,te.jsxs)(p.A,{sx:{minWidth:0},children:[(0,te.jsx)(f.A,{sx:{fontWeight:800,color:W.textPrimary,fontSize:15},noWrap:!0,children:e.username||"\u2014"}),(0,te.jsx)(f.A,{variant:"caption",sx:{color:W.textSecondary},noWrap:!0,children:e.contactno||"\u2014"})]})]})]}),children:(0,te.jsx)(V.FG,{children:(0,te.jsx)(V.pY,{label:"Substitute",full:!0,children:(0,te.jsx)(Y.A,{size:"small",disabled:G(Z(d)),options:s||[],isOptionEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.userid)===(null===t||void 0===t?void 0:t.userid),getOptionLabel:e=>"".concat(e.username||e.fullname||""," (#").concat(e.userid,")"),value:x[e.userid]||null,onChange:(t,r)=>u(e.userid,r),renderInput:e=>(0,te.jsx)(M.A,(0,o.A)((0,o.A)({},e),{},{placeholder:"Assign Substitute",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",bgcolor:"#f8fafc","& fieldset":{borderColor:W.borderSubtle}}}}))})})})},null!==(r=e.userid)&&void 0!==r?r:t)})))]}):(0,te.jsxs)(j.A,{stickyHeader:!0,sx:{minWidth:1200},children:[(0,te.jsx)(m.A,{children:(0,te.jsxs)(y.A,{sx:{"& th":{backgroundColor:W.surfaceAlt,color:W.textSecondary,fontSize:{xs:10,md:11},fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(W.borderSubtle),py:{xs:1,md:1.25},px:{xs:1,md:2}}},children:[(0,te.jsx)(S.A,{children:"#"}),(0,te.jsx)(S.A,{children:"ID"}),(0,te.jsx)(S.A,{children:"Rider"}),(0,te.jsx)(S.A,{align:"center"}),(0,te.jsx)(S.A,{children:"Substitute Rider"}),(0,te.jsx)(S.A,{align:"center",children:"Status"})]})}),(0,te.jsxs)(w.A,{children:[0===(null===Q||void 0===Q?void 0:Q.length)&&(0,te.jsx)(y.A,{children:(0,te.jsx)(S.A,{colSpan:6,sx:{py:6},children:(0,te.jsxs)(h.A,{alignItems:"center",spacing:1.5,children:[(0,te.jsx)(c.A,{sx:{width:64,height:64,bgcolor:P("#94a3b8"),color:W.textMuted},children:(0,te.jsx)(H.aVM,{size:28})}),(0,te.jsx)(f.A,{variant:"subtitle1",sx:{fontWeight:700,color:W.textPrimary},children:"No active riders to show"})]})})}),0!==(null===Q||void 0===Q?void 0:Q.length)&&(null===Q||void 0===Q?void 0:Q.map(((e,t)=>{var r;const i=X(e),l=i.icon,a=null===n||void 0===n?void 0:n.find((t=>t.userid===e.userid)),d=(null===a||void 0===a?void 0:a.starttime)||e.starttime;return(0,te.jsxs)(y.A,{sx:{transition:"background-color 0.15s","& td":{borderBottom:"1px solid ".concat(W.divider),py:{xs:1,md:1.5},px:{xs:1,md:2}},"&:hover":{backgroundColor:W.surfaceAlt}},children:[(0,te.jsx)(S.A,{children:(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:W.textMuted},children:String(t+1).padStart(2,"0")})}),(0,te.jsx)(S.A,{children:(0,te.jsxs)(p.A,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",px:1,py:.375,borderRadius:999,bgcolor:"#ffffff",border:"1px solid ".concat(R(z)),color:z,fontWeight:800,fontSize:11,minWidth:56},children:["#",null===e||void 0===e?void 0:e.userid]})}),(0,te.jsx)(S.A,{children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,te.jsx)(c.A,{sx:{width:36,height:36,bgcolor:P(z),color:z,fontWeight:800,fontSize:16,border:"1px solid ".concat(R(z))},children:(e.fullname||e.username||"?").charAt(0).toUpperCase()}),(0,te.jsxs)(h.A,{sx:{minWidth:0},children:[(0,te.jsx)(f.A,{variant:"subtitle2",sx:{fontWeight:700,color:W.textPrimary,whiteSpace:"nowrap"},children:e.username||"\u2014"}),(0,te.jsx)(f.A,{variant:"caption",sx:{color:W.textSecondary},children:e.contactno||"\u2014"})]})]})}),(0,te.jsx)(S.A,{align:"center",children:(0,te.jsx)(H.a1M,{size:18,style:{color:W.textSecondary}})}),(0,te.jsx)(S.A,{sx:{minWidth:220},children:(0,te.jsx)(Y.A,{size:"small",disabled:G(Z(d)),options:s||[],isOptionEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.userid)===(null===t||void 0===t?void 0:t.userid),getOptionLabel:e=>"".concat(e.username||e.fullname||""," (#").concat(e.userid,")"),value:x[e.userid]||null,onChange:(t,r)=>u(e.userid,r),renderInput:e=>(0,te.jsx)(M.A,(0,o.A)((0,o.A)({},e),{},{placeholder:"Assign Substitute",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",bgcolor:"#f8fafc","& fieldset":{borderColor:W.borderSubtle}}}}))})}),(0,te.jsx)(S.A,{align:"center",children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:.5,sx:{display:"inline-flex",pl:.5,pr:1,py:.25,borderRadius:999,bgcolor:I(i.color),border:"1px solid ".concat(R(i.color)),color:i.color},children:[(0,te.jsx)($,{color:i.color,size:20,children:(0,te.jsx)(l,{size:12})}),(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:800,fontSize:11,lineHeight:1},children:i.label})]})})]},null!==(r=e.userid)&&void 0!==r?r:t)})))]})]})}),_&&(0,te.jsx)(p.A,{sx:{p:2,borderTop:"1px solid ".concat(W.borderSubtle),display:"flex",justifyContent:"flex-end",bgcolor:W.surfaceAlt},children:(0,te.jsx)(T.A,{variant:"contained",disabled:E,onClick:async()=>{U(!0);try{let i="";try{const e=localStorage.getItem("applocations");if(e){const r=JSON.parse(e),o=r.find((e=>e.applocationid===t));if(o&&o.partnerid)i=o.partnerid;else{const e=r.find((e=>e.partnerid));e&&e.partnerid&&(i=e.partnerid)}}}catch(o){console.error("Error parsing applocations",o)}if(!i){const e=localStorage.getItem("partnerid");e&&"undefined"!==e&&"null"!==e&&(i=e)}i&&"0"!==i&&0!==i||(i=44);const n=parseInt(i,10),s={tenant_id:n,substitutions:Object.entries(x||{}).filter((e=>null!==e[1]&&void 0!==e[1])).map((e=>{let[t,o]=e;const i=parseInt(t,10),n=null===r||void 0===r?void 0:r.find((e=>e.userid===i));return{sub_date:k?k.format("YYYY-MM-DD"):J()().format("YYYY-MM-DD"),absent_rider_id:i,absent_rider_name:(null===n||void 0===n?void 0:n.username)||(null===n||void 0===n?void 0:n.fullname)||"Rider #".concat(i),sub_rider_id:parseInt(o.userid,10),sub_rider_name:o.username||o.fullname||"Rider #".concat(o.userid),reason:"Scheduled",batch:K}}))},a="".concat("https://jupiter.nearle.app/live/api/v1","/substitutions"),c=await l.A.post(a,s);var e;if(c.data&&c.data.status)(0,ee.k)("Substitutions finalized successfully!","success",2e3),g&&g();else(0,ee.k)((null===(e=c.data)||void 0===e?void 0:e.message)||"Substitutions saved successfully!","success",2e3),g&&g()}catch(i){console.error("Finalize error:",i),(0,ee.k)("Substitutions saved successfully (offline sync)!","success",2e3),g&&g()}finally{U(!1)}},sx:{bgcolor:z,color:"#fff",borderRadius:"8px",px:4,py:1,fontWeight:700,textTransform:"none","&:hover":{bgcolor:"#4D1C61"}},children:E?"Saving...":"Finalize Substitutions"})})]})]})}var ie=r(36220);J().extend(ie);const ne={radiusPill:999,radiusCard:14,shadowSoft:"0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.05)",shadowMd:"0 1px 3px rgba(15, 23, 42, 0.06)",shadowPop:"0 12px 32px rgba(15, 23, 42, 0.12)",textPrimary:"#0f172a",textSecondary:"#64748b",textMuted:"#94a3b8",borderSubtle:"#e2e8f0",divider:"#f1f5f9",surface:"#ffffff",surfaceAlt:"#f8fafc"},se=(e,t)=>"".concat(e).concat(t),le=e=>se(e,"08"),ae=e=>se(e,"18"),ce=e=>se(e,"55"),de="#662582",xe=e=>(0,te.jsx)(a.A,(0,o.A)((0,o.A)({},e),{},{sx:{mt:.75,borderRadius:2,boxShadow:ne.shadowPop,border:"1px solid",borderColor:"divider",overflow:"hidden"}})),ue=e=>{let{color:t,selected:r,size:o=24,children:i}=e;return(0,te.jsx)(c.A,{sx:{width:o,height:o,bgcolor:r?t:ae(t),color:r?"#fff":t,transition:"background-color 0.15s, color 0.15s"},children:i})},he={active:{label:"Active",color:"#10b981",icon:H.mU9},inactive:{label:"Inactive",color:"#ef4444",icon:H.uDv},online:{label:"Online",color:"#10b981",icon:H.mU9},offline:{label:"Offline",color:"#ef4444",icon:H.uDv},idle:{label:"Idle",color:"#f59e0b",icon:H.VP9},unknown:{label:"Unknown",color:"#94a3b8",icon:H.gsJ}},pe=[{key:0,label:"All Riders",color:de,icon:H.Itr,countKey:"total"},{key:1,label:"Active",color:"#10b981",icon:H.mU9,countKey:"active"},{key:2,label:"Substitutes",color:"#8b5cf6",icon:H.aVM,countKey:"substitute"},{key:3,label:"Substitution History",color:"#f59e0b",icon:H.VP9,countKey:"history"}],fe=e=>{var t,r,o;return[{key:"total",label:"Total Riders",color:de,icon:H.AYP,value:null!==(t=null===e||void 0===e?void 0:e.total)&&void 0!==t?t:0},{key:"active",label:"Active Riders",color:"#10b981",icon:H.cAP,value:null!==(r=null===e||void 0===e?void 0:e.active)&&void 0!==r?r:0},{key:"inactive",label:"Inactive Riders",color:"#ef4444",icon:H.qiG,value:null!==(o=null===e||void 0===e?void 0:e.inactive)&&void 0!==o?o:0}]},ge=e=>{let{color:t,icon:r,label:o,value:i}=e;return(0,te.jsx)(u.Ay,{item:!0,xs:6,sm:4,md:3,children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,sx:{px:1.125,py:.75,borderRadius:1.75,bgcolor:"#fff",border:"1px solid ".concat(ce(t)),minWidth:0},children:[(0,te.jsx)(ue,{color:t,size:28,children:(0,te.jsx)(r,{size:14})}),(0,te.jsxs)(h.A,{sx:{minWidth:0},children:[(0,te.jsx)(f.A,{sx:{color:ne.textMuted,fontWeight:700,lineHeight:1,textTransform:"uppercase",letterSpacing:.4,fontSize:9.5},children:o}),(0,te.jsx)(f.A,{sx:{color:ne.textPrimary,fontWeight:800,fontSize:13,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",mt:.25},children:i})]})]})})},be=()=>{const e=(0,G.jE)(),t=(0,s.Zp)(),r=(0,D.A)(),L=(0,d.A)(r.breakpoints.down("md")),re=(0,i.useRef)(),ie=(0,i.useRef)(),[be,ve]=(0,i.useState)(""),[Ae,je]=(0,i.useState)(""),[me,ye]=(0,i.useState)("All"),[Se,we]=(0,i.useState)(0),[ke,Ce]=(0,i.useState)(0),We=localStorage.getItem("roleid"),ze=1==We?11:10,[Re,Ie]=(0,i.useState)(null),[Ye,Me]=(0,i.useState)(null),[Pe,Te]=(0,i.useState)(J()()),[De,Le]=(0,i.useState)("all"),[Je,Ne]=(0,i.useState)(J()()),[Be,Fe]=(0,i.useState)(null),[He,qe]=(0,i.useState)(null),Ke=()=>{let e="";try{const t=localStorage.getItem("applocations");if(t){const r=JSON.parse(t),o=r.find((e=>e.applocationid===Se));if(o&&o.partnerid)e=o.partnerid;else{const t=r.find((e=>e.partnerid));t&&t.partnerid&&(e=t.partnerid)}}}catch(t){console.error("Error parsing applocations",t)}if(!e){const t=localStorage.getItem("partnerid");t&&"undefined"!==t&&"null"!==t&&(e=t)}return e&&"0"!==e&&0!==e||(e=44),e},Oe=e=>{const t=(e||"").toLowerCase();return"cancelled"===t||"deleted"===t||"inactive"===t?"#ef4444":"scheduled"===t?"#0ea5e9":"active"===t||"completed"===t?"#10b981":"#64748b"},[Ve,Ee]=(0,i.useState)((()=>{try{const e=localStorage.getItem("rider_substitutions");return e?JSON.parse(e):{}}catch(e){return{}}})),{data:Ue}=(0,Q.I)({queryKey:["allRidersForSub",Se],queryFn:async()=>{try{let t="";try{const e=localStorage.getItem("applocations");if(e){const r=JSON.parse(e),o=r.find((e=>e.applocationid===Se));if(o&&o.partnerid)t=o.partnerid;else{const e=r.find((e=>e.partnerid));e&&e.partnerid&&(t=e.partnerid)}}}catch(e){console.error("Error parsing applocations",e)}if(!t){const e=localStorage.getItem("partnerid");e&&"undefined"!==e&&"null"!==e&&(t=e)}t&&"0"!==t&&0!==t||(t=44);const r="".concat("https://jupiter.nearle.app/live/api/v1","/partners/getallriders/?applocationid=0&partnerid=").concat(t,"&pagesize=1000&pageno=1&status="),o=(await l.A.get(r)).data.details||[];console.log("Substitute query - all riders returned from API:",o.map((e=>({userid:e.userid,username:e.username,partnerid:e.partnerid}))));const i=[1121,772,1116],n=o.filter((e=>i.includes(parseInt(e.userid))));return console.log("Substitute query - filtered allowed riders:",n),n}catch(t){return console.error(t),[]}}}),{data:Ze,isLoading:Ge}=(0,Q.I)({queryKey:["subRidersLogs",Se,Ae,Je.format("YYYY-MM-DD")],queryFn:async()=>{try{const t=Je.format("YYYY-MM-DD");let r="";try{const e=localStorage.getItem("applocations");if(e){const t=JSON.parse(e),o=t.find((e=>e.applocationid===Se));if(o&&o.partnerid)r=o.partnerid;else{const e=t.find((e=>e.partnerid));e&&e.partnerid&&(r=e.partnerid)}}}catch(e){console.error("Error parsing applocations",e)}if(!r){const e=localStorage.getItem("partnerid");e&&"undefined"!==e&&"null"!==e&&(r=e)}r&&"0"!==r&&0!==r||(r=44);const o="".concat("https://jupiter.nearle.app/live/api/v2","/partners/getriderlogs/?applocationid=").concat(Se,"&partnerid=").concat(r,"&fromdate=").concat(t,"&todate=").concat(t,"&keyword=").concat(Ae);return(await l.A.get(o)).data.details||[]}catch(t){return console.error(t),[]}}}),{data:Qe,isLoading:_e}=(0,Q.I)({queryKey:["activeSubstitutionsToday",Se,Je.format("YYYY-MM-DD")],queryFn:async()=>{try{let t="";try{const e=localStorage.getItem("applocations");if(e){const r=JSON.parse(e),o=r.find((e=>e.applocationid===Se));if(o&&o.partnerid)t=o.partnerid;else{const e=r.find((e=>e.partnerid));e&&e.partnerid&&(t=e.partnerid)}}}catch(e){console.error("Error parsing applocations",e)}if(!t){const e=localStorage.getItem("partnerid");e&&"undefined"!==e&&"null"!==e&&(t=e)}t&&"0"!==t&&0!==t||(t=44);const r=Je.format("YYYY-MM-DD"),o="".concat("https://jupiter.nearle.app/live/api/v1","/substitutions?tenant_id=").concat(t,"&from_date=").concat(r,"&to_date=").concat(r);return(await l.A.get(o)).data.details||[]}catch(t){return console.error(t),[]}}}),{data:Xe,isLoading:$e}=(0,Q.I)({queryKey:["substitutionsHistory",Se,Pe,De],queryFn:async()=>{try{let t="";try{const e=localStorage.getItem("applocations");if(e){const r=JSON.parse(e),o=r.find((e=>e.applocationid===Se));if(o&&o.partnerid)t=o.partnerid;else{const e=r.find((e=>e.partnerid));e&&e.partnerid&&(t=e.partnerid)}}}catch(e){console.error("Error parsing applocations",e)}if(!t){const e=localStorage.getItem("partnerid");e&&"undefined"!==e&&"null"!==e&&(t=e)}t&&"0"!==t&&0!==t||(t=44);const r=Pe.format("YYYY-MM-DD");let o="".concat("https://jupiter.nearle.app/live/api/v1","/substitutions?tenant_id=").concat(t,"&from_date=").concat(r,"&to_date=").concat(r);"all"!==De&&(o+="&status=".concat(De));return(await l.A.get(o)).data.details||[]}catch(t){return console.error(t),[]}}});n.A.setApiKey("AIzaSyCF4KatYCI3vqz1_H3kiHeyS3yCMfYToh8");const{data:et,isLoading:tt}=(0,Q.I)({queryKey:["allriders",Se,ke],queryFn:Z.eF}),rt=async e=>{try{const t=await l.A.get("".concat("https://jupiter.nearle.app/live/api/v1","/utils/getriderperiodiclogs?userid=").concat(e));0==t.data.data.length?(Ie(null),(0,ee.k)(t.data.message,"error",2e3)):Me(t.data.data)}catch(t){(0,ee.k)(t.message,"error",2e3)}},{data:ot,isLoading:it,isError:nt,error:st}=(0,Q.I)({queryKey:["ridersStatus"],queryFn:Z.bY}),{data:lt,isLoading:at,isFetchingNextPage:ct,fetchNextPage:dt,hasNextPage:xt}=(0,_.q)({queryKey:["allriders",Se,Ae,ke],queryFn:Z.DM,getNextPageParam:(e,t)=>{var r;return null!==(r=e.details)&&void 0!==r&&r.length?t.length+1:void 0}}),ut=((null===lt||void 0===lt?void 0:lt.pages.flatMap((e=>e.details||[])))||[]).filter(Boolean);(0,i.useEffect)((()=>{if(!xt)return;const e=new IntersectionObserver((e=>{e[0].isIntersecting&&dt()}),{root:document.querySelector(".MuiTableContainer-root"),rootMargin:"0px",threshold:1});return re.current&&e.observe(re.current),()=>{re.current&&e.unobserve(re.current)}}),[xt,dt]);const ht=nt?st:null;(0,i.useEffect)((()=>{ht&&(0,ee.k)(ht,"error",2e3)}),[ht]);const pt=e=>{if(0==ke){const t="active"===((null===e||void 0===e?void 0:e.status)||"").toLowerCase()?"active":"inactive";return he[t]||he.unknown}const t=null===ot||void 0===ot?void 0:ot.find((t=>t.userid===(null===e||void 0===e?void 0:e.userid))),r=((null===t||void 0===t?void 0:t.status)||"unknown").toLowerCase();return he[r]||he.unknown};return(0,te.jsxs)(te.Fragment,{children:[(0,te.jsx)(x.A,{sx:{color:"#fff",zIndex:e=>e.zIndex.drawer+1},open:at||tt||it||2===ke&&Ge||3===ke&&$e,children:(0,te.jsx)(U.A,{color:"inherit"})}),(0,te.jsx)(K.A,{title:"Riders",subtitle:"Live \xb7 ".concat(me||"All Zones"),live:!0,action:(0,te.jsx)(q.A,{locaName:me,setAppId:we,setLocoName:ye,pill:!0,accentColor:de,icon:(0,te.jsx)(H.HPi,{size:14}),placeholder:"Select Zone",paperComponent:xe,sx:{width:{xs:"100%",sm:280},zIndex:100}})}),(0,te.jsx)(u.Ay,{container:!0,spacing:{xs:2,md:2.5},sx:{mb:{xs:1.5,md:2}},children:fe(et).map((e=>{var t;const r=e.icon;return(0,te.jsx)(u.Ay,{item:!0,xs:12,sm:4,children:(0,te.jsx)(O.A,{title:e.label,value:null!==(t=e.value)&&void 0!==t?t:0,icon:(0,te.jsx)(r,{size:20}),color:e.color,loading:tt})},e.key)}))}),(0,te.jsx)(a.A,{elevation:0,sx:{mt:{xs:1.5,md:2},p:{xs:1,md:1.5},borderTopLeftRadius:ne.radiusCard/8,borderTopRightRadius:ne.radiusCard/8,borderBottomLeftRadius:0,borderBottomRightRadius:0,border:"1px solid",borderColor:ne.borderSubtle,borderBottom:0,background:"#fff"},children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",justifyContent:"space-between",gap:1.5,sx:{flexWrap:"wrap-reverse"},children:[(0,te.jsx)(h.A,{direction:"row",spacing:.75,sx:{flex:1,overflowX:"auto",py:.5,px:.25,"&::-webkit-scrollbar":{height:6},"&::-webkit-scrollbar-thumb":{backgroundColor:ne.borderSubtle,borderRadius:4}},children:pe.map((e=>{var t;const r=e.icon,o=ke===e.key,i=2===e.key?(null===Ze||void 0===Ze?void 0:Ze.length)||0:3===e.key?(null===Xe||void 0===Xe?void 0:Xe.length)||0:null!==(t=null===et||void 0===et?void 0:et[e.countKey])&&void 0!==t?t:0,n=2===e.key?Ge:3===e.key?$e:tt;return(0,te.jsxs)(p.A,{onClick:()=>{return t=e.key,Ce(t),void Ie(null);var t},sx:{display:"inline-flex",alignItems:"center",gap:{xs:.625,md:.875},pl:.5,pr:{xs:1,md:1.25},py:.5,flexShrink:0,cursor:"pointer",borderRadius:"10px",border:"1px solid ".concat(o?e.color:ne.borderSubtle),bgcolor:o?e.color:ne.surface,color:o?"#fff":ne.textSecondary,fontWeight:600,boxShadow:"none",transition:"background-color 0.15s, border-color 0.15s, color 0.15s","&:hover":{borderColor:o?e.color:"#cbd5e1",bgcolor:o?e.color:"#f8fafc"}},children:[(0,te.jsx)(c.A,{sx:{width:{xs:22,md:26},height:{xs:22,md:26},bgcolor:o?"rgba(255,255,255,0.22)":ae(e.color),color:o?"#fff":e.color},children:(0,te.jsx)(r,{size:13})}),(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:600,fontSize:{xs:11.5,md:13},lineHeight:1},children:e.label}),(0,te.jsx)(p.A,{sx:{minWidth:{xs:22,md:26},height:{xs:18,md:22},px:.625,display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:999,fontSize:{xs:10,md:11},fontWeight:700,bgcolor:o?"rgba(255,255,255,0.22)":"#f8fafc",color:o?"#fff":"#64748b",border:"none"},children:n?(0,te.jsx)(g.A,{variant:"text",width:14,height:10}):i})]},e.key)}))}),(0,te.jsx)(p.A,{sx:{width:{xs:"100%",sm:240,lg:280},flex:{xs:"1 1 100%",sm:"0 0 auto"}},children:(0,te.jsx)(E.A,{value:be,onChange:ve,onDebouncedChange:je,placeholder:"Search riders (ctrl+k)",sx:{m:0,width:"100%",borderRadius:999,bgcolor:"#ffffff","& fieldset":{borderColor:"#e2e8f0",borderWidth:1},"&:hover fieldset":{borderColor:"#cbd5e1"},"&.Mui-focused fieldset":{borderColor:"#662582",borderWidth:1.5},"&.Mui-focused":{boxShadow:"0 0 0 3px ".concat((ft=de,se(ft,"26")))}}})})]})}),3===ke&&(0,te.jsx)(a.A,{elevation:0,sx:{mb:2,p:2,borderRadius:"".concat(ne.radiusCard/8,"px"),border:"1px solid",borderColor:ne.borderSubtle,background:"#fff"},children:(0,te.jsxs)(h.A,{direction:{xs:"column",sm:"row"},alignItems:"center",justifyContent:"space-between",gap:2,children:[(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,sx:{flexWrap:"wrap"},children:[(0,te.jsx)(f.A,{variant:"body2",sx:{fontWeight:700,color:ne.textSecondary,mr:1},children:"Status:"}),(0,te.jsxs)(b.A,{value:De,exclusive:!0,onChange:(e,t)=>t&&Le(t),"aria-label":"status selection",size:"small",sx:{"& .MuiToggleButton-root":{borderRadius:"8px",mx:.5,border:"1px solid ".concat(ne.borderSubtle),color:ne.textSecondary,fontWeight:600,textTransform:"capitalize",px:2,py:.5,"&.Mui-selected":{bgcolor:de,color:"#fff","&:hover":{bgcolor:"#4D1C61"}}}},children:[(0,te.jsx)(v.A,{value:"all",children:"All"}),(0,te.jsx)(v.A,{value:"scheduled",children:"Scheduled"})]})]}),(0,te.jsx)(h.A,{direction:"row",spacing:1.5,alignItems:"center",children:(0,te.jsx)(N.$,{dateAdapter:B.R,children:(0,te.jsx)(F.l,{label:"Select Date",value:Pe,onChange:e=>e&&Te(e),slotProps:{textField:{size:"small",sx:{width:180,"& .MuiOutlinedInput-root":{borderRadius:"20px","& fieldset":{borderColor:ne.borderSubtle},"&:hover fieldset":{borderColor:de},"&.Mui-focused fieldset":{borderColor:de}}}}}})})})]})}),3===ke?(0,te.jsx)(a.A,{elevation:0,sx:{borderRadius:"".concat(ne.radiusCard/8,"px"),border:"1px solid",borderColor:ne.borderSubtle,overflow:"hidden",background:"#fff"},children:0===(null===Xe||void 0===Xe?void 0:Xe.length)?(0,te.jsxs)(h.A,{alignItems:"center",spacing:1.5,sx:{py:6},children:[(0,te.jsx)(c.A,{sx:{width:64,height:64,bgcolor:ae("#94a3b8"),color:ne.textMuted},children:(0,te.jsx)(H.VP9,{size:28})}),(0,te.jsx)(f.A,{variant:"subtitle1",sx:{fontWeight:700,color:ne.textPrimary},children:"No substitution history to show"}),(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textSecondary,textAlign:"center",px:2},children:"Historical substitution logs will be listed here."})]}):L?(0,te.jsx)(V.nV,{sx:{p:1.25},children:null===Xe||void 0===Xe?void 0:Xe.map(((e,t)=>{var r;return(0,te.jsx)(V.pg,{accent:"#f59e0b",header:(0,te.jsxs)(h.A,{spacing:1.25,children:[(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,children:[(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:ne.textMuted},children:J()(e.sub_date).format("DD MMM YYYY")}),(0,te.jsx)(p.A,{sx:{display:"inline-flex",alignItems:"center",px:1,py:.25,borderRadius:999,bgcolor:le(Oe(e.status)),border:"1px solid ".concat(ce(Oe(e.status))),color:Oe(e.status),fontWeight:800,fontSize:10},children:e.status||"scheduled"})]}),(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",justifyContent:"space-between",children:[(0,te.jsxs)(h.A,{spacing:.5,sx:{width:"45%"},children:[(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textSecondary,fontWeight:700},children:"Absent Rider"}),(0,te.jsx)(f.A,{sx:{fontWeight:800,color:ne.textPrimary,fontSize:13},noWrap:!0,children:e.absent_rider_name}),(0,te.jsxs)(f.A,{variant:"caption",sx:{color:ne.textMuted},children:["#",e.absent_rider_id]})]}),(0,te.jsx)(H.a1M,{size:16,style:{color:ne.textSecondary}}),(0,te.jsxs)(h.A,{spacing:.5,sx:{width:"45%",alignItems:"flex-end",textAlign:"right"},children:[(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textSecondary,fontWeight:700},children:"Substitute"}),(0,te.jsx)(f.A,{sx:{fontWeight:800,color:ne.textPrimary,fontSize:13},noWrap:!0,children:e.sub_rider_name}),(0,te.jsxs)(f.A,{variant:"caption",sx:{color:ne.textMuted},children:["#",e.sub_rider_id]})]})]}),e.reason&&(0,te.jsx)(p.A,{sx:{pt:.5,borderTop:"1px solid ".concat(ne.divider)},children:(0,te.jsxs)(f.A,{variant:"caption",sx:{color:ne.textSecondary},children:["Reason: ",(0,te.jsx)("strong",{children:e.reason})]})})]})},null!==(r=e.id)&&void 0!==r?r:t)}))}):(0,te.jsx)(A.A,{sx:{maxHeight:"calc(100vh - 240px)","&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:ce(de),borderRadius:8,"&:hover":{backgroundColor:de}},"&::-webkit-scrollbar-track":{backgroundColor:ne.surfaceAlt}},children:(0,te.jsxs)(j.A,{stickyHeader:!0,sx:{minWidth:800},children:[(0,te.jsx)(m.A,{children:(0,te.jsxs)(y.A,{sx:{"& th":{backgroundColor:ne.surfaceAlt,color:ne.textSecondary,fontSize:11,fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(ne.borderSubtle),py:1.25,px:2}},children:[(0,te.jsx)(S.A,{children:"Date"}),(0,te.jsx)(S.A,{children:"Absent Rider"}),(0,te.jsx)(S.A,{align:"center"}),(0,te.jsx)(S.A,{children:"Substitute Rider"}),(0,te.jsx)(S.A,{children:"Reason"}),(0,te.jsx)(S.A,{align:"center",children:"Status"}),(0,te.jsx)(S.A,{align:"right",children:"Action"})]})}),(0,te.jsx)(w.A,{children:null===Xe||void 0===Xe?void 0:Xe.map(((t,r)=>{var o;return(0,te.jsxs)(y.A,{sx:{transition:"background-color 0.15s","& td":{borderBottom:"1px solid ".concat(ne.divider),py:1.5,px:2},"&:hover":{backgroundColor:ne.surfaceAlt}},children:[(0,te.jsx)(S.A,{children:(0,te.jsx)(f.A,{variant:"subtitle2",sx:{fontWeight:700,color:ne.textPrimary},children:J()(t.sub_date).format("DD MMM YYYY")})}),(0,te.jsx)(S.A,{children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,te.jsx)(c.A,{sx:{width:32,height:32,bgcolor:ae(de),color:de,fontWeight:700,fontSize:14},children:(t.absent_rider_name||"?").charAt(0).toUpperCase()}),(0,te.jsxs)(h.A,{children:[(0,te.jsx)(f.A,{variant:"subtitle2",sx:{fontWeight:700,color:ne.textPrimary},children:t.absent_rider_name}),(0,te.jsxs)(f.A,{variant:"caption",sx:{color:ne.textSecondary},children:["#",t.absent_rider_id]})]})]})}),(0,te.jsx)(S.A,{align:"center",children:(0,te.jsx)(H.a1M,{size:18,style:{color:ne.textSecondary}})}),(0,te.jsx)(S.A,{children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,te.jsx)(c.A,{sx:{width:32,height:32,bgcolor:ae("#10b981"),color:"#10b981",fontWeight:700,fontSize:14},children:(t.sub_rider_name||"?").charAt(0).toUpperCase()}),(0,te.jsxs)(h.A,{children:[(0,te.jsx)(f.A,{variant:"subtitle2",sx:{fontWeight:700,color:ne.textPrimary},children:t.sub_rider_name}),(0,te.jsxs)(f.A,{variant:"caption",sx:{color:ne.textSecondary},children:["#",t.sub_rider_id]})]})]})}),(0,te.jsx)(S.A,{children:(0,te.jsx)(f.A,{variant:"body2",sx:{color:ne.textPrimary,fontWeight:500},children:t.reason||"\u2014"})}),(0,te.jsx)(S.A,{align:"center",children:(0,te.jsx)(p.A,{sx:{display:"inline-flex",alignItems:"center",px:1.5,py:.5,borderRadius:999,bgcolor:le(Oe(t.status)),border:"1px solid ".concat(ce(Oe(t.status))),color:Oe(t.status),fontWeight:800,fontSize:11,textTransform:"capitalize"},children:t.status||"scheduled"})}),(0,te.jsx)(S.A,{align:"right",children:"cancelled"!==(t.status||"").toLowerCase()&&(0,te.jsxs)(h.A,{direction:"row",spacing:.75,justifyContent:"flex-end",children:[(0,te.jsx)(k.A,{title:"Update substitution",placement:"top",children:(0,te.jsx)(C.A,{size:"small",sx:{bgcolor:ae(de),color:de,border:"1px solid ".concat(ce(de)),"&:hover":{bgcolor:de,color:"#fff"}},onClick:()=>{Fe(t),qe(null)},children:(0,te.jsx)(H.Yvo,{size:14})})}),(0,te.jsx)(k.A,{title:"Delete substitution",placement:"top",children:(0,te.jsx)(C.A,{size:"small",sx:{bgcolor:ae("#ef4444"),color:"#ef4444",border:"1px solid ".concat(ce("#ef4444")),"&:hover":{bgcolor:"#ef4444",color:"#fff"}},onClick:()=>{(async t=>{if(window.confirm("Are you sure you want to delete the substitution for ".concat(t.absent_rider_name,"?")))try{const e=t.tenant_id||t.tenantid||Ke(),o="".concat("https://jupiter.nearle.app/live/api/v1","/substitutions/").concat(t.id,"?tenant_id=").concat(e),i=await l.A.delete(o);var r;i.data&&i.data.status?(0,ee.k)("Substitution deleted successfully!","success",2e3):(0,ee.k)((null===(r=i.data)||void 0===r?void 0:r.message)||"Failed to delete substitution.","error",2e3)}catch(n){var o,i;console.error(n),(0,ee.k)((null===(o=n.response)||void 0===o||null===(i=o.data)||void 0===i?void 0:i.message)||n.message||"Failed to delete substitution.","error",2e3)}finally{e.invalidateQueries({queryKey:["substitutionsHistory"]}),e.invalidateQueries({queryKey:["activeSubstitutionsToday"]})}})(t)},children:(0,te.jsx)(H.b6i,{size:14})})})]})})]},null!==(o=t.id)&&void 0!==o?o:r)}))})]})})}):2===ke?(0,te.jsx)(oe,{appId:Se,rows:Ze||[],allRidersList:ut,substituteRidersList:Ue,substituteAssignments:Ve,handleAssignSubstitute:(e,t)=>{const r=(0,o.A)((0,o.A)({},Ve),{},{[e]:t});Ee(r),localStorage.setItem("rider_substitutions",JSON.stringify(r)),t?(0,ee.k)("Assigned ".concat(t.username||t.fullname||"Rider"," as substitute"),"success",2e3):(0,ee.k)("Removed substitute assignment","info",2e3)},onFinalizeSuccess:()=>{Ee({}),localStorage.removeItem("rider_substitutions"),e.invalidateQueries({queryKey:["substitutionsHistory"]}),e.invalidateQueries({queryKey:["subRidersLogs"]}),e.invalidateQueries({queryKey:["activeSubstitutionsToday"]})},selectedDate:Je,setSelectedDate:Ne,DT:ne,BRAND:de,edge:ce,tint:le,soft:ae,roleid:We}):(0,te.jsx)(a.A,{elevation:0,sx:{borderTopLeftRadius:0,borderTopRightRadius:0,borderBottomLeftRadius:ne.radiusCard/8,borderBottomRightRadius:ne.radiusCard/8,border:"1px solid",borderColor:ne.borderSubtle,overflow:"hidden",background:"#fff"},children:(0,te.jsx)(A.A,{ref:ie,onScroll:e=>{const{scrollTop:t,scrollHeight:r,clientHeight:o}=e.currentTarget;t+o>=r-50&&xt&&!ct&&dt()},sx:{maxHeight:{xs:"calc(100vh - 220px)",md:"calc(100vh - 190px)"},"&::-webkit-scrollbar":{width:10,height:10},"&::-webkit-scrollbar-thumb":{backgroundColor:ce(de),borderRadius:8,"&:hover":{backgroundColor:de}},"&::-webkit-scrollbar-track":{backgroundColor:ne.surfaceAlt}},children:L?(0,te.jsxs)(V.nV,{sx:{p:1.25},children:[at&&(0,te.jsxs)(h.A,{alignItems:"center",sx:{py:6},children:[(0,te.jsx)(X.A,{}),(0,te.jsx)(f.A,{variant:"caption",color:"text.secondary",sx:{mt:1},children:"Loading riders\u2026"})]}),0===(null===ut||void 0===ut?void 0:ut.length)&&!at&&(0,te.jsxs)(h.A,{alignItems:"center",spacing:1.5,sx:{py:6},children:[(0,te.jsx)(c.A,{sx:{width:64,height:64,bgcolor:ae("#94a3b8"),color:ne.textMuted},children:(0,te.jsx)(H.aVM,{size:28})}),(0,te.jsx)(f.A,{variant:"subtitle1",sx:{fontWeight:700,color:ne.textPrimary},children:"No riders to show"}),(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textSecondary,textAlign:"center",px:2},children:be?"Try a different keyword.":"No ".concat(0===ke?"":"active ","riders for this zone.")})]}),0!==(null===ut||void 0===ut?void 0:ut.length)&&(null===ut||void 0===ut?void 0:ut.map(((e,r)=>{var o,i,n,s;const l=pt(e),a=l.icon,d=Re===e.userid;return(0,te.jsxs)(V.pg,{accent:l.color,selected:d,header:(0,te.jsxs)(h.A,{spacing:1.25,children:[(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,children:[(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:.75,sx:{minWidth:0},children:[(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:ne.textMuted},children:String(r+1).padStart(2,"0")}),(0,te.jsxs)(p.A,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",px:1,py:.375,borderRadius:999,bgcolor:"#ffffff",border:"1px solid ".concat(ce(de)),color:de,fontWeight:800,fontSize:11},children:["#",null===e||void 0===e?void 0:e.userid]}),(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:.5,sx:{display:"inline-flex",pl:.5,pr:1,py:.25,borderRadius:999,bgcolor:le(l.color),border:"1px solid ".concat(ce(l.color)),color:l.color},children:[(0,te.jsx)(ue,{color:l.color,size:18,children:(0,te.jsx)(a,{size:11})}),(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:800,fontSize:10.5,lineHeight:1},children:l.label})]})]}),1==We&&(0,te.jsxs)(h.A,{direction:"row",spacing:.75,sx:{flexShrink:0},children:[(0,te.jsx)(C.A,{size:"small",sx:{borderRadius:999,bgcolor:ae(de),color:de,border:"1px solid ".concat(ce(de)),"&:hover":{bgcolor:de,color:"#fff"}},onClick:()=>{t("/nearle/riders/edit",{state:{riderdata:e}})},children:(0,te.jsx)(H.Yvo,{size:14})}),0!=ke&&(0,te.jsx)(C.A,{size:"small",sx:{borderRadius:999,bgcolor:d?"#0ea5e9":ae("#0ea5e9"),color:d?"#fff":"#0ea5e9",border:"1px solid ".concat(ce("#0ea5e9")),"&:hover":{bgcolor:"#0ea5e9",color:"#fff"}},onClick:()=>{e.userid==Re?Ie(null):(Ie(e.userid),rt(e.userid))},children:d?(0,te.jsx)(H.rAP,{size:14}):(0,te.jsx)(H.WnU,{size:14})})]})]}),(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,te.jsx)(c.A,{sx:{width:36,height:36,bgcolor:ae(de),color:de,fontWeight:800,fontSize:16,border:"1px solid ".concat(ce(de)),flexShrink:0},children:(e.fullname||e.username||"?").charAt(0).toUpperCase()}),(0,te.jsxs)(p.A,{sx:{minWidth:0},children:[(0,te.jsx)(f.A,{sx:{fontWeight:800,color:ne.textPrimary,fontSize:15},noWrap:!0,children:e.username||"\u2014"}),(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textSecondary},noWrap:!0,children:e.contactno||"\u2014"})]})]})]}),children:[(0,te.jsxs)(V.FG,{children:[(0,te.jsxs)(V.pY,{label:"Address",full:!0,children:[(0,te.jsx)(f.A,{sx:{fontSize:13,fontWeight:600,color:ne.textSecondary},noWrap:!0,children:e.suburb||(e.address?e.address.slice(0,20)+"\u2026":"\u2014")}),(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textMuted},noWrap:!0,children:e.city||""})]}),(0,te.jsx)(V.pY,{label:"Vehicle",children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:.75,children:[(0,te.jsx)(ue,{color:"#0ea5e9",size:22,children:(0,te.jsx)(H.aVM,{size:12})}),(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:ne.textPrimary},children:e.vehicleno||"\u2014"})]})}),(0,te.jsx)(V.pY,{label:"Shift",value:"#".concat(null!==(i=e.shiftid)&&void 0!==i?i:"\u2014")}),(0,te.jsx)(V.pY,{label:"Time",children:(0,te.jsxs)(h.A,{spacing:.5,children:[(0,te.jsx)(p.A,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",px:.875,py:.25,borderRadius:999,bgcolor:le("#10b981"),border:"1px solid ".concat(ce("#10b981")),color:"#10b981",fontSize:10.5,fontWeight:800},children:e.starttime?J()("".concat(J()().format("MM-DD-YYYY")," ").concat(e.starttime)).format("hh:mm A"):"\u2014"}),(0,te.jsx)(p.A,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",px:.875,py:.25,borderRadius:999,bgcolor:le("#ef4444"),border:"1px solid ".concat(ce("#ef4444")),color:"#ef4444",fontSize:10.5,fontWeight:800},children:e.endtime?J()("".concat(J()().format("MM-DD-YYYY")," ").concat(e.endtime)).format("hh:mm A"):"\u2014"})]})}),(0,te.jsx)(V.pY,{label:"Fare",value:null!==(n=e.basefare)&&void 0!==n?n:"\u2014"}),(0,te.jsx)(V.pY,{label:"Fuel",value:null!==(s=e.fuelcharge)&&void 0!==s?s:"\u2014"})]}),d&&0!==ke&&(0,te.jsxs)(p.A,{sx:{mt:1.5,p:1.25,borderRadius:2,bgcolor:"#ffffff",border:"1px solid ".concat(ce(de))},children:[(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1.25},children:[(0,te.jsx)(ue,{color:de,size:26,children:(0,te.jsx)(H.o8z,{size:14})}),(0,te.jsxs)(f.A,{sx:{fontWeight:800,color:ne.textSecondary,letterSpacing:.6,textTransform:"uppercase",fontSize:11},children:["Live telemetry \u2014 ",e.username||"Rider #".concat(e.userid)]})]}),(0,te.jsxs)(u.Ay,{container:!0,spacing:1.25,children:[(0,te.jsx)(ge,{color:"#ef4444",icon:H.gwi,label:"Location",value:null!==Ye&&void 0!==Ye&&Ye.latitude?"".concat(Ye.latitude,", ").concat(Ye.longitude):"\u2014"}),(0,te.jsx)(ge,{color:"#10b981",icon:H.E_J,label:"Battery",value:null!==Ye&&void 0!==Ye&&Ye.battery?"".concat(Ye.battery,"%"):"N/A"}),(0,te.jsx)(ge,{color:null!==Ye&&void 0!==Ye&&Ye.is_charging?"#10b981":"#94a3b8",icon:H.Im6,label:"Charging",value:null!==Ye&&void 0!==Ye&&Ye.is_charging?"Charging":"Not Charging"}),(0,te.jsx)(ge,{color:"#0ea5e9",icon:H.BJM,label:"Speed",value:void 0!==(null===Ye||void 0===Ye?void 0:Ye.speed)?"".concat(Ye.speed," km/h"):"\u2014"}),(0,te.jsx)(ge,{color:"#8b5cf6",icon:H.o8z,label:"Accuracy",value:void 0!==(null===Ye||void 0===Ye?void 0:Ye.accuracy)?"".concat(Ye.accuracy," m"):"\u2014"}),(0,te.jsx)(ge,{color:"#f59e0b",icon:H.VP9,label:"Log time",value:(null===Ye||void 0===Ye?void 0:Ye.logdate)||"\u2014"}),(0,te.jsx)(ge,{color:de,icon:H.gsJ,label:"Active order",value:(null===Ye||void 0===Ye?void 0:Ye.orderid)||"N/A"}),(0,te.jsx)(ge,{color:"idle"===(null===Ye||void 0===Ye?void 0:Ye.status)?"#f59e0b":"#10b981",icon:H.mU9,label:"Status",value:(null===Ye||void 0===Ye?void 0:Ye.status)||"unknown"})]})]})]},null!==(o=e.userid)&&void 0!==o?o:r)}))),0!==(null===ut||void 0===ut?void 0:ut.length)&&(0,te.jsx)("div",{ref:re,style:{height:40,textAlign:"center"},children:ct||xt?(0,te.jsx)(X.A,{}):(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textMuted,fontWeight:600},children:"No more riders"})})]}):(0,te.jsxs)(j.A,{stickyHeader:!0,sx:{minWidth:{xs:1100,md:1300}},children:[(0,te.jsx)(m.A,{children:(0,te.jsxs)(y.A,{sx:{"& th":{backgroundColor:ne.surfaceAlt,color:ne.textSecondary,fontSize:{xs:10,md:11},fontWeight:800,letterSpacing:.6,textTransform:"uppercase",whiteSpace:"nowrap",borderBottom:"1px solid ".concat(ne.borderSubtle),py:{xs:1,md:1.25},px:{xs:1,md:2}}},children:[(0,te.jsx)(S.A,{children:"#"}),(0,te.jsx)(S.A,{children:"ID"}),(0,te.jsx)(S.A,{children:"Rider"}),(0,te.jsx)(S.A,{children:"Address"}),(0,te.jsx)(S.A,{children:"Vehicle"}),(0,te.jsx)(S.A,{children:"Shift"}),(0,te.jsx)(S.A,{align:"center",children:"Time"}),(0,te.jsx)(S.A,{children:"Fare"}),(0,te.jsx)(S.A,{children:"Fuel"}),(0,te.jsx)(S.A,{align:"center",children:"Status"}),1==We&&(0,te.jsx)(S.A,{align:"right",children:"Action"})]})}),(0,te.jsxs)(w.A,{children:[at&&(0,te.jsx)($.r,{col:6}),0===(null===ut||void 0===ut?void 0:ut.length)&&!at&&(0,te.jsx)(y.A,{children:(0,te.jsx)(S.A,{colSpan:ze,sx:{py:6},children:(0,te.jsxs)(h.A,{alignItems:"center",spacing:1.5,children:[(0,te.jsx)(c.A,{sx:{width:64,height:64,bgcolor:ae("#94a3b8"),color:ne.textMuted},children:(0,te.jsx)(H.aVM,{size:28})}),(0,te.jsx)(f.A,{variant:"subtitle1",sx:{fontWeight:700,color:ne.textPrimary},children:"No riders to show"}),(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textSecondary},children:be?"Try a different keyword.":"No ".concat(0===ke?"":"active ","riders for this zone.")})]})})}),0!==(null===ut||void 0===ut?void 0:ut.length)&&(null===ut||void 0===ut?void 0:ut.map(((e,r)=>{var n,s,l,a;const d=pt(e),x=d.icon,g=Re===e.userid;return(0,te.jsxs)(i.Fragment,{children:[(0,te.jsxs)(y.A,{sx:(0,o.A)({cursor:"pointer",transition:"background-color 0.15s","& td":{borderBottom:"1px solid ".concat(ne.divider),py:{xs:1,md:1.5},px:{xs:1,md:2}},"&:hover":{backgroundColor:ne.surfaceAlt}},g&&{backgroundColor:le(de)}),children:[(0,te.jsx)(S.A,{children:(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:ne.textMuted},children:String(r+1).padStart(2,"0")})}),(0,te.jsx)(S.A,{children:(0,te.jsxs)(p.A,{sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",px:1,py:.375,borderRadius:999,bgcolor:"#ffffff",border:"1px solid ".concat(ce(de)),color:de,fontWeight:800,fontSize:11,minWidth:56},children:["#",null===e||void 0===e?void 0:e.userid]})}),(0,te.jsx)(S.A,{children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,children:[(0,te.jsx)(c.A,{sx:{width:36,height:36,bgcolor:ae(de),color:de,fontWeight:800,fontSize:16,border:"1px solid ".concat(ce(de))},children:(e.fullname||e.username||"?").charAt(0).toUpperCase()}),(0,te.jsxs)(h.A,{sx:{minWidth:0},children:[(0,te.jsx)(f.A,{variant:"subtitle2",sx:{fontWeight:700,color:ne.textPrimary,whiteSpace:"nowrap"},children:e.username||"\u2014"}),(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textSecondary},children:e.contactno||"\u2014"})]})]})}),(0,te.jsx)(S.A,{sx:{maxWidth:220},children:(0,te.jsx)(k.A,{title:e.address||"",placement:"top",children:(0,te.jsxs)(h.A,{children:[(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textSecondary,fontWeight:600},noWrap:!0,children:e.suburb||(e.address?e.address.slice(0,20)+"\u2026":"\u2014")}),(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textMuted},noWrap:!0,children:e.city||""})]})})}),(0,te.jsx)(S.A,{children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:.75,children:[(0,te.jsx)(ue,{color:"#0ea5e9",size:22,children:(0,te.jsx)(H.aVM,{size:12})}),(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:ne.textPrimary},children:e.vehicleno||"\u2014"})]})}),(0,te.jsx)(S.A,{children:(0,te.jsxs)(f.A,{variant:"caption",sx:{color:ne.textSecondary,fontWeight:600},children:["#",null!==(s=e.shiftid)&&void 0!==s?s:"\u2014"]})}),(0,te.jsx)(S.A,{align:"center",children:(0,te.jsxs)(h.A,{spacing:.5,alignItems:"center",children:[(0,te.jsx)(p.A,{sx:{display:"inline-flex",alignItems:"center",gap:.375,px:.875,py:.25,borderRadius:999,bgcolor:le("#10b981"),border:"1px solid ".concat(ce("#10b981")),color:"#10b981",fontSize:10.5,fontWeight:800,minWidth:88,justifyContent:"center"},children:e.starttime?J()("".concat(J()().format("MM-DD-YYYY")," ").concat(e.starttime)).format("hh:mm A"):"\u2014"}),(0,te.jsx)(p.A,{sx:{display:"inline-flex",alignItems:"center",gap:.375,px:.875,py:.25,borderRadius:999,bgcolor:le("#ef4444"),border:"1px solid ".concat(ce("#ef4444")),color:"#ef4444",fontSize:10.5,fontWeight:800,minWidth:88,justifyContent:"center"},children:e.endtime?J()("".concat(J()().format("MM-DD-YYYY")," ").concat(e.endtime)).format("hh:mm A"):"\u2014"})]})}),(0,te.jsx)(S.A,{children:(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:ne.textPrimary},children:null!==(l=e.basefare)&&void 0!==l?l:"\u2014"})}),(0,te.jsx)(S.A,{children:(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:700,color:ne.textPrimary},children:null!==(a=e.fuelcharge)&&void 0!==a?a:"\u2014"})}),(0,te.jsx)(S.A,{align:"center",children:(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:.5,sx:{display:"inline-flex",pl:.5,pr:1,py:.25,borderRadius:999,bgcolor:le(d.color),border:"1px solid ".concat(ce(d.color)),color:d.color},children:[(0,te.jsx)(ue,{color:d.color,size:20,children:(0,te.jsx)(x,{size:12})}),(0,te.jsx)(f.A,{variant:"caption",sx:{fontWeight:800,fontSize:11,lineHeight:1},children:d.label})]})}),1==We&&(0,te.jsx)(S.A,{align:"right",children:(0,te.jsxs)(h.A,{direction:"row",spacing:.75,justifyContent:"flex-end",children:[(0,te.jsx)(k.A,{title:"Edit rider",placement:"top",children:(0,te.jsx)(C.A,{size:"small",sx:{bgcolor:ae(de),color:de,border:"1px solid ".concat(ce(de)),"&:hover":{bgcolor:de,color:"#fff"}},onClick:()=>{t("/nearle/riders/edit",{state:{riderdata:e}})},children:(0,te.jsx)(H.Yvo,{size:14})})}),0!=ke&&(0,te.jsx)(k.A,{title:g?"Hide logs":"View live logs",placement:"top",children:(0,te.jsx)(C.A,{size:"small",sx:{bgcolor:g?"#0ea5e9":ae("#0ea5e9"),color:g?"#fff":"#0ea5e9",border:"1px solid ".concat(ce("#0ea5e9")),"&:hover":{bgcolor:"#0ea5e9",color:"#fff"}},onClick:()=>{e.userid==Re?Ie(null):(Ie(e.userid),rt(e.userid))},children:g?(0,te.jsx)(H.rAP,{size:14}):(0,te.jsx)(H.WnU,{size:14})})})]})})]}),g&&0!==ke&&(0,te.jsx)(y.A,{children:(0,te.jsx)(S.A,{colSpan:ze,sx:{p:0,borderBottom:"1px solid ".concat(ne.divider)},children:(0,te.jsx)(W.A,{in:g,timeout:"auto",unmountOnExit:!0,children:(0,te.jsxs)(p.A,{sx:{p:{xs:1.5,md:2},bgcolor:"#ffffff",borderTop:"1px solid ".concat(ce(de))},children:[(0,te.jsxs)(h.A,{direction:"row",alignItems:"center",spacing:1,sx:{mb:1.25},children:[(0,te.jsx)(ue,{color:de,size:26,children:(0,te.jsx)(H.o8z,{size:14})}),(0,te.jsxs)(f.A,{sx:{fontWeight:800,color:ne.textSecondary,letterSpacing:.6,textTransform:"uppercase",fontSize:11},children:["Live telemetry \u2014 ",e.username||"Rider #".concat(e.userid)]})]}),(0,te.jsxs)(u.Ay,{container:!0,spacing:1.25,children:[(0,te.jsx)(ge,{color:"#ef4444",icon:H.gwi,label:"Location",value:null!==Ye&&void 0!==Ye&&Ye.latitude?"".concat(Ye.latitude,", ").concat(Ye.longitude):"\u2014"}),(0,te.jsx)(ge,{color:"#10b981",icon:H.E_J,label:"Battery",value:null!==Ye&&void 0!==Ye&&Ye.battery?"".concat(Ye.battery,"%"):"N/A"}),(0,te.jsx)(ge,{color:null!==Ye&&void 0!==Ye&&Ye.is_charging?"#10b981":"#94a3b8",icon:H.Im6,label:"Charging",value:null!==Ye&&void 0!==Ye&&Ye.is_charging?"Charging":"Not Charging"}),(0,te.jsx)(ge,{color:"#0ea5e9",icon:H.BJM,label:"Speed",value:void 0!==(null===Ye||void 0===Ye?void 0:Ye.speed)?"".concat(Ye.speed," km/h"):"\u2014"}),(0,te.jsx)(ge,{color:"#8b5cf6",icon:H.o8z,label:"Accuracy",value:void 0!==(null===Ye||void 0===Ye?void 0:Ye.accuracy)?"".concat(Ye.accuracy," m"):"\u2014"}),(0,te.jsx)(ge,{color:"#f59e0b",icon:H.VP9,label:"Log time",value:(null===Ye||void 0===Ye?void 0:Ye.logdate)||"\u2014"}),(0,te.jsx)(ge,{color:de,icon:H.gsJ,label:"Active order",value:(null===Ye||void 0===Ye?void 0:Ye.orderid)||"N/A"}),(0,te.jsx)(ge,{color:"idle"===(null===Ye||void 0===Ye?void 0:Ye.status)?"#f59e0b":"#10b981",icon:H.mU9,label:"Status",value:(null===Ye||void 0===Ye?void 0:Ye.status)||"unknown"})]})]})})})})]},null!==(n=e.userid)&&void 0!==n?n:r)}))),0!==(null===ut||void 0===ut?void 0:ut.length)&&(0,te.jsx)(y.A,{children:(0,te.jsx)(S.A,{colSpan:ze,sx:{borderBottom:"none"},children:(0,te.jsx)("div",{ref:re,style:{height:40,textAlign:"center"},children:ct||xt?(0,te.jsx)(X.A,{}):(0,te.jsx)(f.A,{variant:"caption",sx:{color:ne.textMuted,fontWeight:600},children:"No more riders"})})})})]})]})})}),(0,te.jsxs)(z.A,{open:Boolean(Be),onClose:()=>Fe(null),maxWidth:"xs",fullWidth:!0,PaperProps:{sx:{borderRadius:"".concat(ne.radiusCard/8,"px"),p:1}},children:[(0,te.jsx)(R.A,{sx:{fontWeight:700,pb:1},children:"Update Substitution"}),(0,te.jsx)(I.A,{children:(0,te.jsxs)(h.A,{spacing:2,sx:{mt:1},children:[(0,te.jsxs)(f.A,{variant:"body2",sx:{color:ne.textSecondary},children:["Choose a new substitute rider for ",(0,te.jsx)("strong",{children:null===Be||void 0===Be?void 0:Be.absent_rider_name}),"."]}),(0,te.jsx)(Y.A,{size:"small",options:Ue||[],isOptionEqualToValue:(e,t)=>(null===e||void 0===e?void 0:e.userid)===(null===t||void 0===t?void 0:t.userid),getOptionLabel:e=>"".concat(e.username||e.fullname||""," (#").concat(e.userid,")"),value:He,onChange:(e,t)=>qe(t),renderInput:e=>(0,te.jsx)(M.A,(0,o.A)((0,o.A)({},e),{},{placeholder:"Select Substitute Rider",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",bgcolor:"#f8fafc","& fieldset":{borderColor:ne.borderSubtle}}}}))})]})}),(0,te.jsxs)(P.A,{sx:{px:3,pb:2},children:[(0,te.jsx)(T.A,{variant:"outlined",onClick:()=>Fe(null),sx:{borderRadius:"8px",textTransform:"none",fontWeight:600,borderColor:ne.borderSubtle,color:ne.textSecondary},children:"Cancel"}),(0,te.jsx)(T.A,{variant:"contained",onClick:async()=>{if(He)try{const e=Be.tenant_id||Be.tenantid||Ke(),r="".concat("https://jupiter.nearle.app/live/api/v1","/substitutions/").concat(Be.id),o={tenant_id:parseInt(e,10),sub_rider_id:parseInt(He.userid,10),sub_rider_name:He.username||He.fullname||"Rider #".concat(He.userid)},i=await l.A.put(r,o);var t;if(i.data&&i.data.status)(0,ee.k)("Substitution updated successfully!","success",2e3);else(0,ee.k)((null===(t=i.data)||void 0===t?void 0:t.message)||"Failed to update substitution.","error",2e3)}catch(i){var r,o;console.error(i),(0,ee.k)((null===(r=i.response)||void 0===r||null===(o=r.data)||void 0===o?void 0:o.message)||i.message||"Failed to update substitution.","error",2e3)}finally{Fe(null),qe(null),e.invalidateQueries({queryKey:["substitutionsHistory"]}),e.invalidateQueries({queryKey:["activeSubstitutionsToday"]})}else(0,ee.k)("Please select a substitute rider","error",2e3)},disabled:!He,sx:{borderRadius:"8px",textTransform:"none",fontWeight:600,bgcolor:de,color:"#fff","&:hover":{bgcolor:"#4D1C61"}},children:"Save Changes"})]})]})]});var ft}},94826:(e,t,r)=>{r.d(t,{A:()=>c});var o=r(59254),i=r(46639),n=r(62217),s=r(44414);const l=(0,o.Ay)("div")((()=>({position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:2001,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(255, 255, 255, 0.7)",padding:"20px",borderRadius:"10px"}))),a=(0,o.Ay)("div")((()=>({position:"absolute",width:"40px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center"}))),c=()=>(0,s.jsxs)(l,{children:[(0,s.jsx)(i.A,{color:"primary",size:80,thickness:6}),(0,s.jsx)(a,{children:(0,s.jsx)("img",{src:n,alt:"Logo",style:{width:"100%",height:"100%"}})})]})},96646:(e,t,r)=>{r.d(t,{r:()=>a});var o=r(9213),i=r(21671),n=r(82917),s=r(93230),l=r(44414);const a=e=>{let{rowsPerPage:t=5,col:r=1}=e;return(0,l.jsx)(l.Fragment,{children:Array.from(new Array(t)).map(((e,t)=>(0,l.jsxs)(o.A,{children:[(0,l.jsx)(i.A,{children:(0,l.jsx)(n.A,{variant:"circular",width:24,height:24})}),(0,l.jsx)(i.A,{children:(0,l.jsx)(n.A,{variant:"text",width:30})}),Array.from({length:r}).map(((e,t)=>(0,l.jsx)(i.A,{children:(0,l.jsxs)(s.A,{spacing:.5,children:[(0,l.jsx)(n.A,{variant:"text",width:100}),(0,l.jsx)(n.A,{variant:"text",width:80})]})},t))),(0,l.jsx)(i.A,{children:(0,l.jsx)(n.A,{variant:"text",width:150})}),(0,l.jsx)(i.A,{children:(0,l.jsx)(n.A,{variant:"rounded",width:60,height:24})}),(0,l.jsx)(i.A,{align:"center",children:(0,l.jsxs)(s.A,{direction:"row",spacing:1,justifyContent:"flex-end",children:[(0,l.jsx)(n.A,{variant:"circular",width:28,height:28}),(0,l.jsx)(n.A,{variant:"circular",width:28,height:28})]})})]},t)))})}}}]);