@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,635 @@
1
+ import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
+ import { useState as d, useId as Ee, useRef as x, useEffect as q } from "react";
3
+ import { emptyTokenUsage as K, addTokenUsage as Re } from "../import/usage.js";
4
+ import { loadAiImportSession as We, saveAiImportSession as Ge } from "../import/session.js";
5
+ import { readImportBrief as Ue } from "../import/brief.js";
6
+ import { DEFAULT_IMPORT_BUDGET as Pe, readImportBudget as ue } from "../import/checkpoint.js";
7
+ import { readImportInstruction as $e, mergeImportInstructions as Je } from "../import/instructions.js";
8
+ import { AnalysisPreview as qe } from "./AnalysisPreview.js";
9
+ import { loadAnalysisPreview as Ke, deleteAnalysisPreview as ze, saveAnalysisPreview as Ye } from "../import/analysisPreview.js";
10
+ function nt({
11
+ adapter: j,
12
+ assets: N,
13
+ onProject: de,
14
+ onRunningChange: z,
15
+ currentProject: B
16
+ }) {
17
+ const [pe, De] = d(!0), [U, Y] = d("setup"), I = Ee(), [b, _] = d(null), [H, me] = d(""), [L, he] = d(""), [E, ge] = d(""), [Q, fe] = d(""), [R, be] = d(""), [W, ye] = d(""), [P, G] = d(""), [v, V] = d(Pe), [X, Z] = d(), [n, we] = d(null), o = x(n), $ = x(B), ee = x(de);
18
+ $.current = B, ee.current = de;
19
+ const [ve, Ie] = d(0), [Ne, f] = d(""), [g, te] = d(!1), [J, Ce] = d(!1), [re, Te] = d(), T = x(null), Se = x(Promise.resolve()), ne = x(null), ie = x(!0), c = (n == null ? void 0 : n.phase) === "running", ae = (n == null ? void 0 : n.phase) ?? "ready", oe = (n == null ? void 0 : n.messages) ?? [], D = (n == null ? void 0 : n.usage) ?? K(), Oe = (n == null ? void 0 : n.hasUsage) ?? !1, Ae = (n == null ? void 0 : n.edits) ?? 0, Fe = (n == null ? void 0 : n.activity) ?? "", m = (t) => {
20
+ o.current = t, we(t);
21
+ const e = Se.current.catch(() => {
22
+ }).then(() => Ge(N, t));
23
+ return Se.current = e, e;
24
+ };
25
+ q(() => {
26
+ let t = !0;
27
+ return We(N, B.id).then(async (e) => {
28
+ var u, h, C, l, y, s, w, k, p;
29
+ if (t && (o.current = e, we(e), me((e == null ? void 0 : e.instructions) ?? ""), G((e == null ? void 0 : e.followUp) ?? ""), he(((h = (u = e == null ? void 0 : e.brief) == null ? void 0 : u.widthMetres) == null ? void 0 : h.toString()) ?? ""), ge(((l = (C = e == null ? void 0 : e.brief) == null ? void 0 : C.depthMetres) == null ? void 0 : l.toString()) ?? ""), fe(((y = e == null ? void 0 : e.brief) == null ? void 0 : y.buildingType) ?? ""), be(((w = (s = e == null ? void 0 : e.brief) == null ? void 0 : s.floorCount) == null ? void 0 : w.toString()) ?? ""), ye(((p = (k = e == null ? void 0 : e.brief) == null ? void 0 : k.footprintAreaM2) == null ? void 0 : p.toString()) ?? ""), f((e == null ? void 0 : e.error) ?? ""), V((e == null ? void 0 : e.budget) ?? Pe), Y((e == null ? void 0 : e.tab) ?? (e ? "activity" : "setup")), e)) {
30
+ const F = await Ke(N, e.sourceId);
31
+ t && Z(F);
32
+ }
33
+ }).catch((e) => {
34
+ t && f(e.message);
35
+ }).finally(() => {
36
+ t && De(!1);
37
+ }), () => {
38
+ var e;
39
+ t = !1, (e = T.current) == null || e.abort(), T.current = null;
40
+ };
41
+ }, [N, B.id]), q(() => {
42
+ ie.current && ne.current && (ne.current.scrollTop = 0);
43
+ }, [n == null ? void 0 : n.messages]), q(() => (z(c), () => z(!1)), [c, z]), q(() => {
44
+ if (!c) return;
45
+ const t = Date.now();
46
+ Ie(0);
47
+ const e = setInterval(() => Ie(Math.floor((Date.now() - t) / 1e3)), 1e3);
48
+ return () => clearInterval(e);
49
+ }, [c]);
50
+ const ke = async (t = !1) => {
51
+ var h, C;
52
+ if (T.current || pe) return;
53
+ const e = new AbortController();
54
+ T.current = e, te(!0), f("");
55
+ let u = K();
56
+ try {
57
+ const l = o.current, y = ue(v), s = Ue({
58
+ buildingType: Q || void 0,
59
+ floorCount: R ? Number(R) : void 0,
60
+ widthMetres: L ? Number(L) : void 0,
61
+ depthMetres: E ? Number(E) : void 0,
62
+ footprintAreaM2: W ? Number(W) : void 0
63
+ });
64
+ let w = b;
65
+ if (t && l) {
66
+ const a = await N.get(l.sourceId);
67
+ if (!a) throw new Error("The saved source drawing is missing. Choose it again to continue.");
68
+ w = new File([a], l.sourceName, { type: l.sourceType });
69
+ }
70
+ if (!w || !/\.(dwg|pdf|png|jpe?g|webp)$/i.test(w.name) || !w.size || w.size > 25 * 1024 * 1024)
71
+ throw new Error("Choose a non-empty DWG, PDF, PNG, JPEG or WebP file under 25 MB.");
72
+ const k = t && l ? l.sourceId : `ai-import:source:${crypto.randomUUID()}`;
73
+ t || await N.put(k, w), t || Z(void 0), e.signal.throwIfAborted();
74
+ const p = t && l ? {
75
+ ...l,
76
+ brief: s,
77
+ phase: "running",
78
+ tab: "activity",
79
+ budget: y,
80
+ pause: void 0,
81
+ error: "",
82
+ followUp: "",
83
+ activity: "Preparing import",
84
+ messages: l.messages
85
+ } : {
86
+ version: 1,
87
+ projectId: $.current.id,
88
+ sourceId: k,
89
+ sourceName: w.name,
90
+ sourceType: w.type,
91
+ instructions: H,
92
+ brief: s,
93
+ followUp: "",
94
+ messages: [
95
+ {
96
+ type: "user",
97
+ detail: [
98
+ H.trim(),
99
+ [
100
+ s == null ? void 0 : s.buildingType,
101
+ (s == null ? void 0 : s.floorCount) && `${s.floorCount} floors`,
102
+ (s == null ? void 0 : s.widthMetres) && `Width ${s.widthMetres} m`,
103
+ (s == null ? void 0 : s.depthMetres) && `Depth ${s.depthMetres} m`,
104
+ (s == null ? void 0 : s.footprintAreaM2) && `Footprint ${s.footprintAreaM2} m² per floor`
105
+ ].filter(Boolean).join(" · ")
106
+ ].filter(Boolean).join(`
107
+ `)
108
+ }
109
+ ].filter((a) => a.detail),
110
+ phase: "running",
111
+ tab: "activity",
112
+ budget: y,
113
+ pause: void 0,
114
+ activity: "Preparing import",
115
+ edits: 0,
116
+ usage: K(),
117
+ hasUsage: !1,
118
+ error: ""
119
+ };
120
+ if (t) {
121
+ if (P.trim()) {
122
+ const a = $e({ id: crypto.randomUUID(), text: P });
123
+ p.pendingInstructions = [...p.pendingInstructions ?? [], a], p.messages = [...p.messages, { type: "user", detail: a.text, instructionId: a.id }];
124
+ }
125
+ (h = p.pendingInstructions) != null && h.length && (p.checkpoint = {
126
+ version: 1,
127
+ projectId: $.current.id,
128
+ brief: p.brief,
129
+ phase: "inspect",
130
+ notes: "",
131
+ sourcePlan: "",
132
+ mutationKinds: [],
133
+ analysis: [],
134
+ lastAssistantText: "",
135
+ lastToolReport: "",
136
+ ...p.checkpoint,
137
+ steering: Je(((C = p.checkpoint) == null ? void 0 : C.steering) ?? [], p.pendingInstructions)
138
+ });
139
+ }
140
+ u = t && l ? l.usage : K(), await m(p), G(""), !t && l && l.sourceId !== k && await Promise.all([N.delete(l.sourceId), ze(N, l.sourceId)]).catch(
141
+ () => {
142
+ }
143
+ ), e.signal.throwIfAborted(), Y("activity"), _(null), te(!1), ie.current = !0;
144
+ let F;
145
+ const xe = await j.run(w, {
146
+ origin: $.current.origin,
147
+ brief: p.brief,
148
+ instructions: p.instructions,
149
+ // The live document includes manual corrections made between runs. Never restore an
150
+ // earlier import snapshot over them or switch to a newly generated project ID.
151
+ base: $.current,
152
+ checkpoint: p.checkpoint,
153
+ budget: y,
154
+ onSession: (a) => {
155
+ e.signal.aborted || Te(a);
156
+ },
157
+ onAnalysis: async (a) => {
158
+ e.signal.aborted || (await Ye(N, k, a), e.signal.aborted || Z(a));
159
+ },
160
+ onCheckpoint: async (a) => {
161
+ var S, M;
162
+ if (!e.signal.aborted) {
163
+ const le = new Set((S = a.steering) == null ? void 0 : S.map((ce) => ce.id));
164
+ await m({
165
+ ...o.current,
166
+ checkpoint: a,
167
+ pendingInstructions: (M = o.current.pendingInstructions) == null ? void 0 : M.filter((ce) => !le.has(ce.id))
168
+ });
169
+ }
170
+ },
171
+ onPause: async (a) => {
172
+ e.signal.aborted || await m({ ...o.current, pause: a, activity: a.message });
173
+ },
174
+ signal: e.signal,
175
+ onUsage: async (a) => {
176
+ e.signal.aborted || await m({ ...o.current, usage: Re(u, a), hasUsage: !0 });
177
+ },
178
+ onDocument: async (a) => {
179
+ e.signal.aborted || (await ee.current(a), F = a, await m({ ...o.current, edits: o.current.edits + 1 }));
180
+ },
181
+ onProgress: async (a) => {
182
+ if (e.signal.aborted) return;
183
+ const S = o.current;
184
+ if (a.type === "status") return m({ ...S, activity: a.detail });
185
+ const M = S.messages.at(-1), le = a.type === "text" && (M == null ? void 0 : M.type) === "text" ? [...S.messages.slice(0, -1), { type: "text", detail: M.detail + a.detail }] : [...S.messages, { type: a.type, detail: a.detail }];
186
+ await m({ ...S, messages: le });
187
+ }
188
+ });
189
+ e.signal.aborted || ((!F || JSON.stringify(xe) !== JSON.stringify(F)) && await ee.current(xe), await m({ ...o.current, phase: o.current.pause ? "paused" : "done" }));
190
+ } catch (l) {
191
+ if (T.current !== e) return;
192
+ const y = e.signal.aborted ? "" : l.message;
193
+ if (f(y), o.current)
194
+ try {
195
+ await m({ ...o.current, phase: e.signal.aborted ? "paused" : "failed", error: y });
196
+ } catch {
197
+ f("Could not save the import session. Keep this page open and retry when storage is available.");
198
+ }
199
+ } finally {
200
+ T.current === e && (T.current = null, Te(void 0)), te(!1);
201
+ }
202
+ }, je = async () => {
203
+ if (!(!P.trim() || J || g || !o.current)) {
204
+ if (!c) return ke(!0);
205
+ if (!(!re || !j.sendInstruction)) {
206
+ Ce(!0), f("");
207
+ try {
208
+ const t = $e({ id: crypto.randomUUID(), text: P }), e = [...o.current.pendingInstructions ?? [], t];
209
+ if (e.length > 20 || JSON.stringify(e).length > 8e3)
210
+ throw new Error("Wait for Claude to receive the queued instructions before sending more.");
211
+ await m({
212
+ ...o.current,
213
+ followUp: "",
214
+ pendingInstructions: e,
215
+ messages: [
216
+ ...o.current.messages,
217
+ { type: "user", detail: t.text, instructionId: t.id }
218
+ ]
219
+ }), G(""), await j.sendInstruction(re, t);
220
+ } catch (t) {
221
+ f(t.message);
222
+ } finally {
223
+ Ce(!1);
224
+ }
225
+ }
226
+ }
227
+ }, O = (t) => {
228
+ const e = { widthMetres: L, depthMetres: E, footprintArea: W, buildingType: Q, floorCount: R, ...t };
229
+ if (he(e.widthMetres), ge(e.depthMetres), ye(e.footprintArea), fe(e.buildingType), be(e.floorCount), !!o.current)
230
+ try {
231
+ const u = Ue({
232
+ buildingType: e.buildingType || void 0,
233
+ floorCount: e.floorCount ? Number(e.floorCount) : void 0,
234
+ widthMetres: e.widthMetres ? Number(e.widthMetres) : void 0,
235
+ depthMetres: e.depthMetres ? Number(e.depthMetres) : void 0,
236
+ footprintAreaM2: e.footprintArea ? Number(e.footprintArea) : void 0
237
+ });
238
+ m({ ...o.current, brief: u }).catch(() => f("Could not save the import template."));
239
+ } catch {
240
+ }
241
+ }, Be = /* @__PURE__ */ i("fieldset", { className: "ai-import-scale", children: [
242
+ /* @__PURE__ */ r("legend", { children: "Import template · optional" }),
243
+ /* @__PURE__ */ i("div", { className: "field-grid", children: [
244
+ /* @__PURE__ */ i("label", { className: "field", children: [
245
+ /* @__PURE__ */ r("span", { children: "Building type" }),
246
+ /* @__PURE__ */ i(
247
+ "select",
248
+ {
249
+ "aria-label": "Import building type",
250
+ value: Q,
251
+ disabled: g || c,
252
+ onChange: (t) => O({ buildingType: t.target.value }),
253
+ children: [
254
+ /* @__PURE__ */ r("option", { value: "", children: "Use the drawing" }),
255
+ /* @__PURE__ */ r("option", { value: "apartment", children: "Apartment" }),
256
+ /* @__PURE__ */ r("option", { value: "house", children: "Detached house" }),
257
+ /* @__PURE__ */ r("option", { value: "office", children: "Office" }),
258
+ /* @__PURE__ */ r("option", { value: "retail", children: "Shop / retail" }),
259
+ /* @__PURE__ */ r("option", { value: "other", children: "Other building" })
260
+ ]
261
+ }
262
+ )
263
+ ] }),
264
+ /* @__PURE__ */ i("label", { className: "field", children: [
265
+ /* @__PURE__ */ r("span", { children: "Floor count" }),
266
+ /* @__PURE__ */ r(
267
+ "input",
268
+ {
269
+ type: "number",
270
+ min: "1",
271
+ max: "100",
272
+ step: "1",
273
+ "aria-label": "Import floor count",
274
+ value: R,
275
+ placeholder: "e.g. 1",
276
+ disabled: g || c,
277
+ onChange: (t) => O({ floorCount: t.target.value })
278
+ }
279
+ )
280
+ ] }),
281
+ /* @__PURE__ */ i("label", { className: "field", children: [
282
+ /* @__PURE__ */ r("span", { children: "Overall width (m)" }),
283
+ /* @__PURE__ */ r(
284
+ "input",
285
+ {
286
+ type: "number",
287
+ min: "0.01",
288
+ step: "any",
289
+ "aria-label": "Overall width (m)",
290
+ value: L,
291
+ placeholder: "e.g. 20",
292
+ disabled: g || c,
293
+ onChange: (t) => O({ widthMetres: t.target.value })
294
+ }
295
+ )
296
+ ] }),
297
+ /* @__PURE__ */ i("label", { className: "field", children: [
298
+ /* @__PURE__ */ r("span", { children: "Overall depth (m)" }),
299
+ /* @__PURE__ */ r(
300
+ "input",
301
+ {
302
+ type: "number",
303
+ min: "0.01",
304
+ step: "any",
305
+ "aria-label": "Overall depth (m)",
306
+ value: E,
307
+ placeholder: "Optional",
308
+ disabled: g || c,
309
+ onChange: (t) => O({ depthMetres: t.target.value })
310
+ }
311
+ )
312
+ ] }),
313
+ /* @__PURE__ */ i("label", { className: "field", children: [
314
+ /* @__PURE__ */ r("span", { children: "Footprint per floor (m²)" }),
315
+ /* @__PURE__ */ r(
316
+ "input",
317
+ {
318
+ type: "number",
319
+ min: "0.01",
320
+ step: "any",
321
+ "aria-label": "Floor footprint (m²)",
322
+ value: W,
323
+ placeholder: "Whole floor area",
324
+ disabled: g || c,
325
+ onChange: (t) => O({ footprintArea: t.target.value })
326
+ }
327
+ )
328
+ ] })
329
+ ] }),
330
+ /* @__PURE__ */ r("small", { children: "Dimensions follow the plan’s main axes, to the outside of the walls. Footprint includes wall area and applies per floor, not to the sum of all floors. One known value can establish scale; others cross-check it. Leave measurements blank only when the drawing has readable dimensions. Different floor footprints can be described in the instructions." })
331
+ ] }), Le = /* @__PURE__ */ i("details", { className: "ai-import-budget", children: [
332
+ /* @__PURE__ */ i("summary", { children: [
333
+ "Budget per run · ",
334
+ v.maxTurns ?? 40,
335
+ " turns · ",
336
+ v.inputTokens.toLocaleString(),
337
+ " input /",
338
+ " ",
339
+ v.outputTokens.toLocaleString(),
340
+ " output"
341
+ ] }),
342
+ /* @__PURE__ */ r("p", { className: "helper", children: "Input includes cached tokens. Output includes model thinking. Continue starts another paid run using the saved working state. Limits are checked between responses." }),
343
+ /* @__PURE__ */ i("div", { className: "field-grid", children: [
344
+ /* @__PURE__ */ i("label", { className: "field", children: [
345
+ /* @__PURE__ */ r("span", { children: "Turn limit" }),
346
+ /* @__PURE__ */ r(
347
+ "input",
348
+ {
349
+ type: "number",
350
+ "aria-label": "Turn limit",
351
+ min: "1",
352
+ max: "100",
353
+ step: "1",
354
+ value: v.maxTurns ?? 40,
355
+ disabled: c || g,
356
+ onChange: (t) => {
357
+ const e = { ...v, maxTurns: Number(t.target.value) };
358
+ V(e);
359
+ try {
360
+ const u = ue(e);
361
+ o.current && m({ ...o.current, budget: u }).catch(
362
+ () => f("Could not save import budget.")
363
+ );
364
+ } catch {
365
+ }
366
+ }
367
+ }
368
+ )
369
+ ] }),
370
+ ["inputTokens", "outputTokens"].map((t) => /* @__PURE__ */ i("label", { className: "field", children: [
371
+ /* @__PURE__ */ r("span", { children: t === "inputTokens" ? "Input token limit" : "Output token limit" }),
372
+ /* @__PURE__ */ r(
373
+ "input",
374
+ {
375
+ type: "number",
376
+ "aria-label": t === "inputTokens" ? "Input token limit" : "Output token limit",
377
+ min: t === "inputTokens" ? 1e4 : 1e3,
378
+ max: t === "inputTokens" ? 2e6 : 1e5,
379
+ step: "1000",
380
+ value: v[t],
381
+ disabled: c || g,
382
+ onChange: (e) => {
383
+ const u = { ...v, [t]: Number(e.target.value) };
384
+ V(u);
385
+ try {
386
+ const h = ue(u);
387
+ o.current && m({ ...o.current, budget: h }).catch(
388
+ () => f("Could not save import budget.")
389
+ );
390
+ } catch {
391
+ }
392
+ }
393
+ }
394
+ )
395
+ ] }, t))
396
+ ] })
397
+ ] }), A = [
398
+ ["setup", "Setup"],
399
+ ["analysis", "Analysis"],
400
+ ["activity", "Activity"],
401
+ ["usage", "Usage"]
402
+ ], Me = (t) => {
403
+ Y(t), o.current && m({ ...o.current, tab: t }).catch(() => f("Could not save the import view."));
404
+ };
405
+ if (pe) return /* @__PURE__ */ r("p", { role: "status", children: "Restoring import session…" });
406
+ const se = !!b || !n;
407
+ return /* @__PURE__ */ i("section", { className: "ai-import-panel ai-import-organized", children: [
408
+ /* @__PURE__ */ i("header", { className: "ai-import-sticky", children: [
409
+ /* @__PURE__ */ r("strong", { className: "ai-import-source", title: (b == null ? void 0 : b.name) ?? (n == null ? void 0 : n.sourceName), children: (b == null ? void 0 : b.name) ?? (n == null ? void 0 : n.sourceName) ?? "Choose a source drawing" }),
410
+ /* @__PURE__ */ i("div", { className: "ai-import-toolbar", children: [
411
+ /* @__PURE__ */ r("span", { role: "status", children: c ? `Importing · ${Ae} accepted edits · ${Math.floor(ve / 60)}:${String(ve % 60).padStart(2, "0")}` : ae === "done" ? `Saved to project · ${Ae} accepted edits` : ae === "paused" ? "Paused · accepted changes saved" : ae === "failed" ? "Import interrupted" : "Ready to import" }),
412
+ c ? /* @__PURE__ */ r("button", { className: "button secondary", onClick: () => {
413
+ var t;
414
+ return (t = T.current) == null ? void 0 : t.abort();
415
+ }, children: "Stop import" }) : /* @__PURE__ */ r(
416
+ "button",
417
+ {
418
+ className: "button primary",
419
+ disabled: g || se && !b,
420
+ onClick: () => ke(!se),
421
+ children: g ? "Preparing…" : se ? "Start AI import" : "Continue import"
422
+ }
423
+ )
424
+ ] }),
425
+ c && /* @__PURE__ */ r("p", { className: "ai-import-activity", children: Fe || "Claude is working…" }),
426
+ !c && (n == null ? void 0 : n.pause) && /* @__PURE__ */ r("p", { className: "ai-import-pause", "aria-live": "polite", children: n.pause.message }),
427
+ Ne && /* @__PURE__ */ r("p", { className: "form-error", role: "alert", children: Ne })
428
+ ] }),
429
+ /* @__PURE__ */ r("div", { className: "ai-import-tablist", role: "tablist", "aria-label": "AI import sections", children: A.map(([t, e], u) => /* @__PURE__ */ i(
430
+ "button",
431
+ {
432
+ id: `${I}-${t}`,
433
+ "data-tab": t,
434
+ role: "tab",
435
+ "aria-selected": U === t,
436
+ "aria-controls": `${I}-${t}-panel`,
437
+ tabIndex: U === t ? 0 : -1,
438
+ onClick: () => Me(t),
439
+ onKeyDown: (h) => {
440
+ var l, y;
441
+ const C = h.key === "ArrowRight" ? (u + 1) % A.length : h.key === "ArrowLeft" ? (u + A.length - 1) % A.length : h.key === "Home" ? 0 : h.key === "End" ? A.length - 1 : -1;
442
+ C < 0 || (h.preventDefault(), Me(A[C][0]), (y = (l = h.currentTarget.parentElement) == null ? void 0 : l.querySelector(`[data-tab="${A[C][0]}"]`)) == null || y.focus());
443
+ },
444
+ children: [
445
+ e,
446
+ t === "analysis" && X && /* @__PURE__ */ r("i", { "aria-hidden": "true", title: "Preview available" })
447
+ ]
448
+ },
449
+ t
450
+ )) }),
451
+ /* @__PURE__ */ i(
452
+ "div",
453
+ {
454
+ className: "ai-import-tab-scroll",
455
+ role: "tabpanel",
456
+ id: `${I}-setup-panel`,
457
+ "aria-labelledby": `${I}-setup`,
458
+ hidden: U !== "setup",
459
+ children: [
460
+ /* @__PURE__ */ r("p", { className: "helper", children: "Claude edits the live project and saves accepted changes. Starting or continuing uses your backend API key and incurs API usage." }),
461
+ /* @__PURE__ */ i("div", { className: "ai-import-inputs", children: [
462
+ /* @__PURE__ */ i("label", { className: "field", children: [
463
+ /* @__PURE__ */ r("span", { children: n ? "Replace source drawing" : "Source drawing" }),
464
+ /* @__PURE__ */ r(
465
+ "input",
466
+ {
467
+ type: "file",
468
+ "aria-label": "AI source drawing",
469
+ accept: ".dwg,.pdf,.png,.jpg,.jpeg,.webp",
470
+ disabled: c || g,
471
+ onChange: (t) => {
472
+ var e;
473
+ _(((e = t.target.files) == null ? void 0 : e[0]) ?? null), t.currentTarget.value = "";
474
+ }
475
+ }
476
+ ),
477
+ /* @__PURE__ */ r("small", { children: "Images, PDF (up to 20 pages), or DWG · up to 25 MB" })
478
+ ] }),
479
+ b && n && /* @__PURE__ */ r("button", { className: "text-button", onClick: () => _(null), children: "Keep current source" }),
480
+ /* @__PURE__ */ i("label", { className: "field", children: [
481
+ /* @__PURE__ */ r("span", { children: "Import instructions" }),
482
+ /* @__PURE__ */ r(
483
+ "textarea",
484
+ {
485
+ "aria-label": "Import instructions",
486
+ maxLength: 8e3,
487
+ rows: 3,
488
+ disabled: c || g,
489
+ value: H,
490
+ onChange: (t) => {
491
+ me(t.target.value), o.current && m({ ...o.current, instructions: t.target.value }).catch(
492
+ () => f("Could not save instructions.")
493
+ );
494
+ },
495
+ placeholder: "For example: page 2 is the ground floor, exterior width 18.4 m. Include room names and openings."
496
+ }
497
+ )
498
+ ] })
499
+ ] }),
500
+ Be,
501
+ Le,
502
+ /* @__PURE__ */ r("p", { className: "helper", children: "Stop before making manual edits. Continue uses the current project and saved working notes. Closing this sidebar keeps an active import running." })
503
+ ]
504
+ }
505
+ ),
506
+ /* @__PURE__ */ r(
507
+ "div",
508
+ {
509
+ className: "ai-import-tab-scroll",
510
+ role: "tabpanel",
511
+ id: `${I}-analysis-panel`,
512
+ "aria-labelledby": `${I}-analysis`,
513
+ hidden: U !== "analysis",
514
+ children: X ? /* @__PURE__ */ r(qe, { preview: X }) : /* @__PURE__ */ r("p", { className: "ai-import-empty", children: "The source SVG will appear here when Claude analyses the drawing. It shows detected evidence; accepted geometry appears on the main map." })
515
+ }
516
+ ),
517
+ /* @__PURE__ */ i(
518
+ "div",
519
+ {
520
+ className: "ai-import-activity-panel",
521
+ role: "tabpanel",
522
+ id: `${I}-activity-panel`,
523
+ "aria-labelledby": `${I}-activity`,
524
+ hidden: U !== "activity",
525
+ children: [
526
+ /* @__PURE__ */ r(
527
+ "div",
528
+ {
529
+ className: "ai-import-tab-scroll",
530
+ ref: ne,
531
+ onScroll: (t) => {
532
+ ie.current = t.currentTarget.scrollTop < 60;
533
+ },
534
+ children: /* @__PURE__ */ i("section", { className: "ai-import-conversation", "aria-label": "AI conversation", children: [
535
+ !oe.length && /* @__PURE__ */ r("p", { className: "ai-import-empty", children: "Claude’s latest message and tool activity will appear at the top." }),
536
+ [...oe].reverse().map((t, e) => {
537
+ var u;
538
+ return /* @__PURE__ */ i("div", { className: `ai-import-message ${t.type}`, children: [
539
+ /* @__PURE__ */ r("small", { children: t.type === "text" ? "Claude" : t.type === "user" ? (u = n == null ? void 0 : n.pendingInstructions) != null && u.some((h) => h.id === t.instructionId) ? "You · queued" : "You" : "Tool" }),
540
+ /* @__PURE__ */ r("p", { children: t.detail })
541
+ ] }, oe.length - 1 - e);
542
+ })
543
+ ] })
544
+ }
545
+ ),
546
+ /* @__PURE__ */ i(
547
+ "form",
548
+ {
549
+ className: "ai-import-composer",
550
+ onSubmit: (t) => {
551
+ t.preventDefault(), je();
552
+ },
553
+ children: [
554
+ /* @__PURE__ */ i("label", { className: "field", children: [
555
+ /* @__PURE__ */ r("span", { children: "Message to AI" }),
556
+ /* @__PURE__ */ r(
557
+ "textarea",
558
+ {
559
+ "aria-label": "Message to AI",
560
+ rows: 3,
561
+ maxLength: 2e3,
562
+ value: P,
563
+ disabled: !n || g || J || !!b,
564
+ onChange: (t) => {
565
+ G(t.target.value), o.current && m({ ...o.current, followUp: t.target.value }).catch(
566
+ () => f("Could not save your draft.")
567
+ );
568
+ },
569
+ placeholder: "Give a correction or describe what to do next…"
570
+ }
571
+ )
572
+ ] }),
573
+ /* @__PURE__ */ i("div", { children: [
574
+ /* @__PURE__ */ r("small", { children: c ? "Queued for Claude’s next turn." : n ? "Resumes with the saved project. Uses API tokens." : "Start an import in Setup to chat." }),
575
+ /* @__PURE__ */ r(
576
+ "button",
577
+ {
578
+ className: "button primary",
579
+ type: "submit",
580
+ disabled: !n || !P.trim() || g || J || !!b || c && (!re || !j.sendInstruction),
581
+ children: J ? "Sending…" : c ? "Send" : "Send & continue"
582
+ }
583
+ )
584
+ ] })
585
+ ]
586
+ }
587
+ )
588
+ ]
589
+ }
590
+ ),
591
+ /* @__PURE__ */ i(
592
+ "div",
593
+ {
594
+ className: "ai-import-tab-scroll",
595
+ role: "tabpanel",
596
+ id: `${I}-usage-panel`,
597
+ "aria-labelledby": `${I}-usage`,
598
+ hidden: U !== "usage",
599
+ children: [
600
+ /* @__PURE__ */ i("section", { className: "ai-import-usage", "aria-label": "Token usage", children: [
601
+ /* @__PURE__ */ i("strong", { children: [
602
+ "Tokens reported ·",
603
+ " ",
604
+ Object.values(D).reduce((t, e) => t + e, 0).toLocaleString()
605
+ ] }),
606
+ /* @__PURE__ */ r("dl", { children: [
607
+ ["Input", D.inputTokens],
608
+ ["Output", D.outputTokens],
609
+ ["Cache read", D.cacheReadTokens],
610
+ ["Cache write", D.cacheWriteTokens]
611
+ ].map(([t, e]) => /* @__PURE__ */ i("div", { children: [
612
+ /* @__PURE__ */ r("dt", { children: t }),
613
+ /* @__PURE__ */ r("dd", { children: e.toLocaleString() })
614
+ ] }, t)) }),
615
+ /* @__PURE__ */ r("small", { children: Oe ? "Includes continuations in this session. Saved with this project; interrupted runs may report incomplete usage." : "Waiting for Claude to report usage." })
616
+ ] }),
617
+ /* @__PURE__ */ i("p", { className: "helper", children: [
618
+ "Per run: ",
619
+ v.maxTurns ?? 40,
620
+ " turns, ",
621
+ v.inputTokens.toLocaleString(),
622
+ " input (including cache),",
623
+ " ",
624
+ v.outputTokens.toLocaleString(),
625
+ " output tokens. Adjust limits in Setup. Reaching a limit pauses the import; Continue starts the next paid run from the saved checkpoint."
626
+ ] })
627
+ ]
628
+ }
629
+ )
630
+ ] });
631
+ }
632
+ export {
633
+ nt as AiImportPanel
634
+ };
635
+ //# sourceMappingURL=AiImportPanel.js.map