@page-speed/maps 0.1.4 → 0.1.6

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 (46) hide show
  1. package/README.md +120 -0
  2. package/dist/components/geo-map.cjs +1237 -0
  3. package/dist/components/geo-map.cjs.map +1 -0
  4. package/dist/components/geo-map.d.cts +138 -0
  5. package/dist/components/geo-map.d.ts +138 -0
  6. package/dist/components/geo-map.js +1216 -0
  7. package/dist/components/geo-map.js.map +1 -0
  8. package/dist/components/index.cjs +1359 -0
  9. package/dist/components/index.cjs.map +1 -0
  10. package/dist/components/index.d.cts +5 -0
  11. package/dist/components/index.d.ts +5 -0
  12. package/dist/components/index.js +1335 -0
  13. package/dist/components/index.js.map +1 -0
  14. package/dist/components/map-marker.cjs +137 -0
  15. package/dist/components/map-marker.cjs.map +1 -0
  16. package/dist/components/map-marker.d.cts +76 -0
  17. package/dist/components/map-marker.d.ts +76 -0
  18. package/dist/components/map-marker.js +130 -0
  19. package/dist/components/map-marker.js.map +1 -0
  20. package/dist/index.cjs +929 -21
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +2 -0
  23. package/dist/index.d.ts +2 -0
  24. package/dist/index.js +910 -21
  25. package/dist/index.js.map +1 -1
  26. package/dist/types/index.d.cts +5 -5
  27. package/dist/types/index.d.ts +5 -5
  28. package/dist/utils/cn.cjs +13 -0
  29. package/dist/utils/cn.cjs.map +1 -0
  30. package/dist/utils/cn.d.cts +16 -0
  31. package/dist/utils/cn.d.ts +16 -0
  32. package/dist/utils/cn.js +11 -0
  33. package/dist/utils/cn.js.map +1 -0
  34. package/dist/utils/index.cjs +63 -0
  35. package/dist/utils/index.cjs.map +1 -1
  36. package/dist/utils/index.d.cts +4 -0
  37. package/dist/utils/index.d.ts +4 -0
  38. package/dist/utils/index.js +42 -1
  39. package/dist/utils/index.js.map +1 -1
  40. package/dist/utils/simple-pressable.cjs +63 -0
  41. package/dist/utils/simple-pressable.cjs.map +1 -0
  42. package/dist/utils/simple-pressable.d.cts +20 -0
  43. package/dist/utils/simple-pressable.d.ts +20 -0
  44. package/dist/utils/simple-pressable.js +41 -0
  45. package/dist/utils/simple-pressable.js.map +1 -0
  46. package/package.json +29 -2
