@xyo-network/react-map 2.77.0 → 2.77.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.
Files changed (67) hide show
  1. package/dist/browser/MapBoxClasses/MapSettings.d.cts +0 -5
  2. package/dist/browser/MapBoxClasses/MapSettings.d.cts.map +1 -1
  3. package/dist/browser/MapBoxClasses/MapSettings.d.mts +0 -5
  4. package/dist/browser/MapBoxClasses/MapSettings.d.mts.map +1 -1
  5. package/dist/browser/MapBoxClasses/MapSettings.d.ts +0 -5
  6. package/dist/browser/MapBoxClasses/MapSettings.d.ts.map +1 -1
  7. package/dist/browser/Settings/MapSetting.d.cts +0 -5
  8. package/dist/browser/Settings/MapSetting.d.cts.map +1 -1
  9. package/dist/browser/Settings/MapSetting.d.mts +0 -5
  10. package/dist/browser/Settings/MapSetting.d.mts.map +1 -1
  11. package/dist/browser/Settings/MapSetting.d.ts +0 -5
  12. package/dist/browser/Settings/MapSetting.d.ts.map +1 -1
  13. package/dist/browser/hooks/useDynamicMapResize.d.cts +0 -3
  14. package/dist/browser/hooks/useDynamicMapResize.d.cts.map +1 -1
  15. package/dist/browser/hooks/useDynamicMapResize.d.mts +0 -3
  16. package/dist/browser/hooks/useDynamicMapResize.d.mts.map +1 -1
  17. package/dist/browser/hooks/useDynamicMapResize.d.ts +0 -3
  18. package/dist/browser/hooks/useDynamicMapResize.d.ts.map +1 -1
  19. package/dist/browser/index.cjs +2 -1332
  20. package/dist/browser/index.cjs.map +1 -1
  21. package/dist/browser/index.js +2 -1309
  22. package/dist/browser/index.js.map +1 -1
  23. package/dist/neutral/MapBoxClasses/MapSettings.d.cts +0 -5
  24. package/dist/neutral/MapBoxClasses/MapSettings.d.cts.map +1 -1
  25. package/dist/neutral/MapBoxClasses/MapSettings.d.mts +0 -5
  26. package/dist/neutral/MapBoxClasses/MapSettings.d.mts.map +1 -1
  27. package/dist/neutral/MapBoxClasses/MapSettings.d.ts +0 -5
  28. package/dist/neutral/MapBoxClasses/MapSettings.d.ts.map +1 -1
  29. package/dist/neutral/Settings/MapSetting.d.cts +0 -5
  30. package/dist/neutral/Settings/MapSetting.d.cts.map +1 -1
  31. package/dist/neutral/Settings/MapSetting.d.mts +0 -5
  32. package/dist/neutral/Settings/MapSetting.d.mts.map +1 -1
  33. package/dist/neutral/Settings/MapSetting.d.ts +0 -5
  34. package/dist/neutral/Settings/MapSetting.d.ts.map +1 -1
  35. package/dist/neutral/hooks/useDynamicMapResize.d.cts +0 -3
  36. package/dist/neutral/hooks/useDynamicMapResize.d.cts.map +1 -1
  37. package/dist/neutral/hooks/useDynamicMapResize.d.mts +0 -3
  38. package/dist/neutral/hooks/useDynamicMapResize.d.mts.map +1 -1
  39. package/dist/neutral/hooks/useDynamicMapResize.d.ts +0 -3
  40. package/dist/neutral/hooks/useDynamicMapResize.d.ts.map +1 -1
  41. package/dist/neutral/index.cjs +2 -1332
  42. package/dist/neutral/index.cjs.map +1 -1
  43. package/dist/neutral/index.js +2 -1309
  44. package/dist/neutral/index.js.map +1 -1
  45. package/dist/node/MapBoxClasses/MapSettings.d.cts +0 -5
  46. package/dist/node/MapBoxClasses/MapSettings.d.cts.map +1 -1
  47. package/dist/node/MapBoxClasses/MapSettings.d.mts +0 -5
  48. package/dist/node/MapBoxClasses/MapSettings.d.mts.map +1 -1
  49. package/dist/node/MapBoxClasses/MapSettings.d.ts +0 -5
  50. package/dist/node/MapBoxClasses/MapSettings.d.ts.map +1 -1
  51. package/dist/node/Settings/MapSetting.d.cts +0 -5
  52. package/dist/node/Settings/MapSetting.d.cts.map +1 -1
  53. package/dist/node/Settings/MapSetting.d.mts +0 -5
  54. package/dist/node/Settings/MapSetting.d.mts.map +1 -1
  55. package/dist/node/Settings/MapSetting.d.ts +0 -5
  56. package/dist/node/Settings/MapSetting.d.ts.map +1 -1
  57. package/dist/node/hooks/useDynamicMapResize.d.cts +0 -3
  58. package/dist/node/hooks/useDynamicMapResize.d.cts.map +1 -1
  59. package/dist/node/hooks/useDynamicMapResize.d.mts +0 -3
  60. package/dist/node/hooks/useDynamicMapResize.d.mts.map +1 -1
  61. package/dist/node/hooks/useDynamicMapResize.d.ts +0 -3
  62. package/dist/node/hooks/useDynamicMapResize.d.ts.map +1 -1
  63. package/dist/node/index.cjs +2 -1389
  64. package/dist/node/index.cjs.map +1 -1
  65. package/dist/node/index.js +2 -1312
  66. package/dist/node/index.js.map +1 -1
  67. package/package.json +7 -7
