@collabdt/core 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/core/components/ui/Comments/Comment.d.ts +3 -1
  2. package/dist/core/components/ui/Comments/Comment.d.ts.map +1 -1
  3. package/dist/core/components/ui/Comments/Comment.js +3 -1
  4. package/dist/core/components/ui/Comments/Comment.js.map +1 -1
  5. package/dist/core/components/ui/Sensors/Sensor.d.ts +3 -1
  6. package/dist/core/components/ui/Sensors/Sensor.d.ts.map +1 -1
  7. package/dist/core/components/ui/Sensors/Sensor.js +3 -1
  8. package/dist/core/components/ui/Sensors/Sensor.js.map +1 -1
  9. package/dist/core/components/viewers/map/MapViewer.d.ts.map +1 -1
  10. package/dist/core/components/viewers/map/MapViewer.js +31 -3
  11. package/dist/core/components/viewers/map/MapViewer.js.map +1 -1
  12. package/dist/core/components/viewers/map/datasets/src/useOrganizationalDatasets.js +1 -1
  13. package/dist/core/components/viewers/map/datasets/src/useOrganizationalDatasets.js.map +1 -1
  14. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/index.d.ts +2 -1
  15. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/index.d.ts.map +1 -1
  16. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/index.js +4 -1
  17. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/index.js.map +1 -1
  18. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.d.ts +2 -1
  19. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.d.ts.map +1 -1
  20. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.js +3 -1
  21. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/DatabaseBuildingPopover/index.js.map +1 -1
  22. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.d.ts +2 -1
  23. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.d.ts.map +1 -1
  24. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.js +116 -112
  25. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/NonDatabaseBuildingPopover.js.map +1 -1
  26. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.d.ts +2 -1
  27. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.d.ts.map +1 -1
  28. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.js +52 -48
  29. package/dist/core/components/viewers/map/src/MapFeaturePopoverMenu/src/OpenDataFeaturePopover.js.map +1 -1
  30. package/dist/core/components/viewers/map/src/MapLayers/index.d.ts.map +1 -1
  31. package/dist/core/components/viewers/map/src/MapLayers/index.js +3 -1
  32. package/dist/core/components/viewers/map/src/MapLayers/index.js.map +1 -1
  33. package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.d.ts.map +1 -1
  34. package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js +2 -2
  35. package/dist/core/components/viewers/map/src/MapLayers/src/BimLayer/index.js.map +1 -1
  36. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.d.ts.map +1 -1
  37. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js +92 -76
  38. package/dist/core/components/viewers/map/src/MapLayers/src/BuildingLayers/index.js.map +1 -1
  39. package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.d.ts.map +1 -1
  40. package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.js +104 -109
  41. package/dist/core/components/viewers/map/src/MapLayers/src/CommentLayer/index.js.map +1 -1
  42. package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.d.ts +1 -0
  43. package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.d.ts.map +1 -1
  44. package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js +13 -19
  45. package/dist/core/components/viewers/map/src/MapLayers/src/CountryLayer/index.js.map +1 -1
  46. package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/utils/CustomModelLayer.d.ts.map +1 -1
  47. package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/utils/CustomModelLayer.js +2 -2
  48. package/dist/core/components/viewers/map/src/MapLayers/src/FileLayer/utils/CustomModelLayer.js.map +1 -1
  49. package/dist/core/components/viewers/map/src/MapLayers/src/MapPopupStack.d.ts +3 -0
  50. package/dist/core/components/viewers/map/src/MapLayers/src/MapPopupStack.d.ts.map +1 -0
  51. package/dist/core/components/viewers/map/src/MapLayers/src/MapPopupStack.js +88 -0
  52. package/dist/core/components/viewers/map/src/MapLayers/src/MapPopupStack.js.map +1 -0
  53. package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.d.ts.map +1 -1
  54. package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js +79 -99
  55. package/dist/core/components/viewers/map/src/MapLayers/src/OpenDataLayer/src/index.js.map +1 -1
  56. package/dist/core/components/viewers/map/src/MapLayers/src/PlaceOnMap.js.map +1 -1
  57. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.d.ts.map +1 -1
  58. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js +125 -121
  59. package/dist/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.js.map +1 -1
  60. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.d.ts.map +1 -1
  61. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.js +67 -35
  62. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.js.map +1 -1
  63. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/{SiteContextMenu.d.ts → SiteMenu.d.ts} +4 -5
  64. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteMenu.d.ts.map +1 -0
  65. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/{SiteContextMenu.js → SiteMenu.js} +8 -9
  66. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteMenu.js.map +1 -0
  67. package/dist/core/components/viewers/map/src/MapLayers/src/clusterPopupEntry.d.ts +23 -0
  68. package/dist/core/components/viewers/map/src/MapLayers/src/clusterPopupEntry.d.ts.map +1 -0
  69. package/dist/core/components/viewers/map/src/MapLayers/src/clusterPopupEntry.js +88 -0
  70. package/dist/core/components/viewers/map/src/MapLayers/src/clusterPopupEntry.js.map +1 -0
  71. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/BuildingVisibility.d.ts +3 -0
  72. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/BuildingVisibility.d.ts.map +1 -0
  73. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/BuildingVisibility.js +28 -0
  74. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/BuildingVisibility.js.map +1 -0
  75. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/MapCustomization.d.ts.map +1 -1
  76. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/MapCustomization.js +3 -1
  77. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/src/MapCustomization.js.map +1 -1
  78. package/dist/core/components/viewers/map/src/SimpleMap.js +1 -1
  79. package/dist/core/components/viewers/map/src/SimpleMap.js.map +1 -1
  80. package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/FileAdder.js +1 -1
  81. package/dist/core/components/viewers/map/src/tools/AddTools/AddFile/FileAdder.js.map +1 -1
  82. package/dist/core/components/viewers/map/src/tools/AddTools/AddSite/SiteAdder.d.ts.map +1 -1
  83. package/dist/core/components/viewers/map/src/tools/AddTools/AddSite/SiteAdder.js.map +1 -1
  84. package/dist/core/components/viewers/map/src/tools/measureMapTool.d.ts.map +1 -1
  85. package/dist/core/components/viewers/map/src/tools/measureMapTool.js +1 -1
  86. package/dist/core/components/viewers/map/src/tools/measureMapTool.js.map +1 -1
  87. package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.d.ts +12 -5
  88. package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.d.ts.map +1 -1
  89. package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.js +46 -12
  90. package/dist/core/components/viewers/map/utils/MapEventManager/MapClickManager.js.map +1 -1
  91. package/dist/core/components/viewers/map/utils/MapEventManager/MapHoverManager.d.ts +1 -1
  92. package/dist/core/components/viewers/map/utils/MapEventManager/MapHoverManager.d.ts.map +1 -1
  93. package/dist/core/components/viewers/map/utils/MapEventManager/MapHoverManager.js +1 -1
  94. package/dist/core/components/viewers/map/utils/MapEventManager/MapHoverManager.js.map +1 -1
  95. package/dist/core/components/viewers/map/utils/getOsmIdFromMartin.d.ts +1 -1
  96. package/dist/core/components/viewers/map/utils/getOsmIdFromMartin.d.ts.map +1 -1
  97. package/dist/core/components/viewers/map/utils/getOsmIdFromMartin.js.map +1 -1
  98. package/dist/core/components/viewers/map/utils/mapStyleSpec.d.ts +4 -0
  99. package/dist/core/components/viewers/map/utils/mapStyleSpec.d.ts.map +1 -1
  100. package/dist/core/components/viewers/map/utils/mapStyleSpec.js +3 -1
  101. package/dist/core/components/viewers/map/utils/mapStyleSpec.js.map +1 -1
  102. package/dist/core/components/viewers/map/utils/modelMatrix.d.ts +8 -0
  103. package/dist/core/components/viewers/map/utils/modelMatrix.d.ts.map +1 -0
  104. package/dist/core/components/viewers/map/utils/modelMatrix.js +13 -0
  105. package/dist/core/components/viewers/map/utils/modelMatrix.js.map +1 -0
  106. package/dist/core/components/viewers/map/utils/validateBounds.d.ts +5 -10
  107. package/dist/core/components/viewers/map/utils/validateBounds.d.ts.map +1 -1
  108. package/dist/core/components/viewers/map/utils/validateBounds.js +5 -6
  109. package/dist/core/components/viewers/map/utils/validateBounds.js.map +1 -1
  110. package/dist/core/i18n/messages/en.json +15 -4
  111. package/dist/core/i18n/messages/es.json +15 -4
  112. package/dist/core/i18n/messages/fr.json +15 -4
  113. package/dist/core/store/Map/context.d.ts.map +1 -1
  114. package/dist/core/store/Map/context.js +3 -1
  115. package/dist/core/store/Map/context.js.map +1 -1
  116. package/dist/core/store/Map/reducer.d.ts +10 -1
  117. package/dist/core/store/Map/reducer.d.ts.map +1 -1
  118. package/dist/core/store/Map/reducer.js +20 -0
  119. package/dist/core/store/Map/reducer.js.map +1 -1
  120. package/dist/core/types/map.d.ts +17 -1
  121. package/dist/core/types/map.d.ts.map +1 -1
  122. package/package.json +5 -5
  123. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteContextMenu.d.ts.map +0 -1
  124. package/dist/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteContextMenu.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useSession } from 'next-auth/react'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\nimport { Source, Layer, Popup, Marker } from 'react-map-gl/maplibre'\nimport { toast } from 'sonner'\n\nimport { useSensor, useSensors } from '../../../../../../../hooks/sensors/sensors'\nimport { useSensorTypes } from '../../../../../../../hooks/sensorTypes/sensorTypes'\nimport { useUsers } from '../../../../../../../hooks/users/users'\nimport { AppConfigContext, MapContext, MenusContext } from '../../../../../../../store'\nimport { ViewerNames, type Sensor as ISensor} from '../../../../../../../types/dbTypes'\nimport { withAlpha } from '../../../../../../../utils/colourUtils'\nimport { HIGHLIGHT_COLOR, markerOcclusionProps } from '../../../../../../../utils/markerUtils'\nimport Sensor from '../../../../../../ui/Sensors/Sensor'\nimport { observedDomain, resolveDomain, resolveRamp } from '../../../../../../ui/Sensors/sensorColour'\nimport { SensorDetailDialog } from '../../../../../../ui/Sensors/SensorDetailDialog'\nimport { SensorInput } from '../../../../../../ui/Sensors/SensorInput'\nimport { valueColoursBySensor } from '../../../../../../ui/Sensors/sensorValueColours'\nimport { activeSensorTypeId, visibleSensors } from '../../../../../../ui/Sensors/sensorVisibility'\nimport { useSensorSeriesMulti } from '../../../../../../ui/Sensors/useSensorSeriesMulti'\nimport { extractCoordinatesFromFeature } from '../../../../utils/extractCoordinates'\nimport { MapLayerClickPriority } from '../../../../utils/MapEventManager/MapClickManager'\nimport { CLUSTER_COUNT_COLOUR, createClusterLayer, createClusterCountLayer, createUnclusteredPointLayer } from '../mapLayersUtils'\n\nimport { SENSOR_CLUSTER_PROPERTIES, sensorClusterColour } from './sensorClusterColour'\n\nimport type { SensorType} from '../../../../../../../types/dbTypes';\nimport type { ClickCallback } from '../../../../utils/MapEventManager/MapClickManager';\nimport type { MapGeoJSONFeature, MapLayerMouseEvent } from 'maplibre-gl'\n\nconst SensorIconMarker = ({ feature, isHighlighted, isFocused, haloColour, onMouseEnter, onMouseLeave, sensorTypes }: { feature: MapGeoJSONFeature; isHighlighted?: boolean; isFocused?: boolean; haloColour?: string; onMouseEnter?: () => void; onMouseLeave?: () => void; sensorTypes: SensorType[] }) => {\n\n const coords = extractCoordinatesFromFeature(feature)\n if (!coords) return null\n\n const sensorType = sensorTypes.find(t => t.id === feature.properties?.typeId)\n const icon = sensorType?.icon || 'Radio'\n const SensorIcon = LR[icon] || LR.Radio\n\n // The border carries the sensor's current value when there is one, so selection moves to\n // border width and scale. Ring widths mirror the BIM marker's 2/3/4px tiers.\n const borderWidth = isFocused ? 4 : isHighlighted ? 3 : 2\n const borderColour = haloColour ?? (isHighlighted || isFocused ? HIGHLIGHT_COLOR : 'white')\n const glowColour = haloColour ? withAlpha(haloColour, 0.55) : 'rgba(115, 206, 226, 0.5)'\n const scale = isFocused ? 1.25 : isHighlighted ? 1.2 : 1\n\n return (\n <Marker key={String(feature.properties?.id ?? `${coords.lng},${coords.lat}`)} longitude={coords.lng} latitude={coords.lat} anchor=\"center\" {...markerOcclusionProps}>\n <div\n style={{\n width: '36px',\n height: '36px',\n borderRadius: '50%',\n border: `${borderWidth}px solid ${borderColour}`,\n backgroundColor: 'black',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n boxShadow: haloColour || isHighlighted || isFocused\n ? `0 0 ${isFocused ? 16 : 12}px ${glowColour}`\n : 'none',\n transition: 'all 0.2s ease-in-out',\n transform: `scale(${scale})`,\n }}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n <SensorIcon style={{ width: '20px', height: '20px', color: 'hsl(var(--primary-foreground))' }} />\n </div>\n </Marker>\n )\n}\n\nexport const SensorLayers = () => {\n const [hoveredSensorId, setHoveredSensorId] = React.useState<number | null>(null)\n const clusterCountLayer = createClusterCountLayer('sensors')\n const unclusteredPointLayer = createUnclusteredPointLayer('sensors')\n\n // global map state\n\n const t = useTranslations('SensorLayers')\n const tSensors = useTranslations('SensorsSection')\n\n const { state: mapState } = React.useContext(MapContext)\n const { map, mapClickManager } = mapState.map\n const { sensors } = useSensors()\n const { users } = useUsers()\n const user = useSession().data?.user\n\n const [popupInfo, setPopUpInfo] = React.useState<Partial<ISensor & { sensorType: SensorType }> | null>(null)\n const { deleteSensor, updateSensor } = useSensor(popupInfo?.id ?? null)\n const { state: menusState, dispatch: menusDispatch } = React.useContext(MenusContext)\n const { visibleSensorTypes, visibleSensorTags, currentSensorId, focusedSensorId, sensorLegendTypeId } = menusState.menus\n const typesVisible = visibleSensorTypes?.[ViewerNames.map] || []\n const tagsVisible = visibleSensorTags?.[ViewerNames.map] || []\n\n const {sensorTypes} = useSensorTypes()\n\n const { state: appConfigState } = React.useContext(AppConfigContext)\n const timeZone = appConfigState.appConfig.displayTimeZone\n const [detailSensor, setDetailSensor] = React.useState<ISensor | null>(null)\n const [editSensor, setEditSensor] = React.useState<ISensor | null>(null)\n\n const eligibleSensors: Array<ISensor & { authorName: string } & { sensorType: SensorType }> = visibleSensors(sensors, {\n viewer: ViewerNames.map,\n visibleTypeIds: typesVisible,\n visibleTags: tagsVisible,\n })\n .map((sensor) => {\n const user = users.find(u => u.id === sensor.authorId)\n const sensorType = sensorTypes.find(t => t.id === sensor.typeId)\n return {\n ...sensor,\n authorName: user?.name ?? 'Unknown User',\n sensorType,\n }\n })\n\n // Close popup if the sensor was deleted\n React.useEffect(() => {\n if (popupInfo && !sensors.find((s) => s.id === popupInfo.id)) {\n setPopUpInfo(null)\n }\n }, [sensors, popupInfo])\n\n // Every sensor sharing the active type gets a halo coloured by its own current value, readable\n // against the SensorLegend card. Only that one type is polled. Resolved through the same\n // helper the legend uses, so pinning a type in the legend dropdown moves the halos with it.\n const haloTypeId = activeSensorTypeId(eligibleSensors, {\n legendTypeId: sensorLegendTypeId?.[ViewerNames.map],\n activeSensorId: focusedSensorId,\n })\n const haloSensors = haloTypeId == null\n ? []\n : eligibleSensors.filter(s => s.typeId === haloTypeId)\n const { seriesById } = useSensorSeriesMulti(haloSensors, { enabled: haloSensors.length > 0 })\n\n const haloIdsKey = haloSensors.map(s => s.id).join(',')\n const readings = React.useMemo(\n () => valueColoursBySensor(haloSensors, sensorTypes, seriesById),\n [seriesById, sensorTypes, haloIdsKey],\n )\n\n // Cluster bubbles average the readings they hide, on the same ramp and domain the individual\n // halos use, so zooming out does not change what a colour means.\n const haloType = haloTypeId == null ? undefined : sensorTypes.find(t => t.id === haloTypeId)\n const haloRamp = haloType ? resolveRamp(haloType) : null\n const haloDomain = resolveDomain(\n haloType,\n observedDomain(haloSensors.flatMap(s => seriesById.get(s.id)?.points ?? [])),\n )\n const clusterLayer = createClusterLayer(\n 'sensors',\n sensorClusterColour(haloRamp, haloDomain, CLUSTER_COUNT_COLOUR),\n )\n\n const geojsonSensorData = React.useMemo(() => {\n const convertDataToGeojson = (sensorData: typeof eligibleSensors): GeoJSON.FeatureCollection<GeoJSON.Point, { [key: string]: any }> => {\n const sensorFeatures: GeoJSON.Feature<GeoJSON.Point, { [key: string]: any }>[] = sensorData\n .map((sensor) => {\n const { longitude, latitude, id, name, typeId, sensorType, data, dataFormat, updateFrequency, createdAt, authorId, organizationId, visible, url, authorName } = sensor\n\n return {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: [longitude, latitude],\n },\n properties: {\n id: Number(id),\n organizationId,\n visible,\n longitude,\n latitude,\n authorId: Number(authorId),\n authorName,\n name,\n typeId: Number(typeId),\n typeIcon: sensorType?.icon,\n data,\n dataFormat,\n updateFrequency,\n url,\n createdAt,\n viewer: ViewerNames.map,\n // Only present for sensors of the active type that are actually reporting. The\n // cluster accumulators count exactly these, so the average is over real readings.\n ...(readings.has(Number(id)) ? { value: readings.get(Number(id))?.value } : {}),\n },\n }\n })\n\n\n\n const sensorFC: GeoJSON.FeatureCollection<GeoJSON.Point, { [key: string]: any }> = {\n type: 'FeatureCollection',\n features: sensorFeatures,\n }\n return sensorFC\n }\n return convertDataToGeojson(eligibleSensors)\n }, [eligibleSensors, readings])\n\n // event listeners for sensor unclustered points\n React.useEffect(() => {\n if (!map) return\n const showSensorPopUp: ClickCallback = (e: MapLayerMouseEvent, features: MapGeoJSONFeature[]) => {\n const feature = features?.[0]\n\n if (!feature || feature.properties.point_count) return\n\n if (feature.geometry.type !== 'Point') return\n const [longitude, latitude] = feature.geometry.coordinates\n const { id, authorId, name, typeId, data, dataFormat, updateFrequency, createdAt, url } = feature.properties\n // Focus on click so the legend and the sibling halos follow the sensor just opened.\n menusDispatch({ type: 'SET_FOCUSED_SENSOR_ID', payload: { sensorId: Number(id) } })\n setPopUpInfo({\n id: Number(id),\n authorId: Number(authorId),\n organizationId: feature.properties?.organizationId,\n visible: feature.properties?.visible,\n longitude,\n latitude,\n name,\n typeId: Number(typeId),\n data,\n dataFormat,\n updateFrequency,\n url,\n createdAt,\n viewer: ViewerNames.map,\n })\n }\n\n const mouseEnterChangeCursor = () => {\n map.getCanvas().style.cursor = 'pointer'\n }\n const mouseLeaveChangeCursor = () => {\n map.getCanvas().style.cursor = ''\n }\n\n // event listener for clicking on single point to show sensor, hover to change cursor\n mapClickManager.register('sensors-unclustered-points', MapLayerClickPriority.CommentLayersClickPriority, showSensorPopUp)\n\n map.on('mouseenter', 'sensors-unclustered-points', mouseEnterChangeCursor)\n map.on('mouseleave', 'sensors-unclustered-points', mouseLeaveChangeCursor)\n return () => {\n mapClickManager.unregister('sensors-unclustered-points')\n map.off('mouseenter', 'sensors-unclustered-points', mouseEnterChangeCursor)\n map.off('mouseleave', 'sensors-unclustered-points', mouseLeaveChangeCursor)\n }\n }, [map, mapClickManager, menusDispatch])\n\n const handleRemoveSensor = () => {\n toast.success(t('sensorDeleted'))\n void deleteSensor()\n setPopUpInfo(null)\n }\n\n // event listeners for clustered points\n React.useEffect(() => {\n if (!map) return\n\n const zoomInToDecluster = (e: MapLayerMouseEvent) => {\n const feature = e.features?.[0] // only proceed if this is actually a cluster\n if (!feature || !feature.properties.cluster_id) return\n\n const clusterId = feature.properties.cluster_id as number\n\n // Check if geometry has coordinates (not a GeometryCollection)\n if (!('coordinates' in feature.geometry)) return\n const [lng, lat] = feature.geometry.coordinates as [number, number]\n\n const source = map.getSource('sensors') as any\n source.getClusterExpansionZoom(clusterId).then(\n (zoom: number) => {\n map.easeTo({ center: [lng, lat], zoom })\n },\n )\n .catch((error) => {\n console.error(error)\n })\n }\n\n const mouseEnterChangeCursor = () => { map.getCanvas().style.cursor = 'pointer' }\n const mouseLeaveChangeCursor = () => { map.getCanvas().style.cursor = '' }\n\n // event listener for clicking on single point to zoom in and decluster, hover to change cursor\n map.on('click', 'sensors-clusters', zoomInToDecluster)\n map.on('mouseenter', 'sensors-clusters', mouseEnterChangeCursor)\n map.on('mouseleave', 'sensors-clusters', mouseLeaveChangeCursor)\n return () => {\n map.off('click', 'sensors-clusters', zoomInToDecluster)\n map.off('mouseenter', 'sensors-clusters', mouseEnterChangeCursor)\n map.off('mouseleave', 'sensors-clusters', mouseLeaveChangeCursor)\n }\n }, [map])\n\n const renderPopup = () => {\n if (!popupInfo) return null\n const sensorType = sensorTypes.find(t => t.id === popupInfo.typeId)\n const liveSensor = sensors.find(s => s.id === popupInfo.id)\n const dataUrl = popupInfo.url || popupInfo.data || ''\n\n return (\n <Popup\n className=\"noBorderPopup\"\n longitude={popupInfo.longitude}\n latitude={popupInfo.latitude}\n closeOnClick={false}\n closeButton={false}\n onClose={() => setPopUpInfo(null)}\n anchor=\"bottom\"\n style={{ height: '50px', border: 'none', boxShadow: 'none' }}\n offset={[0, 10]}\n >\n <Sensor\n sensorName={popupInfo.name || ''}\n sensorType={sensorType}\n sensorId={popupInfo.id}\n tags={liveSensor?.tags ?? []}\n onAddTag={async (tag) => { await updateSensor({ tags: [...(liveSensor?.tags ?? []), tag] }) }}\n onDeleteTag={async (tag) => { await updateSensor({ tags: (liveSensor?.tags ?? []).filter(t => t !== tag) }) }}\n tagsTranslations={{\n addTag: tSensors('addTag'),\n removeTag: tSensors('removeTag'),\n cancel: tSensors('cancel'),\n newTagPlaceholder: tSensors('newTagPlaceholder'),\n }}\n dataUrl={dataUrl}\n dataFormat={popupInfo.dataFormat}\n updateFrequency={popupInfo.updateFrequency}\n buildingId={popupInfo.buildingId}\n createdAt={popupInfo.createdAt}\n onRemove={user.id === String(popupInfo.authorId) ? handleRemoveSensor : null}\n onClose={() => setPopUpInfo(null)}\n onExpand={() => { if (liveSensor) setDetailSensor(liveSensor) }}\n onEdit={user.id === String(popupInfo.authorId) && liveSensor ? () => setEditSensor(liveSensor) : undefined}\n showActions\n focused={focusedSensorId === popupInfo.id}\n haloColour={popupInfo.id == null ? undefined : readings.get(popupInfo.id)?.colour}\n onSelect={() => {\n if (popupInfo.id != null) {\n menusDispatch({ type: 'SET_FOCUSED_SENSOR_ID', payload: { sensorId: popupInfo.id } })\n }\n }}\n timeZone={timeZone}\n size=\"sm\"\n />\n {/* inline styles to override MapLibre's Pop up CSS */}\n <style>\n {`\n .noBorderPopup .maplibregl-popup-content {\n border: none !important;\n box-shadow: none !important;\n background: transparent !important;\n }\n .noBorderPopup .maplibregl-popup-tip {\n display: none !important;\n }\n `}\n </style>\n </Popup>\n )\n }\n\n // Track unclustered sensors to display icons\n const [unclusteredFeatures, setUnclusteredFeatures] = React.useState<MapGeoJSONFeature[]>([])\n\n React.useEffect(() => {\n if (!map) return\n\n const updateUnclusteredFeatures = () => {\n const allFeatures = map.querySourceFeatures('sensors')\n const unclusteredOnly = allFeatures.filter(\n (f) => !f.properties?.cluster && !f.properties?.point_count\n )\n // Deduplicate by id\n const uniqueFeatures = new Map()\n unclusteredOnly.forEach((f) => uniqueFeatures.set(f.properties.id, f))\n setUnclusteredFeatures(Array.from(uniqueFeatures.values()))\n }\n\n const onSourceData = (e: any) => {\n if (e?.sourceId === 'sensors') updateUnclusteredFeatures()\n }\n\n map.on('sourcedata', onSourceData)\n map.on('moveend', updateUnclusteredFeatures)\n map.on('zoomend', updateUnclusteredFeatures)\n\n updateUnclusteredFeatures()\n\n return () => {\n map.off('sourcedata', onSourceData)\n map.off('moveend', updateUnclusteredFeatures)\n map.off('zoomend', updateUnclusteredFeatures)\n }\n }, [map])\n\n return (\n <>\n {detailSensor && (\n <SensorDetailDialog\n open={!!detailSensor}\n onOpenChange={(o) => !o && setDetailSensor(null)}\n sensor={detailSensor}\n sensorType={sensorTypes.find(t => t.id === detailSensor.typeId)}\n />\n )}\n {editSensor && (\n <SensorInput\n viewer={ViewerNames.map}\n layout=\"dialog\"\n isOpen={!!editSensor}\n editSensor={editSensor ?? undefined}\n onCancel={() => setEditSensor(null)}\n onSaved={() => setEditSensor(null)}\n />\n )}\n {(typesVisible.length > 0 || tagsVisible.length > 0) &&\n <Source\n id=\"sensors\"\n type=\"geojson\"\n data={geojsonSensorData}\n cluster={true}\n clusterMaxZoom={14}\n clusterRadius={40}\n clusterProperties={SENSOR_CLUSTER_PROPERTIES}\n >\n <Layer {...clusterLayer} />\n <Layer {...clusterCountLayer} />\n <Layer {...unclusteredPointLayer} />\n\n {renderPopup()}\n {unclusteredFeatures\n .filter((feature) => feature.properties?.id !== popupInfo?.id)\n .map((feature) => (\n <SensorIconMarker\n key={String(feature.properties?.id)}\n feature={feature}\n isHighlighted={currentSensorId === feature.properties?.id || hoveredSensorId === feature.properties?.id}\n isFocused={focusedSensorId === feature.properties?.id}\n haloColour={readings.get(Number(feature.properties?.id))?.colour}\n onMouseEnter={() => setHoveredSensorId(feature.properties?.id)}\n onMouseLeave={() => setHoveredSensorId(null)}\n sensorTypes={sensorTypes}\n />\n ))}\n </Source>}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyEQ,SA8UJ,UA9UI,KA8OF,YA9OE;AApER,YAAY,QAAQ;AACpB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,QAAQ,OAAO,OAAO,cAAc;AAC7C,SAAS,aAAa;AAEtB,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB,YAAY,oBAAoB;AAC3D,SAAS,mBAA0C;AACnD,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB,4BAA4B;AACtD,OAAO,YAAY;AACnB,SAAS,gBAAgB,eAAe,mBAAmB;AAC3D,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB,sBAAsB;AACnD,SAAS,4BAA4B;AACrC,SAAS,qCAAqC;AAC9C,SAAS,6BAA6B;AACtC,SAAS,sBAAsB,oBAAoB,yBAAyB,mCAAmC;AAE/G,SAAS,2BAA2B,2BAA2B;AAM/D,MAAM,mBAAmB,CAAC,EAAE,SAAS,eAAe,WAAW,YAAY,cAAc,cAAc,YAAY,MAA0L;AApC7S;AAsCE,QAAM,SAAS,8BAA8B,OAAO;AACpD,MAAI,CAAC,OAAQ,QAAO;AAEpB,QAAM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AAAA,gBACnD,aAAY,cAAS,IAAI,QAAO,aAAQ,eAAR,mBAAoB,EAAE,CAAC,MAA3C,mBAA8C;AAAA,gBAC1D,cAAc,MAAG;AAlc7B,sBAAAH;AAkcgC,6CAAmBA,MAAA,QAAQ,eAAR,gBAAAA,IAAoB,EAAE;AAAA;AAAA,gBAC7D,cAAc,MAAM,mBAAmB,IAAI;AAAA,gBAC3C;AAAA;AAAA,cAPK,QAAOA,MAAA,QAAQ,eAAR,gBAAAA,IAAoB,EAAE;AAAA,YAQpC;AAAA,WACD;AAAA;AAAA;AAAA,IACL;AAAA,KACA;AAEJ;","names":["_a","user","t","_b"]}
1
+ {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/SensorsLayer/index.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useSession } from 'next-auth/react'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\nimport { Source, Layer, Marker } from 'react-map-gl/maplibre'\nimport { toast } from 'sonner'\n\nimport { useSensor, useSensors } from '../../../../../../../hooks/sensors/sensors'\nimport { useSensorTypes } from '../../../../../../../hooks/sensorTypes/sensorTypes'\nimport { useUsers } from '../../../../../../../hooks/users/users'\nimport { AppConfigContext, MapContext, MenusContext } from '../../../../../../../store'\nimport { ViewerNames, type Sensor as ISensor} from '../../../../../../../types/dbTypes'\nimport { withAlpha } from '../../../../../../../utils/colourUtils'\nimport { HIGHLIGHT_COLOR, markerOcclusionProps } from '../../../../../../../utils/markerUtils'\nimport Sensor from '../../../../../../ui/Sensors/Sensor'\nimport { observedDomain, resolveDomain, resolveRamp } from '../../../../../../ui/Sensors/sensorColour'\nimport { SensorDetailDialog } from '../../../../../../ui/Sensors/SensorDetailDialog'\nimport { SensorInput } from '../../../../../../ui/Sensors/SensorInput'\nimport { valueColoursBySensor } from '../../../../../../ui/Sensors/sensorValueColours'\nimport { activeSensorTypeId, visibleSensors } from '../../../../../../ui/Sensors/sensorVisibility'\nimport { useSensorSeriesMulti } from '../../../../../../ui/Sensors/useSensorSeriesMulti'\nimport { extractCoordinatesFromFeature } from '../../../../utils/extractCoordinates'\nimport { MapLayerClickPriority } from '../../../../utils/MapEventManager/MapClickManager'\nimport { buildClusterEntry, clusterSpecFromFeature } from '../clusterPopupEntry'\nimport { CLUSTER_COUNT_COLOUR, createClusterLayer, createClusterCountLayer, createUnclusteredPointLayer } from '../mapLayersUtils'\n\nimport { SENSOR_CLUSTER_PROPERTIES, sensorClusterColour } from './sensorClusterColour'\n\nconst SENSOR_POINTS_LAYER_ID = 'sensors-unclustered-points'\nconst SENSOR_CLUSTER_LAYER_ID = 'sensors-clusters'\n\nimport type { SensorType} from '../../../../../../../types/dbTypes';\nimport type { PopupEntry } from '../../../../../../../types/map'\nimport type { MapGeoJSONFeature, MapLayerMouseEvent, MapMouseEvent } from 'maplibre-gl'\n\nconst SensorIconMarker = ({ feature, isHighlighted, isFocused, haloColour, onMouseEnter, onMouseLeave, sensorTypes }: { feature: MapGeoJSONFeature; isHighlighted?: boolean; isFocused?: boolean; haloColour?: string; onMouseEnter?: () => void; onMouseLeave?: () => void; sensorTypes: SensorType[] }) => {\n\n const coords = extractCoordinatesFromFeature(feature)\n if (!coords) return null\n\n const sensorType = sensorTypes.find(t => t.id === feature.properties?.typeId)\n const icon = sensorType?.icon || 'Radio'\n const SensorIcon = LR[icon] || LR.Radio\n\n // The border carries the sensor's current value when there is one, so selection moves to\n // border width and scale. Ring widths mirror the BIM marker's 2/3/4px tiers.\n const borderWidth = isFocused ? 4 : isHighlighted ? 3 : 2\n const borderColour = haloColour ?? (isHighlighted || isFocused ? HIGHLIGHT_COLOR : 'white')\n const glowColour = haloColour ? withAlpha(haloColour, 0.55) : 'rgba(115, 206, 226, 0.5)'\n const scale = isFocused ? 1.25 : isHighlighted ? 1.2 : 1\n\n return (\n <Marker key={String(feature.properties?.id ?? `${coords.lng},${coords.lat}`)} longitude={coords.lng} latitude={coords.lat} anchor=\"center\" {...markerOcclusionProps}>\n <div\n style={{\n width: '36px',\n height: '36px',\n borderRadius: '50%',\n border: `${borderWidth}px solid ${borderColour}`,\n backgroundColor: 'black',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n boxShadow: haloColour || isHighlighted || isFocused\n ? `0 0 ${isFocused ? 16 : 12}px ${glowColour}`\n : 'none',\n transition: 'all 0.2s ease-in-out',\n transform: `scale(${scale})`,\n }}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n >\n <SensorIcon style={{ width: '20px', height: '20px', color: 'hsl(var(--primary-foreground))' }} />\n </div>\n </Marker>\n )\n}\n\nexport const SensorLayers = () => {\n const [hoveredSensorId, setHoveredSensorId] = React.useState<number | null>(null)\n const clusterCountLayer = createClusterCountLayer('sensors')\n const unclusteredPointLayer = createUnclusteredPointLayer('sensors')\n\n // global map state\n\n const t = useTranslations('SensorLayers')\n const tSensors = useTranslations('SensorsSection')\n\n const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext)\n const { map, mapClickManager } = mapState.map\n const { sensors } = useSensors()\n const { users } = useUsers()\n const user = useSession().data?.user\n\n const sensorEntriesRef = React.useRef<Record<string, Partial<ISensor & { sensorType: SensorType }>>>({})\n const sensorBodyRef = React.useRef<(header: React.ReactNode) => React.ReactNode>(() => null)\n\n const closePopups = React.useCallback(\n () => mapDispatch({ type: 'SET_POPUP_STACK', payload: null }),\n [mapDispatch],\n )\n\n const popupInfo = React.useMemo(() => {\n const active = mapState.map.popupStack?.entries[mapState.map.popupStack.activeIndex]\n return active?.layerId === SENSOR_POINTS_LAYER_ID ? sensorEntriesRef.current[active.id] ?? null : null\n }, [mapState.map.popupStack])\n const { deleteSensor, updateSensor } = useSensor(popupInfo?.id ?? null)\n const { state: menusState, dispatch: menusDispatch } = React.useContext(MenusContext)\n const { visibleSensorTypes, visibleSensorTags, currentSensorId, focusedSensorId, sensorLegendTypeId } = menusState.menus\n const typesVisible = visibleSensorTypes?.[ViewerNames.map] || []\n const tagsVisible = visibleSensorTags?.[ViewerNames.map] || []\n\n const {sensorTypes} = useSensorTypes()\n\n const { state: appConfigState } = React.useContext(AppConfigContext)\n const timeZone = appConfigState.appConfig.displayTimeZone\n const [detailSensor, setDetailSensor] = React.useState<ISensor | null>(null)\n const [editSensor, setEditSensor] = React.useState<ISensor | null>(null)\n\n const eligibleSensors: Array<ISensor & { authorName: string } & { sensorType: SensorType }> = visibleSensors(sensors, {\n viewer: ViewerNames.map,\n visibleTypeIds: typesVisible,\n visibleTags: tagsVisible,\n })\n .map((sensor) => {\n const user = users.find(u => u.id === sensor.authorId)\n const sensorType = sensorTypes.find(t => t.id === sensor.typeId)\n return {\n ...sensor,\n authorName: user?.name ?? 'Unknown User',\n sensorType,\n }\n })\n\n // Close popup if the sensor was deleted\n React.useEffect(() => {\n if (popupInfo && !sensors.find((s) => s.id === popupInfo.id)) {\n closePopups()\n }\n }, [sensors, popupInfo, closePopups])\n\n // Every sensor sharing the active type gets a halo coloured by its own current value, readable\n // against the SensorLegend card. Only that one type is polled. Resolved through the same\n // helper the legend uses, so pinning a type in the legend dropdown moves the halos with it.\n const haloTypeId = activeSensorTypeId(eligibleSensors, {\n legendTypeId: sensorLegendTypeId?.[ViewerNames.map],\n activeSensorId: focusedSensorId,\n })\n const haloSensors = haloTypeId == null\n ? []\n : eligibleSensors.filter(s => s.typeId === haloTypeId)\n const { seriesById } = useSensorSeriesMulti(haloSensors, { enabled: haloSensors.length > 0 })\n\n const haloIdsKey = haloSensors.map(s => s.id).join(',')\n const readings = React.useMemo(\n () => valueColoursBySensor(haloSensors, sensorTypes, seriesById),\n [seriesById, sensorTypes, haloIdsKey],\n )\n\n // Cluster bubbles average the readings they hide, on the same ramp and domain the individual\n // halos use, so zooming out does not change what a colour means.\n const haloType = haloTypeId == null ? undefined : sensorTypes.find(t => t.id === haloTypeId)\n const haloRamp = haloType ? resolveRamp(haloType) : null\n const haloDomain = resolveDomain(\n haloType,\n observedDomain(haloSensors.flatMap(s => seriesById.get(s.id)?.points ?? [])),\n )\n const clusterLayer = createClusterLayer(\n 'sensors',\n sensorClusterColour(haloRamp, haloDomain, CLUSTER_COUNT_COLOUR),\n )\n\n const geojsonSensorData = React.useMemo(() => {\n const convertDataToGeojson = (sensorData: typeof eligibleSensors): GeoJSON.FeatureCollection<GeoJSON.Point, { [key: string]: any }> => {\n const sensorFeatures: GeoJSON.Feature<GeoJSON.Point, { [key: string]: any }>[] = sensorData\n .map((sensor) => {\n const { longitude, latitude, id, name, typeId, sensorType, data, dataFormat, updateFrequency, createdAt, authorId, organizationId, visible, url, authorName } = sensor\n\n return {\n type: 'Feature',\n geometry: {\n type: 'Point',\n coordinates: [longitude, latitude],\n },\n properties: {\n id: Number(id),\n organizationId,\n visible,\n longitude,\n latitude,\n authorId: Number(authorId),\n authorName,\n name,\n typeId: Number(typeId),\n typeIcon: sensorType?.icon,\n data,\n dataFormat,\n updateFrequency,\n url,\n createdAt,\n viewer: ViewerNames.map,\n // Only present for sensors of the active type that are actually reporting. The\n // cluster accumulators count exactly these, so the average is over real readings.\n ...(readings.has(Number(id)) ? { value: readings.get(Number(id))?.value } : {}),\n },\n }\n })\n\n\n\n const sensorFC: GeoJSON.FeatureCollection<GeoJSON.Point, { [key: string]: any }> = {\n type: 'FeatureCollection',\n features: sensorFeatures,\n }\n return sensorFC\n }\n return convertDataToGeojson(eligibleSensors)\n }, [eligibleSensors, readings])\n\n // event listeners for sensor unclustered points\n React.useEffect(() => {\n if (!map) return\n const resolveSensors = (_e: MapMouseEvent, features: MapGeoJSONFeature[]): PopupEntry[] => {\n sensorEntriesRef.current = {}\n\n const entries = features.flatMap((feature) => {\n if (feature.properties.point_count) return []\n if (feature.geometry.type !== 'Point') return []\n const [longitude, latitude] = feature.geometry.coordinates\n const { id, authorId, name, typeId, data, dataFormat, updateFrequency, createdAt, url } = feature.properties\n\n const entryId = `${SENSOR_POINTS_LAYER_ID}:${id}`\n sensorEntriesRef.current[entryId] = {\n id: Number(id),\n authorId: Number(authorId),\n organizationId: feature.properties?.organizationId,\n visible: feature.properties?.visible,\n longitude,\n latitude,\n name,\n typeId: Number(typeId),\n data,\n dataFormat,\n updateFrequency,\n url,\n createdAt,\n viewer: ViewerNames.map,\n }\n\n return [{\n id: entryId,\n layerId: SENSOR_POINTS_LAYER_ID,\n priority: MapLayerClickPriority.CommentLayersClickPriority,\n title: (name as string) || t('sensorTitle'),\n coordinates: [longitude, latitude] as [number, number],\n // Readings and tags are live, so the body resolves at render time, not in this closure.\n render: (header) => sensorBodyRef.current(header),\n }]\n })\n\n // Focus on click so the legend and the sibling halos follow the sensor just opened.\n const first = entries[0]\n if (first) {\n menusDispatch({ type: 'SET_FOCUSED_SENSOR_ID', payload: { sensorId: sensorEntriesRef.current[first.id].id } })\n }\n\n return entries\n }\n\n const mouseEnterChangeCursor = () => {\n map.getCanvas().style.cursor = 'pointer'\n }\n const mouseLeaveChangeCursor = () => {\n map.getCanvas().style.cursor = ''\n }\n\n // event listener for clicking on single point to show sensor, hover to change cursor\n mapClickManager.register(SENSOR_POINTS_LAYER_ID, MapLayerClickPriority.CommentLayersClickPriority, resolveSensors)\n\n map.on('mouseenter', 'sensors-unclustered-points', mouseEnterChangeCursor)\n map.on('mouseleave', 'sensors-unclustered-points', mouseLeaveChangeCursor)\n return () => {\n mapClickManager.unregister('sensors-unclustered-points')\n map.off('mouseenter', 'sensors-unclustered-points', mouseEnterChangeCursor)\n map.off('mouseleave', 'sensors-unclustered-points', mouseLeaveChangeCursor)\n }\n }, [map, mapClickManager, menusDispatch, t])\n\n const handleRemoveSensor = () => {\n toast.success(t('sensorDeleted'))\n void deleteSensor()\n closePopups()\n }\n\n // event listeners for clustered points\n React.useEffect(() => {\n if (!map) return\n\n const resolveCluster = (_e: MapMouseEvent, features: MapGeoJSONFeature[]): PopupEntry[] => {\n const feature = features[0]\n const spec = feature && clusterSpecFromFeature(feature)\n if (!spec) return []\n\n return [buildClusterEntry({\n map,\n sourceId: 'sensors',\n layerId: SENSOR_CLUSTER_LAYER_ID,\n title: t('sensorTitle'),\n priority: MapLayerClickPriority.CommentLayersClickPriority,\n leafLabel: (leaf) => String(leaf.properties?.name ?? ''),\n ...spec,\n })]\n }\n\n const mouseEnterChangeCursor = () => { map.getCanvas().style.cursor = 'pointer' }\n const mouseLeaveChangeCursor = () => { map.getCanvas().style.cursor = '' }\n\n // a cluster click contributes one entry listing its contents, hover to change cursor\n mapClickManager.register(SENSOR_CLUSTER_LAYER_ID, MapLayerClickPriority.CommentLayersClickPriority, resolveCluster)\n map.on('mouseenter', SENSOR_CLUSTER_LAYER_ID, mouseEnterChangeCursor)\n map.on('mouseleave', SENSOR_CLUSTER_LAYER_ID, mouseLeaveChangeCursor)\n return () => {\n mapClickManager.unregister(SENSOR_CLUSTER_LAYER_ID)\n map.off('mouseenter', SENSOR_CLUSTER_LAYER_ID, mouseEnterChangeCursor)\n map.off('mouseleave', SENSOR_CLUSTER_LAYER_ID, mouseLeaveChangeCursor)\n }\n }, [map, mapClickManager, t])\n\n const renderSensorBody = (header: React.ReactNode) => {\n if (!popupInfo) return null\n const sensorType = sensorTypes.find(t => t.id === popupInfo.typeId)\n const liveSensor = sensors.find(s => s.id === popupInfo.id)\n const dataUrl = popupInfo.url || popupInfo.data || ''\n\n return (\n <Sensor\n header={header}\n sensorName={popupInfo.name || ''}\n sensorType={sensorType}\n sensorId={popupInfo.id}\n tags={liveSensor?.tags ?? []}\n onAddTag={async (tag) => { await updateSensor({ tags: [...(liveSensor?.tags ?? []), tag] }) }}\n onDeleteTag={async (tag) => { await updateSensor({ tags: (liveSensor?.tags ?? []).filter(t => t !== tag) }) }}\n tagsTranslations={{\n addTag: tSensors('addTag'),\n removeTag: tSensors('removeTag'),\n cancel: tSensors('cancel'),\n newTagPlaceholder: tSensors('newTagPlaceholder'),\n }}\n dataUrl={dataUrl}\n dataFormat={popupInfo.dataFormat}\n updateFrequency={popupInfo.updateFrequency}\n buildingId={popupInfo.buildingId}\n createdAt={popupInfo.createdAt}\n onRemove={user.id === String(popupInfo.authorId) ? handleRemoveSensor : null}\n onClose={closePopups}\n onExpand={() => { if (liveSensor) setDetailSensor(liveSensor) }}\n onEdit={user.id === String(popupInfo.authorId) && liveSensor ? () => setEditSensor(liveSensor) : undefined}\n showActions\n focused={focusedSensorId === popupInfo.id}\n haloColour={popupInfo.id == null ? undefined : readings.get(popupInfo.id)?.colour}\n onSelect={() => {\n if (popupInfo.id != null) {\n menusDispatch({ type: 'SET_FOCUSED_SENSOR_ID', payload: { sensorId: popupInfo.id } })\n }\n }}\n timeZone={timeZone}\n size=\"sm\"\n />\n )\n }\n sensorBodyRef.current = renderSensorBody\n\n // Track unclustered sensors to display icons\n const [unclusteredFeatures, setUnclusteredFeatures] = React.useState<MapGeoJSONFeature[]>([])\n\n React.useEffect(() => {\n if (!map) return\n\n const updateUnclusteredFeatures = () => {\n const allFeatures = map.querySourceFeatures('sensors')\n const unclusteredOnly = allFeatures.filter(\n (f) => !f.properties?.cluster && !f.properties?.point_count\n )\n // Deduplicate by id\n const uniqueFeatures = new Map()\n unclusteredOnly.forEach((f) => uniqueFeatures.set(f.properties.id, f))\n setUnclusteredFeatures(Array.from(uniqueFeatures.values()))\n }\n\n const onSourceData = (e: any) => {\n if (e?.sourceId === 'sensors') updateUnclusteredFeatures()\n }\n\n map.on('sourcedata', onSourceData)\n map.on('moveend', updateUnclusteredFeatures)\n map.on('zoomend', updateUnclusteredFeatures)\n\n updateUnclusteredFeatures()\n\n return () => {\n map.off('sourcedata', onSourceData)\n map.off('moveend', updateUnclusteredFeatures)\n map.off('zoomend', updateUnclusteredFeatures)\n }\n }, [map])\n\n return (\n <>\n {detailSensor && (\n <SensorDetailDialog\n open={!!detailSensor}\n onOpenChange={(o) => !o && setDetailSensor(null)}\n sensor={detailSensor}\n sensorType={sensorTypes.find(t => t.id === detailSensor.typeId)}\n />\n )}\n {editSensor && (\n <SensorInput\n viewer={ViewerNames.map}\n layout=\"dialog\"\n isOpen={!!editSensor}\n editSensor={editSensor ?? undefined}\n onCancel={() => setEditSensor(null)}\n onSaved={() => setEditSensor(null)}\n />\n )}\n {(typesVisible.length > 0 || tagsVisible.length > 0) &&\n <Source\n id=\"sensors\"\n type=\"geojson\"\n data={geojsonSensorData}\n cluster={true}\n clusterMaxZoom={14}\n clusterRadius={40}\n clusterProperties={SENSOR_CLUSTER_PROPERTIES}\n >\n <Layer {...clusterLayer} />\n <Layer {...clusterCountLayer} />\n <Layer {...unclusteredPointLayer} />\n\n\n {unclusteredFeatures\n .filter((feature) => feature.properties?.id !== popupInfo?.id)\n .map((feature) => (\n <SensorIconMarker\n key={String(feature.properties?.id)}\n feature={feature}\n isHighlighted={currentSensorId === feature.properties?.id || hoveredSensorId === feature.properties?.id}\n isFocused={focusedSensorId === feature.properties?.id}\n haloColour={readings.get(Number(feature.properties?.id))?.colour}\n onMouseEnter={() => setHoveredSensorId(feature.properties?.id)}\n onMouseLeave={() => setHoveredSensorId(null)}\n sensorTypes={sensorTypes}\n />\n ))}\n </Source>}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6EQ,SAgVJ,UAhVI,KAoWJ,YApWI;AAxER,YAAY,QAAQ;AACpB,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,YAAY,WAAW;AACvB,SAAS,QAAQ,OAAO,cAAc;AACtC,SAAS,aAAa;AAEtB,SAAS,WAAW,kBAAkB;AACtC,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB,YAAY,oBAAoB;AAC3D,SAAS,mBAA0C;AACnD,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB,4BAA4B;AACtD,OAAO,YAAY;AACnB,SAAS,gBAAgB,eAAe,mBAAmB;AAC3D,SAAS,0BAA0B;AACnC,SAAS,mBAAmB;AAC5B,SAAS,4BAA4B;AACrC,SAAS,oBAAoB,sBAAsB;AACnD,SAAS,4BAA4B;AACrC,SAAS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teLayer.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAgE9B,eAAO,MAAM,SAAS,yBA+QrB,CAAA"}
1
+ {"version":3,"file":"SiteLayer.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAkE9B,eAAO,MAAM,SAAS,yBAuTrB,CAAA"}
@@ -31,8 +31,8 @@ import {
31
31
  } from "../../../../../../../store";
32
32
  import { ViewerNames } from "../../../../../../../types/dbTypes";
33
33
  import { MapLayerClickPriority } from "../../../../utils/MapEventManager/MapClickManager";
34
- import { SiteContextMenu } from "./SiteContextMenu";
35
34
  import { polygonCentroid, uploadGeoJsonToAsset, pointToSegmentDistance } from "./siteGeometry";
35
+ import { SiteMenu } from "./SiteMenu";
36
36
  const SITE_FILL_ID = "site-fill";
37
37
  const SITE_OUTLINE_ID = "site-outline";
38
38
  const SITE_LABEL_ID = "site-label";
@@ -71,7 +71,7 @@ const labelLayer = {
71
71
  };
72
72
  const SiteLayer = () => {
73
73
  var _a, _b, _c, _d;
74
- const { state: mapState } = React.useContext(MapContext);
74
+ const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext);
75
75
  const { map, mapClickManager } = mapState.map;
76
76
  const { state: mapSitesState, dispatch } = useMapSitesContext();
77
77
  const { sites, editingSiteId } = mapSitesState.mapSites;
@@ -81,6 +81,11 @@ const SiteLayer = () => {
81
81
  const canRead = ability.can("read", "Site");
82
82
  const { dispatch: menusDispatch, setSelectedSite, setView } = useMenusContext();
83
83
  const [menu, setMenu] = React.useState(null);
84
+ const closeMenu = React.useCallback(() => {
85
+ setMenu(null);
86
+ mapDispatch({ type: "SET_POPUP_STACK", payload: null });
87
+ }, [mapDispatch]);
88
+ const siteMenuRef = React.useRef(() => null);
84
89
  const activeSiteId = (_b = (_a = menu == null ? void 0 : menu.siteId) != null ? _a : editingSiteId) != null ? _b : null;
85
90
  const { updateSite } = useSite(activeSiteId ? String(activeSiteId) : "");
86
91
  const { deleteSite } = useDeleteSite(activeSiteId != null ? activeSiteId : void 0);
@@ -90,6 +95,28 @@ const SiteLayer = () => {
90
95
  sitesRef.current = sites;
91
96
  const editingSiteIdRef = React.useRef(editingSiteId);
92
97
  editingSiteIdRef.current = editingSiteId;
98
+ const editStartRingRef = React.useRef(null);
99
+ React.useEffect(() => {
100
+ var _a2, _b2;
101
+ editStartRingRef.current = editingSiteId == null ? null : (_b2 = (_a2 = sitesRef.current.find((s) => s.id === editingSiteId)) == null ? void 0 : _a2.ring) != null ? _b2 : null;
102
+ }, [editingSiteId]);
103
+ const cancelEdit = React.useCallback(() => {
104
+ const id = editingSiteIdRef.current;
105
+ if (id == null) return;
106
+ const original = editStartRingRef.current;
107
+ if (original) dispatch({ type: "UPDATE_SITE_RING", payload: { id, ring: original } });
108
+ dispatch({ type: "SET_EDITING_SITE", payload: { id: null } });
109
+ }, [dispatch]);
110
+ React.useEffect(() => {
111
+ if (editingSiteId == null) return;
112
+ const onKey = (e) => {
113
+ if (e.key !== "Escape") return;
114
+ e.stopPropagation();
115
+ cancelEdit();
116
+ };
117
+ document.addEventListener("keydown", onKey);
118
+ return () => document.removeEventListener("keydown", onKey);
119
+ }, [editingSiteId, cancelEdit]);
93
120
  const featureCollection = React.useMemo(() => {
94
121
  const features = [];
95
122
  for (const s of sites) {
@@ -109,18 +136,20 @@ const SiteLayer = () => {
109
136
  }, [sites]);
110
137
  React.useEffect(() => {
111
138
  if (!map || !mapClickManager) return;
112
- const handleSiteClick = (e, features) => {
113
- var _a2, _b2, _c2;
114
- if (editingSiteIdRef.current != null) return;
139
+ const resolveSitePopups = (e, features) => {
140
+ var _a2, _b2, _c2, _d2, _e;
115
141
  const feature = features == null ? void 0 : features[0];
116
142
  const siteId = Number((_a2 = feature == null ? void 0 : feature.properties) == null ? void 0 : _a2.siteId);
117
- if (!siteId || Number.isNaN(siteId)) return;
118
- const native = e.originalEvent;
119
- setMenu({
120
- x: (_b2 = native == null ? void 0 : native.clientX) != null ? _b2 : e.point.x,
121
- y: (_c2 = native == null ? void 0 : native.clientY) != null ? _c2 : e.point.y,
122
- siteId
123
- });
143
+ if (!siteId || Number.isNaN(siteId)) return [];
144
+ setMenu({ siteId });
145
+ return [{
146
+ id: `${SITE_FILL_ID}:${siteId}`,
147
+ layerId: SITE_FILL_ID,
148
+ priority: MapLayerClickPriority.SiteLayerClickPriority,
149
+ title: String((_e = (_d2 = (_b2 = feature == null ? void 0 : feature.properties) == null ? void 0 : _b2.name) != null ? _d2 : (_c2 = sitesRef.current.find((s) => s.id === siteId)) == null ? void 0 : _c2.name) != null ? _e : "Site"),
150
+ coordinates: [e.lngLat.lng, e.lngLat.lat],
151
+ render: (header) => siteMenuRef.current(header)
152
+ }];
124
153
  };
125
154
  const onEnter = () => {
126
155
  map.getCanvas().style.cursor = "pointer";
@@ -128,7 +157,7 @@ const SiteLayer = () => {
128
157
  const onLeave = () => {
129
158
  map.getCanvas().style.cursor = "";
130
159
  };
131
- mapClickManager.register(SITE_FILL_ID, MapLayerClickPriority.SiteLayerClickPriority, handleSiteClick);
160
+ mapClickManager.register(SITE_FILL_ID, MapLayerClickPriority.SiteLayerClickPriority, resolveSitePopups);
132
161
  map.on("mouseenter", SITE_FILL_ID, onEnter);
133
162
  map.on("mouseleave", SITE_FILL_ID, onLeave);
134
163
  return () => {
@@ -221,7 +250,7 @@ const SiteLayer = () => {
221
250
  const handleHide = () => {
222
251
  if (!menu) return;
223
252
  dispatch({ type: "HIDE_SITE", payload: { id: menu.siteId } });
224
- setMenu(null);
253
+ closeMenu();
225
254
  };
226
255
  const handleInfo = () => {
227
256
  if (!menu) return;
@@ -229,7 +258,7 @@ const SiteLayer = () => {
229
258
  setSelectedSite({ id: menu.siteId, siteName: s == null ? void 0 : s.name });
230
259
  setView("detail");
231
260
  menusDispatch({ type: "SET_VIEWER", payload: { currentViewer: ViewerNames.sites } });
232
- setMenu(null);
261
+ closeMenu();
233
262
  };
234
263
  const handleDelete = async () => {
235
264
  if (!menu) return;
@@ -244,13 +273,34 @@ const SiteLayer = () => {
244
273
  }
245
274
  }
246
275
  dispatch({ type: "HIDE_SITE", payload: { id } });
247
- setMenu(null);
276
+ closeMenu();
248
277
  toast.success("Site deleted.");
249
278
  } catch (e) {
250
279
  toast.error("Failed to delete the site.");
251
280
  }
252
281
  };
253
282
  const editingSite = editingSiteId != null ? (_d = sites.find((s) => s.id === editingSiteId)) != null ? _d : null : null;
283
+ const renderSiteMenu = (header) => {
284
+ if (!menu || !menuSite) return null;
285
+ return /* @__PURE__ */ jsx(
286
+ SiteMenu,
287
+ {
288
+ header,
289
+ site: menuSite,
290
+ isEditing: editingSiteId === menu.siteId,
291
+ canUpdate,
292
+ canDelete,
293
+ canRead,
294
+ onClose: closeMenu,
295
+ onRename: (name) => void handleRename(name),
296
+ onToggleEdit: () => void handleToggleEdit(),
297
+ onHide: handleHide,
298
+ onInfo: handleInfo,
299
+ onDelete: handleDelete
300
+ }
301
+ );
302
+ };
303
+ siteMenuRef.current = renderSiteMenu;
254
304
  return /* @__PURE__ */ jsxs(Fragment, { children: [
255
305
  /* @__PURE__ */ jsxs(Source, { id: "sites-source", type: "geojson", data: featureCollection, children: [
256
306
  /* @__PURE__ */ jsx(Layer, __spreadValues({}, fillLayer)),
@@ -285,25 +335,7 @@ const SiteLayer = () => {
285
335
  )
286
336
  },
287
337
  `${editingSite.id}-vertex-${index}`
288
- )),
289
- menu && menuSite && /* @__PURE__ */ jsx(
290
- SiteContextMenu,
291
- {
292
- x: menu.x,
293
- y: menu.y,
294
- site: menuSite,
295
- isEditing: editingSiteId === menu.siteId,
296
- canUpdate,
297
- canDelete,
298
- canRead,
299
- onClose: () => setMenu(null),
300
- onRename: (name) => void handleRename(name),
301
- onToggleEdit: () => void handleToggleEdit(),
302
- onHide: handleHide,
303
- onInfo: handleInfo,
304
- onDelete: handleDelete
305
- }
306
- )
338
+ ))
307
339
  ] });
308
340
  };
309
341
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\nimport { Source, Layer, Marker } from 'react-map-gl/maplibre'\nimport { toast } from 'sonner'\n\nimport { useDeleteFile } from '../../../../../../../hooks/files/files'\nimport { useSite, useDeleteSite } from '../../../../../../../hooks/sites/sites'\nimport {\n MapContext,\n usePermissions,\n useMenusContext,\n useMapSitesContext,\n} from '../../../../../../../store'\nimport { ViewerNames, type Site } from '../../../../../../../types/dbTypes'\nimport { MapLayerClickPriority, type ClickCallback } from '../../../../utils/MapEventManager/MapClickManager'\n\nimport { SiteContextMenu } from './SiteContextMenu'\nimport { polygonCentroid, uploadGeoJsonToAsset, pointToSegmentDistance } from './siteGeometry'\n\nimport type { MapGeoJSONFeature } from 'maplibre-gl'\nimport type { LayerProps } from 'react-map-gl/maplibre'\n\nconst SITE_FILL_ID = 'site-fill'\nconst SITE_OUTLINE_ID = 'site-outline'\nconst SITE_LABEL_ID = 'site-label'\n\n// How close (screen px) a click must be to count as \"on a vertex\" / \"on an edge\".\nconst VERTEX_HIT_PX = 12\nconst EDGE_HIT_PX = 8\n// A polygon needs at least 3 corners; deleting below that is blocked.\nconst MIN_RING_POINTS = 3\n\nconst fillLayer: LayerProps = {\n id: SITE_FILL_ID,\n type: 'fill',\n paint: { 'fill-color': '#3b82f6', 'fill-opacity': 0.35 },\n filter: ['==', ['get', 'type'], 'site'],\n}\n\nconst outlineLayer: LayerProps = {\n id: SITE_OUTLINE_ID,\n type: 'line',\n layout: { 'line-cap': 'round', 'line-join': 'round' },\n paint: { 'line-color': '#1c4587', 'line-width': 2 },\n filter: ['==', ['get', 'type'], 'site'],\n}\n\nconst labelLayer: LayerProps = {\n id: SITE_LABEL_ID,\n type: 'symbol',\n layout: {\n 'text-field': ['get', 'name'],\n 'text-font': ['Inter'],\n 'text-size': 16,\n 'text-anchor': 'center',\n 'text-allow-overlap': false,\n },\n paint: {\n 'text-color': '#ffffff',\n 'text-halo-color': '#000000',\n 'text-halo-width': 1.5,\n },\n filter: ['==', ['get', 'type'], 'site-label'],\n}\n\nexport const SiteLayer = () => {\n const { state: mapState } = React.useContext(MapContext)\n const { map, mapClickManager } = mapState.map\n const { state: mapSitesState, dispatch } = useMapSitesContext()\n const { sites, editingSiteId } = mapSitesState.mapSites\n\n const { ability } = usePermissions()\n const canUpdate = ability.can('update', 'Site')\n const canDelete = ability.can('delete', 'Site')\n const canRead = ability.can('read', 'Site')\n\n const { dispatch: menusDispatch, setSelectedSite, setView } = useMenusContext()\n\n const [menu, setMenu] = React.useState<{ x: number, y: number, siteId: number } | null>(null)\n\n // The site the user is currently acting on (menu open) or editing.\n const activeSiteId = menu?.siteId ?? editingSiteId ?? null\n const { updateSite } = useSite(activeSiteId ? String(activeSiteId) : '')\n const { deleteSite } = useDeleteSite(activeSiteId ?? undefined)\n const { deleteFile } = useDeleteFile(undefined, activeSiteId ?? undefined)\n\n const menuSite = menu ? sites.find(s => s.id === menu.siteId) ?? null : null\n\n // Live mirrors so the once-bound map click handlers read current values.\n const sitesRef = React.useRef(sites)\n sitesRef.current = sites\n const editingSiteIdRef = React.useRef(editingSiteId)\n editingSiteIdRef.current = editingSiteId\n\n // Build the rendered FeatureCollection: a polygon + a single centroid label\n // per shown site.\n const featureCollection = React.useMemo<GeoJSON.FeatureCollection>(() => {\n const features: GeoJSON.Feature[] = []\n for (const s of sites) {\n if (s.ring.length < 3) continue\n features.push({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [[...s.ring, s.ring[0]]] },\n properties: { type: 'site', siteId: s.id, name: s.name },\n })\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: polygonCentroid(s.ring) },\n properties: { type: 'site-label', siteId: s.id, name: s.name },\n })\n }\n return { type: 'FeatureCollection', features }\n }, [sites])\n\n // Lowest-priority click handler: opens the site menu only when no other\n // interactive layer was hit at the click point.\n React.useEffect(() => {\n if (!map || !mapClickManager) return\n\n const handleSiteClick: ClickCallback = (e, features: MapGeoJSONFeature[]) => {\n // While editing a shape, fill clicks are for adding vertices (see the\n // edit-click effect), not for (re)opening the menu.\n if (editingSiteIdRef.current != null) return\n const feature = features?.[0]\n const siteId = Number(feature?.properties?.siteId)\n if (!siteId || Number.isNaN(siteId)) return\n const native = e.originalEvent as MouseEvent | undefined\n setMenu({\n x: native?.clientX ?? e.point.x,\n y: native?.clientY ?? e.point.y,\n siteId,\n })\n }\n\n const onEnter = () => { map.getCanvas().style.cursor = 'pointer' }\n const onLeave = () => { map.getCanvas().style.cursor = '' }\n\n mapClickManager.register(SITE_FILL_ID, MapLayerClickPriority.SiteLayerClickPriority, handleSiteClick)\n map.on('mouseenter', SITE_FILL_ID, onEnter)\n map.on('mouseleave', SITE_FILL_ID, onLeave)\n\n return () => {\n mapClickManager.unregister(SITE_FILL_ID)\n map.off('mouseenter', SITE_FILL_ID, onEnter)\n map.off('mouseleave', SITE_FILL_ID, onLeave)\n }\n }, [map, mapClickManager])\n\n const updateVertex = (index: number, lng: number, lat: number) => {\n if (editingSiteId == null) return\n const s = sites.find(x => x.id === editingSiteId)\n if (!s) return\n const ring = s.ring.map((p, i) => (i === index ? [lng, lat] as [number, number] : p))\n dispatch({ type: 'UPDATE_SITE_RING', payload: { id: editingSiteId, ring } })\n }\n\n // Double-click a vertex to delete it (a polygon keeps at least 3 corners).\n const deleteVertex = (index: number) => {\n if (editingSiteId == null) return\n const s = sites.find(x => x.id === editingSiteId)\n if (!s) return\n if (s.ring.length <= MIN_RING_POINTS) {\n toast.warning('A site needs at least 3 points.')\n return\n }\n const ring = s.ring.filter((_, i) => i !== index)\n dispatch({ type: 'UPDATE_SITE_RING', payload: { id: editingSiteId, ring } })\n }\n\n // While editing, a click on an edge (not a vertex) inserts a new vertex there.\n React.useEffect(() => {\n if (!map || editingSiteId == null) return\n\n const onEditClick = (e: maplibregl.MapMouseEvent) => {\n const site = sitesRef.current.find(s => s.id === editingSiteId)\n const ring = site?.ring\n if (!ring || ring.length < 2) return\n\n const click = e.point\n // Ignore clicks on/near an existing vertex — those drag (or, on a\n // double-click, delete) via the markers.\n for (const v of ring) {\n const vp = map.project(v as [number, number])\n if (Math.hypot(vp.x - click.x, vp.y - click.y) <= VERTEX_HIT_PX) return\n }\n\n // Find the nearest edge segment in screen space.\n let bestDist = Infinity\n let bestIdx = -1\n for (let i = 0; i < ring.length; i++) {\n const a = map.project(ring[i] as [number, number])\n const b = map.project(ring[(i + 1) % ring.length] as [number, number])\n const d = pointToSegmentDistance(click.x, click.y, a.x, a.y, b.x, b.y)\n if (d < bestDist) { bestDist = d; bestIdx = i }\n }\n\n if (bestIdx >= 0 && bestDist <= EDGE_HIT_PX) {\n const next = [...ring]\n next.splice(bestIdx + 1, 0, [e.lngLat.lng, e.lngLat.lat])\n dispatch({ type: 'UPDATE_SITE_RING', payload: { id: editingSiteId, ring: next } })\n }\n }\n\n // Avoid the map zooming when a vertex is double-clicked to delete it.\n map.doubleClickZoom.disable()\n map.on('click', onEditClick)\n return () => {\n map.off('click', onEditClick)\n map.doubleClickZoom.enable()\n }\n }, [map, editingSiteId, dispatch])\n\n const handleRename = async (name: string) => {\n if (!menu) return\n dispatch({ type: 'UPDATE_SITE_NAME', payload: { id: menu.siteId, name } })\n try {\n await updateSite({ siteName: name })\n }\n catch {\n toast.error('Failed to rename the site.')\n }\n }\n\n const handleToggleEdit = async () => {\n if (editingSiteId === activeSiteId && activeSiteId != null) {\n // Finishing an edit: persist the new geometry + centroid.\n const s = sites.find(x => x.id === activeSiteId)\n dispatch({ type: 'SET_EDITING_SITE', payload: { id: null } })\n if (s?.assetId && s.ring.length >= 3) {\n const toastId = toast.loading('Saving site shape…')\n try {\n await uploadGeoJsonToAsset(s.assetId, s.ring, s.name)\n const c = polygonCentroid(s.ring)\n await updateSite({ siteLongitude: c[0], siteLatitude: c[1] })\n toast.success('Site shape saved.', { id: toastId })\n }\n catch {\n toast.error('Failed to save the site shape.', { id: toastId })\n }\n }\n }\n else {\n // Keep the menu open so the name can be edited alongside the vertices.\n dispatch({ type: 'SET_EDITING_SITE', payload: { id: activeSiteId } })\n }\n }\n\n const handleHide = () => {\n if (!menu) return\n dispatch({ type: 'HIDE_SITE', payload: { id: menu.siteId } })\n setMenu(null)\n }\n\n const handleInfo = () => {\n if (!menu) return\n const s = sites.find(x => x.id === menu.siteId)\n setSelectedSite({ id: menu.siteId, siteName: s?.name } as Site)\n setView('detail')\n menusDispatch({ type: 'SET_VIEWER', payload: { currentViewer: ViewerNames.sites } })\n setMenu(null)\n }\n\n const handleDelete = async () => {\n if (!menu) return\n const id = menu.siteId\n const s = sites.find(x => x.id === id)\n try {\n await deleteSite(id)\n if (s?.fileId) {\n try { await deleteFile(s.fileId) }\n catch { /* geometry file orphaned; site itself is gone */ }\n }\n dispatch({ type: 'HIDE_SITE', payload: { id } })\n setMenu(null)\n toast.success('Site deleted.')\n }\n catch {\n toast.error('Failed to delete the site.')\n }\n }\n\n const editingSite = editingSiteId != null ? sites.find(s => s.id === editingSiteId) ?? null : null\n\n return (\n <>\n <Source id=\"sites-source\" type=\"geojson\" data={featureCollection}>\n <Layer {...fillLayer} />\n <Layer {...outlineLayer} />\n <Layer {...labelLayer} />\n </Source>\n\n {/* Draggable vertex handles while editing a site's shape */}\n {editingSite?.ring.map((vertex, index) => (\n <Marker\n key={`${editingSite.id}-vertex-${index}`}\n longitude={vertex[0]}\n latitude={vertex[1]}\n draggable\n onDrag={(e: { lngLat: { lng: number, lat: number } }) =>\n updateVertex(index, e.lngLat.lng, e.lngLat.lat)}\n >\n <div\n title=\"Drag to move · double-click to delete\"\n onDoubleClick={(ev) => { ev.stopPropagation(); deleteVertex(index) }}\n style={{\n width: 14,\n height: 14,\n borderRadius: '50%',\n background: '#22c55e',\n border: '2px solid #ffffff',\n boxShadow: '0 0 0 1px #15803d',\n cursor: 'grab',\n }}\n />\n </Marker>\n ))}\n\n {menu && menuSite && (\n <SiteContextMenu\n x={menu.x}\n y={menu.y}\n site={menuSite}\n isEditing={editingSiteId === menu.siteId}\n canUpdate={canUpdate}\n canDelete={canDelete}\n canRead={canRead}\n onClose={() => setMenu(null)}\n onRename={(name) => void handleRename(name)}\n onToggleEdit={() => void handleToggleEdit()}\n onHide={handleHide}\n onInfo={handleInfo}\n onDelete={handleDelete}\n />\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAgSI,mBAEI,KADF,YADF;AA3RJ,YAAY,WAAW;AACvB,SAAS,QAAQ,OAAO,cAAc;AACtC,SAAS,aAAa;AAEtB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAA8B;AACvC,SAAS,6BAAiD;AAE1D,SAAS,uBAAuB;AAChC,SAAS,iBAAiB,sBAAsB,8BAA8B;AAK9E,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AAGtB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AAEpB,MAAM,kBAAkB;AAExB,MAAM,YAAwB;AAAA,EAC5B,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,EAAE,cAAc,WAAW,gBAAgB,KAAK;AAAA,EACvD,QAAQ,CAAC,MAAM,CAAC,OAAO,MAAM,GAAG,MAAM;AACxC;AAEA,MAAM,eAA2B;AAAA,EAC/B,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,QAAQ,EAAE,YAAY,SAAS,aAAa,QAAQ;AAAA,EACpD,OAAO,EAAE,cAAc,WAAW,cAAc,EAAE;AAAA,EAClD,QAAQ,CAAC,MAAM,CAAC,OAAO,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AA,YAAE;AAAA,YACnE,OAAO;AAAA,cACL,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,YAAY;AAAA,cACZ,QAAQ;AAAA,cACR,WAAW;AAAA,cACX,QAAQ;AAAA,YACV;AAAA;AAAA,QACF;AAAA;AAAA,MAnBK,GAAG,YAAY,EAAE,WAAW,KAAK;AAAA,IAoBxC;AAAA,IAGD,QAAQ,YACP;AAAA,MAAC;AAAA;AAAA,QACC,GAAG,KAAK;AAAA,QACR,GAAG,KAAK;AAAA,QACR,MAAM;AAAA,QACN,WAAW,kBAAkB,KAAK;AAAA,QAClC;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,MAAM,QAAQ,IAAI;AAAA,QAC3B,UAAU,CAAC,SAAS,KAAK,aAAa,IAAI;AAAA,QAC1C,cAAc,MAAM,KAAK,iBAAiB;AAAA,QAC1C,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,UAAU;AAAA;AAAA,IACZ;AAAA,KAEJ;AAEJ;","names":["_a","_b","_c"]}
1
+ {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteLayer.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as React from 'react'\nimport { Source, Layer, Marker } from 'react-map-gl/maplibre'\nimport { toast } from 'sonner'\n\nimport { useDeleteFile } from '../../../../../../../hooks/files/files'\nimport { useSite, useDeleteSite } from '../../../../../../../hooks/sites/sites'\nimport {\n MapContext,\n usePermissions,\n useMenusContext,\n useMapSitesContext,\n} from '../../../../../../../store'\nimport { ViewerNames, type Site } from '../../../../../../../types/dbTypes'\nimport { MapLayerClickPriority } from '../../../../utils/MapEventManager/MapClickManager'\n\nimport { polygonCentroid, uploadGeoJsonToAsset, pointToSegmentDistance } from './siteGeometry'\nimport { SiteMenu } from './SiteMenu'\n\nimport type { PopupEntry } from '../../../../../../../types/map'\nimport type * as maplibregl from 'maplibre-gl'\nimport type { MapGeoJSONFeature, MapMouseEvent } from 'maplibre-gl'\nimport type { LayerProps } from 'react-map-gl/maplibre'\n\nconst SITE_FILL_ID = 'site-fill'\nconst SITE_OUTLINE_ID = 'site-outline'\nconst SITE_LABEL_ID = 'site-label'\n\n// How close (screen px) a click must be to count as \"on a vertex\" / \"on an edge\".\nconst VERTEX_HIT_PX = 12\nconst EDGE_HIT_PX = 8\n// A polygon needs at least 3 corners; deleting below that is blocked.\nconst MIN_RING_POINTS = 3\n\nconst fillLayer: LayerProps = {\n id: SITE_FILL_ID,\n type: 'fill',\n paint: { 'fill-color': '#3b82f6', 'fill-opacity': 0.35 },\n filter: ['==', ['get', 'type'], 'site'],\n}\n\nconst outlineLayer: LayerProps = {\n id: SITE_OUTLINE_ID,\n type: 'line',\n layout: { 'line-cap': 'round', 'line-join': 'round' },\n paint: { 'line-color': '#1c4587', 'line-width': 2 },\n filter: ['==', ['get', 'type'], 'site'],\n}\n\nconst labelLayer: LayerProps = {\n id: SITE_LABEL_ID,\n type: 'symbol',\n layout: {\n 'text-field': ['get', 'name'],\n 'text-font': ['Inter'],\n 'text-size': 16,\n 'text-anchor': 'center',\n 'text-allow-overlap': false,\n },\n paint: {\n 'text-color': '#ffffff',\n 'text-halo-color': '#000000',\n 'text-halo-width': 1.5,\n },\n filter: ['==', ['get', 'type'], 'site-label'],\n}\n\nexport const SiteLayer = () => {\n const { state: mapState, dispatch: mapDispatch } = React.useContext(MapContext)\n const { map, mapClickManager } = mapState.map\n const { state: mapSitesState, dispatch } = useMapSitesContext()\n const { sites, editingSiteId } = mapSitesState.mapSites\n\n const { ability } = usePermissions()\n const canUpdate = ability.can('update', 'Site')\n const canDelete = ability.can('delete', 'Site')\n const canRead = ability.can('read', 'Site')\n\n const { dispatch: menusDispatch, setSelectedSite, setView } = useMenusContext()\n\n const [menu, setMenu] = React.useState<{ siteId: number } | null>(null)\n\n const closeMenu = React.useCallback(() => {\n setMenu(null)\n mapDispatch({ type: 'SET_POPUP_STACK', payload: null })\n }, [mapDispatch])\n // Site state is live, so the menu body resolves at render time, not in the entry's closure.\n const siteMenuRef = React.useRef<(header: React.ReactNode) => React.ReactNode>(() => null)\n\n // The site the user is currently acting on (menu open) or editing.\n const activeSiteId = menu?.siteId ?? editingSiteId ?? null\n const { updateSite } = useSite(activeSiteId ? String(activeSiteId) : '')\n const { deleteSite } = useDeleteSite(activeSiteId ?? undefined)\n const { deleteFile } = useDeleteFile(undefined, activeSiteId ?? undefined)\n\n const menuSite = menu ? sites.find(s => s.id === menu.siteId) ?? null : null\n\n // Live mirrors so the once-bound map click handlers read current values.\n const sitesRef = React.useRef(sites)\n sitesRef.current = sites\n const editingSiteIdRef = React.useRef(editingSiteId)\n editingSiteIdRef.current = editingSiteId\n\n // The ring as it was when editing began, so Escape can put it back.\n const editStartRingRef = React.useRef<[number, number][] | null>(null)\n\n React.useEffect(() => {\n editStartRingRef.current = editingSiteId == null\n ? null\n : sitesRef.current.find(s => s.id === editingSiteId)?.ring ?? null\n }, [editingSiteId])\n\n const cancelEdit = React.useCallback(() => {\n const id = editingSiteIdRef.current\n if (id == null) return\n const original = editStartRingRef.current\n if (original) dispatch({ type: 'UPDATE_SITE_RING', payload: { id, ring: original } })\n dispatch({ type: 'SET_EDITING_SITE', payload: { id: null } })\n }, [dispatch])\n\n React.useEffect(() => {\n if (editingSiteId == null) return\n const onKey = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return\n e.stopPropagation()\n cancelEdit()\n }\n document.addEventListener('keydown', onKey)\n return () => document.removeEventListener('keydown', onKey)\n }, [editingSiteId, cancelEdit])\n\n // Build the rendered FeatureCollection: a polygon + a single centroid label\n // per shown site.\n const featureCollection = React.useMemo<GeoJSON.FeatureCollection>(() => {\n const features: GeoJSON.Feature[] = []\n for (const s of sites) {\n if (s.ring.length < 3) continue\n features.push({\n type: 'Feature',\n geometry: { type: 'Polygon', coordinates: [[...s.ring, s.ring[0]]] },\n properties: { type: 'site', siteId: s.id, name: s.name },\n })\n features.push({\n type: 'Feature',\n geometry: { type: 'Point', coordinates: polygonCentroid(s.ring) },\n properties: { type: 'site-label', siteId: s.id, name: s.name },\n })\n }\n return { type: 'FeatureCollection', features }\n }, [sites])\n\n // Lowest-priority handler: the site entry sorts last in the popup stack.\n React.useEffect(() => {\n if (!map || !mapClickManager) return\n\n const resolveSitePopups = (e: MapMouseEvent, features: MapGeoJSONFeature[]): PopupEntry[] => {\n const feature = features?.[0]\n const siteId = Number(feature?.properties?.siteId)\n if (!siteId || Number.isNaN(siteId)) return []\n\n setMenu({ siteId })\n\n return [{\n id: `${SITE_FILL_ID}:${siteId}`,\n layerId: SITE_FILL_ID,\n priority: MapLayerClickPriority.SiteLayerClickPriority,\n title: String(feature?.properties?.name ?? sitesRef.current.find(s => s.id === siteId)?.name ?? 'Site'),\n coordinates: [e.lngLat.lng, e.lngLat.lat],\n render: (header) => siteMenuRef.current(header),\n }]\n }\n\n const onEnter = () => { map.getCanvas().style.cursor = 'pointer' }\n const onLeave = () => { map.getCanvas().style.cursor = '' }\n\n mapClickManager.register(SITE_FILL_ID, MapLayerClickPriority.SiteLayerClickPriority, resolveSitePopups)\n map.on('mouseenter', SITE_FILL_ID, onEnter)\n map.on('mouseleave', SITE_FILL_ID, onLeave)\n\n return () => {\n mapClickManager.unregister(SITE_FILL_ID)\n map.off('mouseenter', SITE_FILL_ID, onEnter)\n map.off('mouseleave', SITE_FILL_ID, onLeave)\n }\n }, [map, mapClickManager])\n\n const updateVertex = (index: number, lng: number, lat: number) => {\n if (editingSiteId == null) return\n const s = sites.find(x => x.id === editingSiteId)\n if (!s) return\n const ring = s.ring.map((p, i) => (i === index ? [lng, lat] as [number, number] : p))\n dispatch({ type: 'UPDATE_SITE_RING', payload: { id: editingSiteId, ring } })\n }\n\n // Double-click a vertex to delete it (a polygon keeps at least 3 corners).\n const deleteVertex = (index: number) => {\n if (editingSiteId == null) return\n const s = sites.find(x => x.id === editingSiteId)\n if (!s) return\n if (s.ring.length <= MIN_RING_POINTS) {\n toast.warning('A site needs at least 3 points.')\n return\n }\n const ring = s.ring.filter((_, i) => i !== index)\n dispatch({ type: 'UPDATE_SITE_RING', payload: { id: editingSiteId, ring } })\n }\n\n // While editing, a click on an edge (not a vertex) inserts a new vertex there.\n React.useEffect(() => {\n if (!map || editingSiteId == null) return\n\n const onEditClick = (e: maplibregl.MapMouseEvent) => {\n const site = sitesRef.current.find(s => s.id === editingSiteId)\n const ring = site?.ring\n if (!ring || ring.length < 2) return\n\n const click = e.point\n // Ignore clicks on/near an existing vertex — those drag (or, on a\n // double-click, delete) via the markers.\n for (const v of ring) {\n const vp = map.project(v as [number, number])\n if (Math.hypot(vp.x - click.x, vp.y - click.y) <= VERTEX_HIT_PX) return\n }\n\n // Find the nearest edge segment in screen space.\n let bestDist = Infinity\n let bestIdx = -1\n for (let i = 0; i < ring.length; i++) {\n const a = map.project(ring[i] as [number, number])\n const b = map.project(ring[(i + 1) % ring.length] as [number, number])\n const d = pointToSegmentDistance(click.x, click.y, a.x, a.y, b.x, b.y)\n if (d < bestDist) { bestDist = d; bestIdx = i }\n }\n\n if (bestIdx >= 0 && bestDist <= EDGE_HIT_PX) {\n const next = [...ring]\n next.splice(bestIdx + 1, 0, [e.lngLat.lng, e.lngLat.lat])\n dispatch({ type: 'UPDATE_SITE_RING', payload: { id: editingSiteId, ring: next } })\n }\n }\n\n // Avoid the map zooming when a vertex is double-clicked to delete it.\n map.doubleClickZoom.disable()\n map.on('click', onEditClick)\n return () => {\n map.off('click', onEditClick)\n map.doubleClickZoom.enable()\n }\n }, [map, editingSiteId, dispatch])\n\n const handleRename = async (name: string) => {\n if (!menu) return\n dispatch({ type: 'UPDATE_SITE_NAME', payload: { id: menu.siteId, name } })\n try {\n await updateSite({ siteName: name })\n }\n catch {\n toast.error('Failed to rename the site.')\n }\n }\n\n const handleToggleEdit = async () => {\n if (editingSiteId === activeSiteId && activeSiteId != null) {\n // Finishing an edit: persist the new geometry + centroid.\n const s = sites.find(x => x.id === activeSiteId)\n dispatch({ type: 'SET_EDITING_SITE', payload: { id: null } })\n if (s?.assetId && s.ring.length >= 3) {\n const toastId = toast.loading('Saving site shape…')\n try {\n await uploadGeoJsonToAsset(s.assetId, s.ring, s.name)\n const c = polygonCentroid(s.ring)\n await updateSite({ siteLongitude: c[0], siteLatitude: c[1] })\n toast.success('Site shape saved.', { id: toastId })\n }\n catch {\n toast.error('Failed to save the site shape.', { id: toastId })\n }\n }\n }\n else {\n // Keep the menu open so the name can be edited alongside the vertices.\n dispatch({ type: 'SET_EDITING_SITE', payload: { id: activeSiteId } })\n }\n }\n\n const handleHide = () => {\n if (!menu) return\n dispatch({ type: 'HIDE_SITE', payload: { id: menu.siteId } })\n closeMenu()\n }\n\n const handleInfo = () => {\n if (!menu) return\n const s = sites.find(x => x.id === menu.siteId)\n setSelectedSite({ id: menu.siteId, siteName: s?.name } as Site)\n setView('detail')\n menusDispatch({ type: 'SET_VIEWER', payload: { currentViewer: ViewerNames.sites } })\n closeMenu()\n }\n\n const handleDelete = async () => {\n if (!menu) return\n const id = menu.siteId\n const s = sites.find(x => x.id === id)\n try {\n await deleteSite(id)\n if (s?.fileId) {\n try { await deleteFile(s.fileId) }\n catch { /* geometry file orphaned; site itself is gone */ }\n }\n dispatch({ type: 'HIDE_SITE', payload: { id } })\n closeMenu()\n toast.success('Site deleted.')\n }\n catch {\n toast.error('Failed to delete the site.')\n }\n }\n\n const editingSite = editingSiteId != null ? sites.find(s => s.id === editingSiteId) ?? null : null\n\n const renderSiteMenu = (header: React.ReactNode) => {\n if (!menu || !menuSite) return null\n return (\n <SiteMenu\n header={header}\n site={menuSite}\n isEditing={editingSiteId === menu.siteId}\n canUpdate={canUpdate}\n canDelete={canDelete}\n canRead={canRead}\n onClose={closeMenu}\n onRename={(name) => void handleRename(name)}\n onToggleEdit={() => void handleToggleEdit()}\n onHide={handleHide}\n onInfo={handleInfo}\n onDelete={handleDelete}\n />\n )\n }\n siteMenuRef.current = renderSiteMenu\n\n return (\n <>\n <Source id=\"sites-source\" type=\"geojson\" data={featureCollection}>\n <Layer {...fillLayer} />\n <Layer {...outlineLayer} />\n <Layer {...labelLayer} />\n </Source>\n\n {/* Draggable vertex handles while editing a site's shape */}\n {editingSite?.ring.map((vertex, index) => (\n <Marker\n key={`${editingSite.id}-vertex-${index}`}\n longitude={vertex[0]}\n latitude={vertex[1]}\n draggable\n onDrag={(e: { lngLat: { lng: number, lat: number } }) =>\n updateVertex(index, e.lngLat.lng, e.lngLat.lat)}\n >\n <div\n title=\"Drag to move · double-click to delete\"\n onDoubleClick={(ev) => { ev.stopPropagation(); deleteVertex(index) }}\n style={{\n width: 14,\n height: 14,\n borderRadius: '50%',\n background: '#22c55e',\n border: '2px solid #ffffff',\n boxShadow: '0 0 0 1px #15803d',\n cursor: 'grab',\n }}\n />\n </Marker>\n ))}\n\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwUM,SAmBF,UAnBE,KAoBA,YApBA;AAnUN,YAAY,WAAW;AACvB,SAAS,QAAQ,OAAO,cAAc;AACtC,SAAS,aAAa;AAEtB,SAAS,qBAAqB;AAC9B,SAAS,SAAS,qBAAqB;AACvC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAA8B;AACvC,SAAS,6BAA6B;AAEtC,SAAS,iBAAiB,sBAAsB,8BAA8B;AAC9E,SAAS,gBAAgB;AAOzB,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,gBAAgB;AAGtB,MAAM,gBAAgB;AACtB,MAAM,cAAc;AAEpB,MAAM,kBAAkB;AAExB,MAAM,YAAwB;AAAA,EAC5B,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,OAAO,EAAE,cAAc,WAAW,gBAAgB,KAAK;AAAA,EACvD,QAAQ,CAAC,MAAM,CAAC,OAAO,MAAM,GAAG,MAAM;AACxC;AAEA,MAAM,eAA2B;AAAA,EAC/B,IAAI;AAA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C,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,UAAU;AAAA;AAAA,IACZ;AAAA,EAEJ;AACA,cAAY,UAAU;AAEtB,SACE,iCACE;AAAA,yBAAC,UAAO,IAAG,gBAAe,MAAK,WAAU,MAAM,mBAC7C;AAAA,0BAAC,0BAAU,UAAW;AAAA,MACtB,oBAAC,0BAAU,aAAc;AAAA,MACzB,oBAAC,0BAAU,WAAY;AAAA,OACzB;AAAA,IAGC,2CAAa,KAAK,IAAI,CAAC,QAAQ,UAC9B;AAAA,MAAC;AAAA;AAAA,QAEC,WAAW,OAAO,CAAC;AAAA,QACnB,UAAU,OAAO,CAAC;AAAA,QAClB,WAAS;AAAA,QACT,QAAQ,CAAC,MACP,aAAa,OAAO,EAAE,OAAO,KAAK,EAAE,OAAO,GAAG;AAAA,QAEhD;AAAA,UAAC;AAAA;AAAA,YACC,OAAM;AAAA,YACN,eAAe,CAAC,OAAO;AAAE,iBAAG,gBAAgB;AAAG,2BAAa,KAAK;AAAA,YAAE;AAAA,YACnE,OAAO;AAAA,cACL,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,YAAY;AAAA,cACZ,QAAQ;AAAA,cACR,WAAW;AAAA,cACX,QAAQ;AAAA,YACV;AAAA;AAAA,QACF;AAAA;AAAA,MAnBK,GAAG,YAAY,EAAE,WAAW,KAAK;AAAA,IAoBxC;AAAA,KAGJ;AAEJ;","names":["_a","_b","_c","_d"]}
@@ -1,8 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import type { ShownSite } from '../../../../../../../store/MapSites/reducer';
3
- export interface SiteContextMenuProps {
4
- x: number;
5
- y: number;
3
+ export interface SiteMenuProps {
4
+ header?: React.ReactNode;
6
5
  site: ShownSite;
7
6
  isEditing: boolean;
8
7
  canUpdate: boolean;
@@ -15,5 +14,5 @@ export interface SiteContextMenuProps {
15
14
  onInfo: () => void;
16
15
  onDelete: () => void | Promise<void>;
17
16
  }
18
- export declare const SiteContextMenu: React.FC<SiteContextMenuProps>;
19
- //# sourceMappingURL=SiteContextMenu.d.ts.map
17
+ export declare const SiteMenu: React.FC<SiteMenuProps>;
18
+ //# sourceMappingURL=SiteMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SiteMenu.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteMenu.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAA;AAE5E,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACxB,IAAI,EAAE,SAAS,CAAA;IACf,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrC;AAED,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAqI5C,CAAA"}
@@ -7,9 +7,8 @@ import { useTranslations } from "next-intl";
7
7
  import * as React from "react";
8
8
  import ConfirmDialog from "../../../../../../ConfirmDialog";
9
9
  import { Input } from "../../../../../../ui/Input";
10
- const SiteContextMenu = ({
11
- x,
12
- y,
10
+ const SiteMenu = ({
11
+ header,
13
12
  site,
14
13
  isEditing,
15
14
  canUpdate,
@@ -22,7 +21,7 @@ const SiteContextMenu = ({
22
21
  onInfo,
23
22
  onDelete
24
23
  }) => {
25
- const t = useTranslations("SiteContextMenu");
24
+ const t = useTranslations("SiteMenu");
26
25
  const tf = React.useCallback(
27
26
  (key, fallback) => t.has(key) ? t(key) : fallback,
28
27
  [t]
@@ -68,11 +67,11 @@ const SiteContextMenu = ({
68
67
  "div",
69
68
  {
70
69
  ref,
71
- className: "fixed z-50 w-56 rounded-md border bg-popover text-popover-foreground shadow-md p-1",
72
- style: { left: x, top: y },
70
+ className: "w-60 rounded-md border bg-popover p-2 text-popover-foreground shadow-md",
73
71
  onClick: (e) => e.stopPropagation(),
74
72
  children: [
75
- /* @__PURE__ */ jsx("div", { className: "px-2 pt-1.5 pb-2", children: /* @__PURE__ */ jsx(
73
+ header,
74
+ /* @__PURE__ */ jsx("div", { className: `pb-2 pl-2 pt-1.5 ${header ? "pr-9" : "pr-2"}`, children: /* @__PURE__ */ jsx(
76
75
  Input,
77
76
  {
78
77
  value: name,
@@ -160,6 +159,6 @@ const SiteContextMenu = ({
160
159
  );
161
160
  };
162
161
  export {
163
- SiteContextMenu
162
+ SiteMenu
164
163
  };
165
- //# sourceMappingURL=SiteContextMenu.js.map
164
+ //# sourceMappingURL=SiteMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/SiteLayer/SiteMenu.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport * as LR from 'lucide-react'\nimport { useTranslations } from 'next-intl'\nimport * as React from 'react'\n\nimport ConfirmDialog from '../../../../../../ConfirmDialog'\nimport { Button } from '../../../../../../ui/Button'\nimport { Input } from '../../../../../../ui/Input'\n\nimport type { ShownSite } from '../../../../../../../store/MapSites/reducer'\n\nexport interface SiteMenuProps {\n header?: React.ReactNode\n site: ShownSite\n isEditing: boolean\n canUpdate: boolean\n canDelete: boolean\n canRead: boolean\n onClose: () => void\n onRename: (name: string) => void\n onToggleEdit: () => void\n onHide: () => void\n onInfo: () => void\n onDelete: () => void | Promise<void>\n}\n\nexport const SiteMenu: React.FC<SiteMenuProps> = ({\n header, site, isEditing, canUpdate, canDelete, canRead,\n onClose, onRename, onToggleEdit, onHide, onInfo, onDelete,\n}) => {\n const t = useTranslations('SiteMenu')\n // Translate with an English fallback so the menu is usable before the host\n // app's message catalog is updated (mirrors SiteAdder's approach).\n const tf = React.useCallback(\n (key: string, fallback: string) => (t.has(key) ? t(key) : fallback),\n [t],\n )\n\n const ref = React.useRef<HTMLDivElement>(null)\n const [name, setName] = React.useState(site.name)\n const [isDeleteOpen, setIsDeleteOpen] = React.useState(false)\n const [isDeleting, setIsDeleting] = React.useState(false)\n\n React.useEffect(() => { setName(site.name) }, [site.id, site.name])\n\n // Close on outside click / Escape, unless the delete confirmation is open or\n // the user is editing the polygon (dragging a vertex is an \"outside\" click).\n React.useEffect(() => {\n const onPointerDown = (e: MouseEvent) => {\n if (isDeleteOpen || isEditing) return\n if (ref.current && !ref.current.contains(e.target as Node)) onClose()\n }\n const onKey = (e: KeyboardEvent) => {\n if (isDeleteOpen || isEditing) return\n if (e.key === 'Escape') onClose()\n }\n document.addEventListener('mousedown', onPointerDown)\n document.addEventListener('keydown', onKey)\n return () => {\n document.removeEventListener('mousedown', onPointerDown)\n document.removeEventListener('keydown', onKey)\n }\n }, [isDeleteOpen, isEditing, onClose])\n\n const commitName = () => {\n const trimmed = name.trim()\n if (trimmed && trimmed !== site.name) onRename(trimmed)\n }\n\n const handleConfirmDelete = async (e: React.MouseEvent) => {\n e.preventDefault()\n setIsDeleting(true)\n try {\n await onDelete()\n }\n finally {\n setIsDeleting(false)\n setIsDeleteOpen(false)\n }\n }\n\n return (\n <div\n ref={ref}\n className=\"w-60 rounded-md border bg-popover p-2 text-popover-foreground shadow-md\"\n onClick={e => e.stopPropagation()}\n >\n {header}\n {/* Editable site name. The floating close button overlays this row, so keep its corner clear. */}\n <div className={`pb-2 pl-2 pt-1.5 ${header ? 'pr-9' : 'pr-2'}`}>\n <Input\n value={name}\n disabled={!canUpdate}\n onChange={e => setName(e.target.value)}\n onBlur={commitName}\n onKeyDown={(e) => {\n if (e.key === 'Enter') { e.preventDefault(); commitName(); (e.target as HTMLInputElement).blur() }\n }}\n placeholder={tf('namePlaceholder', 'Site name')}\n className=\"h-8 text-sm\"\n />\n </div>\n\n <div className=\"h-px bg-border my-1\" />\n\n <button\n type=\"button\"\n onClick={onToggleEdit}\n disabled={!canUpdate}\n className=\"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent disabled:opacity-50 disabled:pointer-events-none\"\n >\n {isEditing\n ? <LR.Check className=\"h-4 w-4\" />\n : <LR.PencilRuler className=\"h-4 w-4\" />}\n {isEditing ? tf('doneEditing', 'Done editing shape') : tf('editShape', 'Edit shape')}\n </button>\n\n <button\n type=\"button\"\n onClick={onHide}\n disabled={!canRead}\n className=\"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent disabled:opacity-50 disabled:pointer-events-none\"\n >\n <LR.EyeOff className=\"h-4 w-4\" />\n {tf('hide', 'Hide')}\n </button>\n\n <button\n type=\"button\"\n onClick={onInfo}\n disabled={!canRead}\n className=\"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm hover:bg-accent disabled:opacity-50 disabled:pointer-events-none\"\n >\n <LR.Info className=\"h-4 w-4\" />\n {tf('info', 'Site details')}\n </button>\n\n <div className=\"h-px bg-border my-1\" />\n\n <button\n type=\"button\"\n onClick={() => setIsDeleteOpen(true)}\n disabled={!canDelete}\n className=\"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-destructive hover:bg-accent disabled:opacity-50 disabled:pointer-events-none\"\n >\n <LR.Trash2 className=\"h-4 w-4\" />\n {tf('delete', 'Delete site')}\n </button>\n\n <ConfirmDialog\n isOpen={isDeleteOpen}\n isDeleting={isDeleting}\n onOpenChange={setIsDeleteOpen}\n handleConfirm={(e) => void handleConfirmDelete(e)}\n itemName={site.name}\n dataType={t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AAA;AAAA,QACrF;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS;AAAA,YACT,UAAU,CAAC;AAAA,YACX,WAAU;AAAA,YAEV;AAAA,kCAAC,GAAG,QAAH,EAAU,WAAU,WAAU;AAAA,cAC9B,GAAG,QAAQ,MAAM;AAAA;AAAA;AAAA,QACpB;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS;AAAA,YACT,UAAU,CAAC;AAAA,YACX,WAAU;AAAA,YAEV;AAAA,kCAAC,GAAG,MAAH,EAAQ,WAAU,WAAU;AAAA,cAC5B,GAAG,QAAQ,cAAc;AAAA;AAAA;AAAA,QAC5B;AAAA,QAEA,oBAAC,SAAI,WAAU,uBAAsB;AAAA,QAErC;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,SAAS,MAAM,gBAAgB,IAAI;AAAA,YACnC,UAAU,CAAC;AAAA,YACX,WAAU;AAAA,YAEV;AAAA,kCAAC,GAAG,QAAH,EAAU,WAAU,WAAU;AAAA,cAC9B,GAAG,UAAU,aAAa;AAAA;AAAA;AAAA,QAC7B;AAAA,QAEA;AAAA,UAAC;AAAA;AAAA,YACC,QAAQ;AAAA,YACR;AAAA,YACA,cAAc;AAAA,YACd,eAAe,CAAC,MAAM,KAAK,oBAAoB,CAAC;AAAA,YAChD,UAAU,KAAK;AAAA,YACf,UAAU,GAAG,gBAAgB,MAAM;AAAA;AAAA,QACrC;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
@@ -0,0 +1,23 @@
1
+ import type { PopupEntry } from '../../../../../../types/map';
2
+ import type { MapLayerClickPriority } from '../../../utils/MapEventManager/MapClickManager';
3
+ import type { Map, MapGeoJSONFeature } from 'maplibre-gl';
4
+ interface ClusterSpec {
5
+ map: Map;
6
+ sourceId: string;
7
+ layerId: string;
8
+ clusterId: number;
9
+ count: number;
10
+ coordinates: [number, number];
11
+ title: string;
12
+ priority: MapLayerClickPriority;
13
+ leafLabel: (feature: MapGeoJSONFeature) => string;
14
+ }
15
+ /** One entry for a whole cluster: a 143-point cluster must not become 143 switcher steps. */
16
+ export declare const buildClusterEntry: (spec: ClusterSpec) => PopupEntry;
17
+ export declare const clusterSpecFromFeature: (feature: MapGeoJSONFeature) => {
18
+ clusterId: number;
19
+ count: number;
20
+ coordinates: [number, number];
21
+ } | null;
22
+ export {};
23
+ //# sourceMappingURL=clusterPopupEntry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clusterPopupEntry.d.ts","sourceRoot":"","sources":["../../../../../../../../src/core/components/viewers/map/src/MapLayers/src/clusterPopupEntry.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAA;AAC3F,OAAO,KAAK,EAAE,GAAG,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAEzD,UAAU,WAAW;IACnB,GAAG,EAAE,GAAG,CAAA;IACR,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,qBAAqB,CAAA;IAC/B,SAAS,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,MAAM,CAAA;CAClD;AAoDD,6FAA6F;AAC7F,eAAO,MAAM,iBAAiB,GAAI,MAAM,WAAW,KAAG,UAOpD,CAAA;AAEF,eAAO,MAAM,sBAAsB,GACjC,SAAS,iBAAiB,KACzB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IASxE,CAAA"}