@mathscan/geometry-engine 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (380) hide show
  1. package/README.md +1101 -0
  2. package/dist/coordinates/grid.d.cts +8 -0
  3. package/dist/coordinates/grid.d.ts +9 -0
  4. package/dist/coordinates/grid.d.ts.map +1 -0
  5. package/dist/coordinates/lineClipping.d.cts +3 -0
  6. package/dist/coordinates/lineClipping.d.ts +4 -0
  7. package/dist/coordinates/lineClipping.d.ts.map +1 -0
  8. package/dist/coordinates/transform.d.cts +18 -0
  9. package/dist/coordinates/transform.d.ts +19 -0
  10. package/dist/coordinates/transform.d.ts.map +1 -0
  11. package/dist/core.cjs +1 -0
  12. package/dist/core.mjs +4 -0
  13. package/dist/entries/core.d.cts +16 -0
  14. package/dist/entries/core.d.ts +17 -0
  15. package/dist/entries/core.d.ts.map +1 -0
  16. package/dist/entries/react.d.cts +18 -0
  17. package/dist/entries/react.d.ts +19 -0
  18. package/dist/entries/react.d.ts.map +1 -0
  19. package/dist/entries/schemas.d.cts +14 -0
  20. package/dist/entries/schemas.d.ts +15 -0
  21. package/dist/entries/schemas.d.ts.map +1 -0
  22. package/dist/entries/validation.d.cts +12 -0
  23. package/dist/entries/validation.d.ts +13 -0
  24. package/dist/entries/validation.d.ts.map +1 -0
  25. package/dist/exercise.schema-BV2b7rtN.cjs +2 -0
  26. package/dist/exercise.schema-BV2b7rtN.cjs.map +1 -0
  27. package/dist/exercise.schema-ckVBW9XA.js +212 -0
  28. package/dist/exercise.schema-ckVBW9XA.js.map +1 -0
  29. package/dist/geometry/distance.d.cts +9 -0
  30. package/dist/geometry/distance.d.ts +10 -0
  31. package/dist/geometry/distance.d.ts.map +1 -0
  32. package/dist/geometry/entities/circle.d.cts +36 -0
  33. package/dist/geometry/entities/circle.d.ts +37 -0
  34. package/dist/geometry/entities/circle.d.ts.map +1 -0
  35. package/dist/geometry/entities/index.d.cts +60 -0
  36. package/dist/geometry/entities/index.d.ts +61 -0
  37. package/dist/geometry/entities/index.d.ts.map +1 -0
  38. package/dist/geometry/entities/line.d.cts +43 -0
  39. package/dist/geometry/entities/line.d.ts +44 -0
  40. package/dist/geometry/entities/line.d.ts.map +1 -0
  41. package/dist/geometry/entities/point.d.cts +27 -0
  42. package/dist/geometry/entities/point.d.ts +28 -0
  43. package/dist/geometry/entities/point.d.ts.map +1 -0
  44. package/dist/geometry/entities/relations.d.cts +27 -0
  45. package/dist/geometry/entities/relations.d.ts +28 -0
  46. package/dist/geometry/entities/relations.d.ts.map +1 -0
  47. package/dist/geometry/entities/segment.d.cts +45 -0
  48. package/dist/geometry/entities/segment.d.ts +46 -0
  49. package/dist/geometry/entities/segment.d.ts.map +1 -0
  50. package/dist/geometry/entityCapabilities.d.cts +2 -0
  51. package/dist/geometry/entityCapabilities.d.ts +3 -0
  52. package/dist/geometry/entityCapabilities.d.ts.map +1 -0
  53. package/dist/geometry/entityModel.d.cts +139 -0
  54. package/dist/geometry/entityModel.d.ts +140 -0
  55. package/dist/geometry/entityModel.d.ts.map +1 -0
  56. package/dist/geometry/entityRecord.d.cts +27 -0
  57. package/dist/geometry/entityRecord.d.ts +28 -0
  58. package/dist/geometry/entityRecord.d.ts.map +1 -0
  59. package/dist/geometry/evaluateGraph.d.cts +37 -0
  60. package/dist/geometry/evaluateGraph.d.ts +38 -0
  61. package/dist/geometry/evaluateGraph.d.ts.map +1 -0
  62. package/dist/geometry/geometryObject.d.cts +4 -0
  63. package/dist/geometry/geometryObject.d.ts +5 -0
  64. package/dist/geometry/geometryObject.d.ts.map +1 -0
  65. package/dist/geometry/goalCandidate.d.cts +8 -0
  66. package/dist/geometry/goalCandidate.d.ts +9 -0
  67. package/dist/geometry/goalCandidate.d.ts.map +1 -0
  68. package/dist/geometry/hitTest.d.cts +23 -0
  69. package/dist/geometry/hitTest.d.ts +24 -0
  70. package/dist/geometry/hitTest.d.ts.map +1 -0
  71. package/dist/geometry/point.d.cts +5 -0
  72. package/dist/geometry/point.d.ts +6 -0
  73. package/dist/geometry/point.d.ts.map +1 -0
  74. package/dist/geometry/pointOrigin.d.cts +5 -0
  75. package/dist/geometry/pointOrigin.d.ts +6 -0
  76. package/dist/geometry/pointOrigin.d.ts.map +1 -0
  77. package/dist/geometry/v1Bridge.d.cts +41 -0
  78. package/dist/geometry/v1Bridge.d.ts +42 -0
  79. package/dist/geometry/v1Bridge.d.ts.map +1 -0
  80. package/dist/geometryAttemptStatus-5L_q6-9l.js +184 -0
  81. package/dist/geometryAttemptStatus-5L_q6-9l.js.map +1 -0
  82. package/dist/geometryAttemptStatus-N_XHIkiS.cjs +2 -0
  83. package/dist/geometryAttemptStatus-N_XHIkiS.cjs.map +1 -0
  84. package/dist/geometryState.schema-D0ixyGYE.js +955 -0
  85. package/dist/geometryState.schema-D0ixyGYE.js.map +1 -0
  86. package/dist/geometryState.schema-DKQ-durx.cjs +2 -0
  87. package/dist/geometryState.schema-DKQ-durx.cjs.map +1 -0
  88. package/dist/goals-C3ZwbEh_.js +451 -0
  89. package/dist/goals-C3ZwbEh_.js.map +1 -0
  90. package/dist/goals-CxR5qPDC.cjs +2 -0
  91. package/dist/goals-CxR5qPDC.cjs.map +1 -0
  92. package/dist/index.cjs +1 -0
  93. package/dist/index.d.cts +4 -0
  94. package/dist/index.d.ts +5 -0
  95. package/dist/index.d.ts.map +1 -0
  96. package/dist/index.mjs +10 -0
  97. package/dist/measure/geometryAdapter.d.cts +26 -0
  98. package/dist/measure/geometryAdapter.d.ts +27 -0
  99. package/dist/measure/geometryAdapter.d.ts.map +1 -0
  100. package/dist/measure/kernel.d.cts +25 -0
  101. package/dist/measure/kernel.d.ts +26 -0
  102. package/dist/measure/kernel.d.ts.map +1 -0
  103. package/dist/numerics/policy.d.cts +17 -0
  104. package/dist/numerics/policy.d.ts +18 -0
  105. package/dist/numerics/policy.d.ts.map +1 -0
  106. package/dist/react-BEcdx1f6.js +1851 -0
  107. package/dist/react-BEcdx1f6.js.map +1 -0
  108. package/dist/react-Pp_VSk--.cjs +2 -0
  109. package/dist/react-Pp_VSk--.cjs.map +1 -0
  110. package/dist/react.cjs +1 -0
  111. package/dist/react.mjs +2 -0
  112. package/dist/renderer/GeometryCanvas.d.cts +14 -0
  113. package/dist/renderer/GeometryCanvas.d.ts +15 -0
  114. package/dist/renderer/GeometryCanvas.d.ts.map +1 -0
  115. package/dist/renderer/GeometryCompanion.d.cts +29 -0
  116. package/dist/renderer/GeometryCompanion.d.ts +30 -0
  117. package/dist/renderer/GeometryCompanion.d.ts.map +1 -0
  118. package/dist/renderer/GeometryGrid.d.cts +7 -0
  119. package/dist/renderer/GeometryGrid.d.ts +8 -0
  120. package/dist/renderer/GeometryGrid.d.ts.map +1 -0
  121. package/dist/renderer/GeometryInstruments.d.cts +7 -0
  122. package/dist/renderer/GeometryInstruments.d.ts +8 -0
  123. package/dist/renderer/GeometryInstruments.d.ts.map +1 -0
  124. package/dist/renderer/StudentGeometryCanvas.d.cts +11 -0
  125. package/dist/renderer/StudentGeometryCanvas.d.ts +12 -0
  126. package/dist/renderer/StudentGeometryCanvas.d.ts.map +1 -0
  127. package/dist/renderer/StudentGeometryExercise.d.cts +36 -0
  128. package/dist/renderer/StudentGeometryExercise.d.ts +37 -0
  129. package/dist/renderer/StudentGeometryExercise.d.ts.map +1 -0
  130. package/dist/renderer/Toolbar.d.cts +7 -0
  131. package/dist/renderer/Toolbar.d.ts +8 -0
  132. package/dist/renderer/Toolbar.d.ts.map +1 -0
  133. package/dist/renderer/deriveRenderableGeometry.d.cts +15 -0
  134. package/dist/renderer/deriveRenderableGeometry.d.ts +16 -0
  135. package/dist/renderer/deriveRenderableGeometry.d.ts.map +1 -0
  136. package/dist/renderer/deriveSemanticScene.d.cts +58 -0
  137. package/dist/renderer/deriveSemanticScene.d.ts +59 -0
  138. package/dist/renderer/deriveSemanticScene.d.ts.map +1 -0
  139. package/dist/renderer/entityDisplayName.d.cts +12 -0
  140. package/dist/renderer/entityDisplayName.d.ts +13 -0
  141. package/dist/renderer/entityDisplayName.d.ts.map +1 -0
  142. package/dist/renderer/gesturePolicy.d.cts +97 -0
  143. package/dist/renderer/gesturePolicy.d.ts +98 -0
  144. package/dist/renderer/gesturePolicy.d.ts.map +1 -0
  145. package/dist/renderer/shapes/CircleShape.d.cts +17 -0
  146. package/dist/renderer/shapes/CircleShape.d.ts +18 -0
  147. package/dist/renderer/shapes/CircleShape.d.ts.map +1 -0
  148. package/dist/renderer/shapes/EntityLabel.d.cts +14 -0
  149. package/dist/renderer/shapes/EntityLabel.d.ts +15 -0
  150. package/dist/renderer/shapes/EntityLabel.d.ts.map +1 -0
  151. package/dist/renderer/shapes/EntityShape.d.cts +18 -0
  152. package/dist/renderer/shapes/EntityShape.d.ts +19 -0
  153. package/dist/renderer/shapes/EntityShape.d.ts.map +1 -0
  154. package/dist/renderer/shapes/LineShape.d.cts +16 -0
  155. package/dist/renderer/shapes/LineShape.d.ts +17 -0
  156. package/dist/renderer/shapes/LineShape.d.ts.map +1 -0
  157. package/dist/renderer/shapes/PointShape.d.cts +17 -0
  158. package/dist/renderer/shapes/PointShape.d.ts +18 -0
  159. package/dist/renderer/shapes/PointShape.d.ts.map +1 -0
  160. package/dist/renderer/shapes/SegmentShape.d.cts +17 -0
  161. package/dist/renderer/shapes/SegmentShape.d.ts +18 -0
  162. package/dist/renderer/shapes/SegmentShape.d.ts.map +1 -0
  163. package/dist/renderer/shapes/SnapMarker.d.cts +8 -0
  164. package/dist/renderer/shapes/SnapMarker.d.ts +9 -0
  165. package/dist/renderer/shapes/SnapMarker.d.ts.map +1 -0
  166. package/dist/renderer/shapes/StrokedLine.d.cts +18 -0
  167. package/dist/renderer/shapes/StrokedLine.d.ts +19 -0
  168. package/dist/renderer/shapes/StrokedLine.d.ts.map +1 -0
  169. package/dist/renderer/studentExerciseSession.d.cts +71 -0
  170. package/dist/renderer/studentExerciseSession.d.ts +72 -0
  171. package/dist/renderer/studentExerciseSession.d.ts.map +1 -0
  172. package/dist/renderer/useConnectionPreview.d.cts +44 -0
  173. package/dist/renderer/useConnectionPreview.d.ts +45 -0
  174. package/dist/renderer/useConnectionPreview.d.ts.map +1 -0
  175. package/dist/renderer/usePlacementSnap.d.cts +28 -0
  176. package/dist/renderer/usePlacementSnap.d.ts +29 -0
  177. package/dist/renderer/usePlacementSnap.d.ts.map +1 -0
  178. package/dist/renderer/usePointerGestures.d.cts +46 -0
  179. package/dist/renderer/usePointerGestures.d.ts +47 -0
  180. package/dist/renderer/usePointerGestures.d.ts.map +1 -0
  181. package/dist/schemas/circle.schema.d.cts +8 -0
  182. package/dist/schemas/circle.schema.d.ts +9 -0
  183. package/dist/schemas/circle.schema.d.ts.map +1 -0
  184. package/dist/schemas/entityDefinition.schema.d.cts +69 -0
  185. package/dist/schemas/entityDefinition.schema.d.ts +70 -0
  186. package/dist/schemas/entityDefinition.schema.d.ts.map +1 -0
  187. package/dist/schemas/entityDocument.d.cts +95 -0
  188. package/dist/schemas/entityDocument.d.ts +96 -0
  189. package/dist/schemas/entityDocument.d.ts.map +1 -0
  190. package/dist/schemas/entityPresentation.schema.d.cts +12 -0
  191. package/dist/schemas/entityPresentation.schema.d.ts +13 -0
  192. package/dist/schemas/entityPresentation.schema.d.ts.map +1 -0
  193. package/dist/schemas/exercise.schema.d.cts +217 -0
  194. package/dist/schemas/exercise.schema.d.ts +218 -0
  195. package/dist/schemas/exercise.schema.d.ts.map +1 -0
  196. package/dist/schemas/exerciseProjection.d.cts +10 -0
  197. package/dist/schemas/exerciseProjection.d.ts +11 -0
  198. package/dist/schemas/exerciseProjection.d.ts.map +1 -0
  199. package/dist/schemas/exerciseV2.schema.d.cts +137 -0
  200. package/dist/schemas/exerciseV2.schema.d.ts +138 -0
  201. package/dist/schemas/exerciseV2.schema.d.ts.map +1 -0
  202. package/dist/schemas/exerciseV3.schema.d.cts +149 -0
  203. package/dist/schemas/exerciseV3.schema.d.ts +150 -0
  204. package/dist/schemas/exerciseV3.schema.d.ts.map +1 -0
  205. package/dist/schemas/geometryObject.schema.d.cts +17 -0
  206. package/dist/schemas/geometryObject.schema.d.ts +18 -0
  207. package/dist/schemas/geometryObject.schema.d.ts.map +1 -0
  208. package/dist/schemas/geometryState.schema.d.cts +64 -0
  209. package/dist/schemas/geometryState.schema.d.ts +65 -0
  210. package/dist/schemas/geometryState.schema.d.ts.map +1 -0
  211. package/dist/schemas/givenElement.schema.d.cts +24 -0
  212. package/dist/schemas/givenElement.schema.d.ts +25 -0
  213. package/dist/schemas/givenElement.schema.d.ts.map +1 -0
  214. package/dist/schemas/goals/createGoal.schema.d.cts +12 -0
  215. package/dist/schemas/goals/createGoal.schema.d.ts +13 -0
  216. package/dist/schemas/goals/createGoal.schema.d.ts.map +1 -0
  217. package/dist/schemas/goals/geometryGoal.schema.d.cts +58 -0
  218. package/dist/schemas/goals/geometryGoal.schema.d.ts +59 -0
  219. package/dist/schemas/goals/geometryGoal.schema.d.ts.map +1 -0
  220. package/dist/schemas/goals/goalKindDeclaration.d.cts +53 -0
  221. package/dist/schemas/goals/goalKindDeclaration.d.ts +54 -0
  222. package/dist/schemas/goals/goalKindDeclaration.d.ts.map +1 -0
  223. package/dist/schemas/goals/midpointGoal.schema.d.cts +9 -0
  224. package/dist/schemas/goals/midpointGoal.schema.d.ts +10 -0
  225. package/dist/schemas/goals/midpointGoal.schema.d.ts.map +1 -0
  226. package/dist/schemas/goals/parallelGoal.schema.d.cts +15 -0
  227. package/dist/schemas/goals/parallelGoal.schema.d.ts +16 -0
  228. package/dist/schemas/goals/parallelGoal.schema.d.ts.map +1 -0
  229. package/dist/schemas/goals/perpendicularGoal.schema.d.cts +15 -0
  230. package/dist/schemas/goals/perpendicularGoal.schema.d.ts +16 -0
  231. package/dist/schemas/goals/perpendicularGoal.schema.d.ts.map +1 -0
  232. package/dist/schemas/goals/segmentLengthGoal.schema.d.cts +9 -0
  233. package/dist/schemas/goals/segmentLengthGoal.schema.d.ts +10 -0
  234. package/dist/schemas/goals/segmentLengthGoal.schema.d.ts.map +1 -0
  235. package/dist/schemas/goals/throughPointsGoal.schema.d.cts +13 -0
  236. package/dist/schemas/goals/throughPointsGoal.schema.d.ts +14 -0
  237. package/dist/schemas/goals/throughPointsGoal.schema.d.ts.map +1 -0
  238. package/dist/schemas/identifier.schema.d.cts +2 -0
  239. package/dist/schemas/identifier.schema.d.ts +3 -0
  240. package/dist/schemas/identifier.schema.d.ts.map +1 -0
  241. package/dist/schemas/line.schema.d.cts +7 -0
  242. package/dist/schemas/line.schema.d.ts +8 -0
  243. package/dist/schemas/line.schema.d.ts.map +1 -0
  244. package/dist/schemas/migrate.d.cts +21 -0
  245. package/dist/schemas/migrate.d.ts +22 -0
  246. package/dist/schemas/migrate.d.ts.map +1 -0
  247. package/dist/schemas/objectTypeName.schema.d.cts +8 -0
  248. package/dist/schemas/objectTypeName.schema.d.ts +9 -0
  249. package/dist/schemas/objectTypeName.schema.d.ts.map +1 -0
  250. package/dist/schemas/point.schema.d.cts +15 -0
  251. package/dist/schemas/point.schema.d.ts +16 -0
  252. package/dist/schemas/point.schema.d.ts.map +1 -0
  253. package/dist/schemas/pointOrigin.schema.d.cts +25 -0
  254. package/dist/schemas/pointOrigin.schema.d.ts +26 -0
  255. package/dist/schemas/pointOrigin.schema.d.ts.map +1 -0
  256. package/dist/schemas/segment.schema.d.cts +8 -0
  257. package/dist/schemas/segment.schema.d.ts +9 -0
  258. package/dist/schemas/segment.schema.d.ts.map +1 -0
  259. package/dist/schemas/v1ToV2.d.cts +37 -0
  260. package/dist/schemas/v1ToV2.d.ts +38 -0
  261. package/dist/schemas/v1ToV2.d.ts.map +1 -0
  262. package/dist/schemas/v2ToV3.d.cts +37 -0
  263. package/dist/schemas/v2ToV3.d.ts +38 -0
  264. package/dist/schemas/v2ToV3.d.ts.map +1 -0
  265. package/dist/schemas/v3ToV4.d.cts +3 -0
  266. package/dist/schemas/v3ToV4.d.ts +4 -0
  267. package/dist/schemas/v3ToV4.d.ts.map +1 -0
  268. package/dist/schemas/viewport.schema.d.cts +3 -0
  269. package/dist/schemas/viewport.schema.d.ts +4 -0
  270. package/dist/schemas/viewport.schema.d.ts.map +1 -0
  271. package/dist/schemas.cjs +1 -0
  272. package/dist/schemas.mjs +3 -0
  273. package/dist/snapping/computeSnap.d.cts +30 -0
  274. package/dist/snapping/computeSnap.d.ts +31 -0
  275. package/dist/snapping/computeSnap.d.ts.map +1 -0
  276. package/dist/state/geometryContext.d.cts +40 -0
  277. package/dist/state/geometryContext.d.ts +41 -0
  278. package/dist/state/geometryContext.d.ts.map +1 -0
  279. package/dist/state/resolvePoints.d.cts +51 -0
  280. package/dist/state/resolvePoints.d.ts +52 -0
  281. package/dist/state/resolvePoints.d.ts.map +1 -0
  282. package/dist/store/attemptChange.d.cts +30 -0
  283. package/dist/store/attemptChange.d.ts +31 -0
  284. package/dist/store/attemptChange.d.ts.map +1 -0
  285. package/dist/store/constructionCommand.d.cts +35 -0
  286. package/dist/store/constructionCommand.d.ts +36 -0
  287. package/dist/store/constructionCommand.d.ts.map +1 -0
  288. package/dist/store/constructionIdentity.d.cts +21 -0
  289. package/dist/store/constructionIdentity.d.ts +22 -0
  290. package/dist/store/constructionIdentity.d.ts.map +1 -0
  291. package/dist/store/createStore.d.cts +6 -0
  292. package/dist/store/createStore.d.ts +7 -0
  293. package/dist/store/createStore.d.ts.map +1 -0
  294. package/dist/store/history.d.cts +2 -0
  295. package/dist/store/history.d.ts +3 -0
  296. package/dist/store/history.d.ts.map +1 -0
  297. package/dist/store/studentStore.d.cts +151 -0
  298. package/dist/store/studentStore.d.ts +152 -0
  299. package/dist/store/studentStore.d.ts.map +1 -0
  300. package/dist/store/teacherStore.d.cts +111 -0
  301. package/dist/store/teacherStore.d.ts +112 -0
  302. package/dist/store/teacherStore.d.ts.map +1 -0
  303. package/dist/store/useStoreState.d.cts +2 -0
  304. package/dist/store/useStoreState.d.ts +3 -0
  305. package/dist/store/useStoreState.d.ts.map +1 -0
  306. package/dist/studentStore-CEKTtMCh.js +1162 -0
  307. package/dist/studentStore-CEKTtMCh.js.map +1 -0
  308. package/dist/studentStore-DLftfFAl.cjs +2 -0
  309. package/dist/studentStore-DLftfFAl.cjs.map +1 -0
  310. package/dist/validation/checkGeometryAnswer.d.cts +63 -0
  311. package/dist/validation/checkGeometryAnswer.d.ts +64 -0
  312. package/dist/validation/checkGeometryAnswer.d.ts.map +1 -0
  313. package/dist/validation/deriveGeometryCanvasFeedback.d.cts +7 -0
  314. package/dist/validation/deriveGeometryCanvasFeedback.d.ts +8 -0
  315. package/dist/validation/deriveGeometryCanvasFeedback.d.ts.map +1 -0
  316. package/dist/validation/exerciseLoad.d.cts +29 -0
  317. package/dist/validation/exerciseLoad.d.ts +30 -0
  318. package/dist/validation/exerciseLoad.d.ts.map +1 -0
  319. package/dist/validation/geometryAttemptStatus.d.cts +23 -0
  320. package/dist/validation/geometryAttemptStatus.d.ts +24 -0
  321. package/dist/validation/geometryAttemptStatus.d.ts.map +1 -0
  322. package/dist/validation/getGeometryExerciseWarnings.d.cts +16 -0
  323. package/dist/validation/getGeometryExerciseWarnings.d.ts +17 -0
  324. package/dist/validation/getGeometryExerciseWarnings.d.ts.map +1 -0
  325. package/dist/validation/goals/create.d.cts +3 -0
  326. package/dist/validation/goals/create.d.ts +4 -0
  327. package/dist/validation/goals/create.d.ts.map +1 -0
  328. package/dist/validation/goals/goalContext.d.cts +44 -0
  329. package/dist/validation/goals/goalContext.d.ts +45 -0
  330. package/dist/validation/goals/goalContext.d.ts.map +1 -0
  331. package/dist/validation/goals/goalKindHandler.d.cts +26 -0
  332. package/dist/validation/goals/goalKindHandler.d.ts +27 -0
  333. package/dist/validation/goals/goalKindHandler.d.ts.map +1 -0
  334. package/dist/validation/goals/index.d.cts +14 -0
  335. package/dist/validation/goals/index.d.ts +15 -0
  336. package/dist/validation/goals/index.d.ts.map +1 -0
  337. package/dist/validation/goals/midpoint.d.cts +4 -0
  338. package/dist/validation/goals/midpoint.d.ts +5 -0
  339. package/dist/validation/goals/midpoint.d.ts.map +1 -0
  340. package/dist/validation/goals/parallel.d.cts +3 -0
  341. package/dist/validation/goals/parallel.d.ts +4 -0
  342. package/dist/validation/goals/parallel.d.ts.map +1 -0
  343. package/dist/validation/goals/perpendicular.d.cts +3 -0
  344. package/dist/validation/goals/perpendicular.d.ts +4 -0
  345. package/dist/validation/goals/perpendicular.d.ts.map +1 -0
  346. package/dist/validation/goals/previewGeometry.d.cts +9 -0
  347. package/dist/validation/goals/previewGeometry.d.ts +10 -0
  348. package/dist/validation/goals/previewGeometry.d.ts.map +1 -0
  349. package/dist/validation/goals/segmentLength.d.cts +3 -0
  350. package/dist/validation/goals/segmentLength.d.ts +4 -0
  351. package/dist/validation/goals/segmentLength.d.ts.map +1 -0
  352. package/dist/validation/goals/throughPoints.d.cts +5 -0
  353. package/dist/validation/goals/throughPoints.d.ts +6 -0
  354. package/dist/validation/goals/throughPoints.d.ts.map +1 -0
  355. package/dist/validation/gradingFingerprints.d.cts +4 -0
  356. package/dist/validation/gradingFingerprints.d.ts +5 -0
  357. package/dist/validation/gradingFingerprints.d.ts.map +1 -0
  358. package/dist/validation/revealGeometryAnswers.d.cts +3 -0
  359. package/dist/validation/revealGeometryAnswers.d.ts +4 -0
  360. package/dist/validation/revealGeometryAnswers.d.ts.map +1 -0
  361. package/dist/validation/revealGeometryAttempt.d.cts +36 -0
  362. package/dist/validation/revealGeometryAttempt.d.ts +37 -0
  363. package/dist/validation/revealGeometryAttempt.d.ts.map +1 -0
  364. package/dist/validation/types.d.cts +58 -0
  365. package/dist/validation/types.d.ts +59 -0
  366. package/dist/validation/types.d.ts.map +1 -0
  367. package/dist/validation/validateGeometryExercise.d.cts +30 -0
  368. package/dist/validation/validateGeometryExercise.d.ts +31 -0
  369. package/dist/validation/validateGeometryExercise.d.ts.map +1 -0
  370. package/dist/validation/validateGeometryState.d.cts +16 -0
  371. package/dist/validation/validateGeometryState.d.ts +17 -0
  372. package/dist/validation/validateGeometryState.d.ts.map +1 -0
  373. package/dist/validation/validateGeometryStateInput.d.cts +22 -0
  374. package/dist/validation/validateGeometryStateInput.d.ts +23 -0
  375. package/dist/validation/validateGeometryStateInput.d.ts.map +1 -0
  376. package/dist/validation.cjs +2 -0
  377. package/dist/validation.cjs.map +1 -0
  378. package/dist/validation.mjs +269 -0
  379. package/dist/validation.mjs.map +1 -0
  380. package/package.json +150 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1Bridge.d.ts","sourceRoot":"","sources":["../../src/geometry/v1Bridge.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAGtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAA;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAkC,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAiBhF,0EAA0E;AAC1E,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,CAK3E;AAID,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,eAAe,CAQvE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,gBAAgB,CAIvE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,OAAO,EAAE,CAE1E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAElE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,GAClC,cAAc,GAAG,IAAI,CAYvB"}
