@kerros/editor 0.0.0-stage → 0.1.0-rc.2

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 (345) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -2
  3. package/dist/SitePlanner.js +1189 -0
  4. package/dist/SitePlanner.js.map +1 -0
  5. package/dist/adapters/basemap.js +11 -0
  6. package/dist/adapters/basemap.js.map +1 -0
  7. package/dist/adapters/persistence.js +121 -0
  8. package/dist/adapters/persistence.js.map +1 -0
  9. package/dist/adapters/status.js +11 -0
  10. package/dist/adapters/status.js.map +1 -0
  11. package/dist/adapters/useProjectPersistence.js +56 -0
  12. package/dist/adapters/useProjectPersistence.js.map +1 -0
  13. package/dist/components/AiImportPanel.js +635 -0
  14. package/dist/components/AiImportPanel.js.map +1 -0
  15. package/dist/components/AnalysisPreview.js +179 -0
  16. package/dist/components/AnalysisPreview.js.map +1 -0
  17. package/dist/components/ElevatorPanel.js +120 -0
  18. package/dist/components/ElevatorPanel.js.map +1 -0
  19. package/dist/components/Icons.js +57 -0
  20. package/dist/components/Icons.js.map +1 -0
  21. package/dist/components/ImportDialog.js +467 -0
  22. package/dist/components/ImportDialog.js.map +1 -0
  23. package/dist/components/Inspector.js +1184 -0
  24. package/dist/components/Inspector.js.map +1 -0
  25. package/dist/components/NavigatePanel.js +301 -0
  26. package/dist/components/NavigatePanel.js.map +1 -0
  27. package/dist/components/NavigationGraph.js +234 -0
  28. package/dist/components/NavigationGraph.js.map +1 -0
  29. package/dist/components/StructureExplorer.js +510 -0
  30. package/dist/components/StructureExplorer.js.map +1 -0
  31. package/dist/components/StructureView.js +286 -0
  32. package/dist/components/StructureView.js.map +1 -0
  33. package/dist/components/controls.js +209 -0
  34. package/dist/components/controls.js.map +1 -0
  35. package/dist/components/graphLayout.js +27 -0
  36. package/dist/components/graphLayout.js.map +1 -0
  37. package/dist/host.js +175 -0
  38. package/dist/host.js.map +1 -0
  39. package/dist/i18n.js +88 -0
  40. package/dist/i18n.js.map +1 -0
  41. package/dist/import/analysisPreview.js +41 -0
  42. package/dist/import/analysisPreview.js.map +1 -0
  43. package/dist/import/brief.js +29 -0
  44. package/dist/import/brief.js.map +1 -0
  45. package/dist/import/checkpoint.js +50 -0
  46. package/dist/import/checkpoint.js.map +1 -0
  47. package/dist/import/detect.js +120 -0
  48. package/dist/import/detect.js.map +1 -0
  49. package/dist/import/documentSvg.js +49 -0
  50. package/dist/import/documentSvg.js.map +1 -0
  51. package/dist/import/instructions.js +20 -0
  52. package/dist/import/instructions.js.map +1 -0
  53. package/dist/import/openings.js +61 -0
  54. package/dist/import/openings.js.map +1 -0
  55. package/dist/import/planImport.js +233 -0
  56. package/dist/import/planImport.js.map +1 -0
  57. package/dist/import/register.js +47 -0
  58. package/dist/import/register.js.map +1 -0
  59. package/dist/import/runs.js +67 -0
  60. package/dist/import/runs.js.map +1 -0
  61. package/dist/import/session.js +23 -0
  62. package/dist/import/session.js.map +1 -0
  63. package/dist/import/types.js +13 -0
  64. package/dist/import/types.js.map +1 -0
  65. package/dist/import/usage.js +29 -0
  66. package/dist/import/usage.js.map +1 -0
  67. package/dist/import/walls.js +112 -0
  68. package/dist/import/walls.js.map +1 -0
  69. package/dist/index.js +178 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/map/CabinMaterials.js +81 -0
  72. package/dist/map/CabinMaterials.js.map +1 -0
  73. package/dist/map/CabinMirror.js +43 -0
  74. package/dist/map/CabinMirror.js.map +1 -0
  75. package/dist/map/Doors.js +80 -0
  76. package/dist/map/Doors.js.map +1 -0
  77. package/dist/map/ElevatorCabin.js +93 -0
  78. package/dist/map/ElevatorCabin.js.map +1 -0
  79. package/dist/map/FixtureLights.js +117 -0
  80. package/dist/map/FixtureLights.js.map +1 -0
  81. package/dist/map/MapCanvas.js +2161 -0
  82. package/dist/map/MapCanvas.js.map +1 -0
  83. package/dist/map/Passenger.js +69 -0
  84. package/dist/map/Passenger.js.map +1 -0
  85. package/dist/map/SceneLayer.js +1534 -0
  86. package/dist/map/SceneLayer.js.map +1 -0
  87. package/dist/map/UndergroundContext.js +153 -0
  88. package/dist/map/UndergroundContext.js.map +1 -0
  89. package/dist/map/ambience.js +194 -0
  90. package/dist/map/ambience.js.map +1 -0
  91. package/dist/map/architecture.js +305 -0
  92. package/dist/map/architecture.js.map +1 -0
  93. package/dist/map/bathMusic.js +92 -0
  94. package/dist/map/bathMusic.js.map +1 -0
  95. package/dist/map/cameraAim.js +33 -0
  96. package/dist/map/cameraAim.js.map +1 -0
  97. package/dist/map/elevators.js +56 -0
  98. package/dist/map/elevators.js.map +1 -0
  99. package/dist/map/excavation.js +52 -0
  100. package/dist/map/excavation.js.map +1 -0
  101. package/dist/map/exteriors.js +25 -0
  102. package/dist/map/exteriors.js.map +1 -0
  103. package/dist/map/features.js +218 -0
  104. package/dist/map/features.js.map +1 -0
  105. package/dist/map/fences.js +29 -0
  106. package/dist/map/fences.js.map +1 -0
  107. package/dist/map/journey.js +112 -0
  108. package/dist/map/journey.js.map +1 -0
  109. package/dist/map/levels.js +6 -0
  110. package/dist/map/levels.js.map +1 -0
  111. package/dist/map/lighting.js +143 -0
  112. package/dist/map/lighting.js.map +1 -0
  113. package/dist/map/loadBasemap.js +26 -0
  114. package/dist/map/loadBasemap.js.map +1 -0
  115. package/dist/map/materials.js +183 -0
  116. package/dist/map/materials.js.map +1 -0
  117. package/dist/map/poolLighting.js +39 -0
  118. package/dist/map/poolLighting.js.map +1 -0
  119. package/dist/map/projection.js +24 -0
  120. package/dist/map/projection.js.map +1 -0
  121. package/dist/map/rampGeometry.js +38 -0
  122. package/dist/map/rampGeometry.js.map +1 -0
  123. package/dist/map/route.js +107 -0
  124. package/dist/map/route.js.map +1 -0
  125. package/dist/map/stairSurfaces.js +115 -0
  126. package/dist/map/stairSurfaces.js.map +1 -0
  127. package/dist/map/surfaces.js +136 -0
  128. package/dist/map/surfaces.js.map +1 -0
  129. package/dist/map/textures.js +95 -0
  130. package/dist/map/textures.js.map +1 -0
  131. package/dist/map/underground.js +34 -0
  132. package/dist/map/underground.js.map +1 -0
  133. package/dist/map/walk.js +433 -0
  134. package/dist/map/walk.js.map +1 -0
  135. package/dist/map/walkContext.js +46 -0
  136. package/dist/map/walkContext.js.map +1 -0
  137. package/dist/map/walkDimensions.js +7 -0
  138. package/dist/map/walkDimensions.js.map +1 -0
  139. package/dist/map/walkJourney.js +85 -0
  140. package/dist/map/walkJourney.js.map +1 -0
  141. package/dist/map/walkSurfaces.js +106 -0
  142. package/dist/map/walkSurfaces.js.map +1 -0
  143. package/dist/map/wallJoins.js +70 -0
  144. package/dist/map/wallJoins.js.map +1 -0
  145. package/dist/map/water.js +274 -0
  146. package/dist/map/water.js.map +1 -0
  147. package/dist/model/authoring.js +99 -0
  148. package/dist/model/authoring.js.map +1 -0
  149. package/dist/model/boundaries.js +548 -0
  150. package/dist/model/boundaries.js.map +1 -0
  151. package/dist/model/coverage.js +30 -0
  152. package/dist/model/coverage.js.map +1 -0
  153. package/dist/model/document.js +52 -0
  154. package/dist/model/document.js.map +1 -0
  155. package/dist/model/doors.js +47 -0
  156. package/dist/model/doors.js.map +1 -0
  157. package/dist/model/factory.js +56 -0
  158. package/dist/model/factory.js.map +1 -0
  159. package/dist/model/geometry.js +454 -0
  160. package/dist/model/geometry.js.map +1 -0
  161. package/dist/model/history.js +29 -0
  162. package/dist/model/history.js.map +1 -0
  163. package/dist/model/imports.js +45 -0
  164. package/dist/model/imports.js.map +1 -0
  165. package/dist/model/inference.js +182 -0
  166. package/dist/model/inference.js.map +1 -0
  167. package/dist/model/materials.js +11 -0
  168. package/dist/model/materials.js.map +1 -0
  169. package/dist/model/mutations.js +157 -0
  170. package/dist/model/mutations.js.map +1 -0
  171. package/dist/model/navigation.js +275 -0
  172. package/dist/model/navigation.js.map +1 -0
  173. package/dist/model/ontology.js +109 -0
  174. package/dist/model/ontology.js.map +1 -0
  175. package/dist/model/passages.js +5 -0
  176. package/dist/model/passages.js.map +1 -0
  177. package/dist/model/portals.js +42 -0
  178. package/dist/model/portals.js.map +1 -0
  179. package/dist/model/precision.js +11 -0
  180. package/dist/model/precision.js.map +1 -0
  181. package/dist/model/project.js +31 -0
  182. package/dist/model/project.js.map +1 -0
  183. package/dist/model/ramps.js +10 -0
  184. package/dist/model/ramps.js.map +1 -0
  185. package/dist/model/roomNavigation.js +87 -0
  186. package/dist/model/roomNavigation.js.map +1 -0
  187. package/dist/model/routeClearance.js +72 -0
  188. package/dist/model/routeClearance.js.map +1 -0
  189. package/dist/model/spaces.js +104 -0
  190. package/dist/model/spaces.js.map +1 -0
  191. package/dist/model/stairGeometry.js +40 -0
  192. package/dist/model/stairGeometry.js.map +1 -0
  193. package/dist/model/stairTraversal.js +48 -0
  194. package/dist/model/stairTraversal.js.map +1 -0
  195. package/dist/model/topology.js +63 -0
  196. package/dist/model/topology.js.map +1 -0
  197. package/dist/model/types.js +35 -0
  198. package/dist/model/types.js.map +1 -0
  199. package/dist/model/validate.js +240 -0
  200. package/dist/model/validate.js.map +1 -0
  201. package/dist/model/vertical.js +129 -0
  202. package/dist/model/vertical.js.map +1 -0
  203. package/dist/model/walls.js +261 -0
  204. package/dist/model/walls.js.map +1 -0
  205. package/dist/planner/DrawingDock.js +231 -0
  206. package/dist/planner/DrawingDock.js.map +1 -0
  207. package/dist/planner/FloorControls.js +93 -0
  208. package/dist/planner/FloorControls.js.map +1 -0
  209. package/dist/planner/MapSettings.js +143 -0
  210. package/dist/planner/MapSettings.js.map +1 -0
  211. package/dist/planner/PlannerHelp.js +57 -0
  212. package/dist/planner/PlannerHelp.js.map +1 -0
  213. package/dist/planner/ProjectSidebar.js +246 -0
  214. package/dist/planner/ProjectSidebar.js.map +1 -0
  215. package/dist/planner/floors.js +18 -0
  216. package/dist/planner/floors.js.map +1 -0
  217. package/dist/planner/useDrawingTools.js +341 -0
  218. package/dist/planner/useDrawingTools.js.map +1 -0
  219. package/dist/planner/useMapDisplay.js +51 -0
  220. package/dist/planner/useMapDisplay.js.map +1 -0
  221. package/dist/planner/usePlannerKeyboard.js +138 -0
  222. package/dist/planner/usePlannerKeyboard.js.map +1 -0
  223. package/dist/planner/useReferenceAlignment.js +50 -0
  224. package/dist/planner/useReferenceAlignment.js.map +1 -0
  225. package/dist/styles.css +4931 -0
  226. package/dist/theme/index.js +34 -0
  227. package/dist/theme/index.js.map +1 -0
  228. package/dist/types/SitePlanner.d.ts +5 -0
  229. package/dist/types/adapters/basemap.d.ts +2 -0
  230. package/dist/types/adapters/persistence.d.ts +29 -0
  231. package/dist/types/adapters/status.d.ts +4 -0
  232. package/dist/types/adapters/useProjectPersistence.d.ts +13 -0
  233. package/dist/types/components/AiImportPanel.d.ts +9 -0
  234. package/dist/types/components/AnalysisPreview.d.ts +4 -0
  235. package/dist/types/components/ElevatorPanel.d.ts +18 -0
  236. package/dist/types/components/Icons.d.ts +8 -0
  237. package/dist/types/components/ImportDialog.d.ts +42 -0
  238. package/dist/types/components/Inspector.d.ts +38 -0
  239. package/dist/types/components/NavigatePanel.d.ts +27 -0
  240. package/dist/types/components/NavigationGraph.d.ts +10 -0
  241. package/dist/types/components/StructureExplorer.d.ts +8 -0
  242. package/dist/types/components/StructureView.d.ts +22 -0
  243. package/dist/types/components/controls.d.ts +52 -0
  244. package/dist/types/components/graphLayout.d.ts +9 -0
  245. package/dist/types/editor/host.d.ts +9 -0
  246. package/dist/types/editor/index.d.ts +2 -0
  247. package/dist/types/i18n.d.ts +85 -0
  248. package/dist/types/import/analysisPreview.d.ts +27 -0
  249. package/dist/types/import/brief.d.ts +22 -0
  250. package/dist/types/import/checkpoint.d.ts +49 -0
  251. package/dist/types/import/detect.d.ts +34 -0
  252. package/dist/types/import/documentSvg.d.ts +2 -0
  253. package/dist/types/import/index.d.ts +10 -0
  254. package/dist/types/import/instructions.d.ts +7 -0
  255. package/dist/types/import/openings.d.ts +22 -0
  256. package/dist/types/import/planImport.d.ts +22 -0
  257. package/dist/types/import/register.d.ts +25 -0
  258. package/dist/types/import/runs.d.ts +31 -0
  259. package/dist/types/import/session.d.ts +33 -0
  260. package/dist/types/import/types.d.ts +56 -0
  261. package/dist/types/import/usage.d.ts +10 -0
  262. package/dist/types/import/walls.d.ts +37 -0
  263. package/dist/types/map/CabinMaterials.d.ts +18 -0
  264. package/dist/types/map/CabinMirror.d.ts +13 -0
  265. package/dist/types/map/Doors.d.ts +11 -0
  266. package/dist/types/map/ElevatorCabin.d.ts +20 -0
  267. package/dist/types/map/FixtureLights.d.ts +35 -0
  268. package/dist/types/map/MapCanvas.d.ts +87 -0
  269. package/dist/types/map/Passenger.d.ts +18 -0
  270. package/dist/types/map/SceneLayer.d.ts +306 -0
  271. package/dist/types/map/UndergroundContext.d.ts +18 -0
  272. package/dist/types/map/ambience.d.ts +29 -0
  273. package/dist/types/map/architecture.d.ts +8 -0
  274. package/dist/types/map/bathMusic.d.ts +14 -0
  275. package/dist/types/map/cameraAim.d.ts +20 -0
  276. package/dist/types/map/elevators.d.ts +16 -0
  277. package/dist/types/map/excavation.d.ts +9 -0
  278. package/dist/types/map/exteriors.d.ts +3 -0
  279. package/dist/types/map/features.d.ts +33 -0
  280. package/dist/types/map/fences.d.ts +4 -0
  281. package/dist/types/map/journey.d.ts +36 -0
  282. package/dist/types/map/levels.d.ts +4 -0
  283. package/dist/types/map/lighting.d.ts +103 -0
  284. package/dist/types/map/loadBasemap.d.ts +4 -0
  285. package/dist/types/map/materials.d.ts +38 -0
  286. package/dist/types/map/poolLighting.d.ts +11 -0
  287. package/dist/types/map/projection.d.ts +9 -0
  288. package/dist/types/map/rampGeometry.d.ts +8 -0
  289. package/dist/types/map/route.d.ts +59 -0
  290. package/dist/types/map/stairSurfaces.d.ts +29 -0
  291. package/dist/types/map/surfaces.d.ts +36 -0
  292. package/dist/types/map/textures.d.ts +8 -0
  293. package/dist/types/map/underground.d.ts +30 -0
  294. package/dist/types/map/walk.d.ts +232 -0
  295. package/dist/types/map/walkContext.d.ts +11 -0
  296. package/dist/types/map/walkDimensions.d.ts +5 -0
  297. package/dist/types/map/walkJourney.d.ts +33 -0
  298. package/dist/types/map/walkSurfaces.d.ts +27 -0
  299. package/dist/types/map/wallJoins.d.ts +6 -0
  300. package/dist/types/map/water.d.ts +12 -0
  301. package/dist/types/model/authoring.d.ts +38 -0
  302. package/dist/types/model/boundaries.d.ts +41 -0
  303. package/dist/types/model/coverage.d.ts +8 -0
  304. package/dist/types/model/document.d.ts +9 -0
  305. package/dist/types/model/doors.d.ts +19 -0
  306. package/dist/types/model/factory.d.ts +5 -0
  307. package/dist/types/model/geometry.d.ts +99 -0
  308. package/dist/types/model/history.d.ts +10 -0
  309. package/dist/types/model/host.d.ts +154 -0
  310. package/dist/types/model/imports.d.ts +7 -0
  311. package/dist/types/model/inference.d.ts +46 -0
  312. package/dist/types/model/live.d.ts +60 -0
  313. package/dist/types/model/materials.d.ts +28 -0
  314. package/dist/types/model/mutations.d.ts +178 -0
  315. package/dist/types/model/navigation.d.ts +70 -0
  316. package/dist/types/model/ontology.d.ts +43 -0
  317. package/dist/types/model/passages.d.ts +2 -0
  318. package/dist/types/model/portals.d.ts +9 -0
  319. package/dist/types/model/precision.d.ts +11 -0
  320. package/dist/types/model/project.d.ts +8 -0
  321. package/dist/types/model/ramps.d.ts +7 -0
  322. package/dist/types/model/roomNavigation.d.ts +15 -0
  323. package/dist/types/model/routeClearance.d.ts +11 -0
  324. package/dist/types/model/spaces.d.ts +46 -0
  325. package/dist/types/model/stairGeometry.d.ts +27 -0
  326. package/dist/types/model/stairTraversal.d.ts +8 -0
  327. package/dist/types/model/topology.d.ts +14 -0
  328. package/dist/types/model/types.d.ts +369 -0
  329. package/dist/types/model/validate.d.ts +38 -0
  330. package/dist/types/model/vertical.d.ts +145 -0
  331. package/dist/types/model/walls.d.ts +71 -0
  332. package/dist/types/planner/DrawingDock.d.ts +16 -0
  333. package/dist/types/planner/FloorControls.d.ts +17 -0
  334. package/dist/types/planner/MapSettings.d.ts +16 -0
  335. package/dist/types/planner/PlannerHelp.d.ts +3 -0
  336. package/dist/types/planner/ProjectSidebar.d.ts +32 -0
  337. package/dist/types/planner/floors.d.ts +3 -0
  338. package/dist/types/planner/types.d.ts +3 -0
  339. package/dist/types/planner/useDrawingTools.d.ts +52 -0
  340. package/dist/types/planner/useMapDisplay.d.ts +29 -0
  341. package/dist/types/planner/usePlannerKeyboard.d.ts +18 -0
  342. package/dist/types/planner/useReferenceAlignment.d.ts +30 -0
  343. package/dist/types/schema/index.d.ts +25 -0
  344. package/dist/types/theme/index.d.ts +55 -0
  345. package/package.json +58 -4
