@collabdt/core 0.4.4 → 0.4.8

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 (291) hide show
  1. package/dist/core/components/Toolbar.js +1 -1
  2. package/dist/core/components/Toolbar.js.map +1 -1
  3. package/dist/core/components/TopNavigationBar.js +3 -3
  4. package/dist/core/components/TopNavigationBar.js.map +1 -1
  5. package/dist/core/components/ui/CollapsibleSection.d.ts +5 -1
  6. package/dist/core/components/ui/CollapsibleSection.d.ts.map +1 -1
  7. package/dist/core/components/ui/CollapsibleSection.js +10 -2
  8. package/dist/core/components/ui/CollapsibleSection.js.map +1 -1
  9. package/dist/core/components/ui/Sidebar.d.ts.map +1 -1
  10. package/dist/core/components/ui/Sidebar.js +3 -3
  11. package/dist/core/components/ui/Sidebar.js.map +1 -1
  12. package/dist/core/components/ui/ViewerSidebar/CommunicationTab.d.ts +9 -0
  13. package/dist/core/components/ui/ViewerSidebar/CommunicationTab.d.ts.map +1 -0
  14. package/dist/core/components/ui/ViewerSidebar/CommunicationTab.js +14 -0
  15. package/dist/core/components/ui/ViewerSidebar/CommunicationTab.js.map +1 -0
  16. package/dist/core/components/ui/ViewerSidebar/Header.d.ts.map +1 -0
  17. package/dist/core/components/ui/ViewerSidebar/Header.js.map +1 -0
  18. package/dist/core/components/ui/ViewerSidebar/Panel.d.ts +23 -0
  19. package/dist/core/components/ui/ViewerSidebar/Panel.d.ts.map +1 -0
  20. package/dist/core/components/ui/ViewerSidebar/Panel.js +37 -0
  21. package/dist/core/components/ui/ViewerSidebar/Panel.js.map +1 -0
  22. package/dist/core/components/ui/ViewerSidebar/SensorsTab.d.ts +4 -0
  23. package/dist/core/components/ui/ViewerSidebar/SensorsTab.d.ts.map +1 -0
  24. package/dist/core/components/ui/ViewerSidebar/SensorsTab.js +11 -0
  25. package/dist/core/components/ui/ViewerSidebar/SensorsTab.js.map +1 -0
  26. package/dist/core/components/ui/ViewerSidebar/Shell.d.ts +16 -0
  27. package/dist/core/components/ui/ViewerSidebar/Shell.d.ts.map +1 -0
  28. package/dist/core/components/ui/ViewerSidebar/Shell.js +56 -0
  29. package/dist/core/components/ui/ViewerSidebar/Shell.js.map +1 -0
  30. package/dist/core/components/ui/ViewerSidebar/TabStrip.d.ts +19 -0
  31. package/dist/core/components/ui/ViewerSidebar/TabStrip.d.ts.map +1 -0
  32. package/dist/core/components/ui/ViewerSidebar/TabStrip.js +82 -0
  33. package/dist/core/components/ui/ViewerSidebar/TabStrip.js.map +1 -0
  34. package/dist/core/components/ui/{InfoSidebar → ViewerSidebar}/index.d.ts +1 -1
  35. package/dist/core/components/ui/ViewerSidebar/index.d.ts.map +1 -0
  36. package/dist/core/components/ui/{InfoSidebar → ViewerSidebar}/index.js +3 -3
  37. package/dist/core/components/ui/ViewerSidebar/index.js.map +1 -0
  38. package/dist/core/components/ui/ViewerSidebar/sidebarTabs.d.ts +45 -0
  39. package/dist/core/components/ui/ViewerSidebar/sidebarTabs.d.ts.map +1 -0
  40. package/dist/core/components/ui/ViewerSidebar/sidebarTabs.js +30 -0
  41. package/dist/core/components/ui/ViewerSidebar/sidebarTabs.js.map +1 -0
  42. package/dist/core/components/ui/index.d.ts +1 -1
  43. package/dist/core/components/ui/index.d.ts.map +1 -1
  44. package/dist/core/components/ui/index.js +2 -2
  45. package/dist/core/components/ui/index.js.map +1 -1
  46. package/dist/core/components/viewers/Viewer.js.map +1 -1
  47. package/dist/core/components/viewers/bim/BimToolbar.d.ts +1 -3
  48. package/dist/core/components/viewers/bim/BimToolbar.d.ts.map +1 -1
  49. package/dist/core/components/viewers/bim/BimToolbar.js +2 -2
  50. package/dist/core/components/viewers/bim/BimToolbar.js.map +1 -1
  51. package/dist/core/components/viewers/bim/BimViewer.d.ts.map +1 -1
  52. package/dist/core/components/viewers/bim/BimViewer.js +42 -0
  53. package/dist/core/components/viewers/bim/BimViewer.js.map +1 -1
  54. package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/index.d.ts.map +1 -1
  55. package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/index.js +4 -13
  56. package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/index.js.map +1 -1
  57. package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.d.ts.map +1 -1
  58. package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.js +5 -0
  59. package/dist/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.js.map +1 -1
  60. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/index.d.ts +11 -8
  61. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/index.d.ts.map +1 -1
  62. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/index.js +126 -58
  63. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/index.js.map +1 -1
  64. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceProvider.d.ts +32 -0
  65. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceProvider.d.ts.map +1 -0
  66. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceProvider.js +53 -0
  67. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceProvider.js.map +1 -0
  68. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceSwatch.d.ts +19 -0
  69. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceSwatch.d.ts.map +1 -0
  70. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceSwatch.js +131 -0
  71. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/AppearanceSwatch.js.map +1 -0
  72. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/BimTreeView.d.ts +19 -0
  73. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/BimTreeView.d.ts.map +1 -0
  74. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/BimTreeView.js +101 -0
  75. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/BimTreeView.js.map +1 -0
  76. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/ElevationsSection.d.ts.map +1 -1
  77. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/ElevationsSection.js +24 -35
  78. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/ElevationsSection.js.map +1 -1
  79. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/FloorplanSection.d.ts.map +1 -1
  80. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/FloorplanSection.js +4 -9
  81. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/FloorplanSection.js.map +1 -1
  82. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/IfcClassesSection.d.ts +16 -0
  83. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/IfcClassesSection.d.ts.map +1 -0
  84. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/IfcClassesSection.js +94 -0
  85. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/IfcClassesSection.js.map +1 -0
  86. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/LayerGroupSection.d.ts +28 -0
  87. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/LayerGroupSection.d.ts.map +1 -0
  88. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/LayerGroupSection.js +55 -0
  89. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/LayerGroupSection.js.map +1 -0
  90. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/LayerViewPanel.d.ts +18 -0
  91. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/LayerViewPanel.d.ts.map +1 -0
  92. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/LayerViewPanel.js +16 -0
  93. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/LayerViewPanel.js.map +1 -0
  94. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/SpatialStructureSection.d.ts +6 -12
  95. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/SpatialStructureSection.d.ts.map +1 -1
  96. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/SpatialStructureSection.js +78 -401
  97. package/dist/core/components/viewers/bim/src/BimSidebar/src/LayersTab/src/SpatialStructureSection.js.map +1 -1
  98. package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/index.d.ts +1 -1
  99. package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/index.d.ts.map +1 -1
  100. package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/index.js +2 -5
  101. package/dist/core/components/viewers/bim/src/BimSidebar/src/SettingsTab/index.js.map +1 -1
  102. package/dist/core/components/viewers/bim/src/BimSidebar/src/Topics/src/CollapsibleTopicItem.d.ts.map +1 -0
  103. package/dist/core/components/viewers/bim/src/BimSidebar/src/Topics/src/CollapsibleTopicItem.js.map +1 -0
  104. package/dist/core/components/viewers/bim/src/BimSidebar/src/Topics/src/CreateTopicDialog.d.ts.map +1 -0
  105. package/dist/core/components/viewers/bim/src/BimSidebar/src/Topics/src/CreateTopicDialog.js.map +1 -0
  106. package/dist/core/components/viewers/bim/src/BimSidebar/src/Topics/src/TopicsSection.d.ts.map +1 -0
  107. package/dist/core/components/viewers/bim/src/BimSidebar/src/Topics/src/TopicsSection.js.map +1 -0
  108. package/dist/core/components/viewers/bim/src/BimSidebar/src/index.d.ts +1 -2
  109. package/dist/core/components/viewers/bim/src/BimSidebar/src/index.d.ts.map +1 -1
  110. package/dist/core/components/viewers/bim/src/BimSidebar/src/index.js +14 -35
  111. package/dist/core/components/viewers/bim/src/BimSidebar/src/index.js.map +1 -1
  112. package/dist/core/components/viewers/bim/src/ElementAppearance.d.ts +115 -0
  113. package/dist/core/components/viewers/bim/src/ElementAppearance.d.ts.map +1 -0
  114. package/dist/core/components/viewers/bim/src/ElementAppearance.js +254 -0
  115. package/dist/core/components/viewers/bim/src/ElementAppearance.js.map +1 -0
  116. package/dist/core/components/viewers/bim/src/FloorplanTool/index.d.ts +8 -0
  117. package/dist/core/components/viewers/bim/src/FloorplanTool/index.d.ts.map +1 -1
  118. package/dist/core/components/viewers/bim/src/FloorplanTool/index.js +54 -2
  119. package/dist/core/components/viewers/bim/src/FloorplanTool/index.js.map +1 -1
  120. package/dist/core/components/viewers/bim/src/FloorplanTool/src/StoreyProjector.d.ts.map +1 -1
  121. package/dist/core/components/viewers/bim/src/FloorplanTool/src/StoreyProjector.js +15 -0
  122. package/dist/core/components/viewers/bim/src/FloorplanTool/src/StoreyProjector.js.map +1 -1
  123. package/dist/core/components/viewers/bim/src/FloorplanTool/src/types.d.ts +4 -0
  124. package/dist/core/components/viewers/bim/src/FloorplanTool/src/types.d.ts.map +1 -1
  125. package/dist/core/components/viewers/bim/src/FloorplanTool/src/types.js.map +1 -1
  126. package/dist/core/components/viewers/bim/src/Highlighter/index.d.ts +31 -4
  127. package/dist/core/components/viewers/bim/src/Highlighter/index.d.ts.map +1 -1
  128. package/dist/core/components/viewers/bim/src/Highlighter/index.js +122 -69
  129. package/dist/core/components/viewers/bim/src/Highlighter/index.js.map +1 -1
  130. package/dist/core/components/viewers/bim/src/IfcClasses.d.ts +93 -0
  131. package/dist/core/components/viewers/bim/src/IfcClasses.d.ts.map +1 -0
  132. package/dist/core/components/viewers/bim/src/IfcClasses.js +196 -0
  133. package/dist/core/components/viewers/bim/src/IfcClasses.js.map +1 -0
  134. package/dist/core/components/viewers/bim/src/SimpleBimViewer.d.ts.map +1 -1
  135. package/dist/core/components/viewers/bim/src/SimpleBimViewer.js +2 -0
  136. package/dist/core/components/viewers/bim/src/SimpleBimViewer.js.map +1 -1
  137. package/dist/core/components/viewers/bim/src/SpatialStructure.d.ts +37 -31
  138. package/dist/core/components/viewers/bim/src/SpatialStructure.d.ts.map +1 -1
  139. package/dist/core/components/viewers/bim/src/SpatialStructure.js +141 -234
  140. package/dist/core/components/viewers/bim/src/SpatialStructure.js.map +1 -1
  141. package/dist/core/components/viewers/bim/src/VisibilityState.d.ts +21 -0
  142. package/dist/core/components/viewers/bim/src/VisibilityState.d.ts.map +1 -0
  143. package/dist/core/components/viewers/bim/src/VisibilityState.js +18 -0
  144. package/dist/core/components/viewers/bim/src/VisibilityState.js.map +1 -0
  145. package/dist/core/components/viewers/bim/src/lib/ViewModeCoordinator.d.ts +12 -0
  146. package/dist/core/components/viewers/bim/src/lib/ViewModeCoordinator.d.ts.map +1 -1
  147. package/dist/core/components/viewers/bim/src/lib/ViewModeCoordinator.js +15 -1
  148. package/dist/core/components/viewers/bim/src/lib/ViewModeCoordinator.js.map +1 -1
  149. package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts +75 -0
  150. package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.d.ts.map +1 -0
  151. package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js +121 -0
  152. package/dist/core/components/viewers/bim/src/lib/appearanceOverrides.js.map +1 -0
  153. package/dist/core/components/viewers/bim/src/lib/bimItemActions.d.ts +22 -0
  154. package/dist/core/components/viewers/bim/src/lib/bimItemActions.d.ts.map +1 -0
  155. package/dist/core/components/viewers/bim/src/lib/bimItemActions.js +106 -0
  156. package/dist/core/components/viewers/bim/src/lib/bimItemActions.js.map +1 -0
  157. package/dist/core/components/viewers/bim/src/lib/bimTree.d.ts +58 -0
  158. package/dist/core/components/viewers/bim/src/lib/bimTree.d.ts.map +1 -0
  159. package/dist/core/components/viewers/bim/src/lib/bimTree.js +133 -0
  160. package/dist/core/components/viewers/bim/src/lib/bimTree.js.map +1 -0
  161. package/dist/core/components/viewers/bim/src/lib/spaceOverlay.d.ts +64 -0
  162. package/dist/core/components/viewers/bim/src/lib/spaceOverlay.d.ts.map +1 -0
  163. package/dist/core/components/viewers/bim/src/lib/spaceOverlay.js +244 -0
  164. package/dist/core/components/viewers/bim/src/lib/spaceOverlay.js.map +1 -0
  165. package/dist/core/components/viewers/bim/src/lib/spatialTree.d.ts +30 -0
  166. package/dist/core/components/viewers/bim/src/lib/spatialTree.d.ts.map +1 -0
  167. package/dist/core/components/viewers/bim/src/lib/spatialTree.js +73 -0
  168. package/dist/core/components/viewers/bim/src/lib/spatialTree.js.map +1 -0
  169. package/dist/core/components/viewers/bim/src/lib/useBimTreeControls.d.ts +36 -0
  170. package/dist/core/components/viewers/bim/src/lib/useBimTreeControls.d.ts.map +1 -0
  171. package/dist/core/components/viewers/bim/src/lib/useBimTreeControls.js +138 -0
  172. package/dist/core/components/viewers/bim/src/lib/useBimTreeControls.js.map +1 -0
  173. package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingPlanes.d.ts +74 -0
  174. package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingPlanes.d.ts.map +1 -0
  175. package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingPlanes.js +261 -0
  176. package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingPlanes.js.map +1 -0
  177. package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.d.ts.map +1 -1
  178. package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.js +82 -110
  179. package/dist/core/components/viewers/bim/src/tools/ClippingTool/ClippingTool.js.map +1 -1
  180. package/dist/core/components/viewers/bim/src/tools/bimToolbar.d.ts +1 -3
  181. package/dist/core/components/viewers/bim/src/tools/bimToolbar.d.ts.map +1 -1
  182. package/dist/core/components/viewers/bim/src/tools/bimToolbar.js +2 -4
  183. package/dist/core/components/viewers/bim/src/tools/bimToolbar.js.map +1 -1
  184. package/dist/core/components/viewers/bim/src/tools/selectionBimTool.d.ts.map +1 -1
  185. package/dist/core/components/viewers/bim/src/tools/selectionBimTool.js +39 -12
  186. package/dist/core/components/viewers/bim/src/tools/selectionBimTool.js.map +1 -1
  187. package/dist/core/components/viewers/map/src/MapSidebar/index.d.ts.map +1 -1
  188. package/dist/core/components/viewers/map/src/MapSidebar/index.js +16 -31
  189. package/dist/core/components/viewers/map/src/MapSidebar/index.js.map +1 -1
  190. package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/index.d.ts.map +1 -1
  191. package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/index.js +5 -15
  192. package/dist/core/components/viewers/map/src/MapSidebar/src/FileTab/index.js.map +1 -1
  193. package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.d.ts.map +1 -1
  194. package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.js +26 -29
  195. package/dist/core/components/viewers/map/src/MapSidebar/src/LayersTab/index.js.map +1 -1
  196. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/index.d.ts +1 -1
  197. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/index.d.ts.map +1 -1
  198. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/index.js +2 -1
  199. package/dist/core/components/viewers/map/src/MapSidebar/src/SettingsTab/index.js.map +1 -1
  200. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.d.ts.map +1 -1
  201. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.js +7 -28
  202. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/index.js.map +1 -1
  203. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/FileTab/index.d.ts.map +1 -1
  204. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/FileTab/index.js +3 -2
  205. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/FileTab/index.js.map +1 -1
  206. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/SettingsTab/index.d.ts +1 -1
  207. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/SettingsTab/index.d.ts.map +1 -1
  208. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/SettingsTab/index.js +2 -3
  209. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/src/SettingsTab/index.js.map +1 -1
  210. package/dist/core/hooks/ui/useCompactTabStrip.d.ts +25 -0
  211. package/dist/core/hooks/ui/useCompactTabStrip.d.ts.map +1 -0
  212. package/dist/core/hooks/ui/useCompactTabStrip.js +33 -0
  213. package/dist/core/hooks/ui/useCompactTabStrip.js.map +1 -0
  214. package/dist/core/hooks/useUndoRedoShortcuts.d.ts +33 -0
  215. package/dist/core/hooks/useUndoRedoShortcuts.d.ts.map +1 -0
  216. package/dist/core/hooks/useUndoRedoShortcuts.js +40 -0
  217. package/dist/core/hooks/useUndoRedoShortcuts.js.map +1 -0
  218. package/dist/core/i18n/messages/en.json +32 -4
  219. package/dist/core/i18n/messages/es.json +32 -4
  220. package/dist/core/i18n/messages/fr.json +33 -5
  221. package/dist/core/utils/undoHistory.d.ts +72 -0
  222. package/dist/core/utils/undoHistory.d.ts.map +1 -0
  223. package/dist/core/utils/undoHistory.js +93 -0
  224. package/dist/core/utils/undoHistory.js.map +1 -0
  225. package/package.json +1 -1
  226. package/dist/core/components/ui/InfoSidebar/Container.d.ts +0 -10
  227. package/dist/core/components/ui/InfoSidebar/Container.d.ts.map +0 -1
  228. package/dist/core/components/ui/InfoSidebar/Container.js +0 -34
  229. package/dist/core/components/ui/InfoSidebar/Container.js.map +0 -1
  230. package/dist/core/components/ui/InfoSidebar/Header.d.ts.map +0 -1
  231. package/dist/core/components/ui/InfoSidebar/Header.js.map +0 -1
  232. package/dist/core/components/ui/InfoSidebar/index.d.ts.map +0 -1
  233. package/dist/core/components/ui/InfoSidebar/index.js.map +0 -1
  234. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/index.d.ts +0 -9
  235. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/index.d.ts.map +0 -1
  236. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/index.js +0 -14
  237. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/index.js.map +0 -1
  238. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/src/CollapsibleTopicItem.d.ts.map +0 -1
  239. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/src/CollapsibleTopicItem.js.map +0 -1
  240. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/src/CreateTopicDialog.d.ts.map +0 -1
  241. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/src/CreateTopicDialog.js.map +0 -1
  242. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/src/TopicsSection.d.ts.map +0 -1
  243. package/dist/core/components/viewers/bim/src/BimSidebar/src/CommunicationTab/src/TopicsSection.js.map +0 -1
  244. package/dist/core/components/viewers/bim/src/BimSidebar/src/SensorsTab/index.d.ts +0 -9
  245. package/dist/core/components/viewers/bim/src/BimSidebar/src/SensorsTab/index.d.ts.map +0 -1
  246. package/dist/core/components/viewers/bim/src/BimSidebar/src/SensorsTab/index.js +0 -10
  247. package/dist/core/components/viewers/bim/src/BimSidebar/src/SensorsTab/index.js.map +0 -1
  248. package/dist/core/components/viewers/bim/src/BimSidebar/src/TabSelector.d.ts +0 -9
  249. package/dist/core/components/viewers/bim/src/BimSidebar/src/TabSelector.d.ts.map +0 -1
  250. package/dist/core/components/viewers/bim/src/BimSidebar/src/TabSelector.js +0 -32
  251. package/dist/core/components/viewers/bim/src/BimSidebar/src/TabSelector.js.map +0 -1
  252. package/dist/core/components/viewers/bim/src/ClippingPlane.d.ts +0 -19
  253. package/dist/core/components/viewers/bim/src/ClippingPlane.d.ts.map +0 -1
  254. package/dist/core/components/viewers/bim/src/ClippingPlane.js +0 -86
  255. package/dist/core/components/viewers/bim/src/ClippingPlane.js.map +0 -1
  256. package/dist/core/components/viewers/map/src/MapSidebar/TabSelector.d.ts +0 -9
  257. package/dist/core/components/viewers/map/src/MapSidebar/TabSelector.d.ts.map +0 -1
  258. package/dist/core/components/viewers/map/src/MapSidebar/TabSelector.js +0 -32
  259. package/dist/core/components/viewers/map/src/MapSidebar/TabSelector.js.map +0 -1
  260. package/dist/core/components/viewers/map/src/MapSidebar/src/CommunicationTab/index.d.ts +0 -9
  261. package/dist/core/components/viewers/map/src/MapSidebar/src/CommunicationTab/index.d.ts.map +0 -1
  262. package/dist/core/components/viewers/map/src/MapSidebar/src/CommunicationTab/index.js +0 -10
  263. package/dist/core/components/viewers/map/src/MapSidebar/src/CommunicationTab/index.js.map +0 -1
  264. package/dist/core/components/viewers/map/src/MapSidebar/src/SensorsTab/index.d.ts +0 -9
  265. package/dist/core/components/viewers/map/src/MapSidebar/src/SensorsTab/index.d.ts.map +0 -1
  266. package/dist/core/components/viewers/map/src/MapSidebar/src/SensorsTab/index.js +0 -10
  267. package/dist/core/components/viewers/map/src/MapSidebar/src/SensorsTab/index.js.map +0 -1
  268. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudManagementTable.d.ts +0 -5
  269. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudManagementTable.d.ts.map +0 -1
  270. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudManagementTable.js +0 -30
  271. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudManagementTable.js.map +0 -1
  272. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudTable.d.ts +0 -8
  273. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudTable.d.ts.map +0 -1
  274. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudTable.js +0 -350
  275. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudTable.js.map +0 -1
  276. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudUploadPanel.d.ts +0 -8
  277. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudUploadPanel.d.ts.map +0 -1
  278. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudUploadPanel.js +0 -336
  279. package/dist/core/components/viewers/pointcloud/src/PointCloudManagement/PointCloudUploadPanel.js.map +0 -1
  280. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/TabSelector.d.ts +0 -9
  281. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/TabSelector.d.ts.map +0 -1
  282. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/TabSelector.js +0 -30
  283. package/dist/core/components/viewers/pointcloud/src/PointCloudSidebar/TabSelector.js.map +0 -1
  284. /package/dist/core/components/ui/{InfoSidebar → ViewerSidebar}/Header.d.ts +0 -0
  285. /package/dist/core/components/ui/{InfoSidebar → ViewerSidebar}/Header.js +0 -0
  286. /package/dist/core/components/viewers/bim/src/BimSidebar/src/{CommunicationTab → Topics}/src/CollapsibleTopicItem.d.ts +0 -0
  287. /package/dist/core/components/viewers/bim/src/BimSidebar/src/{CommunicationTab → Topics}/src/CollapsibleTopicItem.js +0 -0
  288. /package/dist/core/components/viewers/bim/src/BimSidebar/src/{CommunicationTab → Topics}/src/CreateTopicDialog.d.ts +0 -0
  289. /package/dist/core/components/viewers/bim/src/BimSidebar/src/{CommunicationTab → Topics}/src/CreateTopicDialog.js +0 -0
  290. /package/dist/core/components/viewers/bim/src/BimSidebar/src/{CommunicationTab → Topics}/src/TopicsSection.d.ts +0 -0
  291. /package/dist/core/components/viewers/bim/src/BimSidebar/src/{CommunicationTab → Topics}/src/TopicsSection.js +0 -0