@@ -1,1333 +1,3 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- AnimatedHeatMap: () => AnimatedHeatMap,
24
- AnimatedHeatMapLegend: () => AnimatedHeatMapLegend,
25
- AnimatedHeatMapLoaded: () => AnimatedHeatMapLoaded,
26
- AnimatedHeatMapSettings: () => AnimatedHeatMapSettings,
27
- CircleLayerBuilder: () => CircleLayerBuilder,
28
- ColorGradientLegend: () => ColorGradientLegend,
29
- DefaultMapSettings: () => DefaultMapSettings,
30
- FillLayerBuilder: () => FillLayerBuilder,
31
- HeatMapFillLayerConfig: () => HeatMapFillLayerConfig,
32
- HeatMapInitializerProvider: () => HeatMapInitializerProvider,
33
- HeatMapLineLayerConfig: () => HeatMapLineLayerConfig,
34
- HeatMapSettings: () => HeatMapSettings,
35
- HeatMapSymbolLayerConfig: () => HeatMapSymbolLayerConfig,
36
- LayerAnimator: () => LayerAnimator,
37
- LineLayerBuilder: () => LineLayerBuilder,
38
- LocationHeatMapLayerBuilder: () => LocationHeatMapLayerBuilder,
39
- LocationHeatMapLayerBuilderAnimated: () => LocationHeatMapLayerBuilderAnimated,
40
- LocationPointLayerConfig: () => LocationPointLayerConfig,
41
- LocationPointsMapLayerBuilder: () => LocationPointsMapLayerBuilder,
42
- MapBase: () => MapBase,
43
- MapBox: () => MapBox,
44
- MapBoxInstanceProvider: () => MapBoxInstanceProvider,
45
- MapHeat: () => MapHeat,
46
- MapHeatConstants: () => MapHeatConstants,
47
- MapPoints: () => MapPoints,
48
- MapPointsConstants: () => MapPointsConstants,
49
- MapSettingSwitch: () => MapSettingSwitch,
50
- MapSettings: () => MapSettings,
51
- MapSettingsBox: () => MapSettingsBox,
52
- MapSettingsProvider: () => MapSettingsProvider,
53
- MapStyle: () => MapStyle,
54
- MapboxAccessTokenContext: () => MapboxAccessTokenContext,
55
- MapboxAccessTokenProvider: () => MapboxAccessTokenProvider,
56
- MapboxHeatFlexBox: () => MapboxHeatFlexBox,
57
- MapboxPointsFlexBox: () => MapboxPointsFlexBox,
58
- NetworkLocationAnswerSchema: () => NetworkLocationAnswerSchema,
59
- NetworkLocationHeatmapAnswerSchema: () => NetworkLocationHeatmapAnswerSchema,
60
- NetworkLocationHeatmapQuadkeyAnswerSchema: () => NetworkLocationHeatmapQuadkeyAnswerSchema,
61
- SymbolLayerBuilder: () => SymbolLayerBuilder,
62
- isNetworkLocationAnswer: () => isNetworkLocationAnswer,
63
- isNetworkLocationHeatmapAnswer: () => isNetworkLocationHeatmapAnswer,
64
- isNetworkLocationHeatmapQuadkeyAnswer: () => isNetworkLocationHeatmapQuadkeyAnswer,
65
- useDynamicMapResize: () => useDynamicMapResize,
66
- useDynamicPositioning: () => useDynamicPositioning,
67
- useFindHashes: () => useFindHashes,
68
- useHeatMapColors: () => useHeatMapColors,
69
- useHeatMapInitializer: () => useHeatMapInitializer,
70
- useMapBoxInstance: () => useMapBoxInstance,
71
- useMapSettings: () => useMapSettings,
72
- useMapboxAccessToken: () => useMapboxAccessToken,
73
- useQuadKeyPayloadsToFeatures: () => useQuadKeyPayloadsToFeatures
74
- });
75
- module.exports = __toCommonJS(src_exports);
76
-
77
- // src/Settings/DefaultMapSettings.ts
78
- var DefaultMapSettings = () => ({
79
- debugLayer: {
80
- devMode: true,
81
- field: "debugLayer",
82
- hidden: true,
83
- label: "Debug Layer",
84
- value: false
85
- },
86
- debugLogging: {
87
- devMode: true,
88
- field: "debugLogging",
89
- hidden: true,
90
- label: "Debug Logging",
91
- value: false
92
- },
93
- dynamicMapResize: {
94
- devMode: true,
95
- field: "dynamicMapResize",
96
- hidden: true,
97
- label: "Auto Map Resize",
98
- value: true
99
- },
100
- enableControls: {
101
- devMode: true,
102
- field: "enableControls",
103
- hidden: true,
104
- label: "Map Controls",
105
- value: false
106
- },
107
- fitToPoints: {
108
- devMode: true,
109
- field: "fitToPoints",
110
- hidden: true,
111
- label: "Fit To Points",
112
- value: false
113
- },
114
- preferDark: {
115
- devMode: false,
116
- field: "preferDark",
117
- hidden: true,
118
- label: "Prefer dark",
119
- value: false
120
- },
121
- scrollToZoom: {
122
- devMode: true,
123
- field: "scrollToZoom",
124
- hidden: true,
125
- label: "Scroll To Zoom",
126
- value: false
127
- }
128
- });
129
-
130
- // src/AnimatedHeatMapSettings.ts
131
- var AnimatedHeatMapSettings = DefaultMapSettings();
132
- var { debugLayer, scrollToZoom, fitToPoints, preferDark } = AnimatedHeatMapSettings;
133
- debugLayer.hidden = false;
134
- scrollToZoom.value = true;
135
- fitToPoints.value = false;
136
- preferDark.value = true;
137
-
138
- // src/Components/AnimatedHeatMap.tsx
139
- var import_material4 = require("@mui/material");
140
- var import_react_flexbox3 = require("@xylabs/react-flexbox");
141
- var import_react16 = require("react");
142
-
143
- // src/Contexts/HeatMapInitializer/Provider.tsx
144
- var import_forget2 = require("@xylabs/forget");
145
- var import_react12 = require("react");
146
-
147
- // src/hooks/useDynamicMapResize.tsx
148
- var import_react = require("react");
149
- var useDynamicMapResize = (mapContainerRef, mapCanvasRef, mapInstance, active = true) => {
150
- const [dependenciesReady, setDependenciesReady] = (0, import_react.useState)(false);
151
- const resizer = (0, import_react.useMemo)(
152
- () => new ResizeObserver(() => {
153
- const width = mapContainerRef.current?.getBoundingClientRect().width;
154
- if (width && mapCanvasRef.current) {
155
- mapCanvasRef.current.style.width = `${width}px`;
156
- setTimeout(() => mapInstance?.resize());
157
- }
158
- }),
159
- [mapCanvasRef, mapContainerRef, mapInstance]
160
- );
161
- (0, import_react.useEffect)(() => {
162
- const dependenciesReady2 = !!(active && mapInstance && mapContainerRef?.current && mapCanvasRef.current);
163
- setDependenciesReady(dependenciesReady2);
164
- }, [active, mapCanvasRef, mapContainerRef, mapInstance]);
165
- (0, import_react.useEffect)(() => {
166
- if (dependenciesReady) {
167
- if (mapContainerRef.current) {
168
- resizer.observe(mapContainerRef.current);
169
- }
170
- return () => {
171
- resizer.disconnect();
172
- };
173
- }
174
- }, [active, dependenciesReady, mapCanvasRef, mapContainerRef, mapInstance, resizer]);
175
- };
176
-
177
- // src/hooks/useDynamicPositioning.tsx
178
- var import_react_shared = require("@xylabs/react-shared");
179
- var import_react2 = require("react");
180
- var defaultZoom = 1.6;
181
- var defaultAspectRatioRange = [0.5, 2];
182
- var latRange = [0.9121644205263664, 1.71785031559439];
183
- var lngRange = [-81.4742014851959, 12.788958675506933];
184
- var linearInterpolate = (aspectRatio, degreeRange, aspectRatioRange) => {
185
- const [degreeMin, degreeMax] = degreeRange;
186
- const [aspectRatioMin, aspectRatioMax] = aspectRatioRange || defaultAspectRatioRange;
187
- const aspectRatioRangeSpan = aspectRatioMax - aspectRatioMin;
188
- const degreeRangeSpan = degreeMax - degreeMin;
189
- const percent = (aspectRatio - aspectRatioMin) / aspectRatioRangeSpan;
190
- const scaledDegree = percent * degreeRangeSpan + degreeMin;
191
- return scaledDegree;
192
- };
193
- var useDynamicPositioning = () => {
194
- const [options, setOptions] = (0, import_react2.useState)({});
195
- const { width, height } = (0, import_react_shared.useWindowSize)();
196
- (0, import_react2.useEffect)(() => {
197
- if (width && height) {
198
- const aspectRatio = width / height;
199
- setOptions({
200
- center: [linearInterpolate(aspectRatio, lngRange), linearInterpolate(aspectRatio, latRange)],
201
- zoom: defaultZoom
202
- });
203
- }
204
- }, [height, width]);
205
- return { options };
206
- };
207
-
208
- // src/hooks/useFindHashes.tsx
209
- var import_react_network = require("@xyo-network/react-network");
210
- var import_react3 = require("react");
211
- var animatedAnswerHashesConst = [
212
- "79af071f451fc7af10d009dc63236ef9a9b211732c1ee0c06f028fcecf2336c5",
213
- "531bfba6d8dfefd3bcc888aca54cdbbd4574ed2b3ec551b230845a1f9a608898",
214
- "c874412b4faa4947de81372fd1ba12fdd6f43f5e408622b7f357cb2bcb3f17cb",
215
- "29d3f8b882c61a82a1a1675782a27e797ea7196f45a23b4409680ab8b8d5f14e",
216
- "cfd20f80ac073fd9518f4ef3f43d2a1f5e4e56e40c2677f38d6f6fecd05df60c",
217
- "1354fa73497519a39aed19fc99bdbae78a880a1eafb2f7898d607e07db36528d",
218
- "1043b0d25eacfc5013ae9dba780305a6fbf01a43543bd871d7c00537fca142a9",
219
- "973dfc5df142851ced258d52d0ac2784e814000ac22e35776f772256b0d4dde9",
220
- "463808eb74d3d87e6563970e0301a493577f8cd1b501e6e0ffa5e027ad2cea95",
221
- "15b21acea2e3fd9d1ace3768a72636ee7bdf67a6f8e0807bfa2273dea2207555",
222
- "32d377bfe7ebe382598c54dd13f8af7510e0a1e2fd2e913311fdd58e517e5e2e,"
223
- ];
224
- var staticAnswerHashConst = "c7bbf61f61cfd4a1b2def160c28136fc1d100d39fbdb67b227a2c6e558d9d3a5";
225
- var useFindHashes = () => {
226
- const { network } = (0, import_react_network.useNetwork)();
227
- const exploreMapHashes = network?.nodes?.find((node) => node.type === "archivist")?.explorerMapHashes;
228
- const animatedAnswerHashes = exploreMapHashes?.animatedAnswerHashes || animatedAnswerHashesConst;
229
- const staticAnswerHash = exploreMapHashes?.staticAnswerHash || staticAnswerHashConst;
230
- const foundHashes = (0, import_react3.useMemo)(() => [staticAnswerHash, ...animatedAnswerHashes], [animatedAnswerHashes, staticAnswerHash]);
231
- return foundHashes;
232
- };
233
-
234
- // src/hooks/useHeatMapColors.tsx
235
- var import_material = require("@mui/material");
236
- var useHeatMapColors = () => {
237
- const theme = (0, import_material.useTheme)();
238
- const staticMapColor = "#FFFF75";
239
- const highUsageColor = "#FF0000";
240
- const heatMapColorProps = {
241
- highUsageColor,
242
- lowUsageColor: "#FFB3B3",
243
- staticMapColor
244
- };
245
- const legendProps = {
246
- endColor: highUsageColor,
247
- endLabel: "High",
248
- heading: "Network Usage",
249
- startColor: staticMapColor,
250
- startLabel: "Low",
251
- textColor: theme.palette.common.white
252
- };
253
- return { heatMapColorProps, legendProps };
254
- };
255
-
256
- // src/hooks/useQuadKeyPayloadsToFeatures.tsx
257
- var import_lodash = require("@xylabs/lodash");
258
- var import_sdk_geo = require("@xyo-network/sdk-geo");
259
- var import_react4 = require("react");
260
- var quadKeyToFeature = ({ density, quadkey }) => {
261
- const polygonFeature = new import_sdk_geo.GeoJson(quadkey).polygonFeature();
262
- polygonFeature.properties = {
263
- count: density,
264
- density
265
- };
266
- return polygonFeature;
267
- };
268
- var setDensity = (feature) => {
269
- if (feature.properties) {
270
- feature.properties.value = feature.properties.density / 5;
271
- }
272
- return feature;
273
- };
274
- var useQuadKeyPayloadsToFeatures = (payloads) => {
275
- const [multipleFeatureSets, setMultipleFeatureSets] = (0, import_react4.useState)([[]]);
276
- const [features, setFeatures] = (0, import_react4.useState)([]);
277
- const [error, setError] = (0, import_react4.useState)();
278
- (0, import_react4.useEffect)(() => {
279
- if (Array.isArray(payloads)) {
280
- if ((0, import_lodash.compact)(payloads).length > 0) {
281
- const mappedFeatures = payloads?.map((payload) => payload?.result.map(quadKeyToFeature));
282
- setMultipleFeatureSets(mappedFeatures.map((features2) => features2?.map(setDensity) ?? []));
283
- } else {
284
- setError(new Error("Cannot find payloads for provided hashes"));
285
- }
286
- }
287
- if (payloads && payloads.result) {
288
- const singlePayload = payloads;
289
- const mappedFeatures = singlePayload.result.map(quadKeyToFeature);
290
- setFeatures(mappedFeatures.map(setDensity));
291
- }
292
- }, [payloads]);
293
- return { error, features, multipleFeatureSets };
294
- };
295
-
296
- // src/MapBoxClasses/MapBase.ts
297
- var import_assert = require("@xylabs/assert");
298
- var import_sdk_geo2 = require("@xyo-network/sdk-geo");
299
- var MapBase = class {
300
- _config;
301
- constructor(config) {
302
- this._config = { requestLocation: true, zoom: 2, ...config };
303
- }
304
- get isMapReady() {
305
- return !!this._config.map;
306
- }
307
- initializeMapSource(layer) {
308
- const getSource = () => {
309
- const featuresCollection = import_sdk_geo2.GeoJson.featureCollection(this._config.features);
310
- return import_sdk_geo2.GeoJson.featuresSource(featuresCollection);
311
- };
312
- const existingSource = this._config.map.getSource(layer.source);
313
- const source = getSource();
314
- if (existingSource) {
315
- existingSource.setData((0, import_assert.assertEx)(source.data));
316
- } else {
317
- this._config.map.addSource(layer.source, source);
318
- }
319
- layer.update(this._config.map, true);
320
- return this;
321
- }
322
- };
323
-
324
- // src/MapBoxClasses/MapHeat.ts
325
- var import_assert2 = require("@xylabs/assert");
326
- var import_delay = require("@xylabs/delay");
327
- var import_forget = require("@xylabs/forget");
328
- var import_sdk_geo3 = require("@xyo-network/sdk-geo");
329
- var import_mapbox_gl = require("mapbox-gl");
330
- var MapHeat = class extends MapBase {
331
- static animationStarted = false;
332
- config;
333
- constructor(config) {
334
- super(config);
335
- this.config = config;
336
- }
337
- static initialMapPositioning(options, map, features, initialBounds) {
338
- if (!features) {
339
- return;
340
- }
341
- let bounds;
342
- if (initialBounds) {
343
- bounds = initialBounds;
344
- } else {
345
- bounds = new import_mapbox_gl.LngLatBounds();
346
- features.forEach((feature) => {
347
- for (const coordinates of feature.geometry.coordinates) {
348
- for (const position of coordinates) {
349
- bounds.extend(position);
350
- }
351
- }
352
- });
353
- }
354
- map.setCenter(bounds.getCenter());
355
- map.fitBounds(bounds, options);
356
- return this;
357
- }
358
- static async initializeAnimatedHeatMapSource(layers, featureSet, map, startColor, endColor) {
359
- this.animationStarted = true;
360
- let layerTick = 0;
361
- let sourceTick = 0;
362
- const sources = featureSet.map((feature) => {
363
- const featuresCollection = import_sdk_geo3.GeoJson.featureCollection(feature);
364
- return import_sdk_geo3.GeoJson.featuresSource(featuresCollection);
365
- });
366
- this.updateLayer(map, layers[0], sources[0]);
367
- this.updateLayer(map, layers[1], sources[1]);
368
- for (const layer of layers) {
369
- map.setPaintProperty(layer.id, "fill-opacity", 0);
370
- }
371
- const frameLength = 3e3;
372
- const initialPad = 0.5;
373
- const factor = 10;
374
- const steps = 30;
375
- const stepLength = frameLength / steps;
376
- const lowUsageColor = startColor ?? "#FFB3B3";
377
- const highUsageColor = endColor ?? "#FF0000";
378
- const dynamicFillColor = (factor2, initialPad2, i) => {
379
- const sinFade = Math.sin(i / steps * Math.PI / 2);
380
- const cosFade = Math.cos(i / steps * Math.PI / 2);
381
- const divisor = factor2 + factor2 * sinFade;
382
- const offset = initialPad2 * cosFade;
383
- return [
384
- "let",
385
- "density",
386
- ["+", ["/", ["number", ["get", "value"]], divisor], offset],
387
- ["interpolate", ["linear"], ["var", "density"], 0, lowUsageColor, 0.5, highUsageColor]
388
- ];
389
- };
390
- const fadedIn = layers.map((_) => false);
391
- const fadeIn = async (id, index) => {
392
- for (let i = steps; i >= 1; i--) {
393
- map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
394
- await (0, import_delay.delay)(stepLength);
395
- }
396
- fadedIn[index] = true;
397
- };
398
- const fadeOut = async (id, index) => {
399
- for (let i = 1; i <= steps; i++) {
400
- map.setPaintProperty(id, "fill-color", dynamicFillColor(factor, initialPad, i * (180 / stepLength)));
401
- await (0, import_delay.delay)(stepLength);
402
- }
403
- fadedIn[index] = false;
404
- };
405
- let started = false;
406
- const startAnimation = async () => {
407
- (0, import_assert2.assertEx)(!started, () => "Animation Already Started");
408
- started = true;
409
- while (this.animationStarted) {
410
- const upLayer = layerTick % layers.length;
411
- const downLayer = (layerTick + 1) % layers.length;
412
- const incomingSource = sourceTick % featureSet.length;
413
- const outgoingSource = (sourceTick + 1) % featureSet.length;
414
- if (fadedIn[upLayer]) {
415
- this.updateLayer(map, layers[upLayer], sources[incomingSource]);
416
- (0, import_forget.forget)(fadeOut(layers[upLayer].id, upLayer));
417
- }
418
- if (!fadedIn[downLayer]) {
419
- this.updateLayer(map, layers[downLayer], sources[outgoingSource]);
420
- (0, import_forget.forget)(fadeIn(layers[downLayer].id, downLayer));
421
- }
422
- while ((fadedIn[upLayer] || !fadedIn[downLayer]) && this.animationStarted) {
423
- await (0, import_delay.delay)(1e3);
424
- }
425
- layerTick++;
426
- sourceTick++;
427
- }
428
- };
429
- await startAnimation();
430
- }
431
- static updateLayer(map, layer, source) {
432
- const existingSource = map.getSource(layer.source);
433
- if (existingSource && source.data) {
434
- existingSource.setData(source.data);
435
- } else if (source) {
436
- map.addSource(layer.source, source);
437
- }
438
- layer.update(map, true);
439
- }
440
- // Build layers each with the same features
441
- initializeHeatMapSource(layers) {
442
- const getSource = (_) => {
443
- const featuresCollection = import_sdk_geo3.GeoJson.featureCollection(this.config.features);
444
- return import_sdk_geo3.GeoJson.featuresSource(featuresCollection);
445
- };
446
- for (const [index, layer] of layers.entries()) {
447
- const existingSource = this.config.map.getSource(layer.source);
448
- const source = getSource(index);
449
- if (existingSource) {
450
- existingSource.setData((0, import_assert2.assertEx)(source.data));
451
- } else {
452
- this.config.map.addSource(layer.source, source);
453
- }
454
- layer.update(this.config.map, true);
455
- }
456
- return this;
457
- }
458
- };
459
-
460
- // src/MapBoxClasses/MapPoints.ts
461
- var import_mapbox_gl2 = require("mapbox-gl");
462
- var MapPoints = class extends MapBase {
463
- config;
464
- constructor(config) {
465
- super(config);
466
- this.config = config;
467
- }
468
- initialMapPositioning(options, initialBounds) {
469
- let bounds;
470
- if (initialBounds) {
471
- bounds = initialBounds;
472
- } else {
473
- bounds = new import_mapbox_gl2.LngLatBounds();
474
- this.config.features.forEach((feature) => {
475
- bounds.extend(feature.geometry.coordinates);
476
- });
477
- }
478
- this.config.map.setCenter(bounds.getCenter());
479
- this.config.map.fitBounds(bounds, options);
480
- return this.config.map;
481
- }
482
- };
483
-
484
- // src/MapBoxClasses/MapSettings.ts
485
- var import_mapbox_gl3 = require("mapbox-gl");
486
- var MapSettings = class _MapSettings {
487
- static geoLocateControl;
488
- static mapListeners = {
489
- logData: (ev, map) => {
490
- const target = map || ev?.target;
491
- if (target) {
492
- console.log("zoom", target.getZoom());
493
- console.log("center", target.getCenter());
494
- }
495
- }
496
- };
497
- static navControl;
498
- static requestLocation;
499
- static toggleControls(value, map, zoom, requestLocation) {
500
- if (value) {
501
- _MapSettings.addControls(map, zoom, requestLocation);
502
- } else {
503
- _MapSettings.removeControls(map);
504
- }
505
- return this;
506
- }
507
- static toggleDebugLayer(value, map, layerName) {
508
- const debugLayer3 = map.getLayer(layerName);
509
- if (debugLayer3) {
510
- if (value) {
511
- map.setLayoutProperty(layerName, "visibility", "visible");
512
- } else {
513
- map.setLayoutProperty(layerName, "visibility", "none");
514
- }
515
- }
516
- return this;
517
- }
518
- static toggleDebugLogging(value, map) {
519
- const debugEvents = ["resize", "zoomend", "dragend"];
520
- if (value) {
521
- this.mapListeners.logData(void 0, map);
522
- for (const event of debugEvents)
523
- map.on(event, this.mapListeners.logData);
524
- } else {
525
- for (const event of debugEvents)
526
- map.off(event, this.mapListeners.logData);
527
- }
528
- }
529
- static toggleScrollToZoom(value, map) {
530
- if (value) {
531
- map.scrollZoom.enable();
532
- } else {
533
- map.scrollZoom.disable();
534
- }
535
- return this;
536
- }
537
- static updateSettings(config) {
538
- const { settings, map, zoom, requestLocation, debugLayerName = "" } = config;
539
- const { scrollToZoom: scrollToZoom3, enableControls, debugLayer: debugLayer3, debugLogging } = settings;
540
- _MapSettings.toggleControls(enableControls?.value, map, zoom, requestLocation).toggleScrollToZoom(scrollToZoom3?.value, map).toggleDebugLayer(debugLayer3?.value, map, debugLayerName).toggleDebugLogging(debugLogging.value, map);
541
- }
542
- // Needs to be static so we ensure controls are only instantiated once
543
- static addControls(map, zoom, requestLocation) {
544
- const geolocateControl = new import_mapbox_gl3.GeolocateControl({
545
- fitBoundsOptions: {
546
- zoom: zoom || 2
547
- },
548
- positionOptions: {
549
- enableHighAccuracy: true
550
- },
551
- trackUserLocation: true
552
- });
553
- const navControl = new import_mapbox_gl3.NavigationControl({
554
- showCompass: false
555
- });
556
- this.geoLocateControl = this.geoLocateControl || geolocateControl;
557
- this.navControl = this.navControl || navControl;
558
- if (!map.hasControl(this.geoLocateControl) && requestLocation) {
559
- map.addControl(this.geoLocateControl);
560
- }
561
- if (!map.hasControl(this.navControl)) {
562
- map.addControl(this.navControl, "top-left");
563
- }
564
- return this;
565
- }
566
- static removeControls(map) {
567
- if (this.geoLocateControl && map.hasControl(this.geoLocateControl) && this.requestLocation) {
568
- map.removeControl(this.geoLocateControl);
569
- }
570
- if (this.navControl && map.hasControl(this.navControl)) {
571
- map.removeControl(this.navControl);
572
- }
573
- return this;
574
- }
575
- };
576
-
577
- // src/Contexts/MapBoxInstance/Provider.tsx
578
- var import_react6 = require("react");
579
-
580
- // src/Contexts/MapBoxInstance/Context.ts
581
- var import_react5 = require("react");
582
- var MapBoxInstanceContext = (0, import_react5.createContext)({});
583
-
584
- // src/Contexts/MapBoxInstance/Provider.tsx
585
- var import_jsx_runtime = require("react/jsx-runtime");
586
- var MapBoxInstanceProvider = ({ children }) => {
587
- const [map, setMapBoxInstance] = (0, import_react6.useState)();
588
- const [mapInitialized, setMapInitialized] = (0, import_react6.useState)(false);
589
- const value = { map, mapInitialized, setMapBoxInstance };
590
- (0, import_react6.useEffect)(() => {
591
- if (!mapInitialized && map) {
592
- map?.on("load", () => {
593
- setMapInitialized(true);
594
- });
595
- }
596
- }, [map, mapInitialized, setMapInitialized]);
597
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MapBoxInstanceContext.Provider, { value, children });
598
- };
599
-
600
- // src/Contexts/MapBoxInstance/useMapBoxInstance.tsx
601
- var import_assert3 = require("@xylabs/assert");
602
- var import_react7 = require("react");
603
- var useMapBoxInstance = () => {
604
- const context = (0, import_react7.useContext)(MapBoxInstanceContext);
605
- (0, import_assert3.assertEx)("map" in context, () => "useMapBoxInstance must be used within a MapBoxInstanceContext");
606
- return context;
607
- };
608
-
609
- // src/Contexts/MapSettings/Provider.tsx
610
- var import_react9 = require("react");
611
-
612
- // src/Contexts/MapSettings/Context.ts
613
- var import_react8 = require("react");
614
- var MapSettingsContext = (0, import_react8.createContext)({});
615
-
616
- // src/Contexts/MapSettings/Provider.tsx
617
- var import_jsx_runtime2 = require("react/jsx-runtime");
618
- var MapSettingsProvider = ({
619
- children,
620
- debugLayerName,
621
- defaultMapSettings,
622
- requestLocation,
623
- zoom = 1
624
- }) => {
625
- const [mapSettings, setMapSettings] = (0, import_react9.useState)(defaultMapSettings || {});
626
- const { map, mapInitialized } = useMapBoxInstance();
627
- const value = {
628
- mapSettings,
629
- setMapSettings
630
- };
631
- (0, import_react9.useEffect)(() => {
632
- if (mapSettings && map && mapInitialized) {
633
- MapSettings.updateSettings({ debugLayerName, map, requestLocation, settings: mapSettings, zoom });
634
- }
635
- }, [debugLayerName, map, mapInitialized, mapSettings, requestLocation, zoom]);
636
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(MapSettingsContext.Provider, { value, children });
637
- };
638
-
639
- // src/Contexts/MapSettings/useMapSettings.tsx
640
- var import_react10 = require("react");
641
- var useMapSettings = () => {
642
- const context = (0, import_react10.useContext)(MapSettingsContext);
643
- return context;
644
- };
645
-
646
- // src/Contexts/HeatMapInitializer/Context.ts
647
- var import_react11 = require("react");
648
- var HeatMapInitializerContext = (0, import_react11.createContext)({});
649
-
650
- // src/Contexts/HeatMapInitializer/Provider.tsx
651
- var import_jsx_runtime3 = require("react/jsx-runtime");
652
- var HeatMapInitializerProvider = ({
653
- children,
654
- featureSets,
655
- featureSetsLayers,
656
- features,
657
- fitToPadding,
658
- heatMapColorProps,
659
- layers,
660
- zoom
661
- }) => {
662
- const [mapHeat, setMapHeat] = (0, import_react12.useState)();
663
- const { options } = useDynamicPositioning();
664
- const { mapSettings } = useMapSettings();
665
- const { map, mapInitialized } = useMapBoxInstance();
666
- const value = {
667
- MapHeat: mapHeat,
668
- heatMapColorProps
669
- };
670
- (0, import_react12.useEffect)(() => {
671
- if (mapInitialized && featureSets?.length && featureSets[0].length > 0 && map && featureSetsLayers?.length) {
672
- const { lowUsageColor, highUsageColor } = heatMapColorProps;
673
- (0, import_forget2.forget)(MapHeat.initializeAnimatedHeatMapSource(featureSetsLayers, featureSets, map, lowUsageColor, highUsageColor));
674
- }
675
- return () => {
676
- MapHeat.animationStarted = false;
677
- };
678
- }, [featureSets, featureSetsLayers, mapInitialized, map, heatMapColorProps]);
679
- (0, import_react12.useEffect)(() => {
680
- if (mapHeat && mapInitialized && features?.length && layers?.length) {
681
- mapHeat.initializeHeatMapSource(layers);
682
- }
683
- }, [mapHeat, features?.length, layers, mapInitialized]);
684
- (0, import_react12.useEffect)(() => {
685
- if (mapInitialized) {
686
- const { fitToPoints: fitToPoints3 } = mapSettings || {};
687
- if (map) {
688
- if (fitToPoints3?.value === true) {
689
- MapHeat.initialMapPositioning({ padding: fitToPadding }, map, features);
690
- } else if (options.zoom && options.center) {
691
- map.setZoom(options.zoom);
692
- map.setCenter(options.center);
693
- }
694
- }
695
- }
696
- }, [mapHeat, map, mapSettings, fitToPadding, options, mapInitialized, features]);
697
- (0, import_react12.useEffect)(() => {
698
- if (map && features?.length) {
699
- setMapHeat(new MapHeat({ features, map, zoom }));
700
- }
701
- }, [map, features, zoom]);
702
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(HeatMapInitializerContext.Provider, { value, children });
703
- };
704
-
705
- // src/Contexts/HeatMapInitializer/useHeatMapInitializer.tsx
706
- var import_assert4 = require("@xylabs/assert");
707
- var import_react13 = require("react");
708
- var useHeatMapInitializer = () => {
709
- const context = (0, import_react13.useContext)(HeatMapInitializerContext);
710
- (0, import_assert4.assertEx)("heatMapInitialized" in context, () => "useHeatMapInitializer must be used within a HeatMapInitializerContext");
711
- return context;
712
- };
713
-
714
- // src/Contexts/MapboxAccessToken/Context.ts
715
- var import_react_shared2 = require("@xyo-network/react-shared");
716
- var MapboxAccessTokenContext = (0, import_react_shared2.createContextEx)();
717
-
718
- // src/Contexts/MapboxAccessToken/Provider.tsx
719
- var import_react14 = require("react");
720
- var import_jsx_runtime4 = require("react/jsx-runtime");
721
- var MapboxAccessTokenProvider = ({ defaultAccessToken, ...props }) => {
722
- const [accessToken, setAccessToken] = (0, import_react14.useState)();
723
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(MapboxAccessTokenContext.Provider, { value: { accessToken: accessToken ?? defaultAccessToken, provided: true, setAccessToken }, ...props });
724
- };
725
-
726
- // src/Contexts/MapboxAccessToken/use.ts
727
- var import_react_shared3 = require("@xyo-network/react-shared");
728
- var useMapboxAccessToken = (required = false) => {
729
- return (0, import_react_shared3.useContextEx)(MapboxAccessTokenContext, "MapboxAccessToken", required);
730
- };
731
-
732
- // src/Layers/Configs/HeatMapFillLayerConfig.ts
733
- var HeatMapFillLayerConfig = (color) => ({
734
- paint: {
735
- "fill-color": color,
736
- "fill-opacity": [
737
- "let",
738
- "density",
739
- ["+", ["/", ["number", ["get", "value"]], 4], 0.125],
740
- ["interpolate", ["linear"], ["var", "density"], 0.8, ["var", "density"], 1, 0.85]
741
- ]
742
- }
743
- });
744
-
745
- // src/Layers/Configs/HeatMapLineLayerConfig.ts
746
- var HeatMapLineLayerConfig = (color) => ({
747
- layout: {
748
- // Enable for debugging
749
- visibility: "none"
750
- },
751
- paint: {
752
- "line-color": color,
753
- "line-opacity": ["let", "density", 0, ["interpolate", ["linear"], ["var", "density"], 0.8, ["var", "density"], 1, 0.85]],
754
- "line-width": 0.5
755
- }
756
- });
757
-
758
- // src/Layers/Configs/HeatMapSymbolLayerConfig.ts
759
- var HeatMapSymbolLayerConfig = (color) => ({
760
- layout: {
761
- "text-anchor": "center",
762
- "text-field": [
763
- "concat",
764
- "value: ",
765
- ["to-string", ["+", ["/", ["number", ["get", "value"]], 2], 0.25]],
766
- "\n",
767
- "count: ",
768
- ["to-string", ["get", "count"]]
769
- ],
770
- "text-size": 10,
771
- visibility: "none"
772
- },
773
- paint: {
774
- "text-color": color
775
- }
776
- });
777
-
778
- // src/Layers/Configs/LocationPointLayerConfig.ts
779
- var LocationPointLayerConfig = (color, circleRadius, circleOpacity) => {
780
- return {
781
- paint: {
782
- "circle-color": color,
783
- "circle-opacity": circleOpacity,
784
- "circle-radius": circleRadius
785
- }
786
- };
787
- };
788
-
789
- // src/Layers/FillLayer.ts
790
- var import_sdk_geo4 = require("@xyo-network/sdk-geo");
791
- var FillLayerBuilder = class extends import_sdk_geo4.LayerBase {
792
- FillLayerOptions;
793
- // ensures this class passes for `AnyLayer` type in MapBox
794
- type = "fill";
795
- constructor(id, source, FillLayerOptions) {
796
- super(id, source);
797
- this.FillLayerOptions = FillLayerOptions || { id: this.id, source: this.source };
798
- }
799
- buildLayer() {
800
- return {
801
- ...this.FillLayerOptions,
802
- id: this.id,
803
- source: this.source,
804
- type: this.type
805
- };
806
- }
807
- };
808
-
809
- // src/Layers/LineLayer.ts
810
- var import_sdk_geo5 = require("@xyo-network/sdk-geo");
811
- var LineLayerBuilder = class extends import_sdk_geo5.LayerBase {
812
- LineLayerOptions;
813
- // ensures this class passes for `AnyLayer` type in MapBox
814
- type = "line";
815
- constructor(id, source, LineLayerOptions) {
816
- super(id, source);
817
- this.LineLayerOptions = LineLayerOptions || { id: this.id, source: this.source };
818
- }
819
- buildLayer() {
820
- return {
821
- ...this.LineLayerOptions,
822
- id: this.id,
823
- layout: {},
824
- source: this.source,
825
- type: this.type
826
- };
827
- }
828
- };
829
-
830
- // src/Layers/SymbolLayer.ts
831
- var import_sdk_geo6 = require("@xyo-network/sdk-geo");
832
- var SymbolLayerBuilder = class extends import_sdk_geo6.LayerBase {
833
- SymbolLayerOptions;
834
- // ensures this class passes for `AnyLayer` type in MapBox
835
- type = "symbol";
836
- constructor(id, source, SymbolLayerOptions) {
837
- super(id, source);
838
- this.SymbolLayerOptions = SymbolLayerOptions || { id: this.id, source: this.source };
839
- }
840
- buildLayer() {
841
- return {
842
- ...this.SymbolLayerOptions,
843
- id: this.id,
844
- source: this.source,
845
- type: this.type
846
- };
847
- }
848
- };
849
-
850
- // src/Layers/Builders/LocationHeatMapLayerBuilder.ts
851
- var MapHeatConstants = {
852
- LocationDebugLayerId: "location-debug-id",
853
- LocationDebugLayerSource: "location-debug-source",
854
- LocationFillLayerId: "location-fill-id",
855
- LocationFillLayerSource: "location-fill-source",
856
- LocationLineLayerId: "location-line-id",
857
- LocationLineLayerSource: "location-line-source"
858
- };
859
- var LocationHeatMapLayerBuilder = (color, alternateColor = "#000") => {
860
- const {
861
- LocationFillLayerId,
862
- LocationFillLayerSource,
863
- LocationLineLayerId,
864
- LocationLineLayerSource,
865
- LocationDebugLayerId,
866
- LocationDebugLayerSource
867
- } = MapHeatConstants;
868
- const fillLayerConfig = HeatMapFillLayerConfig(color);
869
- const lineLayerConfig = HeatMapLineLayerConfig(color);
870
- const debugLayerConfig = HeatMapSymbolLayerConfig(alternateColor);
871
- const fillLayer = new FillLayerBuilder(LocationFillLayerId, LocationFillLayerSource, fillLayerConfig);
872
- const lineLayer = new LineLayerBuilder(LocationLineLayerId, LocationLineLayerSource, lineLayerConfig);
873
- const debugLayer3 = new SymbolLayerBuilder(LocationDebugLayerId, LocationDebugLayerSource, debugLayerConfig);
874
- return [fillLayer, lineLayer, debugLayer3];
875
- };
876
-
877
- // src/Layers/Builders/LocationHeatMapLayerBuilderAnimated.ts
878
- var MapHeatConstants2 = (index, type) => ({
879
- LocationDebugLayerId: `location-${type}-debug-id-${index}`,
880
- LocationDebugLayerSource: `location-${type}-debug-source-${index}`,
881
- LocationFillLayerId: `location-${type}-fill-id-${index}`,
882
- LocationFillLayerSource: `location-${type}-fill-source-${index}`,
883
- LocationLineLayerId: `location-${type}-line-id-${index}`,
884
- LocationLineLayerSource: `location-${type}-line-source-${index}`
885
- });
886
- var LocationHeatMapLayerBuilderAnimated = (color, index, type = "") => {
887
- const { LocationFillLayerId, LocationFillLayerSource } = MapHeatConstants2(index, type);
888
- const fillLayerConfig = HeatMapFillLayerConfig(color);
889
- const fillLayer = new FillLayerBuilder(LocationFillLayerId, LocationFillLayerSource, fillLayerConfig);
890
- return fillLayer;
891
- };
892
-
893
- // src/Layers/CircleLayer.ts
894
- var import_sdk_geo7 = require("@xyo-network/sdk-geo");
895
- var CircleLayerBuilder = class extends import_sdk_geo7.LayerBase {
896
- CircleLayerOptions;
897
- // ensures this class passes for `AnyLayer` type in MapBox
898
- type = "circle";
899
- constructor(id, source, CircleLayerOptions) {
900
- super(id, source);
901
- this.CircleLayerOptions = CircleLayerOptions || { id: this.id, source: this.source, type: "circle" };
902
- }
903
- buildLayer() {
904
- return {
905
- filter: ["==", "$type", "Point"],
906
- layout: {},
907
- paint: {
908
- "circle-color": "#ff0000",
909
- "circle-radius": 6
910
- },
911
- type: this.type,
912
- ...this.CircleLayerOptions,
913
- id: this.id,
914
- source: this.source
915
- };
916
- }
917
- };
918
-
919
- // src/Layers/Builders/LocationPointsMapLayerBuilder.ts
920
- var MapPointsConstants = {
921
- LocationDotsLayerId: "location-dots",
922
- LocationDotsLayerSource: "location-dots-source"
923
- };
924
- var LocationPointsMapLayerBuilder = (color, circleRadius = 6, circleOpacity = 0.8) => {
925
- const { LocationDotsLayerId, LocationDotsLayerSource } = MapPointsConstants;
926
- const dotLayerConfig = LocationPointLayerConfig(color, circleRadius, circleOpacity);
927
- const dotLayer = new CircleLayerBuilder(LocationDotsLayerId, LocationDotsLayerSource, dotLayerConfig);
928
- return [dotLayer];
929
- };
930
-
931
- // src/Components/MapBoxHeat.tsx
932
- var import_react_flexbox2 = require("@xylabs/react-flexbox");
933
-
934
- // src/Components/MapBox.tsx
935
- var import_mapbox_gl4 = require("mapbox-gl/dist/mapbox-gl.css");
936
- var import_mapbox_gl5 = require("mapbox-gl");
937
- var import_react15 = require("react");
938
-
939
- // src/lib/MapStyle.ts
940
- var MapStyle = /* @__PURE__ */ ((MapStyle2) => {
941
- MapStyle2["Dark"] = "mapbox/dark-v10";
942
- MapStyle2["Light"] = "mapbox/light-v10";
943
- MapStyle2["Outdoors"] = "mapbox/outdoors-v11";
944
- MapStyle2["Satellite"] = "mapbox/satellite-v9";
945
- MapStyle2["SatelliteStreets"] = "mapbox/satellite-streets-v11";
946
- MapStyle2["Streets"] = "mapbox/streets-v11";
947
- return MapStyle2;
948
- })(MapStyle || {});
949
-
950
- // src/Components/MapBox.tsx
951
- var import_jsx_runtime5 = require("react/jsx-runtime");
952
- var MapBox = ({ accessToken, darkMode = false, options, zoom = 2, ...props }) => {
953
- const [map, setMap] = (0, import_react15.useState)();
954
- const mapContainerRef = (0, import_react15.useRef)(null);
955
- const mapCanvasRef = (0, import_react15.useRef)(null);
956
- const { setMapBoxInstance, map: mapInstance } = useMapBoxInstance();
957
- const { mapSettings } = useMapSettings();
958
- const activeResize = mapSettings?.dynamicMapResize.value;
959
- useDynamicMapResize(mapContainerRef, mapCanvasRef, mapInstance, activeResize);
960
- (0, import_react15.useEffect)(() => {
961
- if (mapSettings?.preferDark?.value === true) {
962
- map?.setStyle(`mapbox://styles/${"mapbox/dark-v10" /* Dark */}`);
963
- } else {
964
- map?.setStyle(`mapbox://styles/${darkMode ? "mapbox/dark-v10" /* Dark */ : "mapbox/light-v10" /* Light */}`);
965
- }
966
- }, [map, darkMode, mapSettings]);
967
- (0, import_react15.useEffect)(() => {
968
- const map2 = new import_mapbox_gl5.Map({
969
- accessToken,
970
- center: [0, 0],
971
- container: mapContainerRef.current ?? "",
972
- style: `mapbox://styles/${"mapbox/light-v10" /* Light */}`,
973
- zoom,
974
- ...options
975
- });
976
- setMapBoxInstance?.(map2);
977
- setMap(map2);
978
- mapCanvasRef.current = document.querySelector(".mapboxgl-canvas");
979
- console.log("Created Map");
980
- return () => {
981
- console.log("Removing Map");
982
- map2.remove();
983
- };
984
- }, [mapContainerRef, setMap, options, zoom, setMapBoxInstance, accessToken]);
985
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
986
- "div",
987
- {
988
- ref: (el) => mapContainerRef.current = el,
989
- style: {
990
- bottom: 0,
991
- left: 0,
992
- position: "absolute",
993
- right: 0,
994
- top: 0,
995
- ...props
996
- }
997
- }
998
- );
999
- };
1000
-
1001
- // src/Components/MapSettingsComponents/Setting.tsx
1002
- var import_material2 = require("@mui/material");
1003
- var import_jsx_runtime6 = require("react/jsx-runtime");
1004
- var MapSettingSwitch = ({ developerMode, field, ...props }) => {
1005
- const { mapSettings, setMapSettings } = useMapSettings();
1006
- const setting = mapSettings?.[field];
1007
- const onLocalChange = (event) => {
1008
- if (setting) {
1009
- setMapSettings?.((previous) => {
1010
- previous[setting.field].value = event.target.checked;
1011
- return { ...previous };
1012
- });
1013
- }
1014
- };
1015
- if (setting?.devMode && developerMode === false) {
1016
- return null;
1017
- }
1018
- return setting?.hidden ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material2.FormControlLabel, { label: setting?.label, control: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material2.Switch, { checked: setting?.value, onChange: onLocalChange, ...props }) });
1019
- };
1020
-
1021
- // src/Components/MapSettingsComponents/SettingsBox.tsx
1022
- var import_material3 = require("@mui/material");
1023
- var import_react_flexbox = require("@xylabs/react-flexbox");
1024
- var import_react_app_settings = require("@xyo-network/react-app-settings");
1025
- var import_jsx_runtime7 = require("react/jsx-runtime");
1026
- var MapSettingsBox = ({ developerMode, ...props }) => {
1027
- const { mapSettings } = useMapSettings();
1028
- const { developerMode: devModeFromContext } = (0, import_react_app_settings.useAppSettings)();
1029
- const resolveDeveloperMode = developerMode ?? devModeFromContext;
1030
- return mapSettings && resolveDeveloperMode ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_flexbox.FlexGrowRow, { bottom: 36, left: 10, position: "absolute", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react_flexbox.FlexRow, { paddingX: 2, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material3.Paper, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material3.Stack, { direction: "row", spacing: 1, marginX: 1, children: Object.keys(mapSettings).map((key, index) => {
1031
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(MapSettingSwitch, { field: mapSettings[key].field, developerMode }, index);
1032
- }) }) }) }) }) : null;
1033
- };
1034
-
1035
- // src/Components/MapBoxHeat.tsx
1036
- var import_jsx_runtime8 = require("react/jsx-runtime");
1037
- var MapboxHeatFlexBox = ({ accessToken, children, mapBoxOptions, zoom, legend, developerMode, ...props }) => {
1038
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react_flexbox2.FlexCol, { ...props, children: [
1039
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MapBox, { accessToken, options: mapBoxOptions, zoom }),
1040
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MapSettingsBox, { developerMode }),
1041
- legend,
1042
- children
1043
- ] });
1044
- };
1045
-
1046
- // src/Components/AnimatedHeatMap.tsx
1047
- var import_jsx_runtime9 = require("react/jsx-runtime");
1048
- var AnimatedHeatMap = ({
1049
- accessToken,
1050
- animatedFeatureSets,
1051
- defaultMapSettings,
1052
- heatMapColorProps,
1053
- staticFeatureSet,
1054
- ...props
1055
- }) => {
1056
- const theme = (0, import_material4.useTheme)();
1057
- const { staticMapColor, lowUsageColor, highUsageColor } = heatMapColorProps || {};
1058
- const localStaticMapColor = staticMapColor ?? theme.palette.primary.light;
1059
- const [layers] = (0, import_react16.useState)([
1060
- LocationHeatMapLayerBuilderAnimated(localStaticMapColor, 0, "static"),
1061
- LocationHeatMapLayerBuilderAnimated(lowUsageColor || localStaticMapColor, 0, "animated"),
1062
- LocationHeatMapLayerBuilderAnimated(highUsageColor || (0, import_material4.darken)(localStaticMapColor, 0.9), 1, "animated")
1063
- ]);
1064
- return animatedFeatureSets?.length ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MapBoxInstanceProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MapSettingsProvider, { defaultMapSettings, debugLayerName: MapHeatConstants.LocationDebugLayerId, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1065
- HeatMapInitializerProvider,
1066
- {
1067
- features: staticFeatureSet,
1068
- layers: [layers[0]],
1069
- featureSets: animatedFeatureSets,
1070
- featureSetsLayers: layers.slice(1, 3),
1071
- heatMapColorProps,
1072
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MapboxHeatFlexBox, { accessToken, ...props })
1073
- }
1074
- ) }) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_react_flexbox3.FlexCol, { minHeight: 160, minWidth: 160, busy: true });
1075
- };
1076
-
1077
- // src/Components/AnimatedHeatMapLoaded.tsx
1078
- var import_material7 = require("@mui/material");
1079
- var import_react_flexbox6 = require("@xylabs/react-flexbox");
1080
- var import_react_archivist = require("@xyo-network/react-archivist");
1081
-
1082
- // src/Components/Legend.tsx
1083
- var import_material6 = require("@mui/material");
1084
- var import_react_flexbox5 = require("@xylabs/react-flexbox");
1085
-
1086
- // src/Components/Legends/ColorGradient.tsx
1087
- var import_material5 = require("@mui/material");
1088
- var import_react_flexbox4 = require("@xylabs/react-flexbox");
1089
- var import_jsx_runtime10 = require("react/jsx-runtime");
1090
- var ColorGradientLegend = ({ startColor, endColor, startLabel, endLabel, heading, textColor, ...props }) => {
1091
- const theme = (0, import_material5.useTheme)();
1092
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_flexbox4.FlexCol, { ...props, children: [
1093
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material5.Typography, { mb: theme.spacing(0.25), color: textColor, variant: "caption", textAlign: "center", children: heading }),
1094
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_flexbox4.FlexCol, { flexGrow: 1, alignItems: "stretch", paddingX: theme.spacing(1), mb: theme.spacing(0.25), children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1095
- import_react_flexbox4.FlexCol,
1096
- {
1097
- height: theme.spacing(0.75),
1098
- border: `1px solid ${textColor}`,
1099
- sx: { backgroundImage: `linear-gradient(to right, ${startColor},${endColor})` }
1100
- }
1101
- ) }),
1102
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_flexbox4.FlexRow, { flexGrow: 1, justifyContent: "space-between", children: [
1103
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material5.Typography, { color: textColor, variant: "caption", children: startLabel }),
1104
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_material5.Typography, { color: textColor, variant: "caption", children: endLabel })
1105
- ] })
1106
- ] });
1107
- };
1108
-
1109
- // src/Components/Legend.tsx
1110
- var import_jsx_runtime11 = require("react/jsx-runtime");
1111
- var AnimatedHeatMapLegend = ({ ...legendProps }) => {
1112
- const { startColor, endColor, startLabel, endLabel, heading, textColor } = legendProps;
1113
- const theme = (0, import_material6.useTheme)();
1114
- const isSmall = (0, import_material6.useMediaQuery)(theme.breakpoints.down("sm"));
1115
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react_flexbox5.FlexCol, { position: "absolute", bottom: 0, right: 0, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1116
- ColorGradientLegend,
1117
- {
1118
- startColor,
1119
- endColor,
1120
- startLabel,
1121
- endLabel,
1122
- heading,
1123
- textColor,
1124
- ...{
1125
- alignItems: "stretch",
1126
- marginBottom: theme.spacing(4),
1127
- marginLeft: isSmall ? theme.spacing(3) : 0,
1128
- marginRight: isSmall ? theme.spacing(2) : theme.spacing(3),
1129
- width: isSmall ? "40vw" : theme.spacing(18)
1130
- }
1131
- }
1132
- ) });
1133
- };
1134
-
1135
- // src/Components/AnimatedHeatMapLoaded.tsx
1136
- var import_jsx_runtime12 = require("react/jsx-runtime");
1137
- var AnimatedHeatMapLoaded = ({ accessToken, archivistNameOrAddress, ...props }) => {
1138
- const hashes = useFindHashes();
1139
- const [archivist] = (0, import_react_archivist.useWeakArchivistFromNode)(archivistNameOrAddress);
1140
- const [payloads, xyoError] = (0, import_react_archivist.useWeakArchivistGet)(archivist, hashes);
1141
- const { multipleFeatureSets } = useQuadKeyPayloadsToFeatures(payloads);
1142
- const { heatMapColorProps, legendProps } = useHeatMapColors();
1143
- const MapBoxHeatProps = {
1144
- flexGrow: 1,
1145
- legend: legendProps ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(AnimatedHeatMapLegend, { ...legendProps }) : null
1146
- };
1147
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react_flexbox6.FlexCol, { alignItems: "stretch", ...props, children: [
1148
- xyoError ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_material7.Alert, { sx: { mt: 2 }, children: [
1149
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material7.AlertTitle, { children: "Error Loading Map" }),
1150
- xyoError.message ? `Error: ${xyoError.message}` : null,
1151
- "You might try authenticating again."
1152
- ] }) : null,
1153
- hashes === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material7.Alert, { children: "Missing answer hash for heat map query" }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1154
- AnimatedHeatMap,
1155
- {
1156
- accessToken,
1157
- defaultMapSettings: AnimatedHeatMapSettings,
1158
- animatedFeatureSets: multipleFeatureSets.slice(1, multipleFeatureSets.length),
1159
- staticFeatureSet: multipleFeatureSets[0],
1160
- heatMapColorProps,
1161
- ...MapBoxHeatProps
1162
- }
1163
- )
1164
- ] });
1165
- };
1166
-
1167
- // src/Components/HeatMapSettings.ts
1168
- var HeatMapSettings = DefaultMapSettings();
1169
- var { debugLayer: debugLayer2, scrollToZoom: scrollToZoom2, fitToPoints: fitToPoints2 } = HeatMapSettings;
1170
- debugLayer2.hidden = false;
1171
- scrollToZoom2.value = true;
1172
- fitToPoints2.value = true;
1173
-
1174
- // src/Components/LayerAnimator.tsx
1175
- var import_react_shared4 = require("@xylabs/react-shared");
1176
- var import_react17 = require("react");
1177
- var import_jsx_runtime13 = require("react/jsx-runtime");
1178
- var timeIncrement = 2e3;
1179
- var animatedLayerCount = 3;
1180
- var LayerAnimator = ({ animateLayers, children, layers, layersInitialized, map }) => {
1181
- const [fillLayers, setFillLayers] = (0, import_react17.useState)([]);
1182
- const layerIndexQueue = (0, import_react17.useRef)([]);
1183
- const incrementQueue = (0, import_react17.useCallback)(
1184
- (index) => {
1185
- if (fillLayers[index]) {
1186
- layerIndexQueue.current.push(index);
1187
- } else {
1188
- layerIndexQueue.current.push(0);
1189
- }
1190
- return layerIndexQueue.current.at(-1);
1191
- },
1192
- [fillLayers]
1193
- );
1194
- const lastQueuedIndex = (0, import_react17.useCallback)(() => {
1195
- const last = layerIndexQueue.current.at(-1);
1196
- if (last === void 0) {
1197
- incrementQueue(0);
1198
- return 0;
1199
- } else {
1200
- return last;
1201
- }
1202
- }, [incrementQueue]);
1203
- const unshiftQueue = (0, import_react17.useCallback)(() => {
1204
- layerIndexQueue.current.shift();
1205
- }, []);
1206
- const getNextLayer = (0, import_react17.useCallback)(() => {
1207
- const nextLayer = fillLayers[lastQueuedIndex()];
1208
- incrementQueue(lastQueuedIndex() + 1);
1209
- return nextLayer;
1210
- }, [fillLayers, incrementQueue, lastQueuedIndex]);
1211
- const layerAnimateWorker = (0, import_react17.useCallback)(
1212
- (layer) => {
1213
- if (layer) {
1214
- map?.setPaintProperty(layer.id, "fill-opacity", 0.85);
1215
- setTimeout(() => {
1216
- map?.setPaintProperty(layer.id, "fill-opacity", 0);
1217
- unshiftQueue();
1218
- }, timeIncrement * 2);
1219
- } else {
1220
- console.warn("tried to queue an empty layer");
1221
- }
1222
- },
1223
- [map, unshiftQueue]
1224
- );
1225
- (0, import_react17.useEffect)(() => {
1226
- if (layers?.length && map && layersInitialized) {
1227
- setFillLayers(
1228
- layers.filter((layer) => {
1229
- const fillLayer = layer.id.startsWith("location-fill");
1230
- if (fillLayer) {
1231
- map.setPaintProperty(layer.id, "fill-opacity-transition", { delay: 0, duration: 4e3 });
1232
- }
1233
- return fillLayer;
1234
- })
1235
- );
1236
- }
1237
- }, [layers, layersInitialized, map]);
1238
- const queueLayerAnimation = (0, import_react17.useCallback)(() => {
1239
- const animatedLayers = [];
1240
- for (let i = 0; i < animatedLayerCount; i++) {
1241
- animatedLayers.push(getNextLayer());
1242
- }
1243
- for (const [index, layer] of animatedLayers.entries()) {
1244
- if (index === 0) {
1245
- layerAnimateWorker(layer);
1246
- } else {
1247
- setTimeout(() => {
1248
- layerAnimateWorker(layer);
1249
- }, timeIncrement * index);
1250
- }
1251
- }
1252
- }, [getNextLayer, layerAnimateWorker]);
1253
- (0, import_react17.useEffect)(() => {
1254
- if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
1255
- queueLayerAnimation();
1256
- }
1257
- }, [animateLayers, fillLayers.length, layersInitialized, map, queueLayerAnimation]);
1258
- (0, import_react_shared4.useInterval)(() => {
1259
- if (animateLayers && layersInitialized && map && fillLayers.length > 0) {
1260
- queueLayerAnimation();
1261
- }
1262
- }, timeIncrement * animatedLayerCount);
1263
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children });
1264
- };
1265
-
1266
- // src/Components/MapBoxPoints.tsx
1267
- var import_material8 = require("@mui/material");
1268
- var import_react_flexbox7 = require("@xylabs/react-flexbox");
1269
- var import_react18 = require("react");
1270
- var import_jsx_runtime14 = require("react/jsx-runtime");
1271
- var MapboxPointsFlexBox = ({
1272
- accessToken,
1273
- features,
1274
- fitToPointsPadding = 20,
1275
- layers,
1276
- zoom,
1277
- ...props
1278
- }) => {
1279
- const [mapPoints, setMapPoints] = (0, import_react18.useState)();
1280
- const { mapSettings } = useMapSettings();
1281
- const { map, mapInitialized } = useMapBoxInstance();
1282
- const customFitToBoundsOptions = (zoom2) => {
1283
- if (zoom2 !== void 0) {
1284
- return {
1285
- maxZoom: zoom2
1286
- };
1287
- }
1288
- return {};
1289
- };
1290
- const updateFeatures = (0, import_react18.useCallback)(() => {
1291
- if (mapPoints?.isMapReady && features?.length && layers)
1292
- for (const layer of layers) {
1293
- mapPoints.initializeMapSource(layer);
1294
- }
1295
- }, [mapPoints, features, layers]);
1296
- const updateMapSetup = (0, import_react18.useCallback)(() => {
1297
- const { fitToPoints: fitToPoints3 } = mapSettings || {};
1298
- if (mapPoints && map && fitToPoints3?.value === true) {
1299
- mapPoints.initialMapPositioning({ padding: fitToPointsPadding, ...customFitToBoundsOptions(zoom) });
1300
- }
1301
- }, [mapSettings, mapPoints, map, fitToPointsPadding, zoom]);
1302
- const reInitializeMap = (0, import_react18.useCallback)(() => {
1303
- mapPoints?.initialMapPositioning({ padding: fitToPointsPadding, ...customFitToBoundsOptions(zoom) });
1304
- updateFeatures();
1305
- }, [mapPoints, fitToPointsPadding, updateFeatures, zoom]);
1306
- (0, import_react18.useEffect)(() => {
1307
- if (map && features?.length) {
1308
- setMapPoints(new MapPoints({ features, map, zoom }));
1309
- }
1310
- }, [map, features, zoom]);
1311
- (0, import_react18.useEffect)(() => {
1312
- if (mapInitialized) {
1313
- updateMapSetup();
1314
- reInitializeMap();
1315
- }
1316
- }, [mapInitialized, reInitializeMap, updateMapSetup]);
1317
- return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_flexbox7.FlexCol, { alignItems: "stretch", id: "xyo-mapbox-wrap", ...props, children: features ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_jsx_runtime14.Fragment, { children: [
1318
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MapBox, { accessToken, zoom }),
1319
- /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(MapSettingsBox, {})
1320
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material8.Alert, { severity: "error", children: "No data to show" }) });
1321
- };
1322
-
1323
- // src/types/NetworkLocationAnswerBase.ts
1324
- var import_payload_model = require("@xyo-network/payload-model");
1325
- var NetworkLocationAnswerSchema = "network.xyo.location.range.answer";
1326
- var isNetworkLocationAnswer = (0, import_payload_model.isPayloadOfSchemaType)(NetworkLocationAnswerSchema);
1327
- var NetworkLocationHeatmapAnswerSchema = "network.xyo.location.heatmap.answer";
1328
- var isNetworkLocationHeatmapAnswer = (0, import_payload_model.isPayloadOfSchemaType)(NetworkLocationHeatmapAnswerSchema);
1329
- var NetworkLocationHeatmapQuadkeyAnswerSchema = "network.xyo.location.heatmap.quadkey.answer";
1330
- var isNetworkLocationHeatmapQuadkeyAnswer = (0, import_payload_model.isPayloadOfSchemaType)(
1331
- NetworkLocationHeatmapQuadkeyAnswerSchema
1332
- );
1
+ "use strict";var Me=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Wt=Object.prototype.hasOwnProperty;var qt=(r,e)=>{for(var o in e)Me(r,o,{get:e[o],enumerable:!0})},Zt=(r,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Qt(e))!Wt.call(r,a)&&a!==o&&Me(r,a,{get:()=>e[a],enumerable:!(t=$t(e,a))||t.enumerable});return r};var Ut=r=>Zt(Me({},"__esModule",{value:!0}),r);var bo={};qt(bo,{AnimatedHeatMap:()=>Ge,AnimatedHeatMapLegend:()=>ze,AnimatedHeatMapLoaded:()=>mo,AnimatedHeatMapSettings:()=>ee,CircleLayerBuilder:()=>K,ColorGradientLegend:()=>De,DefaultMapSettings:()=>z,FillLayerBuilder:()=>T,HeatMapFillLayerConfig:()=>W,HeatMapInitializerProvider:()=>ke,HeatMapLineLayerConfig:()=>Ae,HeatMapSettings:()=>At,HeatMapSymbolLayerConfig:()=>Be,LayerAnimator:()=>yo,LineLayerBuilder:()=>q,LocationHeatMapLayerBuilder:()=>co,LocationHeatMapLayerBuilderAnimated:()=>U,LocationPointLayerConfig:()=>Te,LocationPointsMapLayerBuilder:()=>po,MapBase:()=>A,MapBox:()=>X,MapBoxInstanceProvider:()=>ve,MapHeat:()=>F,MapHeatConstants:()=>ce,MapPoints:()=>_,MapPointsConstants:()=>xt,MapSettingSwitch:()=>Ne,MapSettings:()=>J,MapSettingsBox:()=>Y,MapSettingsProvider:()=>He,MapStyle:()=>bt,MapboxAccessTokenContext:()=>Q,MapboxAccessTokenProvider:()=>io,MapboxHeatFlexBox:()=>Oe,MapboxPointsFlexBox:()=>Lo,NetworkLocationAnswerSchema:()=>Ot,NetworkLocationHeatmapAnswerSchema:()=>Gt,NetworkLocationHeatmapQuadkeyAnswerSchema:()=>Dt,SymbolLayerBuilder:()=>Z,isNetworkLocationAnswer:()=>Mo,isNetworkLocationHeatmapAnswer:()=>ho,isNetworkLocationHeatmapQuadkeyAnswer:()=>xo,useDynamicMapResize:()=>he,useDynamicPositioning:()=>xe,useFindHashes:()=>be,useHeatMapColors:()=>Ce,useHeatMapInitializer:()=>no,useMapBoxInstance:()=>b,useMapSettings:()=>x,useMapboxAccessToken:()=>so,useQuadKeyPayloadsToFeatures:()=>Se});module.exports=Ut(bo);var z=()=>({debugLayer:{devMode:!0,field:"debugLayer",hidden:!0,label:"Debug Layer",value:!1},debugLogging:{devMode:!0,field:"debugLogging",hidden:!0,label:"Debug Logging",value:!1},dynamicMapResize:{devMode:!0,field:"dynamicMapResize",hidden:!0,label:"Auto Map Resize",value:!0},enableControls:{devMode:!0,field:"enableControls",hidden:!0,label:"Map Controls",value:!1},fitToPoints:{devMode:!0,field:"fitToPoints",hidden:!0,label:"Fit To Points",value:!1},preferDark:{devMode:!1,field:"preferDark",hidden:!0,label:"Prefer dark",value:!1},scrollToZoom:{devMode:!0,field:"scrollToZoom",hidden:!0,label:"Scroll To Zoom",value:!1}});var ee=z(),{debugLayer:Kt,scrollToZoom:Xt,fitToPoints:Yt,preferDark:Vt}=ee;Kt.hidden=!1;Xt.value=!0;Yt.value=!1;Vt.value=!0;var ue=require("@mui/material"),wt=require("@xylabs/react-flexbox"),vt=require("react");var ct=require("@xylabs/forget"),B=require("react");var k=require("react"),he=(r,e,o,t=!0)=>{let[a,n]=(0,k.useState)(!1),i=(0,k.useMemo)(()=>new ResizeObserver(()=>{let s=r.current?.getBoundingClientRect().width;s&&e.current&&(e.current.style.width=`${s}px`,setTimeout(()=>o?.resize()))}),[e,r,o]);(0,k.useEffect)(()=>{let s=!!(t&&o&&r?.current&&e.current);n(s)},[t,e,r,o]),(0,k.useEffect)(()=>{if(a)return r.current&&i.observe(r.current),()=>{i.disconnect()}},[t,a,e,r,o,i])};var $e=require("@xylabs/react-shared"),te=require("react"),jt=1.6,eo=[.5,2],to=[.9121644205263664,1.71785031559439],oo=[-81.4742014851959,12.788958675506933],Je=(r,e,o)=>{let[t,a]=e,[n,i]=o||eo,s=i-n,c=a-t;return(r-n)/s*c+t},xe=()=>{let[r,e]=(0,te.useState)({}),{width:o,height:t}=(0,$e.useWindowSize)();return(0,te.useEffect)(()=>{if(o&&t){let a=o/t;e({center:[Je(a,oo),Je(a,to)],zoom:jt})}},[t,o]),{options:r}};var Qe=require("@xyo-network/react-network"),We=require("react"),ro=["79af071f451fc7af10d009dc63236ef9a9b211732c1ee0c06f028fcecf2336c5","531bfba6d8dfefd3bcc888aca54cdbbd4574ed2b3ec551b230845a1f9a608898","c874412b4faa4947de81372fd1ba12fdd6f43f5e408622b7f357cb2bcb3f17cb","29d3f8b882c61a82a1a1675782a27e797ea7196f45a23b4409680ab8b8d5f14e","cfd20f80ac073fd9518f4ef3f43d2a1f5e4e56e40c2677f38d6f6fecd05df60c","1354fa73497519a39aed19fc99bdbae78a880a1eafb2f7898d607e07db36528d","1043b0d25eacfc5013ae9dba780305a6fbf01a43543bd871d7c00537fca142a9","973dfc5df142851ced258d52d0ac2784e814000ac22e35776f772256b0d4dde9","463808eb74d3d87e6563970e0301a493577f8cd1b501e6e0ffa5e027ad2cea95","15b21acea2e3fd9d1ace3768a72636ee7bdf67a6f8e0807bfa2273dea2207555","32d377bfe7ebe382598c54dd13f8af7510e0a1e2fd2e913311fdd58e517e5e2e,"],ao="c7bbf61f61cfd4a1b2def160c28136fc1d100d39fbdb67b227a2c6e558d9d3a5",be=()=>{let{network:r}=(0,Qe.useNetwork)(),e=r?.nodes?.find(n=>n.type==="archivist")?.explorerMapHashes,o=e?.animatedAnswerHashes||ro,t=e?.staticAnswerHash||ao;return(0,We.useMemo)(()=>[t,...o],[o,t])};var qe=require("@mui/material"),Ce=()=>{let r=(0,qe.useTheme)(),e="#FFFF75",o="#FF0000",t={highUsageColor:o,lowUsageColor:"#FFB3B3",staticMapColor:e},a={endColor:o,endLabel:"High",heading:"Network Usage",startColor:e,startLabel:"Low",textColor:r.palette.common.white};return{heatMapColorProps:t,legendProps:a}};var Ke=require("@xylabs/lodash"),Xe=require("@xyo-network/sdk-geo"),N=require("react"),Ze=({density:r,quadkey:e})=>{let o=new Xe.GeoJson(e).polygonFeature();return o.properties={count:r,density:r},o},Ue=r=>(r.properties&&(r.properties.value=r.properties.density/5),r),Se=r=>{let[e,o]=(0,N.useState)([[]]),[t,a]=(0,N.useState)([]),[n,i]=(0,N.useState)();return(0,N.useEffect)(()=>{if(Array.isArray(r))if((0,Ke.compact)(r).length>0){let s=r?.map(c=>c?.result.map(Ze));o(s.map(c=>c?.map(Ue)??[]))}else i(new Error("Cannot find payloads for provided hashes"));if(r&&r.result){let c=r.result.map(Ze);a(c.map(Ue))}},[r]),{error:n,features:t,multipleFeatureSets:e}};var Ye=require("@xylabs/assert"),Pe=require("@xyo-network/sdk-geo"),A=class{_config;constructor(e){this._config={requestLocation:!0,zoom:2,...e}}get isMapReady(){return!!this._config.map}initializeMapSource(e){let o=()=>{let n=Pe.GeoJson.featureCollection(this._config.features);return Pe.GeoJson.featuresSource(n)},t=this._config.map.getSource(e.source),a=o();return t?t.setData((0,Ye.assertEx)(a.data)):this._config.map.addSource(e.source,a),e.update(this._config.map,!0),this}};var Fe=require("@xylabs/assert"),oe=require("@xylabs/delay"),we=require("@xylabs/forget"),E=require("@xyo-network/sdk-geo"),Ve=require("mapbox-gl");var F=class extends A{static animationStarted=!1;config;constructor(e){super(e),this.config=e}static initialMapPositioning(e,o,t,a){if(!t)return;let n;return a?n=a:(n=new Ve.LngLatBounds,t.forEach(i=>{for(let s of i.geometry.coordinates)for(let c of s)n.extend(c)})),o.setCenter(n.getCenter()),o.fitBounds(n,e),this}static async initializeAnimatedHeatMapSource(e,o,t,a,n){this.animationStarted=!0;let i=0,s=0,c=o.map(y=>{let M=E.GeoJson.featureCollection(y);return E.GeoJson.featuresSource(M)});this.updateLayer(t,e[0],c[0]),this.updateLayer(t,e[1],c[1]);for(let y of e)t.setPaintProperty(y.id,"fill-opacity",0);let l=3e3,m=.5,g=10,p=30,u=l/p,d=a??"#FFB3B3",f=n??"#FF0000",H=(y,M,h)=>{let Le=Math.sin(h/p*Math.PI/2),Et=Math.cos(h/p*Math.PI/2),_t=y+y*Le,Jt=M*Et;return["let","density",["+",["/",["number",["get","value"]],_t],Jt],["interpolate",["linear"],["var","density"],0,d,.5,f]]},I=e.map(y=>!1),Rt=async(y,M)=>{for(let h=p;h>=1;h--)t.setPaintProperty(y,"fill-color",H(g,m,h*(180/u))),await(0,oe.delay)(u);I[M]=!0},zt=async(y,M)=>{for(let h=1;h<=p;h++)t.setPaintProperty(y,"fill-color",H(g,m,h*(180/u))),await(0,oe.delay)(u);I[M]=!1},_e=!1;await(async()=>{for((0,Fe.assertEx)(!_e,()=>"Animation Already Started"),_e=!0;this.animationStarted;){let y=i%e.length,M=(i+1)%e.length,h=s%o.length,Le=(s+1)%o.length;for(I[y]&&(this.updateLayer(t,e[y],c[h]),(0,we.forget)(zt(e[y].id,y))),I[M]||(this.updateLayer(t,e[M],c[Le]),(0,we.forget)(Rt(e[M].id,M)));(I[y]||!I[M])&&this.animationStarted;)await(0,oe.delay)(1e3);i++,s++}})()}static updateLayer(e,o,t){let a=e.getSource(o.source);a&&t.data?a.setData(t.data):t&&e.addSource(o.source,t),o.update(e,!0)}initializeHeatMapSource(e){let o=t=>{let a=E.GeoJson.featureCollection(this.config.features);return E.GeoJson.featuresSource(a)};for(let[t,a]of e.entries()){let n=this.config.map.getSource(a.source),i=o(t);n?n.setData((0,Fe.assertEx)(i.data)):this.config.map.addSource(a.source,i),a.update(this.config.map,!0)}return this}};var je=require("mapbox-gl");var _=class extends A{config;constructor(e){super(e),this.config=e}initialMapPositioning(e,o){let t;return o?t=o:(t=new je.LngLatBounds,this.config.features.forEach(a=>{t.extend(a.geometry.coordinates)})),this.config.map.setCenter(t.getCenter()),this.config.map.fitBounds(t,e),this.config.map}};var re=require("mapbox-gl"),J=class r{static geoLocateControl;static mapListeners={logData:(e,o)=>{let t=o||e?.target;t&&(console.log("zoom",t.getZoom()),console.log("center",t.getCenter()))}};static navControl;static requestLocation;static toggleControls(e,o,t,a){return e?r.addControls(o,t,a):r.removeControls(o),this}static toggleDebugLayer(e,o,t){return o.getLayer(t)&&(e?o.setLayoutProperty(t,"visibility","visible"):o.setLayoutProperty(t,"visibility","none")),this}static toggleDebugLogging(e,o){let t=["resize","zoomend","dragend"];if(e){this.mapListeners.logData(void 0,o);for(let a of t)o.on(a,this.mapListeners.logData)}else for(let a of t)o.off(a,this.mapListeners.logData)}static toggleScrollToZoom(e,o){return e?o.scrollZoom.enable():o.scrollZoom.disable(),this}static updateSettings(e){let{settings:o,map:t,zoom:a,requestLocation:n,debugLayerName:i=""}=e,{scrollToZoom:s,enableControls:c,debugLayer:l,debugLogging:m}=o;r.toggleControls(c?.value,t,a,n).toggleScrollToZoom(s?.value,t).toggleDebugLayer(l?.value,t,i).toggleDebugLogging(m.value,t)}static addControls(e,o,t){let a=new re.GeolocateControl({fitBoundsOptions:{zoom:o||2},positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),n=new re.NavigationControl({showCompass:!1});return this.geoLocateControl=this.geoLocateControl||a,this.navControl=this.navControl||n,!e.hasControl(this.geoLocateControl)&&t&&e.addControl(this.geoLocateControl),e.hasControl(this.navControl)||e.addControl(this.navControl,"top-left"),this}static removeControls(e){return this.geoLocateControl&&e.hasControl(this.geoLocateControl)&&this.requestLocation&&e.removeControl(this.geoLocateControl),this.navControl&&e.hasControl(this.navControl)&&e.removeControl(this.navControl),this}};var $=require("react");var et=require("react"),ae=(0,et.createContext)({});var tt=require("react/jsx-runtime"),ve=({children:r})=>{let[e,o]=(0,$.useState)(),[t,a]=(0,$.useState)(!1),n={map:e,mapInitialized:t,setMapBoxInstance:o};return(0,$.useEffect)(()=>{!t&&e&&e?.on("load",()=>{a(!0)})},[e,t,a]),(0,tt.jsx)(ae.Provider,{value:n,children:r})};var ot=require("@xylabs/assert"),rt=require("react");var b=()=>{let r=(0,rt.useContext)(ae);return(0,ot.assertEx)("map"in r,()=>"useMapBoxInstance must be used within a MapBoxInstanceContext"),r};var ie=require("react");var at=require("react"),ne=(0,at.createContext)({});var nt=require("react/jsx-runtime"),He=({children:r,debugLayerName:e,defaultMapSettings:o,requestLocation:t,zoom:a=1})=>{let[n,i]=(0,ie.useState)(o||{}),{map:s,mapInitialized:c}=b(),l={mapSettings:n,setMapSettings:i};return(0,ie.useEffect)(()=>{n&&s&&c&&J.updateSettings({debugLayerName:e,map:s,requestLocation:t,settings:n,zoom:a})},[e,s,c,n,t,a]),(0,nt.jsx)(ne.Provider,{value:l,children:r})};var it=require("react");var x=()=>(0,it.useContext)(ne);var st=require("react"),se=(0,st.createContext)({});var lt=require("react/jsx-runtime"),ke=({children:r,featureSets:e,featureSetsLayers:o,features:t,fitToPadding:a,heatMapColorProps:n,layers:i,zoom:s})=>{let[c,l]=(0,B.useState)(),{options:m}=xe(),{mapSettings:g}=x(),{map:p,mapInitialized:u}=b(),d={MapHeat:c,heatMapColorProps:n};return(0,B.useEffect)(()=>{if(u&&e?.length&&e[0].length>0&&p&&o?.length){let{lowUsageColor:f,highUsageColor:H}=n;(0,ct.forget)(F.initializeAnimatedHeatMapSource(o,e,p,f,H))}return()=>{F.animationStarted=!1}},[e,o,u,p,n]),(0,B.useEffect)(()=>{c&&u&&t?.length&&i?.length&&c.initializeHeatMapSource(i)},[c,t?.length,i,u]),(0,B.useEffect)(()=>{if(u){let{fitToPoints:f}=g||{};p&&(f?.value===!0?F.initialMapPositioning({padding:a},p,t):m.zoom&&m.center&&(p.setZoom(m.zoom),p.setCenter(m.center)))}},[c,p,g,a,m,u,t]),(0,B.useEffect)(()=>{p&&t?.length&&l(new F({features:t,map:p,zoom:s}))},[p,t,s]),(0,lt.jsx)(se.Provider,{value:d,children:r})};var pt=require("@xylabs/assert"),mt=require("react");var no=()=>{let r=(0,mt.useContext)(se);return(0,pt.assertEx)("heatMapInitialized"in r,()=>"useHeatMapInitializer must be used within a HeatMapInitializerContext"),r};var ut=require("@xyo-network/react-shared"),Q=(0,ut.createContextEx)();var dt=require("react");var ft=require("react/jsx-runtime"),io=({defaultAccessToken:r,...e})=>{let[o,t]=(0,dt.useState)();return(0,ft.jsx)(Q.Provider,{value:{accessToken:o??r,provided:!0,setAccessToken:t},...e})};var gt=require("@xyo-network/react-shared");var so=(r=!1)=>(0,gt.useContextEx)(Q,"MapboxAccessToken",r);var W=r=>({paint:{"fill-color":r,"fill-opacity":["let","density",["+",["/",["number",["get","value"]],4],.125],["interpolate",["linear"],["var","density"],.8,["var","density"],1,.85]]}});var Ae=r=>({layout:{visibility:"none"},paint:{"line-color":r,"line-opacity":["let","density",0,["interpolate",["linear"],["var","density"],.8,["var","density"],1,.85]],"line-width":.5}});var Be=r=>({layout:{"text-anchor":"center","text-field":["concat","value: ",["to-string",["+",["/",["number",["get","value"]],2],.25]],`
2
+ `,"count: ",["to-string",["get","count"]]],"text-size":10,visibility:"none"},paint:{"text-color":r}});var Te=(r,e,o)=>({paint:{"circle-color":r,"circle-opacity":o,"circle-radius":e}});var yt=require("@xyo-network/sdk-geo"),T=class extends yt.LayerBase{FillLayerOptions;type="fill";constructor(e,o,t){super(e,o),this.FillLayerOptions=t||{id:this.id,source:this.source}}buildLayer(){return{...this.FillLayerOptions,id:this.id,source:this.source,type:this.type}}};var Lt=require("@xyo-network/sdk-geo"),q=class extends Lt.LayerBase{LineLayerOptions;type="line";constructor(e,o,t){super(e,o),this.LineLayerOptions=t||{id:this.id,source:this.source}}buildLayer(){return{...this.LineLayerOptions,id:this.id,layout:{},source:this.source,type:this.type}}};var Mt=require("@xyo-network/sdk-geo"),Z=class extends Mt.LayerBase{SymbolLayerOptions;type="symbol";constructor(e,o,t){super(e,o),this.SymbolLayerOptions=t||{id:this.id,source:this.source}}buildLayer(){return{...this.SymbolLayerOptions,id:this.id,source:this.source,type:this.type}}};var ce={LocationDebugLayerId:"location-debug-id",LocationDebugLayerSource:"location-debug-source",LocationFillLayerId:"location-fill-id",LocationFillLayerSource:"location-fill-source",LocationLineLayerId:"location-line-id",LocationLineLayerSource:"location-line-source"},co=(r,e="#000")=>{let{LocationFillLayerId:o,LocationFillLayerSource:t,LocationLineLayerId:a,LocationLineLayerSource:n,LocationDebugLayerId:i,LocationDebugLayerSource:s}=ce,c=W(r),l=Ae(r),m=Be(e),g=new T(o,t,c),p=new q(a,n,l),u=new Z(i,s,m);return[g,p,u]};var lo=(r,e)=>({LocationDebugLayerId:`location-${e}-debug-id-${r}`,LocationDebugLayerSource:`location-${e}-debug-source-${r}`,LocationFillLayerId:`location-${e}-fill-id-${r}`,LocationFillLayerSource:`location-${e}-fill-source-${r}`,LocationLineLayerId:`location-${e}-line-id-${r}`,LocationLineLayerSource:`location-${e}-line-source-${r}`}),U=(r,e,o="")=>{let{LocationFillLayerId:t,LocationFillLayerSource:a}=lo(e,o),n=W(r);return new T(t,a,n)};var ht=require("@xyo-network/sdk-geo"),K=class extends ht.LayerBase{CircleLayerOptions;type="circle";constructor(e,o,t){super(e,o),this.CircleLayerOptions=t||{id:this.id,source:this.source,type:"circle"}}buildLayer(){return{filter:["==","$type","Point"],layout:{},paint:{"circle-color":"#ff0000","circle-radius":6},type:this.type,...this.CircleLayerOptions,id:this.id,source:this.source}}};var xt={LocationDotsLayerId:"location-dots",LocationDotsLayerSource:"location-dots-source"},po=(r,e=6,o=.8)=>{let{LocationDotsLayerId:t,LocationDotsLayerSource:a}=xt,n=Te(r,e,o);return[new K(t,a,n)]};var Ft=require("@xylabs/react-flexbox");var $r=require("mapbox-gl/dist/mapbox-gl.css"),Ct=require("mapbox-gl"),w=require("react");var bt=(i=>(i.Dark="mapbox/dark-v10",i.Light="mapbox/light-v10",i.Outdoors="mapbox/outdoors-v11",i.Satellite="mapbox/satellite-v9",i.SatelliteStreets="mapbox/satellite-streets-v11",i.Streets="mapbox/streets-v11",i))(bt||{});var St=require("react/jsx-runtime"),X=({accessToken:r,darkMode:e=!1,options:o,zoom:t=2,...a})=>{let[n,i]=(0,w.useState)(),s=(0,w.useRef)(null),c=(0,w.useRef)(null),{setMapBoxInstance:l,map:m}=b(),{mapSettings:g}=x(),p=g?.dynamicMapResize.value;return he(s,c,m,p),(0,w.useEffect)(()=>{g?.preferDark?.value===!0?n?.setStyle("mapbox://styles/mapbox/dark-v10"):n?.setStyle(`mapbox://styles/${e?"mapbox/dark-v10":"mapbox/light-v10"}`)},[n,e,g]),(0,w.useEffect)(()=>{let u=new Ct.Map({accessToken:r,center:[0,0],container:s.current??"",style:"mapbox://styles/mapbox/light-v10",zoom:t,...o});return l?.(u),i(u),c.current=document.querySelector(".mapboxgl-canvas"),console.log("Created Map"),()=>{console.log("Removing Map"),u.remove()}},[s,i,o,t,l,r]),(0,St.jsx)("div",{ref:u=>s.current=u,style:{bottom:0,left:0,position:"absolute",right:0,top:0,...a}})};var le=require("@mui/material");var Ie=require("react/jsx-runtime"),Ne=({developerMode:r,field:e,...o})=>{let{mapSettings:t,setMapSettings:a}=x(),n=t?.[e],i=s=>{n&&a?.(c=>(c[n.field].value=s.target.checked,{...c}))};return n?.devMode&&r===!1||n?.hidden?null:(0,Ie.jsx)(le.FormControlLabel,{label:n?.label,control:(0,Ie.jsx)(le.Switch,{checked:n?.value,onChange:i,...o})})};var pe=require("@mui/material"),me=require("@xylabs/react-flexbox"),Pt=require("@xyo-network/react-app-settings");var O=require("react/jsx-runtime"),Y=({developerMode:r,...e})=>{let{mapSettings:o}=x(),{developerMode:t}=(0,Pt.useAppSettings)();return o&&(r??t)?(0,O.jsx)(me.FlexGrowRow,{bottom:36,left:10,position:"absolute",...e,children:(0,O.jsx)(me.FlexRow,{paddingX:2,children:(0,O.jsx)(pe.Paper,{children:(0,O.jsx)(pe.Stack,{direction:"row",spacing:1,marginX:1,children:Object.keys(o).map((n,i)=>(0,O.jsx)(Ne,{field:o[n].field,developerMode:r},i))})})})}):null};var V=require("react/jsx-runtime"),Oe=({accessToken:r,children:e,mapBoxOptions:o,zoom:t,legend:a,developerMode:n,...i})=>(0,V.jsxs)(Ft.FlexCol,{...i,children:[(0,V.jsx)(X,{accessToken:r,options:o,zoom:t}),(0,V.jsx)(Y,{developerMode:n}),a,e]});var G=require("react/jsx-runtime"),Ge=({accessToken:r,animatedFeatureSets:e,defaultMapSettings:o,heatMapColorProps:t,staticFeatureSet:a,...n})=>{let i=(0,ue.useTheme)(),{staticMapColor:s,lowUsageColor:c,highUsageColor:l}=t||{},m=s??i.palette.primary.light,[g]=(0,vt.useState)([U(m,0,"static"),U(c||m,0,"animated"),U(l||(0,ue.darken)(m,.9),1,"animated")]);return e?.length?(0,G.jsx)(ve,{children:(0,G.jsx)(He,{defaultMapSettings:o,debugLayerName:ce.LocationDebugLayerId,children:(0,G.jsx)(ke,{features:a,layers:[g[0]],featureSets:e,featureSetsLayers:g.slice(1,3),heatMapColorProps:t,children:(0,G.jsx)(Oe,{accessToken:r,...n})})})}):(0,G.jsx)(wt.FlexCol,{minHeight:160,minWidth:160,busy:!0})};var j=require("@mui/material"),kt=require("@xylabs/react-flexbox"),fe=require("@xyo-network/react-archivist");var de=require("@mui/material"),Ht=require("@xylabs/react-flexbox");var D=require("@mui/material"),R=require("@xylabs/react-flexbox"),C=require("react/jsx-runtime"),De=({startColor:r,endColor:e,startLabel:o,endLabel:t,heading:a,textColor:n,...i})=>{let s=(0,D.useTheme)();return(0,C.jsxs)(R.FlexCol,{...i,children:[(0,C.jsx)(D.Typography,{mb:s.spacing(.25),color:n,variant:"caption",textAlign:"center",children:a}),(0,C.jsx)(R.FlexCol,{flexGrow:1,alignItems:"stretch",paddingX:s.spacing(1),mb:s.spacing(.25),children:(0,C.jsx)(R.FlexCol,{height:s.spacing(.75),border:`1px solid ${n}`,sx:{backgroundImage:`linear-gradient(to right, ${r},${e})`}})}),(0,C.jsxs)(R.FlexRow,{flexGrow:1,justifyContent:"space-between",children:[(0,C.jsx)(D.Typography,{color:n,variant:"caption",children:o}),(0,C.jsx)(D.Typography,{color:n,variant:"caption",children:t})]})]})};var Re=require("react/jsx-runtime"),ze=({...r})=>{let{startColor:e,endColor:o,startLabel:t,endLabel:a,heading:n,textColor:i}=r,s=(0,de.useTheme)(),c=(0,de.useMediaQuery)(s.breakpoints.down("sm"));return(0,Re.jsx)(Ht.FlexCol,{position:"absolute",bottom:0,right:0,children:(0,Re.jsx)(De,{startColor:e,endColor:o,startLabel:t,endLabel:a,heading:n,textColor:i,alignItems:"stretch",marginBottom:s.spacing(4),marginLeft:c?s.spacing(3):0,marginRight:c?s.spacing(2):s.spacing(3),width:c?"40vw":s.spacing(18)})})};var v=require("react/jsx-runtime"),mo=({accessToken:r,archivistNameOrAddress:e,...o})=>{let t=be(),[a]=(0,fe.useWeakArchivistFromNode)(e),[n,i]=(0,fe.useWeakArchivistGet)(a,t),{multipleFeatureSets:s}=Se(n),{heatMapColorProps:c,legendProps:l}=Ce(),m={flexGrow:1,legend:l?(0,v.jsx)(ze,{...l}):null};return(0,v.jsxs)(kt.FlexCol,{alignItems:"stretch",...o,children:[i?(0,v.jsxs)(j.Alert,{sx:{mt:2},children:[(0,v.jsx)(j.AlertTitle,{children:"Error Loading Map"}),i.message?`Error: ${i.message}`:null,"You might try authenticating again."]}):null,t===void 0?(0,v.jsx)(j.Alert,{children:"Missing answer hash for heat map query"}):(0,v.jsx)(Ge,{accessToken:r,defaultMapSettings:ee,animatedFeatureSets:s.slice(1,s.length),staticFeatureSet:s[0],heatMapColorProps:c,...m})]})};var At=z(),{debugLayer:uo,scrollToZoom:fo,fitToPoints:go}=At;uo.hidden=!1;fo.value=!0;go.value=!0;var Tt=require("@xylabs/react-shared"),L=require("react"),ge=require("react/jsx-runtime"),Ee=2e3,Bt=3,yo=({animateLayers:r,children:e,layers:o,layersInitialized:t,map:a})=>{let[n,i]=(0,L.useState)([]),s=(0,L.useRef)([]),c=(0,L.useCallback)(d=>(n[d]?s.current.push(d):s.current.push(0),s.current.at(-1)),[n]),l=(0,L.useCallback)(()=>{let d=s.current.at(-1);return d===void 0?(c(0),0):d},[c]),m=(0,L.useCallback)(()=>{s.current.shift()},[]),g=(0,L.useCallback)(()=>{let d=n[l()];return c(l()+1),d},[n,c,l]),p=(0,L.useCallback)(d=>{d?(a?.setPaintProperty(d.id,"fill-opacity",.85),setTimeout(()=>{a?.setPaintProperty(d.id,"fill-opacity",0),m()},Ee*2)):console.warn("tried to queue an empty layer")},[a,m]);(0,L.useEffect)(()=>{o?.length&&a&&t&&i(o.filter(d=>{let f=d.id.startsWith("location-fill");return f&&a.setPaintProperty(d.id,"fill-opacity-transition",{delay:0,duration:4e3}),f}))},[o,t,a]);let u=(0,L.useCallback)(()=>{let d=[];for(let f=0;f<Bt;f++)d.push(g());for(let[f,H]of d.entries())f===0?p(H):setTimeout(()=>{p(H)},Ee*f)},[g,p]);return(0,L.useEffect)(()=>{r&&t&&a&&n.length>0&&u()},[r,n.length,t,a,u]),(0,Tt.useInterval)(()=>{r&&t&&a&&n.length>0&&u()},Ee*Bt),(0,ge.jsx)(ge.Fragment,{children:e})};var It=require("@mui/material"),Nt=require("@xylabs/react-flexbox"),P=require("react");var S=require("react/jsx-runtime"),Lo=({accessToken:r,features:e,fitToPointsPadding:o=20,layers:t,zoom:a,...n})=>{let[i,s]=(0,P.useState)(),{mapSettings:c}=x(),{map:l,mapInitialized:m}=b(),g=f=>f!==void 0?{maxZoom:f}:{},p=(0,P.useCallback)(()=>{if(i?.isMapReady&&e?.length&&t)for(let f of t)i.initializeMapSource(f)},[i,e,t]),u=(0,P.useCallback)(()=>{let{fitToPoints:f}=c||{};i&&l&&f?.value===!0&&i.initialMapPositioning({padding:o,...g(a)})},[c,i,l,o,a]),d=(0,P.useCallback)(()=>{i?.initialMapPositioning({padding:o,...g(a)}),p()},[i,o,p,a]);return(0,P.useEffect)(()=>{l&&e?.length&&s(new _({features:e,map:l,zoom:a}))},[l,e,a]),(0,P.useEffect)(()=>{m&&(u(),d())},[m,d,u]),(0,S.jsx)(Nt.FlexCol,{alignItems:"stretch",id:"xyo-mapbox-wrap",...n,children:e?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(X,{accessToken:r,zoom:a}),(0,S.jsx)(Y,{})]}):(0,S.jsx)(It.Alert,{severity:"error",children:"No data to show"})})};var ye=require("@xyo-network/payload-model"),Ot="network.xyo.location.range.answer",Mo=(0,ye.isPayloadOfSchemaType)(Ot),Gt="network.xyo.location.heatmap.answer",ho=(0,ye.isPayloadOfSchemaType)(Gt),Dt="network.xyo.location.heatmap.quadkey.answer",xo=(0,ye.isPayloadOfSchemaType)(Dt);
1333
3
  //# sourceMappingURL=index.cjs.map