1import{r as h,j as t,B as S,b as W,W as U,ax as z,T as Y,A as q,Y as B}from"./vendor-mui-SV2jZBhJ.js";import{u as P,b as C,bQ as H,ac as Q,z as G,bR as K,bS as X,bT as Z,bU as J,bV as tt,bW as et,aD as rt}from"./main-CxZpl-xO.js";import st from"./StationMap-DKWq9F5G.js";import{u as nt}from"./useSubscription-DS1E1V92.js";import"./vendor-mapbox-D8F1hoiy.js";import"./vendor-react-DsHBsgbR.js";import"./vehicleCategoryIcons-Cy4gsWAt.js";function at(e,{duration:s=1e3}={}){const[i,n]=h.useState(e),r=h.useRef(e),u=h.useRef(void 0);return h.useEffect(()=>{if(window.matchMedia("(prefers-reduced-motion: reduce)").matches){n(e);return}const c=r.current,d=e,y=Date.now(),g=()=>{const v=Date.now()-y,f=Math.min(v/s,1),T=1-Math.pow(1-f,3),j=c+(d-c)*T;n(j),f<1?u.current=requestAnimationFrame(g):r.current=e};return u.current=requestAnimationFrame(g),()=>{u.current&&cancelAnimationFrame(u.current)}},[e,s]),i}const it=e=>{const s=new Date;if(e.startDate||e.endDate){const o=e.startDate?new Date(e.startDate):null,c=e.endDate?new Date(e.endDate):null;if(o&&s<o||c&&s>c)return!1}if(e.daysOfWeek&&e.daysOfWeek.length>0){const o=s.getDay(),c=o===0?7:o;if(!e.daysOfWeek.includes(c))return!1}if(e.startTime===e.endTime)return!0;const i=o=>{if(!o)return 0;const c=o.split(":").map(Number),d=c[0]||0,y=c[1]||0,g=c[2]||0;return d*3600+y*60+g},n=s.getHours()*3600+s.getMinutes()*60+s.getSeconds(),r=i(e.startTime),u=i(e.endTime);return u>=r?n>=r&&n<u:n>=r||n<u};function ot({value:e,duration:s}){const i=at(e,{duration:s});return t.jsx(t.Fragment,{children:Math.floor(i).toLocaleString()})}function E({value:e,loading:s,error:i,animate:n}){return s?t.jsx(S,{sx:{display:"inline-flex",alignItems:"center"},children:t.jsx(W,{size:16})}):i||e===null?t.jsx(U,{sx:{fontSize:16,color:"warning.main"}}):typeof e=="string"?t.jsx(t.Fragment,{children:e}):n?t.jsx(ot,{value:e,duration:n.duration}):t.jsx(t.Fragment,{children:e.toLocaleString()})}function k({id:e,title:s,value:i,extra:n,first:r=!1}){return t.jsxs(S,{"data-testid":e,sx:{px:2,pt:1.5,pb:1,mt:0,mb:1},children:[!r&&t.jsx(z,{sx:{mb:1.5}}),i!==null&&s!==null&&t.jsx(Y,{id:e,variant:"caption",color:"text.secondary",sx:{display:"block",mb:.5},children:s}),i!==null&&t.jsx(Y,{variant:"h6",sx:{fontWeight:600,fontSize:"1.25rem"},"aria-labelledby":e,children:i}),n&&t.jsx(Y,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:.5,lineHeight:1.5},children:n})]})}function V(e,s=!0,i=!0){const n=Math.floor(typeof e=="string"?parseInt(e,10):e),r=Math.floor(n/3600),u=Math.floor((n-r*3600)/60),o=n-r*3600-u*60,c=y=>y<10?`0${y}`:`${y}`,d=s?c(u):u;return e===3600?i?"60:00":"60":!i&&!o?`${d}`:`${d}:${c(o)}`}function lt({pollInterval:e=1e4,season:s=!0,now:i=new Date}){var y,g,D,v,f,T,j,b,A,R,_;const{t:n}=P(),{data:r,loading:u,error:o}=C(H,{pollInterval:s?e:void 0,notifyOnNetworkStatusChange:!0}),c={duration:e*.9},d=(x,M)=>x.getFullYear()===M.getFullYear()&&x.getMonth()===M.getMonth()&&x.getDate()===M.getDate();return t.jsxs(t.Fragment,{children:[s&&t.jsx(k,{id:"systemActiveTripCount",title:n("riding_right_now","Riding right now"),value:t.jsx(E,{loading:u,value:((y=r==null?void 0:r.systemActiveTripCount)==null?void 0:y.count)||0,error:o,animate:c}),first:!0}),t.jsx(k,{id:"tripsToday",first:!s,title:n("trips_today","Trips today"),value:s?t.jsx(E,{loading:u,error:o,value:((g=r==null?void 0:r.systemStats)==null?void 0:g.tripsToday)||0,animate:c}):null,extra:t.jsxs(t.Fragment,{children:[s&&t.jsxs(t.Fragment,{children:[(D=r==null?void 0:r.systemStats)!=null&&D.tripsYesterday?n("trips_yesterday","Trips yesterday: {value}",{value:r.systemStats.tripsYesterday.toLocaleString()}):t.jsxs(t.Fragment,{children:[n("trips_yesterday","Trips yesterday: {value}",{value:""}),t.jsx(U,{sx:{fontSize:16,color:"warning.main"}})]}),t.jsx("br",{})]}),(v=r==null?void 0:r.systemStats)!=null&&v.highscoreTrips?n("max_trips_in_one_day","Most trips in one day: {value}",{value:r.systemStats.highscoreTrips.toLocaleString()}):t.jsxs(t.Fragment,{children:[n("max_trips_in_one_day","Most trips in one day: {value}",{value:""}),t.jsx(U,{sx:{fontSize:16,color:"warning.main"}})]}),((f=r==null?void 0:r.systemStats)==null?void 0:f.highscoreUniqueUsersDate)&&d(new Date(r.systemStats.highscoreUniqueUsersDate),i)&&t.jsx("span",{children:" ð"})]})}),t.jsx(k,{id:"uniqueUsersToday",title:n("cyclists_today","Cyclists today"),value:s?t.jsx(E,{loading:u,error:o,value:((T=r==null?void 0:r.systemStats)==null?void 0:T.uniqueUsersToday)||0,animate:c}):null,extra:t.jsx(t.Fragment,{children:(j=r==null?void 0:r.systemStats)!=null&&j.highscoreUniqueUsers?n("max_unique_cyclists_in_one_day","Most cyclists in one day: {value}
1",{value:r.systemStats.highscoreUniqueUsers.toLocaleString()}):t.jsxs(t.Fragment,{children:[n("max_unique_cyclists_in_one_day","Most cyclists in one day: {value}",{value:""}),t.jsx(U,{sx:{fontSize:16,color:"warning.main"}})]})})}),t.jsx(k,{id:"medianTripDuration",title:n("median_trip_duration","Median trip duration"),value:s?t.jsx(E,{loading:u,value:V(((b=r==null?void 0:r.systemStats)==null?void 0:b.medianDurationToday)||-1),error:o}):null,extra:t.jsx(t.Fragment,{children:n("MedianDurationThisSeasonMessage.year","Median trip duration in {startDate, date, year-only}: {median}",{startDate:i,median:V(((A=r==null?void 0:r.systemStats)==null?void 0:A.medianDurationThisYear)||-1)})})}),t.jsx(k,{id:"tripsThisYear",title:t.jsxs(t.Fragment,{children:[n("total_trips","Total trips")," ",i.getFullYear()]}),value:t.jsx(E,{loading:u,value:((R=r==null?void 0:r.systemStats)==null?void 0:R.tripsThisYear)||0,error:o,animate:s?c:void 0}),extra:((_=r==null?void 0:r.systemStats)==null?void 0:_.tripsLastYear)&&r.systemStats.tripsLastYear>0&&t.jsxs(t.Fragment,{children:[n("total_trips","Total trips")," ",i.getFullYear()-1,":"," ",r.systemStats.tripsLastYear.toLocaleString()]})})]})}function ct({view:e,showLiveMap:s}){return e!=="live"?null:t.jsx(S,{sx:{position:"absolute",top:s?176:136,left:16,zIndex:1,backgroundColor:Q.raised,borderRadius:1,boxShadow:2,minWidth:200,maxWidth:300},children:t.jsx(lt,{})})}const ut=G.get("mapboxToken"),mt="mapbox/streets-v11";function dt(e,s,i,n){return`https://api.mapbox.com/styles/v1/${mt}/static/${i}/auto/${e}x${s}?access_token=${n}`}function pt({dockGroups:e,primaryColor:s="#FF6B35"}){const{t:i}=P(),n=s.replace("#",""),r=e.filter(o=>{var c,d;return((c=o.coord)==null?void 0:c.lat)&&((d=o.coord)==null?void 0:d.lng)}).map(o=>`pin-s-bicycle+${n}(${o.coord.lng},${o.coord.lat})`).join(","),u=dt(1200,675,r,ut);return t.jsxs(S,{children:[t.jsx(q,{severity:"warning",sx:{mb:2,mx:2},children:i("StationMap.mapboxIsNotSupported","Your browser does not support the dynamic map, either update your browser or download one of our apps for your phone.")}),t.jsx(S,{component:"img",src:u,alt:i("modules.StationMap.title","Station Map"),sx:{width:"100%",height:"auto",display:"block"}})]})}const w={virtual:!0,physical:!0,hybrid:!0,bike:!0,ebike:!0,ebike_with_childseat:!0,scooter:!0},yt=!rt.supported(),gt="bikes";function _t({view:e=gt,systemId:s,showLiveMap:i}){const n=B(),[r,u]=h.useState(w),[o,c]=h.useState([0,100]);h.useEffect(()=>{u(w),c([0,100])},[e]);const{data:d,loading:y}=C(X,{variables:{systemId:s}}),{data:g,loading:D,error:v}=C(Z,{variables:{systemId:s}}),{data:f,loading:T,error:j}=C(J,{variables:{systemId:s},skip:e!=="live"}),{data:b,loading:A,error:R}=C(tt,{variables:{systemId:s},skip:e!=="live"}),{data:_}=nt(et,{variables:{systemId:s},skip:e!=="live",onData:({data:l})=>{},onError:l=>{console.error("Completed trip subscription error:",l)}}),x=K(),M=h.useMemo(()=>{var l;if((l=d==null?void 0:d.system)!=null&&l.coords)return d.system.coords.filter(a=>a!==null&&a.lat!==null&&a.lat!==void 0&&a.lng!==null&&a.lng!==void 0).map(a=>({lat:a.lat,lng:a.lng}))},[d]),L=h.useMemo(()=>((g==null?void 0:g.dockGroups)||[]).map(a=>{var m,p,F,I,O;return{id:a.id,name:a.name,title:a.title,subTitle:a.subTitle,state:a.state,enabled:a.enabled,coord:a.coord,availabilityInfo:{availableVehicles:((m=a.availabilityInfo)==null?void 0:m.availableVehicles)||0,availableDocks:((p=a.availabilityInfo)==null?void 0:p.availableDocks)||0,availablePhysicalDocks:((F=a.availabilityInfo)==null?void 0:F.availablePhysicalDocks)||0,availableVirtualDocks:((I=a.availabilityInfo)==null?void 0:I.availableVirtualDocks)||0,availableVehicleCategories:((O=a.availabilityInfo)==null?void 0:O.availableVehicleCategories)||[]}}}),[g]),$=h.useMemo(()=>e!=="live"||!(f!=null&&f.freeFloatingVehicles)?[]:f.freeFloatingVehicles.filter(l=>l!==null&&l.available!==!1).map(l=>{var a,m,p,F;return{id:l.id,name:l.name||void 0,number:l.number||void 0,batteryCharge:l.batteryCharge||void 0,maxRange:l.maxRange||void 0,currentRange:l.currentRange||void 0,category:l.category||void 0,available:l.available||void 0,location:(m=(a=l.location)==null?void 0:a.location)!=null&&m.lat&&((F=(p=l.location)==null?void 0:p.location)!=null&&F.lng)?{lat:l.location.location.lat,lng:l.location.location.lng}:void 0}}).filter(l=>l.location),[e,f]),N=h.useMemo(()=>e!=="live"||!(b!=null&&b.areas)?[]:b.areas.filter(a=>!a||!a.configurations?!1:a.configurations.some(m=>(m==null?void 0:m.__typename)!=="AreaTripEnd"||!m.schedules||m.schedules.length===0?!1:m.schedules.some(p=>p?it({startTime:p.startTime,endTime:p.endTime,allHours:p.allHours,startDate:p.startDate,endD
1ate:p.endDate,daysOfWeek:p.daysOfWeek||null}):!1))).filter(a=>a!==null&&a.polygon.length>0).map(a=>({polygon:a.polygon.filter(m=>m!==null&&m.lat!==null&&m.lng!==null).map(m=>({lat:m.lat,lng:m.lng})),fillColor:a.fillColour||void 0,strokeColor:a.strokeColour||void 0})).filter(a=>a.polygon.length>0),[e,b]);return y||D||T||A?t.jsx(S,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",height:"100vh"},children:t.jsx(W,{})}):v||j||R?t.jsx(t.Fragment,{children:"Could not load data"}):L.length?yt?t.jsx(S,{sx:{height:"100vh",width:"100%"},children:t.jsx(pt,{dockGroups:L,primaryColor:n.palette.primary.main})}):t.jsxs(S,{sx:{height:"100vh",width:"100%",position:"relative"},children:[t.jsx(ct,{view:e,showLiveMap:i}),t.jsx(st,{dockGroups:L,systemCoords:M,defaultCenter:x==null?void 0:x.center,defaultZoom:x==null?void 0:x.zoom,view:e,interactive:!0,height:"100vh",showPopups:!0,filters:r,freeFloatingVehicles:$,prohibitedZones:N,batteryChargeFilter:o,completedTrip:e==="live"?_==null?void 0:_.completedTrip:void 0})]}):null}export{_t 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.