@opentripplanner/core-utils 13.0.0-alpha.3 → 13.0.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,735 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ exports.formatPlace = formatPlace;
9
+ exports.getCustomQueryParams = getCustomQueryParams;
10
+ var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
11
+ var _react = _interopRequireDefault(require("react"));
12
+ var _Wheelchair = require("@styled-icons/foundation/Wheelchair");
13
+ var _itinerary = require("./itinerary");
14
+ var _storage = require("./storage");
15
+ var _time = require("./time");
16
+ // TODO: Remove this entire file, as it is deprecated in favor of i18n-queryParams within
17
+ // the SettingsSelector package
18
+
19
+ // This is only used within stories
20
+
21
+ /**
22
+ * name: the default name of the parameter used for internal reference and API calls
23
+ *
24
+ * routingTypes: array of routing type(s) (ITINERARY, PROFILE, or both) this param applies to
25
+ *
26
+ * applicable: an optional function (accepting the current full query as a
27
+ * parameter) indicating whether this query parameter is applicable to the query.
28
+ * (Applicability is assumed if this function is not provided.)
29
+ *
30
+ * default: the default value for this parameter. The default can be also be a
31
+ * function that gets executed when accessing the default value.
32
+ *
33
+ * itineraryRewrite: an optional function for translating the key and/or value
34
+ * for ITINERARY mode only (e.g. 'to' is rewritten as 'toPlace'). Accepts the
35
+ * initial internal value as a function parameter.
36
+ *
37
+ * profileRewrite: an optional function for translating the value for PROFILE mode
38
+ *
39
+ * label: a text label for for onscreen display. May either be a text string or a
40
+ * function (accepting the current full query as a parameter) returning a string
41
+ *
42
+ * selector: the default type of UI selector to use in the form. Can be one of:
43
+ * - DROPDOWN: a standard drop-down menu selector
44
+ *
45
+ * options: an array of text/value pairs used with a dropdown selector
46
+ *
47
+ * TODO: validation system for rewrite functions and/or better user documentation
48
+ * TODO: alphabetize below list
49
+ */
50
+
51
+ // FIXME: Use for parsing URL values?
52
+ // const stringToLocation = string => {
53
+ // const split = string.split(',')
54
+ // return split.length === 2
55
+ // ? {lat: split[0], lon: split[1]}
56
+ // : {lat: null, lon: null}
57
+ // }
58
+
59
+ /**
60
+ * Format location object as string for use in fromPlace or toPlace query param.
61
+ */
62
+ function formatPlace(location, alternateName) {
63
+ if (!location) return null;
64
+ const name = location.name || `${alternateName ? `${alternateName} ` : ""}(${location.lat},${location.lon})`;
65
+ // This string is not language-specific
66
+ return `${name}::${location.lat},${location.lon}`;
67
+ }
68
+
69
+ // Load stored default query settings from local storage
70
+ const storedSettings = (0, _storage.getItem)("defaultQuery", {});
71
+ const queryParams = [{
72
+ /* from - the trip origin. stored internally as a location (lat/lon/name) object */
73
+ name: "from",
74
+ routingTypes: ["ITINERARY", "PROFILE"],
75
+ default: null,
76
+ itineraryRewrite: value => ({
77
+ fromPlace: formatPlace(value)
78
+ }),
79
+ profileRewrite: value => ({
80
+ from: {
81
+ lat: value.lat,
82
+ lon: value.lon
83
+ }
84
+ })
85
+ // FIXME: Use for parsing URL values?
86
+ // fromURL: stringToLocation
87
+ }, {
88
+ /* to - the trip destination. stored internally as a location (lat/lon/name) object */
89
+ name: "to",
90
+ routingTypes: ["ITINERARY", "PROFILE"],
91
+ default: null,
92
+ itineraryRewrite: value => ({
93
+ toPlace: formatPlace(value)
94
+ }),
95
+ profileRewrite: value => ({
96
+ to: {
97
+ lat: value.lat,
98
+ lon: value.lon
99
+ }
100
+ })
101
+ // FIXME: Use for parsing URL values?
102
+ // fromURL: stringToLocation
103
+ }, {
104
+ /* date - the date of travel, in MM-DD-YYYY format */
105
+ name: "date",
106
+ routingTypes: ["ITINERARY", "PROFILE"],
107
+ default: _time.getCurrentDate
108
+ }, {
109
+ /* time - the arrival/departure time for an itinerary trip, in HH:mm format */
110
+ name: "time",
111
+ routingTypes: ["ITINERARY"],
112
+ default: _time.getCurrentTime
113
+ }, {
114
+ /* departArrive - whether this is a depart-at, arrive-by, or leave-now trip */
115
+ name: "departArrive",
116
+ routingTypes: ["ITINERARY"],
117
+ default: "NOW",
118
+ itineraryRewrite: value => ({
119
+ arriveBy: value === "ARRIVE"
120
+ })
121
+ }, {
122
+ /* startTime - the start time for a profile trip, in HH:mm format */
123
+ name: "startTime",
124
+ routingTypes: ["PROFILE"],
125
+ default: "07:00"
126
+ }, {
127
+ /* endTime - the end time for a profile trip, in HH:mm format */
128
+ name: "endTime",
129
+ routingTypes: ["PROFILE"],
130
+ default: "09:00"
131
+ }, {
132
+ /* mode - the allowed modes for a trip, as a comma-separated list */
133
+ name: "mode",
134
+ routingTypes: ["ITINERARY", "PROFILE"],
135
+ default: "WALK,TRANSIT",
136
+ // TODO: make this dependent on routingType?
137
+ profileRewrite: value => {
138
+ const accessModes = [];
139
+ const directModes = [];
140
+ const transitModes = [];
141
+ if (value && value.length > 0) {
142
+ value.split(",").forEach(m => {
143
+ if ((0, _itinerary.isTransit)(m)) transitModes.push(m);
144
+ if ((0, _itinerary.isAccessMode)(m)) {
145
+ accessModes.push(m);
146
+ // TODO: make configurable whether direct-driving is considered
147
+ if (!(0, _itinerary.isCar)(m)) directModes.push(m);
148
+ }
149
+ });
150
+ }
151
+ return {
152
+ accessModes,
153
+ directModes,
154
+ transitModes
155
+ };
156
+ }
157
+ }, {
158
+ /* showIntermediateStops - whether response should include intermediate stops for transit legs */
159
+ name: "showIntermediateStops",
160
+ routingTypes: ["ITINERARY"],
161
+ default: true
162
+ }, {
163
+ /* maxWalkDistance - the maximum distance in meters the user will walk to transit. */
164
+ name: "maxWalkDistance",
165
+ routingTypes: ["ITINERARY"],
166
+ applicable: query =>
167
+ /* Since this query variable isn't in this list, it's not included in the generated query
168
+ * It does however allow us to determine if we should show the OTP1 max walk distance
169
+ * dropdown or the OTP2 walk reluctance slider
170
+ */
171
+ !query.otp2 && query.mode && (0, _itinerary.hasTransit)(query.mode) && query.mode.indexOf("WALK") !== -1,
172
+ default: 1609,
173
+ // 1 mi.
174
+ selector: "DROPDOWN",
175
+ label: "Maximum Walk",
176
+ options: [{
177
+ text: "1/10 mile",
178
+ value: 160.9
179
+ }, {
180
+ text: "1/4 mile",
181
+ value: 402.3
182
+ }, {
183
+ text: "1/2 mile",
184
+ value: 804.7
185
+ }, {
186
+ text: "3/4 mile",
187
+ value: 1207
188
+ }, {
189
+ text: "1 mile",
190
+ value: 1609
191
+ }, {
192
+ text: "2 miles",
193
+ value: 3219
194
+ }, {
195
+ text: "5 miles",
196
+ value: 8047
197
+ }]
198
+ }, {
199
+ /* maxBikeDistance - the maximum distance in meters the user will bike. Not
200
+ * actually an OTP parameter (maxWalkDistance doubles for biking) but we
201
+ * store it separately internally in order to allow different default values,
202
+ * options, etc. Translated to 'maxWalkDistance' via the rewrite function.
203
+ */
204
+ name: "maxBikeDistance",
205
+ routingTypes: ["ITINERARY"],
206
+ applicable: query => query.mode && (0, _itinerary.hasTransit)(query.mode) && query.mode.indexOf("BICYCLE") !== -1,
207
+ default: 4828,
208
+ // 3 mi.
209
+ selector: "DROPDOWN",
210
+ label: "Maximum Bike",
211
+ options: [{
212
+ text: "1/4 mile",
213
+ value: 402.3
214
+ }, {
215
+ text: "1/2 mile",
216
+ value: 804.7
217
+ }, {
218
+ text: "3/4 mile",
219
+ value: 1207
220
+ }, {
221
+ text: "1 mile",
222
+ value: 1609
223
+ }, {
224
+ text: "2 miles",
225
+ value: 3219
226
+ }, {
227
+ text: "3 miles",
228
+ value: 4828
229
+ }, {
230
+ text: "5 miles",
231
+ value: 8047
232
+ }, {
233
+ text: "10 miles",
234
+ value: 16093
235
+ }, {
236
+ text: "20 miles",
237
+ value: 32187
238
+ }, {
239
+ text: "30 miles",
240
+ value: 48280
241
+ }],
242
+ itineraryRewrite: value => ({
243
+ maxWalkDistance: value,
244
+ // ensures that the value is repopulated when loaded from URL params
245
+ maxBikeDistance: value
246
+ })
247
+ }, {
248
+ /* optimize -- how to optimize a trip (non-bike, non-micromobility trips) */
249
+ name: "optimize",
250
+ // This parameter doesn't seem to do anything
251
+ applicable: () => false,
252
+ routingTypes: ["ITINERARY"],
253
+ default: "QUICK",
254
+ selector: "DROPDOWN",
255
+ label: "Optimize for",
256
+ options: [{
257
+ text: "Speed",
258
+ value: "QUICK"
259
+ }, {
260
+ text: "Fewest Transfers",
261
+ value: "TRANSFERS"
262
+ }]
263
+ }, {
264
+ /* optimizeBike -- how to optimize an bike-based trip */
265
+ name: "optimizeBike",
266
+ applicable: query => !query.otp2 && (0, _itinerary.hasBike)(query.mode),
267
+ routingTypes: ["ITINERARY"],
268
+ default: "SAFE",
269
+ selector: "DROPDOWN",
270
+ label: "Optimize for",
271
+ options: () => {
272
+ const opts = [{
273
+ text: "Speed",
274
+ value: "QUICK"
275
+ }, {
276
+ text: "Bike-Friendly Trip",
277
+ value: "SAFE"
278
+ }, {
279
+ text: "Flat Trip",
280
+ value: "FLAT"
281
+ }];
282
+ return opts;
283
+ },
284
+ itineraryRewrite: value => ({
285
+ optimize: value
286
+ })
287
+ }, {
288
+ /* maxWalkTime -- the maximum time the user will spend walking in minutes */
289
+ name: "maxWalkTime",
290
+ routingTypes: ["PROFILE"],
291
+ default: 15,
292
+ selector: "DROPDOWN",
293
+ label: "Max Walk Time",
294
+ applicable: query => query.mode && (0, _itinerary.hasTransit)(query.mode) && query.mode.indexOf("WALK") !== -1,
295
+ options: [{
296
+ text: "5 minutes",
297
+ value: 5
298
+ }, {
299
+ text: "10 minutes",
300
+ value: 10
301
+ }, {
302
+ text: "15 minutes",
303
+ value: 15
304
+ }, {
305
+ text: "20 minutes",
306
+ value: 20
307
+ }, {
308
+ text: "30 minutes",
309
+ value: 30
310
+ }, {
311
+ text: "45 minutes",
312
+ value: 45
313
+ }, {
314
+ text: "1 hour",
315
+ value: 60
316
+ }]
317
+ }, {
318
+ name: "walkReluctance",
319
+ routingTypes: ["ITINERARY", "PROFILE"],
320
+ selector: "SLIDER",
321
+ low: 1,
322
+ high: 10,
323
+ step: 0.5,
324
+ label: "walk reluctance",
325
+ labelLow: "More Walking",
326
+ labelHigh: "More Transit",
327
+ applicable: query =>
328
+ /* Since this query variable isn't in this list, it's not included in the generated query
329
+ * It does however allow us to determine if we should show the OTP1 max walk distance
330
+ * dropdown or the OTP2 walk reluctance slider
331
+ */
332
+ !!query.otp2 && query.mode && query.mode.indexOf("WALK") !== -1
333
+ }, {
334
+ /* maxBikeTime -- the maximum time the user will spend biking in minutes */
335
+ name: "maxBikeTime",
336
+ routingTypes: ["PROFILE"],
337
+ default: 20,
338
+ selector: "DROPDOWN",
339
+ label: "Max Bike Time",
340
+ applicable: query => query.mode && (0, _itinerary.hasTransit)(query.mode) && query.mode.indexOf("BICYCLE") !== -1,
341
+ options: [{
342
+ text: "5 minutes",
343
+ value: 5
344
+ }, {
345
+ text: "10 minutes",
346
+ value: 10
347
+ }, {
348
+ text: "15 minutes",
349
+ value: 15
350
+ }, {
351
+ text: "20 minutes",
352
+ value: 20
353
+ }, {
354
+ text: "30 minutes",
355
+ value: 30
356
+ }, {
357
+ text: "45 minutes",
358
+ value: 45
359
+ }, {
360
+ text: "1 hour",
361
+ value: 60
362
+ }]
363
+ }, {
364
+ /* bikeSpeed -- the user's bikeSpeed speed in m/s */
365
+ name: "bikeSpeed",
366
+ routingTypes: ["ITINERARY", "PROFILE"],
367
+ default: 3.58,
368
+ selector: "DROPDOWN",
369
+ label: "Bicycle Speed",
370
+ applicable: query => query.mode && query.mode.indexOf("BICYCLE") !== -1,
371
+ options: [{
372
+ text: "6 MPH",
373
+ value: 2.68
374
+ }, {
375
+ text: "8 MPH",
376
+ value: 3.58
377
+ }, {
378
+ text: "10 MPH",
379
+ value: 4.47
380
+ }, {
381
+ text: "12 MPH",
382
+ value: 5.36
383
+ }]
384
+ }, {
385
+ /* maxEScooterDistance - the maximum distance in meters the user will ride
386
+ * an E-scooter. Not actually an OTP parameter (maxWalkDistance doubles for
387
+ * any non-transit mode except for car) but we store it separately
388
+ * internally in order to allow different default values, options, etc.
389
+ * Translated to 'maxWalkDistance' via the rewrite function.
390
+ */
391
+ name: "maxEScooterDistance",
392
+ routingTypes: ["ITINERARY"],
393
+ applicable: query => query.mode && (0, _itinerary.hasTransit)(query.mode) && (0, _itinerary.hasMicromobility)(query.mode),
394
+ default: 4828,
395
+ // 3 mi.
396
+ selector: "DROPDOWN",
397
+ label: "Maximum E-scooter Distance",
398
+ options: [{
399
+ text: "1/4 mile",
400
+ value: 402.3
401
+ }, {
402
+ text: "1/2 mile",
403
+ value: 804.7
404
+ }, {
405
+ text: "3/4 mile",
406
+ value: 1207
407
+ }, {
408
+ text: "1 mile",
409
+ value: 1609
410
+ }, {
411
+ text: "2 miles",
412
+ value: 3219
413
+ }, {
414
+ text: "3 miles",
415
+ value: 4828
416
+ }, {
417
+ text: "5 miles",
418
+ value: 8047
419
+ }, {
420
+ text: "10 miles",
421
+ value: 16093
422
+ }, {
423
+ text: "20 miles",
424
+ value: 32187
425
+ }, {
426
+ text: "30 miles",
427
+ value: 48280
428
+ }],
429
+ itineraryRewrite: value => ({
430
+ maxWalkDistance: value,
431
+ // ensures that the value is repopulated when loaded from URL params
432
+ maxEScooterDistance: value
433
+ })
434
+ }, {
435
+ /* bikeSpeed -- the user's bikeSpeed speed in m/s */
436
+ name: "watts",
437
+ routingTypes: ["ITINERARY", "PROFILE"],
438
+ default: 250,
439
+ selector: "DROPDOWN",
440
+ label: "E-scooter Power",
441
+ // this configuration should only be allowed for personal E-scooters as these
442
+ // settings will be defined by the vehicle type of an E-scooter being rented
443
+ applicable: query => query.mode && query.mode.indexOf("MICROMOBILITY") !== -1 && query.mode.indexOf("MICROMOBILITY_RENT") === -1 && query.mode.indexOf("SCOOTER") === -1,
444
+ options: [{
445
+ text: "Kid's hoverboard (6mph)",
446
+ value: 125
447
+ }, {
448
+ text: "Entry-level scooter (11mph)",
449
+ value: 250
450
+ }, {
451
+ text: "Robust E-scooter (18mph)",
452
+ value: 500
453
+ }, {
454
+ text: "Powerful E-scooter (24mph)",
455
+ value: 1500
456
+ }],
457
+ // rewrite a few other values to add some baseline assumptions about the
458
+ // vehicle
459
+ itineraryRewrite: value => {
460
+ const watts = value;
461
+ // the maximum cruising and downhill speed. Units in m/s
462
+ let maximumMicromobilitySpeed;
463
+ let weight;
464
+ // see https://en.wikipedia.org/wiki/Human_body_weight#Average_weight_around_the_world
465
+ // estimate is for an average North American human with clothes and stuff
466
+ // units are in kg
467
+ const TYPICAL_RIDER_WEIGHT = 90;
468
+ switch (watts) {
469
+ case 125:
470
+ // exemplar: Swagtron Turbo 5 hoverboard (https://swagtron.com/product/recertified-swagtron-turbo-five-hoverboard-classic/)
471
+ maximumMicromobilitySpeed = 2.8; // ~= 6mph
472
+ weight = TYPICAL_RIDER_WEIGHT + 9;
473
+ break;
474
+ case 250:
475
+ // exemplar: Xiaomi M365 (https://www.gearbest.com/skateboard/pp_596618.html)
476
+ maximumMicromobilitySpeed = 5; // ~= 11.5mph
477
+ weight = TYPICAL_RIDER_WEIGHT + 12.5;
478
+ break;
479
+ case 500:
480
+ // exemplar: Razor EcoSmart Metro (https://www.amazon.com/Razor-EcoSmart-Metro-Electric-Scooter/dp/B002ZDAEIS?SubscriptionId=AKIAJMXJ2YFJTEDLQMUQ&tag=digitren08-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=B002ZDAEIS&ascsubtag=15599460143449ocb)
481
+ maximumMicromobilitySpeed = 8; // ~= 18mph
482
+ weight = TYPICAL_RIDER_WEIGHT + 30;
483
+ break;
484
+ case 1000:
485
+ // exemplar: Boosted Rev (https://boostedboards.com/vehicles/scooters/boosted-rev)
486
+ maximumMicromobilitySpeed = 11; // ~= 24mph
487
+ weight = TYPICAL_RIDER_WEIGHT + 21;
488
+ break;
489
+ default:
490
+ break;
491
+ }
492
+ return {
493
+ maximumMicromobilitySpeed,
494
+ watts,
495
+ weight
496
+ };
497
+ }
498
+ }, {
499
+ /* ignoreRealtimeUpdates -- if true, do not use realtime updates in routing */
500
+ name: "ignoreRealtimeUpdates",
501
+ routingTypes: ["ITINERARY"],
502
+ default: false
503
+ }, {
504
+ /* companies -- tnc companies to query */
505
+ name: "companies",
506
+ routingTypes: ["ITINERARY"]
507
+ }, {
508
+ /* wheelchair -- whether the user requires a wheelchair-accessible trip */
509
+ name: "wheelchair",
510
+ routingTypes: ["ITINERARY", "PROFILE"],
511
+ default: false,
512
+ selector: "CHECKBOX",
513
+ label: "Prefer Wheelchair Accessible Routes",
514
+ icon: /*#__PURE__*/_react.default.createElement(_Wheelchair.Wheelchair, null),
515
+ applicable: (query, config) => {
516
+ if (!query.mode || !config.modes) return false;
517
+ const configModes = (config.modes.accessModes || []).concat(config.modes.transitModes || []);
518
+ return query.mode.split(",").some(mode => {
519
+ const configMode = configModes.find(m => m.mode === mode);
520
+ if (!configMode || !configMode.showWheelchairSetting) return false;
521
+ if (configMode.company && (!query.companies || !query.companies.split(",").includes(configMode.company))) return false;
522
+ return true;
523
+ });
524
+ }
525
+ }, {
526
+ name: "bannedRoutes",
527
+ routingTypes: ["ITINERARY"]
528
+ }, {
529
+ name: "numItineraries",
530
+ routingTypes: ["ITINERARY"],
531
+ default: 3
532
+ }, {
533
+ name: "intermediatePlaces",
534
+ default: [],
535
+ routingTypes: ["ITINERARY"],
536
+ itineraryRewrite: places => Array.isArray(places) && places.length > 0 ? {
537
+ intermediatePlaces: places.map(place => formatPlace(place))
538
+ } : undefined
539
+ }, {
540
+ // Time penalty in seconds the requester is willing to accept in order to
541
+ // complete journey on preferred route. I.e., number of seconds that we are
542
+ // willing to wait for the preferred route.
543
+ name: "otherThanPreferredRoutesPenalty",
544
+ default: 15 * 60,
545
+ // 15 minutes
546
+ routingTypes: ["ITINERARY"]
547
+ },
548
+ // Below are less commonly used query params included so that in case they are
549
+ // passed in a query parameter they do not get filtered out from the ultimate
550
+ // API request.
551
+ {
552
+ name: "preferredRoutes",
553
+ routingTypes: ["ITINERARY"]
554
+ }, {
555
+ name: "maxPreTransitTime",
556
+ routingTypes: ["ITINERARY"]
557
+ }, {
558
+ name: "waitReluctance",
559
+ routingTypes: ["ITINERARY"]
560
+ }, {
561
+ name: "driveDistanceReluctance",
562
+ routingTypes: ["ITINERARY"]
563
+ }, {
564
+ name: "driveTimeReluctance",
565
+ routingTypes: ["ITINERARY"]
566
+ }, {
567
+ name: "waitAtBeginningFactor",
568
+ routingTypes: ["ITINERARY"]
569
+ }, {
570
+ name: "bikeSwitchTime",
571
+ routingTypes: ["ITINERARY"]
572
+ }, {
573
+ name: "bikeSwitchCost",
574
+ routingTypes: ["ITINERARY"]
575
+ }, {
576
+ name: "minTransferTime",
577
+ routingTypes: ["ITINERARY"]
578
+ }, {
579
+ name: "preferredAgencies",
580
+ routingTypes: ["ITINERARY"]
581
+ }, {
582
+ name: "unpreferredRoutes",
583
+ routingTypes: ["ITINERARY"]
584
+ }, {
585
+ name: "unpreferredAgencies",
586
+ routingTypes: ["ITINERARY"]
587
+ }, {
588
+ name: "walkBoardCost",
589
+ routingTypes: ["ITINERARY"]
590
+ }, {
591
+ name: "bikeBoardCost",
592
+ routingTypes: ["ITINERARY"]
593
+ }, {
594
+ name: "whiteListedRoutes",
595
+ routingTypes: ["ITINERARY"]
596
+ }, {
597
+ name: "bannedAgencies",
598
+ routingTypes: ["ITINERARY"]
599
+ }, {
600
+ name: "whiteListedAgencies",
601
+ routingTypes: ["ITINERARY"]
602
+ }, {
603
+ name: "bannedTrips",
604
+ routingTypes: ["ITINERARY"]
605
+ }, {
606
+ name: "bannedStops",
607
+ routingTypes: ["ITINERARY"]
608
+ }, {
609
+ name: "bannedStopsHard",
610
+ routingTypes: ["ITINERARY"]
611
+ }, {
612
+ name: "transferPenalty",
613
+ routingTypes: ["ITINERARY"]
614
+ }, {
615
+ name: "nonpreferredTransferPenalty",
616
+ routingTypes: ["ITINERARY"]
617
+ }, {
618
+ name: "maxTransfers",
619
+ routingTypes: ["ITINERARY"]
620
+ }, {
621
+ name: "batch",
622
+ routingTypes: ["ITINERARY"]
623
+ }, {
624
+ name: "startTransitStopId",
625
+ routingTypes: ["ITINERARY"]
626
+ }, {
627
+ name: "startTransitTripId",
628
+ routingTypes: ["ITINERARY"]
629
+ }, {
630
+ name: "clampInitialWait",
631
+ routingTypes: ["ITINERARY"]
632
+ }, {
633
+ name: "reverseOptimizeOnTheFly",
634
+ routingTypes: ["ITINERARY"]
635
+ }, {
636
+ name: "boardSlack",
637
+ routingTypes: ["ITINERARY"]
638
+ }, {
639
+ name: "alightSlack",
640
+ routingTypes: ["ITINERARY"]
641
+ }, {
642
+ name: "locale",
643
+ routingTypes: ["ITINERARY"]
644
+ }, {
645
+ name: "disableRemainingWeightHeuristic",
646
+ routingTypes: ["ITINERARY"]
647
+ }, {
648
+ name: "flexFlagStopBufferSize",
649
+ routingTypes: ["ITINERARY"]
650
+ }, {
651
+ name: "flexUseReservationServices",
652
+ routingTypes: ["ITINERARY"]
653
+ }, {
654
+ name: "flexUseEligibilityServices",
655
+ routingTypes: ["ITINERARY"]
656
+ }, {
657
+ name: "flexIgnoreDrtAdvanceBookMin",
658
+ routingTypes: ["ITINERARY"]
659
+ }, {
660
+ name: "maxHours",
661
+ routingTypes: ["ITINERARY"]
662
+ }, {
663
+ name: "useRequestedDateTimeInMaxHours",
664
+ routingTypes: ["ITINERARY"]
665
+ }, {
666
+ name: "disableAlertFiltering",
667
+ routingTypes: ["ITINERARY"]
668
+ }, {
669
+ name: "geoidElevation",
670
+ routingTypes: ["ITINERARY"]
671
+ }, {
672
+ name: "invalidDateStrategy",
673
+ routingTypes: ["ITINERARY"]
674
+ }, {
675
+ name: "minTransitDistance",
676
+ routingTypes: ["ITINERARY"]
677
+ }, {
678
+ name: "searchTimeout",
679
+ routingTypes: ["ITINERARY"]
680
+ }, {
681
+ name: "pathComparator",
682
+ routingTypes: ["ITINERARY"]
683
+ }, {
684
+ name: "onlyTransitTrips",
685
+ routingTypes: ["ITINERARY"]
686
+ }, {
687
+ name: "minimumMicromobilitySpeed",
688
+ routingTypes: ["ITINERARY"]
689
+ }];
690
+ // Iterate over stored settings and update query param defaults.
691
+ // FIXME: this does not get updated if the user defaults are cleared
692
+ queryParams.forEach(param => {
693
+ if (param.name in storedSettings) {
694
+ param.default = storedSettings[param.name];
695
+ param.userDefaultOverride = true;
696
+ }
697
+ });
698
+ var _default = exports.default = queryParams;
699
+ /**
700
+ * You can customize the queryParams labels and options, and labels and values for each option.
701
+ * @param customizations The optional customizations to apply: an object whose fields
702
+ * correspond to the items in queryParams with the corresponding name,
703
+ * the value for those fields being an object which fields (label, options...)
704
+ * will override the originals.
705
+ * Example:
706
+ * {
707
+ * // Matches the name param
708
+ * maxWalkDistance: {
709
+ * // Any fields that should be overridden go here
710
+ * options: [
711
+ * // ...new options
712
+ * ],
713
+ * default: 500,
714
+ * label: "max walk dist"
715
+ * }
716
+ * }
717
+ * @returns A copy of the default queryParams that has the given customizations applied.
718
+ * If no customizations parameter is provided, returns the queryParams object itself.
719
+ */
720
+ function getCustomQueryParams(customizations) {
721
+ if (!customizations) return queryParams;
722
+ const clonedParams = (0, _lodash.default)(queryParams);
723
+ Object.keys(customizations).forEach(k => {
724
+ // Merge fields into the cloned object
725
+ const paramIndex = clonedParams.findIndex(param => param.name === k);
726
+ if (paramIndex !== -1) {
727
+ clonedParams[paramIndex] = {
728
+ ...clonedParams[paramIndex],
729
+ ...customizations[k]
730
+ };
731
+ }
732
+ });
733
+ return clonedParams;
734
+ }
735
+ //# sourceMappingURL=query-params.js.map