@xyo-network/react-map 6.2.0 → 7.0.1

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.
@@ -1,38 +1,29 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
-
4
1
  // src/Components/AnimatedHeatMap.tsx
5
2
  import { useTheme } from "@mui/material";
6
3
  import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
7
4
  import { darkenCss } from "@xylabs/react-theme";
8
- import React8, { useState as useState5 } from "react";
5
+ import { useState as useState5 } from "react";
9
6
 
10
7
  // src/Contexts/HeatMapInitializer/Provider.tsx
11
8
  import { forget as forget2 } from "@xylabs/forget";
12
- import React3, { useEffect as useEffect4, useMemo as useMemo6 } from "react";
9
+ import { useEffect as useEffect4, useMemo as useMemo6 } from "react";
13
10
 
14
11
  // src/hooks/useDynamicMapResize.tsx
15
12
  import { useEffect, useMemo } from "react";
16
- var useDynamicMapResize = /* @__PURE__ */ __name((mapContainerRef, mapCanvasRef, mapInstance, active = true) => {
17
- const resizer = useMemo(() => new ResizeObserver(() => {
18
- const width = mapContainerRef.current?.getBoundingClientRect().width;
19
- if (width && mapCanvasRef.current) {
20
- mapCanvasRef.current.style.width = `${width}px`;
21
- setTimeout(() => mapInstance?.resize());
22
- }
23
- }), [
24
- mapCanvasRef,
25
- mapContainerRef,
26
- mapInstance
27
- ]);
13
+ var useDynamicMapResize = (mapContainerRef, mapCanvasRef, mapInstance, active = true) => {
14
+ const resizer = useMemo(
15
+ () => new ResizeObserver(() => {
16
+ const width = mapContainerRef.current?.getBoundingClientRect().width;
17
+ if (width && mapCanvasRef.current) {
18
+ mapCanvasRef.current.style.width = `${width}px`;
19
+ setTimeout(() => mapInstance?.resize());
20
+ }
21
+ }),
22
+ [mapCanvasRef, mapContainerRef, mapInstance]
23
+ );
28
24
  const dependenciesReady = useMemo(() => {
29
25
  return !!(active && mapInstance && mapContainerRef?.current && mapCanvasRef.current);
30
- }, [
31
- active,
32
- mapCanvasRef,
33
- mapContainerRef,
34
- mapInstance
35
- ]);
26
+ }, [active, mapCanvasRef, mapContainerRef, mapInstance]);
36
27
  useEffect(() => {
37
28
  if (dependenciesReady) {
38
29
  if (mapContainerRef.current) {
@@ -42,33 +33,17 @@ var useDynamicMapResize = /* @__PURE__ */ __name((mapContainerRef, mapCanvasRef,
42
33
  resizer.disconnect();
43
34
  };
44
35
  }
45
- }, [
46
- active,
47
- dependenciesReady,
48
- mapCanvasRef,
49
- mapContainerRef,
50
- mapInstance,
51
- resizer
52
- ]);
53
- }, "useDynamicMapResize");
36
+ }, [active, dependenciesReady, mapCanvasRef, mapContainerRef, mapInstance, resizer]);
37
+ };
54
38
 
55
39
  // src/hooks/useDynamicPositioning.tsx
56
40
  import { useWindowSize } from "@xylabs/react-shared";
57
41
  import { useMemo as useMemo2 } from "react";
58
42
  var defaultZoom = 1.6;
59
- var defaultAspectRatioRange = [
60
- 0.5,
61
- 2
62
- ];
63
- var latRange = [
64
- 0.9121644205263664,
65
- 1.71785031559439
66
- ];
67
- var lngRange = [
68
- -81.4742014851959,
69
- 12.788958675506933
70
- ];
71
- var linearInterpolate = /* @__PURE__ */ __name((aspectRatio, degreeRange, aspectRatioRange) => {
43
+ var defaultAspectRatioRange = [0.5, 2];
44
+ var latRange = [0.9121644205263664, 1.71785031559439];
45
+ var lngRange = [-81.4742014851959, 12.788958675506933];
46
+ var linearInterpolate = (aspectRatio, degreeRange, aspectRatioRange) => {
72
47
  const [degreeMin, degreeMax] = degreeRange;
73
48
  const [aspectRatioMin, aspectRatioMax] = aspectRatioRange || defaultAspectRatioRange;
74
49
  const aspectRatioRangeSpan = aspectRatioMax - aspectRatioMin;
@@ -76,51 +51,41 @@ var linearInterpolate = /* @__PURE__ */ __name((aspectRatio, degreeRange, aspect
76
51
  const percent = (aspectRatio - aspectRatioMin) / aspectRatioRangeSpan;
77
52
  const scaledDegree = percent * degreeRangeSpan + degreeMin;
78
53
  return scaledDegree;
79
- }, "linearInterpolate");
80
- var useDynamicPositioning = /* @__PURE__ */ __name(() => {
54
+ };
55
+ var useDynamicPositioning = () => {
81
56
  const { width, height } = useWindowSize();
82
57
  const options = useMemo2(() => {
83
58
  if (width && height) {
84
59
  const aspectRatio = width / height;
85
60
  return {
86
- center: [
87
- linearInterpolate(aspectRatio, lngRange),
88
- linearInterpolate(aspectRatio, latRange)
89
- ],
61
+ center: [linearInterpolate(aspectRatio, lngRange), linearInterpolate(aspectRatio, latRange)],
90
62
  zoom: defaultZoom
91
63
  };
92
64
  }
93
- }, [
94
- height,
95
- width
96
- ]);
97
- return {
98
- options
99
- };
100
- }, "useDynamicPositioning");
65
+ }, [height, width]);
66
+ return { options };
67
+ };
101
68
 
102
69
  // src/hooks/useQuadKeyPayloadsToFeatures.tsx
103
70
  import { exists } from "@xylabs/exists";
104
71
  import { GeoJson } from "@xyo-network/sdk-geo";
105
72
  import { useMemo as useMemo3, useState } from "react";
106
- var quadKeyToFeature = /* @__PURE__ */ __name(({ density, quadkey }) => {
73
+ var quadKeyToFeature = ({ density, quadkey }) => {
107
74
  const polygonFeature = new GeoJson(quadkey).polygonFeature();
108
75
  polygonFeature.properties = {
109
76
  count: density,
110
77
  density
111
78
  };
112
79
  return polygonFeature;
113
- }, "quadKeyToFeature");
114
- var setDensity = /* @__PURE__ */ __name((feature) => {
80
+ };
81
+ var setDensity = (feature) => {
115
82
  if (feature.properties) {
116
83
  feature.properties.value = feature.properties.density / 5;
117
84
  }
118
85
  return feature;
119
- }, "setDensity");
120
- var useQuadKeyPayloadsToFeatures = /* @__PURE__ */ __name((payloads) => {
121
- const [multipleFeatureSets, setMultipleFeatureSets] = useState([
122
- []
123
- ]);
86
+ };
87
+ var useQuadKeyPayloadsToFeatures = (payloads) => {
88
+ const [multipleFeatureSets, setMultipleFeatureSets] = useState([[]]);
124
89
  const [features, setFeatures] = useState([]);
125
90
  const [error, setError] = useState();
126
91
  useMemo3(() => {
@@ -137,23 +102,18 @@ var useQuadKeyPayloadsToFeatures = /* @__PURE__ */ __name((payloads) => {
137
102
  const mappedFeatures = singlePayload.result.map(quadKeyToFeature);
138
103
  setFeatures(mappedFeatures.map(setDensity));
139
104
  }
140
- }, [
141
- payloads
142
- ]);
105
+ }, [payloads]);
143
106
  return {
144
107
  error,
145
108
  features,
146
109
  multipleFeatureSets
147
110
  };
148
- }, "useQuadKeyPayloadsToFeatures");
111
+ };
149
112
 
150
113
  // src/MapBoxClasses/MapBase.ts
151
114
  import { assertEx } from "@xylabs/assert";
152
115
  import { GeoJson as GeoJson2 } from "@xyo-network/sdk-geo";