@@ -5,17 +5,21 @@ import * as OBF from "@thatopen/components-front";
5
5
  import { useTranslations, useLocale } from "next-intl";
6
6
  import * as React from "react";
7
7
  import * as THREE from "three";
8
+ import { useUndoRedoShortcuts } from "../../../hooks/useUndoRedoShortcuts";
8
9
  import { ToolsContext, BimContext, MenusContext } from "../../../store";
9
10
  import { SensorLegend } from "../../ui/Sensors/SensorLegend";
10
11
  import { useBimCoordinateSystem } from "../useCoordinateSystem";
11
12
  import { BimLoadingState } from "./src/BimLoadingState";
12
13
  import { CurrentCamera } from "./src/CurrentCamera";
13
14
  import { CurrentWorld } from "./src/CurrentWorld";
15
+ import { ElementAppearance } from "./src/ElementAppearance";
14
16
  import { ElevationsTool } from "./src/ElevationsTool";
15
17
  import { FloorplanTool } from "./src/FloorplanTool";
16
18
  import { Highlighter } from "./src/Highlighter";
19
+ import { IfcClasses } from "./src/IfcClasses";
17
20
  import { ViewModeCoordinator } from "./src/lib/ViewModeCoordinator";
18
21
  import { PropertiesMenu } from "./src/propertiesMenu";
22
+ import { ClippingPlanes } from "./src/tools/ClippingTool/ClippingPlanes";
19
23
  import { ViewportGizmo } from "./src/ViewportGizmo";
