PageSourceSearch

https://app.populus.ai/assets/trips-BGiF8rzj.js

js populus.ai collected 2026-10-02 07:52:57 UTC 26,795 bytes, 4 lines download raw bytes

1import{j as s,a3 as Ke,aD as Qe,al as se,C as ie,R as We,a1 as Ze}from"./mui-CRyujWmU.js";import{ai as Ge,e6 as O,B as Xe,b as J,e as Je,f as et,M as re,X as _e,Y as Se,Q as I,g as tt,D as at,a2 as oe,bO as st,h as it,a4 as rt,$ as ot,a1 as Ie,d_ as nt,dZ as lt,bM as ct,aV as ut,b0 as dt,eF as ue,eh as W,an as pt,b1 as Ee,eG as Ve,R as Tt,a6 as mt,a7 as ht,a8 as M,av as Oe,el as Ae,b2 as fe,aa as De,b3 as Re,m as gt,eH as ve,af as de,df as yt,eI as $e,n as _t,ak as pe,aj as St,a$ as Ye,aW as Ne,bN as It,a0 as Et,dS as Z,ag as be,ec as Pe,eb as Ot,eJ as At,aY as Le,a_ as ft,a3 as U,dX as Dt,dW as Rt,e2 as ne,ax as xe,u as vt,eK as Nt,A as bt,H as Pt}from"./index-CBD5-_qU.js";import{a as m,i as w,u as ee,T as V}from"./i18n-CrChlQ3C.js";import{M as Lt,L as xt}from"./index-Dm85aOyr.js";import{M as jt}from"./MapControls-CZphoUpg.js";import{f as Mt,l as Ht,d as B,O as le,e as je,g as Ct,h as wt,i as Me,j as He,k as Ft,H as ce,C as Gt,b as Vt,a as $t,c as Yt}from"./constants-DOW-9jRh.js";import{d as ke}from"./mapbox-DcfCBP9A.js";import{D as $}from"./luxon-BTv6mZXg.js";import{D as kt}from"./index-3ya67o7n.js";import{a as z,g as Ut}from"./index-BBOWU80w.js";import{L as qt}from"./LayersFilter-BGv5vYI3.js";import{T as N}from"./TableElements-Wn8oHmGj.js";import{S as Bt}from"./ShowMoreButton-D9lNAbmL.js";import"./lodash-DJSDE-aZ.js";import"./firebase-UnDNm1mk.js";import"./react-COpKS55S.js";import"./GeocoderControl-B9-QWZ0E.js";import"./Close-BHX07PHX.js";import"./index-DZboSW1s.js";import"./ArrowDropDown-Bvw_O5fU.js";import"./ComponentWithPermission-B800nYG8.js";const K="heatmap-layer",G="heatmap-circle-layer",Q="heatmap-source";function zt(e,t,a){Object.entries(a).forEach(([r,o])=>e.setPaintProperty(t,r,o))}const Kt=({map:e,heatmapConfig:t})=>{const{data:a}=Ge(),{eventsGeojson:r,isVisible:o}=t,l=a?.organizationSettings.disaggregatedData?Mt:Ht;return m.useEffect(()=>{const c=e?.getSource(Q);c&&c.setData(r)},[e,r]),m.useEffect(()=>{e?.getLayer(K)&&(e.setLayoutProperty(K,"visibility",o?"visible":"none"),e.moveLayer(K)),e?.getLayer(G)&&(e.setLayoutProperty(G,"visibility",o?"visible":"none"),e.moveLayer(G))},[e,o]),m.useEffect(()=>{e&&(e.addSource(Q,{type:"geojson",data:r}),e.addLayer({id:K,type:"heatmap",source:Q,maxzoom:l,minzoom:B,layout:{visibility:o?"visible":"none"},paint:{"heatmap-radius":["interpolate",["linear"],["zoom"],B,Ct,l,wt],"heatmap-opacity":["interpolate",["linear"],["zoom"],B,le,B+1,je,l-1,je,l,le],"heatmap-color":["interpolate",["linear"],["heatmap-density"],...O.flatMap(Me,(c,i)=>[He+(Ft-He)/(Me.length-1)*i,c])]}}),a?.organizationSettings.disaggregatedData&&e.addLayer({id:G,type:"circle",source:Q,minzoom:ce,layout:{visibility:o?"visible":"none"},paint:{"circle-radius":Yt,"circle-color":t.circleColor,"circle-stroke-color":$t,"circle-stroke-width":Vt,"circle-opacity":{stops:[[ce,le],[ce+1,Gt]]}}}))},[e]),m.useEffect(()=>{e?.getLayer(G)&&zt(e,G,{"circle-color":t.circleColor})},[t.circleColor]),null},Ue={id:"",url:"",paint:{"fill-color":"rgb(255,255,255)","fill-opacity":.1,"fill-extrusion-color":"rgb(255,255,255)","fill-extrusion-opacity":.1,"fill-extrusion-height":0,"circle-color":"rgb(255,255,255)","circle-opacity":.1,"circle-radius":1}},Ce="choropleth-map",Qt=({sourceName:e,sourceLayerName:t,tileSource:a})=>s.jsxs(ot,{id:e,type:"vector",tiles:[a.url],promoteId:"shape_uuid",children:[s.jsx(Ie,{id:"shapes",type:"fill","source-layer":t,paint:{"fill-color":a.paint["fill-color"],"fill-opacity":a.paint["fill-opacity"]}},`shapes-${a.id}`),s.jsx(Ie,{id:"shapes-border",type:"line","source-layer":t,paint:{"line-color":ct,"line-width":lt,"line-opacity":nt}},`shapes-border-${a.id}`)]}),Wt=({getFeaturePopupContent:e,ready:t,legendBins:a,legendTitle:r,onMapLoaded:o,tileSource:l=Ue,heatmapConfig:c,children:i})=>{const[p,y]=m.useState(!0),[S,u]=m.useState(Xe.REGULAR),{data:{isMetric:_,lat:h,lon:d,mapZoom:E}}=J(),{[Ce]:g}=Je(),f="source-shapes",b="default",H="shapes",P=[{sourceId:f,sourceLayer:b}];m.useEffect(()=>{window.Cypress&&(window._choroplethMap=g?.getMap())},[g]);const{featureState:R,updateFeatureStateFromMouseEvent:L}=et({map:g,sources:P,featureStateKey:re.HOVERED}),{featureState:x}=_e({map:g,sources:P,featureStateKey:re.HOVERED,queryParamKey:I.HOVERED_SHAPE,idPropertyKeyOnFeature:"shape_uuid",fetchFeatureLngLat:m.useCallback(Se,[])}),{featureState:v,updateFeatureStateFromMouseEvent:D}=_e({map:g,sources:P,featureStateKey:re.SELECTED,queryParamKey:I.SELECTED_SHAPE,idPropertyKeyOnFeature:"shape_uuid",fetchFeatureLngLat:m.useCallback(Se,[])});return s.jsxs("div",{style:{height:"100%",position:"absolute",left:0,right:0},children:[s.jsxs(tt,{id:Ce,...at,mapStyle:`mapbox://styles/${S}`,cursor:R?"pointer":"grab",initialViewState:{longitude:d,latitude:h,zoom:E},onLoad:()=>{o&&o(),y(!1)},interactiveLayerIds:[H],onClick:D,onMouseMove:L,onMouseLeave:L,onMouseOut:L,locale:it(),children:[l.url&&s.jsx(Qt,{sourceName:f,sourceLayerName:b,tileSource:l}),e&&v&&s.jsx(oe,{longitude:v.lngLat.lng,latitude:v.lngLat.lat,closeButton:!1,closeOnClick:!1,children:e(v.id,v.properties)}),e&&R&&R.id!==v?.id&&s.jsx(oe,{longitude:R.lngLat.lng,latitude:R.lngLat.lat,closeButton:!1,closeOnClick:!1,children:e(R.id,R.properties)}),e&&x&&x.id!==v?.id&&s.jsx(oe,{longitude:x.lngLat.lng,latitude:x.lngLat.lat,closeButton:!1,closeOnClick:!1,children:e(x.id,x.properties)}),s.jsx(jt,{onStyleChange:u,geocoderProps:{proximity:{latitude:h,longitude:d}},isMetric:_,children:i}),s.jsx(Lt,{title:r,bins:a,legendStyle:xt.CONTINUOUS,loading:!t,opacity:st})]}),(p||!t)&&s.jsx(rt,{}),c&&g&&!p&&s.jsx(Kt,{map:g.getMap(),heatmapConfig:c}
1)]})};class n{static asMap={};static asArray=[];static fromValue(t){return n.asMap[t]}static values=()=>n.asArray;static byMode=t=>n.values().filter(a=>a.mode===t);static TRIPS_ORIGINS=new n({mode:"trips",id:"origins",geojsonAttribute:"orig",title:"Trip Origins",legendTitle:"Trips",statTitle:"Trip Origins",tableHeader:"Trip Origins",requiresLayerIntersect:!1,supportsHourFilters:!0});static TRIPS_DESTINATIONS=new n({mode:"trips",id:"destinations",geojsonAttribute:"dest",title:"Trip Destinations",legendTitle:"Trips",statTitle:"Trip Destinations",tableHeader:"Destination",requiresLayerIntersect:!1,supportsHourFilters:!0});static TRIPS_DAILY_ORIGINS=new n({mode:"trips",id:"daily_origins",geojsonAttribute:"daily_orig",title:"Daily Origins",legendTitle:"Trips",statTitle:"Daily Origins",tableHeader:"Origins",requiresLayerIntersect:!1,supportsHourFilters:!0});static TRIPS_DAILY_DESTINATIONS=new n({mode:"trips",id:"daily_destinations",geojsonAttribute:"daily_dest",title:"Daily Destinations",legendTitle:"Trips",statTitle:"Daily Destinations",tableHeader:"Destination",requiresLayerIntersect:!1,supportsHourFilters:!0});static TRIPS_ALL_INTERSECTING=new n({mode:"trips",id:"intersect",geojsonAttribute:"intersect",title:"All Intersecting Trips",legendTitle:"Trips",statTitle:"Intersecting Trips",tableHeader:"Destination",requiresLayerIntersect:!0,supportsHourFilters:!0});static TRIPS_ORIGIN_OR_DESTINATION=new n({mode:"trips",id:"orig_or_dest",geojsonAttribute:"orig_or_dest_single",title:"Trip Origin Or Trip Destination",legendTitle:"Trips",statTitle:"Trip Origins Or Trip Destinations",tableHeader:"Destination",requiresLayerIntersect:!1,supportsHourFilters:!0});static TRIPS_AVERAGE_ORIGIN_DISTANCE=new n({mode:"trips",id:"average_origin_distance",geojsonAttribute:"average_distance",title:"Average Origin Distance",legendTitle:"Distance ({{units}})",statTitle:"Average Origin Distance ({{units}})",tableHeader:"Average Distance ({{units}})",requiresLayerIntersect:!1,supportsHourFilters:!1});static TRIPS_AVERAGE_DESTINATION_DISTANCE=new n({mode:"trips",id:"average_destination_distance",geojsonAttribute:"average_distance",title:"Average Destination Distance",legendTitle:"Distance ({{units}})",statTitle:"Distance ({{units}})",tableHeader:"Average Distance ({{units}})",requiresLayerIntersect:!1,supportsHourFilters:!1});mode;id;geojsonAttribute;_title;_legendTitle;_statTitle;_tableHeader;requiresLayerIntersect;supportsHourFilters;constructor(t){this.id=t.id,this.geojsonAttribute=t.geojsonAttribute,this._title=t.title,this._legendTitle=t.legendTitle,this._statTitle=t.statTitle,this._tableHeader=t.tableHeader,this.mode=t.mode,this.requiresLayerIntersect=t.requiresLayerIntersect,this.supportsHourFilters=t.supportsHourFilters,n.asArray.push(this),n.asMap[this.id]=this}get title(){return w.t(`evaluationMap.aggregationOption_${this.id}`,this._title)}legendTitle(t){return w.t(`evaluationMap.legendTitle_${this.id}`,this._legendTitle,{units:t})}statTitle(t){return w.t(`evaluationMap.statTitle_${this.id}`,this._statTitle,{units:t})}tableHeader(t){return w.t(`evaluationMap.tableHeader_${this.id}`,this._tableHeader,{units:t})}get isDistance(){return this.id.includes("distance")}get isDuration(){return this.id.includes("duration")}get isAverage(){return this.id.includes("average")}}const we="rgb(255, 255, 255)",Zt=e=>{const t={start_date:e.dateRange.start?.toISODate(),end_date:e.dateRange.end?.toISODate(),vehicle_types:e.vehicleTypes,operators:e.operators,shape_layer_uuid:e.activeLayerUUID,buffer:e.bufferSize,agg:e.aggregation.isDistance?"average_distance":"total_count"};switch(e.aggregation){case n.TRIPS_ORIGINS:case n.TRIPS_DAILY_ORIGINS:case n.TRIPS_AVERAGE_ORIGIN_DISTANCE:t.direction="orig";break;case n.TRIPS_DESTINATIONS:case n.TRIPS_DAILY_DESTINATIONS:case n.TRIPS_AVERAGE_DESTINATION_DISTANCE:t.direction="dest";break;default:t.direction=e.aggregation.id;break}return e.hourFiltersEnabled&&(t.hour_filters=[e.hourFilters[0],e.hourFilters[1]-1]),e.shapeFilterName&&(t.shape_filter=e.selectedShape),t},Xt=(e,t,a,r)=>{const o={};return O.forOwn(e,(l,c)=>{const i={...l};t.isDistance?i.average_distance=ut(i.orig??i.dest,a):(i.daily_orig=(i.orig??0)/r,i.daily_dest=(i.dest??0)/r),o[c]=i}),o},Jt=(e,t)=>({totalCount:O(e).map(t).filter(a=>!O.isNaN(a)).sum(),totalQueryCount:O(e).omit("NOT_IN_SHAPE").map(t).filter(a=>!O.isNaN(a)).sum()}),ea=(e,t)=>{const a=O(e).filter((r,o)=>o!=="NOT_IN_SHAPE").map(t).value();return a.sort((r,o)=>r-o),a},ta=(e,t,a,r)=>{let o;return e===n.TRIPS_ORIGINS&&t||e===n.TRIPS_DESTINATIONS&&!t||e===n.TRIPS_DAILY_ORIGINS&&t||e===n.TRIPS_DAILY_DESTINATIONS&&!t||e===n.TRIPS_AVERAGE_DESTINATION_DISTANCE?o=Ee.YELLOW_TO_RED_7_BINS:o=Ee.YELLOW_TO_BLUE_7_BINS,new dt(o,r)},aa=(e,t,a)=>O.isEmpty(t)?[]:e.bins.map(r=>({value:typeof r.value=="number"?a?ue(r.value):W(r.value):r.value,displayMin:r.displayMin,displayMax:r.displayMax,decimals:r.decimals,color:r.color})),Te=(e,t,a,r)=>{if(!e||!e[t?.toString()])return{value:0,percent:0};const o=e[t.toString()][a];return{value:o,percent:r?O.round(o/r*100,1):NaN}},sa=(e,t,a,r,o)=>ke(e.map(l=>{const c=l.properties.id,i=Te(t,c,a.geojsonAttribute,o);return{type:"Feature",geometry:l.geometry,properties:{id:c,shape_id:c,...i,color:r.getMapColor(i.value),name:l.properties.name}}})),ia=(e,t,a,r)=>{let o=we;return e&&(o=["match",["get","shape_uuid"]],O.forOwn(e,(l,c)=>{const i=Te(e,c,a.geojsonAttribute,r),p=t.getMapColor(i.value);Array.isArray(o)&&o.push(c,p)}),o.push(we)),{color:o}},ra=e=>e?Object.keys(e).length-1:0,oa=(e,t)=>!t||!e?0:Math.ceil(t/e*100),na=(e,t,a)=>e&&t&&a?pt(t/a,2):void 0,la=(e,t)=>n.byMode(e).filter(a=>!a.requiresLayerIntersect||t),ca=e=>{switch(e){case n.TRIPS_ORIGINS:case n.TRIPS_DAILY_ORIGINS:return"origin";case n.TRIPS_DESTINATIONS:case n.TRIPS_DAILY_DESTINATIONS:return"destination";default:return}},ua=(e,t,a,r)=>{const o={[n.TRIPS_ORIGINS.id]:n.TRIPS_DESTINATIONS.id,[n.TRIPS_DESTINATIONS.id]:n.TRIPS_ORIGINS.id,[n.TRIPS_DAILY_ORIGINS.id]:n.TRIPS_DAILY_DESTINATIONS.id,[n.TRIPS_DAILY_DESTINATIONS.id]:n.TRIPS_DAILY_ORIGINS.id},l=t&&e.id in o?o[e.id]:e.id;return O.find(r,c=>c.id===l)?.title},da=(e,t)=>{switch(e){case n.TRIPS_ORIGINS:case n.TRIPS_DAILY_ORIGINS:case n.TRIPS_ORIGIN_OR_DESTINATION:case n.TRIPS_AVERAGE_ORIGIN_DISTANCE:return"origin";default:return"destination"}},pa=(e,t)=>{const a={...e};return Object.entries(t).forEach(([r,o])=>{a[r]&&(a[r]={...a[r],pct_nonwhite:o.pctNonwhite,median_income:o.medianIncome})}),a},Ta=e=>({eventName:"Evaluation Map",header:`geography=${e.layerName},total count=${e.totalCount},operator=${e.operators},vehicle type=${e.vehicleTypes},buffer=${e.bufferSize}m`}),X=e=>{const t=n.byMode(e).map(p=>p.id),a=Ve().map(({value:p})=>p),{data:r}
1=Tt(),o=mt(ht({[I.AGGREGATION]:M(Re(t),t?.[0]),[I.END_DATE]:M(De,$.now().toJSDate()),[I.END_TIME_HOUR]:M(fe,24),[I.SHAPE_LAYER]:M(Re(a),a?.[0]),[I.OPERATORS]:M(Ae,[]),[I.START_DATE]:M(De,$.now().minus({months:3}).toJSDate()),[I.START_TIME_HOUR]:M(fe,0),[I.VEHICLE_TYPES]:M(Ae,[]),[I.SELECTED_SHAPE]:M(Oe,void 0),[I.HOVERED_SHAPE]:M(Oe,void 0)})),[{aggregation:l,shapeLayer:c},i]=o;return m.useEffect(()=>{const p=r?.items.find(S=>S.shapeLayerUuid===c),y={};n.fromValue(l)?.requiresLayerIntersect&&!p?.intersectRoute&&(y[I.AGGREGATION]=void 0),Object.values(y).length&&i(y)},[l,c,r]),o},ma=e=>(e??[]).map(t=>({type:"Feature",geometry:t.geom,id:t.shape_uuid,properties:{id:t.shape_uuid,name:t.shape_name,shape_uuid:t.shape_uuid,shape_id:t.shape_id,shape_name:t.shape_name}})),ha=e=>{switch(e){case"origin":return w.t("evaluationMap.tripOriginHeatmapTitle","Trip Origins");case"destination":default:return w.t("evaluationMap.tripDestinationHeatmapTitle","Trip Destinations")}},ga=(e,t=!1)=>{const{data:{regionId:a}}=J();return de({queryKey:[`/regions/${a}/layers/${e}/census`],queryFn:async()=>await _t.layers.getCensusDataForShapeLayer({regionId:a,shapeLayerUuid:e}),enabled:t&&!!e})},me=()=>{const{data:{regionId:e,isMetric:t}}=J(),[{aggregation:a,startDate:r,endDate:o,startTimeHour:l,endTimeHour:c,shapeLayer:i,operators:p,vehicleTypes:y,selectedShape:S}]=X("trips"),u=n.fromValue(a)??n.TRIPS_ORIGINS,{data:_}=gt(i);let h=ve(r).startOf("day"),d=ve(o).startOf("day");h>d&&([h,d]=[d,h]);const E=d.diff(h,"days").days+1,g=!!_?.hourlyProcessing?.includes("trips"),f=u.supportsHourFilters&&!(u.mode==="trips"&&!g),b=ca(u),H=!0,P=da(u),R=m.useMemo(()=>Zt({dateRange:{start:h,end:d},vehicleTypes:y,operators:p,activeLayerUUID:i,aggregation:u,hourFiltersEnabled:f,hourFilters:[l,c],shapeFilterName:b,selectedShape:S}),[h.toISO(),d.toISO(),y,p,i,u,f,l,c,b,S]),L=de({queryKey:["/trips/spatial",R],queryFn:async()=>await pe("/trips/spatial",R,{reject:!0}),enabled:!!i}),x=_?.layerSlug==="tracts",{data:v}=ga(i,x&&L.isSuccess),D=m.useMemo(()=>{const ge=L.data?.shape_data;if(!ge)return;const ye=Xt(ge,u,t,E);return v?pa(ye,v):ye},[L.data,v,u,t,E]),{totalCount:F,totalQueryCount:j}=m.useMemo(()=>Jt(D,u.geojsonAttribute),[D,u]),Y=yt(i),T=m.useMemo(()=>ma(Y.data),[Y.data]),A=m.useMemo(()=>ta(u,S,"trips",ea(D,u.geojsonAttribute)),[u,S,D]),k=m.useMemo(()=>aa(A,D,u.isDistance),[A,D,u]),te=m.useMemo(()=>ia(D,A,u,j),[D,A,u,j]),C=m.useMemo(()=>sa(T,D,u,A,j),[T,D,u,A,j]),q=m.useMemo(()=>la("trips",!!_?.intersectRoute),[_]),he=ra(D),ae=u.isDistance?$e(t):void 0;return{regionId:e,aggregation:u,aggregationOptions:q,layer:_,activeLayerUUID:i,selectedShape:S,dateRange:{start:h,end:d},shapeData:D,features:T,geojson:C,scale:A,legendBins:k,matchExpressions:te,payload:R,totalCount:F,totalQueryCount:j,queryDataCount:he,queryPercent:oa(F,j),queryAverage:na(F,j,he),hourFiltersEnabled:f,shapeFilterName:b,hasTripsHeatmap:H,tripsHeatmapType:P,aggregationFilterText:ua(u,S,"trips",q),legendTitle:u.legendTitle(ae),statTitle:u.statTitle(ae),statCaption:` ${u.statTitle(ae)}`,mapTitle:w.t("evaluationMap.tripsMap","Trips Map"),heatmapTitle:ha(P),csvDownloadOptions:Ta({layerName:_?.layerName,totalCount:F,operators:p,vehicleTypes:y,bufferSize:void 0}),isMetric:t,ready:!!i&&L.isSuccess&&!L.isFetching,layerIsLoading:Y.isFetching}},ya=e=>ke((e??[]).map(t=>({type:"Feature",geometry:{type:"Point",coordinates:[t.lon,t.lat]},properties:{}}))),qe=(e,t)=>{const{data:{regionId:a}}=J(),r="/trips/most_recent_10k",o=de({queryKey:[a,r,e],queryFn:async()=>{const{data:c}=await pe(r,{location:e??"origin"});return c},enabled:t&&!!e}),l=m.useMemo(()=>ya(o.data),[o.data]);return{events:o.data,eventsGeojson:l,isReady:!t||!o.isFetching}},Be=m.createContext(null),ze=()=>{const e=m.useContext(Be);if(!e)throw new Error("useTripsHeatmapVisibility must be used within a TripsHeatmapProvider");return e};function _a({featureId:e,geojson:t,shapeData:a,aggregation:r,selectedShape:o,shapeFilterName:l,aggregationFilterText:c,distanceUnits:i}){const p=St.find(t.features,h=>h?.properties?.id===e);if(!p)return null;const y=a?.[p.properties?.id],S=l&&o?a?.[o]?.shape_name:void 0;let u="";S&&(u=l==="origin"?` from ${S}`:` to ${S}`);const _=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:0});return s.jsxs(s.Fragment,{children:[s.jsx("h5",{children:p?.properties?.name}),s.jsxs("span",{children:[s.jsx("b",{children:r.isDistance?`${ue(p.properties?.value)} ${i}`:W(p.properties?.value)})," ",c,u]}),!(r.isDistance||r.isDuration)&&s.jsxs(s.Fragment,{children:[s.jsx("br",{}),s.jsxs("span",{children:[s.jsx("b",{children:Ye(p.properties?.percent/100,0)})," of ",c,u]})]}),y?.median_income&&s.jsxs(s.Fragment,{children:[y.pct_nonwhite!=null&&s.jsxs(s.Fragment,{children:[s.jsx("br",{}),s.jsx("span",{children:`${Math.round(y.pct_nonwhite*100)}% Non-White`})]}),s.jsx("br",{}),s.jsx("span",{children:`Median income is ${_.format(y.median_income)}`})]})]})}const Sa="#F39990",Ia="#A7D6CC",Ea=({mode:e})=>{const{t}=ee(),a=me(),{isVisible:r,toggle:o}=ze(),l=qe(a.tripsHeatmapType,r&&a.hasTripsHeatmap),c=$e(a.isMetric);return s.jsx(Wt,{getFeaturePopupContent:i=>s.jsx(_a,{featureId:i,geojson:a.geojson,shapeData:a.shapeData,aggregation:a.aggregation,selectedShape:a.selectedShape,shapeFilterName:a.shapeFilterName,aggregationFilterText:a.aggregationFilterText,distanceUnits:c}
1),ready:a.ready&&!a.layerIsLoading&&l.isReady,legendBins:a.legendBins,legendTitle:a.legendTitle,tileSource:a.ready?Oa(a.regionId,a.activeLayerUUID,a.matchExpressions.color):Ue,heatmapConfig:{eventsGeojson:l.eventsGeojson,isVisible:r,circleColor:a.tripsHeatmapType==="destination"?Ia:Sa},children:s.jsx(Ke,{control:s.jsx(Qe,{checked:r,onChange:o,disabled:!l.isReady}),label:t(`evalMap.showTrip${Ne(a.tripsHeatmapType).replaceAll(" ","")}Toggle`,`Show Trip ${Ne(a.tripsHeatmapType)}s`)})})};function Oa(e,t,a){return{id:t||"",url:`${Et}/regions/${e}/layers/${t}/vector/{z}/{x}/{y}`,paint:{"fill-color":a,"fill-opacity":It,"fill-extrusion-color":a,"fill-extrusion-opacity":.6}}}const Aa=/^[=+\-@\t\r]/;function fa(e){return typeof e=="string"&&Aa.test(e)?`'${e}`:e}function Fe(e){return O.map(e,t=>O.mapValues(t,fa))}function Da(e){const{aggregation:t,shapeData:a,totalQueryCount:r,payload:o,csvHeader:l,dateRange:c,layerName:i}=e,p=Z(c.start,$.DATE_SHORT),y=Z(c.end,$.DATE_SHORT),S=`Trip counts for ${i} from ${p} to ${y}.csv`;let u=["date","operator","vehicle_type","shape_uuid","shape_name","count"];if(O.includes([n.TRIPS_ORIGIN_OR_DESTINATION,n.TRIPS_AVERAGE_ORIGIN_DISTANCE,n.TRIPS_AVERAGE_DESTINATION_DISTANCE],t)){const _=O.map(O.pickBy(a,(E,g)=>g!=="NOT_IN_SHAPE"),(E,g)=>({shape_name:E.shape_name,shape_uuid:g,...Te(a,g,t.geojsonAttribute,r)}));u=t===n.TRIPS_ORIGIN_OR_DESTINATION?["shape_uuid","shape_name","value","percent"]:["shape_uuid","shape_name","value"];const h=l+`
2`+be(Fe(_),u),d=new Blob([h],{type:"text/csv"});Pe(d,S)}else{const _="/trips/by_day_spatial";pe(_,o,{reject:!0}).then(h=>{const d=O.orderBy(O.filter(h.shape_data_by_day,f=>f.shape_uuid!=="NOT_IN_SHAPE"),["date","operator","vehicle_type","shape_name"],["desc"]),E=l+`
3`+be(Fe(d),u),g=new Blob([E],{type:"text/csv"});Pe(g,S)}).catch(h=>{Ot(`${_} error: ${h}`)})}}const Ra=({mode:e})=>{const{t}=ee(),a=At(),[r,o]=m.useState(Le),[{selectedShape:l},c]=X(e),i=me(),p=i.geojson.features.map(d=>d.properties);if(p.length===0)return null;const y=p.sort((d,E)=>E?.value-d?.value).filter(d=>!isNaN(d?.value)),S=ft(y,r),u=i.aggregation.tableHeader(i.aggregation.isDistance?a:void 0),_=!i.aggregation.isDuration&&!i.aggregation.isDistance,h=(d,E,g)=>{const f=s.jsx(N.TableCell,{small:!0,children:d},"name"),b=s.jsx(N.TableCell,{small:!0,children:W(E)},"value"),H=s.jsx(N.TableCell,{small:!0,children:ue(E)},"value"),P=s.jsx(N.TableCell,{small:!0,children:Ye(g/100)},"percent");return i.aggregation.isDistance?[f,H]:i.aggregation.isDuration?[f,b]:[f,b,P]};return s.jsxs("div",{children:[!i.aggregation.isDuration&&s.jsxs("div",{className:"stats-container",children:[s.jsxs("div",{className:"stat",children:[s.jsx(U,{styleType:"secondary",children:i.aggregation.isAverage?i.queryAverage:W(i.totalQueryCount)}),s.jsx(U,{styleType:"caption",children:i.statCaption})]}),_&&s.jsxs("div",{className:"stat",children:[s.jsxs(U,{styleType:"secondary",children:[i.queryPercent,"%"]}),s.jsxs(U,{styleType:"caption",children:[" ",s.jsx(V,{i18nKey:"evaluationMap.percentCountedLabel",children:"counted"})]})]})]}),s.jsxs(N.Table,{showBorder:!0,selectable:!0,className:"cursor-pointer",children:[s.jsx(N.TableHeader,{children:s.jsxs(N.TableRow,{children:[s.jsx(N.TableHeaderCell,{hideSort:!0,small:!0,children:s.jsx(V,{i18nKey:"common.geography",children:"Geography"})}),s.jsx(N.TableHeaderCell,{hideSort:!0,small:!0,children:u}),_&&s.jsx(N.TableHeaderCell,{hideSort:!0,small:!0,children:s.jsx(V,{i18nKey:"common.percent",children:"Percent"})})]})}),s.jsx(N.TableBody,{children:S.map(({id:d,name:E,value:g,percent:f})=>s.jsx(N.TableRow,{className:"cursor-pointer",onClick:()=>c({[I.SELECTED_SHAPE]:d}),onMouseOver:()=>{l||c({[I.HOVERED_SHAPE]:d})},onMouseOut:()=>c({[I.HOVERED_SHAPE]:void 0}),"data-testid":"location",active:l===d,children:h(E,g,f)},d))})]}),y.length>Le&&s.jsx(Bt,{numberItemsShown:r,setNumberItemsShown:o,totalItems:y.length})]})},va=({showEvalTable:e=!0,mode:t})=>{const{t:a}=ee(),{data:r}=Ge(),{data:o}=Dt(),{data:l}=Rt(),c=l?.items??[],i=me(),{isVisible:p,setVisible:y}=ze(),S=qe(i.tripsHeatmapType,p||!!r?.organizationSettings.mobilityMapsDownload),[{shapeLayer:u,operators:_,vehicleTypes:h},d]=X(t),E=Ve();if(!i.layer)return null;const g=O.isEmpty(E),f=!g,b=Z(i.dateRange.start,$.DATE_SHORT),H=Z(i.dateRange.end,$.DATE_SHORT),P={...i.csvDownloadOptions,eventDesc:`Counts for ${i.layer.layerName}`},R=!!r?.organizationSettings.mobilityMapsDownload,L=s.jsxs(s.Fragment,{children:[s.jsx(se,{size:"small",disabled:g,value:i.aggregation,options:i.aggregationOptions,onChange:(T,A)=>{d({[I.AGGREGATION]:A?.id})},getOptionLabel:T=>a(`evaluationMap.title_${T.title}`,T.title),renderInput:T=>s.jsx(ie,{...T,label:a("common.aggregationTitle","Aggregation")})}),R&&s.jsx(U,{link:!0,className:"link-margin",onClick:()=>{y(!0),ne(i.heatmapTitle,S.eventsGeojson,"geojson")},styleType:"link",children:a("evaluationMap.downloadHeatmapTitle","Download {{heatmapTitle}} Heatmap",{heatmapTitle:i.heatmapTitle})}),i.shapeFilterName&&i.selectedShape&&s.jsxs("div",{style:{marginTop:-10,marginBottom:10},children:[i.shapeFilterName==="origin"?s.jsxs(V,{i18nKey:"evaluationMap.tripsSelectionOriginText",children:["You are viewing the count of trip ",s.jsx("i",{children:"destinations"})," which begin at this location."]}):s.jsxs(V,{i18nKey:"evaluationMap.tripsSelectionDestinationText",children:["You are viewing the count of trip ",s.jsx("i",{children:"origins"})," which end at this location."]})," ",s.jsxs(V,{i18nKey:"evaluationMap.tripsSelectionCTA",children:["Click"," ",s.jsxs(We,{variant:"outlined",color:"inherit",size:"small",sx:{textTransform:"none"},onClick:()=>{d({[I.SELECTED_SHAPE]:void 0})},children:[" ","here"]})," ","or click outside the shapes to cancel the selection."]})]})]}),x=(l?.total||0)<2?null:s.jsx(se,{multiple:!0,size:"small","data-cy":"operator",value:c.filter(T=>_?.includes(T.slug)),options:c,onChange:(T,A)=>d({[I.OPERATORS]:A.map(k=>k.slug)}),getOptionLabel:T=>T.name,renderInput:T=>s.jsx(ie,{...T,label:a("common.operatorTitle","Operator")})}),v=s.jsx(se,{multiple:!0,size:"small","data-cy":"vehicle_type",value:h??[],options:o??[],onChange:(T,A)=>d({[I.VEHICLE_TYPES]:A}),getOptionLabel:T=>T?xe(a(`common.vehicleType_${T}`,T)):"",renderInput:T=>s.jsx(ie,{...T,label:a("common.vehicleTypeTitle","Vehicle Type")})}),D=s.jsx("div",{children:a("evaluationMap.noLayersWarning","There are no shapes currently configured for the Eval map. You may use the Policy map to draw shapes that can be used in this map (save as Monitoring Zones) or contact Populus for assistance. Once you draw shapes, you can use this map to count trips and parking events within or near those shapes.")}),F=a("evaluationMap.filterTitleTrips","Trips Filters"),j=a("evaluationMap.downloadTitle","Counts for {{layerName}} from {{startDate}} to {{endDate}}",{layerName:i.layer.layerName,startDate:b,endDate:H}),Y=()=>{const T=Ut(E,u),A=_?.length?_.map(C=>l?.items.find(q=>
3q.slug===C)?.name??C).join(", "):a("common.allOperators","All Operators"),k=h?.length?h.map(C=>xe(a(`common.vehicleType_${C}`,C))).join(", "):a("common.allVehicleTypes","All Vehicle Types"),te=i.aggregation.title;return`${T} | ${A} | ${k} ${R?` | ${te}`:""}`};return s.jsxs(z.Sidebar,{children:[s.jsx(z.HeaderPanel,{type:"floating",titleText:i.mapTitle,primaryMenu:{accessProps:{disabled:!(f&&r?.organizationSettings.mobilityMapsDownload)},iconName:"download",label:a("evaluationMap.downloadButton","Download Map Data"),options:[{text:a("common.downloadCSV","Download .csv"),onClick:()=>ne(j,i.geojson,"geojson",{...P,downloadFunction:()=>Da({aggregation:i.aggregation,shapeData:i.shapeData,totalQueryCount:i.totalQueryCount,payload:i.payload,csvHeader:i.csvDownloadOptions.header,dateRange:i.dateRange,layerName:i.layer?.layerName})})},{text:a("common.downloadGeojson","Download .geojson"),onClick:()=>ne(j,i.geojson,"geojson",P)}]},secondaryButtons:[{iconName:"undo",label:a("common.resetFilters","Reset Filters"),onClick:()=>{d({},"replace"),y(!1)}}],body:g?D:void 0}),s.jsx(kt,{queryParamHook:X.bind(null,t),timeOfDayPicker:i.hourFiltersEnabled?"hourly":"off",dayOfWeekPicker:"off",tooltipText:a("common.choroplethDateWarning","Date ranges longer than 3 months could take a while to process")}),s.jsxs(z.Panel,{iconName:"filter",titleText:F,subtitleText:Y(),hideSubtitleWhenOpen:!0,children:[L,u&&s.jsx(qt,{shapeLayerUuid:u,onChange:(T,A)=>d({[I.SHAPE_LAYER]:A?.shapeLayerUuid})}),x!==null&&x,v]}),s.jsx(z.Panel,{iconName:"location",titleText:i.statTitle,children:e&&s.jsx(Ra,{mode:t})})]})},Na=({children:e})=>{const[t,a]=m.useState(!1),r=m.useMemo(()=>({isVisible:t,setVisible:a,toggle:()=>a(o=>!o)}),[t]);return s.jsx(Be,{value:r,children:e})},Wa=()=>{const{t:e}=ee();vt(`Mobility Manager - ${e("tripsMap.pageTitle","Trips Map")}`);const t=Nt();return s.jsx(bt,{hasAccess:t,children:s.jsxs(Ze,{height:"100%",children:[s.jsx(Pt,{title:e("tripsMap.pageTitle","Trips Map")}),s.jsx(Na,{children:s.jsxs("div",{className:"page-with-floating-sidebar",children:[s.jsx(Ea,{mode:"trips"}),s.jsx(va,{mode:"trips"})]})})]})})};export{Wa as default};
4//# sourceMappingURL=trips-BGiF8rzj.js.map

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.