@mathscan/geometry-engine 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/README.md +24 -7
  2. package/dist/core.cjs +1 -1
  3. package/dist/core.mjs +4 -4
  4. package/dist/entries/core.d.cts +1 -1
  5. package/dist/entries/core.d.ts +1 -1
  6. package/dist/entries/core.d.ts.map +1 -1
  7. package/dist/exercise.schema-Bma3qN9P.js +251 -0
  8. package/dist/exercise.schema-Bma3qN9P.js.map +1 -0
  9. package/dist/exercise.schema-Oj5ZH-yO.cjs +2 -0
  10. package/dist/exercise.schema-Oj5ZH-yO.cjs.map +1 -0
  11. package/dist/exerciseLoad-Db9Cigxi.cjs +2 -0
  12. package/dist/exerciseLoad-Db9Cigxi.cjs.map +1 -0
  13. package/dist/{geometryAttemptStatus-5L_q6-9l.js → exerciseLoad-DgeDXYbf.js} +84 -71
  14. package/dist/exerciseLoad-DgeDXYbf.js.map +1 -0
  15. package/dist/geometry/entities/angle.d.cts +56 -0
  16. package/dist/geometry/entities/angle.d.ts +57 -0
  17. package/dist/geometry/entities/angle.d.ts.map +1 -0
  18. package/dist/geometry/entities/circle.d.ts.map +1 -1
  19. package/dist/geometry/entities/index.d.cts +8 -4
  20. package/dist/geometry/entities/index.d.ts +8 -4
  21. package/dist/geometry/entities/index.d.ts.map +1 -1
  22. package/dist/geometry/entities/line.d.ts.map +1 -1
  23. package/dist/geometry/entities/point.d.ts.map +1 -1
  24. package/dist/geometry/entities/relations.d.cts +8 -1
  25. package/dist/geometry/entities/relations.d.ts +8 -1
  26. package/dist/geometry/entities/relations.d.ts.map +1 -1
  27. package/dist/geometry/entities/segment.d.ts.map +1 -1
  28. package/dist/geometry/entityModel.d.cts +21 -3
  29. package/dist/geometry/entityModel.d.ts +21 -3
  30. package/dist/geometry/entityModel.d.ts.map +1 -1
  31. package/dist/geometryState.schema-B5ccMKDa.cjs +2 -0
  32. package/dist/geometryState.schema-B5ccMKDa.cjs.map +1 -0
  33. package/dist/geometryState.schema-CKFPlX8j.js +1177 -0
  34. package/dist/geometryState.schema-CKFPlX8j.js.map +1 -0
  35. package/dist/goals-BlSeniyt.js +563 -0
  36. package/dist/goals-BlSeniyt.js.map +1 -0
  37. package/dist/goals-DLbmBZD8.cjs +2 -0
  38. package/dist/goals-DLbmBZD8.cjs.map +1 -0
  39. package/dist/index.cjs +1 -1
  40. package/dist/index.mjs +8 -8
  41. package/dist/measure/angleType.d.cts +2 -0
  42. package/dist/measure/angleType.d.ts +3 -0
  43. package/dist/measure/angleType.d.ts.map +1 -0
  44. package/dist/measure/geometryAdapter.d.cts +3 -0
  45. package/dist/measure/geometryAdapter.d.ts +3 -0
  46. package/dist/measure/geometryAdapter.d.ts.map +1 -1
  47. package/dist/react-B26_e52I.cjs +2 -0
  48. package/dist/react-B26_e52I.cjs.map +1 -0
  49. package/dist/{react-BEcdx1f6.js → react-B5cGaxH8.js} +738 -513
  50. package/dist/react-B5cGaxH8.js.map +1 -0
  51. package/dist/react.cjs +1 -1
  52. package/dist/react.mjs +1 -1
  53. package/dist/renderer/GeometryCanvas.d.ts.map +1 -1
  54. package/dist/renderer/StudentGeometryCanvas.d.ts.map +1 -1
  55. package/dist/renderer/Toolbar.d.ts.map +1 -1
  56. package/dist/renderer/angleMeasure.d.cts +14 -0
  57. package/dist/renderer/angleMeasure.d.ts +15 -0
  58. package/dist/renderer/angleMeasure.d.ts.map +1 -0
  59. package/dist/renderer/deriveRenderableGeometry.d.cts +1 -0
  60. package/dist/renderer/deriveRenderableGeometry.d.ts +1 -0
  61. package/dist/renderer/deriveRenderableGeometry.d.ts.map +1 -1
  62. package/dist/renderer/deriveSemanticScene.d.ts.map +1 -1
  63. package/dist/renderer/dragSnap.d.cts +14 -0
  64. package/dist/renderer/dragSnap.d.ts +15 -0
  65. package/dist/renderer/dragSnap.d.ts.map +1 -0
  66. package/dist/renderer/shapes/AngleShape.d.cts +19 -0
  67. package/dist/renderer/shapes/AngleShape.d.ts +20 -0
  68. package/dist/renderer/shapes/AngleShape.d.ts.map +1 -0
  69. package/dist/renderer/shapes/EntityLabel.d.cts +9 -1
  70. package/dist/renderer/shapes/EntityLabel.d.ts +9 -1
  71. package/dist/renderer/shapes/EntityLabel.d.ts.map +1 -1
  72. package/dist/renderer/shapes/EntityShape.d.cts +2 -1
  73. package/dist/renderer/shapes/EntityShape.d.ts +2 -1
  74. package/dist/renderer/shapes/EntityShape.d.ts.map +1 -1
  75. package/dist/renderer/useConnectionPreview.d.cts +12 -1
  76. package/dist/renderer/useConnectionPreview.d.ts +12 -1
  77. package/dist/renderer/useConnectionPreview.d.ts.map +1 -1
  78. package/dist/renderer/usePointerGestures.d.cts +1 -1
  79. package/dist/renderer/usePointerGestures.d.ts +1 -1
  80. package/dist/renderer/usePointerGestures.d.ts.map +1 -1
  81. package/dist/schemas/entityDefinition.schema.d.cts +7 -0
  82. package/dist/schemas/entityDefinition.schema.d.ts +7 -0
  83. package/dist/schemas/entityDefinition.schema.d.ts.map +1 -1
  84. package/dist/schemas/entityDocument.d.cts +34 -13
  85. package/dist/schemas/entityDocument.d.ts +34 -13
  86. package/dist/schemas/entityDocument.d.ts.map +1 -1
  87. package/dist/schemas/entityPresentation.schema.d.cts +3 -0
  88. package/dist/schemas/entityPresentation.schema.d.ts +3 -0
  89. package/dist/schemas/entityPresentation.schema.d.ts.map +1 -1
  90. package/dist/schemas/exercise.schema.d.cts +80 -2
  91. package/dist/schemas/exercise.schema.d.ts +80 -2
  92. package/dist/schemas/exercise.schema.d.ts.map +1 -1
  93. package/dist/schemas/exerciseV2.schema.d.cts +57 -0
  94. package/dist/schemas/exerciseV2.schema.d.ts +57 -0
  95. package/dist/schemas/exerciseV2.schema.d.ts.map +1 -1
  96. package/dist/schemas/exerciseV4.schema.d.cts +168 -0
  97. package/dist/schemas/exerciseV4.schema.d.ts +169 -0
  98. package/dist/schemas/exerciseV4.schema.d.ts.map +1 -0
  99. package/dist/schemas/geometryState.schema.d.cts +8 -0
  100. package/dist/schemas/geometryState.schema.d.ts +8 -0
  101. package/dist/schemas/geometryState.schema.d.ts.map +1 -1
  102. package/dist/schemas/goals/angleBisectorGoal.schema.d.cts +15 -0
  103. package/dist/schemas/goals/angleBisectorGoal.schema.d.ts +16 -0
  104. package/dist/schemas/goals/angleBisectorGoal.schema.d.ts.map +1 -0
  105. package/dist/schemas/goals/angleCriterion.schema.d.cts +28 -0
  106. package/dist/schemas/goals/angleCriterion.schema.d.ts +29 -0
  107. package/dist/schemas/goals/angleCriterion.schema.d.ts.map +1 -0
  108. package/dist/schemas/goals/angleMeasureGoal.schema.d.cts +26 -0
  109. package/dist/schemas/goals/angleMeasureGoal.schema.d.ts +27 -0
  110. package/dist/schemas/goals/angleMeasureGoal.schema.d.ts.map +1 -0
  111. package/dist/schemas/goals/createGoal.schema.d.cts +1 -0
  112. package/dist/schemas/goals/createGoal.schema.d.ts +1 -0
  113. package/dist/schemas/goals/createGoal.schema.d.ts.map +1 -1
  114. package/dist/schemas/goals/geometryGoal.schema.d.cts +61 -0
  115. package/dist/schemas/goals/geometryGoal.schema.d.ts +61 -0
  116. package/dist/schemas/goals/geometryGoal.schema.d.ts.map +1 -1
  117. package/dist/schemas/goals/givenAngleGoal.schema.d.cts +35 -0
  118. package/dist/schemas/goals/givenAngleGoal.schema.d.ts +36 -0
  119. package/dist/schemas/goals/givenAngleGoal.schema.d.ts.map +1 -0
  120. package/dist/schemas/goals/goalKindDeclaration.d.cts +7 -0
  121. package/dist/schemas/goals/goalKindDeclaration.d.ts +7 -0
  122. package/dist/schemas/goals/goalKindDeclaration.d.ts.map +1 -1
  123. package/dist/schemas/goals/parallelGoal.schema.d.cts +1 -0
  124. package/dist/schemas/goals/parallelGoal.schema.d.ts +1 -0
  125. package/dist/schemas/goals/parallelGoal.schema.d.ts.map +1 -1
  126. package/dist/schemas/goals/perpendicularGoal.schema.d.cts +1 -0
  127. package/dist/schemas/goals/perpendicularGoal.schema.d.ts +1 -0
  128. package/dist/schemas/goals/perpendicularGoal.schema.d.ts.map +1 -1
  129. package/dist/schemas/goals/throughPointsGoal.schema.d.cts +1 -0
  130. package/dist/schemas/goals/throughPointsGoal.schema.d.ts +1 -0
  131. package/dist/schemas/goals/throughPointsGoal.schema.d.ts.map +1 -1
  132. package/dist/schemas/objectTypeName.schema.d.cts +1 -0
  133. package/dist/schemas/objectTypeName.schema.d.ts +1 -0
  134. package/dist/schemas/objectTypeName.schema.d.ts.map +1 -1
  135. package/dist/schemas/v2ToV3.d.cts +15 -1
  136. package/dist/schemas/v2ToV3.d.ts +15 -1
  137. package/dist/schemas/v2ToV3.d.ts.map +1 -1
  138. package/dist/schemas/v3ToV4.d.cts +2 -1
  139. package/dist/schemas/v3ToV4.d.ts +2 -1
  140. package/dist/schemas/v3ToV4.d.ts.map +1 -1
  141. package/dist/schemas/v4ToV5.d.cts +7 -0
  142. package/dist/schemas/v4ToV5.d.ts +8 -0
  143. package/dist/schemas/v4ToV5.d.ts.map +1 -0
  144. package/dist/schemas.cjs +1 -1
  145. package/dist/schemas.mjs +3 -3
  146. package/dist/snapping/computeDragSnap.d.cts +30 -0
  147. package/dist/snapping/computeDragSnap.d.ts +31 -0
  148. package/dist/snapping/computeDragSnap.d.ts.map +1 -0
  149. package/dist/state/geometryContext.d.ts.map +1 -1
  150. package/dist/store/attemptChange.d.cts +1 -1
  151. package/dist/store/attemptChange.d.ts +1 -1
  152. package/dist/store/attemptChange.d.ts.map +1 -1
  153. package/dist/store/constructionCommand.d.cts +14 -2
  154. package/dist/store/constructionCommand.d.ts +14 -2
  155. package/dist/store/constructionCommand.d.ts.map +1 -1
  156. package/dist/store/constructionIdentity.d.cts +9 -0
  157. package/dist/store/constructionIdentity.d.ts +9 -0
  158. package/dist/store/constructionIdentity.d.ts.map +1 -1
  159. package/dist/store/studentStore.d.cts +7 -0
  160. package/dist/store/studentStore.d.ts +7 -0
  161. package/dist/store/studentStore.d.ts.map +1 -1
  162. package/dist/store/teacherStore.d.cts +16 -0
  163. package/dist/store/teacherStore.d.ts +16 -0
  164. package/dist/store/teacherStore.d.ts.map +1 -1
  165. package/dist/{studentStore-CEKTtMCh.js → studentStore-CyYa0N93.js} +502 -370
  166. package/dist/studentStore-CyYa0N93.js.map +1 -0
  167. package/dist/studentStore-ubldy4PJ.cjs +2 -0
  168. package/dist/studentStore-ubldy4PJ.cjs.map +1 -0
  169. package/dist/validation/getGeometryExerciseWarnings.d.cts +3 -2
  170. package/dist/validation/getGeometryExerciseWarnings.d.ts +3 -2
  171. package/dist/validation/getGeometryExerciseWarnings.d.ts.map +1 -1
  172. package/dist/validation/goals/angleBisector.d.cts +3 -0
  173. package/dist/validation/goals/angleBisector.d.ts +4 -0
  174. package/dist/validation/goals/angleBisector.d.ts.map +1 -0
  175. package/dist/validation/goals/angleCriterion.d.cts +12 -0
  176. package/dist/validation/goals/angleCriterion.d.ts +13 -0
  177. package/dist/validation/goals/angleCriterion.d.ts.map +1 -0
  178. package/dist/validation/goals/angleMeasure.d.cts +9 -0
  179. package/dist/validation/goals/angleMeasure.d.ts +10 -0
  180. package/dist/validation/goals/angleMeasure.d.ts.map +1 -0
  181. package/dist/validation/goals/create.d.cts +2 -2
  182. package/dist/validation/goals/create.d.ts +2 -2
  183. package/dist/validation/goals/create.d.ts.map +1 -1
  184. package/dist/validation/goals/givenAngle.d.cts +11 -0
  185. package/dist/validation/goals/givenAngle.d.ts +12 -0
  186. package/dist/validation/goals/givenAngle.d.ts.map +1 -0
  187. package/dist/validation/goals/goalKindHandler.d.cts +38 -1
  188. package/dist/validation/goals/goalKindHandler.d.ts +38 -1
  189. package/dist/validation/goals/goalKindHandler.d.ts.map +1 -1
  190. package/dist/validation/goals/index.d.cts +9 -2
  191. package/dist/validation/goals/index.d.ts +9 -2
  192. package/dist/validation/goals/index.d.ts.map +1 -1
  193. package/dist/validation/goals/midpoint.d.cts +2 -2
  194. package/dist/validation/goals/midpoint.d.ts +2 -2
  195. package/dist/validation/goals/midpoint.d.ts.map +1 -1
  196. package/dist/validation/goals/parallel.d.cts +2 -2
  197. package/dist/validation/goals/parallel.d.ts +2 -2
  198. package/dist/validation/goals/parallel.d.ts.map +1 -1
  199. package/dist/validation/goals/perpendicular.d.cts +2 -2
  200. package/dist/validation/goals/perpendicular.d.ts +2 -2
  201. package/dist/validation/goals/perpendicular.d.ts.map +1 -1
  202. package/dist/validation/goals/segmentLength.d.cts +2 -2
  203. package/dist/validation/goals/segmentLength.d.ts +2 -2
  204. package/dist/validation/goals/segmentLength.d.ts.map +1 -1
  205. package/dist/validation/goals/throughPoints.d.cts +2 -2
  206. package/dist/validation/goals/throughPoints.d.ts +2 -2
  207. package/dist/validation/goals/throughPoints.d.ts.map +1 -1
  208. package/dist/validation/types.d.cts +5 -1
  209. package/dist/validation/types.d.ts +5 -1
  210. package/dist/validation/types.d.ts.map +1 -1
  211. package/dist/validation/validateGeometryState.d.ts.map +1 -1
  212. package/dist/validation/validateGeometryStateInput.d.ts.map +1 -1
  213. package/dist/validation.cjs +1 -1
  214. package/dist/validation.cjs.map +1 -1
  215. package/dist/validation.mjs +106 -85
  216. package/dist/validation.mjs.map +1 -1
  217. package/package.json +1 -1
  218. package/dist/exercise.schema-BV2b7rtN.cjs +0 -2
  219. package/dist/exercise.schema-BV2b7rtN.cjs.map +0 -1
  220. package/dist/exercise.schema-ckVBW9XA.js +0 -212
  221. package/dist/exercise.schema-ckVBW9XA.js.map +0 -1
  222. package/dist/geometryAttemptStatus-5L_q6-9l.js.map +0 -1
  223. package/dist/geometryAttemptStatus-N_XHIkiS.cjs +0 -2
  224. package/dist/geometryAttemptStatus-N_XHIkiS.cjs.map +0 -1
  225. package/dist/geometryState.schema-D0ixyGYE.js +0 -955
  226. package/dist/geometryState.schema-D0ixyGYE.js.map +0 -1
  227. package/dist/geometryState.schema-DKQ-durx.cjs +0 -2
  228. package/dist/geometryState.schema-DKQ-durx.cjs.map +0 -1
  229. package/dist/goals-C3ZwbEh_.js +0 -451
  230. package/dist/goals-C3ZwbEh_.js.map +0 -1
  231. package/dist/goals-CxR5qPDC.cjs +0 -2
  232. package/dist/goals-CxR5qPDC.cjs.map +0 -1
  233. package/dist/react-BEcdx1f6.js.map +0 -1
  234. package/dist/react-Pp_VSk--.cjs +0 -2
  235. package/dist/react-Pp_VSk--.cjs.map +0 -1
  236. package/dist/studentStore-CEKTtMCh.js.map +0 -1
  237. package/dist/studentStore-DLftfFAl.cjs +0 -2
  238. package/dist/studentStore-DLftfFAl.cjs.map +0 -1