20
24
  function BimViewer() {
21
25
  var _a, _b, _c;
@@ -27,6 +31,42 @@ function BimViewer() {
27
31
  const { currentToolId } = toolsState.tools;
28
32
  const { state: menusState } = React.useContext(MenusContext);
29
33
  const { currentViewer } = menusState.menus;
34
+ const lastTouchedHistory = React.useRef("appearance");
35
+ React.useEffect(() => {
36
+ if (!bimComponents) return;
37
+ const appearance = bimComponents.get(ElementAppearance);
38
+ const clipping = bimComponents.get(ClippingPlanes);
39
+ const offAppearance = appearance.history.onChanged(() => {
40
+ lastTouchedHistory.current = "appearance";
41
+ });
42
+ const offClipping = clipping.history.onChanged(() => {
43
+ lastTouchedHistory.current = "clipping";
44
+ });
45
+ return () => {
46
+ offAppearance();
47
+ offClipping();
48
+ };
49
+ }, [bimComponents]);
50
+ const undoRedoTarget = React.useCallback((direction) => {
51
+ if (!bimComponents) return null;
52
+ const appearance = bimComponents.get(ElementAppearance);
53
+ const clipping = bimComponents.get(ClippingPlanes);
54
+ const canRun = (target) => direction === "undo" ? target.history.canUndo : target.history.canRedo;
55
+ const preferred = lastTouchedHistory.current === "clipping" ? clipping : appearance;
56
+ if (canRun(preferred)) return preferred;
57
+ const other = preferred === clipping ? appearance : clipping;
58
+ return canRun(other) ? other : null;
59
+ }, [bimComponents]);
60
+ useUndoRedoShortcuts({
61
+ undo: () => {
62
+ var _a2;
63
+ void ((_a2 = undoRedoTarget("undo")) == null ? void 0 : _a2.undo());
64
+ },
65
+ redo: () => {
66
+ var _a2;
67
+ void ((_a2 = undoRedoTarget("redo")) == null ? void 0 : _a2.redo());
68
+ }
69
+ });
30
70
  const containerRef = React.useRef(null);
31
71
  const workerUrlRef = React.useRef(null);
32
72
  const resizeObserverRef = React.useRef(null);
@@ -76,7 +116,9 @@ function BimViewer() {
76
116
  components.get(CurrentWorld).world = world;
77
117
  components.get(CurrentCamera).camera = world.camera;
78
118
  components.get(Highlighter);
119
+ components.get(IfcClasses);
79
120
  components.get(ViewModeCoordinator);
121
+ components.get(ElementAppearance);
80
122
  components.get(FloorplanTool);
81
123
  components.get(ElevationsTool);
82
124
  if (grid) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../src/core/components/viewers/bim/BimViewer.tsx"],"sourcesContent":["\"use client\";\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as OBC from \"@thatopen/components\";\r\nimport * as OBF from \"@thatopen/components-front\"\r\nimport { useTranslations, useLocale } from 'next-intl';\r\nimport * as React from \"react\";\r\nimport * as THREE from \"three\";\r\n\r\nimport { ToolsContext, BimContext, MenusContext } from \"../../../store\";\r\nimport { SensorLegend } from \"../../ui/Sensors/SensorLegend\";\r\nimport { useBimCoordinateSystem } from \"../useCoordinateSystem\";\r\n\r\nimport { BimLoadingState } from \"./src/BimLoadingState\";\r\nimport { CurrentCamera } from './src/CurrentCamera';\r\nimport { CurrentWorld } from \"./src/CurrentWorld\";\r\nimport { ElevationsTool } from \"./src/ElevationsTool\";\r\nimport { FloorplanTool } from \"./src/FloorplanTool\";\r\nimport { Highlighter } from \"./src/Highlighter\";\r\nimport { ViewModeCoordinator } from \"./src/lib/ViewModeCoordinator\";\r\nimport { PropertiesMenu } from \"./src/propertiesMenu\";\r\nimport { ViewportGizmo } from \"./src/ViewportGizmo\";\r\n\r\n\r\nexport function BimViewer() {\r\n\r\n const t = useTranslations('ViewportGizmo');\r\n const locale = useLocale();\r\n\r\n const { dispatch: bimDispatch, state: bimState } = React.useContext(BimContext);\r\n const { bimComponents } = bimState.bim;\r\n\r\n const { dispatch: toolsDispatch, state: toolsState } = React.useContext(ToolsContext);\r\n const { currentToolId } = toolsState.tools;\r\n\r\n const { state: menusState } = React.useContext(MenusContext);\r\n const { currentViewer } = menusState.menus;\r\n\r\n\r\n const containerRef = React.useRef<HTMLDivElement>(null);\r\n const workerUrlRef = React.useRef<string | null>(null);\r\n const resizeObserverRef = React.useRef<ResizeObserver | null>(null);\r\n // Tracks the Components instance THIS mount created, so cleanup disposes the\r\n // real one and the create-guard can't be defeated by a stale [] closure.\r\n const componentsRef = React.useRef<OBC.Components | null>(null);\r\n\r\n const createViewer = React.useCallback(\r\n async (isCancelled: () => boolean) => {\r\n // Re-entrancy guard keyed to the ref we actually set — NOT the stale\r\n // `bimComponents` from this useCallback's [] closure (always null on\r\n // first run, so it could never stop a second init). Without this,\r\n // React StrictMode (dev) and rapid viewer remounts (prod) build a\r\n // second Components + PostproductionRenderer — a second <canvas> —\r\n // and whichever instance wins the SET_COMPONENTS race may be the one\r\n // whose canvas was detached on remount. Models then load into a scene\r\n // that is never painted: the spatial tree builds (metadata) but no\r\n // geometry shows and floorplan nav drives the dead world's camera.\r\n if (!containerRef.current || componentsRef.current) return;\r\n\r\n const container = containerRef.current;\r\n const components = new OBC.Components();\r\n const worlds = components.get(OBC.Worlds);\r\n const world = worlds.create<\r\n OBC.ShadowedScene,\r\n OBC.OrthoPerspectiveCamera,\r\n OBF.PostproductionRenderer\r\n >();\r\n\r\n world.scene = new OBC.ShadowedScene(components);\r\n\r\n world.renderer = new OBF.PostproductionRenderer(components, container);\r\n world.camera = new OBC.OrthoPerspectiveCamera(components);\r\n\r\n components.init();\r\n\r\n world.scene.setup();\r\n world.scene.three.background = null;\r\n\r\n const grids = components.get(OBC.Grids);\r\n const grid = grids.create(world);\r\n\r\n if (grid) {\r\n bimDispatch({\r\n \"type\": \"SET_GRID\",\r\n \"payload\": { grid }\r\n });\r\n }\r\n\r\n const axesHelper = new THREE.AxesHelper(5);\r\n world.scene.three.add(axesHelper);\r\n\r\n const fragments = components.get(OBC.FragmentsManager);\r\n\r\n const githubUrl =\r\n \"https://thatopen.github.io/engine_fragment/resources/worker.mjs\";\r\n const fetchedUrl = await fetch(githubUrl);\r\n const workerBlob = await fetchedUrl.blob();\r\n const workerFile = new File([workerBlob], \"worker.mjs\", {\r\n type: \"text/javascript\",\r\n });\r\n const workerUrl = URL.createObjectURL(workerFile);\r\n workerUrlRef.current = workerUrl; // Store reference for cleanup\r\n fragments.init(workerUrl);\r\n\r\n world.camera.controls.addEventListener(\"control\", () =>\r\n fragments.core.update(),\r\n );\r\n\r\n world.camera.controls.restThreshold = 0.005;\r\n world.camera.controls.addEventListener(\"rest\", () =>\r\n fragments.core.update(true)\r\n );\r\n\r\n components.get(CurrentWorld).world = world;\r\n components.get(CurrentCamera).camera = world.camera;\r\n components.get(Highlighter);\r\n components.get(ViewModeCoordinator);\r\n components.get(FloorplanTool);\r\n components.get(ElevationsTool);\r\n\r\n // Grid injection is safe here — fragments.core is initialized.\r\n if (grid) {\r\n components.get(FloorplanTool).setGrid(grid);\r\n components.get(ElevationsTool).setGrid(grid);\r\n }\r\n\r\n // Enable shadows\r\n world.renderer.three.shadowMap.enabled = true;\r\n world.renderer.three.shadowMap.type = THREE.PCFSoftShadowMap;\r\n world.scene.setup({\r\n shadows: {\r\n cascade: 1,\r\n resolution: 1024,\r\n },\r\n });\r\n\r\n world.scene.distanceRenderer.excludedObjects.add(grid.three);\r\n\r\n await world.scene.updateShadows();\r\n\r\n world.camera.controls.addEventListener(\"rest\", async () => {\r\n await world.scene.updateShadows();\r\n });\r\n\r\n world.scene.three.background = null;\r\n\r\n // If this init was superseded (StrictMode re-run) or the viewer\r\n // unmounted while we awaited the worker fetch / shadow update, throw\r\n // this instance away instead of publishing it. Prevents an orphaned\r\n // world (whose canvas is detached) from winning the store and starving\r\n // the visible canvas of geometry.\r\n if (isCancelled()) {\r\n components.dispose();\r\n return;\r\n }\r\n componentsRef.current = components;\r\n bimDispatch({\r\n type: \"SET_COMPONENTS\",\r\n payload: { bimComponents: components, world, fragments }\r\n });\r\n\r\n // Ensure canvas takes full container size\r\n const canvas = container.querySelector('canvas');\r\n if (canvas) {\r\n canvas.style.width = '100%';\r\n canvas.style.height = '100%';\r\n canvas.style.display = 'block';\r\n }\r\n\r\n // Handle resize using container dimensions\r\n const handleResize = () => {\r\n const width = container.clientWidth;\r\n const height = container.clientHeight;\r\n if (width && height) {\r\n world.renderer?.resize(new THREE.Vector2(width, height));\r\n }\r\n };\r\n\r\n // Initial resize\r\n handleResize();\r\n\r\n // Watch for container size changes using ResizeObserver. This\r\n // already covers the window-resize case: when the window resizes,\r\n // the flex layout reshapes this container, and ResizeObserver\r\n // fires.\r\n const resizeObserver = new ResizeObserver(() => {\r\n handleResize();\r\n });\r\n resizeObserver.observe(container);\r\n resizeObserverRef.current = resizeObserver;\r\n\r\n // The ResizeObserver above is sufficient for redraws. A window\r\n // 'resize' listener here previously leaked on every mount (no matching\r\n // removeEventListener), so it was removed.\r\n }, []\r\n );\r\n\r\n React.useEffect(() => {\r\n let cancelled = false;\r\n void createViewer(() => cancelled);\r\n\r\n // Cleanup: mark this init cancelled (so an in-flight createViewer disposes\r\n // itself instead of publishing), and dispose the instance we actually\r\n // created (componentsRef). The old `if (bimComponents)` read the stale []\r\n // closure value (null at mount), so the real Components was never disposed\r\n // — leaking its renderer/canvas and letting orphans race the store.\r\n return () => {\r\n cancelled = true;\r\n if (resizeObserverRef.current) {\r\n resizeObserverRef.current.disconnect();\r\n }\r\n // OBC walks components in insertion order and does not guard the loop, so one\r\n // component throwing during teardown aborts every disposal after it — including\r\n // FragmentsManager, which it deliberately leaves for last. The store must be cleared\r\n // either way, or it keeps handing out a dead Components/world to whatever mounts next.\r\n try {\r\n componentsRef.current?.dispose();\r\n } catch (error) {\r\n console.error(\"BIM teardown did not complete cleanly\", error);\r\n } finally {\r\n componentsRef.current = null;\r\n bimDispatch({\r\n type: \"DISPOSE-BIM\"\r\n });\r\n }\r\n };\r\n }, []);\r\n\r\n // Enforce Y-up coordinate system for Three.js / camera-controls.\r\n // Runs whenever the world (and its controls) becomes available, and resets on unmount.\r\n useBimCoordinateSystem(bimState.bim.world?.camera?.controls ?? null);\r\n\r\n // Control ViewportGizmo based on current viewer\r\n React.useEffect(() => {\r\n if (!bimComponents) return;\r\n\r\n const viewportGizmo = bimComponents.get(ViewportGizmo);\r\n\r\n viewportGizmo.setLabels({\r\n top: t('top'),\r\n right: t('right'),\r\n bottom: t('bottom'),\r\n left: t('left'),\r\n front: t('front'),\r\n back: t('back')\r\n });\r\n\r\n if (!viewportGizmo) return;\r\n\r\n if (currentViewer === 'bim') {\r\n viewportGizmo.enabled = true;\r\n viewportGizmo.add();\r\n } else {\r\n viewportGizmo.enabled = false;\r\n viewportGizmo.remove();\r\n }\r\n }, [bimComponents, currentViewer, locale, t]);\r\n\r\n return (\r\n <div\r\n style={{\r\n position: \"relative\",\r\n width: \"100%\",\r\n height: \"100%\",\r\n overflow: \"hidden\"\r\n }}\r\n >\r\n <BimLoadingState />\r\n <div\r\n className=\"bim-container\"\r\n id=\"bim-viewer-container\"\r\n ref={containerRef}\r\n style={{\r\n width: \"100%\",\r\n height: \"100%\",\r\n position: \"relative\",\r\n background: \"radial-gradient(circle, rgba(255, 255, 255, 1) 50%, rgba(220, 220, 220, 1) 100%)\",\r\n }}\r\n />\r\n {/* Bottom-left stack, mirroring MapViewer: cards stack upward with flex so a new\r\n overlay never needs a hand-tuned bottom offset. */}\r\n <div className=\"absolute bottom-20 md:bottom-3 left-3 z-10 flex max-w-[calc(100vw-1.5rem)] flex-col gap-2 pointer-events-none\">\r\n <SensorLegend />\r\n </div>\r\n <PropertiesMenu />\r\n </div>\r\n );\r\n}"],"mappings":";AAqQQ,SAQI,KARJ;AAhQR,YAAY,SAAS;AACrB,Y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QACJ;AAAA,QAGA,oBAAC,SAAI,WAAU,iHACX,8BAAC,gBAAa,GAClB;AAAA,QACA,oBAAC,kBAAe;AAAA;AAAA;AAAA,EACpB;AAER;","names":["_a"]}
1
+ {"version":3,"sources":["../../../../../src/core/components/viewers/bim/BimViewer.tsx"],"sourcesContent":["\"use client\";\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as OBC from \"@thatopen/components\";\r\nimport * as OBF from \"@thatopen/components-front\"\r\nimport { useTranslations, useLocale } from 'next-intl';\r\nimport * as React from \"react\";\r\nimport * as THREE from \"three\";\r\n\r\nimport { useUndoRedoShortcuts } from \"../../../hooks/useUndoRedoShortcuts\";\r\nimport { ToolsContext, BimContext, MenusContext } from \"../../../store\";\r\nimport { SensorLegend } from \"../../ui/Sensors/SensorLegend\";\r\nimport { useBimCoordinateSystem } from \"../useCoordinateSystem\";\r\n\r\nimport { BimLoadingState } from \"./src/BimLoadingState\";\r\nimport { CurrentCamera } from './src/CurrentCamera';\r\nimport { CurrentWorld } from \"./src/CurrentWorld\";\r\nimport { ElementAppearance } from \"./src/ElementAppearance\";\r\nimport { ElevationsTool } from \"./src/ElevationsTool\";\r\nimport { FloorplanTool } from \"./src/FloorplanTool\";\r\nimport { Highlighter } from \"./src/Highlighter\";\r\nimport { IfcClasses } from \"./src/IfcClasses\";\r\nimport { ViewModeCoordinator } from \"./src/lib/ViewModeCoordinator\";\r\nimport { PropertiesMenu } from \"./src/propertiesMenu\";\r\nimport { ClippingPlanes } from \"./src/tools/ClippingTool/ClippingPlanes\";\r\nimport { ViewportGizmo } from \"./src/ViewportGizmo\";\r\n\r\n\r\nexport function BimViewer() {\r\n\r\n const t = useTranslations('ViewportGizmo');\r\n const locale = useLocale();\r\n\r\n const { dispatch: bimDispatch, state: bimState } = React.useContext(BimContext);\r\n const { bimComponents } = bimState.bim;\r\n\r\n const { dispatch: toolsDispatch, state: toolsState } = React.useContext(ToolsContext);\r\n const { currentToolId } = toolsState.tools;\r\n\r\n const { state: menusState } = React.useContext(MenusContext);\r\n const { currentViewer } = menusState.menus;\r\n\r\n // Steps appearance overrides (Layers tab) and clipping planes back and\r\n // forward. Bound at the viewer rather than in the tab or the toolbar so the\r\n // shortcuts survive switching tabs, and so neither the sidebar nor the\r\n // toolbar unmounting takes the history with it.\r\n //\r\n // Each feature keeps its own stack, so one keystroke has to pick a target:\r\n // whichever stack changed most recently wins, falling back to the other when\r\n // it has nothing left. `onChanged` also fires while a stack is being\r\n // replayed, which is what keeps CTRL+Z walking down the stack the user\r\n // started on.\r\n const lastTouchedHistory = React.useRef<'appearance' | 'clipping'>('appearance');\r\n\r\n React.useEffect(() => {\r\n if (!bimComponents) return;\r\n const appearance = bimComponents.get(ElementAppearance);\r\n const clipping = bimComponents.get(ClippingPlanes);\r\n const offAppearance = appearance.history.onChanged(() => {\r\n lastTouchedHistory.current = 'appearance';\r\n });\r\n const offClipping = clipping.history.onChanged(() => {\r\n lastTouchedHistory.current = 'clipping';\r\n });\r\n return () => {\r\n offAppearance();\r\n offClipping();\r\n };\r\n }, [bimComponents]);\r\n\r\n const undoRedoTarget = React.useCallback((direction: 'undo' | 'redo') => {\r\n if (!bimComponents) return null;\r\n const appearance = bimComponents.get(ElementAppearance);\r\n const clipping = bimComponents.get(ClippingPlanes);\r\n const canRun = (target: typeof appearance | typeof clipping) =>\r\n direction === 'undo' ? target.history.canUndo : target.history.canRedo;\r\n\r\n const preferred = lastTouchedHistory.current === 'clipping' ? clipping : appearance;\r\n if (canRun(preferred)) return preferred;\r\n\r\n const other = preferred === clipping ? appearance : clipping;\r\n return canRun(other) ? other : null;\r\n }, [bimComponents]);\r\n\r\n useUndoRedoShortcuts({\r\n undo: () => { void undoRedoTarget('undo')?.undo(); },\r\n redo: () => { void undoRedoTarget('redo')?.redo(); },\r\n });\r\n\r\n\r\n const containerRef = React.useRef<HTMLDivElement>(null);\r\n const workerUrlRef = React.useRef<string | null>(null);\r\n const resizeObserverRef = React.useRef<ResizeObserver | null>(null);\r\n // Tracks the Components instance THIS mount created, so cleanup disposes the\r\n // real one and the create-guard can't be defeated by a stale [] closure.\r\n const componentsRef = React.useRef<OBC.Components | null>(null);\r\n\r\n const createViewer = React.useCallback(\r\n async (isCancelled: () => boolean) => {\r\n // Re-entrancy guard keyed to the ref we actually set — NOT the stale\r\n // `bimComponents` from this useCallback's [] closure (always null on\r\n // first run, so it could never stop a second init). Without this,\r\n // React StrictMode (dev) and rapid viewer remounts (prod) build a\r\n // second Components + PostproductionRenderer — a second <canvas> —\r\n // and whichever instance wins the SET_COMPONENTS race may be the one\r\n // whose canvas was detached on remount. Models then load into a scene\r\n // that is never painted: the spatial tree builds (metadata) but no\r\n // geometry shows and floorplan nav drives the dead world's camera.\r\n if (!containerRef.current || componentsRef.current) return;\r\n\r\n const container = containerRef.current;\r\n const components = new OBC.Components();\r\n const worlds = components.get(OBC.Worlds);\r\n const world = worlds.create<\r\n OBC.ShadowedScene,\r\n OBC.OrthoPerspectiveCamera,\r\n OBF.PostproductionRenderer\r\n >();\r\n\r\n world.scene = new OBC.ShadowedScene(components);\r\n\r\n world.renderer = new OBF.PostproductionRenderer(components, container);\r\n world.camera = new OBC.OrthoPerspectiveCamera(components);\r\n\r\n components.init();\r\n\r\n world.scene.setup();\r\n world.scene.three.background = null;\r\n\r\n const grids = components.get(OBC.Grids);\r\n const grid = grids.create(world);\r\n\r\n if (grid) {\r\n bimDispatch({\r\n \"type\": \"SET_GRID\",\r\n \"payload\": { grid }\r\n });\r\n }\r\n\r\n const axesHelper = new THREE.AxesHelper(5);\r\n world.scene.three.add(axesHelper);\r\n\r\n const fragments = components.get(OBC.FragmentsManager);\r\n\r\n const githubUrl =\r\n \"https://thatopen.github.io/engine_fragment/resources/worker.mjs\";\r\n const fetchedUrl = await fetch(githubUrl);\r\n const workerBlob = await fetchedUrl.blob();\r\n const workerFile = new File([workerBlob], \"worker.mjs\", {\r\n type: \"text/javascript\",\r\n });\r\n const workerUrl = URL.createObjectURL(workerFile);\r\n workerUrlRef.current = workerUrl; // Store reference for cleanup\r\n fragments.init(workerUrl);\r\n\r\n world.camera.controls.addEventListener(\"control\", () =>\r\n fragments.core.update(),\r\n );\r\n\r\n world.camera.controls.restThreshold = 0.005;\r\n world.camera.controls.addEventListener(\"rest\", () =>\r\n fragments.core.update(true)\r\n );\r\n\r\n components.get(CurrentWorld).world = world;\r\n components.get(CurrentCamera).camera = world.camera;\r\n components.get(Highlighter);\r\n // Registered up front so it subscribes to model loads before any\r\n // model arrives, rather than when the sidebar first opens.\r\n components.get(IfcClasses);\r\n components.get(ViewModeCoordinator);\r\n // Same reason: it has to hear about model loads and about drawing\r\n // modes releasing the viewer, both of which need its overrides\r\n // repainted, whether or not the Layers tab has ever been opened.\r\n components.get(ElementAppearance);\r\n components.get(FloorplanTool);\r\n components.get(ElevationsTool);\r\n\r\n // Grid injection is safe here — fragments.core is initialized.\r\n if (grid) {\r\n components.get(FloorplanTool).setGrid(grid);\r\n components.get(ElevationsTool).setGrid(grid);\r\n }\r\n\r\n // Enable shadows\r\n world.renderer.three.shadowMap.enabled = true;\r\n world.renderer.three.shadowMap.type = THREE.PCFSoftShadowMap;\r\n world.scene.setup({\r\n shadows: {\r\n cascade: 1,\r\n resolution: 1024,\r\n },\r\n });\r\n\r\n world.scene.distanceRenderer.excludedObjects.add(grid.three);\r\n\r\n await world.scene.updateShadows();\r\n\r\n world.camera.controls.addEventListener(\"rest\", async () => {\r\n await world.scene.updateShadows();\r\n });\r\n\r\n world.scene.three.background = null;\r\n\r\n // If this init was superseded (StrictMode re-run) or the viewer\r\n // unmounted while we awaited the worker fetch / shadow update, throw\r\n // this instance away instead of publishing it. Prevents an orphaned\r\n // world (whose canvas is detached) from winning the store and starving\r\n // the visible canvas of geometry.\r\n if (isCancelled()) {\r\n components.dispose();\r\n return;\r\n }\r\n componentsRef.current = components;\r\n bimDispatch({\r\n type: \"SET_COMPONENTS\",\r\n payload: { bimComponents: components, world, fragments }\r\n });\r\n\r\n // Ensure canvas takes full container size\r\n const canvas = container.querySelector('canvas');\r\n if (canvas) {\r\n canvas.style.width = '100%';\r\n canvas.style.height = '100%';\r\n canvas.style.display = 'block';\r\n }\r\n\r\n // Handle resize using container dimensions\r\n const handleResize = () => {\r\n const width = container.clientWidth;\r\n const height = container.clientHeight;\r\n if (width && height) {\r\n world.renderer?.resize(new THREE.Vector2(width, height));\r\n }\r\n };\r\n\r\n // Initial resize\r\n handleResize();\r\n\r\n // Watch for container size changes using ResizeObserver. This\r\n // already covers the window-resize case: when the window resizes,\r\n // the flex layout reshapes this container, and ResizeObserver\r\n // fires.\r\n const resizeObserver = new ResizeObserver(() => {\r\n handleResize();\r\n });\r\n resizeObserver.observe(container);\r\n resizeObserverRef.current = resizeObserver;\r\n\r\n // The ResizeObserver above is sufficient for redraws. A window\r\n // 'resize' listener here previously leaked on every mount (no matching\r\n // removeEventListener), so it was removed.\r\n }, []\r\n );\r\n\r\n React.useEffect(() => {\r\n let cancelled = false;\r\n void createViewer(() => cancelled);\r\n\r\n // Cleanup: mark this init cancelled (so an in-flight createViewer disposes\r\n // itself instead of publishing), and dispose the instance we actually\r\n // created (componentsRef). The old `if (bimComponents)` read the stale []\r\n // closure value (null at mount), so the real Components was never disposed\r\n // — leaking its renderer/canvas and letting orphans race the store.\r\n return () => {\r\n cancelled = true;\r\n if (resizeObserverRef.current) {\r\n resizeObserverRef.current.disconnect();\r\n }\r\n // OBC walks components in insertion order and does not guard the loop, so one\r\n // component throwing during teardown aborts every disposal after it — including\r\n // FragmentsManager, which it deliberately leaves for last. The store must be cleared\r\n // either way, or it keeps handing out a dead Components/world to whatever mounts next.\r\n try {\r\n componentsRef.current?.dispose();\r\n } catch (error) {\r\n console.error(\"BIM teardown did not complete cleanly\", error);\r\n } finally {\r\n componentsRef.current = null;\r\n bimDispatch({\r\n type: \"DISPOSE-BIM\"\r\n });\r\n }\r\n };\r\n }, []);\r\n\r\n // Enforce Y-up coordinate system for Three.js / camera-controls.\r\n // Runs whenever the world (and its controls) becomes available, and resets on unmount.\r\n useBimCoordinateSystem(bimState.bim.world?.camera?.controls ?? null);\r\n\r\n // Control ViewportGizmo based on current viewer\r\n React.useEffect(() => {\r\n if (!bimComponents) return;\r\n\r\n const viewportGizmo = bimComponents.get(ViewportGizmo);\r\n\r\n viewportGizmo.setLabels({\r\n top: t('top'),\r\n right: t('right'),\r\n bottom: t('bottom'),\r\n left: t('left'),\r\n front: t('front'),\r\n back: t('back')\r\n });\r\n\r\n if (!viewportGizmo) return;\r\n\r\n if (currentViewer === 'bim') {\r\n viewportGizmo.enabled = true;\r\n viewportGizmo.add();\r\n } else {\r\n viewportGizmo.enabled = false;\r\n viewportGizmo.remove();\r\n }\r\n }, [bimComponents, currentViewer, locale, t]);\r\n\r\n return (\r\n <div\r\n style={{\r\n position: \"relative\",\r\n width: \"100%\",\r\n height: \"100%\",\r\n overflow: \"hidden\"\r\n }}\r\n >\r\n <BimLoadingState />\r\n <div\r\n className=\"bim-container\"\r\n id=\"bim-viewer-container\"\r\n ref={containerRef}\r\n style={{\r\n width: \"100%\",\r\n height: \"100%\",\r\n position: \"relative\",\r\n background: \"radial-gradient(circle, rgba(255, 255, 255, 1) 50%, rgba(220, 220, 220, 1) 100%)\",\r\n }}\r\n />\r\n {/* Bottom-left stack, mirroring MapViewer: cards stack upward with flex so a new\r\n overlay never needs a hand-tuned bottom offset. */}\r\n <div className=\"absolute bottom-20 md:bottom-3 left-3 z-10 flex max-w-[calc(100vw-1.5rem)] flex-col gap-2 pointer-events-none\">\r\n <SensorLegend />\r\n </div>\r\n <PropertiesMenu />\r\n </div>\r\n );\r\n}"],"mappings":";AA+TQ,SAQI,KARJ;AA1TR,YAAY,SAAS;AACrB,YAAY,SAAS;AACrB,SAAS,iBAAiB,iBAAiB;AAC3C,YAAY,WAAW;AACvB,YAAY,WAAW;AAEvB,SAAS,4BAA4B;AACrC,SAAS,cAAc,YAAY,oBAAoB;AACvD,SAAS,oBAAo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file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/FileTab/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAY5B,wBAAgB,OAAO,sBA2CxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/FileTab/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAW9B,wBAAgB,OAAO,sBAkCtB"}
@@ -4,17 +4,16 @@ import { useSearchParams } from "next/navigation";
4
4
  import * as React from "react";
5
5
  import { useFilesByBuildingId } from "../../../../../../../hooks/files/files";
6
6
  import { BuildingsContext } from "../../../../../../../store";
7
- import { SearchInput } from "../../../../../../ui";
7
+ import { ViewerSidebarPanel } from "../../../../../../ui/ViewerSidebar/Panel";
8
8
  import { FilesSection } from "./src/FilesSection";
9
9
  import { ModelsSection } from "./src/ModelsSection";
10
10
  function FileTab() {
11
+ var _a;
11
12
  const { state: buildingState } = React.useContext(BuildingsContext);
12
13
  const { building } = buildingState.buildings;
13
- let buildingId;
14
14
  const [searchQuery, setSearchQuery] = React.useState("");
15
15
  const urlBuildingId = useSearchParams().get("buildingId");
16
- if (building) buildingId = building.id;
17
- else if (urlBuildingId) buildingId = Number(urlBuildingId);
16
+ const buildingId = (_a = building == null ? void 0 : building.id) != null ? _a : urlBuildingId ? Number(urlBuildingId) : void 0;
18
17
  const filesData = useFilesByBuildingId(buildingId).files || [];
19
18
  const bimFiles = [];
20
19
  const nonBimFiles = [];
@@ -28,15 +27,7 @@ function FileTab() {
28
27
  nonBimFiles.push(file);
29
28
  }
30
29
  });