153
116
  var MapBase = class {
154
- static {
155
- __name(this, "MapBase");
156
- }
157
117
  _config;
158
118
  constructor(config) {
159
119
  this._config = {
@@ -166,10 +126,10 @@ var MapBase = class {
166
126
  return !!this._config.map;
167
127
  }
168
128
  initializeMapSource(layer) {
169
- const getSource = /* @__PURE__ */ __name(() => {
129
+ const getSource = () => {
170
130
  const featuresCollection = GeoJson2.featureCollection(this._config.features);
171
131
  return GeoJson2.featuresSource(featuresCollection);
172
- }, "getSource");
132
+ };
173
133
  const existingSource = this._config.map.getSource(layer.source);
174
134
  const source = getSource();
175
135
  if (existingSource) {
@@ -189,9 +149,6 @@ import { forget } from "@xylabs/forget";
189
149
  import { GeoJson as GeoJson3 } from "@xyo-network/sdk-geo";
190
150
  import { LngLatBounds } from "mapbox-gl";
191
151
  var MapHeat = class extends MapBase {
192
- static {
193
- __name(this, "MapHeat");
194
- }
195
152
  // eslint-disable-next-line sonarjs/public-static-readonly
196
153
  static animationStarted = false;
197
154
  config;
@@ -240,7 +197,7 @@ var MapHeat = class extends MapBase {
240
197
  const stepLength = frameLength / steps;
241
198
  const lowUsageColor = startColor ?? "#FFB3B3";
242
199
  const highUsageColor = endColor ?? "#FF0000";
243
- const dynamicFillColor = /* @__PURE__ */ __name((factor2, initialPad2, i) => {
200
+ const dynamicFillColor = (factor2, initialPad2, i) => {
244
201
  const sinFade = Math.sin(i / steps * Math.PI / 2);
245
202
  const cosFade = Math.cos(i / steps * Math.PI / 2);
246
203
  const divisor = factor2 + factor2 * sinFade;
@@ -248,54 +205,27 @@ var MapHeat = class extends MapBase {
248
205
  return [
249
206
  "let",
250
207
  "density",
251
- [
252
- "+",
253
- [
254
- "/",
255
- [
256
- "number",
257
- [
258
- "get",
259
- "value"
260
- ]
261
- ],
262
- divisor
263
- ],
264
- offset
265
- ],
266
- [
267
- "interpolate",
268
- [
269
- "linear"
270
- ],
271
- [
272
- "var",
273
- "density"
274
- ],
275
- 0,
276
- lowUsageColor,
277
- 0.5,
278
- highUsageColor
279
- ]
208
+ ["+", ["/", ["number", ["get", "value"]], divisor], offset],
209
+ ["interpolate", ["linear"], ["var", "density"], 0, lowUsageColor, 0.5, highUsageColor]
280
210
  ];
281
- }, "dynamicFillColor");
211
+ };
282
212
  const fadedIn = layers.map((_) => false);
283
- const fadeIn = /* @__PURE__ */ __name(async (id, index) => {
213
+ const fadeIn = async (id, index) => {
284
214
  for (let i = steps; i >= 1; i--) {
285
215
  map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
286
216
  await delay(stepLength);
287
217
  }
288
218
  fadedIn[index] = true;
289
- }, "fadeIn");
290
- const fadeOut = /* @__PURE__ */ __name(async (id, index) => {
219
+ };
220
+ const fadeOut = async (id, index) => {
291
221
  for (let i = 1; i <= steps; i++) {
292
222
  map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
293
223
  await delay(stepLength);
294
224
  }
295
225
  fadedIn[index] = false;
296
- }, "fadeOut");
226
+ };
297
227
  let started = false;
298
- const startAnimation = /* @__PURE__ */ __name(async () => {
228
+ const startAnimation = async () => {
299
229
  assertEx2(!started, () => "Animation Already Started");
300
230
  started = true;
301
231
  while (this.animationStarted) {
@@ -317,7 +247,7 @@ var MapHeat = class extends MapBase {
317
247
  layerTick++;
318
248
  sourceTick++;
319
249
  }
320
- }, "startAnimation");
250
+ };
321
251
  await startAnimation();
322
252
  }
323
253
  static updateLayer(map, layer, source) {
@@ -331,10 +261,10 @@ var MapHeat = class extends MapBase {
331
261
  }
332
262
  // Build layers each with the same features
333
263
  initializeHeatMapSource(layers) {
334
- const getSource = /* @__PURE__ */ __name((_) => {
264
+ const getSource = (_) => {
335
265
  const featuresCollection = GeoJson3.featureCollection(this.config.features);
336
266
  return GeoJson3.featuresSource(featuresCollection);
337
- }, "getSource");
267
+ };
338
268
  for (const [index, layer] of layers.entries()) {
339
269
  const existingSource = this.config.map.getSource(layer.source);
340
270
  const source = getSource(index);
@@ -352,9 +282,6 @@ var MapHeat = class extends MapBase {
352
282
  // src/MapBoxClasses/MapPoints.ts
353
283
  import { LngLatBounds as LngLatBounds2 } from "mapbox-gl";
354
284
  var MapPoints = class extends MapBase {
355
- static {
356
- __name(this, "MapPoints");
357
- }
358
285
  config;
359
286
  constructor(config) {
360
287
  super(config);
@@ -379,20 +306,17 @@ var MapPoints = class extends MapBase {
379
306
  // src/MapBoxClasses/MapSettings.ts
380
307
  import { GeolocateControl, NavigationControl } from "mapbox-gl";
381
308
  var MapSettings = class _MapSettings {
382
- static {
383
- __name(this, "MapSettings");
384
- }
385
309
  // eslint-disable-next-line sonarjs/public-static-readonly
386
310
  static geoLocateControl;
387
311
  // eslint-disable-next-line sonarjs/public-static-readonly
388
312
  static mapListeners = {
389
- logData: /* @__PURE__ */ __name((ev, map) => {
313
+ logData: (ev, map) => {
390
314
  const target = map || ev?.target;
391
315
  if (target) {
392
316
  console.log("zoom", target.getZoom());
393
317
  console.log("center", target.getCenter());
394
318
  }
395
- }, "logData")
319
+ }
396
320
  };
397
321
  // eslint-disable-next-line sonarjs/public-static-readonly
398
322
  static navControl;
@@ -418,11 +342,7 @@ var MapSettings = class _MapSettings {
418
342
  return this;
419
343
  }
420
344
  static toggleDebugLogging(value, map) {
421
- const debugEvents = [
422
- "resize",
423
- "zoomend",
424
- "dragend"
425
- ];
345
+ const debugEvents = ["resize", "zoomend", "dragend"];
426
346
  if (value) {
427
347
  this.mapListeners.logData(void 0, map);
428
348
  for (const event of debugEvents) map.on(event, this.mapListeners.logData);
@@ -439,24 +359,29 @@ var MapSettings = class _MapSettings {
439
359
  return this;
440
360
  }
441
361
  static updateSettings(config) {
442
- const { settings, map, zoom, requestLocation, debugLayerName = "" } = config;
443
- const { scrollToZoom: scrollToZoom2, enableControls, debugLayer: debugLayer2, debugLogging } = settings;
362
+ const {
363
+ settings,
364
+ map,
365
+ zoom,
366
+ requestLocation,
367
+ debugLayerName = ""
368
+ } = config;
369
+ const {
370
+ scrollToZoom: scrollToZoom2,
371
+ enableControls,
372
+ debugLayer: debugLayer2,
373
+ debugLogging
374
+ } = settings;
444
375
  _MapSettings.toggleControls(enableControls?.value, map, zoom, requestLocation).toggleScrollToZoom(scrollToZoom2?.value, map).toggleDebugLayer(debugLayer2?.value, map, debugLayerName).toggleDebugLogging(debugLogging.value, map);
445
376
  }
446
377
  // Needs to be static so we ensure controls are only instantiated once
447
378
  static addControls(map, zoom, requestLocation) {
448
379
  const geolocateControl = new GeolocateControl({
449
- fitBoundsOptions: {
450
- zoom: zoom || 2
451
- },
452
- positionOptions: {
453
- enableHighAccuracy: true
454
- },
380
+ fitBoundsOptions: { zoom: zoom || 2 },
381
+ positionOptions: { enableHighAccuracy: true },
455
382
  trackUserLocation: true
456
383
  });
457
- const navControl = new NavigationControl({
458
- showCompass: false
459
- });
384
+ const navControl = new NavigationControl({ showCompass: false });
460
385
  this.geoLocateControl = this.geoLocateControl || geolocateControl;
461
386
  this.navControl = this.navControl || navControl;
462
387
  if (!map.hasControl(this.geoLocateControl) && requestLocation) {
@@ -479,68 +404,71 @@ var MapSettings = class _MapSettings {
479
404
  };
480
405
 
481
406
  // src/Contexts/MapBoxInstance/Provider.tsx
482
- import React, { useEffect as useEffect2, useMemo as useMemo4, useState as useState2 } from "react";
407
+ import {
408
+ useEffect as useEffect2,
409
+ useMemo as useMemo4,
410
+ useState as useState2
411
+ } from "react";
483
412
 
484
413
  // src/Contexts/MapBoxInstance/Context.ts
485
414
  import { createContext } from "react";
486
415
  var MapBoxInstanceContext = createContext({});
487
416
 
488
417
  // src/Contexts/MapBoxInstance/Provider.tsx
489
- var MapBoxInstanceProvider = /* @__PURE__ */ __name(({ children }) => {
418
+ import { jsx } from "react/jsx-runtime";
419
+ var MapBoxInstanceProvider = ({ children }) => {
490
420
  const [map, setMapBoxInstance] = useState2();
491
421
  const [mapInitialized, setMapInitialized] = useState2(false);
492
422
  const value = useMemo4(() => ({
493
423
  map,
494
424
  mapInitialized,
495
425
  setMapBoxInstance
496
- }), [
497
- map,
498
- mapInitialized,
499
- setMapBoxInstance
500
- ]);
426
+ }), [map, mapInitialized, setMapBoxInstance]);
501
427
  useEffect2(() => {
502
428
  if (!mapInitialized && map) {
503
429
  map?.on("load", () => {
504
430
  setMapInitialized(true);
505
431
  });
506
432
  }
507
- }, [
508
- map,
509
- mapInitialized,
510
- setMapInitialized
511
- ]);
512
- return /* @__PURE__ */ React.createElement(MapBoxInstanceContext, {
513
- value
514
- }, children);
515
- }, "MapBoxInstanceProvider");
433
+ }, [map, mapInitialized, setMapInitialized]);
434
+ return /* @__PURE__ */ jsx(MapBoxInstanceContext, { value, children });
435
+ };
516
436
 
517
437
  // src/Contexts/MapBoxInstance/useMapBoxInstance.tsx
518
438
  import { assertEx as assertEx3 } from "@xylabs/assert";
519
439
  import { use } from "react";
520
- var useMapBoxInstance = /* @__PURE__ */ __name(() => {
440
+ var useMapBoxInstance = () => {
521
441
  const context = use(MapBoxInstanceContext);
522
442
  assertEx3("map" in context, () => "useMapBoxInstance must be used within a MapBoxInstanceContext");
523
443
  return context;
524
- }, "useMapBoxInstance");
444
+ };
525
445
 
526
446
  // src/Contexts/MapSettings/Provider.tsx
527
- import React2, { useEffect as useEffect3, useMemo as useMemo5, useState as useState3 } from "react";
447
+ import {
448
+ useEffect as useEffect3,
449
+ useMemo as useMemo5,
450
+ useState as useState3
451
+ } from "react";
528
452
 
529
453
  // src/Contexts/MapSettings/Context.ts
530
454
  import { createContext as createContext2 } from "react";
531
455
  var MapSettingsContext = createContext2({});
532
456
 
533
457
  // src/Contexts/MapSettings/Provider.tsx
534
- var MapSettingsProvider = /* @__PURE__ */ __name(({ children, debugLayerName, defaultMapSettings, requestLocation, zoom = 1 }) => {
458
+ import { jsx as jsx2 } from "react/jsx-runtime";
459
+ var MapSettingsProvider = ({
460
+ children,
461
+ debugLayerName,
462
+ defaultMapSettings,
463
+ requestLocation,
464
+ zoom = 1
465
+ }) => {
535
466
  const [mapSettings, setMapSettings] = useState3(defaultMapSettings || {});
536
467
  const { map, mapInitialized } = useMapBoxInstance();
537
468
  const value = useMemo5(() => ({
538
469
  mapSettings,
539
470
  setMapSettings
540
- }), [
541
- mapSettings,
542
- setMapSettings
543
- ]);
471
+ }), [mapSettings, setMapSettings]);
544
472
  useEffect3(() => {
545
473
  if (mapSettings && map && mapInitialized) {
546
474
  MapSettings.updateSettings({
@@ -551,32 +479,33 @@ var MapSettingsProvider = /* @__PURE__ */ __name(({ children, debugLayerName, de
551
479
  zoom
552
480
  });
553
481
  }
554
- }, [
555
- debugLayerName,
556
- map,
557
- mapInitialized,
558
- mapSettings,
559
- requestLocation,
560
- zoom
561
- ]);
562
- return /* @__PURE__ */ React2.createElement(MapSettingsContext, {
563
- value
564
- }, children);
565
- }, "MapSettingsProvider");
482
+ }, [debugLayerName, map, mapInitialized, mapSettings, requestLocation, zoom]);
483
+ return /* @__PURE__ */ jsx2(MapSettingsContext, { value, children });
484
+ };
566
485
 
567
486
  // src/Contexts/MapSettings/useMapSettings.tsx
568
487
  import { use as use2 } from "react";
569
- var useMapSettings = /* @__PURE__ */ __name(() => {
488
+ var useMapSettings = () => {
570
489
  const context = use2(MapSettingsContext);
571
490
  return context;
572
- }, "useMapSettings");
491
+ };
573
492
 
574
493
  // src/Contexts/HeatMapInitializer/Context.ts
575
494
  import { createContext as createContext3 } from "react";
576
495
  var HeatMapInitializerContext = createContext3({});
577
496
 
578
497
  // src/Contexts/HeatMapInitializer/Provider.tsx
579
- var HeatMapInitializerProvider = /* @__PURE__ */ __name(({ children, featureSets, featureSetsLayers, features, fitToPadding, heatMapColorProps, layers, zoom }) => {
498
+ import { jsx as jsx3 } from "react/jsx-runtime";
499
+ var HeatMapInitializerProvider = ({
500
+ children,
501
+ featureSets,
502
+ featureSetsLayers,
503
+ features,
504
+ fitToPadding,
505
+ heatMapColorProps,
506
+ layers,
507
+ zoom
508
+ }) => {
580
509
  const { options } = useDynamicPositioning();
581
510
  const { mapSettings } = useMapSettings();
582
511
  const { map, mapInitialized } = useMapBoxInstance();
@@ -586,18 +515,11 @@ var HeatMapInitializerProvider = /* @__PURE__ */ __name(({ children, featureSets
586
515
  map,
587
516
  zoom
588
517
  }) : void 0;
589
- }, [
590
- map,
591
- features,
592
- zoom
593
- ]);
518
+ }, [map, features, zoom]);
594
519
  const value = useMemo6(() => ({
595
520
  MapHeat: mapHeat,
596
521
  heatMapColorProps
597
- }), [
598
- mapHeat,
599
- heatMapColorProps
600
- ]);
522
+ }), [mapHeat, heatMapColorProps]);
601
523
  useEffect4(() => {
602
524
  if (mapInitialized && featureSets?.length && featureSets[0].length > 0 && map && featureSetsLayers?.length) {
603
525
  const { lowUsageColor, highUsageColor } = heatMapColorProps;
@@ -606,187 +528,94 @@ var HeatMapInitializerProvider = /* @__PURE__ */ __name(({ children, featureSets
606
528
  return () => {
607
529
  MapHeat.animationStarted = false;
608
530
  };
609
- }, [
610
- featureSets,
611
- featureSetsLayers,
612
- mapInitialized,
613
- map,
614
- heatMapColorProps
615
- ]);
531
+ }, [featureSets, featureSetsLayers, mapInitialized, map, heatMapColorProps]);
616
532
  useEffect4(() => {
617
533
  if (mapHeat && mapInitialized && features?.length && layers?.length) {
618
534
  mapHeat.initializeHeatMapSource(layers);
619
535
  }
620
- }, [
621
- mapHeat,
622
- features?.length,
623
- layers,
624
- mapInitialized
625
- ]);
536
+ }, [mapHeat, features?.length, layers, mapInitialized]);
626
537
  useEffect4(() => {
627
538
  if (mapInitialized) {
628
539
  const { fitToPoints: fitToPoints2 } = mapSettings || {};
629
540
  if (map) {
630
541
  if (fitToPoints2?.value === true) {
631
- MapHeat.initialMapPositioning({
632
- padding: {
633
- bottom: fitToPadding,
634
- left: fitToPadding,
635
- right: fitToPadding,
636
- top: fitToPadding
637
- }
638
- }, map, features);
542
+ MapHeat.initialMapPositioning(
543
+ {
544
+ padding: {
545
+ bottom: fitToPadding,
546
+ left: fitToPadding,
547
+ right: fitToPadding,
548
+ top: fitToPadding
549
+ }
550
+ },
551
+ map,
552
+ features
553
+ );
639
554
  } else if (options?.zoom && options.center) {
640
555
  map.setZoom(options.zoom);
641
556
  map.setCenter(options.center);
642
557
  }
643
558
  }
644
559
  }
645
- }, [
646
- mapHeat,
647
- map,
648
- mapSettings,
649
- fitToPadding,
650
- options,
651
- mapInitialized,
652
- features
653
- ]);
654
- return /* @__PURE__ */ React3.createElement(HeatMapInitializerContext, {
655
- value
656
- }, children);
657
- }, "HeatMapInitializerProvider");
560
+ }, [mapHeat, map, mapSettings, fitToPadding, options, mapInitialized, features]);
561
+ return /* @__PURE__ */ jsx3(HeatMapInitializerContext, { value, children });
562
+ };
658
563
 
659
564
  // src/Contexts/HeatMapInitializer/useHeatMapInitializer.tsx
660
565
  import { assertEx as assertEx4 } from "@xylabs/assert";
661
566
  import { use as use3 } from "react";
662
- var useHeatMapInitializer = /* @__PURE__ */ __name(() => {
567
+ var useHeatMapInitializer = () => {
663
568
  const context = use3(HeatMapInitializerContext);
664
569
  assertEx4("heatMapInitialized" in context, () => "useHeatMapInitializer must be used within a HeatMapInitializerContext");
665
570
  return context;
666
- }, "useHeatMapInitializer");
571
+ };
667
572
 
668
573
  // src/Layers/Configs/HeatMapFillLayerConfig.ts
669
- var HeatMapFillLayerConfig = /* @__PURE__ */ __name((color) => ({
574
+ var HeatMapFillLayerConfig = (color) => ({
670
575
  paint: {
671
576
  "fill-color": color,
672
577
  "fill-opacity": [
673
578
  "let",
674
579
  "density",
675
- [
676
- "+",
677
- [
678
- "/",
679
- [
680
- "number",
681
- [
682
- "get",
683
- "value"
684
- ]
685
- ],
686
- 4
687
- ],
688
- 0.125
689
- ],
690
- [
691
- "interpolate",
692
- [
693
- "linear"
694
- ],
695
- [
696
- "var",
697
- "density"
698
- ],
699
- 0.8,
700
- [
701
- "var",
702
- "density"
703
- ],
704
- 1,
705
- 0.85
706
- ]
580
+ ["+", ["/", ["number", ["get", "value"]], 4], 0.125],
581
+ ["interpolate", ["linear"], ["var", "density"], 0.8, ["var", "density"], 1, 0.85]
707
582
  ]
708
583
  }
709
- }), "HeatMapFillLayerConfig");
584
+ });
710
585
 
711
586
  // src/Layers/Configs/HeatMapLineLayerConfig.ts
712
- var HeatMapLineLayerConfig = /* @__PURE__ */ __name((color) => ({
587
+ var HeatMapLineLayerConfig = (color) => ({
713
588
  layout: {
714
589
  // Enable for debugging
715
590
  visibility: "none"
716
591
  },
717
592
  paint: {
718
593
  "line-color": color,
719
- "line-opacity": [
720
- "let",
721
- "density",
722
- 0,
723
- [
724
- "interpolate",
725
- [
726
- "linear"
727
- ],
728
- [
729
- "var",
730
- "density"
731
- ],
732
- 0.8,
733
- [
734
- "var",
735
- "density"
736
- ],
737
- 1,
738
- 0.85
739
- ]
740
- ],
594
+ "line-opacity": ["let", "density", 0, ["interpolate", ["linear"], ["var", "density"], 0.8, ["var", "density"], 1, 0.85]],
741
595
  "line-width": 0.5
742
596
  }
743
- }), "HeatMapLineLayerConfig");
597
+ });
744
598
 
745
599
  // src/Layers/Configs/HeatMapSymbolLayerConfig.ts
746
- var HeatMapSymbolLayerConfig = /* @__PURE__ */ __name((color) => ({
600
+ var HeatMapSymbolLayerConfig = (color) => ({
747
601
  layout: {
748
602
  "text-anchor": "center",
749
603
  "text-field": [
750
604
  "concat",
751
605
  "value: ",
752
- [
753
- "to-string",
754
- [
755
- "+",
756
- [
757
- "/",
758
- [
759
- "number",
760
- [
761
- "get",
762
- "value"
763
- ]
764
- ],
765
- 2
766
- ],
767
- 0.25
768
- ]
769
- ],
606
+ ["to-string", ["+", ["/", ["number", ["get", "value"]], 2], 0.25]],
770
607
  "\n",
771
608
  "count: ",
772
- [
773
- "to-string",
774
- [
775
- "get",
776
- "count"
777
- ]
778
- ]
609
+ ["to-string", ["get", "count"]]
779
610
  ],
780
611
  "text-size": 10,
781
612
  "visibility": "none"
782
613
  },
783
- paint: {
784
- "text-color": color
785
- }
786
- }), "HeatMapSymbolLayerConfig");
614
+ paint: { "text-color": color }
615
+ });
787
616
 
788
617
  // src/Layers/Configs/LocationPointLayerConfig.ts
789
- var LocationPointLayerConfig = /* @__PURE__ */ __name((color, circleRadius, circleOpacity) => {
618
+ var LocationPointLayerConfig = (color, circleRadius, circleOpacity) => {
790
619
  return {
791
620
  paint: {
792
621
  "circle-color": color,
@@ -794,23 +623,17 @@ var LocationPointLayerConfig = /* @__PURE__ */ __name((color, circleRadius, circ
794
623
  "circle-radius": circleRadius
795
624
  }
796
625
  };
797
- }, "LocationPointLayerConfig");
626
+ };
798
627
 
799
628
  // src/Layers/FillLayer.ts
800
629
  import { LayerBase } from "@xyo-network/sdk-geo";
801
630
  var FillLayerBuilder = class extends LayerBase {
802
- static {
803
- __name(this, "FillLayerBuilder");
804
- }
805
631
  FillLayerOptions;
806
632
  // ensures this class passes for `AnyLayer` type in MapBox
807
633
  type = "fill";
808
634
  constructor(id, source, FillLayerOptions) {
809
635
  super(id, source);
810
- this.FillLayerOptions = FillLayerOptions || {
811
- id: this.id,
812
- source: this.source
813
- };
636
+ this.FillLayerOptions = FillLayerOptions || { id: this.id, source: this.source };
814
637
  }
815
638
  buildLayer() {
816
639
  return {
@@ -825,18 +648,12 @@ var FillLayerBuilder = class extends LayerBase {
825
648
  // src/Layers/LineLayer.ts
826
649
  import { LayerBase as LayerBase2 } from "@xyo-network/sdk-geo";
827
650
  var LineLayerBuilder = class extends LayerBase2 {
828
- static {
829
- __name(this, "LineLayerBuilder");
830
- }
831
651
  LineLayerOptions;
832
652
  // ensures this class passes for `AnyLayer` type in MapBox
833
653
  type = "line";
834
654
  constructor(id, source, LineLayerOptions) {
835
655
  super(id, source);
836
- this.LineLayerOptions = LineLayerOptions || {
837
- id: this.id,
838
- source: this.source
839
- };
656
+ this.LineLayerOptions = LineLayerOptions || { id: this.id, source: this.source };
840
657
  }
841
658
  buildLayer() {
842
659
  return {
@@ -852,18 +669,12 @@ var LineLayerBuilder = class extends LayerBase2 {
852
669
  // src/Layers/SymbolLayer.ts
853
670
  import { LayerBase as LayerBase3 } from "@xyo-network/sdk-geo";
854
671
  var SymbolLayerBuilder = class extends LayerBase3 {
855
- static {
856
- __name(this, "SymbolLayerBuilder");
857
- }
858
672
  SymbolLayerOptions;
859
673
  // ensures this class passes for `AnyLayer` type in MapBox
860
674
  type = "symbol";
861
675
  constructor(id, source, SymbolLayerOptions) {
862
676
  super(id, source);
863
- this.SymbolLayerOptions = SymbolLayerOptions || {
864
- id: this.id,
865
- source: this.source
866
- };
677
+ this.SymbolLayerOptions = SymbolLayerOptions || { id: this.id, source: this.source };
867
678
  }
868
679
  buildLayer() {
869
680
  return {
@@ -884,43 +695,43 @@ var MapHeatConstants = {
884
695
  LocationLineLayerId: "location-line-id",
885
696
  LocationLineLayerSource: "location-line-source"
886
697
  };
887
- var LocationHeatMapLayerBuilder = /* @__PURE__ */ __name((color, alternateColor = "#000") => {
888
- const { LocationFillLayerId, LocationFillLayerSource, LocationLineLayerId, LocationLineLayerSource, LocationDebugLayerId, LocationDebugLayerSource } = MapHeatConstants;
698
+ var LocationHeatMapLayerBuilder = (color, alternateColor = "#000") => {
699
+ const {
700
+ LocationFillLayerId,
701
+ LocationFillLayerSource,
702
+ LocationLineLayerId,
703
+ LocationLineLayerSource,
704
+ LocationDebugLayerId,
705
+ LocationDebugLayerSource
706
+ } = MapHeatConstants;
889
707
  const fillLayerConfig = HeatMapFillLayerConfig(color);
890
708
  const lineLayerConfig = HeatMapLineLayerConfig(color);
891
709
  const debugLayerConfig = HeatMapSymbolLayerConfig(alternateColor);
892
710
  const fillLayer = new FillLayerBuilder(LocationFillLayerId, LocationFillLayerSource, fillLayerConfig);
893
711
  const lineLayer = new LineLayerBuilder(LocationLineLayerId, LocationLineLayerSource, lineLayerConfig);
894
712
  const debugLayer2 = new SymbolLayerBuilder(LocationDebugLayerId, LocationDebugLayerSource, debugLayerConfig);
895
- return [
896
- fillLayer,
897
- lineLayer,
898
- debugLayer2
899
- ];
900
- }, "LocationHeatMapLayerBuilder");
713
+ return [fillLayer, lineLayer, debugLayer2];
714
+ };
901
715
 
902
716
  // src/Layers/Builders/LocationHeatMapLayerBuilderAnimated.ts
903
- var MapHeatConstants2 = /* @__PURE__ */ __name((index, type) => ({
717
+ var MapHeatConstants2 = (index, type) => ({
904
718
  LocationDebugLayerId: `location-${type}-debug-id-${index}`,
905
719
  LocationDebugLayerSource: `location-${type}-debug-source-${index}`,
906
720
  LocationFillLayerId: `location-${type}-fill-id-${index}`,
907
721
  LocationFillLayerSource: `location-${type}-fill-source-${index}`,
908
722
  LocationLineLayerId: `location-${type}-line-id-${index}`,
909
723
  LocationLineLayerSource: `location-${type}-line-source-${index}`
910
- }), "MapHeatConstants");
911
- var LocationHeatMapLayerBuilderAnimated = /* @__PURE__ */ __name((color, index, type = "") => {
724
+ });
725
+ var LocationHeatMapLayerBuilderAnimated = (color, index, type = "") => {
912
726
  const { LocationFillLayerId, LocationFillLayerSource } = MapHeatConstants2(index, type);
913
727
  const fillLayerConfig = HeatMapFillLayerConfig(color);
914
728
  const fillLayer = new FillLayerBuilder(LocationFillLayerId, LocationFillLayerSource, fillLayerConfig);
915
729
  return fillLayer;
916
- }, "LocationHeatMapLayerBuilderAnimated");
730
+ };
917
731
 
918
732
  // src/Layers/CircleLayer.ts
919
733
  import { LayerBase as LayerBase4 } from "@xyo-network/sdk-geo";
920
734
  var CircleLayerBuilder = class extends LayerBase4 {
921
- static {
922
- __name(this, "CircleLayerBuilder");
923
- }
924
735
  CircleLayerOptions;
925
736
  // ensures this class passes for `AnyLayer` type in MapBox
926
737
  type = "circle";
@@ -934,11 +745,7 @@ var CircleLayerBuilder = class extends LayerBase4 {
934
745
  }
935
746
  buildLayer() {
936
747
  return {
937
- filter: [
938
- "==",
939
- "$type",
940
- "Point"
941
- ],
748
+ filter: ["==", "$type", "Point"],
942
749
  layout: {},
943
750
  paint: {
944
751
  "circle-color": "#ff0000",
@@ -957,25 +764,33 @@ var MapPointsConstants = {
957
764
  LocationDotsLayerId: "location-dots",
958
765
  LocationDotsLayerSource: "location-dots-source"
959
766
  };
960
- var LocationPointsMapLayerBuilder = /* @__PURE__ */ __name((color, circleRadius = 6, circleOpacity = 0.8) => {
767
+ var LocationPointsMapLayerBuilder = (color, circleRadius = 6, circleOpacity = 0.8) => {
961
768
  const { LocationDotsLayerId, LocationDotsLayerSource } = MapPointsConstants;
962
769
  const dotLayerConfig = LocationPointLayerConfig(color, circleRadius, circleOpacity);
963
770
  const dotLayer = new CircleLayerBuilder(LocationDotsLayerId, LocationDotsLayerSource, dotLayerConfig);
964
- return [
965
- dotLayer
966
- ];
967
- }, "LocationPointsMapLayerBuilder");
771
+ return [dotLayer];
772
+ };
968
773
 
969
774
  // src/Components/MapBoxHeat.tsx
970
775
  import { FlexCol } from "@xylabs/react-flexbox";
971
- import React7 from "react";
972
776
 
973
777
  // src/Components/MapBox.tsx
974
778
  import "mapbox-gl/dist/mapbox-gl.css";
975
779
  import { MapStyle } from "@xyo-network/react-map-model";
976
780
  import { Map } from "mapbox-gl";
977
- import React4, { useEffect as useEffect5, useRef, useState as useState4 } from "react";
978
- var MapBox = /* @__PURE__ */ __name(({ accessToken, darkMode = false, options, zoom = 2, ...props }) => {
781
+ import {
782
+ useEffect as useEffect5,
783
+ useRef,
784
+ useState as useState4
785
+ } from "react";
786
+ import { jsx as jsx4 } from "react/jsx-runtime";
787
+ var MapBox = ({
788
+ accessToken,
789
+ darkMode = false,
790
+ options,
791
+ zoom = 2,
792
+ ...props
793
+ }) => {
979
794
  const [map, setMap] = useState4();
980
795
  const mapContainerRef = useRef(null);
981
796
  const mapCanvasRef = useRef(null);
@@ -989,18 +804,11 @@ var MapBox = /* @__PURE__ */ __name(({ accessToken, darkMode = false, options, z
989
804
  } else {
990
805
  map?.setStyle(`mapbox://styles/${darkMode ? MapStyle.Dark : MapStyle.Light}`);
991
806
  }
992
- }, [
993
- map,
994
- darkMode,
995
- mapSettings
996
- ]);
807
+ }, [map, darkMode, mapSettings]);
997
808
  useEffect5(() => {
998
809
  const map2 = new Map({
999
810
  accessToken,
1000
- center: [
1001
- 0,
1002
- 0
1003
- ],
811
+ center: [0, 0],
1004
812
  container: mapContainerRef.current ?? "",
1005
813
  style: `mapbox://styles/${MapStyle.Light}`,
1006
814
  zoom,
@@ -1014,201 +822,202 @@ var MapBox = /* @__PURE__ */ __name(({ accessToken, darkMode = false, options, z
1014
822
  console.log("Removing Map");
1015
823
  map2.remove();
1016
824
  };
1017
- }, [
1018
- mapContainerRef,
1019
- setMap,
1020
- options,
1021
- zoom,
1022
- setMapBoxInstance,
1023
- accessToken
1024
- ]);
1025
- return /* @__PURE__ */ React4.createElement("div", {
1026
- ref: /* @__PURE__ */ __name((el) => {
1027
- mapContainerRef.current = el;
1028
- }, "ref"),
1029
- style: {
1030
- bottom: 0,
1031
- left: 0,
1032
- position: "absolute",
1033
- right: 0,
1034
- top: 0,
1035
- ...props
825
+ }, [mapContainerRef, setMap, options, zoom, setMapBoxInstance, accessToken]);
826
+ return /* @__PURE__ */ jsx4(
827
+ "div",
828
+ {
829
+ ref: (el) => {
830
+ mapContainerRef.current = el;
831
+ },
832
+ style: {
833
+ bottom: 0,
834
+ left: 0,
835
+ position: "absolute",
836
+ right: 0,
837
+ top: 0,
838
+ ...props
839
+ }
1036
840
  }
1037
- });
1038
- }, "MapBox");
841
+ );
842
+ };
1039
843
 
1040
844
  // src/Components/MapSettingsComponents/Setting.tsx
1041
845
  import { FormControlLabel, Switch } from "@mui/material";
1042
- import React5 from "react";
1043
- var MapSettingSwitch = /* @__PURE__ */ __name(({ developerMode, field, ...props }) => {
846
+ import { jsx as jsx5 } from "react/jsx-runtime";
847
+ var MapSettingSwitch = ({
848
+ developerMode,
849
+ field,
850
+ ...props
851
+ }) => {
1044
852
  const { mapSettings, setMapSettings } = useMapSettings();
1045
853
  const setting = mapSettings?.[field];
1046
- const onLocalChange = /* @__PURE__ */ __name((event) => {
854
+ const onLocalChange = (event) => {
1047
855
  if (setting) {
1048
856
  setMapSettings?.((previous) => {
1049
857
  previous[setting.field].value = event.target.checked;
1050
- return {
1051
- ...previous
1052
- };
858
+ return { ...previous };
1053
859
  });
1054
860
  }
1055
- }, "onLocalChange");
861
+ };
1056
862
  if (setting?.devMode && developerMode === false) {
1057
863
  return null;
1058
864
  }
1059
- return setting?.hidden ? null : /* @__PURE__ */ React5.createElement(FormControlLabel, {
1060
- label: setting?.label,
1061
- control: /* @__PURE__ */ React5.createElement(Switch, {
1062
- checked: setting?.value,
1063
- onChange: onLocalChange,
1064
- ...props
1065
- })
1066
- });
1067
- }, "MapSettingSwitch");
865
+ return setting?.hidden ? null : /* @__PURE__ */ jsx5(FormControlLabel, { label: setting?.label, control: /* @__PURE__ */ jsx5(Switch, { checked: setting?.value, onChange: onLocalChange, ...props }) });
866
+ };
1068
867
 
1069
868
  // src/Components/MapSettingsComponents/SettingsBox.tsx
1070
869
  import { Paper, Stack } from "@mui/material";
1071
870
  import { useAppSettings } from "@xylabs/react-app-settings";
1072
871
  import { FlexGrowRow, FlexRow } from "@xylabs/react-flexbox";
1073
- import React6 from "react";
1074
- var MapSettingsBox = /* @__PURE__ */ __name(({ developerMode, ...props }) => {
872
+ import { jsx as jsx6 } from "react/jsx-runtime";
873
+ var MapSettingsBox = ({ developerMode, ...props }) => {
1075
874
  const { mapSettings } = useMapSettings();
1076
875
  const { developerMode: devModeFromContext } = useAppSettings();
1077
876
  const resolveDeveloperMode = developerMode ?? devModeFromContext;
1078
- return mapSettings && resolveDeveloperMode ? /* @__PURE__ */ React6.createElement(FlexGrowRow, {
1079
- bottom: 36,
1080
- left: 10,
1081
- position: "absolute",
1082
- ...props
1083
- }, /* @__PURE__ */ React6.createElement(FlexRow, {
1084
- paddingX: 2
1085
- }, /* @__PURE__ */ React6.createElement(Paper, null, /* @__PURE__ */ React6.createElement(Stack, {
1086
- direction: "row",
1087
- spacing: 1,
1088
- marginX: 1
1089
- }, Object.keys(mapSettings).map((key, index) => {
1090
- return /* @__PURE__ */ React6.createElement(MapSettingSwitch, {
1091
- key: index,
1092
- field: mapSettings[key].field,
1093
- developerMode
1094
- });
1095
- }))))) : null;
1096
- }, "MapSettingsBox");
877
+ return mapSettings && resolveDeveloperMode ? /* @__PURE__ */ jsx6(FlexGrowRow, { bottom: 36, left: 10, position: "absolute", ...props, children: /* @__PURE__ */ jsx6(FlexRow, { paddingX: 2, children: /* @__PURE__ */ jsx6(Paper, { children: /* @__PURE__ */ jsx6(Stack, { direction: "row", spacing: 1, marginX: 1, children: Object.keys(mapSettings).map((key, index) => {
878
+ return /* @__PURE__ */ jsx6(MapSettingSwitch, { field: mapSettings[key].field, developerMode }, index);
879
+ }) }) }) }) }) : null;
880
+ };
1097
881
 
1098
882
  // src/Components/MapBoxHeat.tsx
1099
- var MapboxHeatFlexBox = /* @__PURE__ */ __name(({ accessToken, children, mapBoxOptions, zoom, legend, developerMode, ...props }) => {
1100
- return /* @__PURE__ */ React7.createElement(FlexCol, props, /* @__PURE__ */ React7.createElement(MapBox, {
1101
- accessToken,
1102
- options: mapBoxOptions,
1103
- zoom
1104
- }), /* @__PURE__ */ React7.createElement(MapSettingsBox, {
1105
- developerMode
1106
- }), legend, children);
1107
- }, "MapboxHeatFlexBox");
883
+ import { jsx as jsx7, jsxs } from "react/jsx-runtime";
884
+ var MapboxHeatFlexBox = ({
885
+ accessToken,
886
+ children,
887
+ mapBoxOptions,
888
+ zoom,
889
+ legend,
890
+ developerMode,
891
+ ...props
892
+ }) => {
893
+ return /* @__PURE__ */ jsxs(FlexCol, { ...props, children: [
894
+ /* @__PURE__ */ jsx7(MapBox, { accessToken, options: mapBoxOptions, zoom }),
895
+ /* @__PURE__ */ jsx7(MapSettingsBox, { developerMode }),
896
+ legend,
897
+ children
898
+ ] });
899
+ };
1108
900
 
1109
901
  // src/Components/AnimatedHeatMap.tsx
1110
- var AnimatedHeatMap = /* @__PURE__ */ __name(({ accessToken, animatedFeatureSets, defaultMapSettings, heatMapColorProps, staticFeatureSet, ...props }) => {
902
+ import { jsx as jsx8 } from "react/jsx-runtime";
903
+ var AnimatedHeatMap = ({
904
+ accessToken,
905
+ animatedFeatureSets,
906
+ defaultMapSettings,
907
+ heatMapColorProps,
908
+ staticFeatureSet,
909
+ ...props
910
+ }) => {
1111
911
  const theme = useTheme();
1112
- const { staticMapColor, lowUsageColor, highUsageColor } = heatMapColorProps || {};
912
+ const {
913
+ staticMapColor,
914
+ lowUsageColor,
915
+ highUsageColor
916
+ } = heatMapColorProps || {};
1113
917
  const localStaticMapColor = staticMapColor ?? theme.vars.palette.primary.light;
1114
918
  const [layers] = useState5(() => [
1115
919
  LocationHeatMapLayerBuilderAnimated(localStaticMapColor, 0, "static"),
1116
920
  LocationHeatMapLayerBuilderAnimated(lowUsageColor || localStaticMapColor, 0, "animated"),
1117
921
  LocationHeatMapLayerBuilderAnimated(highUsageColor || darkenCss(localStaticMapColor, 0.9), 1, "animated")
1118
922
  ]);
1119
- return animatedFeatureSets?.length ? /* @__PURE__ */ React8.createElement(MapBoxInstanceProvider, null, /* @__PURE__ */ React8.createElement(MapSettingsProvider, {
1120
- defaultMapSettings,
1121
- debugLayerName: MapHeatConstants.LocationDebugLayerId
1122
- }, /* @__PURE__ */ React8.createElement(HeatMapInitializerProvider, {
1123
- features: staticFeatureSet,
1124
- layers: [
1125
- layers[0]
1126
- ],
1127
- featureSets: animatedFeatureSets,
1128
- featureSetsLayers: layers.slice(1, 3),
1129
- heatMapColorProps
1130
- }, /* @__PURE__ */ React8.createElement(MapboxHeatFlexBox, {
1131
- accessToken,
1132
- ...props
1133
- })))) : /* @__PURE__ */ React8.createElement(FlexCol2, {
1134
- minHeight: 160,
1135
- minWidth: 160,
1136
- busy: true
1137
- });
1138
- }, "AnimatedHeatMap");
923
+ return animatedFeatureSets?.length ? /* @__PURE__ */ jsx8(MapBoxInstanceProvider, { children: /* @__PURE__ */ jsx8(MapSettingsProvider, { defaultMapSettings, debugLayerName: MapHeatConstants.LocationDebugLayerId, children: /* @__PURE__ */ jsx8(
924
+ HeatMapInitializerProvider,
925
+ {
926
+ features: staticFeatureSet,
927
+ layers: [layers[0]],
928
+ featureSets: animatedFeatureSets,
929
+ featureSetsLayers: layers.slice(1, 3),
930
+ heatMapColorProps,
931
+ children: /* @__PURE__ */ jsx8(MapboxHeatFlexBox, { accessToken, ...props })
932
+ }
933
+ ) }) }) : /* @__PURE__ */ jsx8(FlexCol2, { minHeight: 160, minWidth: 160, busy: true });
934
+ };
1139
935
 
1140
936
  // src/Components/AnimatedHeatMapLoaded.tsx
1141
937
  import { Alert, AlertTitle } from "@mui/material";
1142
938
  import { FlexCol as FlexCol5 } from "@xylabs/react-flexbox";
1143
939
  import { useWeakArchivistFromNode, useWeakArchivistGet } from "@xyo-network/react-archivist";
1144
- import { AnimatedHeatMapSettings, useFindHashes, useHeatMapColors } from "@xyo-network/react-map-model";
1145
- import React11 from "react";
940
+ import {
941
+ AnimatedHeatMapSettings,
942
+ useFindHashes,
943
+ useHeatMapColors
944
+ } from "@xyo-network/react-map-model";
1146
945
 
1147
946
  // src/Components/Legend.tsx
1148
947
  import { useMediaQuery, useTheme as useTheme3 } from "@mui/material";
1149
948
  import { FlexCol as FlexCol4 } from "@xylabs/react-flexbox";
1150
- import React10 from "react";
1151
949
 
1152
950
  // src/Components/Legends/ColorGradient.tsx
1153
951
  import { Typography, useTheme as useTheme2 } from "@mui/material";
1154
952
  import { FlexCol as FlexCol3, FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
1155
- import React9 from "react";
1156
- var ColorGradientLegend = /* @__PURE__ */ __name(({ startColor, endColor, startLabel, endLabel, heading, textColor, ...props }) => {
953
+ import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
954
+ var ColorGradientLegend = ({
955
+ startColor,
956
+ endColor,
957
+ startLabel,
958
+ endLabel,
959
+ heading,
960
+ textColor,
961
+ ...props
962
+ }) => {
1157
963
  const theme = useTheme2();
1158
- return /* @__PURE__ */ React9.createElement(FlexCol3, props, /* @__PURE__ */ React9.createElement(Typography, {
1159
- mb: theme.spacing(0.25),
1160
- color: textColor,
1161
- variant: "caption",
1162
- textAlign: "center"
1163
- }, heading), /* @__PURE__ */ React9.createElement(FlexCol3, {
1164
- flexGrow: 1,
1165
- alignItems: "stretch",
1166
- paddingX: theme.spacing(1),
1167
- mb: theme.spacing(0.25)
1168
- }, /* @__PURE__ */ React9.createElement(FlexCol3, {
1169
- height: theme.spacing(0.75),
1170
- border: `1px solid ${textColor}`,
1171
- sx: {
1172
- backgroundImage: `linear-gradient(to right, ${startColor},${endColor})`
1173
- }
1174
- })), /* @__PURE__ */ React9.createElement(FlexRow2, {
1175
- flexGrow: 1,
1176
- justifyContent: "space-between"
1177
- }, /* @__PURE__ */ React9.createElement(Typography, {
1178
- color: textColor,
1179
- variant: "caption"
1180
- }, startLabel), /* @__PURE__ */ React9.createElement(Typography, {
1181
- color: textColor,
1182
- variant: "caption"
1183
- }, endLabel)));
1184
- }, "ColorGradientLegend");
964
+ return /* @__PURE__ */ jsxs2(FlexCol3, { ...props, children: [
965
+ /* @__PURE__ */ jsx9(Typography, { mb: theme.spacing(0.25), color: textColor, variant: "caption", textAlign: "center", children: heading }),
966
+ /* @__PURE__ */ jsx9(FlexCol3, { flexGrow: 1, alignItems: "stretch", paddingX: theme.spacing(1), mb: theme.spacing(0.25), children: /* @__PURE__ */ jsx9(
967
+ FlexCol3,
968
+ {
969
+ height: theme.spacing(0.75),
970
+ border: `1px solid ${textColor}`,
971
+ sx: { backgroundImage: `linear-gradient(to right, ${startColor},${endColor})` }
972
+ }
973
+ ) }),
974
+ /* @__PURE__ */ jsxs2(FlexRow2, { flexGrow: 1, justifyContent: "space-between", children: [
975
+ /* @__PURE__ */ jsx9(Typography, { color: textColor, variant: "caption", children: startLabel }),
976
+ /* @__PURE__ */ jsx9(Typography, { color: textColor, variant: "caption", children: endLabel })
977
+ ] })
978
+ ] });
979
+ };
1185
980
 
1186
981
  // src/Components/Legend.tsx
1187
- var AnimatedHeatMapLegend = /* @__PURE__ */ __name(({ ...legendProps }) => {
1188
- const { startColor, endColor, startLabel, endLabel, heading, textColor } = legendProps;
1189
- const theme = useTheme3();
1190
- const isSmall = useMediaQuery(theme.breakpoints.down("sm"));
1191
- return /* @__PURE__ */ React10.createElement(FlexCol4, {
1192
- position: "absolute",
1193
- bottom: 0,
1194
- right: 0
1195
- }, /* @__PURE__ */ React10.createElement(ColorGradientLegend, {
982
+ import { jsx as jsx10 } from "react/jsx-runtime";
983
+ var AnimatedHeatMapLegend = ({ ...legendProps }) => {
984
+ const {
1196
985
  startColor,
1197
986
  endColor,
1198
987
  startLabel,
1199
988
  endLabel,
1200
989
  heading,
1201
- textColor,
1202
- alignItems: "stretch",
1203
- marginBottom: theme.spacing(4),
1204
- marginLeft: isSmall ? theme.spacing(3) : 0,
1205
- marginRight: isSmall ? theme.spacing(2) : theme.spacing(3),
1206
- width: isSmall ? "40vw" : theme.spacing(18)
1207
- }));
1208
- }, "AnimatedHeatMapLegend");
990
+ textColor
991
+ } = legendProps;
992
+ const theme = useTheme3();
993
+ const isSmall = useMediaQuery(theme.breakpoints.down("sm"));
994
+ return /* @__PURE__ */ jsx10(FlexCol4, { position: "absolute", bottom: 0, right: 0, children: /* @__PURE__ */ jsx10(
995
+ ColorGradientLegend,
996
+ {
997
+ startColor,
998
+ endColor,
999
+ startLabel,
1000
+ endLabel,
1001
+ heading,
1002
+ textColor,
1003
+ ...{
1004
+ alignItems: "stretch",
1005
+ marginBottom: theme.spacing(4),
1006
+ marginLeft: isSmall ? theme.spacing(3) : 0,
1007
+ marginRight: isSmall ? theme.spacing(2) : theme.spacing(3),
1008
+ width: isSmall ? "40vw" : theme.spacing(18)
1009
+ }
1010
+ }
1011
+ ) });
1012
+ };
1209
1013
 
1210
1014
  // src/Components/AnimatedHeatMapLoaded.tsx
1211
- var AnimatedHeatMapLoaded = /* @__PURE__ */ __name(({ accessToken, archivistNameOrAddress, ...props }) => {
1015
+ import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
1016
+ var AnimatedHeatMapLoaded = ({
1017
+ accessToken,
1018
+ archivistNameOrAddress,
1019
+ ...props
1020
+ }) => {
1212
1021
  const hashes = useFindHashes();
1213
1022
  const [archivist] = useWeakArchivistFromNode(archivistNameOrAddress);
1214
1023
  const [payloads, xyoError] = useWeakArchivistGet(archivist, hashes);
@@ -1216,69 +1025,82 @@ var AnimatedHeatMapLoaded = /* @__PURE__ */ __name(({ accessToken, archivistName
1216
1025
  const { heatMapColorProps, legendProps } = useHeatMapColors();
1217
1026
  const MapBoxHeatProps = {
1218
1027
  flexGrow: 1,
1219
- legend: legendProps ? /* @__PURE__ */ React11.createElement(AnimatedHeatMapLegend, legendProps) : null
1028
+ legend: legendProps ? /* @__PURE__ */ jsx11(AnimatedHeatMapLegend, { ...legendProps }) : null
1220
1029
  };
1221
- return /* @__PURE__ */ React11.createElement(FlexCol5, {
1222
- alignItems: "stretch",
1223
- ...props
1224
- }, xyoError ? /* @__PURE__ */ React11.createElement(Alert, {
1225
- sx: {
1226
- mt: 2
1227
- }
1228
- }, /* @__PURE__ */ React11.createElement(AlertTitle, null, "Error Loading Map"), xyoError.message ? `Error: ${xyoError.message}` : null, "You might try authenticating again.") : null, hashes === void 0 ? /* @__PURE__ */ React11.createElement(Alert, null, "Missing answer hash for heat map query") : /* @__PURE__ */ React11.createElement(AnimatedHeatMap, {
1229
- accessToken,
1230
- defaultMapSettings: AnimatedHeatMapSettings,
1231
- animatedFeatureSets: multipleFeatureSets.slice(1),
1232
- staticFeatureSet: multipleFeatureSets[0],
1233
- heatMapColorProps,
1234
- ...MapBoxHeatProps
1235
- }));
1236
- }, "AnimatedHeatMapLoaded");
1030
+ return /* @__PURE__ */ jsxs3(FlexCol5, { alignItems: "stretch", ...props, children: [
1031
+ xyoError ? /* @__PURE__ */ jsxs3(Alert, { sx: { mt: 2 }, children: [
1032
+ /* @__PURE__ */ jsx11(AlertTitle, { children: "Error Loading Map" }),
1033
+ xyoError.message ? `Error: ${xyoError.message}` : null,
1034
+ "You might try authenticating again."
1035
+ ] }) : null,
1036
+ hashes === void 0 ? /* @__PURE__ */ jsx11(Alert, { children: "Missing answer hash for heat map query" }) : /* @__PURE__ */ jsx11(
1037
+ AnimatedHeatMap,
1038
+ {
1039
+ accessToken,
1040
+ defaultMapSettings: AnimatedHeatMapSettings,
1041
+ animatedFeatureSets: multipleFeatureSets.slice(1),
1042
+ staticFeatureSet: multipleFeatureSets[0],
1043
+ heatMapColorProps,
1044
+ ...MapBoxHeatProps
1045
+ }
1046
+ )
1047
+ ] });
1048
+ };
1237
1049
 
1238
1050
  // src/Components/HeatMapSettings.ts
1239
1051
  import { DefaultMapSettings } from "@xyo-network/react-map-model";
1240
1052
  var HeatMapSettings = DefaultMapSettings();
1241
- var { debugLayer, scrollToZoom, fitToPoints } = HeatMapSettings;
1053
+ var {
1054
+ debugLayer,
1055
+ scrollToZoom,
1056
+ fitToPoints
1057
+ } = HeatMapSettings;
1242
1058
  debugLayer.hidden = false;
1243
1059
  scrollToZoom.value = true;
1244
1060
  fitToPoints.value = true;
1245
1061
 
1246
1062
  // src/Components/LayerAnimator.tsx
1247
1063
  import { useInterval } from "@xylabs/react-shared";
1248
- import React12, { useCallback, useEffect as useEffect6, useMemo as useMemo7, useRef as useRef2 } from "react";
1064
+ import {
1065
+ useCallback,
1066
+ useEffect as useEffect6,
1067
+ useMemo as useMemo7,
1068
+ useRef as useRef2
1069
+ } from "react";
1070
+ import { Fragment, jsx as jsx12 } from "react/jsx-runtime";
1249
1071
  var timeIncrement = 2e3;
1250
1072
  var animatedLayerCount = 3;
1251
- var LayerAnimator = /* @__PURE__ */ __name(({ animateLayers, children, layers, layersInitialized, map }) => {
1073
+ var LayerAnimator = ({
1074
+ animateLayers,
1075
+ children,
1076
+ layers,
1077
+ layersInitialized,
1078
+ map
1079
+ }) => {
1252
1080
  const layerIndexQueue = useRef2([]);
1253
1081
  const fillLayers = useMemo7(() => {
1254
1082
  if (layers?.length && map && layersInitialized) {
1255
1083
  return layers.filter((layer) => {
1256
1084
  const fillLayer = layer.id.startsWith("location-fill");
1257
1085
  if (fillLayer) {
1258
- map.setPaintProperty(layer.id, "fill-opacity-transition", {
1259
- delay: 0,
1260
- duration: 4e3
1261
- });
1086
+ map.setPaintProperty(layer.id, "fill-opacity-transition", { delay: 0, duration: 4e3 });
1262
1087
  }
1263
1088
  return fillLayer;
1264
1089
  });
1265
1090
  }
1266
1091
  return [];
1267
- }, [
1268
- layers,
1269
- layersInitialized,
1270
- map
1271
- ]);
1272
- const incrementQueue = useCallback((index) => {
1273
- if (fillLayers[index]) {
1274
- layerIndexQueue.current.push(index);
1275
- } else {
1276
- layerIndexQueue.current.push(0);
1277
- }
1278
- return layerIndexQueue.current.at(-1);
1279
- }, [
1280
- fillLayers
1281
- ]);
1092
+ }, [layers, layersInitialized, map]);
1093
+ const incrementQueue = useCallback(
1094
+ (index) => {
1095
+ if (fillLayers[index]) {
1096
+ layerIndexQueue.current.push(index);
1097
+ } else {
1098
+ layerIndexQueue.current.push(0);
1099
+ }
1100
+ return layerIndexQueue.current.at(-1);
1101
+ },
1102
+ [fillLayers]
1103
+ );
1282
1104
  const lastQueuedIndex = useCallback(() => {
1283
1105
  const last = layerIndexQueue.current.at(-1);
1284
1106
  if (last === void 0) {
@@ -1287,9 +1109,7 @@ var LayerAnimator = /* @__PURE__ */ __name(({ animateLayers, children, layers, l
1287
1109
  } else {
1288
1110
  return last;
1289
1111
  }
1290
- }, [
1291
- incrementQueue
1292
- ]);
1112
+ }, [incrementQueue]);
1293
1113
  const unshiftQueue = useCallback(() => {
1294
1114
  layerIndexQueue.current.shift();
1295
1115
  }, []);
@@ -1297,25 +1117,21 @@ var LayerAnimator = /* @__PURE__ */ __name(({ animateLayers, children, layers, l
1297
1117
  const nextLayer = fillLayers[lastQueuedIndex()];
1298
1118
  incrementQueue(lastQueuedIndex() + 1);
1299
1119
  return nextLayer;
1300
- }, [
1301
- fillLayers,
1302
- incrementQueue,
1303
- lastQueuedIndex
1304
- ]);
1305
- const layerAnimateWorker = useCallback((layer) => {
1306
- if (layer) {
1307
- map?.setPaintProperty(layer.id, "fill-opacity", 0.85);
1308
- setTimeout(() => {
1309
- map?.setPaintProperty(layer.id, "fill-opacity", 0);
1310
- unshiftQueue();
1311
- }, timeIncrement * 2);
1312
- } else {
1313
- console.warn("tried to queue an empty layer");
1314
- }
1315
- }, [
1316
- map,
1317
- unshiftQueue
1318
- ]);
1120
+ }, [fillLayers, incrementQueue, lastQueuedIndex]);
1121
+ const layerAnimateWorker = useCallback(
1122
+ (layer) => {
1123
+ if (layer) {
1124
+ map?.setPaintProperty(layer.id, "fill-opacity", 0.85);
1125
+ setTimeout(() => {
1126
+ map?.setPaintProperty(layer.id, "fill-opacity", 0);
1127
+ unshiftQueue();
1128
+ }, timeIncrement * 2);
1129
+ } else {
1130
+ console.warn("tried to queue an empty layer");
1131
+ }
1132
+ },
1133
+ [map, unshiftQueue]
1134
+ );
1319
1135
  const queueLayerAnimation = useCallback(() => {
1320
1136
  const animatedLayers = [];
1321
1137
  for (let i = 0; i < animatedLayerCount; i++) {
@@ -1330,64 +1146,58 @@ var LayerAnimator = /* @__PURE__ */ __name(({ animateLayers, children, layers, l
1330
1146
  }, timeIncrement * index);
1331
1147
  }
1332
1148
  }
1333
- }, [
1334
- getNextLayer,
1335
- layerAnimateWorker
1336
- ]);
1149
+ }, [getNextLayer, layerAnimateWorker]);
1337
1150
  useEffect6(() => {
1338
1151
  if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
1339
1152
  queueLayerAnimation();
1340
1153
  }
1341
- }, [
1342
- animateLayers,
1343
- fillLayers.length,
1344
- layersInitialized,
1345
- map,
1346
- queueLayerAnimation
1347
- ]);
1154
+ }, [animateLayers, fillLayers.length, layersInitialized, map, queueLayerAnimation]);
1348
1155
  useInterval(() => {
1349
1156
  if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
1350
1157
  queueLayerAnimation();
1351
1158
  }
1352
1159
  }, timeIncrement * animatedLayerCount);
1353
- return /* @__PURE__ */ React12.createElement(React12.Fragment, null, children);
1354
- }, "LayerAnimator");
1160
+ return /* @__PURE__ */ jsx12(Fragment, { children });
1161
+ };
1355
1162
 
1356
1163
  // src/Components/MapBoxPoints.tsx
1357
1164
  import { Alert as Alert2 } from "@mui/material";
1358
1165
  import { FlexCol as FlexCol6 } from "@xylabs/react-flexbox";
1359
- import React13, { useCallback as useCallback2, useEffect as useEffect7, useMemo as useMemo8 } from "react";
1360
- var MapboxPointsFlexBox = /* @__PURE__ */ __name(({ accessToken, features, fitToPointsPadding = 20, layers, zoom, ...props }) => {
1166
+ import {
1167
+ useCallback as useCallback2,
1168
+ useEffect as useEffect7,
1169
+ useMemo as useMemo8
1170
+ } from "react";
1171
+ import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs4 } from "react/jsx-runtime";
1172
+ var MapboxPointsFlexBox = ({
1173
+ accessToken,
1174
+ features,
1175
+ fitToPointsPadding = 20,
1176
+ layers,
1177
+ zoom,
1178
+ ...props
1179
+ }) => {
1361
1180
  const { mapSettings } = useMapSettings();
1362
1181
  const { map, mapInitialized } = useMapBoxInstance();
1363
- const customFitToBoundsOptions = /* @__PURE__ */ __name((zoom2) => {
1182
+ const customFitToBoundsOptions = (zoom2) => {
1364
1183
  if (zoom2 !== void 0) {
1365
- return {
1366
- maxZoom: zoom2
1367
- };
1184
+ return { maxZoom: zoom2 };
1368
1185
  }
1369
1186
  return {};
1370
- }, "customFitToBoundsOptions");
1187
+ };
1371
1188
  const mapPoints = useMemo8(() => {
1372
1189
  return map && features?.length ? new MapPoints({
1373
1190
  features,
1374
1191
  map,
1375
1192
  zoom
1376
1193
  }) : void 0;
1377
- }, [
1378
- map,
1379
- features,
1380
- zoom
1381
- ]);
1194
+ }, [map, features, zoom]);
1382
1195
  const updateFeatures = useCallback2(() => {
1383
- if (mapPoints?.isMapReady && features?.length && layers) for (const layer of layers) {
1384
- mapPoints.initializeMapSource(layer);
1385
- }
1386
- }, [
1387
- mapPoints,
1388
- features,
1389
- layers
1390
- ]);
1196
+ if (mapPoints?.isMapReady && features?.length && layers)
1197
+ for (const layer of layers) {
1198
+ mapPoints.initializeMapSource(layer);
1199
+ }
1200
+ }, [mapPoints, features, layers]);
1391
1201
  const updateMapSetup = useCallback2(() => {
1392
1202
  const { fitToPoints: fitToPoints2 } = mapSettings || {};
1393
1203
  if (mapPoints && map && fitToPoints2?.value === true) {
@@ -1401,13 +1211,7 @@ var MapboxPointsFlexBox = /* @__PURE__ */ __name(({ accessToken, features, fitTo
1401
1211
  ...customFitToBoundsOptions(zoom)
1402
1212
  });
1403
1213
  }
1404
- }, [
1405
- mapSettings,
1406
- mapPoints,
1407
- map,
1408
- fitToPointsPadding,
1409
- zoom
1410
- ]);
1214
+ }, [mapSettings, mapPoints, map, fitToPointsPadding, zoom]);
1411
1215
  const reInitializeMap = useCallback2(() => {
1412
1216
  mapPoints?.initialMapPositioning({
1413
1217
  padding: {
@@ -1419,33 +1223,18 @@ var MapboxPointsFlexBox = /* @__PURE__ */ __name(({ accessToken, features, fitTo
1419
1223
  ...customFitToBoundsOptions(zoom)
1420
1224
  });
1421
1225
  updateFeatures();
1422
- }, [
1423
- mapPoints,
1424
- fitToPointsPadding,
1425
- updateFeatures,
1426
- zoom
1427
- ]);
1226
+ }, [mapPoints, fitToPointsPadding, updateFeatures, zoom]);
1428
1227
  useEffect7(() => {
1429
1228
  if (mapInitialized) {
1430
1229
  updateMapSetup();
1431
1230
  reInitializeMap();
1432
1231
  }
1433
- }, [
1434
- mapInitialized,
1435
- reInitializeMap,
1436
- updateMapSetup
1437
- ]);
1438
- return /* @__PURE__ */ React13.createElement(FlexCol6, {
1439
- alignItems: "stretch",
1440
- id: "xyo-mapbox-wrap",
1441
- ...props
1442
- }, features ? /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(MapBox, {
1443
- accessToken,
1444
- zoom
1445
- }), /* @__PURE__ */ React13.createElement(MapSettingsBox, null)) : /* @__PURE__ */ React13.createElement(Alert2, {
1446
- severity: "error"
1447
- }, "No data to show"));
1448
- }, "MapboxPointsFlexBox");
1232
+ }, [mapInitialized, reInitializeMap, updateMapSetup]);
1233
+ return /* @__PURE__ */ jsx13(FlexCol6, { alignItems: "stretch", id: "xyo-mapbox-wrap", ...props, children: features ? /* @__PURE__ */ jsxs4(Fragment2, { children: [
1234
+ /* @__PURE__ */ jsx13(MapBox, { accessToken, zoom }),
1235
+ /* @__PURE__ */ jsx13(MapSettingsBox, {})
1236
+ ] }) : /* @__PURE__ */ jsx13(Alert2, { severity: "error", children: "No data to show" }) });
1237
+ };
1449
1238
  export {
1450
1239
  AnimatedHeatMap,
1451
1240
  AnimatedHeatMapLegend,