@@ -0,0 +1,184 @@
1
+ import { F as e, O as t, S as n, i as r, n as i, u as a, x as o } from "./geometryState.schema-D0ixyGYE.js";
2
+ import { i as s, o as c } from "./exercise.schema-ckVBW9XA.js";
3
+ //#region src/validation/validateGeometryStateInput.ts
4
+ function l(e, n) {
5
+ let r = /* @__PURE__ */ new Set();
6
+ for (let [i, a] of Object.entries(e.entities)) {
7
+ let e = t(n.entities, i);
8
+ !e || e.kind !== "point" || a.kind !== "point" || n.draggableEntityIds.includes(i) || r.add(i);
9
+ }
10
+ let i = e.answerEntityIds.filter((e) => !Object.prototype.hasOwnProperty.call(n.entities, e));
11
+ if (r.size === 0 && i.length === e.answerEntityIds.length) return e;
12
+ let a = (e) => Object.fromEntries(Object.entries(e).filter(([e]) => !r.has(e)));
13
+ return {
14
+ ...e,
15
+ entities: a(e.entities),
16
+ presentation: a(e.presentation),
17
+ answerEntityIds: i
18
+ };
19
+ }
20
+ function u(e, t) {
21
+ let a = r(e);
22
+ if (!a.success) return {
23
+ success: !1,
24
+ data: null,
25
+ errors: [{
26
+ path: ["schemaVersion"],
27
+ message: a.message
28
+ }]
29
+ };
30
+ let s = i.safeParse(a.data);
31
+ if (!s.success) return {
32
+ success: !1,
33
+ data: null,
34
+ errors: s.error.issues.map((e) => ({
35
+ path: e.path.map((e) => typeof e == "symbol" ? e.toString() : e),
36
+ message: e.message
37
+ }))
38
+ };
39
+ let c = [], u = s.data;
40
+ if (t) {
41
+ u = l(u, t);
42
+ for (let e of o(u, t.entities)) c.push(e);
43
+ for (let e of n(u, t.entities)) c.push(e);
44
+ for (let [e, n] of Object.entries(u.entities)) n.kind !== "point" && (t.allowedObjects.includes(n.kind) || c.push({
45
+ path: ["entities", e],
46
+ message: `${n.kind} is not allowed by this exercise`
47
+ }));
48
+ }
49
+ return c.length > 0 ? {
50
+ success: !1,
51
+ data: null,
52
+ errors: c
53
+ } : {
54
+ success: !0,
55
+ data: u,
56
+ errors: []
57
+ };
58
+ }
59
+ function d(e, t) {
60
+ try {
61
+ return u(JSON.parse(e), t);
62
+ } catch (e) {
63
+ return {
64
+ success: !1,
65
+ data: null,
66
+ errors: [{
67
+ path: [],
68
+ message: e instanceof Error ? e.message : "Invalid JSON syntax"
69
+ }]
70
+ };
71
+ }
72
+ }
73
+ function f(e) {
74
+ return JSON.stringify(e);
75
+ }
76
+ //#endregion
77
+ //#region src/validation/deriveGeometryCanvasFeedback.ts
78
+ function p(n, r, i) {
79
+ let a = n?.goals.find((e) => e.id === i);
80
+ if (!a) return {
81
+ constructions: {},
82
+ points: {}
83
+ };
84
+ let o = Object.fromEntries(a.constructionIds.map((e) => [e, a.status])), s = new Set(a.pointIds);
85
+ for (let [n, i] of Object.entries(r.entities)) if (i.kind !== "point" && t(o, n)) for (let t of e(i)) s.add(t);
86
+ return {
87
+ constructions: o,
88
+ points: Object.fromEntries([...s].map((e) => [e, a.status]))
89
+ };
90
+ }
91
+ //#endregion
92
+ //#region src/validation/gradingFingerprints.ts
93
+ function m(e) {
94
+ if (Array.isArray(e)) return `[${e.map((e) => e === void 0 ? "null" : m(e)).join(",")}]`;
95
+ if (typeof e == "object" && e) {
96
+ let t = e;
97
+ return `{${Object.keys(t).sort().filter((e) => t[e] !== void 0).map((e) => `${JSON.stringify(e)}:${m(t[e])}`).join(",")}}`;
98
+ }
99
+ return JSON.stringify(e);
100
+ }
101
+ function h(e) {
102
+ let t = 3735928559, n = 1103547991;
103
+ for (let r = 0; r < e.length; r++) {
104
+ let i = e.charCodeAt(r);
105
+ t = Math.imul(t ^ i, 2654435761), n = Math.imul(n ^ i, 1597334677);
106
+ }
107
+ return t = Math.imul(t ^ t >>> 16, 2246822507), t ^= Math.imul(n ^ n >>> 13, 3266489909), n = Math.imul(n ^ n >>> 16, 2246822507), n ^= Math.imul(t ^ t >>> 13, 3266489909), `${(n >>> 0).toString(16).padStart(8, "0")}${(t >>> 0).toString(16).padStart(8, "0")}`;
108
+ }
109
+ function g(e) {
110
+ return h(m(a(e)));
111
+ }
112
+ function _(e) {
113
+ return h(m(e));
114
+ }
115
+ //#endregion
116
+ //#region src/validation/getGeometryExerciseWarnings.ts
117
+ function v(e) {
118
+ let [t, n, r, i] = e.viewport, a = [];
119
+ for (let [o, s] of Object.entries(e.entities)) {
120
+ if (s.kind !== "point" || !("at" in s)) continue;
121
+ let { x: e, y: c } = s.at;
122
+ e >= t && e <= r && c >= n && c <= i || a.push({
123
+ path: ["entities", o],
124
+ message: `point ${o} is outside the viewport`
125
+ });
126
+ }
127
+ return a;
128
+ }
129
+ //#endregion
130
+ //#region src/validation/exerciseLoad.ts
131
+ function y(e) {
132
+ return e.map((e) => typeof e == "symbol" ? e.description ?? e.toString() : e);
133
+ }
134
+ function b(e) {
135
+ let t = c(e);
136
+ if (!t.success) return {
137
+ success: !1,
138
+ errors: [{
139
+ path: ["schemaVersion"],
140
+ message: t.message
141
+ }]
142
+ };
143
+ let n = t.data, r = s.safeParse(a(n));
144
+ return r.success ? {
145
+ success: !0,
146
+ data: r.data,
147
+ solution: n.solution,
148
+ warnings: v(r.data)
149
+ } : {
150
+ success: !1,
151
+ errors: r.error.issues.map((e) => ({
152
+ path: y(e.path),
153
+ message: e.message
154
+ }))
155
+ };
156
+ }
157
+ function x(e, t) {
158
+ let n = u(e, t);
159
+ return n.success ? n : {
160
+ ...n,
161
+ errors: n.errors.map((e) => ({
162
+ ...e,
163
+ path: ["solution", ...e.path]
164
+ }))
165
+ };
166
+ }
167
+ //#endregion
168
+ //#region src/validation/geometryAttemptStatus.ts
169
+ function S() {
170
+ return {
171
+ schemaVersion: 2,
172
+ entities: {},
173
+ presentation: {},
174
+ answerEntityIds: []
175
+ };
176
+ }
177
+ function C(e) {
178
+ let t = u(e);
179
+ return t.success && Object.keys(t.data.entities).length > 0;
180
+ }
181
+ //#endregion
182
+ export { v as a, p as c, d, x as i, f as l, C as n, _ as o, b as r, g as s, S as t, u };
183
+
184
+ //# sourceMappingURL=geometryAttemptStatus-5L_q6-9l.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometryAttemptStatus-5L_q6-9l.js","names":[],"sources":["../src/validation/validateGeometryStateInput.ts","../src/validation/deriveGeometryCanvasFeedback.ts","../src/validation/gradingFingerprints.ts","../src/validation/getGeometryExerciseWarnings.ts","../src/validation/exerciseLoad.ts","../src/validation/geometryAttemptStatus.ts"],"sourcesContent":["import type { EntityId } from '../geometry/entityModel'\nimport { entryOf } from '../geometry/entityRecord'\nimport {\n crossDocumentIdCollisionIssues,\n crossDocumentParentIssues,\n} from '../schemas/entityDocument'\nimport type { GeometryExercise } from '../schemas/exercise.schema'\nimport {\n geometryStateSchema,\n migrateGeometryState,\n type GeometryState,\n} from '../schemas/geometryState.schema'\nimport type { GeometryExerciseValidationIssue } from './validateGeometryExercise'\n\n/**\n * The load pass ADR 0008 § Amendment specifies: a v2 attempt carries **only\n * student work**, so an entity re-declaring a *pinned* given point is removed\n * on the way in, and no given at all survives in `answerEntityIds`.\n *\n * Neither drop is an error, because both are what every migrated v1 attempt\n * looks like — v1 seeded the givens into the attempt, required them to be\n * there, and its reveal promoted a given point into `constructedPointIds`,\n * which the migration copies verbatim into `answerEntityIds`. A *draggable*\n * given entity is kept: re-declaring one is how the student moves it.\n *\n * A dropped entity's `presentation` entry goes with it, both because a\n * leftover would make the normalized document fail the schema it just passed,\n * and because it would be saying something about an entity this document no\n * longer declares.\n *\n * **`answerEntityIds` loses every id the exercise declares**, not only the\n * dropped ones: a given is not an answer to anything, so a draggable given the\n * student moved is still not something they built. Dropping rather than\n * refusing is decided by what the loader can see — a hand-written document\n * naming a given there is indistinguishable from a migrated v1 one, and\n * refusing would make every stored v1 attempt with a revealed given\n * unloadable. The entry says nothing true either way, so it is removed in\n * silence, exactly as the pinned re-declaration is.\n */\nfunction normalizedAgainstExercise(\n geometry: GeometryState,\n exercise: GeometryExercise,\n): GeometryState {\n const dropped = new Set<EntityId>()\n for (const [id, definition] of Object.entries(geometry.entities)) {\n const given = entryOf(exercise.entities, id)\n // A mismatched kind is a genuine collision rather than a re-declaration,\n // and it is refused below rather than silently tidied away here.\n if (!given || given.kind !== 'point' || definition.kind !== 'point') continue\n if (!exercise.draggableEntityIds.includes(id)) dropped.add(id)\n }\n const answerEntityIds = geometry.answerEntityIds.filter(\n (id) => !Object.prototype.hasOwnProperty.call(exercise.entities, id),\n )\n if (dropped.size === 0 && answerEntityIds.length === geometry.answerEntityIds.length) {\n return geometry\n }\n\n const keep = <T>(record: Record<EntityId, T>): Record<EntityId, T> =>\n Object.fromEntries(Object.entries(record).filter(([id]) => !dropped.has(id)))\n return {\n ...geometry,\n entities: keep(geometry.entities),\n presentation: keep(geometry.presentation),\n answerEntityIds,\n }\n}\n\nexport type GeometryStateInputValidationResult =\n | { success: true; data: GeometryState; errors: [] }\n | { success: false; data: null; errors: GeometryExerciseValidationIssue[] }\n\nexport function validateGeometryStateInput(\n input: unknown,\n exercise?: GeometryExercise,\n): GeometryStateInputValidationResult {\n // Stored attempts are brought up to the current version before their\n // structure is checked, so an older saved attempt loads rather than failing\n // as malformed.\n const migrated = migrateGeometryState(input)\n if (!migrated.success) {\n return {\n success: false,\n data: null,\n errors: [{ path: ['schemaVersion'], message: migrated.message }],\n }\n }\n\n const result = geometryStateSchema.safeParse(migrated.data)\n if (!result.success) {\n return {\n success: false,\n data: null,\n errors: result.error.issues.map((issue) => ({\n path: issue.path.map((part) => (typeof part === 'symbol' ? part.toString() : part)),\n message: issue.message,\n })),\n }\n }\n\n const errors: GeometryExerciseValidationIssue[] = []\n let data = result.data\n if (exercise) {\n data = normalizedAgainstExercise(data, exercise)\n\n // An id both documents declare, unless both declare it as a point.\n // `buildGeometryContext()` reports these as `duplicate-id` and then\n // resolves the id to the exercise's declaration, so before M2.G.2 an\n // attempt declaring segment `A` over given point `A` loaded clean and had\n // the *given* graded as the student's construction. One rule, shared with\n // the context, and the document is refused rather than reinterpreted.\n for (const issue of crossDocumentIdCollisionIssues(data, exercise.entities)) {\n errors.push(issue)\n }\n\n // The parents the attempt schema deliberately let through: since the\n // amendment a student's point sits on a given segment, so most of an\n // attempt's parents are declared in the other document. This is where the\n // pair is completed, in the schema's own words.\n for (const issue of crossDocumentParentIssues(data, exercise.entities)) {\n errors.push(issue)\n }\n\n // What the student was allowed to draw. Points are not checked: placing one\n // is how every construction starts, and v1 never asked either.\n for (const [id, definition] of Object.entries(data.entities)) {\n if (definition.kind === 'point') continue\n if (!exercise.allowedObjects.includes(definition.kind)) {\n errors.push({\n path: ['entities', id],\n message: `${definition.kind} is not allowed by this exercise`,\n })\n }\n }\n }\n\n return errors.length > 0\n ? { success: false, data: null, errors }\n : { success: true, data, errors: [] }\n}\n\n/**\n * Restores an attempt from stored JSON — the counterpart to\n * validateGeometryExerciseJson(). Pass the exercise to also check the attempt\n * against it — only allowed object types, parents naming entities that exist in\n * one of the two documents — and to normalize it, which is what drops the given\n * points a migrated v1 attempt still carries.\n */\nexport function validateGeometryStateJson(\n json: string,\n exercise?: GeometryExercise,\n): GeometryStateInputValidationResult {\n try {\n return validateGeometryStateInput(JSON.parse(json), exercise)\n } catch (error) {\n return {\n success: false,\n data: null,\n errors: [\n {\n path: [],\n message: error instanceof Error ? error.message : 'Invalid JSON syntax',\n },\n ],\n }\n }\n}\n\n// Saves an attempt. Trivial today, but it is the one place that guarantees the\n// stored document carries its version, so a restore never has to guess.\nexport function serializeGeometryState(geometry: GeometryState): string {\n return JSON.stringify(geometry)\n}\n","import type { GeometryState } from '../schemas/geometryState.schema'\nimport { parentsOfDefinition } from '../geometry/entities'\nimport { entryOf } from '../geometry/entityRecord'\nimport type { GoalStatus, GeometryValidationFeedback } from './types'\n\nexport interface GeometryCanvasFeedback {\n constructions: Record<string, GoalStatus>\n points: Record<string, GoalStatus>\n}\n\nexport function deriveGeometryCanvasFeedback(\n feedback: GeometryValidationFeedback | null,\n geometry: GeometryState,\n focusedGoalId: string | null,\n): GeometryCanvasFeedback {\n const focused = feedback?.goals.find((goal) => goal.id === focusedGoalId)\n if (!focused) return { constructions: {}, points: {} }\n\n const constructions = Object.fromEntries(\n focused.constructionIds.map((id) => [id, focused.status]),\n ) as Record<string, GoalStatus>\n const pointIds = new Set(focused.pointIds)\n for (const [id, definition] of Object.entries(geometry.entities)) {\n if (definition.kind === 'point') continue\n if (!entryOf(constructions, id)) continue\n for (const pointId of parentsOfDefinition(definition)) pointIds.add(pointId)\n }\n const points = Object.fromEntries([...pointIds].map((id) => [id, focused.status])) as Record<\n string,\n GoalStatus\n >\n return { constructions, points }\n}\n","import type { GeometryExercise } from '../schemas/exercise.schema'\nimport { withoutSolution } from '../schemas/exerciseProjection'\nimport type { GeometryState } from '../schemas/geometryState.schema'\n\n// Feedback freshness (RFC 0005 § Decisions 2 and 5, ADR 0014). A check result\n// describes the normalized documents it graded, not the objects a host passed\n// in, so a clone, a JSON round trip or a reordered record fingerprints the same,\n// while any change to what grading reads does not.\n//\n// The value is opaque: only another fingerprint from this engine is ever\n// compared against it. That keeps the format free to change — a result from an\n// older format simply stops matching, which hides feedback instead of showing\n// stale feedback.\n\n// JSON with object keys sorted at every depth. Array order is kept because it\n// is meaningful (answer order is report order); records are the documents'\n// only unordered collections. An `undefined` member is skipped as\n// JSON.stringify skips it, so an absent optional field and an explicit\n// `undefined` agree.\nfunction canonicalJson(value: unknown): string {\n if (Array.isArray(value)) {\n return `[${value.map((item) => (item === undefined ? 'null' : canonicalJson(item))).join(',')}]`\n }\n if (typeof value === 'object' && value !== null) {\n const record = value as Record<string, unknown>\n const members = Object.keys(record)\n .sort()\n .filter((key) => record[key] !== undefined)\n .map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)\n return `{${members.join(',')}}`\n }\n return JSON.stringify(value)\n}\n\n// cyrb53's two 32-bit lanes, both printed: 16 hex digits. Not cryptographic —\n// a fingerprint detects that grading inputs changed; a host forging a match\n// could only ever redisplay feedback it already holds.\nfunction hash(text: string): string {\n let h1 = 0xdeadbeef\n let h2 = 0x41c6ce57\n for (let index = 0; index < text.length; index++) {\n const code = text.charCodeAt(index)\n h1 = Math.imul(h1 ^ code, 2654435761)\n h2 = Math.imul(h2 ^ code, 1597334677)\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507)\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909)\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507)\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909)\n return `${(h2 >>> 0).toString(16).padStart(8, '0')}${(h1 >>> 0).toString(16).padStart(8, '0')}`\n}\n\n// The solution-free grading projection. Checking ignores the authored solution\n// ADR 0015 embeds, so changing only that must not hide feedback.\nexport function fingerprintGeometryExercise(exercise: GeometryExercise): string {\n return hash(canonicalJson(withoutSolution(exercise)))\n}\n\n// Takes the attempt as grading read it: migrated, parsed and normalized against\n// its exercise, so a dropped pinned given or an older version changes nothing.\nexport function fingerprintGeometryAttempt(attempt: GeometryState): string {\n return hash(canonicalJson(attempt))\n}\n","import type { GeometryExercise } from '../schemas/exercise.schema'\n\nexport interface GeometryExerciseWarning {\n path: Array<string | number>\n message: string\n}\n\n/**\n * What is wrong with an exercise without being invalid. Today that is one rule:\n * a given placed where the viewport cannot show it.\n *\n * Only a **free** point is checked. A derived point has no stored coordinates —\n * it is wherever the graph puts it, which depends on the entities it is built\n * on — so warning about it would mean resolving the whole exercise, and where\n * an authoring warning belongs for a construction that lands off-screen is an\n * M3 question about the authoring UI rather than about the document.\n */\nexport function getGeometryExerciseWarnings(exercise: GeometryExercise): GeometryExerciseWarning[] {\n const [xMin, yMin, xMax, yMax] = exercise.viewport\n const warnings: GeometryExerciseWarning[] = []\n for (const [id, definition] of Object.entries(exercise.entities)) {\n if (definition.kind !== 'point' || !('at' in definition)) continue\n const { x, y } = definition.at\n if (x >= xMin && x <= xMax && y >= yMin && y <= yMax) continue\n warnings.push({ path: ['entities', id], message: `point ${id} is outside the viewport` })\n }\n return warnings\n}\n","// The one exercise load every public loader is built on (M3.I.3, option C).\n// Internal: not exported from any entry point.\n//\n// Exercise v4 embeds an authored solution (ADR 0015), and the engine loads an\n// exercise two ways. **Grading** — Check, fingerprints, the student component —\n// must ignore the solution entirely, so a malformed one never disables them.\n// **The full load** — `validateGeometryExercise()` and reveal — must also\n// migrate the solution and check it against the exercise. Both start from\n// `loadExerciseDocument()`, so the exercise half cannot differ between them, and the\n// full load adds `validateEmbeddedSolution()` on top.\nimport { withoutSolution } from '../schemas/exerciseProjection'\nimport {\n geometryExerciseSchema,\n migrateGeometryExercise,\n type GeometryExercise,\n} from '../schemas/exercise.schema'\nimport {\n getGeometryExerciseWarnings,\n type GeometryExerciseWarning,\n} from './getGeometryExerciseWarnings'\nimport type { GeometryExerciseValidationIssue } from './validateGeometryExercise'\nimport {\n validateGeometryStateInput,\n type GeometryStateInputValidationResult,\n} from './validateGeometryStateInput'\n\nexport type ExerciseLoadResult =\n | {\n success: true\n /** The solution-free projection, parsed. */\n data: GeometryExercise\n /** The stored solution, untouched: `undefined` when the document has none. */\n solution: unknown\n warnings: GeometryExerciseWarning[]\n }\n | { success: false; errors: GeometryExerciseValidationIssue[] }\n\nfunction normalizePath(path: PropertyKey[]): Array<string | number> {\n return path.map((segment) =>\n typeof segment === 'symbol' ? (segment.description ?? segment.toString()) : segment,\n )\n}\n\n/**\n * Migrates a stored exercise and parses its solution-free projection. Every\n * refusal the migration stage can produce — an older version with no step, a\n * newer one, something that is not a document at all — is reported under\n * `schemaVersion`, because that is the field the reader consulted.\n */\nexport function loadExerciseDocument(input: unknown): ExerciseLoadResult {\n const migrated = migrateGeometryExercise(input)\n if (!migrated.success) {\n return { success: false, errors: [{ path: ['schemaVersion'], message: migrated.message }] }\n }\n\n const document = migrated.data as Record<string, unknown>\n const result = geometryExerciseSchema.safeParse(withoutSolution(document))\n if (!result.success) {\n return {\n success: false,\n errors: result.error.issues.map((issue) => ({\n path: normalizePath(issue.path),\n message: issue.message,\n })),\n }\n }\n return {\n success: true,\n data: result.data,\n solution: document.solution,\n warnings: getGeometryExerciseWarnings(result.data),\n }\n}\n\n/**\n * The stored solution as an attempt of `exercise`: migrated on the attempt\n * chain, parsed, and normalized and cross-checked against the exercise exactly\n * as a student attempt is. Issue paths are rooted at `solution`, so they point\n * into the exercise document a host holds.\n */\nexport function validateEmbeddedSolution(\n solution: unknown,\n exercise: GeometryExercise,\n): GeometryStateInputValidationResult {\n const attempt = validateGeometryStateInput(solution, exercise)\n if (attempt.success) return attempt\n return {\n ...attempt,\n errors: attempt.errors.map((issue) => ({ ...issue, path: ['solution', ...issue.path] })),\n }\n}\n","import { latestGeometryStateVersion, type GeometryState } from '../schemas/geometryState.schema'\nimport { validateGeometryStateInput } from './validateGeometryStateInput'\n\n/**\n * A fresh attempt at the current attempt version, for a host starting a student\n * on an exercise (RFC 0005 § Decision 5). It takes no exercise: the two\n * documents version independently, and an empty attempt holds nothing of the\n * exercise. Every call returns a new object, so a host may keep or change one\n * without touching another.\n */\nexport function createEmptyGeometryAttempt(): GeometryState {\n return {\n schemaVersion: latestGeometryStateVersion,\n entities: {},\n presentation: {},\n answerEntityIds: [],\n }\n}\n\n/**\n * Whether a stored attempt holds any student work — a completion hint for a\n * host's \"not started\" state, never a grade. Untrusted input is migrated and\n * parsed first; absent or malformed input is `false` rather than an error.\n *\n * Work is any entity the attempt declares, not only an answer: dragging a given\n * copies it into `entities` while `answerEntityIds` stays empty, and that\n * counts. Reset, or deleting everything the student added, empties `entities`\n * again.\n *\n * No exercise is read, so a pinned given that a migrated v1 attempt still\n * re-declares counts here, although the load pass against its exercise drops it.\n */\nexport function hasGeometryWork(attemptInput: unknown): boolean {\n const attempt = validateGeometryStateInput(attemptInput)\n return attempt.success && Object.keys(attempt.data.entities).length > 0\n}\n"],"mappings":";;;AAuCA,SAAS,EACP,GACA,GACe;CACf,IAAM,oBAAU,IAAI,IAAc;CAClC,KAAK,IAAM,CAAC,GAAI,MAAe,OAAO,QAAQ,EAAS,QAAQ,GAAG;EAChE,IAAM,IAAQ,EAAQ,EAAS,UAAU,CAAE;EAGvC,CAAC,KAAS,EAAM,SAAS,WAAW,EAAW,SAAS,WACvD,EAAS,mBAAmB,SA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eAAA;EACA,UAAU,CAAC;EACX,cAAc,CAAC;EACf,iBAAiB,CAAC;CACpB;AACF;AAeA,SAAgB,EAAgB,GAAgC;CAC9D,IAAM,IAAU,EAA2B,CAAY;CACvD,OAAO,EAAQ,WAAW,OAAO,KAAK,EAAQ,KAAK,QAAQ,CAAC,CAAC,SAAS;AACxE"}
@@ -0,0 +1,2 @@
1
+ const e=require("./geometryState.schema-DKQ-durx.cjs"),t=require("./exercise.schema-BV2b7rtN.cjs");function n(t,n){let r=new Set;for(let[i,a]of Object.entries(t.entities)){let t=e.O(n.entities,i);!t||t.kind!==`point`||a.kind!==`point`||n.draggableEntityIds.includes(i)||r.add(i)}let i=t.answerEntityIds.filter(e=>!Object.prototype.hasOwnProperty.call(n.entities,e));if(r.size===0&&i.length===t.answerEntityIds.length)return t;let a=e=>Object.fromEntries(Object.entries(e).filter(([e])=>!r.has(e)));return{...t,entities:a(t.entities),presentation:a(t.presentation),answerEntityIds:i}}function r(t,r){let i=e.i(t);if(!i.success)return{success:!1,data:null,errors:[{path:[`schemaVersion`],message:i.message}]};let a=e.n.safeParse(i.data);if(!a.success)return{success:!1,data:null,errors:a.error.issues.map(e=>({path:e.path.map(e=>typeof e==`symbol`?e.toString():e),message:e.message}))};let o=[],s=a.data;if(r){s=n(s,r);for(let t of e.x(s,r.entities))o.push(t);for(let t of e.S(s,r.entities))o.push(t);for(let[e,t]of Object.entries(s.entities))t.kind!==`point`&&(r.allowedObjects.includes(t.kind)||o.push({path:[`entities`,e],message:`${t.kind} is not allowed by this exercise`}))}return o.length>0?{success:!1,data:null,errors:o}:{success:!0,data:s,errors:[]}}function i(e,t){try{return r(JSON.parse(e),t)}catch(e){return{success:!1,data:null,errors:[{path:[],message:e instanceof Error?e.message:`Invalid JSON syntax`}]}}}function a(e){return JSON.stringify(e)}function o(t,n,r){let i=t?.goals.find(e=>e.id===r);if(!i)return{constructions:{},points:{}};let a=Object.fromEntries(i.constructionIds.map(e=>[e,i.status])),o=new Set(i.pointIds);for(let[t,r]of Object.entries(n.entities))if(r.kind!==`point`&&e.O(a,t))for(let t of e.F(r))o.add(t);return{constructions:a,points:Object.fromEntries([...o].map(e=>[e,i.status]))}}function s(e){if(Array.isArray(e))return`[${e.map(e=>e===void 0?`null`:s(e)).join(`,`)}]`;if(typeof e==`object`&&e){let t=e;return`{${Object.keys(t).sort().filter(e=>t[e]!==void 0).map(e=>`${JSON.stringify(e)}:${s(t[e])}`).join(`,`)}}`}return JSON.stringify(e)}function c(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);t=Math.imul(t^i,2654435761),n=Math.imul(n^i,1597334677)}return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),`${(n>>>0).toString(16).padStart(8,`0`)}${(t>>>0).toString(16).padStart(8,`0`)}`}function l(t){return c(s(e.u(t)))}function u(e){return c(s(e))}function d(e){let[t,n,r,i]=e.viewport,a=[];for(let[o,s]of Object.entries(e.entities)){if(s.kind!==`point`||!(`at`in s))continue;let{x:e,y:c}=s.at;e>=t&&e<=r&&c>=n&&c<=i||a.push({path:[`entities`,o],message:`point ${o} is outside the viewport`})}return a}function f(e){return e.map(e=>typeof e==`symbol`?e.description??e.toString():e)}function p(n){let r=t.o(n);if(!r.success)return{success:!1,errors:[{path:[`schemaVersion`],message:r.message}]};let i=r.data,a=t.i.safeParse(e.u(i));return a.success?{success:!0,data:a.data,solution:i.solution,warnings:d(a.data)}:{success:!1,errors:a.error.issues.map(e=>({path:f(e.path),message:e.message}))}}function m(e,t){let n=r(e,t);return n.success?n:{...n,errors:n.errors.map(e=>({...e,path:[`solution`,...e.path]}))}}function h(){return{schemaVersion:2,entities:{},presentation:{},answerEntityIds:[]}}function g(e){let t=r(e);return t.success&&Object.keys(t.data.entities).length>0}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return r}});
2
+ //# sourceMappingURL=geometryAttemptStatus-N_XHIkiS.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geometryAttemptStatus-N_XHIkiS.cjs","names":[],"sources":["../src/validation/validateGeometryStateInput.ts","../src/validation/deriveGeometryCanvasFeedback.ts","../src/validation/gradingFingerprints.ts","../src/validation/getGeometryExerciseWarnings.ts","../src/validation/exerciseLoad.ts","../src/validation/geometryAttemptStatus.ts"],"sourcesContent":["import type { EntityId } from '../geometry/entityModel'\nimport { entryOf } from '../geometry/entityRecord'\nimport {\n crossDocumentIdCollisionIssues,\n crossDocumentParentIssues,\n} from '../schemas/entityDocument'\nimport type { GeometryExercise } from '../schemas/exercise.schema'\nimport {\n geometryStateSchema,\n migrateGeometryState,\n type GeometryState,\n} from '../schemas/geometryState.schema'\nimport type { GeometryExerciseValidationIssue } from './validateGeometryExercise'\n\n/**\n * The load pass ADR 0008 § Amendment specifies: a v2 attempt carries **only\n * student work**, so an entity re-declaring a *pinned* given point is removed\n * on the way in, and no given at all survives in `answerEntityIds`.\n *\n * Neither drop is an error, because both are what every migrated v1 attempt\n * looks like — v1 seeded the givens into the attempt, required them to be\n * there, and its reveal promoted a given point into `constructedPointIds`,\n * which the migration copies verbatim into `answerEntityIds`. A *draggable*\n * given entity is kept: re-declaring one is how the student moves it.\n *\n * A dropped entity's `presentation` entry goes with it, both because a\n * leftover would make the normalized document fail the schema it just passed,\n * and because it would be saying something about an entity this document no\n * longer declares.\n *\n * **`answerEntityIds` loses every id the exercise declares**, not only the\n * dropped ones: a given is not an answer to anything, so a draggable given the\n * student moved is still not something they built. Dropping rather than\n * refusing is decided by what the loader can see — a hand-written document\n * naming a given there is indistinguishable from a migrated v1 one, and\n * refusing would make every stored v1 attempt with a revealed given\n * unloadable. The entry says nothing true either way, so it is removed in\n * silence, exactly as the pinned re-declaration is.\n */\nfunction normalizedAgainstExercise(\n geometry: GeometryState,\n exercise: GeometryExercise,\n): GeometryState {\n const dropped = new Set<EntityId>()\n for (const [id, definition] of Object.entries(geometry.entities)) {\n const given = entryOf(exercise.entities, id)\n // A mismatched kind is a genuine collision rather than a re-declaration,\n // and it is refused below rather than silently tidied away here.\n if (!given || given.kind !== 'point' || definition.kind !== 'point') continue\n if (!exercise.draggableEntityIds.includes(id)) dropped.add(id)\n }\n const answerEntityIds = geometry.answerEntityIds.filter(\n (id) => !Object.prototype.hasOwnProperty.call(exercise.entities, id),\n )\n if (dropped.size === 0 && answerEntityIds.length === geometry.answerEntityIds.length) {\n return geometry\n }\n\n const keep = <T>(record: Record<EntityId, T>): Record<EntityId, T> =>\n Object.fromEntries(Object.entries(record).filter(([id]) => !dropped.has(id)))\n return {\n ...geometry,\n entities: keep(geometry.entities),\n presentation: keep(geometry.presentation),\n answerEntityIds,\n }\n}\n\nexport type GeometryStateInputValidationResult =\n | { success: true; data: GeometryState; errors: [] }\n | { success: false; data: null; errors: GeometryExerciseValidationIssue[] }\n\nexport function validateGeometryStateInput(\n input: unknown,\n exercise?: GeometryExercise,\n): GeometryStateInputValidationResult {\n // Stored attempts are brought up to the current version before their\n // structure is checked, so an older saved attempt loads rather than failing\n // as malformed.\n const migrated = migrateGeometryState(input)\n if (!migrated.success) {\n return {\n success: false,\n data: null,\n errors: [{ path: ['schemaVersion'], message: migrated.message }],\n }\n }\n\n const result = geometryStateSchema.safeParse(migrated.data)\n if (!result.success) {\n return {\n success: false,\n data: null,\n errors: result.error.issues.map((issue) => ({\n path: issue.path.map((part) => (typeof part === 'symbol' ? part.toString() : part)),\n message: issue.message,\n })),\n }\n }\n\n const errors: GeometryExerciseValidationIssue[] = []\n let data = result.data\n if (exercise) {\n data = normalizedAgainstExercise(data, exercise)\n\n // An id both documents declare, unless both declare it as a point.\n // `buildGeometryContext()` reports these as `duplicate-id` and then\n // resolves the id to the exercise's declaration, so before M2.G.2 an\n // attempt declaring segment `A` over given point `A` loaded clean and had\n // the *given* graded as the student's construction. One rule, shared with\n // the context, and the document is refused rather than reinterpreted.\n for (const issue of crossDocumentIdCollisionIssues(data, exercise.entities)) {\n errors.push(issue)\n }\n\n // The parents the attempt schema deliberately let through: since the\n // amendment a student's point sits on a given segment, so most of an\n // attempt's parents are declared in the other document. This is where the\n // pair is completed, in the schema's own words.\n for (const issue of crossDocumentParentIssues(data, exercise.entities)) {\n errors.push(issue)\n }\n\n // What the student was allowed to draw. Points are not checked: placing one\n // is how every construction starts, and v1 never asked either.\n for (const [id, definition] of Object.entries(data.entities)) {\n if (definition.kind === 'point') continue\n if (!exercise.allowedObjects.includes(definition.kind)) {\n errors.push({\n path: ['entities', id],\n message: `${definition.kind} is not allowed by this exercise`,\n })\n }\n }\n }\n\n return errors.length > 0\n ? { success: false, data: null, errors }\n : { success: true, data, errors: [] }\n}\n\n/**\n * Restores an attempt from stored JSON — the counterpart to\n * validateGeometryExerciseJson(). Pass the exercise to also check the attempt\n * against it — only allowed object types, parents naming entities that exist in\n * one of the two documents — and to normalize it, which is what drops the given\n * points a migrated v1 attempt still carries.\n */\nexport function validateGeometryStateJson(\n json: string,\n exercise?: GeometryExercise,\n): GeometryStateInputValidationResult {\n try {\n return validateGeometryStateInput(JSON.parse(json), exercise)\n } catch (error) {\n return {\n success: false,\n data: null,\n errors: [\n {\n path: [],\n message: error instanceof Error ? error.message : 'Invalid JSON syntax',\n },\n ],\n }\n }\n}\n\n// Saves an attempt. Trivial today, but it is the one place that guarantees the\n// stored document carries its version, so a restore never has to guess.\nexport function serializeGeometryState(geometry: GeometryState): string {\n return JSON.stringify(geometry)\n}\n","import type { GeometryState } from '../schemas/geometryState.schema'\nimport { parentsOfDefinition } from '../geometry/entities'\nimport { entryOf } from '../geometry/entityRecord'\nimport type { GoalStatus, GeometryValidationFeedback } from './types'\n\nexport interface GeometryCanvasFeedback {\n constructions: Record<string, GoalStatus>\n points: Record<string, GoalStatus>\n}\n\nexport function deriveGeometryCanvasFeedback(\n feedback: GeometryValidationFeedback | null,\n geometry: GeometryState,\n focusedGoalId: string | null,\n): GeometryCanvasFeedback {\n const focused = feedback?.goals.find((goal) => goal.id === focusedGoalId)\n if (!focused) return { constructions: {}, points: {} }\n\n const constructions = Object.fromEntries(\n focused.constructionIds.map((id) => [id, focused.status]),\n ) as Record<string, GoalStatus>\n const pointIds = new Set(focused.pointIds)\n for (const [id, definition] of Object.entries(geometry.entities)) {\n if (definition.kind === 'point') continue\n if (!entryOf(constructions, id)) continue\n for (const pointId of parentsOfDefinition(definition)) pointIds.add(pointId)\n }\n const points = Object.fromEntries([...pointIds].map((id) => [id, focused.status])) as Record<\n string,\n GoalStatus\n >\n return { constructions, points }\n}\n","import type { GeometryExercise } from '../schemas/exercise.schema'\nimport { withoutSolution } from '../schemas/exerciseProjection'\nimport type { GeometryState } from '../schemas/geometryState.schema'\n\n// Feedback freshness (RFC 0005 § Decisions 2 and 5, ADR 0014). A check result\n// describes the normalized documents it graded, not the objects a host passed\n// in, so a clone, a JSON round trip or a reordered record fingerprints the same,\n// while any change to what grading reads does not.\n//\n// The value is opaque: only another fingerprint from this engine is ever\n// compared against it. That keeps the format free to change — a result from an\n// older format simply stops matching, which hides feedback instead of showing\n// stale feedback.\n\n// JSON with object keys sorted at every depth. Array order is kept because it\n// is meaningful (answer order is report order); records are the documents'\n// only unordered collections. An `undefined` member is skipped as\n// JSON.stringify skips it, so an absent optional field and an explicit\n// `undefined` agree.\nfunction canonicalJson(value: unknown): string {\n if (Array.isArray(value)) {\n return `[${value.map((item) => (item === undefined ? 'null' : canonicalJson(item))).join(',')}]`\n }\n if (typeof value === 'object' && value !== null) {\n const record = value as Record<string, unknown>\n const members = Object.keys(record)\n .sort()\n .filter((key) => record[key] !== undefined)\n .map((key) => `${JSON.stringify(key)}:${canonicalJson(record[key])}`)\n return `{${members.join(',')}}`\n }\n return JSON.stringify(value)\n}\n\n// cyrb53's two 32-bit lanes, both printed: 16 hex digits. Not cryptographic —\n// a fingerprint detects that grading inputs changed; a host forging a match\n// could only ever redisplay feedback it already holds.\nfunction hash(text: string): string {\n let h1 = 0xdeadbeef\n let h2 = 0x41c6ce57\n for (let index = 0; index < text.length; index++) {\n const code = text.charCodeAt(index)\n h1 = Math.imul(h1 ^ code, 2654435761)\n h2 = Math.imul(h2 ^ code, 1597334677)\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507)\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909)\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507)\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909)\n return `${(h2 >>> 0).toString(16).padStart(8, '0')}${(h1 >>> 0).toString(16).padStart(8, '0')}`\n}\n\n// The solution-free grading projection. Checking ignores the authored solution\n// ADR 0015 embeds, so changing only that must not hide feedback.\nexport function fingerprintGeometryExercise(exercise: GeometryExercise): string {\n return hash(canonicalJson(withoutSolution(exercise)))\n}\n\n// Takes the attempt as grading read it: migrated, parsed and normalized against\n// its exercise, so a dropped pinned given or an older version changes nothing.\nexport function fingerprintGeometryAttempt(attempt: GeometryState): string {\n return hash(canonicalJson(attempt))\n}\n","import type { GeometryExercise } from '../schemas/exercise.schema'\n\nexport interface GeometryExerciseWarning {\n path: Array<string | number>\n message: string\n}\n\n/**\n * What is wrong with an exercise without being invalid. Today that is one rule:\n * a given placed where the viewport cannot show it.\n *\n * Only a **free** point is checked. A derived point has no stored coordinates —\n * it is wherever the graph puts it, which depends on the entities it is built\n * on — so warning about it would mean resolving the whole exercise, and where\n * an authoring warning belongs for a construction that lands off-screen is an\n * M3 question about the authoring UI rather than about the document.\n */\nexport function getGeometryExerciseWarnings(exercise: GeometryExercise): GeometryExerciseWarning[] {\n const [xMin, yMin, xMax, yMax] = exercise.viewport\n const warnings: GeometryExerciseWarning[] = []\n for (const [id, definition] of Object.entries(exercise.entities)) {\n if (definition.kind !== 'point' || !('at' in definition)) continue\n const { x, y } = definition.at\n if (x >= xMin && x <= xMax && y >= yMin && y <= yMax) continue\n warnings.push({ path: ['entities', id], message: `point ${id} is outside the viewport` })\n }\n return warnings\n}\n","// The one exercise load every public loader is built on (M3.I.3, option C).\n// Internal: not exported from any entry point.\n//\n// Exercise v4 embeds an authored solution (ADR 0015), and the engine loads an\n// exercise two ways. **Grading** — Check, fingerprints, the student component —\n// must ignore the solution entirely, so a malformed one never disables them.\n// **The full load** — `validateGeometryExercise()` and reveal — must also\n// migrate the solution and check it against the exercise. Both start from\n// `loadExerciseDocument()`, so the exercise half cannot differ between them, and the\n// full load adds `validateEmbeddedSolution()` on top.\nimport { withoutSolution } from '../schemas/exerciseProjection'\nimport {\n geometryExerciseSchema,\n migrateGeometryExercise,\n type GeometryExercise,\n} from '../schemas/exercise.schema'\nimport {\n getGeometryExerciseWarnings,\n type GeometryExerciseWarning,\n} from './getGeometryExerciseWarnings'\nimport type { GeometryExerciseValidationIssue } from './validateGeometryExercise'\nimport {\n validateGeometryStateInput,\n type GeometryStateInputValidationResult,\n} from './validateGeometryStateInput'\n\nexport type ExerciseLoadResult =\n | {\n success: true\n /** The solution-free projection, parsed. */\n data: GeometryExercise\n /** The stored solution, untouched: `undefined` when the document has none. */\n solution: unknown\n warnings: GeometryExerciseWarning[]\n }\n | { success: false; errors: GeometryExerciseValidationIssue[] }\n\nfunction normalizePath(path: PropertyKey[]): Array<string | number> {\n return path.map((segment) =>\n typeof segment === 'symbol' ? (segment.description ?? segment.toString()) : segment,\n )\n}\n\n/**\n * Migrates a stored exercise and parses its solution-free projection. Every\n * refusal the migration stage can produce — an older version with no step, a\n * newer one, something that is not a document at all — is reported under\n * `schemaVersion`, because that is the field the reader consulted.\n */\nexport function loadExerciseDocument(input: unknown): ExerciseLoadResult {\n const migrated = migrateGeometryExercise(input)\n if (!migrated.success) {\n return { success: false, errors: [{ path: ['schemaVersion'], message: migrated.message }] }\n }\n\n const document = migrated.data as Record<string, unknown>\n const result = geometryExerciseSchema.safeParse(withoutSolution(document))\n if (!result.success) {\n return {\n success: false,\n errors: result.error.issues.map((issue) => ({\n path: normalizePath(issue.path),\n message: issue.message,\n })),\n }\n }\n return {\n success: true,\n data: result.data,\n solution: document.solution,\n warnings: getGeometryExerciseWarnings(result.data),\n }\n}\n\n/**\n * The stored solution as an attempt of `exercise`: migrated on the attempt\n * chain, parsed, and normalized and cross-checked against the exercise exactly\n * as a student attempt is. Issue paths are rooted at `solution`, so they point\n * into the exercise document a host holds.\n */\nexport function validateEmbeddedSolution(\n solution: unknown,\n exercise: GeometryExercise,\n): GeometryStateInputValidationResult {\n const attempt = validateGeometryStateInput(solution, exercise)\n if (attempt.success) return attempt\n return {\n ...attempt,\n errors: attempt.errors.map((issue) => ({ ...issue, path: ['solution', ...issue.path] })),\n }\n}\n","import { latestGeometryStateVersion, type GeometryState } from '../schemas/geometryState.schema'\nimport { validateGeometryStateInput } from './validateGeometryStateInput'\n\n/**\n * A fresh attempt at the current attempt version, for a host starting a student\n * on an exercise (RFC 0005 § Decision 5). It takes no exercise: the two\n * documents version independently, and an empty attempt holds nothing of the\n * exercise. Every call returns a new object, so a host may keep or change one\n * without touching another.\n */\nexport function createEmptyGeometryAttempt(): GeometryState {\n return {\n schemaVersion: latestGeometryStateVersion,\n entities: {},\n presentation: {},\n answerEntityIds: [],\n }\n}\n\n/**\n * Whether a stored attempt holds any student work — a completion hint for a\n * host's \"not started\" state, never a grade. Untrusted input is migrated and\n * parsed first; absent or malformed input is `false` rather than an error.\n *\n * Work is any entity the attempt declares, not only an answer: dragging a given\n * copies it into `entities` while `answerEntityIds` stays empty, and that\n * counts. Reset, or deleting everything the student added, empties `entities`\n * again.\n *\n * No exercise is read, so a pinned given that a migrated v1 attempt still\n * re-declares counts here, although the load pass against its exercise drops it.\n */\nexport function hasGeometryWork(attemptInput: unknown): boolean {\n const attempt = validateGeometryStateInput(attemptInput)\n return attempt.success && Object.keys(attempt.data.entities).length > 0\n}\n"],"mappings":"mGAuCA,SAAS,EACP,EACA,EACe,CACf,IAAM,EAAU,IAAI,IACpB,IAAK,GAAM,CAAC,EAAI,KAAe,OAAO,QAAQ,EAAS,QAAQ,EAAG,CAChE,IAAM,EAAQ,EAAA,EAAQ,EAAS,SAAU,CAAE,EAGvC,CAAC,GAAS,EAAM,OAAS,SAAW,EAAW,OAAS,SACvD,EAAS,mBAAmB,SAAS,CAAE,GAAG,EAAQ,IAAI,CAAE,CAC/D,CACA,IAAM,EAAkB,EAAS,gBAAgB,OAC9C,GAAO,CAAC,OAAO,UAAU,eAAe,KAAK,EAAS,SAAU,CAAE,CACrE,EACA,GAAI,EAAQ,OAAS,GAAK,EAAgB,SAAW,EAAS,gBAAgB,OAC5E,OAAO,EAGT,IAAM,EAAW,GACf,OAAO,YAAY,OAAO,QAAQ,CAAM,CAAC,CAAC,QAAQ,CAAC,KAAQ,CAAC,EAAQ,IAAI,CAAE,CAAC,CAAC,EAC9E,MAAO,CACL,GAAG,EACH,SAAU,EAAK,EAAS,QAAQ,EAChC,aAAc,EAAK,EAAS,YAAY,EACxC,iBACF,CACF,CAMA,SAAgB,EACd,EACA,EACoC,CAIpC,IAAM,EAAW,EAAA,EAAqB,CAAK,EAC3C,GAAI,CAAC,EAAS,QACZ,MAAO,CACL,QAAS,GACT,KAAM,KACN,OAAQ,CAAC,CAAE,KAAM,CAAC,eAAe,EAAG,QAAS,EAAS,OAAQ,CAAC,CACjE,EAGF,IAAM,EAAS,EAAA,EAAoB,UAAU,EAAS,IAAI,EAC1D,GAAI,CAAC,EAAO,QACV,MAAO,CACL,QAAS,GACT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