@xyo-network/react-map 2.64.0 → 2.64.3

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.
Files changed (130) hide show
  1. package/dist/browser/AnimatedHeatMapSettings.js +56 -3
  2. package/dist/browser/AnimatedHeatMapSettings.js.map +1 -1
  3. package/dist/browser/Colors/index.js +0 -1
  4. package/dist/browser/Colors/index.js.map +1 -1
  5. package/dist/browser/Components/AnimatedHeatMap.js +623 -10
  6. package/dist/browser/Components/AnimatedHeatMap.js.map +1 -1
  7. package/dist/browser/Components/AnimatedHeatMapLoaded.js +864 -13
  8. package/dist/browser/Components/AnimatedHeatMapLoaded.js.map +1 -1
  9. package/dist/browser/Components/HeatMapSettings.js +56 -3
  10. package/dist/browser/Components/HeatMapSettings.js.map +1 -1
  11. package/dist/browser/Components/LayerAnimator.js +5 -4
  12. package/dist/browser/Components/LayerAnimator.js.map +1 -1
  13. package/dist/browser/Components/Legend.js +32 -7
  14. package/dist/browser/Components/Legend.js.map +1 -1
  15. package/dist/browser/Components/Legends/ColorGradient.js +3 -2
  16. package/dist/browser/Components/Legends/ColorGradient.js.map +1 -1
  17. package/dist/browser/Components/Legends/index.js +25 -1
  18. package/dist/browser/Components/Legends/index.js.map +1 -1
  19. package/dist/browser/Components/MapBox.js +66 -12
  20. package/dist/browser/Components/MapBox.js.map +1 -1
  21. package/dist/browser/Components/MapBoxHeat.js +151 -6
  22. package/dist/browser/Components/MapBoxHeat.js.map +1 -1
  23. package/dist/browser/Components/MapBoxPoints.js +207 -14
  24. package/dist/browser/Components/MapBoxPoints.js.map +1 -1
  25. package/dist/browser/Components/MapSettingsComponents/Setting.js +16 -3
  26. package/dist/browser/Components/MapSettingsComponents/Setting.js.map +1 -1
  27. package/dist/browser/Components/MapSettingsComponents/SettingsBox.js +38 -6
  28. package/dist/browser/Components/MapSettingsComponents/SettingsBox.js.map +1 -1
  29. package/dist/browser/Components/MapSettingsComponents/index.js +50 -2
  30. package/dist/browser/Components/MapSettingsComponents/index.js.map +1 -1
  31. package/dist/browser/Components/index.js +1084 -11
  32. package/dist/browser/Components/index.js.map +1 -1
  33. package/dist/browser/Contexts/HeatMapInitializer/Context.js +2 -1
  34. package/dist/browser/Contexts/HeatMapInitializer/Context.js.map +1 -1
  35. package/dist/browser/Contexts/HeatMapInitializer/Provider.js +235 -14
  36. package/dist/browser/Contexts/HeatMapInitializer/Provider.js.map +1 -1
  37. package/dist/browser/Contexts/HeatMapInitializer/index.js +294 -3
  38. package/dist/browser/Contexts/HeatMapInitializer/index.js.map +1 -1
  39. package/dist/browser/Contexts/HeatMapInitializer/useHeatMapInitializer.js +8 -2
  40. package/dist/browser/Contexts/HeatMapInitializer/useHeatMapInitializer.js.map +1 -1
  41. package/dist/browser/Contexts/MapBoxInstance/Context.js +2 -1
  42. package/dist/browser/Contexts/MapBoxInstance/Context.js.map +1 -1
  43. package/dist/browser/Contexts/MapBoxInstance/Provider.js +9 -3
  44. package/dist/browser/Contexts/MapBoxInstance/Provider.js.map +1 -1
  45. package/dist/browser/Contexts/MapBoxInstance/index.js +35 -3
  46. package/dist/browser/Contexts/MapBoxInstance/index.js.map +1 -1
  47. package/dist/browser/Contexts/MapBoxInstance/useMapBoxInstance.js +8 -2
  48. package/dist/browser/Contexts/MapBoxInstance/useMapBoxInstance.js.map +1 -1
  49. package/dist/browser/Contexts/MapSettings/Context.js +2 -1
  50. package/dist/browser/Contexts/MapSettings/Context.js.map +1 -1
  51. package/dist/browser/Contexts/MapSettings/Provider.js +117 -5
  52. package/dist/browser/Contexts/MapSettings/Provider.js.map +1 -1
  53. package/dist/browser/Contexts/MapSettings/index.js +148 -3
  54. package/dist/browser/Contexts/MapSettings/index.js.map +1 -1
  55. package/dist/browser/Contexts/MapSettings/useMapSettings.js +8 -2
  56. package/dist/browser/Contexts/MapSettings/useMapSettings.js.map +1 -1
  57. package/dist/browser/Contexts/MapboxAccessToken/Context.js +2 -1
  58. package/dist/browser/Contexts/MapboxAccessToken/Context.js.map +1 -1
  59. package/dist/browser/Contexts/MapboxAccessToken/Provider.js +9 -3
  60. package/dist/browser/Contexts/MapboxAccessToken/Provider.js.map +1 -1
  61. package/dist/browser/Contexts/MapboxAccessToken/index.js +22 -4
  62. package/dist/browser/Contexts/MapboxAccessToken/index.js.map +1 -1
  63. package/dist/browser/Contexts/MapboxAccessToken/use.js +8 -2
  64. package/dist/browser/Contexts/MapboxAccessToken/use.js.map +1 -1
  65. package/dist/browser/Contexts/index.js +459 -4
  66. package/dist/browser/Contexts/index.js.map +1 -1
  67. package/dist/browser/Layers/Builders/LocationHeatMapLayerBuilder.js +110 -6
  68. package/dist/browser/Layers/Builders/LocationHeatMapLayerBuilder.js.map +1 -1
  69. package/dist/browser/Layers/Builders/LocationHeatMapLayerBuilderAnimated.js +36 -4
  70. package/dist/browser/Layers/Builders/LocationHeatMapLayerBuilderAnimated.js.map +1 -1
  71. package/dist/browser/Layers/Builders/LocationPointsMapLayerBuilder.js +40 -4
  72. package/dist/browser/Layers/Builders/LocationPointsMapLayerBuilder.js.map +1 -1
  73. package/dist/browser/Layers/Builders/index.js +205 -3
  74. package/dist/browser/Layers/Builders/index.js.map +1 -1
  75. package/dist/browser/Layers/CircleLayer.js +3 -2
  76. package/dist/browser/Layers/CircleLayer.js.map +1 -1
  77. package/dist/browser/Layers/Configs/HeatMapFillLayerConfig.js +2 -1
  78. package/dist/browser/Layers/Configs/HeatMapFillLayerConfig.js.map +1 -1
  79. package/dist/browser/Layers/Configs/HeatMapLineLayerConfig.js +2 -1
  80. package/dist/browser/Layers/Configs/HeatMapLineLayerConfig.js.map +1 -1
  81. package/dist/browser/Layers/Configs/HeatMapSymbolLayerConfig.js +2 -1
  82. package/dist/browser/Layers/Configs/HeatMapSymbolLayerConfig.js.map +1 -1
  83. package/dist/browser/Layers/Configs/LocationPointLayerConfig.js +2 -1
  84. package/dist/browser/Layers/Configs/LocationPointLayerConfig.js.map +1 -1
  85. package/dist/browser/Layers/Configs/index.js +62 -4
  86. package/dist/browser/Layers/Configs/index.js.map +1 -1
  87. package/dist/browser/Layers/FillLayer.js +3 -2
  88. package/dist/browser/Layers/FillLayer.js.map +1 -1
  89. package/dist/browser/Layers/LineLayer.js +3 -2
  90. package/dist/browser/Layers/LineLayer.js.map +1 -1
  91. package/dist/browser/Layers/SymbolLayer.js +3 -2
  92. package/dist/browser/Layers/SymbolLayer.js.map +1 -1
  93. package/dist/browser/Layers/index.js +213 -7
  94. package/dist/browser/Layers/index.js.map +1 -1
  95. package/dist/browser/MapBoxClasses/MapBase.js +3 -2
  96. package/dist/browser/MapBoxClasses/MapBase.js.map +1 -1
  97. package/dist/browser/MapBoxClasses/MapHeat.js +41 -11
  98. package/dist/browser/MapBoxClasses/MapHeat.js.map +1 -1
  99. package/dist/browser/MapBoxClasses/MapPoints.js +33 -3
  100. package/dist/browser/MapBoxClasses/MapPoints.js.map +1 -1
  101. package/dist/browser/MapBoxClasses/MapSettings.js +6 -5
  102. package/dist/browser/MapBoxClasses/MapSettings.js.map +1 -1
  103. package/dist/browser/MapBoxClasses/index.js +288 -4
  104. package/dist/browser/MapBoxClasses/index.js.map +1 -1
  105. package/dist/browser/Settings/DefaultMapSettings.js +2 -1
  106. package/dist/browser/Settings/DefaultMapSettings.js.map +1 -1
  107. package/dist/browser/Settings/index.js +55 -2
  108. package/dist/browser/Settings/index.js.map +1 -1
  109. package/dist/browser/hooks/index.js +156 -5
  110. package/dist/browser/hooks/index.js.map +1 -1
  111. package/dist/browser/hooks/useDynamicMapResize.js +2 -1
  112. package/dist/browser/hooks/useDynamicMapResize.js.map +1 -1
  113. package/dist/browser/hooks/useDynamicPositioning.js +7 -6
  114. package/dist/browser/hooks/useDynamicPositioning.js.map +1 -1
  115. package/dist/browser/hooks/useFindHashes.js +4 -3
  116. package/dist/browser/hooks/useFindHashes.js.map +1 -1
  117. package/dist/browser/hooks/useHeatMapColors.js +2 -1
  118. package/dist/browser/hooks/useHeatMapColors.js.map +1 -1
  119. package/dist/browser/hooks/useQuadKeyPayloadsToFeatures.js +4 -3
  120. package/dist/browser/hooks/useQuadKeyPayloadsToFeatures.js.map +1 -1
  121. package/dist/browser/index.js +1298 -10
  122. package/dist/browser/index.js.map +1 -1
  123. package/dist/browser/lib/MapStyle.js +1 -0
  124. package/dist/browser/lib/MapStyle.js.map +1 -1
  125. package/dist/browser/lib/index.js +13 -2
  126. package/dist/browser/lib/index.js.map +1 -1
  127. package/dist/browser/types/index.js +0 -1
  128. package/dist/browser/types/index.js.map +1 -1
  129. package/dist/docs.json +296 -296
  130. package/package.json +14 -14