31
- return /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col space-y-6 py-4 overflow-hidden", children: [
32
- /* @__PURE__ */ jsx("div", { className: "px-4", children: /* @__PURE__ */ jsx(
33
- SearchInput,
34
- {
35
- placeholder: "Search...",
36
- value: searchQuery,
37
- onChange: (e) => setSearchQuery(e.target.value)
38
- }
39
- ) }),
30
+ return /* @__PURE__ */ jsxs(ViewerSidebarPanel, { search: { value: searchQuery, onChange: setSearchQuery }, children: [
40
31
  /* @__PURE__ */ jsx(ModelsSection, { files: bimFiles, query: searchQuery }),
41
32
  /* @__PURE__ */ jsx(FilesSection, { files: nonBimFiles, query: searchQuery })
42
33
  ] });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/FileTab/index.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { useSearchParams } from 'next/navigation'\r\nimport * as React from 'react'\r\n\r\nimport { useFilesByBuildingId } from '../../../../../../../hooks/files/files'\r\nimport { BuildingsContext } from '../../../../../../../store'\r\nimport { SearchInput } from '../../../../../../ui'\r\n\r\nimport { FilesSection } from './src/FilesSection'\r\nimport { ModelsSection } from './src/ModelsSection'\r\n\r\nimport type { DbFile } from '../../../../../../../types/dbTypes'\r\n\r\n\r\n export function FileTab() {\r\n const { state: buildingState } = React.useContext(BuildingsContext)\r\n const { building } = buildingState.buildings\r\n let buildingId:number;\r\n const [searchQuery, setSearchQuery] = React.useState('')\r\n\r\n const urlBuildingId = useSearchParams().get('buildingId')\r\n\r\n if (building) buildingId = building.id\r\n else if (urlBuildingId) buildingId = Number(urlBuildingId)\r\n\r\n const filesData: DbFile[] = useFilesByBuildingId(buildingId).files || []\r\n\r\n const bimFiles: DbFile[] = []\r\n const nonBimFiles: DbFile[] = []\r\n\r\n // single pass to populate both arrays\r\n filesData.forEach((file) => {\r\n const {extension} = file\r\n if (!extension) return\r\n const isBim = extension.toLowerCase() === 'ifc' || extension.toLowerCase() === 'frag'\r\n\r\n if (isBim) {\r\n bimFiles.push(file)\r\n } else {\r\n nonBimFiles.push(file)\r\n }\r\n })\r\n\r\n\r\n return (\r\n <div className=\"flex-1 flex flex-col space-y-6 py-4 overflow-hidden\">\r\n <div className=\"px-4\">\r\n <SearchInput\r\n placeholder=\"Search...\"\r\n value={searchQuery}\r\n onChange={e => setSearchQuery(e.target.value)}\r\n />\r\n </div>\r\n <ModelsSection files={bimFiles} query={searchQuery} />\r\n <FilesSection files={nonBimFiles} query={searchQuery} />\r\n </div>\r\n )\r\n}\r\n"],"mappings":";AAiDI,SAEI,KAFJ;AA5CJ,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAE5B,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAKrB,SAAS,UAAU;AACxB,QAAM,EAAE,OAAO,cAAc,IAAI,MAAM,WAAW,gBAAgB;AAClE,QAAM,EAAE,SAAS,IAAI,cAAc;AACnC,MAAI;AACJ,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAS,EAAE;AAEzD,QAAM,gBAAgB,gBAAgB,EAAE,IAAI,YAAY;AAExD,MAAI,SAAU,cAAa,SAAS;AAAA,WAC3B,cAAe,cAAa,OAAO,aAAa;AAEzD,QAAM,YAAsB,qBAAqB,UAAU,EAAE,SAAS,CAAC;AAEvE,QAAM,WAAqB,CAAC;AAC5B,QAAM,cAAwB,CAAC;AAG/B,YAAU,QAAQ,CAAC,SAAS;AAC1B,UAAM,EAAC,UAAS,IAAI;AACpB,QAAI,CAAC,UAAW;AAChB,UAAM,QAAQ,UAAU,YAAY,MAAM,SAAS,UAAU,YAAY,MAAM;AAE/E,QAAI,OAAO;AACT,eAAS,KAAK,IAAI;AAAA,IACpB,OAAO;AACL,kBAAY,KAAK,IAAI;AAAA,IACvB;AAAA,EACF,CAAC;AAGD,SACE,qBAAC,SAAI,WAAU,uDACb;AAAA,wBAAC,SAAI,WAAU,QACb;AAAA,MAAC;AAAA;AAAA,QACC,aAAY;AAAA,QACZ,OAAO;AAAA,QACP,UAAU,OAAK,eAAe,EAAE,OAAO,KAAK;AAAA;AAAA,IAC9C,GACF;AAAA,IACA,oBAAC,iBAAc,OAAO,UAAU,OAAO,aAAa;AAAA,IACpD,oBAAC,gBAAa,OAAO,aAAa,OAAO,aAAa;AAAA,KACxD;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/FileTab/index.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport { useSearchParams } from 'next/navigation'\r\nimport * as React from 'react'\r\n\r\nimport { useFilesByBuildingId } from '../../../../../../../hooks/files/files'\r\nimport { BuildingsContext } from '../../../../../../../store'\r\nimport { ViewerSidebarPanel } from '../../../../../../ui/ViewerSidebar/Panel'\r\n\r\nimport { FilesSection } from './src/FilesSection'\r\nimport { ModelsSection } from './src/ModelsSection'\r\n\r\nimport type { DbFile } from '../../../../../../../types/dbTypes'\r\n\r\nexport function FileTab() {\r\n const { state: buildingState } = React.useContext(BuildingsContext)\r\n const { building } = buildingState.buildings\r\n const [searchQuery, setSearchQuery] = React.useState('')\r\n\r\n const urlBuildingId = useSearchParams().get('buildingId')\r\n // Resolve from the store building, else the URL param; undefined if neither is\r\n // ready yet (e.g. mid viewer-switch) — the hook handles undefined → no files.\r\n const buildingId = building?.id ?? (urlBuildingId ? Number(urlBuildingId) : undefined)\r\n\r\n const filesData: DbFile[] = useFilesByBuildingId(buildingId).files || []\r\n\r\n const bimFiles: DbFile[] = []\r\n const nonBimFiles: DbFile[] = []\r\n\r\n // single pass to populate both arrays\r\n filesData.forEach((file) => {\r\n const { extension } = file\r\n if (!extension) return\r\n const isBim = extension.toLowerCase() === 'ifc' || extension.toLowerCase() === 'frag'\r\n\r\n if (isBim) {\r\n bimFiles.push(file)\r\n } else {\r\n nonBimFiles.push(file)\r\n }\r\n })\r\n\r\n return (\r\n <ViewerSidebarPanel search={{ value: searchQuery, onChange: setSearchQuery }}>\r\n <ModelsSection files={bimFiles} query={searchQuery} />\r\n <FilesSection files={nonBimFiles} query={searchQuery} />\r\n </ViewerSidebarPanel>\r\n )\r\n}\r\n"],"mappings":";AA8CI,SACE,KADF;AAzCJ,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AAEnC,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAIvB,SAAS,UAAU;AAjB1B;AAkBE,QAAM,EAAE,OAAO,cAAc,IAAI,MAAM,WAAW,gBAAgB;AAClE,QAAM,EAAE,SAAS,IAAI,cAAc;AACnC,QAAM,CAAC,aAAa,cAAc,IAAI,MAAM,SAAS,EAAE;AAEvD,QAAM,gBAAgB,gBAAgB,EAAE,IAAI,YAAY;AAGxD,QAAM,cAAa,0CAAU,OAAV,YAAiB,gBAAgB,OAAO,aAAa,IAAI;AAE5E,QAAM,YAAsB,qBAAqB,UAAU,EAAE,SAAS,CAAC;AAEvE,QAAM,WAAqB,CAAC;AAC5B,QAAM,cAAwB,CAAC;AAG/B,YAAU,QAAQ,CAAC,SAAS;AAC1B,UAAM,EAAE,UAAU,IAAI;AACtB,QAAI,CAAC,UAAW;AAChB,UAAM,QAAQ,UAAU,YAAY,MAAM,SAAS,UAAU,YAAY,MAAM;AAE/E,QAAI,OAAO;AACT,eAAS,KAAK,IAAI;AAAA,IACpB,OAAO;AACL,kBAAY,KAAK,IAAI;AAAA,IACvB;AAAA,EACF,CAAC;AAED,SACE,qBAAC,sBAAmB,QAAQ,EAAE,OAAO,aAAa,UAAU,eAAe,GACzE;AAAA,wBAAC,iBAAc,OAAO,UAAU,OAAO,aAAa;AAAA,IACpD,oBAAC,gBAAa,OAAO,aAAa,OAAO,aAAa;AAAA,KACxD;AAEJ;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"ModelsSection.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAc9B,OAAO,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,uCAAuC,CAAA;AAI7E,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,KAAU,EAAE,EAAE,kBAAkB,qBAgTtE"}
1
+ {"version":3,"file":"ModelsSection.d.ts","sourceRoot":"","sources":["../../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAe9B,OAAO,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,uCAAuC,CAAA;AAI7E,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,wBAAgB,aAAa,CAAC,EAAE,KAAK,EAAE,KAAU,EAAE,EAAE,kBAAkB,qBAuTtE"}
@@ -33,6 +33,7 @@ import { CurrentWorld } from "../../../../CurrentWorld";
33
33
  import { GhostMode } from "../../../../GhostMode";
34
34
  import { Highlighter } from "../../../../Highlighter";
35
35
  import { ModelManager } from "../../../../ModelManager";
36
+ import { SpatialStructure } from "../../../../SpatialStructure";
36
37
  const BIM_MODEL_OPTIONS = ["view", "ghost", "move", "info", "delete"];
37
38
  function ModelsSection({ files, query = "" }) {
38
39
  const t = useTranslations("FileItemComponent");
@@ -152,6 +153,10 @@ function ModelsSection({ files, query = "" }) {
152
153
  console.error(`Failed to dispose fragment model "${file.name}":`, err);
153
154
  });
154
155
  bimManager == null ? void 0 : bimManager.remove(file.name);
156
+ try {
157
+ bimComponents == null ? void 0 : bimComponents.get(SpatialStructure).clearForModel(file.name);
158
+ } catch (e) {
159
+ }
155
160
  }
156
161
  }
