@abraca/nuxt 2.35.1 → 2.37.0

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 (93) hide show
  1. package/dist/module.d.mts +6 -0
  2. package/dist/module.json +1 -1
  3. package/dist/runtime/components/ADocPickModal.vue +1 -1
  4. package/dist/runtime/components/ADocSubPageList.d.vue.ts +46 -0
  5. package/dist/runtime/components/ADocSubPageList.vue +1006 -0
  6. package/dist/runtime/components/ADocSubPageList.vue.d.ts +46 -0
  7. package/dist/runtime/components/ADocumentTree.vue +3 -2
  8. package/dist/runtime/components/AEditor.d.vue.ts +9 -0
  9. package/dist/runtime/components/AEditor.vue +14 -2
  10. package/dist/runtime/components/AEditor.vue.d.ts +9 -0
  11. package/dist/runtime/components/AIconPicker.vue +27 -180
  12. package/dist/runtime/components/ANodePanel.d.vue.ts +8 -5
  13. package/dist/runtime/components/ANodePanel.vue +1 -1
  14. package/dist/runtime/components/ANodePanel.vue.d.ts +8 -5
  15. package/dist/runtime/components/AWindowLayer.vue +4 -2
  16. package/dist/runtime/components/aware/AMedia.d.vue.ts +1 -1
  17. package/dist/runtime/components/aware/AMedia.vue.d.ts +1 -1
  18. package/dist/runtime/components/docs/ADocsSearch.d.vue.ts +2 -2
  19. package/dist/runtime/components/docs/ADocsSearch.vue.d.ts +2 -2
  20. package/dist/runtime/components/editor/ADocSuggestMenu.vue +1 -1
  21. package/dist/runtime/components/editor/ALocationPickerPopover.vue +31 -16
  22. package/dist/runtime/components/renderers/ACalendarRenderer.d.vue.ts +1 -0
  23. package/dist/runtime/components/renderers/ACalendarRenderer.vue +309 -68
  24. package/dist/runtime/components/renderers/ACalendarRenderer.vue.d.ts +1 -0
  25. package/dist/runtime/components/renderers/AChecklistRenderer.vue +259 -40
  26. package/dist/runtime/components/renderers/ADashboardRenderer.vue +493 -89
  27. package/dist/runtime/components/renderers/AGraphRenderer.d.vue.ts +2 -0
  28. package/dist/runtime/components/renderers/AGraphRenderer.vue +2113 -576
  29. package/dist/runtime/components/renderers/AGraphRenderer.vue.d.ts +2 -0
  30. package/dist/runtime/components/renderers/AKanbanRenderer.vue +460 -86
  31. package/dist/runtime/components/renderers/AMapRenderer.d.vue.ts +7 -1
  32. package/dist/runtime/components/renderers/AMapRenderer.vue +999 -166
  33. package/dist/runtime/components/renderers/AMapRenderer.vue.d.ts +7 -1
  34. package/dist/runtime/components/renderers/AOutlineRenderer.d.vue.ts +2 -0
  35. package/dist/runtime/components/renderers/AOutlineRenderer.vue +285 -81
  36. package/dist/runtime/components/renderers/AOutlineRenderer.vue.d.ts +2 -0
  37. package/dist/runtime/components/renderers/AOverviewRenderer.vue +3 -2
  38. package/dist/runtime/components/renderers/ASheetsRenderer.client.vue +255 -87
  39. package/dist/runtime/components/renderers/ATimelineRenderer.d.vue.ts +1 -0
  40. package/dist/runtime/components/renderers/ATimelineRenderer.vue +224 -31
  41. package/dist/runtime/components/renderers/ATimelineRenderer.vue.d.ts +1 -0
  42. package/dist/runtime/components/renderers/calendar/ACalendarDayCell.d.vue.ts +8 -0
  43. package/dist/runtime/components/renderers/calendar/ACalendarDayCell.vue +12 -1
  44. package/dist/runtime/components/renderers/calendar/ACalendarDayCell.vue.d.ts +8 -0
  45. package/dist/runtime/components/renderers/calendar/ACalendarEventChip.d.vue.ts +10 -0
  46. package/dist/runtime/components/renderers/calendar/ACalendarEventChip.vue +15 -3
  47. package/dist/runtime/components/renderers/calendar/ACalendarEventChip.vue.d.ts +10 -0
  48. package/dist/runtime/components/renderers/calendar/ACalendarMonthView.d.vue.ts +14 -0
  49. package/dist/runtime/components/renderers/calendar/ACalendarMonthView.vue +6 -1
  50. package/dist/runtime/components/renderers/calendar/ACalendarMonthView.vue.d.ts +14 -0
  51. package/dist/runtime/components/renderers/sheets/ASheetsGrid.d.vue.ts +6 -6
  52. package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue +25 -7
  53. package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue.d.ts +6 -6
  54. package/dist/runtime/components/renderers/sheets/ASheetsMobileActionBar.d.vue.ts +2 -2
  55. package/dist/runtime/components/renderers/sheets/ASheetsMobileActionBar.vue.d.ts +2 -2
  56. package/dist/runtime/components/renderers/sheets/ASheetsToolbar.d.vue.ts +6 -0
  57. package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue +130 -23
  58. package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue.d.ts +6 -0
  59. package/dist/runtime/components/renderers/timeline/ATimelineAxis.vue +5 -3
  60. package/dist/runtime/components/renderers/timeline/ATimelineBar.vue +1 -1
  61. package/dist/runtime/components/renderers/timeline/ATimelineBarArea.d.vue.ts +0 -2
  62. package/dist/runtime/components/renderers/timeline/ATimelineBarArea.vue +16 -14
  63. package/dist/runtime/components/renderers/timeline/ATimelineBarArea.vue.d.ts +0 -2
  64. package/dist/runtime/components/renderers/timeline/ATimelineLabelPanel.vue +4 -2
  65. package/dist/runtime/composables/useCalendarView.js +34 -11
  66. package/dist/runtime/composables/useConnectionStatus.d.ts +1 -1
  67. package/dist/runtime/composables/useGraphReferenceEdges.d.ts +26 -0
  68. package/dist/runtime/composables/useGraphReferenceEdges.js +138 -0
  69. package/dist/runtime/composables/useGraphSim.d.ts +79 -0
  70. package/dist/runtime/composables/useGraphSim.js +231 -0
  71. package/dist/runtime/composables/useSheetsDependencyGraph.d.ts +26 -0
  72. package/dist/runtime/composables/useSheetsDependencyGraph.js +76 -0
  73. package/dist/runtime/composables/useSheetsFormulas.d.ts +4 -3
  74. package/dist/runtime/composables/useSheetsFormulas.js +575 -26
  75. package/dist/runtime/composables/useTimelineView.d.ts +4 -0
  76. package/dist/runtime/composables/useTimelineView.js +45 -11
  77. package/dist/runtime/composables/useWindowManager.d.ts +4 -0
  78. package/dist/runtime/composables/useWindowManager.js +11 -0
  79. package/dist/runtime/utils/dateField.d.ts +17 -0
  80. package/dist/runtime/utils/dateField.js +19 -0
  81. package/dist/runtime/utils/itemLabel.d.ts +27 -0
  82. package/dist/runtime/utils/itemLabel.js +8 -0
  83. package/dist/runtime/utils/localDate.d.ts +15 -0
  84. package/dist/runtime/utils/localDate.js +16 -0
  85. package/dist/runtime/utils/lucideIcons.d.ts +16 -10
  86. package/dist/runtime/utils/lucideIcons.js +1391 -69
  87. package/dist/runtime/utils/resolveDocColor.d.ts +7 -0
  88. package/dist/runtime/utils/resolveDocColor.js +32 -0
  89. package/dist/runtime/utils/resolveDocIcon.d.ts +10 -0
  90. package/dist/runtime/utils/resolveDocIcon.js +44 -0
  91. package/dist/runtime/utils/rowEdges.d.ts +22 -0
  92. package/dist/runtime/utils/rowEdges.js +29 -0
  93. package/package.json +1 -1
@@ -1,10 +1,14 @@
1
1
  <script setup>
2
- import { ref, computed, watch, shallowRef, onMounted, onBeforeUnmount, onUnmounted, defineAsyncComponent } from "vue";
3
- import { useRuntimeConfig, useColorMode, useAppConfig } from "#imports";
2
+ import { ref, computed, watch, nextTick, shallowRef, onMounted, onBeforeUnmount, onUnmounted, defineAsyncComponent } from "vue";
3
+ import { useRuntimeConfig, useColorMode, useAppConfig, useToast } from "#imports";
4
+ import { useRouter } from "vue-router";
4
5
  import { avatarBorderStyle } from "../../utils/avatarStyle";
5
6
  import { useAbracadabra } from "../../composables/useAbracadabra";
6
7
  import { useRendererBase } from "../../composables/useRendererBase";
7
8
  import { useNodePanel } from "../../composables/useNodePanel";
9
+ import { useNodePanelFollow } from "../../composables/useNodePanelFollow";
10
+ import { useWindowManager } from "../../composables/useWindowManager";
11
+ import { useItemPresence, useViewingBroadcast } from "../../composables/useItemPresence";
8
12
  import { DEFAULT_LOCALE } from "../../locale";