@@ -1,12 +1,863 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ // src/Components/AnimatedHeatMapLoaded.tsx
2
2
  import { Alert, AlertTitle } from "@mui/material";
3
- import { FlexCol } from "@xylabs/react-flexbox";
3
+ import { FlexCol as FlexCol5 } from "@xylabs/react-flexbox";
4
4
  import { useArchivistFromNode, useArchivistGet } from "@xyo-network/react-archivist";
5
- import { AnimatedHeatMapSettings } from "../AnimatedHeatMapSettings";
6
- import { useFindHashes, useHeatMapColors, useQuadKeyPayloadsToFeatures } from "../hooks";
7
- import { AnimatedHeatMap } from "./AnimatedHeatMap";
8
- import { AnimatedHeatMapLegend } from "./Legend";
9
- const AnimatedHeatMapLoaded = ({ accessToken, archivistNameOrAddress, ...props }) => {
5
+
6
+ // src/Settings/DefaultMapSettings.ts
7
+ var DefaultMapSettings = () => ({
8
+ debugLayer: {
9
+ devMode: true,
10
+ field: "debugLayer",
11
+ hidden: true,
12
+ label: "Debug Layer",
13
+ value: false
14
+ },
15
+ debugLogging: {
16
+ devMode: true,
17
+ field: "debugLogging",
18
+ hidden: true,
19
+ label: "Debug Logging",
20
+ value: false
21
+ },
22
+ dynamicMapResize: {
23
+ devMode: true,
24
+ field: "dynamicMapResize",
25
+ hidden: true,
26
+ label: "Auto Map Resize",
27
+ value: true
28
+ },
29
+ enableControls: {
30
+ devMode: true,
31
+ field: "enableControls",
32
+ hidden: true,
33
+ label: "Map Controls",
34
+ value: false
35
+ },
36
+ fitToPoints: {
37
+ devMode: true,
38
+ field: "fitToPoints",
39
+ hidden: true,
40
+ label: "Fit To Points",
41
+ value: false
42
+ },
43
+ preferDark: {
44
+ devMode: false,
45
+ field: "preferDark",
46
+ hidden: true,
47
+ label: "Prefer dark",
48
+ value: false
49
+ },
50
+ scrollToZoom: {
51
+ devMode: true,
52
+ field: "scrollToZoom",
53
+ hidden: true,
54
+ label: "Scroll To Zoom",
55
+ value: false
56
+ }
57
+ });
58
+
59
+ // src/AnimatedHeatMapSettings.ts
60
+ var AnimatedHeatMapSettings = DefaultMapSettings();
61
+ var { debugLayer, scrollToZoom, fitToPoints, preferDark } = AnimatedHeatMapSettings;
62
+ debugLayer.hidden = false;
63
+ scrollToZoom.value = true;
64
+ fitToPoints.value = false;
65
+ preferDark.value = true;
66
+
67
+ // src/hooks/useDynamicMapResize.tsx
68
+ import { useEffect, useMemo, useState } from "react";
69
+ var useDynamicMapResize = (mapContainerRef, mapCanvasRef, mapInstance, active = true) => {
70
+ const [dependenciesReady, setDependenciesReady] = useState(false);
71
+ const resizer = useMemo(
72
+ () => new ResizeObserver(() => {
73
+ const width = mapContainerRef.current?.getBoundingClientRect().width;
74
+ if (width && mapCanvasRef.current) {
75
+ mapCanvasRef.current.style.width = `${width}px`;
76
+ setTimeout(() => mapInstance?.resize());
77
+ }
78
+ }),
79
+ [mapCanvasRef, mapContainerRef, mapInstance]
80
+ );
81
+ useEffect(() => {
82
+ const dependenciesReady2 = !!(active && mapInstance && mapContainerRef?.current && mapCanvasRef.current);
83
+ setDependenciesReady(dependenciesReady2);
84
+ }, [active, mapCanvasRef, mapContainerRef, mapInstance]);
85
+ useEffect(() => {
86
+ if (dependenciesReady) {
87
+ if (mapContainerRef.current) {
88
+ resizer.observe(mapContainerRef.current);
89
+ }
90
+ return () => {
91
+ resizer.disconnect();
92
+ };
93
+ }
94
+ }, [active, dependenciesReady, mapCanvasRef, mapContainerRef, mapInstance, resizer]);
95
+ };
96
+
97
+ // src/hooks/useDynamicPositioning.tsx
98
+ import { useWindowSize } from "@xylabs/react-shared";
99
+ import { useEffect as useEffect2, useState as useState2 } from "react";
100
+ var defaultZoom = 1.6;
101
+ var defaultAspectRatioRange = [0.5, 2];
102
+ var latRange = [0.9121644205263664, 1.71785031559439];
103
+ var lngRange = [-81.4742014851959, 12.788958675506933];
104
+ var linearInterpolate = (aspectRatio, degreeRange, aspectRatioRange) => {
105
+ const [degreeMin, degreeMax] = degreeRange;
106
+ const [aspectRatioMin, aspectRatioMax] = aspectRatioRange || defaultAspectRatioRange;
107
+ const aspectRatioRangeSpan = aspectRatioMax - aspectRatioMin;
108
+ const degreeRangeSpan = degreeMax - degreeMin;
109
+ const percent = (aspectRatio - aspectRatioMin) / aspectRatioRangeSpan;
110
+ const scaledDegree = percent * degreeRangeSpan + degreeMin;
111
+ return scaledDegree;
112
+ };
113
+ var useDynamicPositioning = () => {
114
+ const [options, setOptions] = useState2({});
115
+ const { width, height } = useWindowSize();
116
+ useEffect2(() => {
117
+ if (width && height) {
118
+ const aspectRatio = width / height;
119
+ setOptions({
120
+ center: [linearInterpolate(aspectRatio, lngRange), linearInterpolate(aspectRatio, latRange)],
121
+ zoom: defaultZoom
122
+ });
123
+ }
124
+ }, [height, width]);
125
+ return { options };
126
+ };
127
+
128
+ // src/hooks/useFindHashes.tsx
129
+ import { useNetwork } from "@xyo-network/react-network";
130
+ import { useMemo as useMemo2 } from "react";
131
+ var animatedAnswerHashesConst = [
132
+ "79af071f451fc7af10d009dc63236ef9a9b211732c1ee0c06f028fcecf2336c5",
133
+ "531bfba6d8dfefd3bcc888aca54cdbbd4574ed2b3ec551b230845a1f9a608898",
134
+ "c874412b4faa4947de81372fd1ba12fdd6f43f5e408622b7f357cb2bcb3f17cb",
135
+ "29d3f8b882c61a82a1a1675782a27e797ea7196f45a23b4409680ab8b8d5f14e",
136
+ "cfd20f80ac073fd9518f4ef3f43d2a1f5e4e56e40c2677f38d6f6fecd05df60c",
137
+ "1354fa73497519a39aed19fc99bdbae78a880a1eafb2f7898d607e07db36528d",
138
+ "1043b0d25eacfc5013ae9dba780305a6fbf01a43543bd871d7c00537fca142a9",
139
+ "973dfc5df142851ced258d52d0ac2784e814000ac22e35776f772256b0d4dde9",
140
+ "463808eb74d3d87e6563970e0301a493577f8cd1b501e6e0ffa5e027ad2cea95",
141
+ "15b21acea2e3fd9d1ace3768a72636ee7bdf67a6f8e0807bfa2273dea2207555",
142
+ "32d377bfe7ebe382598c54dd13f8af7510e0a1e2fd2e913311fdd58e517e5e2e,"
143
+ ];
144
+ var staticAnswerHashConst = "c7bbf61f61cfd4a1b2def160c28136fc1d100d39fbdb67b227a2c6e558d9d3a5";
145
+ var useFindHashes = () => {
146
+ const { network } = useNetwork();
147
+ const exploreMapHashes = network?.nodes?.find((node) => node.type === "archivist")?.explorerMapHashes;
148
+ const animatedAnswerHashes = exploreMapHashes?.animatedAnswerHashes || animatedAnswerHashesConst;
149
+ const staticAnswerHash = exploreMapHashes?.staticAnswerHash || staticAnswerHashConst;
150
+ const foundHashes = useMemo2(() => [staticAnswerHash, ...animatedAnswerHashes], [animatedAnswerHashes, staticAnswerHash]);
151
+ return foundHashes;
152
+ };
153
+
154
+ // src/hooks/useHeatMapColors.tsx
155
+ import { useTheme } from "@mui/material";
156
+ var useHeatMapColors = () => {
157
+ const theme = useTheme();
158
+ const staticMapColor = "#FFFF75";
159
+ const highUsageColor = "#FF0000";
160
+ const heatMapColorProps = {
161
+ highUsageColor,
162
+ lowUsageColor: "#FFB3B3",
163
+ staticMapColor
164
+ };
165
+ const legendProps = {
166
+ endColor: highUsageColor,
167
+ endLabel: "High",
168
+ heading: "Network Usage",
169
+ startColor: staticMapColor,
170
+ startLabel: "Low",
171
+ textColor: theme.palette.common.white
172
+ };
173
+ return { heatMapColorProps, legendProps };
174
+ };
175
+
176
+ // src/hooks/useQuadKeyPayloadsToFeatures.tsx
177
+ import { compact } from "@xylabs/lodash";
178
+ import { GeoJson } from "@xyo-network/sdk-geo";
179
+ import { useEffect as useEffect3, useState as useState3 } from "react";
180
+ var quadKeyToFeature = ({ density, quadkey }) => {
181
+ const polygonFeature = new GeoJson(quadkey).polygonFeature();
182
+ polygonFeature.properties = {
183
+ count: density,
184
+ density
185
+ };
186
+ return polygonFeature;
187
+ };
188
+ var setDensity = (feature) => {
189
+ if (feature.properties) {
190
+ feature.properties.value = feature.properties.density / 5;
191
+ }
192
+ return feature;
193
+ };
194
+ var useQuadKeyPayloadsToFeatures = (payloads) => {
195
+ const [multipleFeatureSets, setMultipleFeatureSets] = useState3([[]]);
196
+ const [features, setFeatures] = useState3([]);
197
+ const [error, setError] = useState3();
198
+ useEffect3(() => {
199
+ if (Array.isArray(payloads)) {
200
+ if (compact(payloads).length !== 0) {
201
+ const payloadsArray = payloads;
202
+ const mappedFeatures = payloadsArray?.map((payload) => payload?.result.map(quadKeyToFeature));
203
+ setMultipleFeatureSets(mappedFeatures.map((features2) => features2?.map(setDensity) ?? []));
204
+ } else {
205
+ setError(new Error("Cannot find payloads for provided hashes"));
206
+ }
207
+ }
208
+ if (payloads && payloads.result) {
209
+ const singlePayload = payloads;
210
+ const mappedFeatures = singlePayload.result.map(quadKeyToFeature);
211
+ setFeatures(mappedFeatures.map(setDensity));
212
+ }
213
+ }, [payloads]);
214
+ return { error, features, multipleFeatureSets };
215
+ };
216
+
217
+ // src/Components/AnimatedHeatMap.tsx
218
+ import { darken, useTheme as useTheme2 } from "@mui/material";
219
+ import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
220
+ import { useState as useState8 } from "react";
221
+
222
+ // src/Contexts/HeatMapInitializer/Provider.tsx
223
+ import { forget as forget2 } from "@xylabs/forget";
224
+ import { useEffect as useEffect6, useState as useState6 } from "react";
225
+
226
+ // src/MapBoxClasses/MapBase.ts
227
+ import { assertEx } from "@xylabs/assert";
228
+ import { GeoJson as GeoJson2 } from "@xyo-network/sdk-geo";
229
+ var MapBase = class {
230
+ _config;
231
+ constructor(config) {
232
+ this._config = { requestLocation: true, zoom: 2, ...config };
233
+ }
234
+ get isMapReady() {
235
+ return !!this._config.map;
236
+ }
237
+ initializeMapSource(layer) {
238
+ const getSource = () => {
239
+ const featuresCollection = GeoJson2.featureCollection(this._config.features);
240
+ return GeoJson2.featuresSource(featuresCollection);
241
+ };
242
+ const existingSource = this._config.map.getSource(layer.source);
243
+ const source = getSource();
244
+ if (existingSource) {
245
+ existingSource.setData(assertEx(source.data));
246
+ } else {
247
+ this._config.map.addSource(layer.source, source);
248
+ }
249
+ layer.update(this._config.map, true);
250
+ return this;
251
+ }
252
+ };
253
+
254
+ // src/MapBoxClasses/MapHeat.ts
255
+ import { assertEx as assertEx2 } from "@xylabs/assert";
256
+ import { delay } from "@xylabs/delay";
257
+ import { forget } from "@xylabs/forget";
258
+ import { GeoJson as GeoJson3 } from "@xyo-network/sdk-geo";
259
+ import { LngLatBounds } from "mapbox-gl";
260
+ var MapHeat = class extends MapBase {
261
+ static animationStarted = false;
262
+ config;
263
+ constructor(config) {
264
+ super(config);
265
+ this.config = config;
266
+ }
267
+ static initialMapPositioning(options, map, features, initialBounds) {
268
+ if (!features) {
269
+ return;
270
+ }
271
+ let bounds;
272
+ if (initialBounds) {
273
+ bounds = initialBounds;
274
+ } else {
275
+ bounds = new LngLatBounds();
276
+ features.forEach((feature) => {
277
+ feature.geometry.coordinates.forEach((coordinates) => {
278
+ coordinates.forEach((position) => {
279
+ bounds.extend(position);
280
+ });
281
+ });
282
+ });
283
+ }
284
+ map.setCenter(bounds.getCenter());
285
+ map.fitBounds(bounds, options);
286
+ return this;
287
+ }
288
+ static async initializeAnimatedHeatMapSource(layers, featureSet, map, startColor, endColor) {
289
+ this.animationStarted = true;
290
+ let layerTick = 0;
291
+ let sourceTick = 0;
292
+ const sources = featureSet.map((feature) => {
293
+ const featuresCollection = GeoJson3.featureCollection(feature);
294
+ return GeoJson3.featuresSource(featuresCollection);
295
+ });
296
+ this.updateLayer(map, layers[0], sources[0]);
297
+ this.updateLayer(map, layers[1], sources[1]);
298
+ layers.forEach((layer) => {
299
+ map.setPaintProperty(layer.id, "fill-opacity", 0);
300
+ });
301
+ const frameLength = 3e3;
302
+ const initialPad = 0.5;
303
+ const factor = 10;
304
+ const steps = 30;
305
+ const stepLength = frameLength / steps;
306
+ const lowUsageColor = startColor ?? "#FFB3B3";
307
+ const highUsageColor = endColor ?? "#FF0000";
308
+ const dynamicFillColor = (factor2, initialPad2, i) => {
309
+ const sinFade = Math.sin(i / steps * Math.PI / 2);
310
+ const cosFade = Math.cos(i / steps * Math.PI / 2);
311
+ const divisor = factor2 + factor2 * sinFade;
312
+ const offset = initialPad2 * cosFade;
313
+ return [
314
+ "let",
315
+ "density",
316
+ ["+", ["/", ["number", ["get", "value"]], divisor], offset],
317
+ ["interpolate", ["linear"], ["var", "density"], 0, lowUsageColor, 0.5, highUsageColor]
318
+ ];
319
+ };
320
+ const fadedIn = layers.map((_) => false);
321
+ const fadeIn = async (id, index) => {
322
+ for (let i = steps; i >= 1; i--) {
323
+ map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
324
+ await delay(stepLength);
325
+ }
326
+ fadedIn[index] = true;
327
+ };
328
+ const fadeOut = async (id, index) => {
329
+ for (let i = 1; i <= steps; i++) {
330
+ map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
331
+ await delay(stepLength);
332
+ }
333
+ fadedIn[index] = false;
334
+ };
335
+ let started = false;
336
+ const startAnimation = async () => {
337
+ assertEx2(!started, "Animation Already Started");
338
+ started = true;
339
+ while (this.animationStarted) {
340
+ const upLayer = layerTick % layers.length;
341
+ const downLayer = (layerTick + 1) % layers.length;
342
+ const incomingSource = sourceTick % featureSet.length;
343
+ const outgoingSource = (sourceTick + 1) % featureSet.length;
344
+ if (fadedIn[upLayer]) {
345
+ this.updateLayer(map, layers[upLayer], sources[incomingSource]);
346
+ forget(fadeOut(layers[upLayer].id, upLayer));
347
+ }
348
+ if (!fadedIn[downLayer]) {
349
+ this.updateLayer(map, layers[downLayer], sources[outgoingSource]);
350
+ forget(fadeIn(layers[downLayer].id, downLayer));
351
+ }
352
+ while ((fadedIn[upLayer] || !fadedIn[downLayer]) && this.animationStarted) {
353
+ await delay(1e3);
354
+ }
355
+ layerTick++;
356
+ sourceTick++;
357
+ }
358
+ };
359
+ await startAnimation();
360
+ }
361
+ static updateLayer(map, layer, source) {
362
+ const existingSource = map.getSource(layer.source);
363
+ if (existingSource && source.data) {
364
+ existingSource.setData(source.data);
365
+ } else if (source) {
366
+ map.addSource(layer.source, source);
367
+ }
368
+ layer.update(map, true);
369
+ }
370
+ // Build layers each with the same features
371
+ initializeHeatMapSource(layers) {
372
+ const getSource = (_) => {
373
+ const featuresCollection = GeoJson3.featureCollection(this.config.features);
374
+ return GeoJson3.featuresSource(featuresCollection);
375
+ };
376
+ layers.forEach((layer, index) => {
377
+ const existingSource = this.config.map.getSource(layer.source);
378
+ const source = getSource(index);
379
+ if (existingSource) {
380
+ existingSource.setData(assertEx2(source.data));
381
+ } else {
382
+ this.config.map.addSource(layer.source, source);
383
+ }
384
+ layer.update(this.config.map, true);
385
+ });
386
+ return this;
387
+ }
388
+ };
389
+
390
+ // src/MapBoxClasses/MapSettings.ts
391
+ import { GeolocateControl, NavigationControl } from "mapbox-gl";
392
+ var MapSettings = class _MapSettings {
393
+ static geoLocateControl;
394
+ static mapListeners = {
395
+ logData: (ev, map) => {
396
+ const target = map || ev?.target;
397
+ if (target) {
398
+ console.log("zoom", target.getZoom());
399
+ console.log("center", target.getCenter());
400
+ }
401
+ }
402
+ };
403
+ static navControl;
404
+ static requestLocation;
405
+ static toggleControls(value, map, zoom, requestLocation) {
406
+ if (value) {
407
+ _MapSettings.addControls(map, zoom, requestLocation);
408
+ } else {
409
+ _MapSettings.removeControls(map);
410
+ }
411
+ return this;
412
+ }
413
+ static toggleDebugLayer(value, map, layerName) {
414
+ const debugLayer2 = map.getLayer(layerName);
415
+ if (debugLayer2) {
416
+ if (value) {
417
+ map.setLayoutProperty(layerName, "visibility", "visible");
418
+ } else {
419
+ map.setLayoutProperty(layerName, "visibility", "none");
420
+ }
421
+ }
422
+ return this;
423
+ }
424
+ static toggleDebugLogging(value, map) {
425
+ const debugEvents = ["resize", "zoomend", "dragend"];
426
+ if (value) {
427
+ this.mapListeners.logData(void 0, map);
428
+ debugEvents.forEach((event) => map.on(event, this.mapListeners.logData));
429
+ } else {
430
+ debugEvents.forEach((event) => map.off(event, this.mapListeners.logData));
431
+ }
432
+ }
433
+ static toggleScrollToZoom(value, map) {
434
+ if (value) {
435
+ map.scrollZoom.enable();
436
+ } else {
437
+ map.scrollZoom.disable();
438
+ }
439
+ return this;
440
+ }
441
+ static updateSettings(config) {
442
+ const { settings, map, zoom, requestLocation, debugLayerName = "" } = config;
443
+ const { scrollToZoom: scrollToZoom2, enableControls, debugLayer: debugLayer2, debugLogging } = settings;
444
+ _MapSettings.toggleControls(enableControls?.value, map, zoom, requestLocation).toggleScrollToZoom(scrollToZoom2?.value, map).toggleDebugLayer(debugLayer2?.value, map, debugLayerName).toggleDebugLogging(debugLogging.value, map);
445
+ }
446
+ // Needs to be static so we ensure controls are only instantiated once
447
+ static addControls(map, zoom, requestLocation) {
448
+ const geolocateControl = new GeolocateControl({
449
+ fitBoundsOptions: {
450
+ zoom: zoom || 2
451
+ },
452
+ positionOptions: {
453
+ enableHighAccuracy: true
454
+ },
455
+ trackUserLocation: true
456
+ });
457
+ const navControl = new NavigationControl({
458
+ showCompass: false
459
+ });
460
+ this.geoLocateControl = this.geoLocateControl || geolocateControl;
461
+ this.navControl = this.navControl || navControl;
462
+ if (!map.hasControl(this.geoLocateControl)) {
463
+ if (requestLocation) {
464
+ map.addControl(this.geoLocateControl);
465
+ }
466
+ }
467
+ if (!map.hasControl(this.navControl)) {
468
+ map.addControl(this.navControl, "top-left");
469
+ }
470
+ return this;
471
+ }
472
+ static removeControls(map) {
473
+ if (this.geoLocateControl && map.hasControl(this.geoLocateControl)) {
474
+ if (this.requestLocation) {
475
+ map.removeControl(this.geoLocateControl);
476
+ }
477
+ }
478
+ if (this.navControl && map.hasControl(this.navControl)) {
479
+ map.removeControl(this.navControl);
480
+ }
481
+ return this;
482
+ }
483
+ };
484
+
485
+ // src/Contexts/MapBoxInstance/Provider.tsx
486
+ import { useEffect as useEffect4, useState as useState4 } from "react";
487
+
488
+ // src/Contexts/MapBoxInstance/Context.ts
489
+ import { createContext } from "react";
490
+ var MapBoxInstanceContext = createContext({});
491
+
492
+ // src/Contexts/MapBoxInstance/Provider.tsx
493
+ import { jsx } from "react/jsx-runtime";
494
+ var MapBoxInstanceProvider = ({ children }) => {
495
+ const [map, setMapBoxInstance] = useState4();
496
+ const [mapInitialized, setMapInitialized] = useState4(false);
497
+ const value = { map, mapInitialized, setMapBoxInstance };
498
+ useEffect4(() => {
499
+ if (!mapInitialized && map) {
500
+ map?.on("load", () => {
501
+ setMapInitialized(true);
502
+ });
503
+ }
504
+ }, [map, mapInitialized, setMapInitialized]);
505
+ return /* @__PURE__ */ jsx(MapBoxInstanceContext.Provider, { value, children });
506
+ };
507
+
508
+ // src/Contexts/MapBoxInstance/useMapBoxInstance.tsx
509
+ import { assertEx as assertEx3 } from "@xylabs/assert";
510
+ import { useContext } from "react";
511
+ var useMapBoxInstance = () => {
512
+ const context = useContext(MapBoxInstanceContext);
513
+ assertEx3("map" in context, "useMapBoxInstance must be used within a MapBoxInstanceContext");
514
+ return context;
515
+ };
516
+
517
+ // src/Contexts/MapSettings/Provider.tsx
518
+ import { useEffect as useEffect5, useState as useState5 } from "react";
519
+
520
+ // src/Contexts/MapSettings/Context.ts
521
+ import { createContext as createContext2 } from "react";
522
+ var MapSettingsContext = createContext2({});
523
+
524
+ // src/Contexts/MapSettings/Provider.tsx
525
+ import { jsx as jsx2 } from "react/jsx-runtime";
526
+ var MapSettingsProvider = ({
527
+ children,
528
+ debugLayerName,
529
+ defaultMapSettings,
530
+ requestLocation,
531
+ zoom = 1
532
+ }) => {
533
+ const [mapSettings, setMapSettings] = useState5(defaultMapSettings || {});
534
+ const { map, mapInitialized } = useMapBoxInstance();
535
+ const value = {
536
+ mapSettings,
537
+ setMapSettings
538
+ };
539
+ useEffect5(() => {
540
+ if (mapSettings && map && mapInitialized) {
541
+ MapSettings.updateSettings({ debugLayerName, map, requestLocation, settings: mapSettings, zoom });
542
+ }
543
+ }, [debugLayerName, map, mapInitialized, mapSettings, requestLocation, zoom]);
544
+ return /* @__PURE__ */ jsx2(MapSettingsContext.Provider, { value, children });
545
+ };
546
+
547
+ // src/Contexts/MapSettings/useMapSettings.tsx
548
+ import { useContext as useContext2 } from "react";
549
+ var useMapSettings = () => {
550
+ const context = useContext2(MapSettingsContext);
551
+ return context;
552
+ };
553
+
554
+ // src/Contexts/HeatMapInitializer/Context.ts
555
+ import { createContext as createContext3 } from "react";
556
+ var HeatMapInitializerContext = createContext3({});
557
+
558
+ // src/Contexts/HeatMapInitializer/Provider.tsx
559
+ import { jsx as jsx3 } from "react/jsx-runtime";
560
+ var HeatMapInitializerProvider = ({
561
+ children,
562
+ featureSets,
563
+ featureSetsLayers,
564
+ features,
565
+ fitToPadding,
566
+ heatMapColorProps,
567
+ layers,
568
+ zoom
569
+ }) => {
570
+ const [mapHeat, setMapHeat] = useState6();
571
+ const { options } = useDynamicPositioning();
572
+ const { mapSettings } = useMapSettings();
573
+ const { map, mapInitialized } = useMapBoxInstance();
574
+ const value = {
575
+ MapHeat: mapHeat,
576
+ heatMapColorProps
577
+ };
578
+ useEffect6(() => {
579
+ if (mapInitialized && featureSets?.length && featureSets[0].length && map && featureSetsLayers?.length) {
580
+ const { lowUsageColor, highUsageColor } = heatMapColorProps;
581
+ forget2(MapHeat.initializeAnimatedHeatMapSource(featureSetsLayers, featureSets, map, lowUsageColor, highUsageColor));
582
+ }
583
+ return () => {
584
+ MapHeat.animationStarted = false;
585
+ };
586
+ }, [featureSets, featureSetsLayers, mapInitialized, map, heatMapColorProps]);
587
+ useEffect6(() => {
588
+ if (mapHeat && mapInitialized && features?.length && layers?.length) {
589
+ mapHeat.initializeHeatMapSource(layers);
590
+ }
591
+ }, [mapHeat, features?.length, layers, mapInitialized]);
592
+ useEffect6(() => {
593
+ if (mapInitialized) {
594
+ const { fitToPoints: fitToPoints2 } = mapSettings || {};
595
+ if (map) {
596
+ if (fitToPoints2?.value === true) {
597
+ MapHeat.initialMapPositioning({ padding: fitToPadding }, map, features);
598
+ } else if (options.zoom && options.center) {
599
+ map.setZoom(options.zoom);
600
+ map.setCenter(options.center);
601
+ }
602
+ }
603
+ }
604
+ }, [mapHeat, map, mapSettings, fitToPadding, options, mapInitialized, features]);
605
+ useEffect6(() => {
606
+ if (map && features?.length) {
607
+ setMapHeat(new MapHeat({ features, map, zoom }));
608
+ }
609
+ }, [map, features, zoom]);
610
+ return /* @__PURE__ */ jsx3(HeatMapInitializerContext.Provider, { value, children });
611
+ };
612
+
613
+ // src/Layers/Configs/HeatMapFillLayerConfig.ts
614
+ var HeatMapFillLayerConfig = (color) => ({
615
+ paint: {
616
+ "fill-color": color,
617
+ "fill-opacity": [
618
+ "let",
619
+ "density",
620
+ ["+", ["/", ["number", ["get", "value"]], 4], 0.125],
621
+ ["interpolate", ["linear"], ["var", "density"], 0.8, ["var", "density"], 1, 0.85]
622
+ ]
623
+ }
624
+ });
625
+
626
+ // src/Layers/FillLayer.ts
627
+ import { LayerBase } from "@xyo-network/sdk-geo";
628
+ var FillLayerBuilder = class extends LayerBase {
629
+ FillLayerOptions;
630
+ // ensures this class passes for `AnyLayer` type in MapBox
631
+ type = "fill";
632
+ constructor(id, source, FillLayerOptions) {
633
+ super(id, source);
634
+ this.FillLayerOptions = FillLayerOptions || { id: this.id, source: this.source };
635
+ }
636
+ buildLayer() {
637
+ return {
638
+ ...this.FillLayerOptions,
639
+ id: this.id,
640
+ source: this.source,
641
+ type: this.type
642
+ };
643
+ }
644
+ };
645
+
646
+ // src/Layers/Builders/LocationHeatMapLayerBuilder.ts
647
+ var MapHeatConstants = {
648
+ LocationDebugLayerId: "location-debug-id",
649
+ LocationDebugLayerSource: "location-debug-source",
650
+ LocationFillLayerId: "location-fill-id",
651
+ LocationFillLayerSource: "location-fill-source",
652
+ LocationLineLayerId: "location-line-id",
653
+ LocationLineLayerSource: "location-line-source"
654
+ };
655
+
656
+ // src/Layers/Builders/LocationHeatMapLayerBuilderAnimated.ts
657
+ var MapHeatConstants2 = (index, type) => ({
658
+ LocationDebugLayerId: `location-${type}-debug-id-${index}`,
659
+ LocationDebugLayerSource: `location-${type}-debug-source-${index}`,
660
+ LocationFillLayerId: `location-${type}-fill-id-${index}`,
661
+ LocationFillLayerSource: `location-${type}-fill-source-${index}`,
662
+ LocationLineLayerId: `location-${type}-line-id-${index}`,
663
+ LocationLineLayerSource: `location-${type}-line-source-${index}`
664
+ });
665
+ var LocationHeatMapLayerBuilderAnimated = (color, index, type = "") => {
666
+ const { LocationFillLayerId, LocationFillLayerSource } = MapHeatConstants2(index, type);
667
+ const fillLayerConfig = HeatMapFillLayerConfig(color);
668
+ const fillLayer = new FillLayerBuilder(LocationFillLayerId, LocationFillLayerSource, fillLayerConfig);
669
+ return fillLayer;
670
+ };
671
+
672
+ // src/Components/MapBoxHeat.tsx
673
+ import { FlexCol } from "@xylabs/react-flexbox";
674
+
675
+ // src/Components/MapBox.tsx
676
+ import "mapbox-gl/dist/mapbox-gl.css";
677
+ import { Map as Map3 } from "mapbox-gl";
678
+ import { useEffect as useEffect7, useRef, useState as useState7 } from "react";
679
+ import { jsx as jsx4 } from "react/jsx-runtime";
680
+ var MapBox = ({ accessToken, darkMode = false, options, zoom = 2, ...props }) => {
681
+ const [map, setMap] = useState7();
682
+ const mapContainerRef = useRef(null);
683
+ const mapCanvasRef = useRef(null);
684
+ const { setMapBoxInstance, map: mapInstance } = useMapBoxInstance();
685
+ const { mapSettings } = useMapSettings();
686
+ const activeResize = mapSettings?.dynamicMapResize.value;
687
+ useDynamicMapResize(mapContainerRef, mapCanvasRef, mapInstance, activeResize);
688
+ useEffect7(() => {
689
+ if (mapSettings?.preferDark?.value === true) {
690
+ map?.setStyle(`mapbox://styles/${"mapbox/dark-v10" /* Dark */}`);
691
+ } else {
692
+ map?.setStyle(`mapbox://styles/${darkMode ? "mapbox/dark-v10" /* Dark */ : "mapbox/light-v10" /* Light */}`);
693
+ }
694
+ }, [map, darkMode, mapSettings]);
695
+ useEffect7(() => {
696
+ const map2 = new Map3({
697
+ accessToken,
698
+ center: [0, 0],
699
+ container: mapContainerRef.current ?? "",
700
+ style: `mapbox://styles/${"mapbox/light-v10" /* Light */}`,
701
+ zoom,
702
+ ...options
703
+ });
704
+ setMapBoxInstance?.(map2);
705
+ setMap(map2);
706
+ mapCanvasRef.current = document.querySelector(".mapboxgl-canvas");
707
+ console.log("Created Map");
708
+ return () => {
709
+ console.log("Removing Map");
710
+ map2.remove();
711
+ };
712
+ }, [mapContainerRef, setMap, options, zoom, setMapBoxInstance, accessToken]);
713
+ return /* @__PURE__ */ jsx4(
714
+ "div",
715
+ {
716
+ ref: (el) => mapContainerRef.current = el,
717
+ style: {
718
+ bottom: 0,
719
+ left: 0,
720
+ position: "absolute",
721
+ right: 0,
722
+ top: 0,
723
+ ...props
724
+ }
725
+ }
726
+ );
727
+ };
728
+
729
+ // src/Components/MapSettingsComponents/Setting.tsx
730
+ import { FormControlLabel, Switch } from "@mui/material";
731
+ import { jsx as jsx5 } from "react/jsx-runtime";
732
+ var MapSettingSwitch = ({ developerMode, field, ...props }) => {
733
+ const { mapSettings, setMapSettings } = useMapSettings();
734
+ const setting = mapSettings?.[field];
735
+ const onLocalChange = (event) => {
736
+ if (setting) {
737
+ setMapSettings?.((previous) => {
738
+ previous[setting.field].value = event.target.checked;
739
+ return { ...previous };
740
+ });
741
+ }
742
+ };
743
+ if (setting?.devMode && developerMode === false) {
744
+ return null;
745
+ }
746
+ return setting?.hidden ? null : /* @__PURE__ */ jsx5(FormControlLabel, { label: setting?.label, control: /* @__PURE__ */ jsx5(Switch, { checked: setting?.value, onChange: onLocalChange, ...props }) });
747
+ };
748
+
749
+ // src/Components/MapSettingsComponents/SettingsBox.tsx
750
+ import { Paper, Stack } from "@mui/material";
751
+ import { FlexGrowRow, FlexRow } from "@xylabs/react-flexbox";
752
+ import { useAppSettings } from "@xyo-network/react-app-settings";
753
+ import { jsx as jsx6 } from "react/jsx-runtime";
754
+ var MapSettingsBox = ({ developerMode, ...props }) => {
755
+ const { mapSettings } = useMapSettings();
756
+ const { developerMode: devModeFromContext } = useAppSettings();
757
+ const resolveDeveloperMode = developerMode ?? devModeFromContext;
758
+ 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) => {
759
+ return /* @__PURE__ */ jsx6(MapSettingSwitch, { field: mapSettings[key].field, developerMode }, index);
760
+ }) }) }) }) }) : null;
761
+ };
762
+
763
+ // src/Components/MapBoxHeat.tsx
764
+ import { jsx as jsx7, jsxs } from "react/jsx-runtime";
765
+ var MapboxHeatFlexBox = ({ accessToken, children, mapBoxOptions, zoom, legend, developerMode, ...props }) => {
766
+ return /* @__PURE__ */ jsxs(FlexCol, { ...props, children: [
767
+ /* @__PURE__ */ jsx7(MapBox, { accessToken, options: mapBoxOptions, zoom }),
768
+ /* @__PURE__ */ jsx7(MapSettingsBox, { developerMode }),
769
+ legend,
770
+ children
771
+ ] });
772
+ };
773
+
774
+ // src/Components/AnimatedHeatMap.tsx
775
+ import { jsx as jsx8 } from "react/jsx-runtime";
776
+ var AnimatedHeatMap = ({
777
+ accessToken,
778
+ animatedFeatureSets,
779
+ defaultMapSettings,
780
+ heatMapColorProps,
781
+ staticFeatureSet,
782
+ ...props
783
+ }) => {
784
+ const theme = useTheme2();
785
+ const { staticMapColor, lowUsageColor, highUsageColor } = heatMapColorProps || {};
786
+ const localStaticMapColor = staticMapColor ?? theme.palette.primary.light;
787
+ const [layers] = useState8([
788
+ LocationHeatMapLayerBuilderAnimated(localStaticMapColor, 0, "static"),
789
+ LocationHeatMapLayerBuilderAnimated(lowUsageColor || localStaticMapColor, 0, "animated"),
790
+ LocationHeatMapLayerBuilderAnimated(highUsageColor || darken(localStaticMapColor, 0.9), 1, "animated")
791
+ ]);
792
+ return animatedFeatureSets?.length ? /* @__PURE__ */ jsx8(MapBoxInstanceProvider, { children: /* @__PURE__ */ jsx8(MapSettingsProvider, { defaultMapSettings, debugLayerName: MapHeatConstants.LocationDebugLayerId, children: /* @__PURE__ */ jsx8(
793
+ HeatMapInitializerProvider,
794
+ {
795
+ features: staticFeatureSet,
796
+ layers: [layers[0]],
797
+ featureSets: animatedFeatureSets,
798
+ featureSetsLayers: layers.slice(1, 3),
799
+ heatMapColorProps,
800
+ children: /* @__PURE__ */ jsx8(MapboxHeatFlexBox, { accessToken, ...props })
801
+ }
802
+ ) }) }) : /* @__PURE__ */ jsx8(FlexCol2, { minHeight: 160, minWidth: 160, busy: true });
803
+ };
804
+
805
+ // src/Components/Legend.tsx
806
+ import { useMediaQuery, useTheme as useTheme4 } from "@mui/material";
807
+ import { FlexCol as FlexCol4 } from "@xylabs/react-flexbox";
808
+
809
+ // src/Components/Legends/ColorGradient.tsx
810
+ import { Typography, useTheme as useTheme3 } from "@mui/material";
811
+ import { FlexCol as FlexCol3, FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
812
+ import { jsx as jsx9, jsxs as jsxs2 } from "react/jsx-runtime";
813
+ var ColorGradientLegend = ({ startColor, endColor, startLabel, endLabel, heading, textColor, ...props }) => {
814
+ const theme = useTheme3();
815
+ return /* @__PURE__ */ jsxs2(FlexCol3, { ...props, children: [
816
+ /* @__PURE__ */ jsx9(Typography, { mb: theme.spacing(0.25), color: textColor, variant: "caption", textAlign: "center", children: heading }),
817
+ /* @__PURE__ */ jsx9(FlexCol3, { flexGrow: 1, alignItems: "stretch", paddingX: theme.spacing(1), mb: theme.spacing(0.25), children: /* @__PURE__ */ jsx9(
818
+ FlexCol3,
819
+ {
820
+ height: theme.spacing(0.75),
821
+ border: `1px solid ${textColor}`,
822
+ sx: { backgroundImage: `linear-gradient(to right, ${startColor},${endColor})` }
823
+ }
824
+ ) }),
825
+ /* @__PURE__ */ jsxs2(FlexRow2, { flexGrow: 1, justifyContent: "space-between", children: [
826
+ /* @__PURE__ */ jsx9(Typography, { color: textColor, variant: "caption", children: startLabel }),
827
+ /* @__PURE__ */ jsx9(Typography, { color: textColor, variant: "caption", children: endLabel })
828
+ ] })
829
+ ] });
830
+ };
831
+
832
+ // src/Components/Legend.tsx
833
+ import { jsx as jsx10 } from "react/jsx-runtime";
834
+ var AnimatedHeatMapLegend = ({ ...legendProps }) => {
835
+ const { startColor, endColor, startLabel, endLabel, heading, textColor } = legendProps;
836
+ const theme = useTheme4();
837
+ const isSmall = useMediaQuery(theme.breakpoints.down("sm"));
838
+ return /* @__PURE__ */ jsx10(FlexCol4, { position: "absolute", bottom: 0, right: 0, children: /* @__PURE__ */ jsx10(
839
+ ColorGradientLegend,
840
+ {
841
+ startColor,
842
+ endColor,
843
+ startLabel,
844
+ endLabel,
845
+ heading,
846
+ textColor,
847
+ ...{
848
+ alignItems: "stretch",
849
+ marginBottom: theme.spacing(4),
850
+ marginLeft: isSmall ? theme.spacing(3) : 0,
851
+ marginRight: isSmall ? theme.spacing(2) : theme.spacing(3),
852
+ width: isSmall ? "40vw" : theme.spacing(18)
853
+ }
854
+ }
855
+ ) });
856
+ };
857
+
858
+ // src/Components/AnimatedHeatMapLoaded.tsx
859
+ import { jsx as jsx11, jsxs as jsxs3 } from "react/jsx-runtime";
860
+ var AnimatedHeatMapLoaded = ({ accessToken, archivistNameOrAddress, ...props }) => {
10
861
  const hashes = useFindHashes();
11
862
  const [archivist] = useArchivistFromNode(archivistNameOrAddress);
12
863
  const [payloads, xyoError] = useArchivistGet(archivist, hashes);
@@ -14,15 +865,15 @@ const AnimatedHeatMapLoaded = ({ accessToken, archivistNameOrAddress, ...props }
14
865
  const { heatMapColorProps, legendProps } = useHeatMapColors();
15
866
  const MapBoxHeatProps = {
16
867
  flexGrow: 1,
17
- legend: legendProps ? /* @__PURE__ */ jsx(AnimatedHeatMapLegend, { ...legendProps }) : null
868
+ legend: legendProps ? /* @__PURE__ */ jsx11(AnimatedHeatMapLegend, { ...legendProps }) : null
18
869
  };
19
- return /* @__PURE__ */ jsxs(FlexCol, { alignItems: "stretch", ...props, children: [
20
- xyoError ? /* @__PURE__ */ jsxs(Alert, { sx: { mt: 2 }, children: [
21
- /* @__PURE__ */ jsx(AlertTitle, { children: "Error Loading Map" }),
870
+ return /* @__PURE__ */ jsxs3(FlexCol5, { alignItems: "stretch", ...props, children: [
871
+ xyoError ? /* @__PURE__ */ jsxs3(Alert, { sx: { mt: 2 }, children: [
872
+ /* @__PURE__ */ jsx11(AlertTitle, { children: "Error Loading Map" }),
22
873
  xyoError.message ? `Error: ${xyoError.message}` : null,
23
874
  "You might try authenticating again."
24
875
  ] }) : null,
25
- hashes !== void 0 ? /* @__PURE__ */ jsx(
876
+ hashes !== void 0 ? /* @__PURE__ */ jsx11(
26
877
  AnimatedHeatMap,
27
878
  {
28
879
  accessToken,
@@ -32,7 +883,7 @@ const AnimatedHeatMapLoaded = ({ accessToken, archivistNameOrAddress, ...props }
32
883
  heatMapColorProps,
33
884
  ...MapBoxHeatProps
34
885
  }
35
- ) : /* @__PURE__ */ jsx(Alert, { children: "Missing answer hash for heat map query" })
886
+ ) : /* @__PURE__ */ jsx11(Alert, { children: "Missing answer hash for heat map query" })
36
887
  ] });
37
888
  };
38
889
  export {