@@ -1,39 +1,39 @@
1
- import { A as e, B as t, I as n, M as r, N as i, O as a, P as o, V as s, ft as c, ht as l, j as u, u as d, ut as f, z as p } from "./geometryState.schema-D0ixyGYE.js";
2
- import { a as m, d as h, s as g, u as _ } from "./goals-C3ZwbEh_.js";
1
+ import { A as e, B as t, F as n, I as r, J as i, L as a, M as o, P as s, R as c, U as l, W as u, u as d, wt as f, xt as p, yt as m } from "./geometryState.schema-CKFPlX8j.js";
2
+ import { c as h, d as g, f as _, o as ee } from "./goals-BlSeniyt.js";
3
3
  //#region src/geometry/hitTest.ts
4
- function v(t, r, i, a = {}) {
5
- let o = new Set(a.exclude ?? []), s = a.types ? new Set(a.types) : null, c = [];
6
- if (!s || s.has("point")) for (let [n, s] of r.points) {
7
- if (o.has(n) || a.accepts && !a.accepts(n)) continue;
8
- let r = e({
4
+ function v(e, r, i, a = {}) {
5
+ let o = new Set(a.exclude ?? []), c = a.types ? new Set(a.types) : null, l = [];
6
+ if (!c || c.has("point")) for (let [t, n] of r.points) {
7
+ if (o.has(t) || a.accepts && !a.accepts(t)) continue;
8
+ let r = s({
9
9
  kind: "point",
10
- at: s
11
- }, t);
12
- r <= i && c.push({
13
- id: n,
10
+ at: n
11
+ }, e);
12
+ r <= i && l.push({
13
+ id: t,
14
14
  type: "point",
15
15
  distance: r
16
16
  });
17
17
  }
18
- for (let { id: l, definition: u } of r.objects) {
19
- if (o.has(l) || a.accepts && !a.accepts(l) || s && !s.has(u.kind)) continue;
20
- let d = n(u, r.points);
18
+ for (let { id: n, definition: u } of r.objects) {
19
+ if (o.has(n) || a.accepts && !a.accepts(n) || c && !c.has(u.kind)) continue;
20
+ let d = t(u, r.points);
21
21
  if (!d) continue;
22
- let f = e(d, t);
23
- f <= i && c.push({
24
- id: l,
22
+ let f = s(d, e);
23
+ f <= i && l.push({
24
+ id: n,
25
25
  type: u.kind,
26
26
  distance: f
27
27
  });
28
28
  }
29
- return c.sort((e, t) => u(e.type) - u(t.type) || e.distance - t.distance);
29
+ return l.sort((e, t) => n(e.type) - n(t.type) || e.distance - t.distance);
30
30
  }
31
- function y(e, t, n, r = {}) {
31
+ function te(e, t, n, r = {}) {
32
32
  return v(e, t, n, r)[0] ?? null;
33
33
  }
34
34
  //#endregion
35
35
  //#region src/coordinates/transform.ts
36
- function b(e, t) {
36
+ function y(e, t) {
37
37
  let [n, r, i, a] = e, o = t.width / (i - n), s = t.height / (a - r), c = Math.min(o, s), l = t.projection === "stretch" ? o : c, u = t.projection === "stretch" ? s : c;
38
38
  return {
39
39
  scale: c,
@@ -43,26 +43,26 @@ function b(e, t) {
43
43
  offsetY: (t.height - (a - r) * u) / 2
44
44
  };
45
45
  }
46
- function ee(e, t, n, r = b(t, n)) {
46
+ function ne(e, t, n, r = y(t, n)) {
47
47
  let [i, a] = t, { scaleX: o, scaleY: s, offsetX: c, offsetY: l } = r;
48
48
  return {
49
49
  x: c + (e.x - i) * o,
50
50
  y: n.height - l - (e.y - a) * s
51
51
  };
52
52
  }
53
- function te(e, t, n, r = b(t, n)) {
53
+ function re(e, t, n, r = y(t, n)) {
54
54
  let [i, a] = t, { scaleX: o, scaleY: s, offsetX: c, offsetY: l } = r;
55
55
  return {
56
56
  x: (e.x - c) / o + i,
57
57
  y: (n.height - l - e.y) / s + a
58
58
  };
59
59
  }
60
- function ne(e, t) {
61
- return c(e, Math.min(t.scaleX, t.scaleY));
60
+ function ie(e, t) {
61
+ return p(e, Math.min(t.scaleX, t.scaleY));
62
62
  }
63
63
  //#endregion
64
64
  //#region src/coordinates/lineClipping.ts
65
- function re(e, t, n) {
65
+ function ae(e, t, n) {
66
66
  let r = t.x - e.x, i = t.y - e.y;
67
67
  if (r === 0 && i === 0) return null;
68
68
  let [a, o, s, c] = n, l = [
@@ -89,24 +89,24 @@ function re(e, t, n) {
89
89
  }
90
90
  //#endregion
91
91
  //#region src/coordinates/grid.ts
92
- function x(e) {
92
+ function b(e) {
93
93
  if (e >= 4 && e <= 20) return 1;
94
94
  let t = e / 16, n = 10 ** Math.floor(Math.log10(t)), r = t / n;
95
95
  return r <= 2 ? 2 * n : r <= 5 ? 5 * n : 10 * n;
96
96
  }
97
- function ie(e) {
97
+ function x(e) {
98
98
  let [t, n, r, i] = e;
99
99
  return {
100
- x: x(r - t),
101
- y: x(i - n)
100
+ x: b(r - t),
101
+ y: b(i - n)
102
102
  };
103
103
  }
104
104
  function S(e, t, n, r) {
105
105
  let i = Math.ceil(n / t) * t, a = Math.floor(r / t) * t;
106
106
  return Math.min(a, Math.max(i, Math.round(e / t) * t));
107
107
  }
108
- function C(e, t) {
109
- let [n, r, i, a] = t, o = ie(t);
108
+ function oe(e, t) {
109
+ let [n, r, i, a] = t, o = x(t);
110
110
  return {
111
111
  x: S(e.x, o.x, n, i),
112
112
  y: S(e.y, o.y, r, a)
@@ -114,13 +114,13 @@ function C(e, t) {
114
114
  }
115
115
  //#endregion
116
116
  //#region src/snapping/computeSnap.ts
117
- var ae = [
117
+ var se = [
118
118
  "point",
119
119
  "intersection",
120
120
  "grid",
121
121
  "onObject"
122
122
  ];
123
- function oe(e, t, n) {
123
+ function ce(e, t, n) {
124
124
  let r = v(e, t, n.tolerance, {
125
125
  exclude: n.exclude,
126
126
  types: ["point"],
@@ -135,37 +135,37 @@ function oe(e, t, n) {
135
135
  distance: r.distance
136
136
  } : null;
137
137
  }
138
- function se(e, t, r) {
139
- let a = new Set(r.exclude ?? []), o = [];
140
- for (let { id: e, definition: r } of t.objects) {
141
- if (a.has(e) || t.isSnapTarget && !t.isSnapTarget(e)) continue;
142
- let s = n(r, t.points), c = s && i(s);
143
- c && o.push({
138
+ function le(e, n, r) {
139
+ let o = new Set(r.exclude ?? []), s = [];
140
+ for (let { id: e, definition: r } of n.objects) {
141
+ if (o.has(e) || n.isSnapTarget && !n.isSnapTarget(e)) continue;
142
+ let i = t(r, n.points), c = i && a(i);
143
+ c && s.push({
144
144
  id: e,
145
145
  measured: c
146
146
  });
147
147
  }
148
148
  let c = null;
149
- for (let t = 0; t < o.length; t += 1) {
150
- let n = o[t];
151
- for (let i = t + 1; i < o.length; i += 1) {
152
- let t = o[i];
153
- for (let i of s(n.measured, t.measured)) {
154
- let a = l(e, i);
155
- a > r.tolerance || c && c.distance <= a || (c = {
156
- position: i,
149
+ for (let t = 0; t < s.length; t += 1) {
150
+ let n = s[t];
151
+ for (let a = t + 1; a < s.length; a += 1) {
152
+ let t = s[a];
153
+ for (let a of i(n.measured, t.measured)) {
154
+ let i = f(e, a);
155
+ i > r.tolerance || c && c.distance <= i || (c = {
156
+ position: a,
157
157
  kind: "intersection",
158
158
  targetIds: [n.id, t.id],
159
- distance: a
159
+ distance: i
160
160
  });
161
161
  }
162
162
  }
163
163
  }
164
164
  return c;
165
165
  }
166
- function ce(e, t, n) {
166
+ function ue(e, t, n) {
167
167
  if (!t.showGrid) return null;
168
- let r = C(e, t.viewport), i = l(e, r);
168
+ let r = oe(e, t.viewport), i = f(e, r);
169
169
  return i > n.tolerance ? null : {
170
170
  position: r,
171
171
  kind: "grid",
@@ -173,47 +173,47 @@ function ce(e, t, n) {
173
173
  distance: i
174
174
  };
175
175
  }
176
- function le(e, r, i) {
177
- let a = v(e, r, i.tolerance, {
178
- exclude: i.exclude,
179
- types: o,
180
- accepts: r.isSnapTarget
176
+ function de(e, n, r) {
177
+ let i = v(e, n, r.tolerance, {
178
+ exclude: r.exclude,
179
+ types: c,
180
+ accepts: n.isSnapTarget
181
181
  })[0];
182
+ if (!i) return null;
183
+ let a = n.objects.find((e) => e.id === i.id);
182
184
  if (!a) return null;
183
- let s = r.objects.find((e) => e.id === a.id);
184
- if (!s) return null;
185
- let c = n(s.definition, r.points);
186
- if (!c) return null;
187
- let l = p(c, e);
188
- if (l === null) return null;
189
- let u = t(c, l);
190
- return u ? {
191
- position: u,
185
+ let o = t(a.definition, n.points);
186
+ if (!o) return null;
187
+ let s = l(o, e);
188
+ if (s === null) return null;
189
+ let d = u(o, s);
190
+ return d ? {
191
+ position: d,
192
192
  kind: "onObject",
193
- targetIds: [s.id],
194
- parameter: l,
195
- distance: a.distance
193
+ targetIds: [a.id],
194
+ parameter: s,
195
+ distance: i.distance
196
196
  } : null;
197
197
  }
198
- var ue = {
199
- point: oe,
200
- intersection: se,
201
- grid: ce,
202
- onObject: le
198
+ var fe = {
199
+ point: ce,
200
+ intersection: le,
201
+ grid: ue,
202
+ onObject: de
203
203
  };
204
- function w(e, t, n) {
204
+ function pe(e, t, n) {
205
205
  let r = n.kinds ? new Set(n.kinds) : null;
206
- for (let i of ae) {
206
+ for (let i of se) {
207
207
  if (r && !r.has(i)) continue;
208
- let a = ue[i](e, t, n);
208
+ let a = fe[i](e, t, n);
209
209
  if (a) return a;
210
210
  }
211
211
  return null;
212
212
  }
213
- function de(e, t, n) {
214
- return w(e, t, n)?.position ?? e;
213
+ function me(e, t, n) {
214
+ return pe(e, t, n)?.position ?? e;
215
215
  }
216
- function fe(e) {
216
+ function he(e) {
217
217
  let { snap: t, position: n } = e, r = {
218
218
  kind: "point",
219
219
  at: {
@@ -238,7 +238,7 @@ function fe(e) {
238
238
  }
239
239
  //#endregion
240
240
  //#region src/store/createStore.ts
241
- function T(e) {
241
+ function C(e) {
242
242
  let t = e, n = /* @__PURE__ */ new Set();
243
243
  function r() {
244
244
  return t;
@@ -260,50 +260,59 @@ function T(e) {
260
260
  subscribe: a
261
261
  };
262
262
  }
263
- function pe(e, t) {
263
+ function w(e, t) {
264
264
  let n = [...e, t];
265
265
  return n.length > 100 ? n.slice(n.length - 100) : n;
266
266
  }
267
267
  //#endregion
268
+ //#region src/store/constructionCommand.ts
269
+ function T(e) {
270
+ return e.tool === "angle" ? [
271
+ e.from,
272
+ e.vertex,
273
+ e.to
274
+ ] : [e.from, e.to];
275
+ }
276
+ //#endregion
268
277
  //#region src/store/constructionIdentity.ts
269
- var me = /* @__PURE__ */ new WeakMap();
278
+ var ge = /* @__PURE__ */ new WeakMap();
270
279
  function E(e) {
271
- let t = me.get(e);
272
- return t === void 0 && (t = `${e.kind} ${r(e)}`, me.set(e, t)), t;
280
+ let t = ge.get(e);
281
+ return t === void 0 && (t = `${e.kind} ${r(e)}`, ge.set(e, t)), t;
273
282
  }
274
- var he = /* @__PURE__ */ new WeakMap();
275
- function D(e) {
276
- let t = he.get(e);
283
+ var _e = /* @__PURE__ */ new WeakMap();
284
+ function ve(e) {
285
+ let t = _e.get(e);
277
286
  if (!t) {
278
287
  let n = /* @__PURE__ */ new Map();
279
288
  for (let t of Object.keys(e)) {
280
- let r = a(e, t);
289
+ let r = o(e, t);
281
290
  if (!r) continue;
282
291
  let i = E(r);
283
292
  n.has(i) || n.set(i, t);
284
293
  }
285
- he.set(e, n), t = n;
294
+ _e.set(e, n), t = n;
286
295
  }
287
296
  return t;
288
297
  }
289
- function O(e, t, n) {
298
+ function D(e, t, n) {
290
299
  let r = E(t);
291
- if (!n) return D(e).get(r) ?? null;
300
+ if (!n) return ve(e).get(r) ?? null;
292
301
  for (let i of Object.keys(e)) {
293
- let o = a(e, i);
294
- if (!(o?.kind !== t.kind || !n(i)) && E(o) === r) return i;
302
+ let a = o(e, i);
303
+ if (!(a?.kind !== t.kind || !n(i)) && E(a) === r) return i;
295
304
  }
296
305
  return null;
297
306
  }
298
- function k(e, t, n = {}) {
307
+ function ye(e, t, n = {}) {
299
308
  let r = e.map((e) => e.kind === "create" ? E(e.origin) : null), i = r.map(() => null);
300
309
  if (r.every((e) => e === null)) return i;
301
- let o = !1;
310
+ let a = !1;
302
311
  for (let e of Object.keys(n)) {
303
- let s = a(n, e);
312
+ let s = o(n, e);
304
313
  if (s?.kind !== "point") continue;
305
314
  if (Object.prototype.hasOwnProperty.call(t, e)) {
306
- o = !0;
315
+ a = !0;
307
316
  continue;
308
317
  }
309
318
  let c = E(s);
@@ -313,15 +322,23 @@ function k(e, t, n = {}) {
313
322
  }
314
323
  return r.map((e, r) => {
315
324
  if (e === null) return null;
316
- if (!o) return D(t).get(e) ?? i[r] ?? null;
325
+ if (!a) return ve(t).get(e) ?? i[r] ?? null;
317
326
  for (let r of Object.keys(t)) {
318
- let i = a(n, r) ?? a(t, r);
327
+ let i = o(n, r) ?? o(t, r);
319
328
  if (i && E(i) === e) return r;
320
329
  }
321
330
  return i[r] ?? null;
322
331
  });
323
332
  }
324
- function A(e) {
333
+ function O(e, t) {
334
+ let n = e.map((e, n) => {
335
+ if (e.kind === "existing") return `p${e.id}`;
336
+ let r = t[n];
337
+ return r ? `p${r}` : `n${E(e.origin)}`;
338
+ });
339
+ return new Set(n).size < n.length;
340
+ }
341
+ function k(e) {
325
342
  return {
326
343
  code: "duplicate-construction",
327
344
  entityId: e
@@ -329,11 +346,12 @@ function A(e) {
329
346
  }
330
347
  //#endregion
331
348
  //#region src/store/teacherStore.ts
332
- function ge(e) {
333
- return T({
349
+ function be(e) {
350
+ return C({
334
351
  exercise: e,
335
352
  pendingObjectType: null,
336
353
  pendingFirstPointId: null,
354
+ pendingVertexPointId: null,
337
355
  selectedGivenId: null,
338
356
  past: [],
339
357
  future: [],
@@ -342,9 +360,17 @@ function ge(e) {
342
360
  constructionNotice: null
343
361
  });
344
362
  }
345
- function j(e) {
346
- e.getState().constructionNotice && e.setState({ constructionNotice: null });
363
+ function A(e) {
364
+ let t = e.getState();
365
+ (t.constructionNotice || t.pendingFirstPointId) && e.setState({
366
+ ...j,
367
+ constructionNotice: null
368
+ });
347
369
  }
370
+ var j = {
371
+ pendingFirstPointId: null,
372
+ pendingVertexPointId: null
373
+ };
348
374
  function M(e, t, n = {}, r = {}) {
349
375
  e.setState((e) => {
350
376
  let i = t(e.exercise);
@@ -352,32 +378,32 @@ function M(e, t, n = {}, r = {}) {
352
378
  let a = r.coalesceTag ?? null;
353
379
  return {
354
380
  exercise: i,
355
- past: a !== null && a === e.coalesceTag ? e.past : pe(e.past, e.exercise),
381
+ past: a !== null && a === e.coalesceTag ? e.past : w(e.past, e.exercise),
356
382
  future: [],
357
383
  coalesceTag: a,
358
384
  ...n
359
385
  };
360
386
  });
361
387
  }
362
- function N(e) {
388
+ function xe(e) {
363
389
  let t = e + 1, n = "";
364
390
  for (; t > 0;) --t, n = String.fromCharCode(65 + t % 26) + n, t = Math.floor(t / 26);
365
391
  return n;
366
392
  }
367
- function P(e) {
393
+ function Se(e) {
368
394
  let t = 0;
369
- for (; F(e, N(t));) t += 1;
370
- return N(t);
395
+ for (; N(e, xe(t));) t += 1;
396
+ return xe(t);
371
397
  }
372
- function _e(e, t) {
398
+ function Ce(e, t) {
373
399
  let n = 1;
374
- for (; F(e, `${t}-${n}`);) n += 1;
400
+ for (; N(e, `${t}-${n}`);) n += 1;
375
401
  return `${t}-${n}`;
376
402
  }
377
- function F(e, t) {
403
+ function N(e, t) {
378
404
  return Object.prototype.hasOwnProperty.call(e.entities, t);
379
405
  }
380
- function I(e, t, n, r) {
406
+ function P(e, t, n, r) {
381
407
  return {
382
408
  ...e,
383
409
  entities: {
@@ -390,11 +416,12 @@ function I(e, t, n, r) {
390
416
  } : e.presentation
391
417
  };
392
418
  }
393
- function ve(e, t) {
419
+ function we(e, t) {
394
420
  e.setState((e) => ({
395
421
  exercise: t,
396
422
  pendingObjectType: null,
397
423
  pendingFirstPointId: null,
424
+ pendingVertexPointId: null,
398
425
  selectedGivenId: null,
399
426
  past: [],
400
427
  future: [],
@@ -403,7 +430,7 @@ function ve(e, t) {
403
430
  constructionNotice: null
404
431
  }));
405
432
  }
406
- function ye(e) {
433
+ function Te(e) {
407
434
  e.setState((e) => {
408
435
  let t = e.past[e.past.length - 1];
409
436
  return t ? {
@@ -412,13 +439,14 @@ function ye(e) {
412
439
  future: [e.exercise, ...e.future],
413
440
  selectedGivenId: null,
414
441
  pendingFirstPointId: null,
442
+ pendingVertexPointId: null,
415
443
  coalesceTag: null,
416
444
  interactionEpoch: (e.interactionEpoch ?? 0) + 1,
417
445
  constructionNotice: null
418
446
  } : {};
419
447
  });
420
448
  }
421
- function be(e) {
449
+ function Ee(e) {
422
450
  e.setState((e) => {
423
451
  let t = e.future[0];
424
452
  return t ? {
@@ -427,40 +455,41 @@ function be(e) {
427
455
  future: e.future.slice(1),
428
456
  selectedGivenId: null,
429
457
  pendingFirstPointId: null,
458
+ pendingVertexPointId: null,
430
459
  coalesceTag: null,
431
460
  interactionEpoch: (e.interactionEpoch ?? 0) + 1,
432
461
  constructionNotice: null
433
462
  } : {};
434
463
  });
435
464
  }
436
- function xe(e, t) {
465
+ function De(e, t) {
437
466
  e.setState({ selectedGivenId: t });
438
467
  }
439
- function Se(e, t) {
468
+ function Oe(e, t) {
440
469
  M(e, (e) => ({
441
470
  ...e,
442
471
  viewport: t
443
472
  }));
444
473
  }
445
- function Ce(e, t) {
474
+ function ke(e, t) {
446
475
  M(e, (e) => ({
447
476
  ...e,
448
477
  showGrid: t
449
478
  }));
450
479
  }
451
- function we(e, t) {
480
+ function Ae(e, t) {
452
481
  M(e, (e) => ({
453
482
  ...e,
454
483
  allowedObjects: t
455
484
  }));
456
485
  }
457
- function Te(e, t) {
486
+ function je(e, t) {
458
487
  M(e, (e) => ({
459
488
  ...e,
460
489
  tools: t
461
490
  }));
462
491
  }
463
- function Ee(e, t) {
492
+ function Me(e, t) {
464
493
  M(e, (e) => {
465
494
  if (t === "allow") {
466
495
  if (e.grading === void 0) return e;
@@ -473,45 +502,45 @@ function Ee(e, t) {
473
502
  };
474
503
  });
475
504
  }
476
- function De(e, t) {
505
+ function Ne(e, t) {
477
506
  M(e, (e) => ({
478
507
  ...e,
479
508
  goals: [...e.goals, t]
480
509
  }));
481
510
  }
482
- function Oe(e, t) {
511
+ function Pe(e, t) {
483
512
  M(e, (e) => ({
484
513
  ...e,
485
514
  goals: e.goals.map((e) => e.id === t.id ? t : e)
486
515
  }));
487
516
  }
488
- function ke(e, t) {
517
+ function Fe(e, t) {
489
518
  M(e, (e) => ({
490
519
  ...e,
491
520
  goals: e.goals.filter((e) => e.id !== t)
492
521
  }));
493
522
  }
494
- function Ae(e, t, n = !1) {
523
+ function Ie(e, t, n = !1) {
495
524
  let { exercise: r } = e.getState(), i = "kind" in t ? t : {
496
525
  kind: "point",
497
526
  at: {
498
527
  x: t.x,
499
528
  y: t.y
500
529
  }
501
- }, a = O(r.entities, i);
502
- if (a) return e.setState({ constructionNotice: A(a) }), a;
503
- let o = P(r);
530
+ }, a = D(r.entities, i);
531
+ if (a) return e.setState({ constructionNotice: k(a) }), a;
532
+ let o = Se(r);
504
533
  return M(e, (e) => {
505
- let t = I(e, o, i);
534
+ let t = P(e, o, i);
506
535
  return n ? {
507
536
  ...t,
508
537
  draggableEntityIds: [...t.draggableEntityIds, o]
509
538
  } : t;
510
539
  }, { constructionNotice: null }), o;
511
540
  }
512
- function je(e, t) {
541
+ function Le(e, t) {
513
542
  let n = e.getState();
514
- a(n.exercise.entities, t) && n.exercise.presentation[t]?.role === "implicit" && M(e, (e) => ({
543
+ o(n.exercise.entities, t) && n.exercise.presentation[t]?.role === "implicit" && M(e, (e) => ({
515
544
  ...e,
516
545
  presentation: {
517
546
  ...e.presentation,
@@ -522,47 +551,57 @@ function je(e, t) {
522
551
  }
523
552
  }));
524
553
  }
525
- function Me(e, t) {
526
- a(e.getState().exercise.entities, t)?.kind === "point" && je(e, t);
554
+ function Re(e, t) {
555
+ o(e.getState().exercise.entities, t)?.kind === "point" && Le(e, t);
527
556
  }
528
- function Ne(e, t, n) {
557
+ function ze(e, t, n) {
529
558
  if (t.kind === "existing") return [e, t.id];
530
559
  if (n) return [e, n];
531
- let r = P(e);
532
- return [I(e, r, t.origin, "implicit"), r];
560
+ let r = Se(e);
561
+ return [P(e, r, t.origin, "implicit"), r];
533
562
  }
534
- function Pe(e, t) {
535
- let n = e.getState();
536
- if (![t.from, t.to].every((e) => e.kind !== "existing" || a(n.exercise.entities, e.id)?.kind === "point") || t.from.kind === "existing" && t.to.kind === "existing" && t.from.id === t.to.id) {
537
- j(e);
563
+ function Be(e, t) {
564
+ let n = e.getState(), r = T(t);
565
+ if (r.flatMap((e) => e.kind === "existing" ? [e.id] : []).some((e) => o(n.exercise.entities, e)?.kind !== "point")) {
566
+ A(e);
538
567
  return;
539
568
  }
540
- let [r = null, i = null] = k([t.from, t.to], n.exercise.entities), [o, s] = Ne(n.exercise, t.from, r), [c, l] = Ne(o, t.to, i), u = {
569
+ let i = ye(r, n.exercise.entities);
570
+ if (O(r, i)) {
571
+ A(e);
572
+ return;
573
+ }
574
+ let a = n.exercise, s = [];
575
+ for (let [e, t] of r.entries()) {
576
+ let [n, r] = ze(a, t, i[e] ?? null);
577
+ a = n, s.push(r);
578
+ }
579
+ let c = {
541
580
  kind: t.tool,
542
- parents: [s, l]
543
- }, d = c === n.exercise ? O(n.exercise.entities, u) : null;
544
- if (d) {
581
+ parents: s
582
+ }, l = a === n.exercise ? D(n.exercise.entities, c) : null;
583
+ if (l) {
545
584
  e.setState({
546
- pendingFirstPointId: null,
547
- constructionNotice: A(d)
585
+ ...j,
586
+ constructionNotice: k(l)
548
587
  });
549
588
  return;
550
589
  }
551
- let p = _e(c, t.tool), m = I(c, p, u, "explicit"), h = g(m), _ = h.points.get(s), v = h.points.get(l);
552
- if (!_ || !v || f(_, v)) {
553
- j(e);
590
+ let u = Ce(a, t.tool), d = P(a, u, c, "explicit"), f = h(d), p = s.map((e) => f.points.get(e)), g = p[1];
591
+ if (!g || !p.every((e, t) => e && (t === 1 || !m(e, g)))) {
592
+ A(e);
554
593
  return;
555
594
  }
556
- M(e, () => m, {
557
- pendingFirstPointId: null,
558
- selectedGivenId: p,
595
+ M(e, () => d, {
596
+ ...j,
597
+ selectedGivenId: u,
559
598
  constructionNotice: null
560
599
  });
561
600
  }
562
- function Fe(e, t, n) {
601
+ function Ve(e, t, n) {
563
602
  M(e, (e) => {
564
- let r = a(e.entities, t);
565
- return !r || r.kind !== "point" || !("at" in r) ? e : I(e, t, {
603
+ let r = o(e.entities, t);
604
+ return !r || r.kind !== "point" || !("at" in r) ? e : P(e, t, {
566
605
  kind: "point",
567
606
  at: {
568
607
  x: n.x,
@@ -571,149 +610,182 @@ function Fe(e, t, n) {
571
610
  });
572
611
  }, {}, { coalesceTag: `move:${t}` });
573
612
  }
574
- function Ie(e, t) {
575
- let n = a(e.exercise.entities, t);
613
+ function He(e, t) {
614
+ let n = o(e.exercise.entities, t);
576
615
  return n?.kind === "point" && "at" in n;
577
616
  }
578
- function Le(e) {
617
+ function Ue(e) {
579
618
  e.setState({ coalesceTag: null });
580
619
  }
581
- function Re(e, t, n) {
620
+ function We(e, t, n) {
582
621
  M(e, (e) => {
583
- let r = a(e.entities, t);
622
+ let r = o(e.entities, t);
584
623
  return !r || r.kind !== "point" || e.draggableEntityIds.includes(t) === n ? e : {
585
624
  ...e,
586
625
  draggableEntityIds: n ? [...e.draggableEntityIds, t] : e.draggableEntityIds.filter((e) => e !== t)
587
626
  };
588
627
  });
589
628
  }
590
- function ze(e, t, n) {
629
+ function Ge(e, t, n) {
591
630
  M(e, (e) => {
592
- if (!a(e.entities, t)) return e;
593
- let r = a(e.presentation, t), i = n.trim();
631
+ if (!o(e.entities, t)) return e;
632
+ let r = o(e.presentation, t), i = n.trim();
594
633
  if ((r?.label ?? "") === i) return e;
595
- let o = r?.role ?? "explicit";
596
- return {
634
+ let a = {
635
+ ...r,
636
+ role: r?.role ?? "explicit"
637
+ };
638
+ return i ? a.label = i : delete a.label, {
597
639
  ...e,
598
640
  presentation: {
599
641
  ...e.presentation,
600
- [t]: i ? {
601
- role: o,
602
- label: i
603
- } : { role: o }
642
+ [t]: a
604
643
  }
605
644
  };
606
645
  }, {}, { coalesceTag: `label:${t}` });
607
646
  }
608
- function Be(e, t) {
609
- if (!a(e.entities, t)) return {
647
+ function Ke(e, t, n) {
648
+ M(e, (e) => {
649
+ if (o(e.entities, t)?.kind !== "angle") return e;
650
+ let r = o(e.presentation, t);
651
+ if (r?.measureLabel === "degrees" === n) return e;
652
+ let i = {
653
+ ...r,
654
+ role: r?.role ?? "explicit"
655
+ };
656
+ return n ? i.measureLabel = "degrees" : delete i.measureLabel, {
657
+ ...e,
658
+ presentation: {
659
+ ...e.presentation,
660
+ [t]: i
661
+ }
662
+ };
663
+ });
664
+ }
665
+ function qe(e, t) {
666
+ if (!o(e.entities, t)) return {
610
667
  dependentEntityIds: [],
611
668
  dependentGoalIds: []
612
669
  };
613
- let n = g(e).removalClosureOf(t), r = new Set(n);
670
+ let n = h(e).removalClosureOf(t), r = new Set(n);
614
671
  return {
615
672
  dependentEntityIds: n.filter((e) => e !== t),
616
- dependentGoalIds: e.goals.filter((e) => m(e).some((e) => r.has(e))).map((e) => e.id)
673
+ dependentGoalIds: e.goals.filter((e) => ee(e).some((e) => r.has(e))).map((e) => e.id)
617
674
  };
618
675
  }
619
- function Ve(e, t) {
620
- M(e, (e) => {
621
- if (!F(e, t)) return e;
622
- let n = Be(e, t), r = /* @__PURE__ */ new Set([t, ...n.dependentEntityIds]);
623
- return {
624
- ...e,
625
- entities: Object.fromEntries(Object.entries(e.entities).filter(([e]) => !r.has(e))),
626
- presentation: Object.fromEntries(Object.entries(e.presentation).filter(([e]) => !r.has(e))),
627
- draggableEntityIds: e.draggableEntityIds.filter((e) => !r.has(e)),
628
- goals: e.goals.filter((e) => !n.dependentGoalIds.includes(e.id))
629
- };
630
- }, {
676
+ function Je(e, t) {
677
+ let { exercise: n, pendingFirstPointId: r, pendingVertexPointId: i } = e.getState();
678
+ if (!N(n, t)) return De(e, null);
679
+ let a = qe(n, t), o = /* @__PURE__ */ new Set([t, ...a.dependentEntityIds]);
680
+ M(e, () => ({
681
+ ...n,
682
+ entities: Object.fromEntries(Object.entries(n.entities).filter(([e]) => !o.has(e))),
683
+ presentation: Object.fromEntries(Object.entries(n.presentation).filter(([e]) => !o.has(e))),
684
+ draggableEntityIds: n.draggableEntityIds.filter((e) => !o.has(e)),
685
+ goals: n.goals.filter((e) => !a.dependentGoalIds.includes(e.id))
686
+ }), {
631
687
  selectedGivenId: null,
632
- pendingFirstPointId: null
688
+ ...(o.has(r ?? "") || o.has(i ?? "")) && j
633
689
  });
634
690
  }
635
- function L(e, t, n) {
636
- if (n[0] === n[1]) return j(e), null;
691
+ function F(e, t, n) {
692
+ if (n[0] === n[1]) return A(e), null;
637
693
  let { exercise: r } = e.getState(), i = {
638
694
  kind: t,
639
695
  parents: n
640
- }, a = O(r.entities, i);
641
- if (a) return e.setState({ constructionNotice: A(a) }), null;
642
- let o = _e(r, t);
643
- return M(e, (e) => I(e, o, i), { constructionNotice: null }), o;
696
+ }, a = D(r.entities, i);
697
+ if (a) return e.setState({ constructionNotice: k(a) }), null;
698
+ let o = Ce(r, t);
699
+ return M(e, (e) => P(e, o, i), { constructionNotice: null }), o;
644
700
  }
645
- function He(e, t, n) {
646
- return L(e, "segment", [t, n]);
701
+ function Ye(e, t, n) {
702
+ return F(e, "segment", [t, n]);
647
703
  }
648
- function Ue(e, t, n) {
649
- return L(e, "line", [t, n]);
704
+ function Xe(e, t, n) {
705
+ return F(e, "line", [t, n]);
650
706
  }
651
- function We(e, t) {
707
+ function Ze(e, t) {
652
708
  e.setState((e) => ({
653
709
  pendingObjectType: t,
654
710
  pendingFirstPointId: null,
711
+ pendingVertexPointId: null,
655
712
  selectedGivenId: null,
656
713
  interactionEpoch: (e.interactionEpoch ?? 0) + 1,
657
714
  constructionNotice: null
658
715
  }));
659
716
  }
660
- function Ge(e) {
661
- e.getState().pendingFirstPointId !== null && e.setState({ pendingFirstPointId: null });
717
+ function Qe(e) {
718
+ e.getState().pendingFirstPointId !== null && e.setState(j);
662
719
  }
663
- function Ke(e, t) {
664
- let { pendingObjectType: n, pendingFirstPointId: r } = e.getState();
665
- if (n !== "segment" && n !== "line") return;
666
- if (!r) {
667
- e.setState({
720
+ function $e(e, t) {
721
+ let { pendingObjectType: n, pendingFirstPointId: r, pendingVertexPointId: i } = e.getState();
722
+ if (n === "segment" || n === "line" || n === "angle") {
723
+ if (!r) e.setState({
668
724
  pendingFirstPointId: t,
669
725
  constructionNotice: null
670
726
  });
671
- return;
672
- }
673
- if (r === t) {
674
- e.setState({
675
- pendingFirstPointId: null,
727
+ else if (t === r || t === i) e.setState({
728
+ ...j,
729
+ constructionNotice: null
730
+ });
731
+ else if (n !== "angle") {
732
+ let i = F(e, n, [r, t]);
733
+ e.setState(i ? {
734
+ ...j,
735
+ selectedGivenId: i
736
+ } : j);
737
+ } else i ? Be(e, {
738
+ tool: n,
739
+ from: {
740
+ kind: "existing",
741
+ id: r
742
+ },
743
+ vertex: {
744
+ kind: "existing",
745
+ id: i
746
+ },
747
+ to: {
748
+ kind: "existing",
749
+ id: t
750
+ }
751
+ }) : e.setState({
752
+ pendingVertexPointId: t,
676
753
  constructionNotice: null
677
754
  });
678
- return;
679
755
  }
680
- let i = L(e, n, [r, t]);
681
- e.setState(i ? {
682
- pendingFirstPointId: null,
683
- selectedGivenId: i
684
- } : { pendingFirstPointId: null });
685
756
  }
686
757
  //#endregion
687
758
  //#region src/store/attemptChange.ts
688
- function R(e, t) {
759
+ function I(e, t) {
689
760
  if (e === t) return !0;
690
761
  if (typeof e != "object" || typeof t != "object" || e === null || t === null || Array.isArray(e) !== Array.isArray(t)) return !1;
691
762
  let n = e, r = t, i = Object.keys(n);
692
- return i.length === Object.keys(r).length && i.every((e) => Object.prototype.hasOwnProperty.call(r, e) && R(n[e], r[e]));
763
+ return i.length === Object.keys(r).length && i.every((e) => Object.prototype.hasOwnProperty.call(r, e) && I(n[e], r[e]));
693
764
  }
694
- function z(e, t) {
765
+ function L(e, t) {
695
766
  let n = new Set(e.answerEntityIds), r = new Set(t.answerEntityIds), i = /* @__PURE__ */ new Set();
696
767
  for (let n of [e, t]) {
697
768
  for (let e of Object.keys(n.entities)) i.add(e);
698
769
  for (let e of Object.keys(n.presentation)) i.add(e);
699
770
  for (let e of n.answerEntityIds) i.add(e);
700
771
  }
701
- return [...i].filter((i) => !R(a(e.entities, i), a(t.entities, i)) || !R(a(e.presentation, i), a(t.presentation, i)) || n.has(i) !== r.has(i));
772
+ return [...i].filter((i) => !I(o(e.entities, i), o(t.entities, i)) || !I(o(e.presentation, i), o(t.presentation, i)) || n.has(i) !== r.has(i));
702
773
  }
703
774
  //#endregion
704
775
  //#region src/store/studentStore.ts
705
- var B = {
776
+ var R = {
706
777
  schemaVersion: 2,
707
778
  entities: {},
708
779
  presentation: {},
709
780
  answerEntityIds: []
710
781
  };
711
- function qe(e, t) {
712
- return T({
782
+ function et(e, t) {
783
+ return C({
713
784
  exercise: d(e),
714
- geometry: t ?? B,
785
+ geometry: t ?? R,
715
786
  pendingObjectType: null,
716
787
  pendingFirstPointId: null,
788
+ pendingVertexPointId: null,
717
789
  selectedObjectId: null,
718
790
  past: [],
719
791
  future: [],
@@ -724,38 +796,38 @@ function qe(e, t) {
724
796
  lastAttemptChange: null
725
797
  });
726
798
  }
727
- function V(e, t) {
728
- let n = a(e.geometry.entities, t) ?? a(e.exercise.entities, t);
799
+ function z(e, t) {
800
+ let n = o(e.geometry.entities, t) ?? o(e.exercise.entities, t);
729
801
  return n?.kind === "point" ? n : void 0;
730
802
  }
731
- function H(e, t) {
803
+ function B(e, t) {
732
804
  return {
733
805
  ...t,
734
806
  sequence: (e.lastAttemptChange?.sequence ?? 0) + 1
735
807
  };
736
808
  }
737
- var U = "move:";
738
- function W(e) {
809
+ var V = "move:";
810
+ function H(e) {
739
811
  let t = e.coalesceTag;
740
- if (!t?.startsWith(U)) return null;
741
- let n = t.slice(5), r = e.past[e.past.length - 1], i = (t) => a(t.entities, n) ?? a(e.exercise.entities, n);
742
- return r && R(i(r), i(e.geometry)) ? {
812
+ if (!t?.startsWith(V)) return null;
813
+ let n = t.slice(5), r = e.past[e.past.length - 1], i = (t) => o(t.entities, n) ?? o(e.exercise.entities, n);
814
+ return r && I(i(r), i(e.geometry)) ? {
743
815
  coalesceTag: null,
744
816
  geometry: r,
745
817
  past: e.past.slice(0, -1)
746
818
  } : {
747
819
  coalesceTag: null,
748
- lastAttemptChange: H(e, {
820
+ lastAttemptChange: B(e, {
749
821
  action: "point-moved",
750
822
  entityIds: [n]
751
823
  })
752
824
  };
753
825
  }
754
- function G(e) {
755
- let t = W(e.getState());
826
+ function U(e) {
827
+ let t = H(e.getState());
756
828
  t && e.setState(t);
757
829
  }
758
- function K(e, t, n = {}) {
830
+ function W(e, t, n = {}) {
759
831
  let r = e.getState().geometry, i = t(r);
760
832
  if (i === r) {
761
833
  e.setState(n.extra ?? {});
@@ -764,17 +836,18 @@ function K(e, t, n = {}) {
764
836
  let a = n.coalesceTag ?? null;
765
837
  e.setState((e) => ({
766
838
  geometry: i,
767
- past: a !== null && a === e.coalesceTag ? e.past : pe(e.past, r),
839
+ past: a !== null && a === e.coalesceTag ? e.past : w(e.past, r),
768
840
  future: [],
769
841
  coalesceTag: a,
770
- ...n.receipt && { lastAttemptChange: H(e, n.receipt(r, i)) },
842
+ ...n.receipt && { lastAttemptChange: B(e, n.receipt(r, i)) },
771
843
  ...n.extra
772
844
  }));
773
845
  }
774
- function q(e) {
846
+ function G(e) {
775
847
  return {
776
848
  pendingObjectType: null,
777
849
  pendingFirstPointId: null,
850
+ pendingVertexPointId: null,
778
851
  selectedObjectId: null,
779
852
  past: [],
780
853
  future: [],
@@ -783,7 +856,7 @@ function q(e) {
783
856
  constructionNotice: null
784
857
  };
785
858
  }
786
- function Je(e, t) {
859
+ function tt(e, t) {
787
860
  if ((e.getState().readOnly ?? !1) !== t) {
788
861
  if (!t) {
789
862
  e.setState((e) => ({
@@ -793,10 +866,11 @@ function Je(e, t) {
793
866
  return;
794
867
  }
795
868
  e.setState((e) => ({
796
- ...W(e),
869
+ ...H(e),
797
870
  readOnly: !0,
798
871
  pendingObjectType: null,
799
872
  pendingFirstPointId: null,
873
+ pendingVertexPointId: null,
800
874
  selectedObjectId: null,
801
875
  coalesceTag: null,
802
876
  interactionEpoch: (e.interactionEpoch ?? 0) + 1,
@@ -804,31 +878,39 @@ function Je(e, t) {
804
878
  }));
805
879
  }
806
880
  }
807
- function Ye(e, t) {
881
+ function nt(e, t) {
808
882
  e.setState((e) => ({
809
- ...q(e),
883
+ ...G(e),
810
884
  geometry: t
811
885
  }));
812
886
  }
813
- function Xe(e, t, n) {
887
+ function rt(e, t, n) {
814
888
  e.setState((e) => ({
815
- ...q(e),
889
+ ...G(e),
816
890
  exercise: d(t),
817
- geometry: n ?? { ...B }
891
+ geometry: n ?? { ...R }
818
892
  }));
819
893
  }
820
- function J(e) {
894
+ function K(e) {
821
895
  return (t) => !Object.prototype.hasOwnProperty.call(e.entities, t);
822
896
  }
823
- function Ze(e) {
824
- e.getState().constructionNotice && e.setState({ constructionNotice: null });
897
+ var q = {
898
+ pendingFirstPointId: null,
899
+ pendingVertexPointId: null
900
+ };
901
+ function it(e) {
902
+ let t = e.getState();
903
+ (t.constructionNotice || t.pendingFirstPointId) && e.setState({
904
+ ...q,
905
+ constructionNotice: null
906
+ });
825
907
  }
826
- function Y(e, t, n) {
908
+ function J(e, t, n) {
827
909
  let r = /* @__PURE__ */ new Set([...Object.keys(e.entities), ...Object.keys(t.entities)]), i = 1;
828
910
  for (; r.has(`${n}-${i}`);) i += 1;
829
911
  return `${n}-${i}`;
830
912
  }
831
- function X(e, t, n, { role: r, countsAsAnswer: i }) {
913
+ function Y(e, t, n, { role: r, countsAsAnswer: i }) {
832
914
  return {
833
915
  ...e,
834
916
  entities: {
@@ -842,78 +924,81 @@ function X(e, t, n, { role: r, countsAsAnswer: i }) {
842
924
  answerEntityIds: i ? [...e.answerEntityIds, t] : e.answerEntityIds
843
925
  };
844
926
  }
845
- function Qe(e, t) {
927
+ function at(e, t) {
846
928
  let { exercise: n, readOnly: r } = e.getState();
847
929
  t && (r || !n.allowedObjects.includes(t)) || e.setState((e) => ({
848
930
  pendingObjectType: t,
849
931
  pendingFirstPointId: null,
932
+ pendingVertexPointId: null,
850
933
  interactionEpoch: (e.interactionEpoch ?? 0) + 1,
851
934
  constructionNotice: null
852
935
  }));
853
936
  }
854
- function $e(e) {
855
- e.getState().pendingFirstPointId !== null && e.setState({ pendingFirstPointId: null });
937
+ function ot(e) {
938
+ e.getState().pendingFirstPointId !== null && e.setState(q);
856
939
  }
857
- function et(e) {
940
+ function st(e) {
858
941
  let { readOnly: t, past: n } = e.getState();
859
- t || n.length === 0 || (G(e), e.setState((e) => {
942
+ t || n.length === 0 || (U(e), e.setState((e) => {
860
943
  let t = e.past[e.past.length - 1];
861
944
  return t ? {
862
945
  geometry: t,
863
946
  past: e.past.slice(0, -1),
864
947
  future: [e.geometry, ...e.future],
865
948
  pendingFirstPointId: null,
949
+ pendingVertexPointId: null,
866
950
  selectedObjectId: null,
867
951
  coalesceTag: null,
868
952
  interactionEpoch: (e.interactionEpoch ?? 0) + 1,
869
953
  constructionNotice: null,
870
- lastAttemptChange: H(e, {
954
+ lastAttemptChange: B(e, {
871
955
  action: "undo",
872
- entityIds: z(e.geometry, t)
956
+ entityIds: L(e.geometry, t)
873
957
  })
874
958
  } : {};
875
959
  }));
876
960
  }
877
- function tt(e) {
961
+ function ct(e) {
878
962
  let { readOnly: t, future: n } = e.getState();
879
- t || n.length === 0 || (G(e), e.setState((e) => {
963
+ t || n.length === 0 || (U(e), e.setState((e) => {
880
964
  let t = e.future[0];
881
965
  return t ? {
882
966
  geometry: t,
883
967
  past: [...e.past, e.geometry],
884
968
  future: e.future.slice(1),
885
969
  pendingFirstPointId: null,
970
+ pendingVertexPointId: null,
886
971
  selectedObjectId: null,
887
972
  coalesceTag: null,
888
973
  interactionEpoch: (e.interactionEpoch ?? 0) + 1,
889
974
  constructionNotice: null,
890
- lastAttemptChange: H(e, {
975
+ lastAttemptChange: B(e, {
891
976
  action: "redo",
892
- entityIds: z(e.geometry, t)
977
+ entityIds: L(e.geometry, t)
893
978
  })
894
979
  } : {};
895
980
  }));
896
981
  }
897
- function nt(e) {
898
- e.getState().readOnly || (G(e), e.setState((e) => {
899
- let t = { ...B };
982
+ function lt(e) {
983
+ e.getState().readOnly || (U(e), e.setState((e) => {
984
+ let t = { ...R };
900
985
  return {
901
- ...q(e),
986
+ ...G(e),
902
987
  geometry: t,
903
- lastAttemptChange: H(e, {
988
+ lastAttemptChange: B(e, {
904
989
  action: "reset",
905
- entityIds: z(e.geometry, t)
990
+ entityIds: L(e.geometry, t)
906
991
  })
907
992
  };
908
993
  }));
909
994
  }
910
- function rt(e, t, n = !0) {
995
+ function ut(e, t, n = !0) {
911
996
  if (e.getState().readOnly) return null;
912
- G(e);
913
- let { exercise: r, geometry: i } = e.getState(), a = O(i.entities, t, J(r));
914
- if (a) return e.setState({ constructionNotice: A(a) }), a;
915
- let o = Y(r, i, "student-point");
916
- return K(e, (e) => X(e, o, t, {
997
+ U(e);
998
+ let { exercise: r, geometry: i } = e.getState(), a = D(i.entities, t, K(r));
999
+ if (a) return e.setState({ constructionNotice: k(a) }), a;
1000
+ let o = J(r, i, "student-point");
1001
+ return W(e, (e) => Y(e, o, t, {
917
1002
  role: "explicit",
918
1003
  countsAsAnswer: n
919
1004
  }), {
@@ -924,11 +1009,11 @@ function rt(e, t, n = !0) {
924
1009
  })
925
1010
  }), o;
926
1011
  }
927
- function it(e, t) {
1012
+ function dt(e, t) {
928
1013
  if (e.getState().readOnly) return;
929
- G(e);
1014
+ U(e);
930
1015
  let n = e.getState();
931
- a(n.geometry.entities, t)?.kind === "point" && n.geometry.presentation[t]?.role === "implicit" && K(e, (e) => ({
1016
+ o(n.geometry.entities, t)?.kind === "point" && n.geometry.presentation[t]?.role === "implicit" && W(e, (e) => ({
932
1017
  ...e,
933
1018
  presentation: {
934
1019
  ...e.presentation,
@@ -942,11 +1027,11 @@ function it(e, t) {
942
1027
  entityIds: [t]
943
1028
  }) });
944
1029
  }
945
- function at(e, t, n) {
1030
+ function ft(e, t, n) {
946
1031
  if (e.getState().readOnly) return;
947
- e.getState().coalesceTag !== `${U}${t}` && G(e);
948
- let r = e.getState(), i = V(r, t);
949
- if (!i || "intersectionOf" in i || !Z(r, t)) return;
1032
+ e.getState().coalesceTag !== `${V}${t}` && U(e);
1033
+ let r = e.getState(), i = z(r, t);
1034
+ if (!i || "intersectionOf" in i || !X(r, t)) return;
950
1035
  let a = {
951
1036
  kind: "point",
952
1037
  at: {
@@ -955,9 +1040,9 @@ function at(e, t, n) {
955
1040
  }
956
1041
  };
957
1042
  if ("on" in i) {
958
- let e = h(r.exercise, r.geometry).resolvedOf(i.on);
1043
+ let e = _(r.exercise, r.geometry).resolvedOf(i.on);
959
1044
  if (!e) return;
960
- let t = p(e, n);
1045
+ let t = l(e, n);
961
1046
  if (t === null) return;
962
1047
  a = {
963
1048
  kind: "point",
@@ -965,127 +1050,153 @@ function at(e, t, n) {
965
1050
  t
966
1051
  };
967
1052
  }
968
- R(a, i) || K(e, (e) => ({
1053
+ I(a, i) || W(e, (e) => ({
969
1054
  ...e,
970
1055
  entities: {
971
1056
  ...e.entities,
972
1057
  [t]: a
973
1058
  }
974
- }), { coalesceTag: `${U}${t}` });
1059
+ }), { coalesceTag: `${V}${t}` });
975
1060
  }
976
- function Z(e, t) {
977
- if (e.readOnly) return !1;
978
- let n = V(e, t);
979
- return !n || "intersectionOf" in n ? !1 : !Object.prototype.hasOwnProperty.call(e.exercise.entities, t) || e.exercise.draggableEntityIds.includes(t);
1061
+ function X(t, n) {
1062
+ if (t.readOnly) return !1;
1063
+ if (Object.prototype.hasOwnProperty.call(t.exercise.entities, n)) return e(t.exercise, n);
1064
+ let r = z(t, n);
1065
+ return r !== void 0 && !("intersectionOf" in r);
980
1066
  }
981
- function ot(e) {
1067
+ function pt(e) {
982
1068
  let t = e.getState();
983
- t.coalesceTag !== null && e.setState(W(t) ?? { coalesceTag: null });
1069
+ t.coalesceTag !== null && e.setState(H(t) ?? { coalesceTag: null });
984
1070
  }
985
- function st(e, t, n, r) {
1071
+ function mt(e, t, n, r) {
986
1072
  if (n.kind === "existing") return [t, n.id];
987
1073
  if (r) return [t, r];
988
- let i = Y(e, t, "student-point");
989
- return [X(t, i, n.origin, {
1074
+ let i = J(e, t, "student-point");
1075
+ return [Y(t, i, n.origin, {
990
1076
  role: "implicit",
991
1077
  countsAsAnswer: !1
992
1078
  }), i];
993
1079
  }
994
- function ct(e, t) {
1080
+ function Z(e, t) {
995
1081
  if (e.getState().readOnly) return;
996
- G(e);
997
- let n = e.getState();
998
- if (!n.exercise.allowedObjects.includes(t.tool) || t.from.kind === "existing" && t.to.kind === "existing" && t.from.id === t.to.id) {
999
- Ze(e);
1082
+ U(e);
1083
+ let n = e.getState(), r = T(t).flatMap((e) => e.kind === "existing" ? [e.id] : []);
1084
+ if (!n.exercise.allowedObjects.includes(t.tool) || r.some((e) => !z(n, e))) {
1085
+ it(e);
1000
1086
  return;
1001
1087
  }
1002
- for (let r of [t.from, t.to]) if (r.kind === "existing" && !V(n, r.id)) {
1003
- Ze(e);
1088
+ let i = ht(n.exercise, n.geometry, t);
1089
+ if (!i) {
1090
+ it(e);
1004
1091
  return;
1005
1092
  }
1006
- let [r = null, i = null] = k([t.from, t.to], n.exercise.entities, n.geometry.entities), [a, o] = st(n.exercise, n.geometry, t.from, r), [s, c] = st(n.exercise, a, t.to, i), l = {
1007
- kind: t.tool,
1008
- parents: [o, c]
1009
- }, u = s === n.geometry ? O(n.geometry.entities, l, J(n.exercise)) : null;
1010
- if (u) {
1093
+ if ("duplicateId" in i) {
1011
1094
  e.setState({
1012
- pendingFirstPointId: null,
1013
- constructionNotice: A(u)
1095
+ ...q,
1096
+ constructionNotice: k(i.duplicateId)
1014
1097
  });
1015
1098
  return;
1016
1099
  }
1017
- let d = Y(n.exercise, s, `student-${t.tool}`), p = X(s, d, l, {
1018
- role: "explicit",
1019
- countsAsAnswer: !0
1020
- }), m = h(n.exercise, p), g = m.points.get(o), _ = m.points.get(c), v = g && _ && !f(g, _), y = [...a === n.geometry ? [] : [o], ...s === a ? [] : [c]];
1021
- K(e, (e) => v ? p : e, {
1100
+ W(e, () => i.geometry, {
1022
1101
  extra: {
1023
- pendingFirstPointId: null,
1102
+ ...q,
1024
1103
  constructionNotice: null
1025
1104
  },
1026
1105
  receipt: () => ({
1027
- action: t.tool === "segment" ? "segment-created" : "line-created",
1028
- entityIds: [d, ...y]
1106
+ action: `${t.tool}-created`,
1107
+ entityIds: [i.objectId, ...i.inventedIds]
1029
1108
  })
1030
1109
  });
1031
1110
  }
1032
- function lt(e, t) {
1111
+ function ht(e, t, n) {
1112
+ let r = T(n), i = ye(r, e.entities, t.entities);
1113
+ if (O(r, i)) return null;
1114
+ let a = t, o = [], s = [];
1115
+ r.forEach((t, n) => {
1116
+ let r = a, [c, l] = mt(e, r, t, i[n] ?? null);
1117
+ a = c, o.push(l), c !== r && s.push(l);
1118
+ });
1119
+ let c = {
1120
+ kind: n.tool,
1121
+ parents: o
1122
+ }, l = a === t ? D(t.entities, c, K(e)) : null;
1123
+ if (l) return { duplicateId: l };
1124
+ let u = J(e, a, `student-${n.tool}`), d = Y(a, u, c, {
1125
+ role: "explicit",
1126
+ countsAsAnswer: !0
1127
+ }), f = _(e, d), p = o.map((e) => f.points.get(e)), h = p[1];
1128
+ return {
1129
+ geometry: h && p.every((e, t) => e && (t === 1 || !m(e, h))) ? d : t,
1130
+ objectId: u,
1131
+ inventedIds: s
1132
+ };
1133
+ }
1134
+ function gt(e, t) {
1033
1135
  let n = e.getState();
1034
1136
  if (n.readOnly) return;
1035
1137
  let r = n.pendingObjectType;
1036
- if (r === "segment" || r === "line") {
1037
- if (!n.pendingFirstPointId) {
1038
- e.setState({
1039
- pendingFirstPointId: t,
1040
- constructionNotice: null
1041
- });
1042
- return;
1138
+ if (r !== "segment" && r !== "line" && r !== "angle") return;
1139
+ let i = n.pendingFirstPointId, a = n.pendingVertexPointId;
1140
+ i ? t === i || t === a ? e.setState({
1141
+ ...q,
1142
+ constructionNotice: null
1143
+ }) : r === "angle" ? a ? Z(e, {
1144
+ tool: r,
1145
+ from: {
1146
+ kind: "existing",
1147
+ id: i
1148
+ },
1149
+ vertex: {
1150
+ kind: "existing",
1151
+ id: a
1152
+ },
1153
+ to: {
1154
+ kind: "existing",
1155
+ id: t
1043
1156
  }
1044
- if (n.pendingFirstPointId === t) {
1045
- e.setState({
1046
- pendingFirstPointId: null,
1047
- constructionNotice: null
1048
- });
1049
- return;
1157
+ }) : e.setState({
1158
+ pendingVertexPointId: t,
1159
+ constructionNotice: null
1160
+ }) : Z(e, {
1161
+ tool: r,
1162
+ from: {
1163
+ kind: "existing",
1164
+ id: i
1165
+ },
1166
+ to: {
1167
+ kind: "existing",
1168
+ id: t
1050
1169
  }
1051
- ct(e, {
1052
- tool: r,
1053
- from: {
1054
- kind: "existing",
1055
- id: n.pendingFirstPointId
1056
- },
1057
- to: {
1058
- kind: "existing",
1059
- id: t
1060
- }
1061
- });
1062
- }
1170
+ }) : e.setState({
1171
+ pendingFirstPointId: t,
1172
+ constructionNotice: null
1173
+ });
1063
1174
  }
1064
- function ut(e, t) {
1175
+ function _t(e, t) {
1065
1176
  e.setState({ selectedObjectId: t });
1066
1177
  }
1067
1178
  function Q(e, t) {
1068
1179
  return Object.prototype.hasOwnProperty.call(e.geometry.entities, t) ? !Object.prototype.hasOwnProperty.call(e.exercise.entities, t) : !1;
1069
1180
  }
1070
- function dt(e, t) {
1181
+ function vt(e, t) {
1071
1182
  if (!Q(e, t)) return {
1072
1183
  constructionIds: [],
1073
1184
  pointIds: []
1074
1185
  };
1075
- let n = new Set(h(e.exercise, e.geometry).removalClosureOf(t)), r = [], i = [];
1186
+ let n = new Set(_(e.exercise, e.geometry).removalClosureOf(t)), r = [], i = [];
1076
1187
  for (let [t, a] of Object.entries(e.geometry.entities)) n.has(t) && (a.kind === "point" ? i.push(t) : r.push(t));
1077
1188
  return {
1078
1189
  constructionIds: r,
1079
1190
  pointIds: i
1080
1191
  };
1081
1192
  }
1082
- function ft(e, t) {
1193
+ function yt(e, t) {
1083
1194
  if (e.getState().readOnly) return;
1084
- G(e);
1195
+ U(e);
1085
1196
  let n = e.getState();
1086
1197
  if (!Q(n, t)) return;
1087
- let r = dt(n, t), i = /* @__PURE__ */ new Set([...r.constructionIds, ...r.pointIds.filter((e) => Q(n, e))]), a = (e) => Object.fromEntries(Object.entries(e).filter(([e]) => !i.has(e)));
1088
- K(e, (e) => ({
1198
+ let r = vt(n, t), i = /* @__PURE__ */ new Set([...r.constructionIds, ...r.pointIds.filter((e) => Q(n, e))]), a = (e) => Object.fromEntries(Object.entries(e).filter(([e]) => !i.has(e)));
1199
+ W(e, (e) => ({
1089
1200
  schemaVersion: e.schemaVersion,
1090
1201
  entities: a(e.entities),
1091
1202
  presentation: a(e.presentation),
@@ -1093,7 +1204,7 @@ function ft(e, t) {
1093
1204
  }), {
1094
1205
  extra: {
1095
1206
  selectedObjectId: null,
1096
- pendingFirstPointId: n.pendingFirstPointId && i.has(n.pendingFirstPointId) ? null : n.pendingFirstPointId
1207
+ ...(i.has(n.pendingFirstPointId ?? "") || i.has(n.pendingVertexPointId ?? "")) && q
1097
1208
  },
1098
1209
  receipt: (e) => ({
1099
1210
  action: "deleted",
@@ -1102,15 +1213,15 @@ function ft(e, t) {
1102
1213
  });
1103
1214
  }
1104
1215
  function $(e, t) {
1105
- for (let [n, r] of e) if (f(r, t)) return n;
1216
+ for (let [n, r] of e) if (m(r, t)) return n;
1106
1217
  return null;
1107
1218
  }
1108
- function pt(e, t, n, r) {
1219
+ function bt(e, t, n, r) {
1109
1220
  let i = $(n, r);
1110
1221
  return i && Object.prototype.hasOwnProperty.call(t.entities, i) && !Object.prototype.hasOwnProperty.call(e.entities, i) ? t.answerEntityIds.includes(i) ? [t, i] : [{
1111
1222
  ...t,
1112
1223
  answerEntityIds: [...t.answerEntityIds, i]
1113
- }, i] : [X(t, Y(e, t, "student-point"), {
1224
+ }, i] : [Y(t, J(e, t, "student-point"), {
1114
1225
  kind: "point",
1115
1226
  at: r
1116
1227
  }, {
@@ -1118,45 +1229,66 @@ function pt(e, t, n, r) {
1118
1229
  countsAsAnswer: !0
1119
1230
  }), null];
1120
1231
  }
1121
- var mt = {
1232
+ var xt = {
1122
1233
  role: "explicit",
1123
1234
  countsAsAnswer: !1
1124
1235
  };
1125
- function ht(e, t) {
1236
+ function St(e, t) {
1126
1237
  if (e.getState().readOnly) return;
1127
- G(e);
1128
- let { exercise: n, geometry: r } = e.getState(), [i, a] = gt(n, r, t);
1129
- K(e, () => i, {
1130
- extra: { constructionNotice: a ? A(a) : null },
1238
+ U(e);
1239
+ let { exercise: n, geometry: r } = e.getState(), [i, a] = Ct(n, r, t);
1240
+ W(e, () => i, {
1241
+ extra: { constructionNotice: a ? k(a) : null },
1131
1242
  receipt: (e, t) => ({
1132
1243
  action: "revealed",
1133
- entityIds: z(e, t)
1244
+ entityIds: L(e, t)
1134
1245
  })
1135
1246
  });
1136
1247
  }
1137
- function gt(e, t, n) {
1138
- let r = new Map(_(e, t));
1139
- if (n.type === "point") return pt(e, t, r, n.at);
1248
+ function Ct(e, t, n) {
1249
+ let r = new Map(g(e, t));
1250
+ if (n.type === "point") return bt(e, t, r, n.at);
1251
+ if (n.type === "angle") {
1252
+ let i = (e) => {
1253
+ let t = $(r, e);
1254
+ return t ? {
1255
+ kind: "existing",
1256
+ id: t
1257
+ } : {
1258
+ kind: "create",
1259
+ origin: {
1260
+ kind: "point",
1261
+ at: e
1262
+ }
1263
+ };
1264
+ }, a = ht(e, t, {
1265
+ tool: "angle",
1266
+ from: i(n.arms[0]),
1267
+ vertex: i(n.vertex),
1268
+ to: i(n.arms[1])
1269
+ });
1270
+ return a ? "duplicateId" in a ? [t, a.duplicateId] : [a.geometry, null] : [t, null];
1271
+ }
1140
1272
  let [i, a] = n.type === "segment" ? [n.from, n.to] : n.through, o = t, s = $(r, i);
1141
- s || (s = Y(e, o, "student-point"), o = X(o, s, {
1273
+ s || (s = J(e, o, "student-point"), o = Y(o, s, {
1142
1274
  kind: "point",
1143
1275
  at: i
1144
- }, mt), r.set(s, i));
1276
+ }, xt), r.set(s, i));
1145
1277
  let c = $(r, a);
1146
- if (c || (c = Y(e, o, "student-point"), o = X(o, c, {
1278
+ if (c || (c = J(e, o, "student-point"), o = Y(o, c, {
1147
1279
  kind: "point",
1148
1280
  at: a
1149
- }, mt), r.set(c, a)), s === c) return [t, null];
1281
+ }, xt), r.set(c, a)), s === c) return [t, null];
1150
1282
  let l = {
1151
1283
  kind: n.type,
1152
1284
  parents: [s, c]
1153
- }, u = O(o.entities, l, J(e));
1154
- return u ? [t, u] : [X(o, Y(e, o, `student-${n.type}`), l, {
1285
+ }, u = D(o.entities, l, K(e));
1286
+ return u ? [t, u] : [Y(o, J(e, o, `student-${n.type}`), l, {
1155
1287
  role: "explicit",
1156
1288
  countsAsAnswer: !0
1157
1289
  }), null];
1158
1290
  }
1159
1291
  //#endregion
1160
- export { fe as $, Be as A, Oe as B, Ae as C, ge as D, Ge as E, je as F, ze as G, We as H, Me as I, Te as J, Re as K, be as L, ve as M, Fe as N, Le as O, Ke as P, w as Q, Ve as R, Ue as S, De as T, we as U, xe as V, Ee as W, ye as X, Se as Y, T as Z, ht as _, ot as a, b as at, Je as b, Q as c, te as ct, lt as d, de as et, it as f, nt as g, Xe as h, ft as i, re as it, Ie as j, Pe as k, Z as l, y as lt, Ye as m, $e as n, ie as nt, ct as o, ee as ot, tt as p, Ce as q, qe as r, C as rt, dt as s, ne as st, rt as t, x as tt, at as u, v as ut, ut as v, He as w, et as x, Qe as y, ke as z };
1292
+ export { pe as $, qe as A, Pe as B, Ie as C, be as D, Qe as E, Le as F, Ge as G, Ze as H, Re as I, ke as J, Ke as K, Ee as L, we as M, Ve as N, Ue as O, $e as P, C as Q, Je as R, Xe as S, Ne as T, Ae as U, De as V, Me as W, Oe as X, je as Y, Te as Z, St as _, pt as a, ae as at, tt as b, Q as c, ie as ct, gt as d, v as dt, he as et, dt as f, lt as g, rt as h, yt as i, oe as it, He as j, Be as k, X as l, re as lt, nt as m, ot as n, b as nt, Z as o, y as ot, ct as p, We as q, et as r, x as rt, vt as s, ne as st, ut as t, me as tt, ft as u, te as ut, _t as v, Ye as w, st as x, at as y, Fe as z };
1161
1293
 
1162
- //# sourceMappingURL=studentStore-CEKTtMCh.js.map
1294
+ //# sourceMappingURL=studentStore-CyYa0N93.js.map