9
13
  const AEditor = defineAsyncComponent(
10
14
  () => import("../AEditor.vue")
@@ -15,9 +19,13 @@ const props = defineProps({
15
19
  docLabel: { type: String, required: true },
16
20
  pageTypes: { type: Array, required: false },
17
21
  labels: { type: Object, required: false },
18
- editable: { type: Boolean, required: false, default: true }
22
+ editable: { type: Boolean, required: false, default: true },
23
+ followingUser: { type: [String, null], required: false, default: null }
19
24
  });
25
+ const emit = defineEmits(["follow"]);
20
26
  const config = useRuntimeConfig();
27
+ const router = useRouter();
28
+ const toast = useToast();
21
29
  const locale = computed(() => ({
22
30
  ...DEFAULT_LOCALE.renderers.map,
23
31
  ...config.public?.abracadabra?.locale?.renderers?.map ?? {},
@@ -36,6 +44,18 @@ const {
36
44
  openNode,
37
45
  closePanel
38
46
  } = useNodePanel(childProviderRef);
47
+ useNodePanelFollow(
48
+ openNodeId,
49
+ openNodeLabel,
50
+ openNode,
51
+ closePanel,
52
+ () => props.followingUser,
53
+ states,
54
+ setLocalState
55
+ );
56
+ useViewingBroadcast(() => props.docId, openNodeId);
57
+ const { getViewers: getDocViewers } = useItemPresence();
58
+ const wm = useWindowManager();
39
59
  let mapboxgl = null;
40
60
  const mapboxLoaded = ref(false);
41
61
  const mapboxError = ref(null);
@@ -148,7 +168,44 @@ const isDark = computed(() => colorMode.value === "dark");
148
168
  const mapAppConfig = useAppConfig();
149
169
  const mapNeutralColor = computed(() => mapAppConfig.ui?.colors?.neutral ?? "zinc");
150
170
  const activeMode = ref("pan");
151
- const showLabels = ref(true);
171
+ const docMeta = computed(() => tree.treeMap.data?.[props.docId]?.meta);
172
+ const showLabels = computed({
173
+ get: () => docMeta.value?.mapShowLabels ?? true,
174
+ set: (v) => {
175
+ if (props.editable) tree.updateMeta(props.docId, { mapShowLabels: v });
176
+ }
177
+ });
178
+ const MAP_STYLE_URLS = {
179
+ "standard": "mapbox://styles/mapbox/standard",
180
+ "streets": "mapbox://styles/mapbox/streets-v12",
181
+ "satellite": "mapbox://styles/mapbox/satellite-v9",
182
+ "satellite-streets": "mapbox://styles/mapbox/satellite-streets-v12"
183
+ };
184
+ const mapStyleKey = computed({
185
+ get: () => docMeta.value?.mapStyle ?? "standard",
186
+ set: (v) => {
187
+ if (props.editable) tree.updateMeta(props.docId, { mapStyle: v });
188
+ }
189
+ });
190
+ const isStandardStyle = computed(() => mapStyleKey.value === "standard");
191
+ const show3dBuildings = computed({
192
+ get: () => docMeta.value?.map3dBuildings ?? true,
193
+ set: (v) => {
194
+ if (props.editable) tree.updateMeta(props.docId, { map3dBuildings: v });
195
+ }
196
+ });
197
+ const lightPreset = computed({
198
+ get: () => docMeta.value?.mapLightPreset ?? "auto",
199
+ set: (v) => {
200
+ if (props.editable) tree.updateMeta(props.docId, { mapLightPreset: v });
201
+ }
202
+ });
203
+ const showTerrain = computed({
204
+ get: () => docMeta.value?.mapTerrain ?? true,
205
+ set: (v) => {
206
+ if (props.editable) tree.updateMeta(props.docId, { mapTerrain: v });
207
+ }
208
+ });
152
209
  const popupProvider = shallowRef(null);
153
210
  const popupDocId = ref(null);
154
211
  const popupDocLabel = ref("");
@@ -188,6 +245,293 @@ function clearPopupProvider() {
188
245
  popupDocId.value = null;
189
246
  popupDocLabel.value = "";
190
247
  }
248
+ const ctxMenuOpen = ref(false);
249
+ const ctxMenuPos = ref({ x: 0, y: 0 });
250
+ const ctxMenuTarget = ref(null);
251
+ function openCtxMenu(x, y, type, lngLat, id) {
252
+ ctxMenuPos.value = { x, y };
253
+ ctxMenuTarget.value = { type, id, lngLat };
254
+ ctxMenuOpen.value = true;
255
+ }
256
+ const contextMenuItems = computed(() => {
257
+ const tgt = ctxMenuTarget.value;
258
+ if (!tgt) return [];
259
+ const w = props.editable;
260
+ const openItems = (id, entry) => [
261
+ { label: "Open", icon: "i-lucide-external-link", onSelect: () => {
262
+ if (id) router.push(`/doc/${id}`);
263
+ } },
264
+ { label: locale.value.openInPanel ?? "Open as slideover", icon: "i-lucide-panel-right", onSelect: () => {
265
+ if (id && entry) openNode(id, entry.label);
266
+ } },
267
+ ...wm.floatWindowsAvailable.value ? [{ label: "Open as window", icon: "i-lucide-picture-in-picture-2", onSelect: () => {
268
+ if (id && entry) openAsWindow(id, entry.label);
269
+ } }] : []
270
+ ];
271
+ switch (tgt.type) {
272
+ case "empty":
273
+ return [
274
+ [
275
+ ...w ? [{ label: "Place marker here", icon: "i-lucide-map-pin", onSelect: () => {
276
+ const id = tree.createChild(null, userName.value);
277
+ tree.updateMeta(id, { geoType: "marker", geoLat: tgt.lngLat.lat, geoLng: tgt.lngLat.lng, icon: "map-pin", color: myColorHex.value });
278
+ } }] : [],
279
+ { label: "Ping here", icon: "i-lucide-radio", onSelect: () => sendPing(tgt.lngLat.lng, tgt.lngLat.lat) }
280
+ ]
281
+ ];
282
+ case "marker": {
283
+ const entry = markers.value.find((e) => e.id === tgt.id);
284
+ return [
285
+ [
286
+ ...openItems(tgt.id, entry),
287
+ ...w ? [{ label: locale.value.reposition ?? "Reposition", icon: "i-lucide-move", onSelect: () => {
288
+ if (!tgt.id) return;
289
+ openMarkerPopup(tgt.id);
290
+ toggleReposition();
291
+ } }] : []
292
+ ],
293
+ ...w ? [[{ label: "Delete", icon: "i-lucide-trash-2", color: "error", onSelect: () => {
294
+ if (tgt.id) tree.deleteEntry(tgt.id);
295
+ } }]] : []
296
+ ];
297
+ }
298
+ case "line": {
299
+ const entry = lines.value.find((e) => e.id === tgt.id);
300
+ return [
301
+ openItems(tgt.id, entry),
302
+ ...w ? [[{ label: "Delete", icon: "i-lucide-trash-2", color: "error", onSelect: () => {
303
+ if (!tgt.id) return;
304
+ tree.deleteEntry(tgt.id);
305
+ if (selectedLineKey.value === tgt.id) closeLinePopup();
306
+ } }]] : []
307
+ ];
308
+ }
309
+ case "measure": {
310
+ const info = tgt.id ? getMeasureDistance(tgt.id) : null;
311
+ return [
312
+ ...info ? [[
313
+ { label: "Copy distance", icon: "i-lucide-copy", onSelect: () => {
314
+ navigator.clipboard.writeText(formatDist(info));
315
+ } }
316
+ ]] : [],
317
+ ...w ? [[{ label: "Delete", icon: "i-lucide-trash-2", color: "error", onSelect: () => {
318
+ if (!tgt.id) return;
319
+ tree.deleteEntry(tgt.id);
320
+ if (selectedMeasureKey.value === tgt.id) selectedMeasureKey.value = null;
321
+ } }]] : []
322
+ ];
323
+ }
324
+ default:
325
+ return [];
326
+ }
327
+ });
328
+ function getMeasureDistance(id) {
329
+ const entry = measures.value.find((e) => e.id === id);
330
+ if (!entry) return null;
331
+ const pts = tree.childrenOf(entry.id).filter(
332
+ (p) => p.meta?.geoLat !== void 0 && p.meta?.geoLng !== void 0
333
+ );
334
+ if (pts.length < 2) return null;
335
+ let dist = 0;
336
+ for (let i = 1; i < pts.length; i++) {
337
+ dist += haversine(
338
+ [pts[i - 1].meta.geoLng, pts[i - 1].meta.geoLat],
339
+ [pts[i].meta.geoLng, pts[i].meta.geoLat]
340
+ );
341
+ }
342
+ return dist;
343
+ }
344
+ const searchOpen = ref(false);
345
+ const searchQuery = ref("");
346
+ const searchResults = ref([]);
347
+ const searchSearching = ref(false);
348
+ const selectedSearchResult = ref(null);
349
+ let searchPreviewMarker = null;
350
+ let geoSearchTimeout = null;
351
+ let geoSearchSeq = 0;
352
+ watch(searchQuery, (q) => {
353
+ if (geoSearchTimeout) clearTimeout(geoSearchTimeout);
354
+ if (!q.trim()) {
355
+ searchResults.value = [];
356
+ return;
357
+ }
358
+ geoSearchTimeout = setTimeout(() => doGeoSearch(q), 350);
359
+ });
360
+ async function doGeoSearch(q) {
361
+ if (!q.trim() || !mapboxgl) return;
362
+ const seq = ++geoSearchSeq;
363
+ searchSearching.value = true;
364
+ try {
365
+ const url = `https://api.mapbox.com/search/geocode/v6/forward?q=${encodeURIComponent(q)}&limit=5&access_token=${mapboxgl.accessToken}`;
366
+ const res = await fetch(url);
367
+ if (!res.ok) throw new Error(`Geocode request failed: ${res.status}`);
368
+ const data = await res.json();
369
+ if (seq !== geoSearchSeq) return;
370
+ searchResults.value = (data.features ?? []).map((f) => ({
371
+ label: f.properties?.full_address ?? f.properties?.name ?? "",
372
+ lng: f.geometry.coordinates[0],
373
+ lat: f.geometry.coordinates[1]
374
+ }));
375
+ } catch {
376
+ if (seq === geoSearchSeq) searchResults.value = [];
377
+ } finally {
378
+ if (seq === geoSearchSeq) searchSearching.value = false;
379
+ }
380
+ }
381
+ function selectSearchResult(r) {
382
+ selectedSearchResult.value = r;
383
+ searchQuery.value = r.label;
384
+ searchResults.value = [];
385
+ clearSearchPreview();
386
+ searchPreviewMarker = new mapboxgl.Marker({ color: "#6366f1", draggable: props.editable }).setLngLat([r.lng, r.lat]).addTo(map);
387
+ searchPreviewMarker.on("dragend", () => {
388
+ if (!props.editable) return;
389
+ const pos = searchPreviewMarker.getLngLat();
390
+ selectedSearchResult.value = { ...selectedSearchResult.value, lng: pos.lng, lat: pos.lat };
391
+ });
392
+ map?.flyTo({ center: [r.lng, r.lat], zoom: 13 });
393
+ }
394
+ function placeSearchMarker() {
395
+ if (!props.editable) return;
396
+ const r = selectedSearchResult.value;
397
+ if (!r) return;
398
+ const pos = searchPreviewMarker?.getLngLat() ?? { lng: r.lng, lat: r.lat };
399
+ const id = tree.createChild(null, r.label || userName.value);
400
+ tree.updateMeta(id, {
401
+ geoType: "marker",
402
+ geoLat: pos.lat,
403
+ geoLng: pos.lng,
404
+ icon: "map-pin",
405
+ color: myColorHex.value
406
+ });
407
+ clearSearchPreview();
408
+ selectedSearchResult.value = null;
409
+ searchQuery.value = "";
410
+ searchOpen.value = false;
411
+ }
412
+ function clearSearchPreview() {
413
+ searchPreviewMarker?.remove();
414
+ searchPreviewMarker = null;
415
+ }
416
+ watch(searchOpen, (open) => {
417
+ if (!open) {
418
+ clearSearchPreview();
419
+ selectedSearchResult.value = null;
420
+ searchQuery.value = "";
421
+ searchResults.value = [];
422
+ }
423
+ });
424
+ const liveLocationActive = ref(false);
425
+ const liveLocationPos = ref(null);
426
+ let geoWatchId = null;
427
+ let liveLocationMarkerInstance = null;
428
+ const liveLocationLogOpen = ref(false);
429
+ const liveLocationLogNote = ref("");
430
+ const remoteLiveLocationMarkers = /* @__PURE__ */ new Map();
431
+ let firstLocationFix = true;
432
+ function toggleLiveLocation() {
433
+ if (liveLocationActive.value) {
434
+ liveLocationLogOpen.value = !liveLocationLogOpen.value;
435
+ return;
436
+ }
437
+ startLiveLocation();
438
+ }
439
+ function startLiveLocation() {
440
+ if (typeof navigator === "undefined" || !navigator.geolocation) {
441
+ toast.add({ title: "Location unavailable", description: "Geolocation is not available in this browser.", color: "warning" });
442
+ return;
443
+ }
444
+ firstLocationFix = true;
445
+ liveLocationActive.value = true;
446
+ geoWatchId = navigator.geolocation.watchPosition(
447
+ (pos) => {
448
+ const { longitude: lng, latitude: lat, accuracy } = pos.coords;
449
+ liveLocationPos.value = { lng, lat, accuracy };
450
+ setLocalState({ mapLiveLocation: { lng, lat, accuracy, t: Date.now() } });
451
+ updateOwnLiveLocationMarker(lng, lat);
452
+ if (firstLocationFix && map) {
453
+ map.flyTo({ center: [lng, lat], zoom: 15 });
454
+ firstLocationFix = false;
455
+ }
456
+ },
457
+ (err) => {
458
+ liveLocationActive.value = false;
459
+ liveLocationPos.value = null;
460
+ const msg = err.code === 1 ? "Location access was denied." : "Could not determine your location.";
461
+ toast.add({ title: "Location unavailable", description: msg, color: "warning" });
462
+ },
463
+ { enableHighAccuracy: true, maximumAge: 5e3 }
464
+ );
465
+ }
466
+ function stopLiveLocation() {
467
+ if (geoWatchId !== null) {
468
+ navigator.geolocation.clearWatch(geoWatchId);
469
+ geoWatchId = null;
470
+ }
471
+ liveLocationActive.value = false;
472
+ liveLocationPos.value = null;
473
+ liveLocationLogOpen.value = false;
474
+ liveLocationLogNote.value = "";
475
+ setLocalState({ mapLiveLocation: null });
476
+ liveLocationMarkerInstance?.remove();
477
+ liveLocationMarkerInstance = null;
478
+ }
479
+ function updateOwnLiveLocationMarker(lng, lat) {
480
+ if (!map) return;
481
+ if (liveLocationMarkerInstance) {
482
+ liveLocationMarkerInstance.setLngLat([lng, lat]);
483
+ } else {
484
+ const el = createLiveLocationEl(myColorHex.value);
485
+ liveLocationMarkerInstance = new mapboxgl.Marker({ element: el, anchor: "center" }).setLngLat([lng, lat]).addTo(map);
486
+ }
487
+ }
488
+ function createLiveLocationEl(colorHex) {
489
+ const el = document.createElement("div");
490
+ el.className = "live-location-dot";
491
+ el.style.setProperty("--ll-color", colorHex);
492
+ el.innerHTML = `<div class="live-location-pulse"></div><div class="live-location-core"></div>`;
493
+ return el;
494
+ }
495
+ function tickRemoteLiveLocations() {
496
+ if (!map || !mapReady.value || !mapboxgl) return;
497
+ const seen = /* @__PURE__ */ new Set();
498
+ for (const user of remoteUsers.value) {
499
+ const ll = states.value.find((s) => s.clientId === user.clientId)?.mapLiveLocation;
500
+ if (!ll) continue;
501
+ seen.add(user.clientId);
502
+ let m = remoteLiveLocationMarkers.get(user.clientId);
503
+ if (!m) {
504
+ const el = createLiveLocationEl(user.colorHex);
505
+ m = new mapboxgl.Marker({ element: el, anchor: "center" }).setLngLat([ll.lng, ll.lat]).addTo(map);
506
+ remoteLiveLocationMarkers.set(user.clientId, m);
507
+ } else {
508
+ m.setLngLat([ll.lng, ll.lat]);
509
+ }
510
+ }
511
+ for (const [id, m] of remoteLiveLocationMarkers) {
512
+ if (!seen.has(id)) {
513
+ m.remove();
514
+ remoteLiveLocationMarkers.delete(id);
515
+ }
516
+ }
517
+ }
518
+ function placeLogMarker() {
519
+ if (!props.editable) return;
520
+ const pos = liveLocationPos.value;
521
+ if (!pos) return;
522
+ const note = liveLocationLogNote.value.trim();
523
+ const id = tree.createChild(null, note || userName.value);
524
+ tree.updateMeta(id, {
525
+ geoType: "marker",
526
+ geoLat: pos.lat,
527
+ geoLng: pos.lng,
528
+ icon: "circle-dot",
529
+ color: myColorHex.value
530
+ });
531
+ liveLocationLogNote.value = "";
532
+ liveLocationLogOpen.value = false;
533
+ }
534
+ const repositionEnabled = ref(false);
191
535
  const selectedMarkerKey = ref(null);
192
536
  const markerPopupScreenPos = ref({ x: 0, y: 0 });
193
537
  const selectedMarker = computed(
@@ -200,7 +544,10 @@ const selectedLine = computed(
200
544
  () => selectedLineKey.value ? lines.value.find((e) => e.id === selectedLineKey.value) ?? null : null
201
545
  );
202
546
  watch([selectedMarkerKey, selectedLineKey], ([mk, lk]) => {
203
- if (!mk && !lk) clearPopupProvider();
547
+ if (!mk && !lk) {
548
+ clearPopupProvider();
549
+ disableAllDragging();
550
+ }
204
551
  });
205
552
  const selectedMeasureKey = ref(null);
206
553
  const measurePopupScreenPos = ref({ x: 0, y: 0 });
@@ -307,13 +654,15 @@ function setMode(mode) {
307
654
  measurePoints.value = [];
308
655
  clearMeasurePreview();
309
656
  }
657
+ disableAllDragging();
310
658
  selectedMarkerKey.value = null;
311
659
  selectedLineKey.value = null;
312
660
  selectedMeasureKey.value = null;
313
661
  }
314
662
  const remoteUsers = computed(
315
- () => states.value.filter((s) => s.clientId !== localClientId.value).map((s) => ({
663
+ () => states.value.filter((s) => s.clientId !== localClientId.value && s.user?.name).map((s) => ({
316
664
  clientId: s.clientId,
665
+ publicKey: s.user?.publicKey ?? void 0,
317
666
  name: s.user?.name ?? "User",
318
667
  color: s.user?.color ?? "blue",
319
668
  colorHex: s.user?.color || "#6366f1",
@@ -329,10 +678,10 @@ const allPingStates = computed(
329
678
  mapPing: s.mapPing
330
679
  })).filter((s) => s.mapPing && Date.now() - s.mapPing.t < 3e3)
331
680
  );
332
- const followingUser = computed(
681
+ const followingRemoteUser = computed(
333
682
  () => remoteUsers.value.find((u) => u.clientId === followingClientId.value) ?? null
334
683
  );
335
- const getLightPreset = () => isDark.value ? "night" : "day";
684
+ const getLightPreset = () => lightPreset.value === "auto" ? isDark.value ? "night" : "day" : lightPreset.value;
336
685
  function broadcastCamera() {
337
686
  if (!map || followingClientId.value !== null) return;
338
687
  const c = map.getCenter();
@@ -346,6 +695,29 @@ function broadcastCamera() {
346
695
  }
347
696
  });
348
697
  }
698
+ function fitBoundsToContent() {
699
+ if (!map || props.followingUser) return;
700
+ const coords = [];
701
+ for (const entry of markers.value) {
702
+ const loc = getEntryLocation(entry);
703
+ if (loc) coords.push([loc.lng, loc.lat]);
704
+ }
705
+ for (const line of lines.value) {
706
+ for (const pt of tree.childrenOf(line.id)) {
707
+ if (pt.meta?.geoLat !== void 0 && pt.meta?.geoLng !== void 0) {
708
+ coords.push([pt.meta.geoLng, pt.meta.geoLat]);
709
+ }
710
+ }
711
+ }
712
+ if (coords.length === 0) return;
713
+ if (coords.length === 1) {
714
+ map.jumpTo({ center: coords[0], zoom: 14 });
715
+ return;
716
+ }
717
+ const bounds = new mapboxgl.LngLatBounds(coords[0], coords[0]);
718
+ for (const c of coords) bounds.extend(c);
719
+ map.fitBounds(bounds, { padding: 60, maxZoom: 16, animate: false });
720
+ }
349
721
  function breakFollow() {
350
722
  if (followEaseInProgress) return;
351
723
  if (followingClientId.value !== null) followingClientId.value = null;
@@ -355,6 +727,43 @@ function followUser(clientId) {
355
727
  followingClientId.value = clientId;
356
728
  lastAppliedFollowTime = 0;
357
729
  }
730
+ let syncingFromGlobal = false;
731
+ watch(
732
+ () => props.followingUser,
733
+ (pubKey) => {
734
+ syncingFromGlobal = true;
735
+ if (!pubKey) {
736
+ followingClientId.value = null;
737
+ } else {
738
+ const user = remoteUsers.value.find((u) => u.publicKey === pubKey);
739
+ if (user) followUser(user.clientId);
740
+ }
741
+ nextTick(() => {
742
+ syncingFromGlobal = false;
743
+ });
744
+ }
745
+ );
746
+ watch(states, () => {
747
+ const pubKey = props.followingUser;
748
+ if (!pubKey || followingClientId.value !== null) return;
749
+ const user = remoteUsers.value.find((u) => u.publicKey === pubKey);
750
+ if (user) {
751
+ syncingFromGlobal = true;
752
+ followUser(user.clientId);
753
+ nextTick(() => {
754
+ syncingFromGlobal = false;
755
+ });
756
+ }
757
+ });
758
+ watch(followingClientId, (clientId) => {
759
+ if (syncingFromGlobal) return;
760
+ if (clientId === null) {
761
+ emit("follow", null);
762
+ return;
763
+ }
764
+ const user = remoteUsers.value.find((u) => u.clientId === clientId);
765
+ if (user?.publicKey) emit("follow", user.publicKey);
766
+ });
358
767
  function emptyFC() {
359
768
  return { type: "FeatureCollection", features: [] };
360
769
  }
@@ -499,14 +908,12 @@ function createMarkerEl(data, key) {
499
908
  ev.stopPropagation();
500
909
  openMarkerPopup(key);
501
910
  });
502
- if (props.editable) {
503
- container.addEventListener("contextmenu", (ev) => {
504
- ev.preventDefault();
505
- ev.stopPropagation();
506
- if (selectedMarkerKey.value === key) closeMarkerPopup();
507
- tree.deleteEntry(key);
508
- });
509
- }
911
+ container.addEventListener("contextmenu", (ev) => {
912
+ ev.preventDefault();
913
+ ev.stopPropagation();
914
+ const loc = getEntryLocation(allEntries.value.find((e) => e.id === key));
915
+ openCtxMenu(ev.clientX, ev.clientY, "marker", loc ?? { lng: 0, lat: 0 }, key);
916
+ });
510
917
  container.appendChild(pin);
511
918
  container.appendChild(labelEl);
512
919
  return container;
@@ -536,13 +943,12 @@ function syncMarkers() {
536
943
  updateMarkerEl(markerInstances.get(entry.id).getElement(), data);
537
944
  } else {
538
945
  const el = createMarkerEl(data, entry.id);
539
- const m = new mapboxgl.Marker({ element: el, anchor: "bottom", draggable: props.editable }).setLngLat([data.lng, data.lat]).addTo(map);
540
- if (props.editable) {
541
- m.on("dragend", () => {
542
- const lngLat = m.getLngLat();
543
- tree.updateMeta(entry.id, { geoLng: lngLat.lng, geoLat: lngLat.lat });
544
- });
545
- }
946
+ const m = new mapboxgl.Marker({ element: el, anchor: "bottom", draggable: false }).setLngLat([data.lng, data.lat]).addTo(map);
947
+ m.on("dragend", () => {
948
+ if (!props.editable) return;
949
+ const lngLat = m.getLngLat();
950
+ tree.updateMeta(entry.id, { geoLng: lngLat.lng, geoLat: lngLat.lat });
951
+ });
546
952
  markerInstances.set(entry.id, m);
547
953
  }
548
954
  const inst = markerInstances.get(entry.id);
@@ -570,6 +976,7 @@ onBeforeUnmount(() => {
570
976
  tree.treeMap.yMap.value?.unobserve(onTreeYMapChange);
571
977
  });
572
978
  function openMarkerPopup(key) {
979
+ disableAllDragging();
573
980
  const entry = markers.value.find((e) => e.id === key);
574
981
  if (!entry) return;
575
982
  selectedMarkerKey.value = key;
@@ -578,15 +985,43 @@ function openMarkerPopup(key) {
578
985
  updateAllPopupPositions();
579
986
  loadPopupProvider(key, entry.label);
580
987
  }
988
+ function disableAllDragging() {
989
+ repositionEnabled.value = false;
990
+ for (const m of markerInstances.values()) m.setDraggable(false);
991
+ for (const m of linePointInstances.values()) m.setDraggable(false);
992
+ }
581
993
  function closeMarkerPopup() {
994
+ disableAllDragging();
582
995
  selectedMarkerKey.value = null;
583
996
  }
997
+ function closeLinePopup() {
998
+ disableAllDragging();
999
+ selectedLineKey.value = null;
1000
+ }
1001
+ function toggleReposition() {
1002
+ if (!props.editable) return;
1003
+ repositionEnabled.value = !repositionEnabled.value;
1004
+ if (selectedMarkerKey.value) {
1005
+ const inst = markerInstances.get(selectedMarkerKey.value);
1006
+ if (inst) inst.setDraggable(repositionEnabled.value);
1007
+ }
1008
+ if (selectedLineKey.value) {
1009
+ const pts = tree.childrenOf(selectedLineKey.value).filter(
1010
+ (p) => p.meta?.geoLat !== void 0 && p.meta?.geoLng !== void 0
1011
+ );
1012
+ for (const pt of pts) {
1013
+ const inst = linePointInstances.get(pt.id);
1014
+ if (inst) inst.setDraggable(repositionEnabled.value);
1015
+ }
1016
+ }
1017
+ }
584
1018
  function deleteSelectedMarker() {
585
1019
  if (!selectedMarkerKey.value || !props.editable) return;
586
1020
  tree.deleteEntry(selectedMarkerKey.value);
587
1021
  closeMarkerPopup();
588
1022
  }
589
1023
  function openLinePopup(key, geoPos) {
1024
+ disableAllDragging();
590
1025
  selectedLineKey.value = key;
591
1026
  linePopupGeoPos.value = geoPos;
592
1027
  selectedMarkerKey.value = null;
@@ -598,9 +1033,10 @@ function openLinePopup(key, geoPos) {
598
1033
  function deleteSelectedLine() {
599
1034
  if (!selectedLineKey.value || !props.editable) return;
600
1035
  tree.deleteEntry(selectedLineKey.value);
601
- selectedLineKey.value = null;
1036
+ closeLinePopup();
602
1037
  }
603
1038
  function openMeasurePopup(key, geoPos) {
1039
+ disableAllDragging();
604
1040
  selectedMeasureKey.value = key;
605
1041
  measurePopupGeoPos.value = geoPos;
606
1042
  selectedMarkerKey.value = null;
@@ -746,15 +1182,18 @@ function syncLinePoints() {
746
1182
  el.style.background = lineColor;
747
1183
  el.addEventListener("click", (ev) => {
748
1184
  ev.stopPropagation();
749
- openNode(pt.id, pt.label);
1185
+ if ((ev.metaKey || ev.ctrlKey) && wm.floatWindowsAvailable.value) {
1186
+ openAsWindow(pt.id, pt.label);
1187
+ } else {
1188
+ openNode(pt.id, pt.label);
1189
+ }
1190
+ });
1191
+ const m = new mapboxgl.Marker({ element: el, anchor: "center", draggable: false }).setLngLat([lng, lat]).addTo(map);
1192
+ m.on("dragend", () => {
1193
+ if (!props.editable) return;
1194
+ const lngLat = m.getLngLat();
1195
+ tree.updateMeta(pt.id, { geoLng: lngLat.lng, geoLat: lngLat.lat });
750
1196
  });
751
- const m = new mapboxgl.Marker({ element: el, anchor: "center", draggable: props.editable }).setLngLat([lng, lat]).addTo(map);
752
- if (props.editable) {
753
- m.on("dragend", () => {
754
- const lngLat = m.getLngLat();
755
- tree.updateMeta(pt.id, { geoLng: lngLat.lng, geoLat: lngLat.lat });
756
- });
757
- }
758
1197
  linePointInstances.set(pt.id, m);
759
1198
  }
760
1199
  }
@@ -912,6 +1351,10 @@ function updateAllPopupPositions() {
912
1351
  }
913
1352
  }
914
1353
  function handleMapClick(e) {
1354
+ if (ctxMenuOpen.value) {
1355
+ ctxMenuOpen.value = false;
1356
+ return;
1357
+ }
915
1358
  if (followingClientId.value !== null) return;
916
1359
  const target = e.originalEvent.target;
917
1360
  if (target.closest(".collab-marker-pin") || target.closest(".collab-line-point")) return;
@@ -945,7 +1388,7 @@ function handleMapClick(e) {
945
1388
  return;
946
1389
  }
947
1390
  }
948
- selectedLineKey.value = null;
1391
+ closeLinePopup();
949
1392
  selectedMeasureKey.value = null;
950
1393
  break;
951
1394
  }
@@ -997,22 +1440,25 @@ function handleMapDblClick(e) {
997
1440
  }
998
1441
  }
999
1442
  function handleMapContextMenu(e) {
1000
- if (!map || !props.editable) return;
1443
+ if (!map) return;
1444
+ if (!props.editable) return;
1001
1445
  e.originalEvent.preventDefault();
1002
1446
  const bbox = [
1003
1447
  [e.point.x - 8, e.point.y - 8],
1004
1448
  [e.point.x + 8, e.point.y + 8]
1005
1449
  ];
1450
+ const lngLat = { lng: e.lngLat.lng, lat: e.lngLat.lat };
1451
+ const screenX = e.originalEvent.clientX;
1452
+ const screenY = e.originalEvent.clientY;
1006
1453
  const lineFeats = map.queryRenderedFeatures(bbox, {
1007
1454
  layers: ["collab-lines-layer"]
1008
1455
  });
1009
1456
  if (lineFeats.length > 0) {
1010
1457
  const id = lineFeats[0].properties?.key;
1011
1458
  if (id) {
1012
- tree.deleteEntry(id);
1013
- if (selectedLineKey.value === id) selectedLineKey.value = null;
1459
+ openCtxMenu(screenX, screenY, "line", lngLat, id);
1460
+ return;
1014
1461
  }
1015
- return;
1016
1462
  }
1017
1463
  const measureFeats = map.queryRenderedFeatures(bbox, {
1018
1464
  layers: ["measure-collab-lines-layer"]
@@ -1020,27 +1466,38 @@ function handleMapContextMenu(e) {
1020
1466
  if (measureFeats.length > 0) {
1021
1467
  const id = measureFeats[0].properties?.key;
1022
1468
  if (id) {
1023
- tree.deleteEntry(id);
1024
- if (selectedMeasureKey.value === id) selectedMeasureKey.value = null;
1469
+ openCtxMenu(screenX, screenY, "measure", lngLat, id);
1470
+ return;
1025
1471
  }
1026
- return;
1027
1472
  }
1473
+ openCtxMenu(screenX, screenY, "empty", lngLat);
1028
1474
  }
1029
1475
  function onKeyDown(e) {
1030
1476
  if (e.key === "Escape") {
1477
+ if (ctxMenuOpen.value) {
1478
+ ctxMenuOpen.value = false;
1479
+ return;
1480
+ }
1481
+ if (searchOpen.value) {
1482
+ searchOpen.value = false;
1483
+ searchQuery.value = "";
1484
+ searchResults.value = [];
1485
+ clearSearchPreview();
1486
+ return;
1487
+ }
1031
1488
  if (activeMode.value === "line") cancelDrawing();
1032
1489
  if (activeMode.value === "measure") {
1033
1490
  measurePoints.value = [];
1034
1491
  clearMeasurePreview();
1035
1492
  }
1036
1493
  closeMarkerPopup();
1037
- selectedLineKey.value = null;
1494
+ closeLinePopup();
1038
1495
  selectedMeasureKey.value = null;
1039
1496
  activeMode.value = "pan";
1040
1497
  }
1041
1498
  }
1042
1499
  function applyFollowCamera() {
1043
- const user = followingUser.value;
1500
+ const user = followingRemoteUser.value;
1044
1501
  if (!user?.camera || !map) return;
1045
1502
  if (user.camera.t <= lastAppliedFollowTime) return;
1046
1503
  lastAppliedFollowTime = user.camera.t;
@@ -1067,7 +1524,10 @@ function startLoop() {
1067
1524
  tickMeasureLabels();
1068
1525
  updateAllPopupPositions();
1069
1526
  }
1070
- if (broadcastFrame % 2 === 0 && mapReady.value) tickPresenceMarkers();
1527
+ if (broadcastFrame % 2 === 0 && mapReady.value) {
1528
+ tickPresenceMarkers();
1529
+ tickRemoteLiveLocations();
1530
+ }
1071
1531
  if (followingClientId.value === null && broadcastFrame % 4 === 0 && map)
1072
1532
  broadcastCamera();
1073
1533
  rafId = requestAnimationFrame(loop);
@@ -1077,17 +1537,134 @@ function startLoop() {
1077
1537
  function applyLabels() {
1078
1538
  if (!map?.isStyleLoaded()) return;
1079
1539
  const v = showLabels.value;
1080
- map.setConfigProperty("basemap", "showPlaceLabels", v);
1081
- map.setConfigProperty("basemap", "showPointOfInterestLabels", v);
1082
- map.setConfigProperty("basemap", "showRoadLabels", v);
1083
- map.setConfigProperty("basemap", "showTransitLabels", v);
1540
+ if (isStandardStyle.value) {
1541
+ map.setConfigProperty("basemap", "showPlaceLabels", v);
1542
+ map.setConfigProperty("basemap", "showPointOfInterestLabels", v);
1543
+ map.setConfigProperty("basemap", "showRoadLabels", v);
1544
+ map.setConfigProperty("basemap", "showTransitLabels", v);
1545
+ } else {
1546
+ for (const layer of map.getStyle()?.layers ?? []) {
1547
+ if (layer.type === "symbol") {
1548
+ try {
1549
+ map.setLayoutProperty(layer.id, "visibility", v ? "visible" : "none");
1550
+ } catch {
1551
+ }
1552
+ }
1553
+ }
1554
+ }
1555
+ }
1556
+ function apply3dBuildings() {
1557
+ if (!map?.isStyleLoaded() || !isStandardStyle.value) return;
1558
+ try {
1559
+ map.setConfigProperty("basemap", "show3dObjects", show3dBuildings.value);
1560
+ } catch {
1561
+ }
1562
+ }
1563
+ function applyTerrain() {
1564
+ if (!map?.isStyleLoaded()) return;
1565
+ try {
1566
+ if (!map.getSource("mapbox-dem")) {
1567
+ map.addSource("mapbox-dem", {
1568
+ type: "raster-dem",
1569
+ url: "mapbox://mapbox.mapbox-terrain-dem-v1",
1570
+ tileSize: 512,
1571
+ maxzoom: 14
1572
+ });
1573
+ }
1574
+ map.setTerrain(showTerrain.value ? { source: "mapbox-dem", exaggeration: 1.2 } : null);
1575
+ } catch {
1576
+ }
1577
+ }
1578
+ function applyStyleConfig() {
1579
+ if (!map?.isStyleLoaded()) return;
1580
+ if (isStandardStyle.value) {
1581
+ try {
1582
+ map.setConfigProperty("basemap", "lightPreset", getLightPreset());
1583
+ } catch {
1584
+ }
1585
+ }
1586
+ applyLabels();
1587
+ apply3dBuildings();
1084
1588
  }
1085
- watch(showLabels, applyLabels);
1589
+ watch(showLabels, () => applyLabels(), { flush: "sync" });
1590
+ watch(show3dBuildings, () => apply3dBuildings());
1591
+ watch(showTerrain, () => applyTerrain());
1592
+ watch(lightPreset, () => {
1593
+ if (map?.isStyleLoaded() && isStandardStyle.value) {
1594
+ try {
1595
+ map.setConfigProperty("basemap", "lightPreset", getLightPreset());
1596
+ } catch {
1597
+ }
1598
+ }
1599
+ });
1600
+ watch(mapStyleKey, (key) => {
1601
+ if (!map) return;
1602
+ map.setStyle(MAP_STYLE_URLS[key]);
1603
+ });
1086
1604
  watch(activeMode, (mode) => {
1087
1605
  if (!map) return;
1088
1606
  if (mode === "line") map.doubleClickZoom.disable();
1089
1607
  else map.doubleClickZoom.enable();
1090
1608
  });
1609
+ function addDataLayers() {
1610
+ if (!map?.isStyleLoaded()) return;
1611
+ const m = map;
1612
+ const ensureSource = (id) => {
1613
+ if (!m.getSource(id)) m.addSource(id, { type: "geojson", data: emptyFC() });
1614
+ };
1615
+ const ensureLayer = (layer) => {
1616
+ if (!m.getLayer(layer.id)) m.addLayer(layer);
1617
+ };
1618
+ ensureSource("collab-lines");
1619
+ ensureLayer({
1620
+ id: "collab-lines-layer",
1621
+ type: "line",
1622
+ source: "collab-lines",
1623
+ paint: { "line-color": ["get", "color"], "line-width": 4, "line-opacity": 0.85 }
1624
+ });
1625
+ ensureSource("draw-preview");
1626
+ ensureLayer({
1627
+ id: "draw-preview-layer",
1628
+ type: "line",
1629
+ source: "draw-preview",
1630
+ paint: { "line-color": myColorHex.value, "line-width": 2, "line-dasharray": [4, 3], "line-opacity": 0.7 }
1631
+ });
1632
+ ensureSource("draw-points");
1633
+ ensureLayer({
1634
+ id: "draw-points-layer",
1635
+ type: "circle",
1636
+ source: "draw-points",
1637
+ paint: { "circle-radius": 5, "circle-color": myColorHex.value, "circle-stroke-color": "white", "circle-stroke-width": 2 }
1638
+ });
1639
+ ensureSource("measure-preview-lines");
1640
+ ensureLayer({
1641
+ id: "measure-preview-lines-layer",
1642
+ type: "line",
1643
+ source: "measure-preview-lines",
1644
+ paint: { "line-color": "#facc15", "line-width": 2, "line-dasharray": [3, 2] }
1645
+ });
1646
+ ensureSource("measure-preview-points");
1647
+ ensureLayer({
1648
+ id: "measure-preview-points-layer",
1649
+ type: "circle",
1650
+ source: "measure-preview-points",
1651
+ paint: { "circle-radius": 6, "circle-color": "#facc15", "circle-stroke-color": "white", "circle-stroke-width": 2 }
1652
+ });
1653
+ ensureSource("measure-collab-lines");
1654
+ ensureLayer({
1655
+ id: "measure-collab-lines-layer",
1656
+ type: "line",
1657
+ source: "measure-collab-lines",
1658
+ paint: { "line-color": "#facc15", "line-width": 3, "line-dasharray": [3, 2], "line-opacity": 0.85 }
1659
+ });
1660
+ ensureSource("measure-collab-points");
1661
+ ensureLayer({
1662
+ id: "measure-collab-points-layer",
1663
+ type: "circle",
1664
+ source: "measure-collab-points",
1665
+ paint: { "circle-radius": 4, "circle-color": "#facc15", "circle-stroke-color": "white", "circle-stroke-width": 1.5, "circle-opacity": 0.85 }
1666
+ });
1667
+ }
1091
1668
  onMounted(async () => {
1092
1669
  try {
1093
1670
  const mod = await import("mapbox-gl");
@@ -1118,119 +1695,25 @@ onMounted(async () => {
1118
1695
  attributionControl: false
1119
1696
  });
1120
1697
  map.on("style.load", () => {
1121
- map.setConfigProperty("basemap", "lightPreset", getLightPreset());
1122
- applyLabels();
1123
- });
1124
- map.on("load", () => {
1125
1698
  try {
1126
- map.addSource("mapbox-dem", {
1127
- type: "raster-dem",
1128
- url: "mapbox://mapbox.mapbox-terrain-dem-v1",
1129
- tileSize: 512,
1130
- maxzoom: 14
1131
- });
1132
- map.setTerrain({ source: "mapbox-dem", exaggeration: 1 });
1699
+ map.setProjection("globe");
1133
1700
  } catch {
1134
1701
  }
1702
+ applyStyleConfig();
1703
+ applyTerrain();
1704
+ addDataLayers();
1705
+ if (mapReady.value) {
1706
+ syncMarkers();
1707
+ syncLineSource();
1708
+ syncLinePoints();
1709
+ syncMeasureSource();
1710
+ }
1711
+ });
1712
+ map.on("load", () => {
1135
1713
  map.addControl(
1136
1714
  new mapboxgl.AttributionControl({ compact: true }),
1137
1715
  "bottom-right"
1138
1716
  );
1139
- map.addSource("collab-lines", { type: "geojson", data: emptyFC() });
1140
- map.addLayer({
1141
- id: "collab-lines-layer",
1142
- type: "line",
1143
- source: "collab-lines",
1144
- paint: {
1145
- "line-color": ["get", "color"],
1146
- "line-width": 4,
1147
- "line-opacity": 0.85
1148
- }
1149
- });
1150
- map.addSource("draw-preview", { type: "geojson", data: emptyFC() });
1151
- map.addLayer({
1152
- id: "draw-preview-layer",
1153
- type: "line",
1154
- source: "draw-preview",
1155
- paint: {
1156
- "line-color": myColorHex.value,
1157
- "line-width": 2,
1158
- "line-dasharray": [4, 3],
1159
- "line-opacity": 0.7
1160
- }
1161
- });
1162
- map.addSource("draw-points", { type: "geojson", data: emptyFC() });
1163
- map.addLayer({
1164
- id: "draw-points-layer",
1165
- type: "circle",
1166
- source: "draw-points",
1167
- paint: {
1168
- "circle-radius": 5,
1169
- "circle-color": myColorHex.value,
1170
- "circle-stroke-color": "white",
1171
- "circle-stroke-width": 2
1172
- }
1173
- });
1174
- map.addSource("measure-preview-lines", {
1175
- type: "geojson",
1176
- data: emptyFC()
1177
- });
1178
- map.addLayer({
1179
- id: "measure-preview-lines-layer",
1180
- type: "line",
1181
- source: "measure-preview-lines",
1182
- paint: {
1183
- "line-color": "#facc15",
1184
- "line-width": 2,
1185
- "line-dasharray": [3, 2]
1186
- }
1187
- });
1188
- map.addSource("measure-preview-points", {
1189
- type: "geojson",
1190
- data: emptyFC()
1191
- });
1192
- map.addLayer({
1193
- id: "measure-preview-points-layer",
1194
- type: "circle",
1195
- source: "measure-preview-points",
1196
- paint: {
1197
- "circle-radius": 6,
1198
- "circle-color": "#facc15",
1199
- "circle-stroke-color": "white",
1200
- "circle-stroke-width": 2
1201
- }
1202
- });
1203
- map.addSource("measure-collab-lines", {
1204
- type: "geojson",
1205
- data: emptyFC()
1206
- });
1207
- map.addLayer({
1208
- id: "measure-collab-lines-layer",
1209
- type: "line",
1210
- source: "measure-collab-lines",
1211
- paint: {
1212
- "line-color": "#facc15",
1213
- "line-width": 3,
1214
- "line-dasharray": [3, 2],
1215
- "line-opacity": 0.85
1216
- }
1217
- });
1218
- map.addSource("measure-collab-points", {
1219
- type: "geojson",
1220
- data: emptyFC()
1221
- });
1222
- map.addLayer({
1223
- id: "measure-collab-points-layer",
1224
- type: "circle",
1225
- source: "measure-collab-points",
1226
- paint: {
1227
- "circle-radius": 4,
1228
- "circle-color": "#facc15",
1229
- "circle-stroke-color": "white",
1230
- "circle-stroke-width": 1.5,
1231
- "circle-opacity": 0.85
1232
- }
1233
- });
1234
1717
  mapReady.value = true;
1235
1718
  setTimeout(() => mapFadedIn.value = true, 100);
1236
1719
  map.on("moveend", () => {
@@ -1246,6 +1729,7 @@ onMounted(async () => {
1246
1729
  syncLineSource();
1247
1730
  syncLinePoints();
1248
1731
  syncMeasureSource();
1732
+ fitBoundsToContent();
1249
1733
  startLoop();
1250
1734
  broadcastCamera();
1251
1735
  });
@@ -1255,15 +1739,28 @@ onMounted(async () => {
1255
1739
  mapResizeObserver = ro;
1256
1740
  });
1257
1741
  watch(isDark, () => {
1258
- if (map?.isStyleLoaded())
1259
- map.setConfigProperty("basemap", "lightPreset", getLightPreset());
1742
+ if (map?.isStyleLoaded() && isStandardStyle.value && lightPreset.value === "auto") {
1743
+ try {
1744
+ map.setConfigProperty("basemap", "lightPreset", getLightPreset());
1745
+ } catch {
1746
+ }
1747
+ }
1260
1748
  });
1261
1749
  onUnmounted(() => {
1262
1750
  mapResizeObserver?.disconnect();
1263
1751
  mapResizeObserver = null;
1264
1752
  window.removeEventListener("keydown", onKeyDown);
1265
1753
  cancelAnimationFrame(rafId);
1266
- setLocalState({ mapCamera: void 0, mapCursor: null, mapPing: null });
1754
+ setLocalState({ mapCamera: void 0, mapCursor: null, mapPing: null, mapLiveLocation: null });
1755
+ if (geoWatchId !== null) {
1756
+ navigator.geolocation.clearWatch(geoWatchId);
1757
+ geoWatchId = null;
1758
+ }
1759
+ liveLocationMarkerInstance?.remove();
1760
+ for (const m of remoteLiveLocationMarkers.values()) m.remove();
1761
+ remoteLiveLocationMarkers.clear();
1762
+ clearSearchPreview();
1763
+ if (geoSearchTimeout) clearTimeout(geoSearchTimeout);
1267
1764
  for (const m of markerInstances.values()) m.remove();
1268
1765
  for (const m of linePointInstances.values()) m.remove();
1269
1766
  for (const p of presenceLerpMap.values()) p.marker.remove();
@@ -1282,6 +1779,67 @@ onUnmounted(() => {
1282
1779
  function userInitials(name) {
1283
1780
  return name.split(" ").map((w) => w[0] ?? "").join("").substring(0, 2).toUpperCase();
1284
1781
  }
1782
+ function applyMarkerViewerStyle(el, viewers) {
1783
+ const pin = el.querySelector(".collab-marker-pin");
1784
+ if (!pin) return;
1785
+ const existing = el.querySelector(".collab-marker-viewers");
1786
+ if (!viewers.length) {
1787
+ pin.style.outline = "";
1788
+ pin.style.outlineOffset = "";
1789
+ if (existing) existing.remove();
1790
+ return;
1791
+ }
1792
+ pin.style.outline = `4px solid ${viewers[0].color}`;
1793
+ pin.style.outlineOffset = "2px";
1794
+ let badge = existing;
1795
+ if (!badge) {
1796
+ badge = document.createElement("div");
1797
+ badge.className = "collab-marker-viewers";
1798
+ el.appendChild(badge);
1799
+ }
1800
+ badge.innerHTML = viewers.slice(0, 3).map((u) => `<span class="collab-marker-viewer-dot" title="${u.name.replace(/"/g, "&quot;")}" style="background:${u.color}"></span>`).join("");
1801
+ }
1802
+ watch(
1803
+ () => Array.from(markerInstances.entries()).map(([id]) => ({
1804
+ id,
1805
+ viewers: getDocViewers(id)
1806
+ })),
1807
+ (snapshots) => {
1808
+ for (const { id, viewers } of snapshots) {
1809
+ const inst = markerInstances.get(id);
1810
+ if (!inst) continue;
1811
+ applyMarkerViewerStyle(inst.getElement(), viewers);
1812
+ }
1813
+ },
1814
+ { deep: true }
1815
+ );
1816
+ async function openAsWindow(id, label) {
1817
+ if (wm.windows.has(id)) {
1818
+ wm.focusWindow(id);
1819
+ return;
1820
+ }
1821
+ const childProv = await childProviderRef.value?.loadChild(id);
1822
+ if (!childProv) return;
1823
+ if (!childProv.isSynced) {
1824
+ await new Promise((resolve) => {
1825
+ const done = () => {
1826
+ childProv.off("synced", done);
1827
+ resolve();
1828
+ };
1829
+ childProv.on("synced", done);
1830
+ setTimeout(resolve, 6e3);
1831
+ });
1832
+ }
1833
+ const entry = tree.entries.value.find((e) => e.id === id);
1834
+ wm.openWindow({
1835
+ id,
1836
+ title: label,
1837
+ docId: id,
1838
+ docType: entry?.type,
1839
+ provider: childProv,
1840
+ initialTab: "editor"
1841
+ });
1842
+ }
1285
1843
  defineExpose({ connectedUsers });
1286
1844
  </script>
1287
1845
 
@@ -1312,10 +1870,8 @@ defineExpose({ connectedUsers });
1312
1870
  />
1313
1871
 
1314
1872
  <!-- Toolbar (bottom-center) -->
1315
- <div
1316
- v-if="editable"
1317
- class="a-map-toolbar-bar"
1318
- >
1873
+ <div class="a-map-toolbar-bar">
1874
+ <!-- Mode tools -->
1319
1875
  <div class="toolbar-group">
1320
1876
  <UButton
1321
1877
  icon="i-lucide-hand"
@@ -1324,6 +1880,7 @@ defineExpose({ connectedUsers });
1324
1880
  @click="setMode('pan')"
1325
1881
  />
1326
1882
  <UButton
1883
+ v-if="editable"
1327
1884
  icon="i-lucide-map-pin"
1328
1885
  v-bind="toolBtn('marker')"
1329
1886
  :title="locale.addMarker"
@@ -1336,12 +1893,14 @@ defineExpose({ connectedUsers });
1336
1893
  @click="setMode('ping')"
1337
1894
  />
1338
1895
  <UButton
1896
+ v-if="editable"
1339
1897
  icon="i-lucide-route"
1340
1898
  v-bind="toolBtn('line')"
1341
1899
  :title="locale.addLine"
1342
1900
  @click="setMode('line')"
1343
1901
  />
1344
1902
  <UButton
1903
+ v-if="editable"
1345
1904
  icon="i-lucide-ruler"
1346
1905
  v-bind="toolBtn('measure')"
1347
1906
  :title="locale.addMeasure"
@@ -1349,6 +1908,7 @@ defineExpose({ connectedUsers });
1349
1908
  />
1350
1909
  </div>
1351
1910
  <div class="toolbar-divider" />
1911
+ <!-- View -->
1352
1912
  <UButton
1353
1913
  icon="i-lucide-type"
1354
1914
  size="sm"
@@ -1358,19 +1918,211 @@ defineExpose({ connectedUsers });
1358
1918
  :class="{ 'opacity-40': !showLabels }"
1359
1919
  @click="showLabels = !showLabels"
1360
1920
  />
1921
+
1922
+ <!-- Map settings -->
1923
+ <UPopover :content="{ side: 'top', align: 'center' }">
1924
+ <UButton
1925
+ icon="i-lucide-sliders-horizontal"
1926
+ size="sm"
1927
+ color="neutral"
1928
+ :variant="mapStyleKey !== 'standard' || !show3dBuildings || !showTerrain || lightPreset !== 'auto' ? 'soft' : 'ghost'"
1929
+ :title="'View settings'"
1930
+ :disabled="!editable"
1931
+ />
1932
+ <template #content>
1933
+ <div class="flex flex-col gap-3 p-3 w-60">
1934
+ <!-- Base style -->
1935
+ <div class="flex flex-col gap-1.5">
1936
+ <span class="text-[11px] font-medium text-(--ui-text-muted)">Map type</span>
1937
+ <div class="grid grid-cols-2 gap-1">
1938
+ <UButton
1939
+ v-for="opt in [
1940
+ { key: 'standard', label: 'Standard', icon: 'i-lucide-box' },
1941
+ { key: 'streets', label: 'Streets', icon: 'i-lucide-map' },
1942
+ { key: 'satellite', label: 'Satellite', icon: 'i-lucide-satellite' },
1943
+ { key: 'satellite-streets', label: 'Hybrid', icon: 'i-lucide-layers' }
1944
+ ]"
1945
+ :key="opt.key"
1946
+ :icon="opt.icon"
1947
+ :label="opt.label"
1948
+ size="xs"
1949
+ block
1950
+ :variant="mapStyleKey === opt.key ? 'soft' : 'ghost'"
1951
+ :color="mapStyleKey === opt.key ? 'primary' : 'neutral'"
1952
+ @click="mapStyleKey = opt.key"
1953
+ />
1954
+ </div>
1955
+ </div>
1956
+
1957
+ <div class="h-px bg-(--ui-border)" />
1958
+
1959
+ <div class="flex items-center justify-between">
1960
+ <span class="text-xs text-(--ui-text-muted)">{{ locale.showLabels }}</span>
1961
+ <USwitch :model-value="showLabels" size="xs" @update:model-value="showLabels = $event" />
1962
+ </div>
1963
+ <div class="flex items-center justify-between gap-2">
1964
+ <div class="flex flex-col min-w-0">
1965
+ <span class="text-xs text-(--ui-text-muted)">3D buildings</span>
1966
+ <span
1967
+ v-if="!isStandardStyle"
1968
+ class="text-[10px] text-(--ui-text-dimmed)"
1969
+ >Standard map only</span>
1970
+ </div>
1971
+ <USwitch
1972
+ :model-value="show3dBuildings"
1973
+ :disabled="!isStandardStyle"
1974
+ size="xs"
1975
+ @update:model-value="show3dBuildings = $event"
1976
+ />
1977
+ </div>
1978
+ <div class="flex items-center justify-between">
1979
+ <span class="text-xs text-(--ui-text-muted)">3D terrain</span>
1980
+ <USwitch :model-value="showTerrain" size="xs" @update:model-value="showTerrain = $event" />
1981
+ </div>
1982
+
1983
+ <div class="h-px bg-(--ui-border)" />
1984
+
1985
+ <!-- Lighting (Standard only) -->
1986
+ <div
1987
+ class="flex flex-col gap-1.5"
1988
+ :class="{ 'opacity-40 pointer-events-none': !isStandardStyle }"
1989
+ >
1990
+ <span class="text-[11px] font-medium text-(--ui-text-muted)">Lighting</span>
1991
+ <div class="flex gap-0.5">
1992
+ <UButton
1993
+ v-for="lp in ['auto', 'dawn', 'day', 'dusk', 'night']"
1994
+ :key="lp"
1995
+ size="xs"
1996
+ :label="lp === 'auto' ? 'Auto' : lp.charAt(0).toUpperCase() + lp.slice(1)"
1997
+ class="flex-1 justify-center px-0"
1998
+ :variant="lightPreset === lp ? 'soft' : 'ghost'"
1999
+ :color="lightPreset === lp ? 'primary' : 'neutral'"
2000
+ @click="lightPreset = lp"
2001
+ />
2002
+ </div>
2003
+ </div>
2004
+ </div>
2005
+ </template>
2006
+ </UPopover>
2007
+ <div class="toolbar-divider" />
2008
+ <!-- Utility tools -->
2009
+ <div class="toolbar-group">
2010
+ <!-- Live Location -->
2011
+ <UPopover
2012
+ v-model:open="liveLocationLogOpen"
2013
+ :content="{ side: 'top', align: 'center' }"
2014
+ >
2015
+ <UButton
2016
+ icon="i-lucide-locate-fixed"
2017
+ size="sm"
2018
+ :color="liveLocationActive ? 'primary' : 'neutral'"
2019
+ :variant="liveLocationActive ? 'solid' : 'ghost'"
2020
+ :title="'Live location'"
2021
+ @click="toggleLiveLocation"
2022
+ />
2023
+ <template #content>
2024
+ <div class="flex flex-col gap-2 p-2 w-64">
2025
+ <div
2026
+ v-if="liveLocationPos"
2027
+ class="text-xs text-(--ui-text-muted) font-mono"
2028
+ >
2029
+ {{ liveLocationPos.lat.toFixed(6) }}, {{ liveLocationPos.lng.toFixed(6) }}
2030
+ </div>
2031
+ <UInput
2032
+ v-model="liveLocationLogNote"
2033
+ size="sm"
2034
+ placeholder="Note for this spot…"
2035
+ autofocus
2036
+ @keydown.enter="placeLogMarker"
2037
+ />
2038
+ <div class="flex items-center justify-between">
2039
+ <UButton
2040
+ v-if="editable"
2041
+ size="xs"
2042
+ icon="i-lucide-map-pin"
2043
+ label="Log marker"
2044
+ :disabled="!liveLocationPos"
2045
+ @click="placeLogMarker"
2046
+ />
2047
+ <UButton
2048
+ size="xs"
2049
+ color="neutral"
2050
+ variant="ghost"
2051
+ label="Stop tracking"
2052
+ @click="stopLiveLocation"
2053
+ />
2054
+ </div>
2055
+ </div>
2056
+ </template>
2057
+ </UPopover>
2058
+ <!-- Search -->
2059
+ <UPopover
2060
+ v-model:open="searchOpen"
2061
+ :content="{ side: 'top', align: 'end' }"
2062
+ >
2063
+ <UButton
2064
+ icon="i-lucide-search"
2065
+ size="sm"
2066
+ :color="searchOpen ? 'primary' : 'neutral'"
2067
+ :variant="searchOpen ? 'soft' : 'ghost'"
2068
+ :title="'Search'"
2069
+ />
2070
+ <template #content>
2071
+ <div class="flex flex-col gap-2 p-2 w-72">
2072
+ <UInput
2073
+ v-model="searchQuery"
2074
+ size="sm"
2075
+ icon="i-lucide-search"
2076
+ placeholder="Search places…"
2077
+ :loading="searchSearching"
2078
+ autofocus
2079
+ class="w-full"
2080
+ />
2081
+ <div
2082
+ v-if="searchResults.length"
2083
+ class="flex flex-col max-h-48 overflow-auto"
2084
+ >
2085
+ <button
2086
+ v-for="r in searchResults"
2087
+ :key="r.label + r.lng"
2088
+ class="w-full text-left px-3 py-2 text-sm hover:bg-(--ui-bg-elevated) rounded truncate"
2089
+ @click="selectSearchResult(r)"
2090
+ >
2091
+ {{ r.label }}
2092
+ </button>
2093
+ </div>
2094
+ <div
2095
+ v-if="selectedSearchResult"
2096
+ class="flex items-center justify-between"
2097
+ >
2098
+ <span class="text-xs text-(--ui-text-muted) truncate flex-1">
2099
+ {{ selectedSearchResult.lat.toFixed(4) }}, {{ selectedSearchResult.lng.toFixed(4) }}
2100
+ </span>
2101
+ <UButton
2102
+ v-if="editable"
2103
+ size="xs"
2104
+ icon="i-lucide-map-pin"
2105
+ label="Place marker"
2106
+ @click="placeSearchMarker"
2107
+ />
2108
+ </div>
2109
+ </div>
2110
+ </template>
2111
+ </UPopover>
2112
+ </div>
1361
2113
  </div>
1362
2114
 
1363
2115
  <!-- Follow badge -->
1364
2116
  <Transition name="badge-fade">
1365
2117
  <div
1366
- v-if="followingUser"
2118
+ v-if="followingRemoteUser"
1367
2119
  class="follow-badge"
1368
2120
  >
1369
2121
  <UIcon
1370
2122
  name="i-lucide-eye"
1371
2123
  class="badge-icon"
1372
2124
  />
1373
- <span>{{ locale.following }} {{ followingUser.name }}</span>
2125
+ <span>{{ locale.following }} {{ followingRemoteUser.name }}</span>
1374
2126
  <button
1375
2127
  class="badge-close"
1376
2128
  @click="followingClientId = null"
@@ -1448,6 +2200,15 @@ defineExpose({ connectedUsers });
1448
2200
  @click="openNode(selectedMarkerKey, selectedMarker.label);
1449
2201
  closeMarkerPopup()"
1450
2202
  />
2203
+ <UButton
2204
+ v-if="editable"
2205
+ icon="i-lucide-move"
2206
+ size="xs"
2207
+ :color="repositionEnabled ? 'primary' : 'neutral'"
2208
+ :variant="repositionEnabled ? 'solid' : 'ghost'"
2209
+ :title="locale.reposition ?? 'Reposition'"
2210
+ @click="toggleReposition"
2211
+ />
1451
2212
  <UButton
1452
2213
  v-if="editable"
1453
2214
  icon="i-lucide-trash-2"
@@ -1479,6 +2240,7 @@ defineExpose({ connectedUsers });
1479
2240
  :doc-id="selectedMarkerKey"
1480
2241
  :child-provider="popupProvider"
1481
2242
  :doc-label="selectedMarker.label"
2243
+ :show-sub-pages="false"
1482
2244
  />
1483
2245
  </div>
1484
2246
  </div>
@@ -1507,7 +2269,16 @@ defineExpose({ connectedUsers });
1507
2269
  variant="ghost"
1508
2270
  :title="locale.openInPanel"
1509
2271
  @click="openNode(selectedLineKey, selectedLine.label);
1510
- selectedLineKey = null"
2272
+ closeLinePopup()"
2273
+ />
2274
+ <UButton
2275
+ v-if="editable"
2276
+ icon="i-lucide-move"
2277
+ size="xs"
2278
+ :color="repositionEnabled ? 'primary' : 'neutral'"
2279
+ :variant="repositionEnabled ? 'solid' : 'ghost'"
2280
+ :title="locale.reposition ?? 'Reposition'"
2281
+ @click="toggleReposition"
1511
2282
  />
1512
2283
  <UButton
1513
2284
  v-if="editable"
@@ -1522,7 +2293,7 @@ defineExpose({ connectedUsers });
1522
2293
  size="xs"
1523
2294
  color="neutral"
1524
2295
  variant="ghost"
1525
- @click="selectedLineKey = null"
2296
+ @click="closeLinePopup()"
1526
2297
  />
1527
2298
  </div>
1528
2299
  <div class="popup-editor-body">
@@ -1540,6 +2311,7 @@ defineExpose({ connectedUsers });
1540
2311
  :doc-id="selectedLineKey"
1541
2312
  :child-provider="popupProvider"
1542
2313
  :doc-label="selectedLine.label"
2314
+ :show-sub-pages="false"
1543
2315
  />
1544
2316
  </div>
1545
2317
  </div>
@@ -1615,8 +2387,69 @@ defineExpose({ connectedUsers });
1615
2387
  />
1616
2388
  </div>
1617
2389
  </div>
2390
+
2391
+ <!-- Icon safelist (hidden) — ensures dynamically-referenced icons ship -->
2392
+ <div
2393
+ class="sr-only"
2394
+ aria-hidden="true"
2395
+ >
2396
+ <UIcon name="i-lucide-map-pin" /><UIcon name="i-lucide-star" />
2397
+ <UIcon name="i-lucide-flag" /><UIcon name="i-lucide-home" />
2398
+ <UIcon name="i-lucide-building-2" /><UIcon name="i-lucide-coffee" />
2399
+ <UIcon name="i-lucide-utensils" /><UIcon name="i-lucide-camera" />
2400
+ <UIcon name="i-lucide-heart" /><UIcon name="i-lucide-zap" />
2401
+ <UIcon name="i-lucide-triangle-alert" /><UIcon name="i-lucide-car" />
2402
+ <UIcon name="i-lucide-plane" /><UIcon name="i-lucide-anchor" />
2403
+ <UIcon name="i-lucide-tree-pine" /><UIcon name="i-lucide-mountain" />
2404
+ <UIcon name="i-lucide-waves" /><UIcon name="i-lucide-shield" />
2405
+ <UIcon name="i-lucide-crosshair" /><UIcon name="i-lucide-circle-dot" />
2406
+ <UIcon name="i-lucide-bookmark" /><UIcon name="i-lucide-gem" />
2407
+ <UIcon name="i-lucide-radio" /><UIcon name="i-lucide-compass" />
2408
+ <UIcon name="i-lucide-locate-fixed" /><UIcon name="i-lucide-search" />
2409
+ <UIcon name="i-lucide-panel-right" /><UIcon name="i-lucide-copy" />
2410
+ <UIcon name="i-lucide-picture-in-picture-2" /><UIcon name="i-lucide-move" />
2411
+ </div>
1618
2412
  </template>
1619
2413
 
2414
+ <!-- Context menu (positioned manually since Mapbox markers are raw DOM) -->
2415
+ <Teleport to="body">
2416
+ <div
2417
+ v-if="ctxMenuOpen && editable"
2418
+ class="fixed inset-0 z-[9998]"
2419
+ @click="ctxMenuOpen = false"
2420
+ @contextmenu.prevent="ctxMenuOpen = false"
2421
+ />
2422
+ <div
2423
+ v-if="ctxMenuOpen && editable"
2424
+ class="fixed z-[9999] min-w-44 rounded-lg border border-(--ui-border) bg-(--ui-bg) p-1 shadow-lg"
2425
+ :style="{ left: ctxMenuPos.x + 'px', top: ctxMenuPos.y + 'px' }"
2426
+ >
2427
+ <template
2428
+ v-for="(group, gi) in contextMenuItems"
2429
+ :key="gi"
2430
+ >
2431
+ <div
2432
+ v-if="gi > 0"
2433
+ class="my-1 h-px bg-(--ui-border)"
2434
+ />
2435
+ <button
2436
+ v-for="item in group"
2437
+ :key="item.label"
2438
+ class="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-(--ui-bg-elevated) transition-colors"
2439
+ :class="item.color === 'error' ? 'text-(--ui-error)' : 'text-(--ui-text)'"
2440
+ @click="item.onSelect();
2441
+ ctxMenuOpen = false"
2442
+ >
2443
+ <UIcon
2444
+ :name="item.icon"
2445
+ class="size-4 shrink-0"
2446
+ />
2447
+ <span>{{ item.label }}</span>
2448
+ </button>
2449
+ </template>
2450
+ </div>
2451
+ </Teleport>
2452
+
1620
2453
  <ANodePanel
1621
2454
  :node-id="openNodeId"
1622
2455
  :node-label="openNodeLabel"
@@ -1631,5 +2464,5 @@ defineExpose({ connectedUsers });
1631
2464
  </style>
1632
2465
 
1633
2466
  <style>
1634
- .mapboxgl-map{height:100%!important;width:100%!important}.collab-marker-container{align-items:center;cursor:pointer;display:flex;flex-direction:column}.collab-marker-pin{align-items:center;border-radius:50%;display:flex;height:28px;justify-content:center;transition:transform .2s ease;width:28px;z-index:30}.collab-marker-pin:hover{transform:scale(1.15)}.collab-marker-label{background:rgba(0,0,0,.5);border-radius:3px;color:#fff;font-size:11px;font-weight:700;margin-top:3px;padding:1px 5px;pointer-events:none;text-shadow:0 1px 4px rgba(0,0,0,.7);white-space:nowrap}.collab-line-point{border:2px solid #fff;border-radius:50%;box-shadow:0 1px 4px rgba(0,0,0,.4);cursor:grab;height:10px;width:10px}.collab-line-point:hover{height:14px;width:14px}.presence-marker{align-items:center;display:flex;flex-direction:column;gap:2px;pointer-events:none}.presence-avatar{align-items:center;border-radius:50%;box-shadow:0 2px 8px rgba(0,0,0,.4);display:flex;font-size:.65rem;font-weight:700;height:1.75rem;justify-content:center;width:1.75rem}.presence-label{color:#fff;font-size:.6rem;font-weight:700;text-shadow:0 1px 4px rgba(0,0,0,.8);white-space:nowrap}.map-cursor-el{left:0;pointer-events:none;position:absolute;top:0;will-change:transform;z-index:50}.map-cursor-name{font-size:.6rem;font-weight:600;left:14px;top:8px}.map-cursor-name,.measure-label-el{border-radius:3px;color:#000;padding:1px 5px;position:absolute;white-space:nowrap}.measure-label-el{background:rgba(250,204,21,.92);box-shadow:0 1px 4px rgba(0,0,0,.3);font-size:.62rem;font-weight:700;left:0;pointer-events:none;top:0;transform:translate(-50%,calc(-100% - 5px));z-index:35}@keyframes ping-ring{0%{opacity:1;transform:scale(0)}to{opacity:0;transform:scale(3)}}.map-ping-root{height:12px;left:0;pointer-events:none;position:absolute;top:0;transform:translate(-50%,-50%);width:12px;z-index:45}.map-ping-ring{animation:ping-ring 1.5s ease-out forwards;border:3px solid var(--ping-color);border-radius:50%;inset:-16px;position:absolute}.map-ping-dot{background:var(--ping-color);border:2px solid #fff;border-radius:50%;height:12px;left:0;position:absolute;top:0;width:12px}
2467
+ .mapboxgl-map{height:100%!important;width:100%!important}.collab-marker-container{align-items:center;cursor:pointer;display:flex;flex-direction:column;position:relative}.collab-marker-pin{align-items:center;border-radius:50%;display:flex;height:28px;justify-content:center;transition:transform .2s ease;width:28px;z-index:30}.collab-marker-pin:hover{transform:scale(1.15)}.collab-marker-label{background:rgba(0,0,0,.5);border-radius:3px;color:#fff;font-size:11px;font-weight:700;margin-top:3px;padding:1px 5px;pointer-events:none;text-shadow:0 1px 4px rgba(0,0,0,.7);white-space:nowrap}.collab-marker-viewers{display:flex;gap:2px;pointer-events:none;position:absolute;right:-6px;top:-6px;z-index:35}.collab-marker-viewer-dot{box-shadow:0 1px 2px rgba(0,0,0,.4)}.collab-line-point,.collab-marker-viewer-dot{border:2px solid #fff;border-radius:50%;height:10px;width:10px}.collab-line-point{box-shadow:0 1px 4px rgba(0,0,0,.4);cursor:grab}.collab-line-point:hover{height:14px;width:14px}.presence-marker{align-items:center;display:flex;flex-direction:column;gap:2px;pointer-events:none}.presence-avatar{align-items:center;border-radius:50%;box-shadow:0 2px 8px rgba(0,0,0,.4);display:flex;font-size:.65rem;font-weight:700;height:1.75rem;justify-content:center;width:1.75rem}.presence-label{color:#fff;font-size:.6rem;font-weight:700;text-shadow:0 1px 4px rgba(0,0,0,.8);white-space:nowrap}.map-cursor-el{left:0;pointer-events:none;position:absolute;top:0;will-change:transform;z-index:50}.map-cursor-name{font-size:.6rem;font-weight:600;left:14px;top:8px}.map-cursor-name,.measure-label-el{border-radius:3px;color:#000;padding:1px 5px;position:absolute;white-space:nowrap}.measure-label-el{background:rgba(250,204,21,.92);box-shadow:0 1px 4px rgba(0,0,0,.3);font-size:.62rem;font-weight:700;left:0;pointer-events:none;top:0;transform:translate(-50%,calc(-100% - 5px));z-index:35}@keyframes ping-ring{0%{opacity:1;transform:scale(0)}to{opacity:0;transform:scale(3)}}.map-ping-root{height:12px;left:0;pointer-events:none;position:absolute;top:0;transform:translate(-50%,-50%);width:12px;z-index:45}.map-ping-ring{animation:ping-ring 1.5s ease-out forwards;border:3px solid var(--ping-color);border-radius:50%;inset:-16px;position:absolute}.map-ping-dot{background:var(--ping-color);border:2px solid #fff;border-radius:50%;height:12px;left:0;position:absolute;top:0;width:12px}@keyframes live-loc-pulse{0%{opacity:.6;transform:scale(1)}to{opacity:0;transform:scale(3)}}.live-location-dot{height:18px;pointer-events:none;position:relative;width:18px}.live-location-core{border:2.5px solid #fff;border-radius:50%;box-shadow:0 1px 6px rgba(0,0,0,.35);transform:translate(-50%,-50%);z-index:2}.live-location-core,.live-location-pulse{background:var(--ll-color,#3b82f6);height:14px;left:50%;position:absolute;top:50%;width:14px}.live-location-pulse{animation:live-loc-pulse 2s ease-out infinite;border-radius:50%;margin-left:-7px;margin-top:-7px;z-index:1}
1635
2468
  </style>