157
162
  }, [modelManager, bimComponents, fragments, bimManager]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\nimport { useUploadFileToBuilding, useDeleteFile, useFile } from '../../../../../../../../hooks/files/files'\r\nimport { BimContext, BuildingsContext } from '../../../../../../../../store'\r\nimport ConfirmDialog from '../../../../../../../ConfirmDialog'\r\nimport { CollapsibleSection } from '../../../../../../../ui/CollapsibleSection'\r\nimport { useFileUploadHandler, useFileDeleteHandler, FileItemComponent, useFileActions, useCommonFileUpload } from '../../../../../../../ui/FilesManager'\r\nimport { GizmoController } from '../../../../../utils/GizmoController'\r\nimport { BIMManager } from '../../../../BIMManager'\r\nimport { CurrentWorld } from '../../../../CurrentWorld'\r\nimport { GhostMode } from '../../../../GhostMode'\r\nimport { Highlighter } from '../../../../Highlighter'\r\nimport { ModelManager } from '../../../../ModelManager'\r\n\r\nimport type { DbFile as DbFile } from '../../../../../../../../types/dbTypes'\r\n\r\nconst BIM_MODEL_OPTIONS: import('../../../../../../../../types/global').FileAction[] = ['view', 'ghost', 'move', 'info', 'delete']\r\n\r\ninterface ModelsSectionProps {\r\n files: DbFile[]\r\n query?: string\r\n}\r\n\r\nexport function ModelsSection({ files, query = '' }: ModelsSectionProps) {\r\n // Translation\r\n const t = useTranslations('FileItemComponent')\r\n\r\n // Get BIM context\r\n const { state: bimState, dispatch: bimDispatch } = React.useContext(BimContext)\r\n const { bimComponents, fragments, modelId, modelUIState } = bimState.bim\r\n\r\n // Get Buildings context for buildingId\r\n const { state: buildingsState } = React.useContext(BuildingsContext)\r\n const { building } = buildingsState.buildings\r\n const buildingId = building?.id || 0\r\n\r\n // Upload file hook and session\r\n const { uploadFile } = useUploadFileToBuilding(buildingId)\r\n const { deleteFile } = useDeleteFile(buildingId)\r\n\r\n // Use the reusable upload handler\r\n const { handleFileUpload } = useFileUploadHandler({\r\n buildingId,\r\n tag: 'bim-file',\r\n isVisible: true,\r\n uploadFile,\r\n })\r\n\r\n // Use the reusable delete handler\r\n const { handleDeleteFile } = useFileDeleteHandler({\r\n deleteFile,\r\n\r\n })\r\n\r\n // Local state for file management with isVisible property\r\n const [loadedModels, setLoadedModels] = React.useState<(DbFile & { isVisible?: boolean })[]>(\r\n files.map(file => ({\r\n ...file,\r\n isVisible: modelUIState[file.id]?.isVisible ?? (file as any).isVisible,\r\n isGhost: modelUIState[file.id]?.isGhost ?? false,\r\n }))\r\n )\r\n\r\n // Keep local list in sync with incoming props and store UI state changes\r\n React.useEffect(() => {\r\n setLoadedModels(prev => {\r\n const prevMap = new Map(prev.map(f => [f.id, f as any]))\r\n return files.map(file => ({\r\n ...file,\r\n isVisible: modelUIState[file.id]?.isVisible ?? (file as any).isVisible,\r\n isGhost: modelUIState[file.id]?.isGhost ?? prevMap.get(file.id)?.isGhost ?? false,\r\n }))\r\n })\r\n }, [files, modelUIState])\r\n\r\n // Get ModelManager from BIM components\r\n const modelManager = React.useMemo(() => {\r\n if (!bimComponents) return null\r\n try {\r\n return bimComponents.get(ModelManager)\r\n }\r\n catch {\r\n return null\r\n }\r\n }, [bimComponents])\r\n\r\n // Get BIMManager from BIM components\r\n const bimManager = React.useMemo(() => {\r\n if (!bimComponents) return null\r\n try {\r\n return bimComponents.get(BIMManager)\r\n }\r\n catch {\r\n return null\r\n }\r\n }, [bimComponents])\r\n\r\n // Get GhostMode from BIM components\r\n const ghostMode = React.useMemo(() => {\r\n if (!bimComponents) return null\r\n try {\r\n return bimComponents.get(GhostMode)\r\n }\r\n catch {\r\n return null\r\n }\r\n }, [bimComponents])\r\n\r\n // Gizmo controllers keyed by model's file.name (one gizmo per model at most)\r\n const gizmoControllersRef = React.useRef<Map<string, GizmoController>>(new Map())\r\n\r\n // Track the file ID currently being repositioned so useFile can provide updateFile\r\n const [moveFileId, setMoveFileId] = React.useState<number | null>(null)\r\n const { updateFile } = useFile(moveFileId)\r\n const updateFileRef = React.useRef(updateFile)\r\n React.useEffect(() => { updateFileRef.current = updateFile }, [updateFile])\r\n\r\n // Get Highlighter from BIM components\r\n const highlighter = React.useMemo(() => {\r\n if (!bimComponents) return null\r\n try {\r\n return bimComponents.get(Highlighter)\r\n }\r\n catch {\r\n return null\r\n }\r\n }, [bimComponents])\r\n\r\n // Custom handlers for BIM-specific actions (view and delete only - download uses default)\r\n const handleBimView = React.useCallback((file: DbFile, newVisibility: boolean) => {\r\n bimDispatch({ type: 'SET_MODEL_UI_STATE', payload: { fileId: file.id, isVisible: newVisibility } })\r\n\r\n // Disable highlighting for hidden models; re-enable only when visible and not ghosted\r\n if (highlighter) {\r\n const isGhosted = modelUIState[file.id]?.isGhost ?? false\r\n if (!newVisibility || isGhosted) {\r\n highlighter.disableModel(file.name)\r\n } else {\r\n highlighter.enableModel(file.name)\r\n }\r\n }\r\n\r\n // Non-fragment models (gltf/obj/fbx) managed by ModelManager\r\n if (modelManager) {\r\n const modelInfo = modelManager.getModel(file.id.toString())\r\n if (modelInfo) {\r\n modelInfo.model.visible = newVisibility\r\n if (fragments) void fragments.core.update(true)\r\n return\r\n }\r\n }\r\n\r\n // Fragment (IFC/FRAG) models — look up directly from fragments list by file.name\r\n if (fragments) {\r\n const fragModel = fragments.core.models.list.get(file.name)\r\n if (fragModel) {\r\n fragModel.object.visible = newVisibility\r\n void fragments.core.update(true)\r\n } else {\r\n }\r\n }\r\n }, [modelManager, fragments, highlighter, modelUIState])\r\n\r\n const handleBimDelete = React.useCallback((file: DbFile) => {\r\n // Remove from ModelManager if it exists (gltf/obj/fbx models)\r\n if (modelManager) {\r\n const modelIdStr = file.id.toString()\r\n modelManager.remove(modelIdStr)\r\n }\r\n\r\n // Remove fragment model from scene if it exists (ifc/frag models)\r\n if (fragments) {\r\n const fragModel = fragments.core.models.list.get(file.name)\r\n if (fragModel) {\r\n fragments.core.disposeModel(fragModel.modelId).catch((err: unknown) => {\r\n console.error(`Failed to dispose fragment model \"${file.name}\":`, err)\r\n })\r\n // Also clean up BIMManager tracking\r\n bimManager?.remove(file.name)\r\n }\r\n }\r\n }, [modelManager, bimComponents, fragments, bimManager])\r\n\r\n const handleBimMove = React.useCallback((file: DbFile) => {\r\n if (!bimComponents || !fragments) return\r\n\r\n const world = bimComponents.get(CurrentWorld).world\r\n if (!world) return\r\n\r\n const fragModel = fragments.core.models.list.get(file.name)\r\n if (!fragModel) {\r\n console.warn(`[BimMove] Model not found: \"${file.name}\"`)\r\n return\r\n }\r\n\r\n const existing = gizmoControllersRef.current.get(file.name)\r\n if (existing) {\r\n // Toggle off: destroy the gizmo\r\n existing.dispose()\r\n gizmoControllersRef.current.delete(file.name)\r\n if (gizmoControllersRef.current.size === 0 && highlighter) highlighter.enabled = true\r\n } else {\r\n // Toggle on: create a new gizmo attached to the model's root object\r\n const gizmo = new GizmoController(world)\r\n const cleanupGizmo = (savePosition: boolean) => {\r\n if (savePosition) {\r\n const { x, y, z } = fragModel.object.position\r\n const rotation = fragModel.object.rotation.y\r\n updateFileRef.current({ x, y, z, rotation } as any)\r\n .catch((err: unknown) => console.error(`[BimMove] Failed to save position for \"${file.name}\":`, err))\r\n file.x = x\r\n file.y = y\r\n file.z = z\r\n file.rotation = rotation\r\n }\r\n gizmoControllersRef.current.delete(file.name)\r\n if (gizmoControllersRef.current.size === 0 && highlighter) highlighter.enabled = true\r\n setMoveFileId(null)\r\n }\r\n gizmo.onAccept = () => cleanupGizmo(true)\r\n gizmo.onCancel = () => cleanupGizmo(false)\r\n setMoveFileId(file.id)\r\n if (highlighter) highlighter.enabled = false\r\n gizmo.attach(fragModel.object)\r\n gizmoControllersRef.current.set(file.name, gizmo)\r\n }\r\n }, [bimComponents, fragments, highlighter])\r\n\r\n const handleBimGhost = React.useCallback((file: DbFile, ghostState: boolean) => {\r\n if (!fragments || !ghostMode) return\r\n\r\n const fragModel = fragments.core.models.list.get(file.name)\r\n if (!fragModel) {\r\n console.warn(`[BimGhost] Model not found: \"${file.name}\"`)\r\n return\r\n }\r\n\r\n ghostMode.setModelGhost(fragModel, ghostState)\r\n bimDispatch({ type: 'SET_MODEL_UI_STATE', payload: { fileId: file.id, isGhost: ghostState } })\r\n\r\n // Disable highlighting for ghosted models; re-enable only when visible and not ghosted\r\n if (highlighter) {\r\n const isVisible = modelUIState[file.id]?.isVisible ?? true\r\n if (ghostState || !isVisible) {\r\n highlighter.disableModel(file.name)\r\n } else {\r\n highlighter.enableModel(file.name)\r\n }\r\n }\r\n }, [fragments, ghostMode, bimDispatch, highlighter, modelUIState])\r\n\r\n // Use the common file actions hook (no custom download handler - use default for all files)\r\n const { handleAction, deleteDialog } = useFileActions({\r\n files: loadedModels,\r\n setFiles: setLoadedModels,\r\n buildingId,\r\n handleDeleteFile,\r\n onView: handleBimView,\r\n onDelete: handleBimDelete,\r\n onMove: handleBimMove,\r\n onGhost: handleBimGhost\r\n })\r\n\r\n // Use the common file upload hook\r\n const { handleAddFile } = useCommonFileUpload({\r\n buildingId,\r\n acceptedFileTypes: '.ifc,.frag',\r\n handleFileUpload,\r\n onUploadError: (error) => {\r\n console.error('Error uploading model:', error)\r\n }\r\n })\r\n\r\n // Filter models based on search query\r\n const filteredModels = React.useMemo(() => {\r\n if (!query.trim()) return loadedModels\r\n return loadedModels.filter(file =>\r\n file.name.toLowerCase().includes(query.toLowerCase())\r\n )\r\n }, [loadedModels, query])\r\n\r\n const areAllHidden = loadedModels.every(f => !f.isVisible)\r\n\r\n const handleSwitchVariant = () => ({\r\n checked: !areAllHidden,\r\n onCheckedChange: (checked: boolean) => {\r\n setLoadedModels(prev => prev.map(f => ({ ...f, isVisible: checked })))\r\n // Toggle visibility in 3D scene for all models\r\n for (const file of loadedModels) {\r\n handleBimView(file, checked)\r\n }\r\n },\r\n })\r\n\r\n return (\r\n <>\r\n <CollapsibleSection\r\n title={t('modelsTitles')}\r\n icon={LR.Box}\r\n className=\"max-h-40 overflow-y-auto\"\r\n itemCount={filteredModels.length}\r\n onAddItem={handleAddFile}\r\n addItemTitle={t('addBimTitle')}\r\n switchVariant={handleSwitchVariant()}\r\n >\r\n <div className=\"space-y-1\">\r\n {filteredModels.map((file) => (\r\n <FileItemComponent\r\n key={file.id}\r\n file={file}\r\n onAction={handleAction}\r\n options={BIM_MODEL_OPTIONS}\r\n confirmDelete={false}\r\n />\r\n ))}\r\n </div>\r\n </CollapsibleSection>\r\n\r\n <ConfirmDialog\r\n isOpen={deleteDialog.isOpen}\r\n isDeleting={deleteDialog.isDeleting}\r\n onOpenChange={deleteDialog.onOpenChange}\r\n handleConfirm={deleteDialog.onConfirm}\r\n itemName={deleteDialog.itemName}\r\n />\r\n </>\r\n )\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8SI,mBAYQ,KAZR;AAzSJ,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,yBAAyB,eAAe,eAAe;AAChE,SAAS,YAAY,wBAAwB;AAC7C,OAAO,mBAAmB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,sBAAsB,sBAAsB,mBAAmB,gBAAgB,2BAA2B;AACnH,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAI7B,MAAM,oBAAiF,CAAC,QAAQ,SAAS,QAAQ,QAAQ,QAAQ;AAO1H,SAAS,cAAc,EAAE,OAAO,QAAQ,GAAG,GAAuB;AAEvE,QAAM,IAAI,gBAAgB,mBAAmB;AAG7C,QAAM,EAAE,OAAO,UAAU,UAAU,YAAY,IAAI,MAAM,WAAW,UAAU;AAC9E,QAAM,EAAE,eAAe,WAAW,SAAS,aAAa,IAAI,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,iCAAK,IAAL,EAAQ,WAAW,QAAQ,EAAE,CAAC;AAErE,iBAAW,QAAQ,cAAc;AAC/B,sBAAc,MAAM,OAAO;AAAA,MAC7B;AAAA,IACF;AAAA,EACF;AAEA,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,EAAE,cAAc;AAAA,QACvB,MAAM,GAAG;AAAA,QACT,WAAU;AAAA,QACV,WAAW,eAAe;AAAA,QAC1B,WAAW;AAAA,QACX,cAAc,EAAE,aAAa;AAAA,QAC7B,eAAe,oBAAoB;AAAA,QAEnC,8BAAC,SAAI,WAAU,aACZ,yBAAe,IAAI,CAAC,SACnB;AAAA,UAAC;AAAA;AAAA,YAEC;AAAA,YACA,UAAU;AAAA,YACV,SAAS;AAAA,YACT,eAAe;AAAA;AAAA,UAJV,KAAK;AAAA,QAKZ,CACD,GACH;AAAA;AAAA,IACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,aAAa;AAAA,QACrB,YAAY,aAAa;AAAA,QACzB,cAAc,aAAa;AAAA,QAC3B,eAAe,aAAa;AAAA,QAC5B,UAAU,aAAa;AAAA;AAAA,IACzB;AAAA,KACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/FileTab/src/ModelsSection.tsx"],"sourcesContent":["'use client'\r\n\r\n// SPDX-License-Identifier: AGPL-3.0-or-later\r\n// Copyright (C) 2025 Collab Digital Twins\r\n\r\nimport * as LR from 'lucide-react'\r\nimport { useTranslations } from 'next-intl'\r\nimport * as React from 'react'\r\n\r\nimport { useUploadFileToBuilding, useDeleteFile, useFile } from '../../../../../../../../hooks/files/files'\r\nimport { BimContext, BuildingsContext } from '../../../../../../../../store'\r\nimport ConfirmDialog from '../../../../../../../ConfirmDialog'\r\nimport { CollapsibleSection } from '../../../../../../../ui/CollapsibleSection'\r\nimport { useFileUploadHandler, useFileDeleteHandler, FileItemComponent, useFileActions, useCommonFileUpload } from '../../../../../../../ui/FilesManager'\r\nimport { GizmoController } from '../../../../../utils/GizmoController'\r\nimport { BIMManager } from '../../../../BIMManager'\r\nimport { CurrentWorld } from '../../../../CurrentWorld'\r\nimport { GhostMode } from '../../../../GhostMode'\r\nimport { Highlighter } from '../../../../Highlighter'\r\nimport { ModelManager } from '../../../../ModelManager'\r\nimport { SpatialStructure } from '../../../../SpatialStructure'\r\n\r\nimport type { DbFile as DbFile } from '../../../../../../../../types/dbTypes'\r\n\r\nconst BIM_MODEL_OPTIONS: import('../../../../../../../../types/global').FileAction[] = ['view', 'ghost', 'move', 'info', 'delete']\r\n\r\ninterface ModelsSectionProps {\r\n files: DbFile[]\r\n query?: string\r\n}\r\n\r\nexport function ModelsSection({ files, query = '' }: ModelsSectionProps) {\r\n // Translation\r\n const t = useTranslations('FileItemComponent')\r\n\r\n // Get BIM context\r\n const { state: bimState, dispatch: bimDispatch } = React.useContext(BimContext)\r\n const { bimComponents, fragments, modelId, modelUIState } = bimState.bim\r\n\r\n // Get Buildings context for buildingId\r\n const { state: buildingsState } = React.useContext(BuildingsContext)\r\n const { building } = buildingsState.buildings\r\n const buildingId = building?.id || 0\r\n\r\n // Upload file hook and session\r\n const { uploadFile } = useUploadFileToBuilding(buildingId)\r\n const { deleteFile } = useDeleteFile(buildingId)\r\n\r\n // Use the reusable upload handler\r\n const { handleFileUpload } = useFileUploadHandler({\r\n buildingId,\r\n tag: 'bim-file',\r\n isVisible: true,\r\n uploadFile,\r\n })\r\n\r\n // Use the reusable delete handler\r\n const { handleDeleteFile } = useFileDeleteHandler({\r\n deleteFile,\r\n\r\n })\r\n\r\n // Local state for file management with isVisible property\r\n const [loadedModels, setLoadedModels] = React.useState<(DbFile & { isVisible?: boolean })[]>(\r\n files.map(file => ({\r\n ...file,\r\n isVisible: modelUIState[file.id]?.isVisible ?? (file as any).isVisible,\r\n isGhost: modelUIState[file.id]?.isGhost ?? false,\r\n }))\r\n )\r\n\r\n // Keep local list in sync with incoming props and store UI state changes\r\n React.useEffect(() => {\r\n setLoadedModels(prev => {\r\n const prevMap = new Map(prev.map(f => [f.id, f as any]))\r\n return files.map(file => ({\r\n ...file,\r\n isVisible: modelUIState[file.id]?.isVisible ?? (file as any).isVisible,\r\n isGhost: modelUIState[file.id]?.isGhost ?? prevMap.get(file.id)?.isGhost ?? false,\r\n }))\r\n })\r\n }, [files, modelUIState])\r\n\r\n // Get ModelManager from BIM components\r\n const modelManager = React.useMemo(() => {\r\n if (!bimComponents) return null\r\n try {\r\n return bimComponents.get(ModelManager)\r\n }\r\n catch {\r\n return null\r\n }\r\n }, [bimComponents])\r\n\r\n // Get BIMManager from BIM components\r\n const bimManager = React.useMemo(() => {\r\n if (!bimComponents) return null\r\n try {\r\n return bimComponents.get(BIMManager)\r\n }\r\n catch {\r\n return null\r\n }\r\n }, [bimComponents])\r\n\r\n // Get GhostMode from BIM components\r\n const ghostMode = React.useMemo(() => {\r\n if (!bimComponents) return null\r\n try {\r\n return bimComponents.get(GhostMode)\r\n }\r\n catch {\r\n return null\r\n }\r\n }, [bimComponents])\r\n\r\n // Gizmo controllers keyed by model's file.name (one gizmo per model at most)\r\n const gizmoControllersRef = React.useRef<Map<string, GizmoController>>(new Map())\r\n\r\n // Track the file ID currently being repositioned so useFile can provide updateFile\r\n const [moveFileId, setMoveFileId] = React.useState<number | null>(null)\r\n const { updateFile } = useFile(moveFileId)\r\n const updateFileRef = React.useRef(updateFile)\r\n React.useEffect(() => { updateFileRef.current = updateFile }, [updateFile])\r\n\r\n // Get Highlighter from BIM components\r\n const highlighter = React.useMemo(() => {\r\n if (!bimComponents) return null\r\n try {\r\n return bimComponents.get(Highlighter)\r\n }\r\n catch {\r\n return null\r\n }\r\n }, [bimComponents])\r\n\r\n // Custom handlers for BIM-specific actions (view and delete only - download uses default)\r\n const handleBimView = React.useCallback((file: DbFile, newVisibility: boolean) => {\r\n bimDispatch({ type: 'SET_MODEL_UI_STATE', payload: { fileId: file.id, isVisible: newVisibility } })\r\n\r\n // Disable highlighting for hidden models; re-enable only when visible and not ghosted\r\n if (highlighter) {\r\n const isGhosted = modelUIState[file.id]?.isGhost ?? false\r\n if (!newVisibility || isGhosted) {\r\n highlighter.disableModel(file.name)\r\n } else {\r\n highlighter.enableModel(file.name)\r\n }\r\n }\r\n\r\n // Non-fragment models (gltf/obj/fbx) managed by ModelManager\r\n if (modelManager) {\r\n const modelInfo = modelManager.getModel(file.id.toString())\r\n if (modelInfo) {\r\n modelInfo.model.visible = newVisibility\r\n if (fragments) void fragments.core.update(true)\r\n return\r\n }\r\n }\r\n\r\n // Fragment (IFC/FRAG) models — look up directly from fragments list by file.name\r\n if (fragments) {\r\n const fragModel = fragments.core.models.list.get(file.name)\r\n if (fragModel) {\r\n fragModel.object.visible = newVisibility\r\n void fragments.core.update(true)\r\n } else {\r\n }\r\n }\r\n }, [modelManager, fragments, highlighter, modelUIState])\r\n\r\n const handleBimDelete = React.useCallback((file: DbFile) => {\r\n // Remove from ModelManager if it exists (gltf/obj/fbx models)\r\n if (modelManager) {\r\n const modelIdStr = file.id.toString()\r\n modelManager.remove(modelIdStr)\r\n }\r\n\r\n // Remove fragment model from scene if it exists (ifc/frag models)\r\n if (fragments) {\r\n const fragModel = fragments.core.models.list.get(file.name)\r\n if (fragModel) {\r\n fragments.core.disposeModel(fragModel.modelId).catch((err: unknown) => {\r\n console.error(`Failed to dispose fragment model \"${file.name}\":`, err)\r\n })\r\n // Also clean up BIMManager tracking\r\n bimManager?.remove(file.name)\r\n // Drop the model's spatial tree too, otherwise the sidebar keeps\r\n // rendering it and pushing visibility changes at a disposed model.\r\n try {\r\n bimComponents?.get(SpatialStructure).clearForModel(file.name)\r\n } catch {\r\n // The viewer may already be tearing down; nothing to clean up then.\r\n }\r\n }\r\n }\r\n }, [modelManager, bimComponents, fragments, bimManager])\r\n\r\n const handleBimMove = React.useCallback((file: DbFile) => {\r\n if (!bimComponents || !fragments) return\r\n\r\n const world = bimComponents.get(CurrentWorld).world\r\n if (!world) return\r\n\r\n const fragModel = fragments.core.models.list.get(file.name)\r\n if (!fragModel) {\r\n console.warn(`[BimMove] Model not found: \"${file.name}\"`)\r\n return\r\n }\r\n\r\n const existing = gizmoControllersRef.current.get(file.name)\r\n if (existing) {\r\n // Toggle off: destroy the gizmo\r\n existing.dispose()\r\n gizmoControllersRef.current.delete(file.name)\r\n if (gizmoControllersRef.current.size === 0 && highlighter) highlighter.enabled = true\r\n } else {\r\n // Toggle on: create a new gizmo attached to the model's root object\r\n const gizmo = new GizmoController(world)\r\n const cleanupGizmo = (savePosition: boolean) => {\r\n if (savePosition) {\r\n const { x, y, z } = fragModel.object.position\r\n const rotation = fragModel.object.rotation.y\r\n updateFileRef.current({ x, y, z, rotation } as any)\r\n .catch((err: unknown) => console.error(`[BimMove] Failed to save position for \"${file.name}\":`, err))\r\n file.x = x\r\n file.y = y\r\n file.z = z\r\n file.rotation = rotation\r\n }\r\n gizmoControllersRef.current.delete(file.name)\r\n if (gizmoControllersRef.current.size === 0 && highlighter) highlighter.enabled = true\r\n setMoveFileId(null)\r\n }\r\n gizmo.onAccept = () => cleanupGizmo(true)\r\n gizmo.onCancel = () => cleanupGizmo(false)\r\n setMoveFileId(file.id)\r\n if (highlighter) highlighter.enabled = false\r\n gizmo.attach(fragModel.object)\r\n gizmoControllersRef.current.set(file.name, gizmo)\r\n }\r\n }, [bimComponents, fragments, highlighter])\r\n\r\n const handleBimGhost = React.useCallback((file: DbFile, ghostState: boolean) => {\r\n if (!fragments || !ghostMode) return\r\n\r\n const fragModel = fragments.core.models.list.get(file.name)\r\n if (!fragModel) {\r\n console.warn(`[BimGhost] Model not found: \"${file.name}\"`)\r\n return\r\n }\r\n\r\n ghostMode.setModelGhost(fragModel, ghostState)\r\n bimDispatch({ type: 'SET_MODEL_UI_STATE', payload: { fileId: file.id, isGhost: ghostState } })\r\n\r\n // Disable highlighting for ghosted models; re-enable only when visible and not ghosted\r\n if (highlighter) {\r\n const isVisible = modelUIState[file.id]?.isVisible ?? true\r\n if (ghostState || !isVisible) {\r\n highlighter.disableModel(file.name)\r\n } else {\r\n highlighter.enableModel(file.name)\r\n }\r\n }\r\n }, [fragments, ghostMode, bimDispatch, highlighter, modelUIState])\r\n\r\n // Use the common file actions hook (no custom download handler - use default for all files)\r\n const { handleAction, deleteDialog } = useFileActions({\r\n files: loadedModels,\r\n setFiles: setLoadedModels,\r\n buildingId,\r\n handleDeleteFile,\r\n onView: handleBimView,\r\n onDelete: handleBimDelete,\r\n onMove: handleBimMove,\r\n onGhost: handleBimGhost\r\n })\r\n\r\n // Use the common file upload hook\r\n const { handleAddFile } = useCommonFileUpload({\r\n buildingId,\r\n acceptedFileTypes: '.ifc,.frag',\r\n handleFileUpload,\r\n onUploadError: (error) => {\r\n console.error('Error uploading model:', error)\r\n }\r\n })\r\n\r\n // Filter models based on search query\r\n const filteredModels = React.useMemo(() => {\r\n if (!query.trim()) return loadedModels\r\n return loadedModels.filter(file =>\r\n file.name.toLowerCase().includes(query.toLowerCase())\r\n )\r\n }, [loadedModels, query])\r\n\r\n const areAllHidden = loadedModels.every(f => !f.isVisible)\r\n\r\n const handleSwitchVariant = () => ({\r\n checked: !areAllHidden,\r\n onCheckedChange: (checked: boolean) => {\r\n setLoadedModels(prev => prev.map(f => ({ ...f, isVisible: checked })))\r\n // Toggle visibility in 3D scene for all models\r\n for (const file of loadedModels) {\r\n handleBimView(file, checked)\r\n }\r\n },\r\n })\r\n\r\n return (\r\n <>\r\n <CollapsibleSection\r\n title={t('modelsTitles')}\r\n icon={LR.Box}\r\n className=\"max-h-40 overflow-y-auto\"\r\n itemCount={filteredModels.length}\r\n onAddItem={handleAddFile}\r\n addItemTitle={t('addBimTitle')}\r\n switchVariant={handleSwitchVariant()}\r\n >\r\n <div className=\"space-y-1\">\r\n {filteredModels.map((file) => (\r\n <FileItemComponent\r\n key={file.id}\r\n file={file}\r\n onAction={handleAction}\r\n options={BIM_MODEL_OPTIONS}\r\n confirmDelete={false}\r\n />\r\n ))}\r\n </div>\r\n </CollapsibleSection>\r\n\r\n <ConfirmDialog\r\n isOpen={deleteDialog.isOpen}\r\n isDeleting={deleteDialog.isDeleting}\r\n onOpenChange={deleteDialog.onOpenChange}\r\n handleConfirm={deleteDialog.onConfirm}\r\n itemName={deleteDialog.itemName}\r\n />\r\n </>\r\n )\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsTI,mBAYQ,KAZR;AAjTJ,YAAY,QAAQ;AACpB,SAAS,uBAAuB;AAChC,YAAY,WAAW;AAEvB,SAAS,yBAAyB,eAAe,eAAe;AAChE,SAAS,YAAY,wBAAwB;AAC7C,OAAO,mBAAmB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,sBAAsB,sBAAsB,mBAAmB,gBAAgB,2BAA2B;AACnH,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,wBAAwB;AAIjC,MAAM,oBAAiF,CAAC,QAAQ,SAAS,QAAQ,QAAQ,QAAQ;AAO1H,SAAS,cAAc,EAAE,OAAO,QAAQ,GAAG,GAAuB;AAEvE,QAAM,IAAI,gBAAgB,mBAAmB;AAG7C,QAAM,EAAE,OAAO,UAAU,UAAU,YAAY,IAAI,MAAM,WAAW,UAAU;AAC9E,QAAM,EAAE,eAAe,WAAW,SAAS,aAAa,IAAI,SAAS;AAGrE,QAAM,EAAE,OAAO,eAAe,IAAI,MAAM,WAAW,gBAAgB;AACnE,QAAM,EAAE,SAAS,IAAI,eAAe;AACpC,QAAM,cAAa,qCAAU,OAAM;AAGnC,QAAM,EAAE,WAAW,IAAI,wBAAwB,UAAU;AACzD,QAAM,EAAE,WAAW,IAAI,cAAc,UAAU;AAG/C,QAAM,EAAE,iBAAiB,IAAI,qBAAqB;AAAA,IAChD;AAAA,IACA,KAAK;AAAA,IACL,WAAW;AAAA,IACX;AAAA,EACF,CAAC;AAGD,QAAM,EA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AAAA,QAC1B,WAAW;AAAA,QACX,cAAc,EAAE,aAAa;AAAA,QAC7B,eAAe,oBAAoB;AAAA,QAEnC,8BAAC,SAAI,WAAU,aACZ,yBAAe,IAAI,CAAC,SACnB;AAAA,UAAC;AAAA;AAAA,YAEC;AAAA,YACA,UAAU;AAAA,YACV,SAAS;AAAA,YACT,eAAe;AAAA;AAAA,UAJV,KAAK;AAAA,QAKZ,CACD,GACH;AAAA;AAAA,IACF;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ,aAAa;AAAA,QACrB,YAAY,aAAa;AAAA,QACzB,cAAc,aAAa;AAAA,QAC3B,eAAe,aAAa;AAAA,QAC5B,UAAU,aAAa;AAAA;AAAA,IACzB;AAAA,KACF;AAEJ;","names":[]}
@@ -1,12 +1,15 @@
1
1
  import * as React from 'react';
2
- interface LayersTabProps {
3
- modelId: string | null;
4
- }
5
2
  /**
6
- * The "Layers" sidebar tab. Hosts a single shared search bar plus three
7
- * equal-height sections (floorplans, elevations, spatial-structure tree).
8
- * Each section component owns its own data + event subscriptions.
3
+ * The "Layers" sidebar tab: a shared search bar over two collapsible groups.
4
+ *
5
+ * **Drawings** switches between floorplans and elevations; **Classifier**
6
+ * switches between the IFC spatial tree and the IFC class list. Grouping the
7
+ * four views behind two segmented switchers (the same control the Settings tab
8
+ * uses for render mode) keeps one view at full height instead of splitting the
9
+ * sidebar four ways.
10
+ *
11
+ * The two groups share the vertical space through a draggable separator, and a
12
+ * collapsed group shrinks to its header so it hands its space to the other one.
9
13
  */
10
- export declare function LayersTab({ modelId }: LayersTabProps): React.JSX.Element;
11
- export {};
14
+ export declare function LayersTab(): React.JSX.Element;
12
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/LayersTab/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAQ9B,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CACvB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,cAAc,qBAyGpD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/components/viewers/bim/src/BimSidebar/src/LayersTab/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAqB9B;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,sBAmKxB"}
@@ -1,31 +1,63 @@
1
1
  "use client";
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
2
21
  import { jsx, jsxs } from "react/jsx-runtime";
22
+ import * as LR from "lucide-react";
23
+ import { useTranslations } from "next-intl";
3
24
  import * as React from "react";
4
- import { SearchInput } from "../../../../../../ui/";
25
+ import { FloorplanIcon } from "../../../../../../ui/Icons/FloorPlanIcon";
26
+ import { SearchInput } from "../../../../../../ui/SearchInput";
27
+ import { AppearanceProvider } from "./src/AppearanceProvider";
5
28
  import { ElevationSection } from "./src/ElevationsSection";
6
29
  import { FloorplanSection } from "./src/FloorplanSection";
30
+ import { IfcClassesSection } from "./src/IfcClassesSection";
31
+ import { LayerGroupSection } from "./src/LayerGroupSection";
7
32
  import { SpatialStructureSection } from "./src/SpatialStructureSection";
8
- function LayersTab({ modelId }) {
33
+ const SEPARATOR_HEIGHT = 8;
34
+ const DEFAULT_WEIGHTS = { drawings: 45, classifier: 55 };
35
+ const MIN_WEIGHTS = { drawings: 20, classifier: 25 };
36
+ function LayersTab() {
37
+ const t = useTranslations("LayersTab");
9
38
  const [searchQuery, setSearchQuery] = React.useState("");
10
- const [panelSizes, setPanelSizes] = React.useState([44, 18, 38]);
39
+ const [openGroups, setOpenGroups] = React.useState({
40
+ drawings: true,
41
+ classifier: true
42
+ });
43
+ const [activeView, setActiveView] = React.useState({
44
+ drawings: "floorplans",
45
+ classifier: "spatial"
46
+ });
47
+ const [weights, setWeights] = React.useState(DEFAULT_WEIGHTS);
11
48
  const layoutRef = React.useRef(null);
12
49
  const dragStateRef = React.useRef(null);
50
+ const bothOpen = openGroups.drawings && openGroups.classifier;
13
51
  const handlePointerMove = React.useCallback((event) => {
14
- const dragState = dragStateRef.current;
15
- if (!dragState || dragState.containerHeight <= 0) return;
16
- const deltaPercent = (event.clientY - dragState.startY) / dragState.containerHeight * 100;
17
- const minimumSizes = [24, 12, 28];
18
- if (dragState.divider === "top") {
19
- const maxTop = 100 - minimumSizes[1] - dragState.startSizes[2];
20
- const nextTop = Math.min(maxTop, Math.max(minimumSizes[0], dragState.startSizes[0] + deltaPercent));
21
- const nextMiddle2 = 100 - nextTop - dragState.startSizes[2];
22
- setPanelSizes([nextTop, nextMiddle2, dragState.startSizes[2]]);
23
- return;
24
- }
25
- const maxMiddle = 100 - dragState.startSizes[0] - minimumSizes[2];
26
- const nextMiddle = Math.min(maxMiddle, Math.max(minimumSizes[1], dragState.startSizes[1] + deltaPercent));
27
- const nextBottom = 100 - dragState.startSizes[0] - nextMiddle;
28
- setPanelSizes([dragState.startSizes[0], nextMiddle, nextBottom]);
52
+ const drag = dragStateRef.current;
53
+ if (!drag || drag.pixelsPerUnit <= 0) return;
54
+ const total = DEFAULT_WEIGHTS.drawings + DEFAULT_WEIGHTS.classifier;
55
+ const delta = (event.clientY - drag.startY) / drag.pixelsPerUnit;
56
+ const next = Math.min(
57
+ total - MIN_WEIGHTS.classifier,
58
+ Math.max(MIN_WEIGHTS.drawings, drag.startDrawings + delta)
59
+ );
60
+ setWeights({ drawings: next, classifier: total - next });
29
61
  }, []);
30
62
  const stopDragging = React.useCallback(() => {
31
63
  dragStateRef.current = null;
@@ -33,68 +65,104 @@ function LayersTab({ modelId }) {
33
65
  window.removeEventListener("pointerup", stopDragging);
34
66
  window.removeEventListener("pointercancel", stopDragging);
35
67
  }, [handlePointerMove]);
68
+ React.useEffect(() => stopDragging, [stopDragging]);
36
69
  const beginResize = React.useCallback(
37
- (divider) => (event) => {
38
- if (!layoutRef.current) return;
70
+ (event) => {
71
+ const layout = layoutRef.current;
72
+ if (!layout) return;
73
+ const total = DEFAULT_WEIGHTS.drawings + DEFAULT_WEIGHTS.classifier;
74
+ const flexibleHeight = layout.clientHeight - SEPARATOR_HEIGHT;
75
+ if (flexibleHeight <= 0) return;
39
76
  event.preventDefault();
40
77
  event.currentTarget.setPointerCapture(event.pointerId);
41
78
  dragStateRef.current = {
42
- divider,
43
79
  startY: event.clientY,
44
- startSizes: [...panelSizes],
45
- containerHeight: layoutRef.current.clientHeight
80
+ startDrawings: weights.drawings,
81
+ pixelsPerUnit: flexibleHeight / total
46
82
  };
47
83
  window.addEventListener("pointermove", handlePointerMove);
48
84
  window.addEventListener("pointerup", stopDragging);
49
85
  window.addEventListener("pointercancel", stopDragging);
50
86
  },
51
- [handlePointerMove, panelSizes, stopDragging]
87
+ [handlePointerMove, stopDragging, weights.drawings]
52
88
  );
53
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1 min-h-0 overflow-hidden", children: [
89
+ const setOpen = (id) => (open) => setOpenGroups((current) => __spreadProps(__spreadValues({}, current), { [id]: open }));
90
+ const setView = (id) => (view) => setActiveView((current) => __spreadProps(__spreadValues({}, current), { [id]: view }));
91
+ const rowFor = (id) => openGroups[id] ? `${weights[id]}fr` : "auto";
92
+ const gridTemplateRows = bothOpen ? `${rowFor("drawings")} ${SEPARATOR_HEIGHT}px ${rowFor("classifier")}` : `${rowFor("drawings")} ${rowFor("classifier")}`;
93
+ return /* @__PURE__ */ jsx(AppearanceProvider, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col flex-1 min-h-0 overflow-hidden", children: [
54
94
  /* @__PURE__ */ jsx("div", { className: "px-4 py-3 border-b flex-shrink-0", children: /* @__PURE__ */ jsx(
55
95
  SearchInput,
56
96
  {
57
- placeholder: "Search",
97
+ placeholder: t("searchPlaceholder"),
58
98
  value: searchQuery,
59
99
  onChange: (e) => setSearchQuery(e.target.value)
60
100
  }
61
101
  ) }),
62
- /* @__PURE__ */ jsxs(
63
- "div",
64
- {
65
- ref: layoutRef,
66
- className: "grid flex-1 min-h-0",
67
- style: { gridTemplateRows: `${panelSizes[0]}fr 8px ${panelSizes[1]}fr 8px ${panelSizes[2]}fr` },
68
- children: [
69
- /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx(FloorplanSection, { query: searchQuery }) }),
70
- /* @__PURE__ */ jsx(
71
- "div",
102
+ /* @__PURE__ */ jsxs("div", { ref: layoutRef, className: "grid flex-1 min-h-0", style: { gridTemplateRows }, children: [
103
+ /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx(
104
+ LayerGroupSection,
105
+ {
106
+ title: t("drawingsGroup"),
107
+ icon: FloorplanIcon,
108
+ open: openGroups.drawings,
109
+ onOpenChange: setOpen("drawings"),
110
+ activeId: activeView.drawings,
111
+ onActiveChange: setView("drawings"),
112
+ views: [
72
113
  {
73
- role: "separator",
74
- "aria-orientation": "horizontal",
75
- "aria-label": "Resize floorplans and elevations",
76
- className: "group flex items-center justify-center cursor-row-resize select-none touch-none",
77
- onPointerDown: beginResize("top"),
78
- children: /* @__PURE__ */ jsx("div", { className: "h-px w-full bg-border transition-colors group-hover:bg-primary/50" })
114
+ id: "floorplans",
115
+ label: t("floorplansTab"),
116
+ icon: FloorplanIcon,
117
+ content: /* @__PURE__ */ jsx(FloorplanSection, { query: searchQuery })
118
+ },
119
+ {
120
+ id: "elevations",
121
+ label: t("elevationsTab"),
122
+ icon: LR.House,
123
+ content: /* @__PURE__ */ jsx(ElevationSection, { query: searchQuery })
79
124
  }
80
- ),
81
- /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx(ElevationSection, { query: searchQuery }) }),
82
- /* @__PURE__ */ jsx(
83
- "div",
125
+ ]
126
+ }
127
+ ) }),
128
+ bothOpen && /* @__PURE__ */ jsx(
129
+ "div",
130
+ {
131
+ role: "separator",
132
+ "aria-orientation": "horizontal",
133
+ "aria-label": t("resizeSectionsLabel"),
134
+ className: "group flex items-center justify-center cursor-row-resize select-none touch-none",
135
+ onPointerDown: beginResize,
136
+ children: /* @__PURE__ */ jsx("div", { className: "h-px w-full bg-border transition-colors group-hover:bg-primary/50" })
137
+ }
138
+ ),
139
+ /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx(
140
+ LayerGroupSection,
141
+ {
142
+ title: t("classifierGroup"),
143
+ icon: LR.ListTree,
144
+ open: openGroups.classifier,
145
+ onOpenChange: setOpen("classifier"),
146
+ activeId: activeView.classifier,
147
+ onActiveChange: setView("classifier"),
148
+ views: [
149
+ {
150
+ id: "spatial",
151
+ label: t("spatialTab"),
152
+ icon: LR.ListTree,
153
+ content: /* @__PURE__ */ jsx(SpatialStructureSection, { searchQuery })
154
+ },
84
155
  {
85
- role: "separator",
86
- "aria-orientation": "horizontal",
87
- "aria-label": "Resize elevations and spatial structure",
88
- className: "group flex items-center justify-center cursor-row-resize select-none touch-none",
89
- onPointerDown: beginResize("bottom"),
90
- children: /* @__PURE__ */ jsx("div", { className: "h-px w-full bg-border transition-colors group-hover:bg-primary/50" })
156
+ id: "classes",
157
+ label: t("classesTab"),
158
+ icon: LR.Tags,
159
+ content: /* @__PURE__ */ jsx(IfcClassesSection, { searchQuery })
91
160
  }
92
- ),
93
- /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children: /* @__PURE__ */ jsx(SpatialStructureSection, { searchQuery, modelId }) })
94
- ]
95
- }
96
- )
97
- ] });
161
+ ]
162
+ }
163
+ ) })
164
+ ] })
165
+ ] }) });
98
166
  }
99
167
  export {
100
168
  LayersTab