@@ -0,0 +1,67 @@
1
+ const x = 0.02;
2
+ function P(a, p) {
3
+ const s = [], n = (t, o) => {
4
+ Math.abs(t[1] - o[1]) < 0.02 ? s.push({ axis: "h", c: (t[1] + o[1]) / 2, lo: Math.min(t[0], o[0]), hi: Math.max(t[0], o[0]) }) : Math.abs(t[0] - o[0]) < 0.02 && s.push({ axis: "v", c: (t[0] + o[0]) / 2, lo: Math.min(t[1], o[1]), hi: Math.max(t[1], o[1]) });
5
+ };
6
+ for (const t of a)
7
+ if (p.test(t.layer) && (t.type === "LINE" && t.a && t.b && n(t.a, t.b), t.type === "POLYLINE" && t.points))
8
+ for (let o = 1; o < t.points.length; o++) n(t.points[o - 1], t.points[o]);
9
+ return s.filter((t) => t.hi - t.lo > 0.02);
10
+ }
11
+ function g(a, p, s) {
12
+ const n = [];
13
+ for (const t of ["h", "v"]) {
14
+ const o = a.filter((i) => i.axis === t).sort((i, f) => i.c - f.c || i.lo - f.lo);
15
+ let e = [];
16
+ const c = () => {
17
+ if (!e.length) return;
18
+ const i = e.reduce((h, l) => h + l.c, 0) / e.length, f = [...e].sort((h, l) => h.lo - l.lo);
19
+ let M = f[0].lo, r = f[0].hi, u = [];
20
+ const m = () => n.push({ axis: t, c: i, lo: M, hi: r, gaps: u });
21
+ for (const h of f.slice(1)) {
22
+ const l = h.lo - r;
23
+ l <= 0.02 ? r = Math.max(r, h.hi) : l <= p ? (s && l >= s[0] && l <= s[1] && u.push([r, h.lo]), r = Math.max(r, h.hi)) : (m(), M = h.lo, r = h.hi, u = []);
24
+ }
25
+ m();
26
+ };
27
+ for (const i of o)
28
+ e.length && Math.abs(i.c - e[0].c) > 0.02 * 2 && (c(), e = []), e.push(i);
29
+ c();
30
+ }
31
+ return n;
32
+ }
33
+ function E(a, p) {
34
+ const s = [];
35
+ for (const n of a)
36
+ if (p.test(n.layer)) {
37
+ for (const t of [n.a, n.b, n.at, n.center]) t && s.push(t);
38
+ for (const t of n.points ?? []) s.push(t);
39
+ }
40
+ return s;
41
+ }
42
+ function y(a, p) {
43
+ const s = [], n = (t, o) => {
44
+ const e = Math.max(1, Math.ceil(Math.hypot(o[0] - t[0], o[1] - t[1]) / 0.2));
45
+ for (let c = 0; c <= e; c++) s.push([t[0] + (o[0] - t[0]) * c / e, t[1] + (o[1] - t[1]) * c / e]);
46
+ };
47
+ for (const t of a)
48
+ if (p.test(t.layer)) {
49
+ if (t.a && t.b && n(t.a, t.b), t.points) for (let o = 1; o < t.points.length; o++) n(t.points[o - 1], t.points[o]);
50
+ if (t.at && s.push(t.at), t.center && t.r) {
51
+ const o = (t.start ?? 0) * Math.PI / 180, e = (t.end ?? 360) * Math.PI / 180, c = Math.max(4, Math.ceil(Math.abs(e - o) * t.r / 0.2));
52
+ for (let i = 0; i <= c; i++) {
53
+ const f = o + (e - o) * i / c;
54
+ s.push([t.center[0] + t.r * Math.cos(f), t.center[1] + t.r * Math.sin(f)]);
55
+ }
56
+ }
57
+ }
58
+ return s;
59
+ }
60
+ export {
61
+ x as EPS,
62
+ P as faceSegments,
63
+ g as mergeRuns,
64
+ y as symbolPoints,
65
+ E as symbolVertices
66
+ };
67
+ //# sourceMappingURL=runs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.js","sources":["../../../../src/import/runs.ts"],"sourcesContent":["// Axis-aligned runs: the unit the wall reconstruction works in. A \"run\" is a maximal straight\n// stretch of wall face — an axis ('h' along x, 'v' along y), the cross-axis coordinate it sits at,\n// and the interval it covers. Merging collinear fragments into runs, bridging the gaps doors and\n// windows punch through a face, is what turns 93 exterior scribbles into four walls.\nimport type { Point } from '../schema';\nimport type { PlanEntity } from './types';\n\nexport interface FaceSegment {\n axis: 'h' | 'v';\n c: number;\n lo: number;\n hi: number;\n}\nexport interface Run extends FaceSegment {\n /** Bridged gaps big enough to be openings, as [lo, hi] along the run. */\n gaps: [number, number][];\n}\nexport const EPS = 0.02;\n\n/** Axis-aligned LINE/POLYLINE segments on a layer, as face segments. Oblique strokes are ignored —\n * this importer reads Manhattan drawings. */\nexport function faceSegments(entities: PlanEntity[], layer: RegExp): FaceSegment[] {\n const out: FaceSegment[] = [];\n const push = (a: Point, b: Point) => {\n if (Math.abs(a[1] - b[1]) < EPS)\n out.push({ axis: 'h', c: (a[1] + b[1]) / 2, lo: Math.min(a[0], b[0]), hi: Math.max(a[0], b[0]) });\n else if (Math.abs(a[0] - b[0]) < EPS)\n out.push({ axis: 'v', c: (a[0] + b[0]) / 2, lo: Math.min(a[1], b[1]), hi: Math.max(a[1], b[1]) });\n };\n for (const e of entities) {\n if (!layer.test(e.layer)) continue;\n if (e.type === 'LINE' && e.a && e.b) push(e.a, e.b);\n if (e.type === 'POLYLINE' && e.points) for (let i = 1; i < e.points.length; i++) push(e.points[i - 1], e.points[i]);\n }\n return out.filter(s => s.hi - s.lo > EPS);\n}\n\n/** Merge collinear fragments into runs, bridging gaps up to `bridge` metres. Gaps in the opening\n * size range are bridged but remembered — they are the doorways and windows. */\nexport function mergeRuns(segments: FaceSegment[], bridge: number, openingGaps?: [number, number]): Run[] {\n const out: Run[] = [];\n for (const axis of ['h', 'v'] as const) {\n const pool = segments.filter(s => s.axis === axis).sort((x, y) => x.c - y.c || x.lo - y.lo);\n let group: typeof pool = [];\n const flush = () => {\n if (!group.length) return;\n const c = group.reduce((s, g) => s + g.c, 0) / group.length;\n const sorted = [...group].sort((x, y) => x.lo - y.lo);\n let lo = sorted[0].lo,\n hi = sorted[0].hi;\n let gaps: [number, number][] = [];\n const emit = () => out.push({ axis, c, lo, hi, gaps });\n for (const s of sorted.slice(1)) {\n const gap = s.lo - hi;\n if (gap <= EPS) hi = Math.max(hi, s.hi);\n else if (gap <= bridge) {\n if (openingGaps && gap >= openingGaps[0] && gap <= openingGaps[1]) gaps.push([hi, s.lo]);\n hi = Math.max(hi, s.hi);\n } else {\n emit();\n lo = s.lo;\n hi = s.hi;\n gaps = [];\n }\n }\n emit();\n };\n for (const s of pool) {\n if (group.length && Math.abs(s.c - group[0].c) > EPS * 2) {\n flush();\n group = [];\n }\n group.push(s);\n }\n flush();\n }\n return out;\n}\n\n/** Every point a layer's geometry touches, sampled densely along strokes and arcs — the raw\n * material for \"is there a door/window symbol standing in this opening?\" scoring. */\n/** A symbol's own vertices, unsampled.\n *\n * symbolPoints walks every stroke at 20 cm so a door swing reads as a cloud standing in its\n * opening, which is what finding a door needs. It is the wrong picture of a window: a window is\n * drawn as a block at each jamb with the glass between them left empty, and the sampling fills that\n * emptiness in at 20 cm intervals — so the one feature that says where a window begins and ends is\n * the one thing sampling destroys. Where the shape of the symbol is the information, read the\n * vertices. */\nexport function symbolVertices(entities: PlanEntity[], layer: RegExp): Point[] {\n const pts: Point[] = [];\n for (const e of entities) {\n if (!layer.test(e.layer)) continue;\n for (const p of [e.a, e.b, e.at, e.center]) if (p) pts.push(p);\n for (const p of e.points ?? []) pts.push(p);\n }\n return pts;\n}\nexport function symbolPoints(entities: PlanEntity[], layer: RegExp): Point[] {\n const pts: Point[] = [];\n const sample = (a: Point, b: Point) => {\n const n = Math.max(1, Math.ceil(Math.hypot(b[0] - a[0], b[1] - a[1]) / 0.2));\n for (let i = 0; i <= n; i++) pts.push([a[0] + ((b[0] - a[0]) * i) / n, a[1] + ((b[1] - a[1]) * i) / n]);\n };\n for (const e of entities) {\n if (!layer.test(e.layer)) continue;\n if (e.a && e.b) sample(e.a, e.b);\n if (e.points) for (let i = 1; i < e.points.length; i++) sample(e.points[i - 1], e.points[i]);\n if (e.at) pts.push(e.at);\n if (e.center && e.r) {\n const a0 = ((e.start ?? 0) * Math.PI) / 180;\n const a1 = ((e.end ?? 360) * Math.PI) / 180;\n const n = Math.max(4, Math.ceil((Math.abs(a1 - a0) * e.r) / 0.2));\n for (let i = 0; i <= n; i++) {\n const a = a0 + ((a1 - a0) * i) / n;\n pts.push([e.center[0] + e.r * Math.cos(a), e.center[1] + e.r * Math.sin(a)]);\n }\n }\n }\n return pts;\n}\n"],"names":["EPS","faceSegments","entities","layer","out","push","a","b","e","i","s","mergeRuns","segments","bridge","openingGaps","axis","pool","x","y","group","flush","c","g","sorted","lo","hi","gaps","emit","gap","symbolVertices","pts","p","symbolPoints","sample","n","a0","a1"],"mappings":"AAiBO,MAAMA,IAAM;AAIZ,SAASC,EAAaC,GAAwBC,GAA8B;AACjF,QAAMC,IAAqB,CAAA,GACrBC,IAAO,CAACC,GAAUC,MAAa;AACnC,IAAI,KAAK,IAAID,EAAE,CAAC,IAAIC,EAAE,CAAC,CAAC,IAAI,OAC1BH,EAAI,KAAK,EAAE,MAAM,KAAK,IAAIE,EAAE,CAAC,IAAIC,EAAE,CAAC,KAAK,GAAG,IAAI,KAAK,IAAID,EAAE,CAAC,GAAGC,EAAE,CAAC,CAAC,GAAG,IAAI,KAAK,IAAID,EAAE,CAAC,GAAGC,EAAE,CAAC,CAAC,GAAG,IACzF,KAAK,IAAID,EAAE,CAAC,IAAIC,EAAE,CAAC,CAAC,IAAI,QAC/BH,EAAI,KAAK,EAAE,MAAM,KAAK,IAAIE,EAAE,CAAC,IAAIC,EAAE,CAAC,KAAK,GAAG,IAAI,KAAK,IAAID,EAAE,CAAC,GAAGC,EAAE,CAAC,CAAC,GAAG,IAAI,KAAK,IAAID,EAAE,CAAC,GAAGC,EAAE,CAAC,CAAC,GAAG;AAAA,EACpG;AACA,aAAWC,KAAKN;AACd,QAAKC,EAAM,KAAKK,EAAE,KAAK,MACnBA,EAAE,SAAS,UAAUA,EAAE,KAAKA,EAAE,KAAGH,E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B,CAAC,CAAC;AAAA,EACxG;AACA,aAAW1B,KAAKN;AACd,QAAKC,EAAM,KAAKK,EAAE,KAAK,GAEvB;AAAA,UADIA,EAAE,KAAKA,EAAE,OAAUA,EAAE,GAAGA,EAAE,CAAC,GAC3BA,EAAE,OAAQ,UAASC,IAAI,GAAGA,IAAID,EAAE,OAAO,QAAQC,IAAK,CAAAwB,EAAOzB,EAAE,OAAOC,IAAI,CAAC,GAAGD,EAAE,OAAOC,CAAC,CAAC;AAE3F,UADID,EAAE,MAAIsB,EAAI,KAAKtB,EAAE,EAAE,GACnBA,EAAE,UAAUA,EAAE,GAAG;AACnB,cAAM2B,KAAO3B,EAAE,SAAS,KAAK,KAAK,KAAM,KAClC4B,KAAO5B,EAAE,OAAO,OAAO,KAAK,KAAM,KAClC0B,IAAI,KAAK,IAAI,GAAG,KAAK,KAAM,KAAK,IAAIE,IAAKD,CAAE,IAAI3B,EAAE,IAAK,GAAG,CAAC;AAChE,iBAAS,IAAI,GAAG,KAAK0B,GAAG,KAAK;AAC3B,gBAAM5B,IAAI6B,KAAOC,IAAKD,KAAM,IAAKD;AACjC,UAAAJ,EAAI,KAAK,CAACtB,EAAE,OAAO,CAAC,IAAIA,EAAE,IAAI,KAAK,IAAIF,CAAC,GAAGE,EAAE,OAAO,CAAC,IAAIA,EAAE,IAAI,KAAK,IAAIF,CAAC,CAAC,CAAC;AAAA,QAC7E;AAAA,MACF;AAAA;AAEF,SAAOwB;AACT;"}
@@ -0,0 +1,23 @@
1
+ import { readImportCheckpoint as c, readImportBudget as u, readImportPause as d } from "./checkpoint.js";
2
+ import { readTokenUsage as m } from "./usage.js";
3
+ import { mergeImportInstructions as g } from "./instructions.js";
4
+ const a = (t) => `ai-import:${t}:session`;
5
+ async function h(t, s) {
6
+ var o, r;
7
+ const n = await t.get(a(s));
8
+ if (!n) return null;
9
+ const e = JSON.parse(await n.text());
10
+ if (e.version !== 1 || e.projectId !== s || !e.sourceId || !Array.isArray(e.messages))
11
+ throw new Error("The saved import session could not be read.");
12
+ e.tab && !["setup", "analysis", "activity", "usage"].includes(e.tab) && (e.tab = void 0), e.usage = m(e.usage), e.checkpoint = c(e.checkpoint);
13
+ const p = new Set((r = (o = e.checkpoint) == null ? void 0 : o.steering) == null ? void 0 : r.map((i) => i.id));
14
+ return e.pendingInstructions = g(e.pendingInstructions ?? []).filter((i) => !p.has(i.id)), e.budget = u(e.budget), e.pause = d(e.pause), { ...e, phase: e.phase === "running" ? "paused" : e.phase };
15
+ }
16
+ async function b(t, s) {
17
+ await t.put(a(s.projectId), new Blob([JSON.stringify(s)], { type: "application/json" }));
18
+ }
19
+ export {
20
+ h as loadAiImportSession,
21
+ b as saveAiImportSession
22
+ };
23
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sources":["../../../../src/import/session.ts"],"sourcesContent":["import type { AssetRepository } from '../model/types';\nimport {\n readImportCheckpoint,\n readImportPause,\n readImportBudget,\n type ImportCheckpoint,\n type ImportBudget,\n type ImportPause,\n} from './checkpoint';\nimport { readTokenUsage, type AiTokenUsage } from './usage';\nimport { mergeImportInstructions } from './instructions';\n\nexport interface AiImportSession {\n version: 1;\n projectId: string;\n sourceId: string;\n sourceName: string;\n sourceType: string;\n instructions: string;\n brief?: import('./brief').ImportBrief;\n followUp: string;\n tab?: 'setup' | 'analysis' | 'activity' | 'usage';\n pendingInstructions?: import('./instructions').ImportInstruction[];\n checkpoint?: ImportCheckpoint;\n budget?: ImportBudget;\n pause?: ImportPause;\n messages: { type: 'text' | 'tool' | 'user'; detail: string; instructionId?: string }[];\n phase: 'running' | 'done' | 'paused' | 'failed';\n activity: string;\n edits: number;\n usage: AiTokenUsage;\n hasUsage: boolean;\n error: string;\n}\n\nconst key = (projectId: string) => `ai-import:${projectId}:session`;\n\n/** Import state belongs to the host's asset store, alongside the original drawing. It is not\n * another plan: all geometry lives in the normal project repository. */\nexport async function loadAiImportSession(assets: AssetRepository, projectId: string): Promise<AiImportSession | null> {\n const blob = await assets.get(key(projectId));\n if (!blob) return null;\n const value = JSON.parse(await blob.text()) as AiImportSession;\n if (value.version !== 1 || value.projectId !== projectId || !value.sourceId || !Array.isArray(value.messages))\n throw new Error('The saved import session could not be read.');\n if (value.tab && !['setup', 'analysis', 'activity', 'usage'].includes(value.tab)) value.tab = undefined;\n value.usage = readTokenUsage(value.usage);\n value.checkpoint = readImportCheckpoint(value.checkpoint);\n const received = new Set(value.checkpoint?.steering?.map(m => m.id));\n value.pendingInstructions = mergeImportInstructions(value.pendingInstructions ?? []).filter(m => !received.has(m.id));\n value.budget = readImportBudget(value.budget);\n value.pause = readImportPause(value.pause);\n // A reload disconnects/cancels the backend request. Resuming is an explicit paid action.\n return { ...value, phase: value.phase === 'running' ? 'paused' : value.phase };\n}\n\nexport async function saveAiImportSession(assets: AssetRepository, session: AiImportSession): Promise<void> {\n await assets.put(key(session.projectId), new Blob([JSON.stringify(session)], { type: 'application/json' }));\n}\n"],"names":["key","projectId","loadAiImportSession","assets","blob","value","readTokenUsage","readImportCheckpoint","received","_b","_a","m","mergeImportInstructions","readImportBudget","readImportPause","saveAiImportSession","session"],"mappings":";;;AAmCA,MAAMA,IAAM,CAACC,MAAsB,aAAaA,CAAS;AAIzD,eAAsBC,EAAoBC,GAAyBF,GAAoD;;AACrH,QAAMG,IAAO,MAAMD,EAAO,IAAIH,EAAIC,CAAS,CAAC;AAC5C,MAAI,CAACG,EAAM,QAAO;AAClB,QAAMC,IAAQ,KAAK,MAAM,MAAMD,EAAK,MAAM;AAC1C,MAAIC,EAAM,YAAY,KAAKA,EAAM,cAAcJ,KAAa,CAACI,EAAM,YAAY,CAAC,MAAM,QAAQA,EAAM,QAAQ;AAC1G,UAAM,IAAI,MAAM,6CAA6C;AAC/D,EAAIA,EAAM,OAAO,CAAC,CAAC,SAAS,YAAY,YAAY,OAAO,EAAE,SAASA,EAAM,GAAG,QAAS,MAAM,SAC9FA,EAAM,QAAQC,EAAeD,EAAM,KAAK,GACxCA,EAAM,aAAaE,EAAqBF,EAAM,UAAU;AACxD,QAAMG,IAAW,IAAI,KAAIC,KAAAC,IAAAL,EAAM,eAAN,gBAAAK,EAAkB,aAAlB,gBAAAD,EAA4B,IAAI,CAAAE,MAAKA,EAAE,GAAG;AACnE,SAAAN,EAAM,sBAAsBO,EAAwBP,EAAM,uBAAuB,CAAA,CAAE,EAAE,OAAO,CAAAM,MAAK,CAACH,EAAS,IAAIG,EAAE,EAAE,CAAC,GACpHN,EAAM,SAASQ,EAAiBR,EAAM,MAAM,GAC5CA,EAAM,QAAQS,EAAgBT,EAAM,KAAK,GAElC,EAAE,GAAGA,GAAO,OAAOA,EAAM,UAAU,YAAY,WAAWA,EAAM,MAAA;AACzE;AAEA,eAAsBU,EAAoBZ,GAAyBa,GAAyC;AAC1G,QAAMb,EAAO,IAAIH,EAAIgB,EAAQ,SAAS,GAAG,IAAI,KAAK,CAAC,KAAK,UAAUA,CAAO,CAAC,GAAG,EAAE,MAAM,mBAAA,CAAoB,CAAC;AAC5G;"}
@@ -0,0 +1,13 @@
1
+ const _ = {
2
+ exteriorFace: /^12_/,
3
+ interiorFace: /^13_/,
4
+ partitionFaces: /^(186_|196_)/,
5
+ doors: /^27_/,
6
+ windows: /^26_/,
7
+ labels: /^55_/,
8
+ stairs: /^82_/
9
+ };
10
+ export {
11
+ _ as VERTEX_LAYERS
12
+ };
13
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../../src/import/types.ts"],"sourcesContent":["// The plan-import contract: what a normalized drawing entity looks like, which layers mean what,\n// and what an import reports back. Everything here is data; the geometry lives in runs.ts/walls.ts\n// and the orchestration in planImport.ts.\nimport type { Point } from '../schema';\n\n/** One normalized drawing entity, coordinates in metres. The shape scripts/plan-import/extract.mjs\n * emits with `--expand --units m`; hosts producing entities elsewhere target this. */\nexport interface PlanEntity {\n type: 'LINE' | 'POLYLINE' | 'ARC' | 'CIRCLE' | 'TEXT' | 'INSERT' | 'DIMENSION' | 'POINT';\n layer: string;\n a?: Point;\n b?: Point;\n points?: Point[];\n closed?: boolean;\n center?: Point;\n r?: number;\n start?: number;\n end?: number;\n at?: Point;\n text?: string;\n h?: number;\n block?: string;\n rotation?: number;\n}\n\n/** Which layers carry what. Defaults are the Vertex-style numbered taxonomy; override per source. */\nexport interface PlanLayerMap {\n /** Outside face of the building envelope. */\n exteriorFace: RegExp;\n /** Inside face of the envelope — also the outline the interior plate is traced from. */\n interiorFace: RegExp;\n /** Interior wall face layers; each wall is a pair of parallel runs within these. */\n partitionFaces: RegExp;\n /** Door symbol geometry (leaves, swings). Decides whether a wall gap is a doorway. */\n doors: RegExp;\n /** Window symbol geometry. Decides whether a wall gap is a window. */\n windows: RegExp;\n /** Room label texts. Area figures (pure numbers) are ignored automatically. */\n labels: RegExp;\n /** Stair treads. Optional: a sheet with no stair on it simply has none, which is a fact about the\n * building and not a failure. Where it is drawn, the symbol's extent is the flight's footprint. */\n stairs?: RegExp;\n}\nexport const VERTEX_LAYERS: PlanLayerMap = {\n exteriorFace: /^12_/,\n interiorFace: /^13_/,\n partitionFaces: /^(186_|196_)/,\n doors: /^27_/,\n windows: /^26_/,\n labels: /^55_/,\n stairs: /^82_/,\n};\n\nexport interface PlanImportOptions {\n floorId: string | null;\n layers?: PlanLayerMap;\n}\nexport interface PlanImportReport {\n walls: number;\n /** Flights of stairs read off the drawing. */\n stairs: number;\n rooms: number;\n doors: number;\n windows: number;\n /** Doorless openings — stretches where the wall was split rather than sealed. */\n passages: number;\n named: number;\n /** Things the drawing suggested but the import declined, each with the reason. */\n skipped: string[];\n}\n"],"names":["VERTEX_LAYERS"],"mappings":"AA2CO,MAAMA,IAA8B;AAAA,EACzC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AACV;"}
@@ -0,0 +1,29 @@
1
+ const s = () => ({
2
+ inputTokens: 0,
3
+ outputTokens: 0,
4
+ cacheReadTokens: 0,
5
+ cacheWriteTokens: 0
6
+ });
7
+ function c(e, o) {
8
+ return {
9
+ inputTokens: e.inputTokens + o.inputTokens,
10
+ outputTokens: e.outputTokens + o.outputTokens,
11
+ cacheReadTokens: e.cacheReadTokens + o.cacheReadTokens,
12
+ cacheWriteTokens: e.cacheWriteTokens + o.cacheWriteTokens
13
+ };
14
+ }
15
+ function r(e) {
16
+ if (!e || typeof e != "object") throw new Error("Invalid import token usage.");
17
+ const o = e, t = s();
18
+ for (const n of Object.keys(t)) {
19
+ if (!Number.isSafeInteger(o[n]) || o[n] < 0) throw new Error("Invalid import token usage.");
20
+ t[n] = o[n];
21
+ }
22
+ return t;
23
+ }
24
+ export {
25
+ c as addTokenUsage,
26
+ s as emptyTokenUsage,
27
+ r as readTokenUsage
28
+ };
29
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sources":["../../../../src/import/usage.ts"],"sourcesContent":["/** Disjoint provider-reported token counts. Input excludes cache reads and writes. */\nexport interface AiTokenUsage {\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens: number;\n cacheWriteTokens: number;\n}\nexport const emptyTokenUsage = (): AiTokenUsage => ({\n inputTokens: 0,\n outputTokens: 0,\n cacheReadTokens: 0,\n cacheWriteTokens: 0,\n});\nexport function addTokenUsage(a: AiTokenUsage, b: AiTokenUsage): AiTokenUsage {\n return {\n inputTokens: a.inputTokens + b.inputTokens,\n outputTokens: a.outputTokens + b.outputTokens,\n cacheReadTokens: a.cacheReadTokens + b.cacheReadTokens,\n cacheWriteTokens: a.cacheWriteTokens + b.cacheWriteTokens,\n };\n}\nexport function readTokenUsage(value: unknown): AiTokenUsage {\n if (!value || typeof value !== 'object') throw new Error('Invalid import token usage.');\n const usage = value as AiTokenUsage;\n const result = emptyTokenUsage();\n for (const key of Object.keys(result) as (keyof AiTokenUsage)[]) {\n if (!Number.isSafeInteger(usage[key]) || usage[key] < 0) throw new Error('Invalid import token usage.');\n result[key] = usage[key];\n }\n return result;\n}\n"],"names":["emptyTokenUsage","addTokenUsage","a","b","readTokenUsage","value","usage","result","key"],"mappings":"AAOO,MAAMA,IAAkB,OAAqB;AAAA,EAClD,aAAa;AAAA,EACb,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,kBAAkB;AACpB;AACO,SAASC,EAAcC,GAAiBC,GAA+B;AAC5E,SAAO;AAAA,IACL,aAAaD,EAAE,cAAcC,EAAE;AAAA,IAC/B,cAAcD,EAAE,eAAeC,EAAE;AAAA,IACjC,iBAAiBD,EAAE,kBAAkBC,EAAE;AAAA,IACvC,kBAAkBD,EAAE,mBAAmBC,EAAE;AAAA,EAAA;AAE7C;AACO,SAASC,EAAeC,GAA8B;AAC3D,MAAI,CAACA,KAAS,OAAOA,KAAU,SAAU,OAAM,IAAI,MAAM,6BAA6B;AACtF,QAAMC,IAAQD,GACRE,IAASP,EAAA;AACf,aAAWQ,KAAO,OAAO,KAAKD,CAAM,GAA6B;AAC/D,QAAI,CAAC,OAAO,cAAcD,EAAME,CAAG,CAAC,KAAKF,EAAME,CAAG,IAAI,EAAG,OAAM,IAAI,MAAM,6BAA6B;AACtG,IAAAD,EAAOC,CAAG,IAAIF,EAAME,CAAG;AAAA,EACzB;AACA,SAAOD;AACT;"}
@@ -0,0 +1,112 @@
1
+ import "polygon-clipping";
2
+ import { MIN_SEGMENT as d } from "../model/geometry.js";
3
+ function g(c, r, h, t, l, u = "both", i = "union") {
4
+ const n = [], o = /* @__PURE__ */ new Set();
5
+ for (const a of c) {
6
+ if (o.has(a)) continue;
7
+ let s = null;
8
+ for (const f of r) {
9
+ if (f === a || o.has(f) || f.axis !== a.axis) continue;
10
+ const e = Math.abs(f.c - a.c);
11
+ e < h || e > t || Math.min(a.hi, f.hi) - Math.max(a.lo, f.lo) < l || (!s || e < s.t) && (s = { other: f, t: e });
12
+ }
13
+ if (!s) continue;
14
+ o.add(a), o.add(s.other);
15
+ const M = u === "both" ? a.gaps.filter((f) => s.other.gaps.some((e) => Math.max(f[0], e[0]) < Math.min(f[1], e[1]))) : [
16
+ ...a.gaps,
17
+ ...s.other.gaps.filter((f) => !a.gaps.some((e) => Math.max(e[0], f[0]) < Math.min(e[1], f[1])))
18
+ ];
19
+ n.push({
20
+ axis: a.axis,
21
+ c: (a.c + s.other.c) / 2,
22
+ lo: i === "union" ? Math.min(a.lo, s.other.lo) : Math.max(a.lo, s.other.lo),
23
+ hi: i === "union" ? Math.max(a.hi, s.other.hi) : Math.min(a.hi, s.other.hi),
24
+ thickness: Math.round(s.t * 1e3) / 1e3,
25
+ gaps: M.map((f) => [...f])
26
+ });
27
+ }
28
+ return x(n);
29
+ }
30
+ function x(c) {
31
+ const r = [];
32
+ for (const h of c) {
33
+ const t = r.find(
34
+ (i) => i.axis === h.axis && // Bodies intersect across the wall, not merely run near each other.
35
+ Math.abs(i.c - h.c) < (i.thickness + h.thickness) / 2 - 1e-6 && // …and they cover the same stretch along it.
36
+ Math.min(i.hi, h.hi) - Math.max(i.lo, h.lo) > 0
37
+ );
38
+ if (!t) {
39
+ r.push(h);
40
+ continue;
41
+ }
42
+ const l = Math.min(t.c - t.thickness / 2, h.c - h.thickness / 2), u = Math.max(t.c + t.thickness / 2, h.c + h.thickness / 2);
43
+ t.c = (l + u) / 2, t.thickness = Math.round((u - l) * 1e3) / 1e3, t.lo = Math.min(t.lo, h.lo), t.hi = Math.max(t.hi, h.hi), t.gaps = t.gaps.filter((i) => h.gaps.some((n) => Math.max(i[0], n[0]) < Math.min(i[1], n[1])));
44
+ }
45
+ return r;
46
+ }
47
+ const k = (c, r) => c.axis === "h" ? [r, c.c] : [c.c, r];
48
+ function E(c, r) {
49
+ const h = c.gaps.find((t) => Math.max(t[0], r[0]) < Math.min(t[1], r[1]));
50
+ h ? (h[0] = Math.min(h[0], r[0]), h[1] = Math.max(h[1], r[1])) : c.gaps.push([...r]);
51
+ }
52
+ function N(c, r, h = 0.45) {
53
+ for (const t of c)
54
+ for (const l of ["lo", "hi"]) {
55
+ const i = r.filter((o) => o !== t && o.axis !== t.axis && t.c > o.lo - 0.3 && t.c < o.hi + 0.3).map((o) => ({ c: o.c, d: Math.abs(o.c - t[l]) })).sort((o, a) => o.d - a.d)[0];
56
+ if (!i || i.d > h || i.d < 5e-3) continue;
57
+ const n = { ...t, [l]: i.c };
58
+ n.hi - n.lo > d && (t[l] = i.c);
59
+ }
60
+ for (const t of r) {
61
+ const l = [];
62
+ for (const n of c)
63
+ if (!(n.axis === t.axis || n.c <= t.lo + 0.01 || n.c >= t.hi - 0.01))
64
+ for (const o of ["lo", "hi"]) Math.abs(n[o] - t.c) < 0.01 && l.push({ w: n, end: o, at: n.c });
65
+ const u = (n) => n.w.gaps.some((o) => Math.min(Math.abs(o[0] - n.w[n.end]), Math.abs(o[1] - n.w[n.end])) < 1), i = [...l].sort(
66
+ (n, o) => Number(u(n)) - Number(u(o)) || n.w.thickness - o.w.thickness || o.at - n.at
67
+ );
68
+ for (const n of i) {
69
+ if (Math.abs(n.w[n.end] - t.c) > 0.01) continue;
70
+ const o = [t.lo, t.hi, ...l.filter((e) => e !== n && Math.abs(e.w[e.end] - t.c) < 0.01).map((e) => e.at)];
71
+ if (Math.min(...o.filter((e) => Math.abs(e - n.at) > 1e-9).map((e) => Math.abs(e - n.at))) >= d) continue;
72
+ const s = t.thickness / 2 + 0.01, M = n.end === "lo" ? t.c + s : t.c - s, f = { ...n.w, [n.end]: M };
73
+ f.hi - f.lo > d && (n.w[n.end] = M);
74
+ }
75
+ }
76
+ }
77
+ function S(c) {
78
+ for (const r of c) {
79
+ const h = c.filter((t) => t.axis !== r.axis);
80
+ for (const t of ["lo", "hi"]) {
81
+ const l = h.map((u) => ({ o: u, d: Math.abs(u.c - r[t]) })).sort((u, i) => u.d - i.d)[0];
82
+ l && l.d < 0.8 && (r[t] = l.o.c);
83
+ }
84
+ }
85
+ }
86
+ function w(c) {
87
+ if (c.length < 4) return null;
88
+ const r = c.reduce((a, s) => a + (s.axis === "v" ? s.c : (s.lo + s.hi) / 2), 0) / c.length, h = c.reduce((a, s) => a + (s.axis === "h" ? s.c : (s.lo + s.hi) / 2), 0) / c.length, t = (a) => {
89
+ const s = a.axis === "h" ? Math.sign(h - a.c) : Math.sign(r - a.c);
90
+ return a.c + (s || 1) * (a.thickness / 2);
91
+ }, l = (a, s, M) => Math.abs(M.c - s) < 0.8 && (Math.abs(M.lo - a.c) < 0.8 || Math.abs(M.hi - a.c) < 0.8), u = new Set(c);
92
+ let i = c[0];
93
+ u.delete(i);
94
+ let n = i.hi;
95
+ const o = [];
96
+ for (let a = 0; a < c.length; a++) {
97
+ const s = [...u].filter((e) => e.axis !== i.axis && l(i, n, e)).sort((e, m) => Math.abs(e.c - n) - Math.abs(m.c - n))[0], M = !s && !u.size && l(i, n, c[0]), f = s ?? (M ? c[0] : null);
98
+ if (!f) return null;
99
+ if (o.push(i.axis === "h" ? [t(f), t(i)] : [t(i), t(f)]), !s) break;
100
+ n = Math.abs(s.lo - i.c) < Math.abs(s.hi - i.c) ? s.hi : s.lo, i = s, u.delete(i);
101
+ }
102
+ return u.size || o.length < 4 ? null : o;
103
+ }
104
+ export {
105
+ E as addGap,
106
+ k as along,
107
+ S as closeCorners,
108
+ g as pairWalls,
109
+ N as snapEnds,
110
+ w as traceRing
111
+ };
112
+ //# sourceMappingURL=walls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walls.js","sources":["../../../../src/import/walls.ts"],"sourcesContent":["// Wall reconstruction: face runs pair into walls, walls chain into the envelope ring. Pure\n// geometry over runs.ts — nothing here touches a ProjectDocument.\nimport { MIN_SEGMENT } from '../schema';\nimport type { Point } from '../schema';\nimport type { Run } from './runs';\n\nexport interface Wall {\n axis: 'h' | 'v';\n c: number;\n lo: number;\n hi: number;\n thickness: number;\n gaps: [number, number][];\n}\n\n/** Pair opposing face runs into walls: same axis, cross-distance within a wall thickness, intervals\n * overlapping. The wall sits on the centreline. `gapMode` decides what counts as an opening: for\n * partitions both faces must break ('both'); for the envelope the silhouette line is often drawn\n * continuous, so a break in either face counts ('either'). */\nexport function pairWalls(\n a: Run[],\n b: Run[],\n minT: number,\n maxT: number,\n minOverlap: number,\n gapMode: 'both' | 'either' = 'both',\n /** Wall extent from the pair: 'union' for the envelope (its faces fragment unevenly and corners\n * are closed afterwards); 'overlap' for partitions — a wall exists only where BOTH faces do,\n * and taking the union would stretch it over stretches where a lone line means something else. */\n extentMode: 'union' | 'overlap' = 'union',\n): Wall[] {\n const walls: Wall[] = [];\n const used = new Set<Run>();\n for (const one of a) {\n if (used.has(one)) continue;\n let best: { other: Run; t: number } | null = null;\n for (const other of b) {\n if (other === one || used.has(other) || other.axis !== one.axis) continue;\n const t = Math.abs(other.c - one.c);\n if (t < minT || t > maxT) continue;\n const overlap = Math.min(one.hi, other.hi) - Math.max(one.lo, other.lo);\n if (overlap < minOverlap) continue;\n if (!best || t < best.t) best = { other, t };\n }\n if (!best) continue;\n used.add(one);\n used.add(best.other);\n const gaps =\n gapMode === 'both'\n ? one.gaps.filter(g => best!.other.gaps.some(h => Math.max(g[0], h[0]) < Math.min(g[1], h[1])))\n : [\n ...one.gaps,\n ...best.other.gaps.filter(h => !one.gaps.some(g => Math.max(g[0], h[0]) < Math.min(g[1], h[1]))),\n ];\n walls.push({\n axis: one.axis,\n c: (one.c + best.other.c) / 2,\n lo: extentMode === 'union' ? Math.min(one.lo, best.other.lo) : Math.max(one.lo, best.other.lo),\n hi: extentMode === 'union' ? Math.max(one.hi, best.other.hi) : Math.min(one.hi, best.other.hi),\n thickness: Math.round(best.t * 1000) / 1000,\n gaps: gaps.map(g => [...g] as [number, number]),\n });\n }\n return mergeSolids(walls);\n}\n\n/** Collapse walls whose bodies occupy the same space into one spanning the outermost faces.\n *\n * Pairing consumes each run once and takes the nearest partner, which is right when a wall is drawn\n * as exactly two face lines. Some offices draw four — sheathing, both sides of the stud frame, and\n * the inner lining — and those pair up as two thin walls standing inside each other. Two walls\n * cannot occupy the same volume, so where the bodies overlap the drawing meant one wall, and its\n * faces are the outermost lines. On a two-line drawing no two walls overlap and this does nothing. */\nfunction mergeSolids(walls: Wall[]): Wall[] {\n const out: Wall[] = [];\n for (const w of walls) {\n const host = out.find(\n o =>\n o.axis === w.axis &&\n // Bodies intersect across the wall, not merely run near each other.\n Math.abs(o.c - w.c) < (o.thickness + w.thickness) / 2 - 1e-6 &&\n // …and they cover the same stretch along it.\n Math.min(o.hi, w.hi) - Math.max(o.lo, w.lo) > 0,\n );\n if (!host) {\n out.push(w);\n continue;\n }\n const lo = Math.min(host.c - host.thickness / 2, w.c - w.thickness / 2);\n const hi = Math.max(host.c + host.thickness / 2, w.c + w.thickness / 2);\n host.c = (lo + hi) / 2;\n host.thickness = Math.round((hi - lo) * 1000) / 1000;\n host.lo = Math.min(host.lo, w.lo);\n host.hi = Math.max(host.hi, w.hi);\n // An opening is only an opening where both readings agree it is one.\n host.gaps = host.gaps.filter(g => w.gaps.some(h => Math.max(g[0], h[0]) < Math.min(g[1], h[1])));\n }\n return out;\n}\n\nexport const wallEnds = (w: Wall): [Point, Point] =>\n w.axis === 'h'\n ? [\n [w.lo, w.c],\n [w.hi, w.c],\n ]\n : [\n [w.c, w.lo],\n [w.c, w.hi],\n ];\nexport const along = (w: Wall, t: number): Point => (w.axis === 'h' ? [t, w.c] : [w.c, t]);\n\n/** Merge an opening gap into a wall, unioning with any gap it overlaps — both faces usually report\n * the same opening at slightly different extents, and it must become ONE opening. */\nexport function addGap(w: Wall, gap: [number, number]) {\n const twin = w.gaps.find(g => Math.max(g[0], gap[0]) < Math.min(g[1], gap[1]));\n if (twin) {\n twin[0] = Math.min(twin[0], gap[0]);\n twin[1] = Math.max(twin[1], gap[1]);\n } else w.gaps.push([...gap]);\n}\n\n/** Snap wall ends onto the centreline of the perpendicular wall they meet. CAD face lines are\n * drawn to the crossing wall's far face — or stop at its near one — so raw run extents overshoot\n * or undershoot T-junctions by half a thickness. Landing exactly on the centreline is what a\n * hand-drawn wall does in the editor, and it is what lets rendered caps disappear inside the\n * crossing wall instead of poking past it. */\nexport function snapEnds(walls: Wall[], targets: Wall[], tolerance = 0.45) {\n for (const w of walls) {\n for (const end of ['lo', 'hi'] as const) {\n const candidates = targets\n .filter(t => t !== w && t.axis !== w.axis && w.c > t.lo - 0.3 && w.c < t.hi + 0.3)\n .map(t => ({ c: t.c, d: Math.abs(t.c - w[end]) }))\n .sort((x, y) => x.d - y.d);\n const near = candidates[0];\n if (!near || near.d > tolerance || near.d < 0.005) continue;\n const next = { ...w, [end]: near.c } as Wall;\n if (next.hi - next.lo > MIN_SEGMENT) w[end] = near.c;\n }\n }\n // An end landing on a wall's centreline welds a junction there and splits the wall (joinAt), so\n // two T-ends closer together than a legal segment — a staggered junction — would leave\n // sub-MIN_SEGMENT debris the document refuses. Retract such an end to the target's near FACE\n // instead: visually flush, hidden under the crossing wall's stroke, but far enough off the\n // centreline that no junction welds.\n for (const t of targets) {\n const tees: { w: Wall; end: 'lo' | 'hi'; at: number }[] = [];\n for (const w of walls) {\n if (w.axis === t.axis || w.c <= t.lo + 0.01 || w.c >= t.hi - 0.01) continue;\n for (const end of ['lo', 'hi'] as const) if (Math.abs(w[end] - t.c) < 0.01) tees.push({ w, end, at: w.c });\n }\n // Retract one end at a time and re-check: a staggered pair needs only ONE of its two ends\n // pulled back to make the junctions legal, and the one to keep welded is the end whose wall\n // has an opening close by — a retracted end eats into the clearance that opening needs.\n const gapNearEnd = (x: (typeof tees)[number]) =>\n x.w.gaps.some(g => Math.min(Math.abs(g[0] - x.w[x.end]), Math.abs(g[1] - x.w[x.end])) < 1);\n const pending = [...tees].sort(\n (x, y) => Number(gapNearEnd(x)) - Number(gapNearEnd(y)) || x.w.thickness - y.w.thickness || y.at - x.at,\n );\n for (const tee of pending) {\n if (Math.abs(tee.w[tee.end] - t.c) > 0.01) continue; // already retracted\n const points = [t.lo, t.hi, ...tees.filter(x => x !== tee && Math.abs(x.w[x.end] - t.c) < 0.01).map(x => x.at)];\n const nearest = Math.min(...points.filter(p => Math.abs(p - tee.at) > 1e-9).map(p => Math.abs(p - tee.at)));\n if (nearest >= MIN_SEGMENT) continue;\n const back = t.thickness / 2 + 0.01;\n const retracted = tee.end === 'lo' ? t.c + back : t.c - back;\n const next = { ...tee.w, [tee.end]: retracted } as Wall;\n if (next.hi - next.lo > MIN_SEGMENT) tee.w[tee.end] = retracted;\n }\n }\n}\n\n/** Extend each envelope wall to the centreline of its perpendicular neighbours, closing corners. */\nexport function closeCorners(envelope: Wall[]) {\n for (const w of envelope) {\n const perpendicular = envelope.filter(o => o.axis !== w.axis);\n for (const end of ['lo', 'hi'] as const) {\n const near = perpendicular.map(o => ({ o, d: Math.abs(o.c - w[end]) })).sort((x, y) => x.d - y.d)[0];\n if (near && near.d < 0.8) w[end] = near.o.c;\n }\n }\n}\n\n/** Chain envelope walls into the closed inner-face ring. Each corner is the intersection of two\n * adjacent walls' INNER faces (centreline offset half a thickness toward the building), so the\n * plate is the actual floor area, not the wall footprint. Handles L and T footprints; returns\n * null when the walls do not close into one loop. */\nexport function traceRing(envelope: Wall[]): Point[] | null {\n if (envelope.length < 4) return null;\n const cx = envelope.reduce((s, w) => s + (w.axis === 'v' ? w.c : (w.lo + w.hi) / 2), 0) / envelope.length;\n const cy = envelope.reduce((s, w) => s + (w.axis === 'h' ? w.c : (w.lo + w.hi) / 2), 0) / envelope.length;\n const innerC = (w: Wall) => {\n const towards = w.axis === 'h' ? Math.sign(cy - w.c) : Math.sign(cx - w.c);\n return w.c + (towards || 1) * (w.thickness / 2);\n };\n // Adjacency: two perpendicular walls meet when each one's centreline lies near an END of the\n // other's interval. Walk the loop by always leaving through the end we did not enter by.\n const meets = (a: Wall, end: number, b: Wall) =>\n Math.abs(b.c - end) < 0.8 && (Math.abs(b.lo - a.c) < 0.8 || Math.abs(b.hi - a.c) < 0.8);\n const unvisited = new Set(envelope);\n let current = envelope[0];\n unvisited.delete(current);\n let exitEnd = current.hi;\n const ring: Point[] = [];\n for (let steps = 0; steps < envelope.length; steps++) {\n const next = [...unvisited]\n .filter(w => w.axis !== current.axis && meets(current, exitEnd, w))\n .sort((x, y) => Math.abs(x.c - exitEnd) - Math.abs(y.c - exitEnd))[0];\n const closes = !next && !unvisited.size && meets(current, exitEnd, envelope[0]);\n const partner = next ?? (closes ? envelope[0] : null);\n if (!partner) return null;\n ring.push(current.axis === 'h' ? [innerC(partner), innerC(current)] : [innerC(current), innerC(partner)]);\n if (!next) break;\n // Enter `next` at the end near the wall we came from; leave through the other one.\n exitEnd = Math.abs(next.lo - current.c) < Math.abs(next.hi - current.c) ? next.hi : next.lo;\n current = next;\n unvisited.delete(current);\n }\n if (unvisited.size || ring.length < 4) return null;\n return ring;\n}\n"],"names":["pairWalls","a","b","minT","maxT","minOverlap","gapMode","extentMode","walls","used","one","best","other","t","gaps","g","h","mergeSolids","out","w","host","o","lo","hi","along","addGap","gap","twin","snapEnds","targets","tolerance","end","near","x","y","next","MIN_SEGMENT","tees","gapNearEnd","pending","tee","points","p","back","retracted","closeCorners","envelope","perpendicular","traceRing","cx","s","cy","innerC","towards","meets","unvisited","current","exitEnd","ring","steps","closes","partner"],"mappings":";;AAmBO,SAASA,EACdC,GACAC,GACAC,GACAC,GACAC,GACAC,IAA6B,QAI7BC,IAAkC,SAC1B;AACR,QAAMC,IAAgB,CAAA,GAChBC,wBAAW,IAAA;AACjB,aAAWC,KAAOT,GAAG;AACnB,QAAIQ,EAAK,IAAIC,CAAG,EAAG;AACnB,QAAIC,IAAyC;AAC7C,eAAWC,KAASV,GAAG;AACrB,UAAIU,MAAUF,KAAOD,EAAK,IAAIG,CAAK,KAAKA,EAAM,SAASF,EAAI,KAAM;AACjE,YAAMG,IAAI,KAAK,IAAID,EAAM,IAAIF,EAAI,CAAC;AAGlC,MAFIG,IAAIV,KAAQU,IAAIT,KACJ,KAAK,IAAIM,EAAI,IAAIE,EAAM,EAAE,IAAI,KAAK,IAAIF,EAAI,IAAIE,EAAM,EAAE,IACxDP,MACV,CAACM,KAAQE,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I,OAAO,KAAK,IAAIA,EAAE,KAAK,EAAE,CAAC,IAAI,MAC/EqD,IAAY,IAAI,IAAIT,CAAQ;AAClC,MAAIU,IAAUV,EAAS,CAAC;AACxB,EAAAS,EAAU,OAAOC,CAAO;AACxB,MAAIC,IAAUD,EAAQ;AACtB,QAAME,IAAgB,CAAA;AACtB,WAASC,IAAQ,GAAGA,IAAQb,EAAS,QAAQa,KAAS;AACpD,UAAMxB,IAAO,CAAC,GAAGoB,CAAS,EACvB,OAAO,CAAApC,MAAKA,EAAE,SAASqC,EAAQ,QAAQF,EAAME,GAASC,GAAStC,CAAC,CAAC,EACjE,KAAK,CAACc,GAAGC,MAAM,KAAK,IAAID,EAAE,IAAIwB,CAAO,IAAI,KAAK,IAAIvB,EAAE,IAAIuB,CAAO,CAAC,EAAE,CAAC,GAChEG,IAAS,CAACzB,KAAQ,CAACoB,EAAU,QAAQD,EAAME,GAASC,GAASX,EAAS,CAAC,CAAC,GACxEe,IAAU1B,MAASyB,IAASd,EAAS,CAAC,IAAI;AAChD,QAAI,CAACe,EAAS,QAAO;AAErB,QADAH,EAAK,KAAKF,EAAQ,SAAS,MAAM,CAACJ,EAAOS,CAAO,GAAGT,EAAOI,CAAO,CAAC,IAAI,CAACJ,EAAOI,CAAO,GAAGJ,EAAOS,CAAO,CAAC,CAAC,GACpG,CAAC1B,EAAM;AAEX,IAAAsB,IAAU,KAAK,IAAItB,EAAK,KAAKqB,EAAQ,CAAC,IAAI,KAAK,IAAIrB,EAAK,KAAKqB,EAAQ,CAAC,IAAIrB,EAAK,KAAKA,EAAK,IACzFqB,IAAUrB,GACVoB,EAAU,OAAOC,CAAO;AAAA,EAC1B;AACA,SAAID,EAAU,QAAQG,EAAK,SAAS,IAAU,OACvCA;AACT;"}
package/dist/index.js ADDED
@@ -0,0 +1,178 @@
1
+ import { SitePlanner as r, SiteViewer as t } from "./SitePlanner.js";
2
+ import { IndexedAssetRepository as i, IndexedProjectRepository as s, LocalProjectRepository as n } from "./adapters/persistence.js";
3
+ import { neutralBasemap as d } from "./adapters/basemap.js";
4
+ import { KerrosThemeProvider as f, useDarkMode as m, useKerrosTheme as l, useStrings as E } from "./theme/index.js";
5
+ import { enclosedRegion as R, enclosedRegions as u, inSpace as x, refitEnclosedRooms as P, spaceAt as v, spacePoint as S, spaces as y } from "./model/spaces.js";
6
+ import { addPortalGroup as O, addZone as T, captive as A, entryInto as _, nestZone as L, perimeter as b, pruneOntology as B, removePortalGroup as I, removeZone as N, setPortalGroupMembers as j, setZoneMembers as M, zoneSpaces as V } from "./model/ontology.js";
7
+ import { divideSpaces as F, inferOpenBoundaries as C, inferPortals as G, mergeSpaces as w, refreshPortals as K, spacesDividedBy as Z, spacesRejoinedBy as z } from "./model/inference.js";
8
+ import { derivedGraph as U } from "./model/topology.js";
9
+ import { effectivePortals as X, sharedBoundaryPortals as Y } from "./model/portals.js";
10
+ import { OBJECT_KINDS as W, isArea as q, isDevice as Q, isOpening as $, isSpace as ee, uid as oe } from "./model/types.js";
11
+ import { createObject as te, emptyProject as ae } from "./model/factory.js";
12
+ import { addBoundaryHole as se, addVirtualBoundary as ne, bindSpaceToRegion as pe, boundaryEdges as de, boundaryRegionAt as ce, boundaryRegions as fe, boundaryRings as me, connectSpace as le, derivedSpaceRings as Ee, disconnectSpace as ge, drawVirtualBoundary as Re, followsBoundaries as ue, normalizeBoundaries as xe, refreshBoundarySpaces as Pe } from "./model/boundaries.js";
13
+ import { DEFAULT_FOV as Se, DEFAULT_RANGE as ye, coverageOf as he } from "./model/coverage.js";
14
+ import { copyProject as Te, openingFloorId as Ae } from "./model/project.js";
15
+ import { MIN_SEGMENT as Le, OPENING_MIN_SEGMENT as be, addBarrier as Be, barrierEnds as Ie, centroid as Ne, closeRing as je, distance as Me, duplicateFloor as Ve, footprint as De, geoOrigin as Fe, moveOrigin as Ce, objectArea as Ge, objectPosition as we, objectRotation as Ke, openRing as Ze, pointInRing as ze, rectangle as He, removeFloor as Ue, ringArea as ke, rotate as Xe, segmentProjection as Ye, segmentsCross as Je, slopeElevation as We, toLngLat as qe, toLocal as Qe } from "./model/geometry.js";
16
+ import { blobDataUrl as eo, exportProject as oo, importProject as ro, parseExport as to } from "./model/document.js";
17
+ import { COORD_LIMIT as io, freezeProject as so, transact as no, validateNavigation as po, validateProject as co, validateRelationships as fo, validateRings as mo } from "./model/validate.js";
18
+ import { applyMutation as Eo, applyMutations as go } from "./model/mutations.js";
19
+ import { DOOR_COST as uo, ELEVATOR_BASE as xo, ELEVATOR_PER_METRE as Po, HERE as vo, NAV_WELD as So, STAIR_CLIMB_FACTOR as yo, addNavEdge as ho, addNavNode as Oo, chainVertical as To, edgeCost as Ao, edgeLength as _o, findRoute as Lo, floorPhrase as bo, navEdges as Bo, navNodes as Io, navPath as No, routeAnchors as jo, routeSteps as Mo } from "./model/navigation.js";
20
+ import { EXTERIOR_PRESETS as Do } from "./model/materials.js";
21
+ import { PITCH as Co, flights as Go, flightsAt as wo, isVertical as Ko, passesThrough as Zo, pitchOf as zo, primaryShafts as Ho, reaches as Uo, runFor as ko, servedFloors as Xo, shaftKey as Yo, shaftVoids as Jo, span as Wo } from "./model/vertical.js";
22
+ import { buildRoomNavigation as Qo } from "./model/roomNavigation.js";
23
+ import { importPlanEntities as er } from "./import/planImport.js";
24
+ import { VERTEX_LAYERS as rr } from "./import/types.js";
25
+ import { LAYER_ROLES as ar, detectLayers as ir, layerPattern as sr } from "./import/detect.js";
26
+ import { documentSvg as pr } from "./import/documentSvg.js";
27
+ import { landmarks as cr, sheetOffset as fr, shiftEntities as mr } from "./import/register.js";
28
+ import { StructureView as Er } from "./components/StructureView.js";
29
+ export {
30
+ io as COORD_LIMIT,
31
+ Se as DEFAULT_FOV,
32
+ ye as DEFAULT_RANGE,
33
+ uo as DOOR_COST,
34
+ xo as ELEVATOR_BASE,
35
+ Po as ELEVATOR_PER_METRE,
36
+ Do as EXTERIOR_PRESETS,
37
+ r as FloorEditor,
38
+ vo as HERE,
39
+ i as IndexedAssetRepository,
40
+ s as IndexedProjectRepository,
41
+ f as KerrosThemeProvider,
42
+ ar as LAYER_ROLES,
43
+ n as LocalProjectRepository,
44
+ Le as MIN_SEGMENT,
45
+ So as NAV_WELD,
46
+ W as OBJECT_KINDS,
47
+ be as OPENING_MIN_SEGMENT,
48
+ Co as PITCH,
49
+ yo as STAIR_CLIMB_FACTOR,
50
+ t as SiteViewer,
51
+ Er as StructureView,
52
+ rr as VERTEX_LAYERS,
53
+ Be as addBarrier,
54
+ se as addBoundaryHole,
55
+ ho as addNavEdge,
56
+ Oo as addNavNode,
57
+ O as addPortalGroup,
58
+ ne as addVirtualBoundary,
59
+ T as addZone,
60
+ Eo as applyMutation,
61
+ go as applyMutations,
62
+ Ie as barrierEnds,
63
+ pe as bindSpaceToRegion,
64
+ eo as blobDataUrl,
65
+ de as boundaryEdges,
66
+ ce as boundaryRegionAt,
67
+ fe as boundaryRegions,
68
+ me as boundaryRings,
69
+ Qo as buildRoomNavigation,
70
+ A as captive,
71
+ Ne as centroid,
72
+ To as chainVertical,
73
+ je as closeRing,
74
+ le as connectSpace,
75
+ Te as copyProject,
76
+ he as coverageOf,
77
+ te as createObject,
78
+ U as derivedGraph,
79
+ Ee as derivedSpaceRings,
80
+ ir as detectLayers,
81
+ ge as disconnectSpace,
82
+ Me as distance,
83
+ F as divideSpaces,
84
+ pr as documentSvg,
85
+ Re as drawVirtualBoundary,
86
+ Ve as duplicateFloor,
87
+ Ao as edgeCost,
88
+ _o as edgeLength,
89
+ X as effectivePortals,
90
+ ae as emptyProject,
91
+ R as enclosedRegion,
92
+ u as enclosedRegions,
93
+ _ as entryInto,
94
+ oo as exportProject,
95
+ Lo as findRoute,
96
+ Go as flights,
97
+ wo as flightsAt,
98
+ bo as floorPhrase,
99
+ ue as followsBoundaries,
100
+ De as footprint,
101
+ so as freezeProject,
102
+ Fe as geoOrigin,
103
+ er as importPlanEntities,
104
+ ro as importProject,
105
+ x as inSpace,
106
+ C as inferOpenBoundaries,
107
+ G as inferPortals,
108
+ q as isArea,
109
+ Q as isDevice,
110
+ $ as isOpening,
111
+ ee as isSpace,
112
+ Ko as isVertical,
113
+ cr as landmarks,
114
+ sr as layerPattern,
115
+ w as mergeSpaces,
116
+ Ce as moveOrigin,
117
+ Bo as navEdges,
118
+ Io as navNodes,
119
+ No as navPath,
120
+ L as nestZone,
121
+ d as neutralBasemap,
122
+ xe as normalizeBoundaries,
123
+ Ge as objectArea,
124
+ we as objectPosition,
125
+ Ke as objectRotation,
126
+ Ze as openRing,
127
+ Ae as openingFloorId,
128
+ to as parseExport,
129
+ Zo as passesThrough,
130
+ b as perimeter,
131
+ zo as pitchOf,
132
+ ze as pointInRing,
133
+ Ho as primaryShafts,
134
+ B as pruneOntology,
135
+ Uo as reaches,
136
+ He as rectangle,
137
+ P as refitEnclosedRooms,
138
+ Pe as refreshBoundarySpaces,
139
+ K as refreshPortals,
140
+ Ue as removeFloor,
141
+ I as removePortalGroup,
142
+ N as removeZone,
143
+ ke as ringArea,
144
+ Xe as rotate,
145
+ jo as routeAnchors,
146
+ Mo as routeSteps,
147
+ ko as runFor,
148
+ Ye as segmentProjection,
149
+ Je as segmentsCross,
150
+ Xo as servedFloors,
151
+ j as setPortalGroupMembers,
152
+ M as setZoneMembers,
153
+ Yo as shaftKey,
154
+ Jo as shaftVoids,
155
+ Y as sharedBoundaryPortals,
156
+ fr as sheetOffset,
157
+ mr as shiftEntities,
158
+ We as slopeElevation,
159
+ v as spaceAt,
160
+ S as spacePoint,
161
+ y as spaces,
162
+ Z as spacesDividedBy,
163
+ z as spacesRejoinedBy,
164
+ Wo as span,
165
+ qe as toLngLat,
166
+ Qe as toLocal,
167
+ no as transact,
168
+ oe as uid,
169
+ m as useDarkMode,
170
+ l as useKerrosTheme,
171
+ E as useStrings,
172
+ po as validateNavigation,
173
+ co as validateProject,
174
+ fo as validateRelationships,
175
+ mo as validateRings,
176
+ V as zoneSpaces
177
+ };
178
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,81 @@
1
+ var S = Object.defineProperty;
2
+ var y = (r, e, s) => e in r ? S(r, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[e] = s;
3
+ var a = (r, e, s) => y(r, typeof e != "symbol" ? e + "" : e, s);
4
+ import * as t from "three";
5
+ class C {
6
+ constructor(e) {
7
+ a(this, "steel");
8
+ a(this, "trim");
9
+ a(this, "wall");
10
+ a(this, "floor");
11
+ a(this, "dark");
12
+ a(this, "lamp", new t.MeshBasicMaterial({ color: "#fff0d5", toneMapped: !1 }));
13
+ a(this, "display", new t.MeshBasicMaterial({ color: "#f5c985", toneMapped: !1 }));
14
+ a(this, "environment");
15
+ a(this, "target");
16
+ a(this, "textures", []);
17
+ a(this, "owned", []);
18
+ const s = document.createElement("canvas");
19
+ s.width = 512, s.height = 256;
20
+ const o = s.getContext("2d"), l = o.createLinearGradient(0, 0, 0, 256);
21
+ l.addColorStop(0, "#faf1dd"), l.addColorStop(0.24, "#d6cec2"), l.addColorStop(0.55, "#aaa49d"), l.addColorStop(1, "#55585a"), o.fillStyle = l, o.fillRect(0, 0, 512, 256);
22
+ for (const n of [35, 150, 305, 440])
23
+ o.fillStyle = "#fffaf0", o.fillRect(n, 12, 28, 65), o.fillStyle = "#ddd5c6", o.fillRect(n + 10, 90, 5, 80);
24
+ const c = new t.CanvasTexture(s);
25
+ c.mapping = t.EquirectangularReflectionMapping, c.colorSpace = t.SRGBColorSpace;
26
+ const M = new t.PMREMGenerator(e);
27
+ this.target = M.fromEquirectangular(c), this.environment = this.target.texture, c.dispose(), M.dispose(), e.resetState();
28
+ const d = document.createElement("canvas");
29
+ d.width = 256, d.height = 512;
30
+ const m = d.getContext("2d"), u = m.createImageData(256, 512);
31
+ let p = 821;
32
+ const g = () => (p = Math.imul(p, 1664525) + 1013904223 | 0, (p >>> 0) / 4294967295), v = Array.from({ length: 256 }, () => g());
33
+ for (let n = 0; n < 512; n++)
34
+ for (let h = 0; h < 256; h++) {
35
+ const f = 190 + v[h] * 35 + g() * 6, w = (n * 256 + h) * 4;
36
+ u.data.set([f, f, f, 255], w);
37
+ }
38
+ m.putImageData(u, 0, 0);
39
+ const i = new t.CanvasTexture(d);
40
+ i.wrapS = i.wrapT = t.RepeatWrapping, i.repeat.set(2, 1), i.colorSpace = t.SRGBColorSpace, this.textures.push(i), this.steel = new t.MeshPhysicalMaterial({
41
+ color: "#c2c7cc",
42
+ map: i,
43
+ roughness: 0.3,
44
+ metalness: 0.92,
45
+ anisotropy: 0.65,
46
+ anisotropyRotation: Math.PI / 2,
47
+ envMap: this.environment,
48
+ envMapIntensity: 1.35
49
+ }), this.steel.userData.cabinSteel = !0, this.trim = new t.MeshStandardMaterial({
50
+ color: "#cbd0d3",
51
+ metalness: 0.95,
52
+ roughness: 0.18,
53
+ envMap: this.environment,
54
+ envMapIntensity: 1.4
55
+ }), this.wall = new t.MeshStandardMaterial({
56
+ color: "#b4a89a",
57
+ metalness: 0.05,
58
+ roughness: 0.65,
59
+ envMap: this.environment,
60
+ envMapIntensity: 1
61
+ }), this.floor = new t.MeshStandardMaterial({
62
+ color: "#6f7370",
63
+ roughness: 0.83,
64
+ envMap: this.environment,
65
+ envMapIntensity: 1.3
66
+ }), this.dark = new t.MeshStandardMaterial({
67
+ color: "#17232c",
68
+ roughness: 0.6,
69
+ envMap: this.environment,
70
+ envMapIntensity: 0.8
71
+ }), this.owned = [this.steel, this.trim, this.wall, this.floor, this.dark, this.lamp, this.display];
72
+ for (const n of this.owned) n.userData.shared = !0;
73
+ }
74
+ dispose() {
75
+ this.owned.forEach((e) => e.dispose()), this.textures.forEach((e) => e.dispose()), this.target.dispose();
76
+ }
77
+ }
78
+ export {
79
+ C as CabinMaterials
80
+ };
81
+ //# sourceMappingURL=CabinMaterials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CabinMaterials.js","sources":["../../../../src/map/CabinMaterials.ts"],"sourcesContent":["import * as THREE from 'three';\n\n/** Private cabin finishes: their lighting environment is the ceiling diffuser, even in a dark\n * basement. Metals reflect this environment; the cabin walls do not glow like the old grey box. */\nexport class CabinMaterials {\n readonly steel: THREE.MeshPhysicalMaterial;\n readonly trim: THREE.MeshStandardMaterial;\n readonly wall: THREE.MeshStandardMaterial;\n readonly floor: THREE.MeshStandardMaterial;\n readonly dark: THREE.MeshStandardMaterial;\n readonly lamp = new THREE.MeshBasicMaterial({ color: '#fff0d5', toneMapped: false });\n readonly display = new THREE.MeshBasicMaterial({ color: '#f5c985', toneMapped: false });\n readonly environment: THREE.Texture;\n private target: THREE.WebGLRenderTarget;\n private textures: THREE.Texture[] = [];\n private owned: THREE.Material[] = [];\n constructor(renderer: THREE.WebGLRenderer) {\n const canvas = document.createElement('canvas');\n canvas.width = 512;\n canvas.height = 256;\n const ctx = canvas.getContext('2d')!;\n const gradient = ctx.createLinearGradient(0, 0, 0, 256);\n gradient.addColorStop(0, '#faf1dd');\n gradient.addColorStop(0.24, '#d6cec2');\n gradient.addColorStop(0.55, '#aaa49d');\n gradient.addColorStop(1, '#55585a');\n ctx.fillStyle = gradient;\n ctx.fillRect(0, 0, 512, 256);\n for (const x of [35, 150, 305, 440]) {\n ctx.fillStyle = '#fffaf0';\n ctx.fillRect(x, 12, 28, 65);\n ctx.fillStyle = '#ddd5c6';\n ctx.fillRect(x + 10, 90, 5, 80);\n }\n const environment = new THREE.CanvasTexture(canvas);\n environment.mapping = THREE.EquirectangularReflectionMapping;\n environment.colorSpace = THREE.SRGBColorSpace;\n const generator = new THREE.PMREMGenerator(renderer);\n this.target = generator.fromEquirectangular(environment);\n this.environment = this.target.texture;\n environment.dispose();\n generator.dispose();\n renderer.resetState();\n const grain = document.createElement('canvas');\n grain.width = 256;\n grain.height = 512;\n const g = grain.getContext('2d')!,\n pixels = g.createImageData(256, 512);\n let seed = 821;\n const random = () => {\n seed = (Math.imul(seed, 1664525) + 1013904223) | 0;\n return (seed >>> 0) / 0xffffffff;\n };\n const stripes = Array.from({ length: 256 }, () => random());\n for (let y = 0; y < 512; y++)\n for (let x = 0; x < 256; x++) {\n const value = 190 + stripes[x] * 35 + random() * 6;\n const i = (y * 256 + x) * 4;\n pixels.data.set([value, value, value, 255], i);\n }\n g.putImageData(pixels, 0, 0);\n const brushed = new THREE.CanvasTexture(grain);\n brushed.wrapS = brushed.wrapT = THREE.RepeatWrapping;\n brushed.repeat.set(2, 1);\n brushed.colorSpace = THREE.SRGBColorSpace;\n this.textures.push(brushed);\n this.steel = new THREE.MeshPhysicalMaterial({\n color: '#c2c7cc',\n map: brushed,\n roughness: 0.3,\n metalness: 0.92,\n anisotropy: 0.65,\n anisotropyRotation: Math.PI / 2,\n envMap: this.environment,\n envMapIntensity: 1.35,\n });\n this.steel.userData.cabinSteel = true;\n this.trim = new THREE.MeshStandardMaterial({\n color: '#cbd0d3',\n metalness: 0.95,\n roughness: 0.18,\n envMap: this.environment,\n envMapIntensity: 1.4,\n });\n this.wall = new THREE.MeshStandardMaterial({\n color: '#b4a89a',\n metalness: 0.05,\n roughness: 0.65,\n envMap: this.environment,\n envMapIntensity: 1.0,\n });\n this.floor = new THREE.MeshStandardMaterial({\n color: '#6f7370',\n roughness: 0.83,\n envMap: this.environment,\n envMapIntensity: 1.3,\n });\n this.dark = new THREE.MeshStandardMaterial({\n color: '#17232c',\n roughness: 0.6,\n envMap: this.environment,\n envMapIntensity: 0.8,\n });\n this.owned = [this.steel, this.trim, this.wall, this.floor, this.dark, this.lamp, this.display];\n for (const m of this.owned) m.userData.shared = true;\n }\n dispose() {\n this.owned.forEach(m => m.dispose());\n this.textures.forEach(t => t.dispose());\n this.target.dispose();\n }\n}\n"],"names":["CabinMaterials","renderer","__publicField","THREE","canvas","ctx","gradient","x","environment","generator","grain","g","pixels","seed","random","stripes","y","value","i","brushed","m","t"],"mappings":";;;;AAIO,MAAMA,EAAe;AAAA,EAY1B,YAAYC,GAA+B;AAXlC,IAAAC,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