@@ -0,0 +1,1237 @@
1
+ 'use strict';
2
+
3
+ var React3 = require('react');
4
+ var maplibre = require('react-map-gl/maplibre');
5
+ var clsx = require('clsx');
6
+ var tailwindMerge = require('tailwind-merge');
7
+ var jsxRuntime = require('react/jsx-runtime');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ Object.keys(e).forEach(function (k) {
14
+ if (k !== 'default') {
15
+ var d = Object.getOwnPropertyDescriptor(e, k);
16
+ Object.defineProperty(n, k, d.get ? d : {
17
+ enumerable: true,
18
+ get: function () { return e[k]; }
19
+ });
20
+ }
21
+ });
22
+ }
23
+ n.default = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
28
+
29
+ // src/utils/getMapLibreStyleUrl.ts
30
+ var MAPLIBRE_DEFAULT_STYLE_URL = "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json";
31
+ var DEFAULT_STADIA_STYLE_URL = "https://tiles.stadiamaps.com/styles/osm_bright.json";
32
+ var STYLE_MAP = {
33
+ default: DEFAULT_STADIA_STYLE_URL,
34
+ "alidade-smooth": "https://tiles.stadiamaps.com/styles/alidade_smooth.json",
35
+ "alidade-smooth-dark": "https://tiles.stadiamaps.com/styles/alidade_smooth_dark.json",
36
+ "maplibre-default": MAPLIBRE_DEFAULT_STYLE_URL,
37
+ "osm-bright": "https://tiles.stadiamaps.com/styles/osm_bright.json",
38
+ "stadia-outdoors": "https://tiles.stadiamaps.com/styles/outdoors.json",
39
+ "stamen-toner": "https://tiles.stadiamaps.com/styles/stamen_toner.json",
40
+ "stamen-terrain": "https://tiles.stadiamaps.com/styles/stamen_terrain.json",
41
+ "stamen-watercolor": "https://tiles.stadiamaps.com/styles/stamen_watercolor.json"
42
+ };
43
+ var HTTP_URL_REGEX = /^https?:\/\//i;
44
+ function isStadiaMapsUrl(url) {
45
+ try {
46
+ const parsed = new URL(url);
47
+ return parsed.hostname === "tiles.stadiamaps.com";
48
+ } catch {
49
+ return false;
50
+ }
51
+ }
52
+ function assertStadiaApiKey(stadiaApiKey) {
53
+ if (!stadiaApiKey.trim()) {
54
+ throw new Error(
55
+ "A non-empty stadiaApiKey is required for Stadia Maps style URLs."
56
+ );
57
+ }
58
+ }
59
+ function appendStadiaApiKey(styleUrl, stadiaApiKey) {
60
+ if (!isStadiaMapsUrl(styleUrl)) {
61
+ return styleUrl;
62
+ }
63
+ assertStadiaApiKey(stadiaApiKey);
64
+ const parsed = new URL(styleUrl);
65
+ if (!parsed.searchParams.has("api_key")) {
66
+ parsed.searchParams.set("api_key", stadiaApiKey);
67
+ }
68
+ return parsed.toString();
69
+ }
70
+ function getMapLibreStyleUrl(value, stadiaApiKey) {
71
+ const normalizedApiKey = stadiaApiKey.trim();
72
+ if (!value || typeof value !== "string") {
73
+ if (!normalizedApiKey) {
74
+ return MAPLIBRE_DEFAULT_STYLE_URL;
75
+ }
76
+ return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, normalizedApiKey);
77
+ }
78
+ if (STYLE_MAP[value]) {
79
+ const mappedStyleUrl = STYLE_MAP[value];
80
+ if (isStadiaMapsUrl(mappedStyleUrl) && !normalizedApiKey) {
81
+ return MAPLIBRE_DEFAULT_STYLE_URL;
82
+ }
83
+ return appendStadiaApiKey(mappedStyleUrl, normalizedApiKey);
84
+ }
85
+ if (HTTP_URL_REGEX.test(value)) {
86
+ if (isStadiaMapsUrl(value) && !normalizedApiKey) {
87
+ return MAPLIBRE_DEFAULT_STYLE_URL;
88
+ }
89
+ return appendStadiaApiKey(value, normalizedApiKey);
90
+ }
91
+ if (!normalizedApiKey) {
92
+ return MAPLIBRE_DEFAULT_STYLE_URL;
93
+ }
94
+ return appendStadiaApiKey(DEFAULT_STADIA_STYLE_URL, normalizedApiKey);
95
+ }
96
+ function cn(...inputs) {
97
+ return tailwindMerge.twMerge(clsx.clsx(inputs));
98
+ }
99
+ var SimplePressable = React3__namespace.forwardRef(({ children, className, href, onClick, ...props }, ref) => {
100
+ if (href) {
101
+ const isExternal = href.startsWith("http://") || href.startsWith("https://");
102
+ return /* @__PURE__ */ jsxRuntime.jsx(
103
+ "a",
104
+ {
105
+ ref,
106
+ href,
107
+ className,
108
+ target: isExternal ? "_blank" : props.target,
109
+ rel: isExternal ? "noopener noreferrer" : props.rel,
110
+ onClick,
111
+ ...props,
112
+ children
113
+ }
114
+ );
115
+ }
116
+ if (onClick) {
117
+ return /* @__PURE__ */ jsxRuntime.jsx(
118
+ "button",
119
+ {
120
+ ref,
121
+ type: "button",
122
+ className,
123
+ onClick,
124
+ ...props,
125
+ children
126
+ }
127
+ );
128
+ }
129
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { className, children });
130
+ });
131
+ SimplePressable.displayName = "SimplePressable";
132
+ var DEFAULT_MAPLIBRE_CSS_HREF = "https://cdn.jsdelivr.net/npm/maplibre-gl@5.18.0/dist/maplibre-gl.css";
133
+ var MAPLIBRE_STYLESHEET_ID = "page-speed-maplibre-gl-css";
134
+ var DEFAULT_FLY_TO_OPTIONS = Object.freeze({});
135
+ var VIEW_STATE_COORDINATE_EPSILON = 1e-6;
136
+ var VIEW_STATE_ZOOM_EPSILON = 0.01;
137
+ var DEFAULT_FLY_TO_EASING = (t) => 1 - Math.pow(1 - t, 3);
138
+ function joinClassNames(...classNames) {
139
+ return classNames.filter(Boolean).join(" ");
140
+ }
141
+ function hasMeaningfulViewStateDelta(previous, next) {
142
+ return Math.abs(previous.latitude - next.latitude) > VIEW_STATE_COORDINATE_EPSILON || Math.abs(previous.longitude - next.longitude) > VIEW_STATE_COORDINATE_EPSILON || Math.abs(previous.zoom - next.zoom) > VIEW_STATE_ZOOM_EPSILON;
143
+ }
144
+ function ensureMapLibreStylesheet(href) {
145
+ if (typeof document === "undefined") {
146
+ return;
147
+ }
148
+ const existingLink = document.getElementById(MAPLIBRE_STYLESHEET_ID);
149
+ if (existingLink instanceof HTMLLinkElement) {
150
+ if (existingLink.getAttribute("href") !== href) {
151
+ existingLink.setAttribute("href", href);
152
+ }
153
+ return;
154
+ }
155
+ const matchingLink = Array.from(
156
+ document.querySelectorAll("link[rel='stylesheet']")
157
+ ).find((link) => link.getAttribute("href") === href);
158
+ if (matchingLink instanceof HTMLLinkElement) {
159
+ matchingLink.id = MAPLIBRE_STYLESHEET_ID;
160
+ return;
161
+ }
162
+ const stylesheet = document.createElement("link");
163
+ stylesheet.id = MAPLIBRE_STYLESHEET_ID;
164
+ stylesheet.rel = "stylesheet";
165
+ stylesheet.href = href;
166
+ stylesheet.dataset.pageSpeedMaps = "maplibre-css";
167
+ document.head.appendChild(stylesheet);
168
+ }
169
+ function DefaultMarker({ marker }) {
170
+ return /* @__PURE__ */ jsxRuntime.jsxs(
171
+ "div",
172
+ {
173
+ style: {
174
+ cursor: marker.draggable ? "grab" : "pointer",
175
+ transform: "translate(-50%, -100%)",
176
+ display: "inline-flex",
177
+ alignItems: "center",
178
+ justifyContent: "center",
179
+ position: "relative"
180
+ },
181
+ onClick: marker.onClick,
182
+ children: [
183
+ /* @__PURE__ */ jsxRuntime.jsx(
184
+ "svg",
185
+ {
186
+ "aria-hidden": "true",
187
+ width: "32",
188
+ height: "32",
189
+ viewBox: "0 0 24 24",
190
+ fill: marker.color || "#3B82F6",
191
+ style: { filter: "drop-shadow(0 2px 8px rgba(0,0,0,0.35))" },
192
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 2C8.13 2 5 5.13 5 9c0 4.85 6.13 12.24 6.39 12.55a.75.75 0 0 0 1.16 0C12.87 21.24 19 13.85 19 9c0-3.87-3.13-7-7-7Zm0 9.75A2.75 2.75 0 1 1 12 6.25a2.75 2.75 0 0 1 0 5.5Z" })
193
+ }
194
+ ),
195
+ marker.label ? /* @__PURE__ */ jsxRuntime.jsx(
196
+ "div",
197
+ {
198
+ style: {
199
+ position: "absolute",
200
+ bottom: -28,
201
+ left: "50%",
202
+ transform: "translateX(-50%)",
203
+ background: "#FFFFFF",
204
+ borderRadius: 6,
205
+ padding: "2px 8px",
206
+ fontSize: 12,
207
+ fontWeight: 500,
208
+ whiteSpace: "nowrap",
209
+ boxShadow: "0 3px 10px rgba(0, 0, 0, 0.2)"
210
+ },
211
+ children: marker.label
212
+ }
213
+ ) : null
214
+ ]
215
+ }
216
+ );
217
+ }
218
+ function normalizeMarkers(markers) {
219
+ return markers.map((marker, index) => {
220
+ if (marker.lat !== void 0 && marker.lng !== void 0) {
221
+ return marker;
222
+ }
223
+ const basicMarker = marker;
224
+ return {
225
+ id: basicMarker.id ?? index,
226
+ lat: basicMarker.latitude,
227
+ lng: basicMarker.longitude,
228
+ color: basicMarker.color,
229
+ draggable: basicMarker.draggable,
230
+ label: basicMarker.label,
231
+ element: basicMarker.element,
232
+ onClick: basicMarker.onClick
233
+ };
234
+ });
235
+ }
236
+ function MapLibre({
237
+ stadiaApiKey,
238
+ mapLibreCssHref,
239
+ viewState,
240
+ onViewStateChange,
241
+ mapStyle,
242
+ center = viewState ? { lat: viewState.latitude ?? 0, lng: viewState.longitude ?? 0 } : { lat: 0, lng: 0 },
243
+ zoom = viewState?.zoom ?? 14,
244
+ styleUrl,
245
+ markers = [],
246
+ onMoveEnd,
247
+ onClick,
248
+ onMarkerDrag,
249
+ className,
250
+ style,
251
+ children,
252
+ showNavigationControl = true,
253
+ showGeolocateControl = false,
254
+ navigationControlPosition = "bottom-right",
255
+ geolocateControlPosition = "top-left",
256
+ flyToOptions = DEFAULT_FLY_TO_OPTIONS
257
+ }) {
258
+ const mapRef = React3__namespace.default.useRef(null);
259
+ const resolvedMapLibreCssHref = mapLibreCssHref && mapLibreCssHref.trim().length > 0 ? mapLibreCssHref : DEFAULT_MAPLIBRE_CSS_HREF;
260
+ const [internalViewState, setInternalViewState] = React3__namespace.default.useState({
261
+ latitude: viewState?.latitude ?? center.lat,
262
+ longitude: viewState?.longitude ?? center.lng,
263
+ zoom: viewState?.zoom ?? zoom
264
+ });
265
+ const isUserInteracting = React3__namespace.default.useRef(false);
266
+ const isMarkerDragging = React3__namespace.default.useRef(false);
267
+ const dragAnimationFrame = React3__namespace.default.useRef(null);
268
+ const lastReportedViewState = React3__namespace.default.useRef(null);
269
+ const resolvedFlyToOptions = React3__namespace.default.useMemo(
270
+ () => ({
271
+ speed: flyToOptions.speed ?? 0.8,
272
+ curve: flyToOptions.curve ?? 1.2,
273
+ bearing: flyToOptions.bearing ?? 0,
274
+ easing: flyToOptions.easing ?? DEFAULT_FLY_TO_EASING
275
+ }),
276
+ [
277
+ flyToOptions.bearing,
278
+ flyToOptions.curve,
279
+ flyToOptions.easing,
280
+ flyToOptions.speed
281
+ ]
282
+ );
283
+ React3__namespace.default.useEffect(() => {
284
+ ensureMapLibreStylesheet(resolvedMapLibreCssHref);
285
+ }, [resolvedMapLibreCssHref]);
286
+ React3__namespace.default.useEffect(() => {
287
+ if (!mapRef.current || !viewState || isUserInteracting.current || isMarkerDragging.current) {
288
+ return;
289
+ }
290
+ setInternalViewState((previous) => {
291
+ const next = {
292
+ latitude: viewState.latitude ?? previous.latitude,
293
+ longitude: viewState.longitude ?? previous.longitude,
294
+ zoom: viewState.zoom ?? previous.zoom
295
+ };
296
+ const hasChanged = hasMeaningfulViewStateDelta(previous, next);
297
+ if (!hasChanged) {
298
+ return previous;
299
+ }
300
+ const isEchoedMoveState = !!lastReportedViewState.current && !hasMeaningfulViewStateDelta(lastReportedViewState.current, next);
301
+ if (!isEchoedMoveState) {
302
+ mapRef.current?.flyTo({
303
+ center: [next.longitude, next.latitude],
304
+ zoom: next.zoom,
305
+ speed: resolvedFlyToOptions.speed,
306
+ curve: resolvedFlyToOptions.curve,
307
+ bearing: resolvedFlyToOptions.bearing,
308
+ easing: resolvedFlyToOptions.easing,
309
+ essential: true
310
+ });
311
+ }
312
+ return next;
313
+ });
314
+ }, [
315
+ resolvedFlyToOptions,
316
+ viewState?.latitude,
317
+ viewState?.longitude,
318
+ viewState?.zoom
319
+ ]);
320
+ const handleMoveStart = React3__namespace.default.useCallback(() => {
321
+ isUserInteracting.current = true;
322
+ }, []);
323
+ const handleMove = React3__namespace.default.useCallback(
324
+ (event) => {
325
+ const nextViewState = event.viewState;
326
+ setInternalViewState({
327
+ latitude: nextViewState.latitude,
328
+ longitude: nextViewState.longitude,
329
+ zoom: nextViewState.zoom
330
+ });
331
+ const roundedViewState = {
332
+ latitude: Number(nextViewState.latitude.toFixed(6)),
333
+ longitude: Number(nextViewState.longitude.toFixed(6)),
334
+ zoom: Number(nextViewState.zoom.toFixed(2))
335
+ };
336
+ lastReportedViewState.current = roundedViewState;
337
+ onViewStateChange?.(roundedViewState);
338
+ },
339
+ [onViewStateChange]
340
+ );
341
+ const handleMoveEnd = React3__namespace.default.useCallback(
342
+ (event) => {
343
+ isUserInteracting.current = false;
344
+ if (!onMoveEnd) {
345
+ return;
346
+ }
347
+ const map = event.target;
348
+ const nextCenter = map.getCenter();
349
+ const nextZoom = map.getZoom();
350
+ const bounds = map.getBounds();
351
+ onMoveEnd(
352
+ {
353
+ lat: Number(nextCenter.lat.toFixed(6)),
354
+ lng: Number(nextCenter.lng.toFixed(6))
355
+ },
356
+ Number(nextZoom.toFixed(2)),
357
+ bounds
358
+ );
359
+ },
360
+ [onMoveEnd]
361
+ );
362
+ const handleMapClick = React3__namespace.default.useCallback(
363
+ (event) => {
364
+ if (!onClick) {
365
+ return;
366
+ }
367
+ onClick({ latitude: event.lngLat.lat, longitude: event.lngLat.lng });
368
+ },
369
+ [onClick]
370
+ );
371
+ const normalizedMarkers = React3__namespace.default.useMemo(
372
+ () => normalizeMarkers(markers),
373
+ [markers]
374
+ );
375
+ const markerElements = React3__namespace.default.useMemo(
376
+ () => normalizedMarkers.map((marker) => /* @__PURE__ */ jsxRuntime.jsx(
377
+ maplibre.Marker,
378
+ {
379
+ longitude: marker.lng,
380
+ latitude: marker.lat,
381
+ draggable: marker.draggable,
382
+ onDragStart: () => {
383
+ isMarkerDragging.current = true;
384
+ },
385
+ onDrag: (event) => {
386
+ if (!mapRef.current) {
387
+ return;
388
+ }
389
+ const nextLngLat = event.lngLat;
390
+ if (!nextLngLat || nextLngLat.lng === void 0 || nextLngLat.lat === void 0) {
391
+ return;
392
+ }
393
+ const draggedLng = nextLngLat.lng;
394
+ const draggedLat = nextLngLat.lat;
395
+ if (dragAnimationFrame.current) {
396
+ cancelAnimationFrame(dragAnimationFrame.current);
397
+ }
398
+ dragAnimationFrame.current = requestAnimationFrame(() => {
399
+ if (!mapRef.current) {
400
+ return;
401
+ }
402
+ const bounds = mapRef.current.getBounds();
403
+ const viewportWidth = bounds.getEast() - bounds.getWest();
404
+ const viewportHeight = bounds.getNorth() - bounds.getSouth();
405
+ const edgePadding = 0.1;
406
+ const westThreshold = bounds.getWest() + viewportWidth * edgePadding;
407
+ const eastThreshold = bounds.getEast() - viewportWidth * edgePadding;
408
+ const southThreshold = bounds.getSouth() + viewportHeight * edgePadding;
409
+ const northThreshold = bounds.getNorth() - viewportHeight * edgePadding;
410
+ const nearWestEdge = draggedLng < westThreshold;
411
+ const nearEastEdge = draggedLng > eastThreshold;
412
+ const nearSouthEdge = draggedLat < southThreshold;
413
+ const nearNorthEdge = draggedLat > northThreshold;
414
+ if (!nearWestEdge && !nearEastEdge && !nearSouthEdge && !nearNorthEdge) {
415
+ return;
416
+ }
417
+ let panLng = draggedLng;
418
+ let panLat = draggedLat;
419
+ const offsetAmount = 0.2;
420
+ if (nearWestEdge) {
421
+ panLng = draggedLng - viewportWidth * offsetAmount;
422
+ }
423
+ if (nearEastEdge) {
424
+ panLng = draggedLng + viewportWidth * offsetAmount;
425
+ }
426
+ if (nearSouthEdge) {
427
+ panLat = draggedLat - viewportHeight * offsetAmount;
428
+ }
429
+ if (nearNorthEdge) {
430
+ panLat = draggedLat + viewportHeight * offsetAmount;
431
+ }
432
+ mapRef.current?.easeTo({
433
+ center: [panLng, panLat],
434
+ duration: 200
435
+ });
436
+ });
437
+ },
438
+ onDragEnd: (event) => {
439
+ isMarkerDragging.current = false;
440
+ if (dragAnimationFrame.current) {
441
+ cancelAnimationFrame(dragAnimationFrame.current);
442
+ dragAnimationFrame.current = null;
443
+ }
444
+ if (!onMarkerDrag) {
445
+ return;
446
+ }
447
+ const nextLngLat = event.lngLat;
448
+ if (!nextLngLat || nextLngLat.lng === void 0 || nextLngLat.lat === void 0) {
449
+ return;
450
+ }
451
+ onMarkerDrag(marker.id ?? null, {
452
+ latitude: nextLngLat.lat,
453
+ longitude: nextLngLat.lng
454
+ });
455
+ },
456
+ children: marker.element ? typeof marker.element === "function" ? marker.element() : marker.element : /* @__PURE__ */ jsxRuntime.jsx(DefaultMarker, { marker })
457
+ },
458
+ marker.id
459
+ )),
460
+ [normalizedMarkers, onMarkerDrag]
461
+ );
462
+ const resolvedMapStyleUrl = React3__namespace.default.useMemo(() => {
463
+ if (styleUrl) {
464
+ return appendStadiaApiKey(styleUrl, stadiaApiKey);
465
+ }
466
+ if (mapStyle) {
467
+ return getMapLibreStyleUrl(mapStyle, stadiaApiKey);
468
+ }
469
+ return getMapLibreStyleUrl("osm-bright", stadiaApiKey);
470
+ }, [mapStyle, stadiaApiKey, styleUrl]);
471
+ return /* @__PURE__ */ jsxRuntime.jsx(
472
+ "div",
473
+ {
474
+ className: joinClassNames("relative w-full h-full", className),
475
+ style: { width: "100%", height: "100%", ...style },
476
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
477
+ maplibre.Map,
478
+ {
479
+ ref: mapRef,
480
+ ...internalViewState,
481
+ mapStyle: resolvedMapStyleUrl,
482
+ onMoveStart: handleMoveStart,
483
+ onMove: handleMove,
484
+ onMoveEnd: handleMoveEnd,
485
+ onClick: handleMapClick,
486
+ attributionControl: false,
487
+ trackResize: true,
488
+ dragRotate: false,
489
+ touchZoomRotate: false,
490
+ children: [
491
+ showGeolocateControl ? /* @__PURE__ */ jsxRuntime.jsx(maplibre.GeolocateControl, { position: geolocateControlPosition }) : null,
492
+ showNavigationControl ? /* @__PURE__ */ jsxRuntime.jsx(maplibre.NavigationControl, { position: navigationControlPosition }) : null,
493
+ markerElements,
494
+ children
495
+ ]
496
+ }
497
+ )
498
+ }
499
+ );
500
+ }
501
+ var PANEL_POSITION_CLASS = {
502
+ "top-left": "left-4 top-4",
503
+ "top-right": "right-4 top-4",
504
+ "bottom-left": "bottom-4 left-4",
505
+ "bottom-right": "bottom-4 right-4"
506
+ };
507
+ var DEFAULT_VIEW_STATE = {
508
+ latitude: 39.5,
509
+ longitude: -98.35,
510
+ zoom: 3
511
+ };
512
+ var VIDEO_FILE_EXTENSION_REGEX = /\.(mp4|webm|ogg|mov|m4v|m3u8)(\?.*)?$/i;
513
+ function resolveMediaType(item) {
514
+ if (item.type) {
515
+ return item.type;
516
+ }
517
+ return VIDEO_FILE_EXTENSION_REGEX.test(item.src) ? "video" : "image";
518
+ }
519
+ function normalizeId(value, fallback) {
520
+ if (value === null || value === void 0 || value === "") {
521
+ return fallback;
522
+ }
523
+ return String(value);
524
+ }
525
+ function buildClusterCenter(markers) {
526
+ if (!markers.length) {
527
+ return null;
528
+ }
529
+ const total = markers.reduce(
530
+ (accumulator, marker) => ({
531
+ latitude: accumulator.latitude + marker.latitude,
532
+ longitude: accumulator.longitude + marker.longitude
533
+ }),
534
+ { latitude: 0, longitude: 0 }
535
+ );
536
+ return {
537
+ latitude: total.latitude / markers.length,
538
+ longitude: total.longitude / markers.length
539
+ };
540
+ }
541
+ function resolveActionKey(action, index) {
542
+ if (typeof action.label === "string" && action.label.trim().length > 0) {
543
+ return `label:${action.label}:${index}`;
544
+ }
545
+ if (action.href) {
546
+ return `href:${action.href}:${index}`;
547
+ }
548
+ return `action:${index}`;
549
+ }
550
+ var FallbackIcon = ({ size = 20, className }) => /* @__PURE__ */ jsxRuntime.jsx(
551
+ "svg",
552
+ {
553
+ width: size,
554
+ height: size,
555
+ viewBox: "0 0 24 24",
556
+ fill: "none",
557
+ stroke: "currentColor",
558
+ strokeWidth: "2",
559
+ strokeLinecap: "round",
560
+ strokeLinejoin: "round",
561
+ className,
562
+ children: /* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "12", r: "10" })
563
+ }
564
+ );
565
+ var FallbackImg = ({ src, alt, className, loading }) => /* @__PURE__ */ jsxRuntime.jsx("img", { src, alt, className, loading });
566
+ function MarkerActions({ actions }) {
567
+ if (!actions || actions.length === 0) {
568
+ return null;
569
+ }
570
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex flex-wrap gap-2", children: actions.map((action, index) => {
571
+ const {
572
+ label,
573
+ icon,
574
+ iconAfter,
575
+ children,
576
+ href,
577
+ onClick,
578
+ className: actionClassName,
579
+ variant,
580
+ size,
581
+ asButton,
582
+ ...rest
583
+ } = action;
584
+ const buttonStyles = cn(
585
+ "inline-flex items-center gap-2 px-4 py-2 rounded-md font-medium transition-colors",
586
+ variant === "outline" ? "border border-border bg-background hover:bg-muted" : "bg-primary text-primary-foreground hover:bg-primary/90",
587
+ size === "sm" && "text-sm px-3 py-1.5",
588
+ size === "icon" && "p-2",
589
+ actionClassName
590
+ );
591
+ return /* @__PURE__ */ jsxRuntime.jsx(
592
+ SimplePressable,
593
+ {
594
+ href,
595
+ onClick,
596
+ className: buttonStyles,
597
+ ...rest,
598
+ children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
599
+ icon,
600
+ label,
601
+ iconAfter
602
+ ] })
603
+ },
604
+ resolveActionKey(action, index)
605
+ );
606
+ }) });
607
+ }
608
+ function MarkerMediaCarousel({
609
+ mediaItems,
610
+ optixFlowConfig,
611
+ IconComponent = FallbackIcon,
612
+ ImgComponent = FallbackImg
613
+ }) {
614
+ const [activeIndex, setActiveIndex] = React3__namespace.useState(0);
615
+ const totalItems = mediaItems.length;
616
+ const mediaResetKey = React3__namespace.useMemo(
617
+ () => mediaItems.map((item, index) => {
618
+ const itemId = normalizeId(item.id, `media-${index}`);
619
+ return `${itemId}:${item.src}:${item.type ?? ""}:${item.poster ?? ""}`;
620
+ }).join("|"),
621
+ [mediaItems]
622
+ );
623
+ const activeItemIndex = Math.min(activeIndex, Math.max(0, totalItems - 1));
624
+ React3__namespace.useEffect(() => {
625
+ setActiveIndex(0);
626
+ }, [mediaResetKey]);
627
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative border-b border-border/60 bg-muted/40", children: [
628
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative aspect-video w-full overflow-hidden", children: mediaItems.map((item, index) => {
629
+ const isActive = index === activeItemIndex;
630
+ const mediaType = resolveMediaType(item);
631
+ return /* @__PURE__ */ jsxRuntime.jsx(
632
+ "div",
633
+ {
634
+ "aria-hidden": !isActive,
635
+ className: cn(
636
+ "absolute inset-0 transition-opacity duration-500 ease-in-out",
637
+ isActive ? "opacity-100 z-1" : "opacity-0 z-0 pointer-events-none"
638
+ ),
639
+ children: mediaType === "video" ? /* @__PURE__ */ jsxRuntime.jsx(
640
+ "video",
641
+ {
642
+ className: "h-full w-full object-cover",
643
+ controls: isActive,
644
+ preload: "metadata",
645
+ poster: item.poster,
646
+ tabIndex: isActive ? 0 : -1,
647
+ children: /* @__PURE__ */ jsxRuntime.jsx("source", { src: item.src })
648
+ }
649
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
650
+ ImgComponent,
651
+ {
652
+ src: item.src,
653
+ alt: item.alt ?? "Map marker media",
654
+ className: "h-full w-full object-cover",
655
+ loading: "eager",
656
+ optixFlowConfig
657
+ }
658
+ )
659
+ },
660
+ normalizeId(item.id, `media-slide-${index}`)
661
+ );
662
+ }) }),
663
+ totalItems > 1 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
664
+ /* @__PURE__ */ jsxRuntime.jsx(
665
+ "button",
666
+ {
667
+ type: "button",
668
+ "aria-label": "Show previous media",
669
+ className: "absolute left-4 top-1/2 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-2xl bg-card text-card-foreground shadow-lg border-4 border-black hover:border-white hover:bg-black hover:text-white transition-all duration-500 z-2",
670
+ onClick: () => {
671
+ setActiveIndex(
672
+ (current) => (current - 1 + totalItems) % totalItems
673
+ );
674
+ },
675
+ children: /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { name: "lucide/arrow-left", size: 18 })
676
+ }
677
+ ),
678
+ /* @__PURE__ */ jsxRuntime.jsx(
679
+ "button",
680
+ {
681
+ type: "button",
682
+ "aria-label": "Show next media",
683
+ className: "absolute right-4 top-1/2 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-2xl bg-card text-card-foreground shadow-lg border-4 border-black hover:border-white hover:bg-black hover:text-white transition-all duration-500 z-2",
684
+ onClick: () => {
685
+ setActiveIndex((current) => (current + 1) % totalItems);
686
+ },
687
+ children: /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { name: "lucide/arrow-right", size: 18 })
688
+ }
689
+ ),
690
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute bottom-2 left-1/2 flex -translate-x-1/2 items-center gap-1.5 z-[2]", children: mediaItems.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(
691
+ "button",
692
+ {
693
+ type: "button",
694
+ "aria-label": `Show media item ${index + 1}`,
695
+ className: cn(
696
+ "h-2 rounded-full transition-all duration-300",
697
+ index === activeItemIndex ? "w-6 bg-card" : "w-2 bg-card opacity-50 hover:opacity-100"
698
+ ),
699
+ onClick: () => setActiveIndex(index)
700
+ },
701
+ normalizeId(item.id, `media-dot-${index}`)
702
+ )) })
703
+ ] }) : null
704
+ ] });
705
+ }
706
+ function getMarkerTitle(marker, markerIndex) {
707
+ if (marker.title !== void 0 && marker.title !== null) {
708
+ return marker.title;
709
+ }
710
+ if (marker.label !== void 0 && marker.label !== null) {
711
+ return marker.label;
712
+ }
713
+ return `Location ${markerIndex + 1}`;
714
+ }
715
+ function GeoMap({
716
+ className,
717
+ mapWrapperClassName,
718
+ mapClassName,
719
+ panelClassName,
720
+ panelPosition = "top-left",
721
+ stadiaApiKey = "",
722
+ mapStyle = "osm-bright",
723
+ styleUrl,
724
+ mapLibreCssHref,
725
+ markers = [],
726
+ clusters = [],
727
+ viewState,
728
+ defaultViewState,
729
+ onViewStateChange,
730
+ onMapClick,
731
+ onMarkerDrag,
732
+ showNavigationControl = true,
733
+ showGeolocateControl = false,
734
+ navigationControlPosition = "top-right",
735
+ geolocateControlPosition = "top-left",
736
+ flyToOptions,
737
+ markerFocusZoom = 14,
738
+ clusterFocusZoom = 5,
739
+ selectedMarkerId,
740
+ initialSelectedMarkerId,
741
+ onSelectionChange,
742
+ clearSelectionOnMapClick = true,
743
+ mapChildren,
744
+ optixFlowConfig,
745
+ IconComponent = FallbackIcon,
746
+ ImgComponent = FallbackImg
747
+ }) {
748
+ const normalizedStandaloneMarkers = React3__namespace.useMemo(
749
+ () => markers.map((marker, index) => ({
750
+ ...marker,
751
+ id: normalizeId(marker.id, `marker-${index}`)
752
+ })),
753
+ [markers]
754
+ );
755
+ const normalizedClusters = React3__namespace.useMemo(() => {
756
+ const results = [];
757
+ clusters.forEach((cluster, clusterIndex) => {
758
+ const clusterId = normalizeId(cluster.id, `cluster-${clusterIndex}`);
759
+ const normalizedClusterMarkers = cluster.markers.map(
760
+ (marker, markerIndex) => ({
761
+ ...marker,
762
+ id: normalizeId(marker.id, `${clusterId}-marker-${markerIndex}`),
763
+ clusterId
764
+ })
765
+ );
766
+ const clusterCenter = cluster.latitude !== void 0 && cluster.longitude !== void 0 ? { latitude: cluster.latitude, longitude: cluster.longitude } : buildClusterCenter(normalizedClusterMarkers);
767
+ if (!clusterCenter) {
768
+ return;
769
+ }
770
+ results.push({
771
+ ...cluster,
772
+ id: clusterId,
773
+ latitude: clusterCenter.latitude,
774
+ longitude: clusterCenter.longitude,
775
+ markers: normalizedClusterMarkers
776
+ });
777
+ });
778
+ return results;
779
+ }, [clusters]);
780
+ const markerLookup = React3__namespace.useMemo(() => {
781
+ const lookup = /* @__PURE__ */ new Map();
782
+ normalizedStandaloneMarkers.forEach((marker) => {
783
+ lookup.set(marker.id, marker);
784
+ });
785
+ normalizedClusters.forEach((cluster) => {
786
+ cluster.markers.forEach((marker) => {
787
+ lookup.set(marker.id, marker);
788
+ });
789
+ });
790
+ return lookup;
791
+ }, [normalizedClusters, normalizedStandaloneMarkers]);
792
+ const clusterLookup = React3__namespace.useMemo(() => {
793
+ const lookup = /* @__PURE__ */ new Map();
794
+ normalizedClusters.forEach((cluster) => {
795
+ lookup.set(cluster.id, cluster);
796
+ });
797
+ return lookup;
798
+ }, [normalizedClusters]);
799
+ const firstCoordinate = React3__namespace.useMemo(() => {
800
+ const allCoords = [];
801
+ normalizedStandaloneMarkers.forEach((marker) => {
802
+ allCoords.push({
803
+ latitude: marker.latitude,
804
+ longitude: marker.longitude
805
+ });
806
+ });
807
+ normalizedClusters.forEach((cluster) => {
808
+ allCoords.push({
809
+ latitude: cluster.latitude,
810
+ longitude: cluster.longitude
811
+ });
812
+ });
813
+ if (allCoords.length > 0) {
814
+ const sum = allCoords.reduce(
815
+ (acc, coord) => ({
816
+ latitude: acc.latitude + coord.latitude,
817
+ longitude: acc.longitude + coord.longitude
818
+ }),
819
+ { latitude: 0, longitude: 0 }
820
+ );
821
+ return {
822
+ latitude: sum.latitude / allCoords.length,
823
+ longitude: sum.longitude / allCoords.length
824
+ };
825
+ }
826
+ return {
827
+ latitude: DEFAULT_VIEW_STATE.latitude,
828
+ longitude: DEFAULT_VIEW_STATE.longitude
829
+ };
830
+ }, [normalizedClusters, normalizedStandaloneMarkers]);
831
+ const calculatedZoom = React3__namespace.useMemo(() => {
832
+ if (normalizedStandaloneMarkers.length + normalizedClusters.length <= 1) {
833
+ return markerFocusZoom;
834
+ }
835
+ const allCoords = [];
836
+ normalizedStandaloneMarkers.forEach((marker) => {
837
+ allCoords.push({
838
+ latitude: marker.latitude,
839
+ longitude: marker.longitude
840
+ });
841
+ });
842
+ normalizedClusters.forEach((cluster) => {
843
+ allCoords.push({
844
+ latitude: cluster.latitude,
845
+ longitude: cluster.longitude
846
+ });
847
+ });
848
+ if (allCoords.length === 0) {
849
+ return DEFAULT_VIEW_STATE.zoom;
850
+ }
851
+ const lats = allCoords.map((c) => c.latitude);
852
+ const lngs = allCoords.map((c) => c.longitude);
853
+ const latDiff = Math.max(...lats) - Math.min(...lats);
854
+ const lngDiff = Math.max(...lngs) - Math.min(...lngs);
855
+ const maxDiff = Math.max(latDiff, lngDiff);
856
+ if (maxDiff > 10) return 3;
857
+ if (maxDiff > 5) return 5;
858
+ if (maxDiff > 2) return 7;
859
+ if (maxDiff > 1) return 9;
860
+ if (maxDiff > 0.5) return 10;
861
+ if (maxDiff > 0.1) return 12;
862
+ return 13;
863
+ }, [normalizedClusters, normalizedStandaloneMarkers, markerFocusZoom]);
864
+ const [uncontrolledViewState, setUncontrolledViewState] = React3__namespace.useState({
865
+ latitude: defaultViewState?.latitude ?? firstCoordinate.latitude,
866
+ longitude: defaultViewState?.longitude ?? firstCoordinate.longitude,
867
+ zoom: defaultViewState?.zoom ?? calculatedZoom
868
+ });
869
+ React3__namespace.useEffect(() => {
870
+ if (!viewState && !defaultViewState) {
871
+ setUncontrolledViewState({
872
+ latitude: firstCoordinate.latitude,
873
+ longitude: firstCoordinate.longitude,
874
+ zoom: calculatedZoom
875
+ });
876
+ }
877
+ }, [firstCoordinate, calculatedZoom, viewState, defaultViewState]);
878
+ const isControlledViewState = viewState !== void 0;
879
+ const resolvedViewState = isControlledViewState ? viewState : uncontrolledViewState;
880
+ const applyViewState = React3__namespace.useCallback(
881
+ (nextState) => {
882
+ if (!isControlledViewState) {
883
+ setUncontrolledViewState((current) => {
884
+ const next = { ...current, ...nextState };
885
+ const hasChanged = current.latitude !== next.latitude || current.longitude !== next.longitude || current.zoom !== next.zoom;
886
+ return hasChanged ? next : current;
887
+ });
888
+ }
889
+ onViewStateChange?.(nextState);
890
+ },
891
+ [isControlledViewState, onViewStateChange]
892
+ );
893
+ const [selection, setSelection] = React3__namespace.useState(() => {
894
+ if (initialSelectedMarkerId !== void 0 && initialSelectedMarkerId !== null) {
895
+ return {
896
+ type: "marker",
897
+ markerId: String(initialSelectedMarkerId)
898
+ };
899
+ }
900
+ return { type: "none" };
901
+ });
902
+ React3__namespace.useEffect(() => {
903
+ if (selectedMarkerId === void 0 || selectedMarkerId === null) {
904
+ return;
905
+ }
906
+ setSelection({
907
+ type: "marker",
908
+ markerId: String(selectedMarkerId)
909
+ });
910
+ }, [selectedMarkerId]);
911
+ const selectedMarker = selection.markerId ? markerLookup.get(selection.markerId) : void 0;
912
+ const selectedCluster = selection.clusterId ? clusterLookup.get(selection.clusterId) : void 0;
913
+ React3__namespace.useEffect(() => {
914
+ if (selection.type === "marker" && selection.markerId && !selectedMarker) {
915
+ setSelection({ type: "none" });
916
+ onSelectionChange?.({ type: "none" });
917
+ }
918
+ }, [onSelectionChange, selectedMarker, selection]);
919
+ const emitSelectionChange = React3__namespace.useCallback(
920
+ (nextSelection) => {
921
+ if (nextSelection.type === "none") {
922
+ onSelectionChange?.({ type: "none" });
923
+ return;
924
+ }
925
+ if (nextSelection.type === "marker") {
926
+ const parentCluster = nextSelection.marker.clusterId ? clusterLookup.get(nextSelection.marker.clusterId) : void 0;
927
+ onSelectionChange?.({
928
+ type: "marker",
929
+ marker: nextSelection.marker,
930
+ cluster: parentCluster
931
+ });
932
+ return;
933
+ }
934
+ onSelectionChange?.({
935
+ type: "cluster",
936
+ cluster: nextSelection.cluster
937
+ });
938
+ },
939
+ [clusterLookup, onSelectionChange]
940
+ );
941
+ const selectMarker = React3__namespace.useCallback(
942
+ (marker) => {
943
+ setSelection({
944
+ type: "marker",
945
+ markerId: marker.id,
946
+ clusterId: marker.clusterId
947
+ });
948
+ applyViewState({
949
+ latitude: marker.latitude,
950
+ longitude: marker.longitude,
951
+ zoom: markerFocusZoom
952
+ });
953
+ emitSelectionChange({ type: "marker", marker });
954
+ },
955
+ [applyViewState, emitSelectionChange, markerFocusZoom]
956
+ );
957
+ const selectCluster = React3__namespace.useCallback(
958
+ (cluster) => {
959
+ setSelection({
960
+ type: "cluster",
961
+ clusterId: cluster.id
962
+ });
963
+ applyViewState({
964
+ latitude: cluster.latitude,
965
+ longitude: cluster.longitude,
966
+ zoom: clusterFocusZoom
967
+ });
968
+ emitSelectionChange({ type: "cluster", cluster });
969
+ },
970
+ [applyViewState, clusterFocusZoom, emitSelectionChange]
971
+ );
972
+ const clearSelection = React3__namespace.useCallback(() => {
973
+ setSelection({ type: "none" });
974
+ emitSelectionChange({ type: "none" });
975
+ }, [emitSelectionChange]);
976
+ const mapMarkers = React3__namespace.useMemo(() => {
977
+ const resolvedMarkers = [];
978
+ normalizedClusters.forEach((cluster) => {
979
+ const isSelected = selection.type === "cluster" && selection.clusterId === cluster.id;
980
+ resolvedMarkers.push({
981
+ id: `cluster-pin:${cluster.id}`,
982
+ latitude: cluster.latitude,
983
+ longitude: cluster.longitude,
984
+ element: () => {
985
+ const customMarkerElement = cluster.markerElement;
986
+ const markerBody = typeof customMarkerElement === "function" ? customMarkerElement({
987
+ isSelected,
988
+ count: cluster.markers.length
989
+ }) : customMarkerElement;
990
+ return /* @__PURE__ */ jsxRuntime.jsx(
991
+ "button",
992
+ {
993
+ type: "button",
994
+ className: "group cursor-pointer",
995
+ onClick: (event) => {
996
+ event.preventDefault();
997
+ event.stopPropagation();
998
+ selectCluster(cluster);
999
+ },
1000
+ "aria-label": `View ${cluster.markers.length} clustered locations`,
1001
+ children: markerBody ?? /* @__PURE__ */ jsxRuntime.jsx(
1002
+ "span",
1003
+ {
1004
+ className: cn(
1005
+ "inline-flex min-h-10 min-w-10 items-center justify-center rounded-full border-2 border-white px-2 text-xs font-semibold text-white shadow-lg transition-transform duration-200 group-hover:scale-105",
1006
+ isSelected && "ring-4 ring-primary/30",
1007
+ cluster.pinClassName
1008
+ ),
1009
+ style: {
1010
+ backgroundColor: cluster.pinColor ?? "var(--foreground)"
1011
+ },
1012
+ children: cluster.markers.length
1013
+ }
1014
+ )
1015
+ }
1016
+ );
1017
+ }
1018
+ });
1019
+ });
1020
+ normalizedStandaloneMarkers.forEach((marker) => {
1021
+ const isSelected = selection.type === "marker" && selection.markerId === marker.id;
1022
+ const customMarkerElement = marker.markerElement;
1023
+ resolvedMarkers.push({
1024
+ id: marker.id,
1025
+ latitude: marker.latitude,
1026
+ longitude: marker.longitude,
1027
+ draggable: marker.draggable,
1028
+ element: () => {
1029
+ const markerBody = typeof customMarkerElement === "function" ? customMarkerElement({ isSelected }) : customMarkerElement;
1030
+ return /* @__PURE__ */ jsxRuntime.jsx(
1031
+ "button",
1032
+ {
1033
+ type: "button",
1034
+ className: "group cursor-pointer",
1035
+ onClick: (event) => {
1036
+ event.preventDefault();
1037
+ event.stopPropagation();
1038
+ selectMarker(marker);
1039
+ },
1040
+ "aria-label": typeof marker.title === "string" ? `View ${marker.title}` : "View location details",
1041
+ children: markerBody ?? /* @__PURE__ */ jsxRuntime.jsx(
1042
+ "span",
1043
+ {
1044
+ className: cn(
1045
+ "inline-flex h-4 w-4 rounded-full border-2 border-white shadow-md transition-transform duration-200 group-hover:scale-110",
1046
+ isSelected && "h-5 w-5 ring-4 ring-primary/30",
1047
+ marker.pinClassName
1048
+ ),
1049
+ style: {
1050
+ backgroundColor: marker.pinColor ?? "#f43f5e"
1051
+ }
1052
+ }
1053
+ )
1054
+ }
1055
+ );
1056
+ }
1057
+ });
1058
+ });
1059
+ return resolvedMarkers;
1060
+ }, [
1061
+ normalizedClusters,
1062
+ normalizedStandaloneMarkers,
1063
+ selectCluster,
1064
+ selectMarker,
1065
+ selection
1066
+ ]);
1067
+ const renderMarkerPanel = () => {
1068
+ if (selectedMarker) {
1069
+ const markerMediaItems = selectedMarker.mediaItems ?? [];
1070
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1071
+ "div",
1072
+ {
1073
+ className: cn(
1074
+ "relative w-[320px] overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-2xl",
1075
+ panelClassName
1076
+ ),
1077
+ children: [
1078
+ /* @__PURE__ */ jsxRuntime.jsx(
1079
+ "button",
1080
+ {
1081
+ type: "button",
1082
+ "aria-label": "Close marker details",
1083
+ className: "flex size-12 items-center justify-center rounded-bl-lg rounded-br-0 rounded-t-0 bg-black text-white transition-all duration-500 absolute top-0 right-0 z-10 cursor-pointer ring-4 ring-white",
1084
+ onClick: clearSelection,
1085
+ children: /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { name: "lucide/x", size: 20 })
1086
+ }
1087
+ ),
1088
+ markerMediaItems.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
1089
+ MarkerMediaCarousel,
1090
+ {
1091
+ mediaItems: markerMediaItems,
1092
+ optixFlowConfig,
1093
+ IconComponent,
1094
+ ImgComponent
1095
+ }
1096
+ ) : null,
1097
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 p-4", children: [
1098
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start justify-between gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 space-y-1", children: [
1099
+ selectedMarker.eyebrow ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-semibold uppercase tracking-wide", children: selectedMarker.eyebrow }) : null,
1100
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold leading-tight", children: selectedMarker.title ?? selectedMarker.label ?? "Location" })
1101
+ ] }) }),
1102
+ selectedMarker.summary ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm leading-relaxed", children: selectedMarker.summary }) : null,
1103
+ selectedMarker.locationLine ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-center justify-start text-sm gap-2", children: [
1104
+ /* @__PURE__ */ jsxRuntime.jsx(
1105
+ IconComponent,
1106
+ {
1107
+ name: "lucide:map-pin",
1108
+ className: "opacity-50",
1109
+ size: 18
1110
+ }
1111
+ ),
1112
+ typeof selectedMarker.locationLine === "string" ? /* @__PURE__ */ jsxRuntime.jsx(
1113
+ SimplePressable,
1114
+ {
1115
+ href: selectedMarker.locationUrl,
1116
+ className: cn(
1117
+ "transition-all duration-500",
1118
+ "font-medium opacity-75 hover:opacity-100",
1119
+ selectedMarker.locationUrl ? "underline underline-offset-4" : ""
1120
+ ),
1121
+ children: selectedMarker.locationLine
1122
+ }
1123
+ ) : selectedMarker.locationLine
1124
+ ] }) : null,
1125
+ selectedMarker.hoursLine ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row items-center justify-start text-sm gap-2", children: [
1126
+ /* @__PURE__ */ jsxRuntime.jsx(
1127
+ IconComponent,
1128
+ {
1129
+ name: "lucide:clock",
1130
+ className: "opacity-50",
1131
+ size: 18
1132
+ }
1133
+ ),
1134
+ typeof selectedMarker.hoursLine === "string" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium", children: selectedMarker.hoursLine }) : selectedMarker.hoursLine
1135
+ ] }) : null,
1136
+ selectedMarker.markerContentComponent ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: selectedMarker.markerContentComponent }) : null,
1137
+ /* @__PURE__ */ jsxRuntime.jsx(MarkerActions, { actions: selectedMarker.actions })
1138
+ ] })
1139
+ ]
1140
+ }
1141
+ );
1142
+ }
1143
+ if (selectedCluster) {
1144
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1145
+ "div",
1146
+ {
1147
+ className: cn(
1148
+ "relative w-[320px] overflow-hidden rounded-xl border border-border bg-card text-card-foreground p-4 shadow-2xl",
1149
+ panelClassName
1150
+ ),
1151
+ children: [
1152
+ /* @__PURE__ */ jsxRuntime.jsx(
1153
+ "button",
1154
+ {
1155
+ type: "button",
1156
+ "aria-label": "Close cluster details",
1157
+ className: "flex size-8 items-center justify-center rounded-full border border-border bg-card text-card-foreground transition hover:bg-muted hover:text-foreground absolute top-2 right-2 z-10",
1158
+ onClick: clearSelection,
1159
+ children: /* @__PURE__ */ jsxRuntime.jsx(IconComponent, { name: "lucide/x", size: 20 })
1160
+ }
1161
+ ),
1162
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-3 flex items-start justify-between gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
1163
+ selectedCluster.label ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: selectedCluster.label }) : null,
1164
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold leading-tight text-foreground", children: selectedCluster.title ?? "Clustered Locations" }),
1165
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: selectedCluster.summary ?? `${selectedCluster.markers.length} location${selectedCluster.markers.length === 1 ? "" : "s"} in this cluster.` })
1166
+ ] }) }),
1167
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-h-56 space-y-2 overflow-y-auto pr-1", children: selectedCluster.markers.map((marker, markerIndex) => /* @__PURE__ */ jsxRuntime.jsxs(
1168
+ "button",
1169
+ {
1170
+ type: "button",
1171
+ className: "w-full rounded-lg border border-border/60 p-3 text-left transition hover:border-border hover:bg-muted/50",
1172
+ onClick: () => selectMarker(marker),
1173
+ children: [
1174
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "line-clamp-1 text-sm font-semibold text-foreground", children: getMarkerTitle(marker, markerIndex) }),
1175
+ marker.summary ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 line-clamp-2 text-xs text-muted-foreground", children: marker.summary }) : null
1176
+ ]
1177
+ },
1178
+ marker.id
1179
+ )) })
1180
+ ]
1181
+ }
1182
+ );
1183
+ }
1184
+ return null;
1185
+ };
1186
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1187
+ "div",
1188
+ {
1189
+ className: cn(
1190
+ "relative overflow-hidden rounded-2xl border border-border bg-background",
1191
+ className
1192
+ ),
1193
+ children: [
1194
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("h-[520px] w-full", mapWrapperClassName), children: /* @__PURE__ */ jsxRuntime.jsx(
1195
+ MapLibre,
1196
+ {
1197
+ stadiaApiKey,
1198
+ mapStyle,
1199
+ styleUrl,
1200
+ mapLibreCssHref,
1201
+ viewState: resolvedViewState,
1202
+ onViewStateChange: applyViewState,
1203
+ markers: mapMarkers,
1204
+ onClick: (coord) => {
1205
+ onMapClick?.(coord);
1206
+ if (clearSelectionOnMapClick) {
1207
+ clearSelection();
1208
+ }
1209
+ },
1210
+ onMarkerDrag,
1211
+ showNavigationControl,
1212
+ showGeolocateControl,
1213
+ navigationControlPosition,
1214
+ geolocateControlPosition,
1215
+ flyToOptions,
1216
+ className: cn("h-full w-full", mapClassName),
1217
+ children: mapChildren
1218
+ }
1219
+ ) }),
1220
+ selection.type !== "none" ? /* @__PURE__ */ jsxRuntime.jsx(
1221
+ "div",
1222
+ {
1223
+ className: cn(
1224
+ "pointer-events-none absolute z-20",
1225
+ PANEL_POSITION_CLASS[panelPosition]
1226
+ ),
1227
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-auto", children: renderMarkerPanel() })
1228
+ }
1229
+ ) : null
1230
+ ]
1231
+ }
1232
+ );
1233
+ }
1234
+
1235
+ exports.GeoMap = GeoMap;
1236
+ //# sourceMappingURL=geo-map.cjs.map
1237
+ //# sourceMappingURL=geo-map.cjs.map