@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.
- package/README.md +24 -7
- package/dist/core.cjs +1 -1
- package/dist/core.mjs +4 -4
- package/dist/entries/core.d.cts +1 -1
- package/dist/entries/core.d.ts +1 -1
- package/dist/entries/core.d.ts.map +1 -1
- package/dist/exercise.schema-Bma3qN9P.js +251 -0
- package/dist/exercise.schema-Bma3qN9P.js.map +1 -0
- package/dist/exercise.schema-Oj5ZH-yO.cjs +2 -0
- package/dist/exercise.schema-Oj5ZH-yO.cjs.map +1 -0
- package/dist/exerciseLoad-Db9Cigxi.cjs +2 -0
- package/dist/exerciseLoad-Db9Cigxi.cjs.map +1 -0
- package/dist/{geometryAttemptStatus-5L_q6-9l.js → exerciseLoad-DgeDXYbf.js} +84 -71
- package/dist/exerciseLoad-DgeDXYbf.js.map +1 -0
- package/dist/geometry/entities/angle.d.cts +56 -0
- package/dist/geometry/entities/angle.d.ts +57 -0
- package/dist/geometry/entities/angle.d.ts.map +1 -0
- package/dist/geometry/entities/circle.d.ts.map +1 -1
- package/dist/geometry/entities/index.d.cts +8 -4
- package/dist/geometry/entities/index.d.ts +8 -4
- package/dist/geometry/entities/index.d.ts.map +1 -1
- package/dist/geometry/entities/line.d.ts.map +1 -1
- package/dist/geometry/entities/point.d.ts.map +1 -1
- package/dist/geometry/entities/relations.d.cts +8 -1
- package/dist/geometry/entities/relations.d.ts +8 -1
- package/dist/geometry/entities/relations.d.ts.map +1 -1
- package/dist/geometry/entities/segment.d.ts.map +1 -1
- package/dist/geometry/entityModel.d.cts +21 -3
- package/dist/geometry/entityModel.d.ts +21 -3
- package/dist/geometry/entityModel.d.ts.map +1 -1
- package/dist/geometryState.schema-B5ccMKDa.cjs +2 -0
- package/dist/geometryState.schema-B5ccMKDa.cjs.map +1 -0
- package/dist/geometryState.schema-CKFPlX8j.js +1177 -0
- package/dist/geometryState.schema-CKFPlX8j.js.map +1 -0
- package/dist/goals-BlSeniyt.js +563 -0
- package/dist/goals-BlSeniyt.js.map +1 -0
- package/dist/goals-DLbmBZD8.cjs +2 -0
- package/dist/goals-DLbmBZD8.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +8 -8
- package/dist/measure/angleType.d.cts +2 -0
- package/dist/measure/angleType.d.ts +3 -0
- package/dist/measure/angleType.d.ts.map +1 -0
- package/dist/measure/geometryAdapter.d.cts +3 -0
- package/dist/measure/geometryAdapter.d.ts +3 -0
- package/dist/measure/geometryAdapter.d.ts.map +1 -1
- package/dist/react-B26_e52I.cjs +2 -0
- package/dist/react-B26_e52I.cjs.map +1 -0
- package/dist/{react-BEcdx1f6.js → react-B5cGaxH8.js} +738 -513
- package/dist/react-B5cGaxH8.js.map +1 -0
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/renderer/GeometryCanvas.d.ts.map +1 -1
- package/dist/renderer/StudentGeometryCanvas.d.ts.map +1 -1
- package/dist/renderer/Toolbar.d.ts.map +1 -1
- package/dist/renderer/angleMeasure.d.cts +14 -0
- package/dist/renderer/angleMeasure.d.ts +15 -0
- package/dist/renderer/angleMeasure.d.ts.map +1 -0
- package/dist/renderer/deriveRenderableGeometry.d.cts +1 -0
- package/dist/renderer/deriveRenderableGeometry.d.ts +1 -0
- package/dist/renderer/deriveRenderableGeometry.d.ts.map +1 -1
- package/dist/renderer/deriveSemanticScene.d.ts.map +1 -1
- package/dist/renderer/dragSnap.d.cts +14 -0
- package/dist/renderer/dragSnap.d.ts +15 -0
- package/dist/renderer/dragSnap.d.ts.map +1 -0
- package/dist/renderer/shapes/AngleShape.d.cts +19 -0
- package/dist/renderer/shapes/AngleShape.d.ts +20 -0
- package/dist/renderer/shapes/AngleShape.d.ts.map +1 -0
- package/dist/renderer/shapes/EntityLabel.d.cts +9 -1
- package/dist/renderer/shapes/EntityLabel.d.ts +9 -1
- package/dist/renderer/shapes/EntityLabel.d.ts.map +1 -1
- package/dist/renderer/shapes/EntityShape.d.cts +2 -1
- package/dist/renderer/shapes/EntityShape.d.ts +2 -1
- package/dist/renderer/shapes/EntityShape.d.ts.map +1 -1
- package/dist/renderer/useConnectionPreview.d.cts +12 -1
- package/dist/renderer/useConnectionPreview.d.ts +12 -1
- package/dist/renderer/useConnectionPreview.d.ts.map +1 -1
- package/dist/renderer/usePointerGestures.d.cts +1 -1
- package/dist/renderer/usePointerGestures.d.ts +1 -1
- package/dist/renderer/usePointerGestures.d.ts.map +1 -1
- package/dist/schemas/entityDefinition.schema.d.cts +7 -0
- package/dist/schemas/entityDefinition.schema.d.ts +7 -0
- package/dist/schemas/entityDefinition.schema.d.ts.map +1 -1
- package/dist/schemas/entityDocument.d.cts +34 -13
- package/dist/schemas/entityDocument.d.ts +34 -13
- package/dist/schemas/entityDocument.d.ts.map +1 -1
- package/dist/schemas/entityPresentation.schema.d.cts +3 -0
- package/dist/schemas/entityPresentation.schema.d.ts +3 -0
- package/dist/schemas/entityPresentation.schema.d.ts.map +1 -1
- package/dist/schemas/exercise.schema.d.cts +80 -2
- package/dist/schemas/exercise.schema.d.ts +80 -2
- package/dist/schemas/exercise.schema.d.ts.map +1 -1
- package/dist/schemas/exerciseV2.schema.d.cts +57 -0
- package/dist/schemas/exerciseV2.schema.d.ts +57 -0
- package/dist/schemas/exerciseV2.schema.d.ts.map +1 -1
- package/dist/schemas/exerciseV4.schema.d.cts +168 -0
- package/dist/schemas/exerciseV4.schema.d.ts +169 -0
- package/dist/schemas/exerciseV4.schema.d.ts.map +1 -0
- package/dist/schemas/geometryState.schema.d.cts +8 -0
- package/dist/schemas/geometryState.schema.d.ts +8 -0
- package/dist/schemas/geometryState.schema.d.ts.map +1 -1
- package/dist/schemas/goals/angleBisectorGoal.schema.d.cts +15 -0
- package/dist/schemas/goals/angleBisectorGoal.schema.d.ts +16 -0
- package/dist/schemas/goals/angleBisectorGoal.schema.d.ts.map +1 -0
- package/dist/schemas/goals/angleCriterion.schema.d.cts +28 -0
- package/dist/schemas/goals/angleCriterion.schema.d.ts +29 -0
- package/dist/schemas/goals/angleCriterion.schema.d.ts.map +1 -0
- package/dist/schemas/goals/angleMeasureGoal.schema.d.cts +26 -0
- package/dist/schemas/goals/angleMeasureGoal.schema.d.ts +27 -0
- package/dist/schemas/goals/angleMeasureGoal.schema.d.ts.map +1 -0
- package/dist/schemas/goals/createGoal.schema.d.cts +1 -0
- package/dist/schemas/goals/createGoal.schema.d.ts +1 -0
- package/dist/schemas/goals/createGoal.schema.d.ts.map +1 -1
- package/dist/schemas/goals/geometryGoal.schema.d.cts +61 -0
- package/dist/schemas/goals/geometryGoal.schema.d.ts +61 -0
- package/dist/schemas/goals/geometryGoal.schema.d.ts.map +1 -1
- package/dist/schemas/goals/givenAngleGoal.schema.d.cts +35 -0
- package/dist/schemas/goals/givenAngleGoal.schema.d.ts +36 -0
- package/dist/schemas/goals/givenAngleGoal.schema.d.ts.map +1 -0
- package/dist/schemas/goals/goalKindDeclaration.d.cts +7 -0
- package/dist/schemas/goals/goalKindDeclaration.d.ts +7 -0
- package/dist/schemas/goals/goalKindDeclaration.d.ts.map +1 -1
- package/dist/schemas/goals/parallelGoal.schema.d.cts +1 -0
- package/dist/schemas/goals/parallelGoal.schema.d.ts +1 -0
- package/dist/schemas/goals/parallelGoal.schema.d.ts.map +1 -1
- package/dist/schemas/goals/perpendicularGoal.schema.d.cts +1 -0
- package/dist/schemas/goals/perpendicularGoal.schema.d.ts +1 -0
- package/dist/schemas/goals/perpendicularGoal.schema.d.ts.map +1 -1
- package/dist/schemas/goals/throughPointsGoal.schema.d.cts +1 -0
- package/dist/schemas/goals/throughPointsGoal.schema.d.ts +1 -0
- package/dist/schemas/goals/throughPointsGoal.schema.d.ts.map +1 -1
- package/dist/schemas/objectTypeName.schema.d.cts +1 -0
- package/dist/schemas/objectTypeName.schema.d.ts +1 -0
- package/dist/schemas/objectTypeName.schema.d.ts.map +1 -1
- package/dist/schemas/v2ToV3.d.cts +15 -1
- package/dist/schemas/v2ToV3.d.ts +15 -1
- package/dist/schemas/v2ToV3.d.ts.map +1 -1
- package/dist/schemas/v3ToV4.d.cts +2 -1
- package/dist/schemas/v3ToV4.d.ts +2 -1
- package/dist/schemas/v3ToV4.d.ts.map +1 -1
- package/dist/schemas/v4ToV5.d.cts +7 -0
- package/dist/schemas/v4ToV5.d.ts +8 -0
- package/dist/schemas/v4ToV5.d.ts.map +1 -0
- package/dist/schemas.cjs +1 -1
- package/dist/schemas.mjs +3 -3
- package/dist/snapping/computeDragSnap.d.cts +30 -0
- package/dist/snapping/computeDragSnap.d.ts +31 -0
- package/dist/snapping/computeDragSnap.d.ts.map +1 -0
- package/dist/state/geometryContext.d.ts.map +1 -1
- package/dist/store/attemptChange.d.cts +1 -1
- package/dist/store/attemptChange.d.ts +1 -1
- package/dist/store/attemptChange.d.ts.map +1 -1
- package/dist/store/constructionCommand.d.cts +14 -2
- package/dist/store/constructionCommand.d.ts +14 -2
- package/dist/store/constructionCommand.d.ts.map +1 -1
- package/dist/store/constructionIdentity.d.cts +9 -0
- package/dist/store/constructionIdentity.d.ts +9 -0
- package/dist/store/constructionIdentity.d.ts.map +1 -1
- package/dist/store/studentStore.d.cts +7 -0
- package/dist/store/studentStore.d.ts +7 -0
- package/dist/store/studentStore.d.ts.map +1 -1
- package/dist/store/teacherStore.d.cts +16 -0
- package/dist/store/teacherStore.d.ts +16 -0
- package/dist/store/teacherStore.d.ts.map +1 -1
- package/dist/{studentStore-CEKTtMCh.js → studentStore-CyYa0N93.js} +502 -370
- package/dist/studentStore-CyYa0N93.js.map +1 -0
- package/dist/studentStore-ubldy4PJ.cjs +2 -0
- package/dist/studentStore-ubldy4PJ.cjs.map +1 -0
- package/dist/validation/getGeometryExerciseWarnings.d.cts +3 -2
- package/dist/validation/getGeometryExerciseWarnings.d.ts +3 -2
- package/dist/validation/getGeometryExerciseWarnings.d.ts.map +1 -1
- package/dist/validation/goals/angleBisector.d.cts +3 -0
- package/dist/validation/goals/angleBisector.d.ts +4 -0
- package/dist/validation/goals/angleBisector.d.ts.map +1 -0
- package/dist/validation/goals/angleCriterion.d.cts +12 -0
- package/dist/validation/goals/angleCriterion.d.ts +13 -0
- package/dist/validation/goals/angleCriterion.d.ts.map +1 -0
- package/dist/validation/goals/angleMeasure.d.cts +9 -0
- package/dist/validation/goals/angleMeasure.d.ts +10 -0
- package/dist/validation/goals/angleMeasure.d.ts.map +1 -0
- package/dist/validation/goals/create.d.cts +2 -2
- package/dist/validation/goals/create.d.ts +2 -2
- package/dist/validation/goals/create.d.ts.map +1 -1
- package/dist/validation/goals/givenAngle.d.cts +11 -0
- package/dist/validation/goals/givenAngle.d.ts +12 -0
- package/dist/validation/goals/givenAngle.d.ts.map +1 -0
- package/dist/validation/goals/goalKindHandler.d.cts +38 -1
- package/dist/validation/goals/goalKindHandler.d.ts +38 -1
- package/dist/validation/goals/goalKindHandler.d.ts.map +1 -1
- package/dist/validation/goals/index.d.cts +9 -2
- package/dist/validation/goals/index.d.ts +9 -2
- package/dist/validation/goals/index.d.ts.map +1 -1
- package/dist/validation/goals/midpoint.d.cts +2 -2
- package/dist/validation/goals/midpoint.d.ts +2 -2
- package/dist/validation/goals/midpoint.d.ts.map +1 -1
- package/dist/validation/goals/parallel.d.cts +2 -2
- package/dist/validation/goals/parallel.d.ts +2 -2
- package/dist/validation/goals/parallel.d.ts.map +1 -1
- package/dist/validation/goals/perpendicular.d.cts +2 -2
- package/dist/validation/goals/perpendicular.d.ts +2 -2
- package/dist/validation/goals/perpendicular.d.ts.map +1 -1
- package/dist/validation/goals/segmentLength.d.cts +2 -2
- package/dist/validation/goals/segmentLength.d.ts +2 -2
- package/dist/validation/goals/segmentLength.d.ts.map +1 -1
- package/dist/validation/goals/throughPoints.d.cts +2 -2
- package/dist/validation/goals/throughPoints.d.ts +2 -2
- package/dist/validation/goals/throughPoints.d.ts.map +1 -1
- package/dist/validation/types.d.cts +5 -1
- package/dist/validation/types.d.ts +5 -1
- package/dist/validation/types.d.ts.map +1 -1
- package/dist/validation/validateGeometryState.d.ts.map +1 -1
- package/dist/validation/validateGeometryStateInput.d.ts.map +1 -1
- package/dist/validation.cjs +1 -1
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.mjs +106 -85
- package/dist/validation.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/exercise.schema-BV2b7rtN.cjs +0 -2
- package/dist/exercise.schema-BV2b7rtN.cjs.map +0 -1
- package/dist/exercise.schema-ckVBW9XA.js +0 -212
- package/dist/exercise.schema-ckVBW9XA.js.map +0 -1
- package/dist/geometryAttemptStatus-5L_q6-9l.js.map +0 -1
- package/dist/geometryAttemptStatus-N_XHIkiS.cjs +0 -2
- package/dist/geometryAttemptStatus-N_XHIkiS.cjs.map +0 -1
- package/dist/geometryState.schema-D0ixyGYE.js +0 -955
- package/dist/geometryState.schema-D0ixyGYE.js.map +0 -1
- package/dist/geometryState.schema-DKQ-durx.cjs +0 -2
- package/dist/geometryState.schema-DKQ-durx.cjs.map +0 -1
- package/dist/goals-C3ZwbEh_.js +0 -451
- package/dist/goals-C3ZwbEh_.js.map +0 -1
- package/dist/goals-CxR5qPDC.cjs +0 -2
- package/dist/goals-CxR5qPDC.cjs.map +0 -1
- package/dist/react-BEcdx1f6.js.map +0 -1
- package/dist/react-Pp_VSk--.cjs +0 -2
- package/dist/react-Pp_VSk--.cjs.map +0 -1
- package/dist/studentStore-CEKTtMCh.js.map +0 -1
- package/dist/studentStore-DLftfFAl.cjs +0 -2
- package/dist/studentStore-DLftfFAl.cjs.map +0 -1
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { A as e, B as t,
|
|
2
|
-
import {
|
|
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(
|
|
5
|
-
let o = new Set(a.exclude ?? []),
|
|
6
|
-
if (!
|
|
7
|
-
if (o.has(
|
|
8
|
-
let r =
|
|
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:
|
|
11
|
-
},
|
|
12
|
-
r <= i &&
|
|
13
|
-
id:
|
|
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:
|
|
19
|
-
if (o.has(
|
|
20
|
-
let d =
|
|
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 =
|
|
23
|
-
f <= i &&
|
|
24
|
-
id:
|
|
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
|
|
29
|
+
return l.sort((e, t) => n(e.type) - n(t.type) || e.distance - t.distance);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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
|
|
61
|
-
return
|
|
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
|
|
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
|
|
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
|
|
97
|
+
function x(e) {
|
|
98
98
|
let [t, n, r, i] = e;
|
|
99
99
|
return {
|
|
100
|
-
x:
|
|
101
|
-
y:
|
|
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
|
|
109
|
-
let [n, r, i, a] = t, o =
|
|
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
|
|
117
|
+
var se = [
|
|
118
118
|
"point",
|
|
119
119
|
"intersection",
|
|
120
120
|
"grid",
|
|
121
121
|
"onObject"
|
|
122
122
|
];
|
|
123
|
-
function
|
|
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
|
|
139
|
-
let
|
|
140
|
-
for (let { id: e, definition: r } of
|
|
141
|
-
if (
|
|
142
|
-
let
|
|
143
|
-
c &&
|
|
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 <
|
|
150
|
-
let n =
|
|
151
|
-
for (let
|
|
152
|
-
let t =
|
|
153
|
-
for (let
|
|
154
|
-
let
|
|
155
|
-
|
|
156
|
-
position:
|
|
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:
|
|
159
|
+
distance: i
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
return c;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function ue(e, t, n) {
|
|
167
167
|
if (!t.showGrid) return null;
|
|
168
|
-
let 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
|
|
177
|
-
let
|
|
178
|
-
exclude:
|
|
179
|
-
types:
|
|
180
|
-
accepts:
|
|
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
|
|
184
|
-
if (!
|
|
185
|
-
let
|
|
186
|
-
if (
|
|
187
|
-
let
|
|
188
|
-
|
|
189
|
-
|
|
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: [
|
|
194
|
-
parameter:
|
|
195
|
-
distance:
|
|
193
|
+
targetIds: [a.id],
|
|
194
|
+
parameter: s,
|
|
195
|
+
distance: i.distance
|
|
196
196
|
} : null;
|
|
197
197
|
}
|
|
198
|
-
var
|
|
199
|
-
point:
|
|
200
|
-
intersection:
|
|
201
|
-
grid:
|
|
202
|
-
onObject:
|
|
198
|
+
var fe = {
|
|
199
|
+
point: ce,
|
|
200
|
+
intersection: le,
|
|
201
|
+
grid: ue,
|
|
202
|
+
onObject: de
|
|
203
203
|
};
|
|
204
|
-
function
|
|
204
|
+
function pe(e, t, n) {
|
|
205
205
|
let r = n.kinds ? new Set(n.kinds) : null;
|
|
206
|
-
for (let i of
|
|
206
|
+
for (let i of se) {
|
|
207
207
|
if (r && !r.has(i)) continue;
|
|
208
|
-
let a =
|
|
208
|
+
let a = fe[i](e, t, n);
|
|
209
209
|
if (a) return a;
|
|
210
210
|
}
|
|
211
211
|
return null;
|
|
212
212
|
}
|
|
213
|
-
function
|
|
214
|
-
return
|
|
213
|
+
function me(e, t, n) {
|
|
214
|
+
return pe(e, t, n)?.position ?? e;
|
|
215
215
|
}
|
|
216
|
-
function
|
|
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
|
|
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
|
|
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
|
|
278
|
+
var ge = /* @__PURE__ */ new WeakMap();
|
|
270
279
|
function E(e) {
|
|
271
|
-
let t =
|
|
272
|
-
return t === void 0 && (t = `${e.kind} ${r(e)}`,
|
|
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
|
|
275
|
-
function
|
|
276
|
-
let t =
|
|
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 =
|
|
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
|
-
|
|
294
|
+
_e.set(e, n), t = n;
|
|
286
295
|
}
|
|
287
296
|
return t;
|
|
288
297
|
}
|
|
289
|
-
function
|
|
298
|
+
function D(e, t, n) {
|
|
290
299
|
let r = E(t);
|
|
291
|
-
if (!n) return
|
|
300
|
+
if (!n) return ve(e).get(r) ?? null;
|
|
292
301
|
for (let i of Object.keys(e)) {
|
|
293
|
-
let
|
|
294
|
-
if (!(
|
|
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
|
|
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
|
|
310
|
+
let a = !1;
|
|
302
311
|
for (let e of Object.keys(n)) {
|
|
303
|
-
let s =
|
|
312
|
+
let s = o(n, e);
|
|
304
313
|
if (s?.kind !== "point") continue;
|
|
305
314
|
if (Object.prototype.hasOwnProperty.call(t, e)) {
|
|
306
|
-
|
|
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 (!
|
|
325
|
+
if (!a) return ve(t).get(e) ?? i[r] ?? null;
|
|
317
326
|
for (let r of Object.keys(t)) {
|
|
318
|
-
let i =
|
|
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
|
|
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
|
|
333
|
-
return
|
|
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
|
|
346
|
-
|
|
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 :
|
|
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
|
|
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
|
|
393
|
+
function Se(e) {
|
|
368
394
|
let t = 0;
|
|
369
|
-
for (;
|
|
370
|
-
return
|
|
395
|
+
for (; N(e, xe(t));) t += 1;
|
|
396
|
+
return xe(t);
|
|
371
397
|
}
|
|
372
|
-
function
|
|
398
|
+
function Ce(e, t) {
|
|
373
399
|
let n = 1;
|
|
374
|
-
for (;
|
|
400
|
+
for (; N(e, `${t}-${n}`);) n += 1;
|
|
375
401
|
return `${t}-${n}`;
|
|
376
402
|
}
|
|
377
|
-
function
|
|
403
|
+
function N(e, t) {
|
|
378
404
|
return Object.prototype.hasOwnProperty.call(e.entities, t);
|
|
379
405
|
}
|
|
380
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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
|
|
465
|
+
function De(e, t) {
|
|
437
466
|
e.setState({ selectedGivenId: t });
|
|
438
467
|
}
|
|
439
|
-
function
|
|
468
|
+
function Oe(e, t) {
|
|
440
469
|
M(e, (e) => ({
|
|
441
470
|
...e,
|
|
442
471
|
viewport: t
|
|
443
472
|
}));
|
|
444
473
|
}
|
|
445
|
-
function
|
|
474
|
+
function ke(e, t) {
|
|
446
475
|
M(e, (e) => ({
|
|
447
476
|
...e,
|
|
448
477
|
showGrid: t
|
|
449
478
|
}));
|
|
450
479
|
}
|
|
451
|
-
function
|
|
480
|
+
function Ae(e, t) {
|
|
452
481
|
M(e, (e) => ({
|
|
453
482
|
...e,
|
|
454
483
|
allowedObjects: t
|
|
455
484
|
}));
|
|
456
485
|
}
|
|
457
|
-
function
|
|
486
|
+
function je(e, t) {
|
|
458
487
|
M(e, (e) => ({
|
|
459
488
|
...e,
|
|
460
489
|
tools: t
|
|
461
490
|
}));
|
|
462
491
|
}
|
|
463
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 =
|
|
502
|
-
if (a) return e.setState({ constructionNotice:
|
|
503
|
-
let o =
|
|
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 =
|
|
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
|
|
541
|
+
function Le(e, t) {
|
|
513
542
|
let n = e.getState();
|
|
514
|
-
|
|
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
|
|
526
|
-
|
|
554
|
+
function Re(e, t) {
|
|
555
|
+
o(e.getState().exercise.entities, t)?.kind === "point" && Le(e, t);
|
|
527
556
|
}
|
|
528
|
-
function
|
|
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 =
|
|
532
|
-
return [
|
|
560
|
+
let r = Se(e);
|
|
561
|
+
return [P(e, r, t.origin, "implicit"), r];
|
|
533
562
|
}
|
|
534
|
-
function
|
|
535
|
-
let n = e.getState();
|
|
536
|
-
if (
|
|
537
|
-
|
|
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
|
|
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:
|
|
543
|
-
},
|
|
544
|
-
if (
|
|
581
|
+
parents: s
|
|
582
|
+
}, l = a === n.exercise ? D(n.exercise.entities, c) : null;
|
|
583
|
+
if (l) {
|
|
545
584
|
e.setState({
|
|
546
|
-
|
|
547
|
-
constructionNotice:
|
|
585
|
+
...j,
|
|
586
|
+
constructionNotice: k(l)
|
|
548
587
|
});
|
|
549
588
|
return;
|
|
550
589
|
}
|
|
551
|
-
let
|
|
552
|
-
if (!
|
|
553
|
-
|
|
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, () =>
|
|
557
|
-
|
|
558
|
-
selectedGivenId:
|
|
595
|
+
M(e, () => d, {
|
|
596
|
+
...j,
|
|
597
|
+
selectedGivenId: u,
|
|
559
598
|
constructionNotice: null
|
|
560
599
|
});
|
|
561
600
|
}
|
|
562
|
-
function
|
|
601
|
+
function Ve(e, t, n) {
|
|
563
602
|
M(e, (e) => {
|
|
564
|
-
let r =
|
|
565
|
-
return !r || r.kind !== "point" || !("at" in r) ? e :
|
|
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
|
|
575
|
-
let n =
|
|
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
|
|
617
|
+
function Ue(e) {
|
|
579
618
|
e.setState({ coalesceTag: null });
|
|
580
619
|
}
|
|
581
|
-
function
|
|
620
|
+
function We(e, t, n) {
|
|
582
621
|
M(e, (e) => {
|
|
583
|
-
let r =
|
|
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
|
|
629
|
+
function Ge(e, t, n) {
|
|
591
630
|
M(e, (e) => {
|
|
592
|
-
if (!
|
|
593
|
-
let r =
|
|
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
|
|
596
|
-
|
|
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]:
|
|
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
|
|
609
|
-
|
|
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 =
|
|
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) =>
|
|
673
|
+
dependentGoalIds: e.goals.filter((e) => ee(e).some((e) => r.has(e))).map((e) => e.id)
|
|
617
674
|
};
|
|
618
675
|
}
|
|
619
|
-
function
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
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
|
-
|
|
688
|
+
...(o.has(r ?? "") || o.has(i ?? "")) && j
|
|
633
689
|
});
|
|
634
690
|
}
|
|
635
|
-
function
|
|
636
|
-
if (n[0] === n[1]) return
|
|
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 =
|
|
641
|
-
if (a) return e.setState({ constructionNotice:
|
|
642
|
-
let o =
|
|
643
|
-
return M(e, (e) =>
|
|
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
|
|
646
|
-
return
|
|
701
|
+
function Ye(e, t, n) {
|
|
702
|
+
return F(e, "segment", [t, n]);
|
|
647
703
|
}
|
|
648
|
-
function
|
|
649
|
-
return
|
|
704
|
+
function Xe(e, t, n) {
|
|
705
|
+
return F(e, "line", [t, n]);
|
|
650
706
|
}
|
|
651
|
-
function
|
|
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
|
|
661
|
-
e.getState().pendingFirstPointId !== null && e.setState(
|
|
717
|
+
function Qe(e) {
|
|
718
|
+
e.getState().pendingFirstPointId !== null && e.setState(j);
|
|
662
719
|
}
|
|
663
|
-
function
|
|
664
|
-
let { pendingObjectType: n, pendingFirstPointId: r } = e.getState();
|
|
665
|
-
if (n
|
|
666
|
-
|
|
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
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
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
|
|
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) &&
|
|
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
|
|
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) => !
|
|
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
|
|
776
|
+
var R = {
|
|
706
777
|
schemaVersion: 2,
|
|
707
778
|
entities: {},
|
|
708
779
|
presentation: {},
|
|
709
780
|
answerEntityIds: []
|
|
710
781
|
};
|
|
711
|
-
function
|
|
712
|
-
return
|
|
782
|
+
function et(e, t) {
|
|
783
|
+
return C({
|
|
713
784
|
exercise: d(e),
|
|
714
|
-
geometry: t ??
|
|
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
|
|
728
|
-
let n =
|
|
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
|
|
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
|
|
738
|
-
function
|
|
809
|
+
var V = "move:";
|
|
810
|
+
function H(e) {
|
|
739
811
|
let t = e.coalesceTag;
|
|
740
|
-
if (!t?.startsWith(
|
|
741
|
-
let n = t.slice(5), r = e.past[e.past.length - 1], i = (t) =>
|
|
742
|
-
return r &&
|
|
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:
|
|
820
|
+
lastAttemptChange: B(e, {
|
|
749
821
|
action: "point-moved",
|
|
750
822
|
entityIds: [n]
|
|
751
823
|
})
|
|
752
824
|
};
|
|
753
825
|
}
|
|
754
|
-
function
|
|
755
|
-
let t =
|
|
826
|
+
function U(e) {
|
|
827
|
+
let t = H(e.getState());
|
|
756
828
|
t && e.setState(t);
|
|
757
829
|
}
|
|
758
|
-
function
|
|
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 :
|
|
839
|
+
past: a !== null && a === e.coalesceTag ? e.past : w(e.past, r),
|
|
768
840
|
future: [],
|
|
769
841
|
coalesceTag: a,
|
|
770
|
-
...n.receipt && { lastAttemptChange:
|
|
842
|
+
...n.receipt && { lastAttemptChange: B(e, n.receipt(r, i)) },
|
|
771
843
|
...n.extra
|
|
772
844
|
}));
|
|
773
845
|
}
|
|
774
|
-
function
|
|
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
|
|
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
|
-
...
|
|
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
|
|
881
|
+
function nt(e, t) {
|
|
808
882
|
e.setState((e) => ({
|
|
809
|
-
...
|
|
883
|
+
...G(e),
|
|
810
884
|
geometry: t
|
|
811
885
|
}));
|
|
812
886
|
}
|
|
813
|
-
function
|
|
887
|
+
function rt(e, t, n) {
|
|
814
888
|
e.setState((e) => ({
|
|
815
|
-
...
|
|
889
|
+
...G(e),
|
|
816
890
|
exercise: d(t),
|
|
817
|
-
geometry: n ?? { ...
|
|
891
|
+
geometry: n ?? { ...R }
|
|
818
892
|
}));
|
|
819
893
|
}
|
|
820
|
-
function
|
|
894
|
+
function K(e) {
|
|
821
895
|
return (t) => !Object.prototype.hasOwnProperty.call(e.entities, t);
|
|
822
896
|
}
|
|
823
|
-
|
|
824
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
855
|
-
e.getState().pendingFirstPointId !== null && e.setState(
|
|
937
|
+
function ot(e) {
|
|
938
|
+
e.getState().pendingFirstPointId !== null && e.setState(q);
|
|
856
939
|
}
|
|
857
|
-
function
|
|
940
|
+
function st(e) {
|
|
858
941
|
let { readOnly: t, past: n } = e.getState();
|
|
859
|
-
t || n.length === 0 || (
|
|
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:
|
|
954
|
+
lastAttemptChange: B(e, {
|
|
871
955
|
action: "undo",
|
|
872
|
-
entityIds:
|
|
956
|
+
entityIds: L(e.geometry, t)
|
|
873
957
|
})
|
|
874
958
|
} : {};
|
|
875
959
|
}));
|
|
876
960
|
}
|
|
877
|
-
function
|
|
961
|
+
function ct(e) {
|
|
878
962
|
let { readOnly: t, future: n } = e.getState();
|
|
879
|
-
t || n.length === 0 || (
|
|
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:
|
|
975
|
+
lastAttemptChange: B(e, {
|
|
891
976
|
action: "redo",
|
|
892
|
-
entityIds:
|
|
977
|
+
entityIds: L(e.geometry, t)
|
|
893
978
|
})
|
|
894
979
|
} : {};
|
|
895
980
|
}));
|
|
896
981
|
}
|
|
897
|
-
function
|
|
898
|
-
e.getState().readOnly || (
|
|
899
|
-
let t = { ...
|
|
982
|
+
function lt(e) {
|
|
983
|
+
e.getState().readOnly || (U(e), e.setState((e) => {
|
|
984
|
+
let t = { ...R };
|
|
900
985
|
return {
|
|
901
|
-
...
|
|
986
|
+
...G(e),
|
|
902
987
|
geometry: t,
|
|
903
|
-
lastAttemptChange:
|
|
988
|
+
lastAttemptChange: B(e, {
|
|
904
989
|
action: "reset",
|
|
905
|
-
entityIds:
|
|
990
|
+
entityIds: L(e.geometry, t)
|
|
906
991
|
})
|
|
907
992
|
};
|
|
908
993
|
}));
|
|
909
994
|
}
|
|
910
|
-
function
|
|
995
|
+
function ut(e, t, n = !0) {
|
|
911
996
|
if (e.getState().readOnly) return null;
|
|
912
|
-
|
|
913
|
-
let { exercise: r, geometry: i } = e.getState(), a =
|
|
914
|
-
if (a) return e.setState({ constructionNotice:
|
|
915
|
-
let o =
|
|
916
|
-
return
|
|
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
|
|
1012
|
+
function dt(e, t) {
|
|
928
1013
|
if (e.getState().readOnly) return;
|
|
929
|
-
|
|
1014
|
+
U(e);
|
|
930
1015
|
let n = e.getState();
|
|
931
|
-
|
|
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
|
|
1030
|
+
function ft(e, t, n) {
|
|
946
1031
|
if (e.getState().readOnly) return;
|
|
947
|
-
e.getState().coalesceTag !== `${
|
|
948
|
-
let r = e.getState(), i =
|
|
949
|
-
if (!i || "intersectionOf" in i || !
|
|
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 =
|
|
1043
|
+
let e = _(r.exercise, r.geometry).resolvedOf(i.on);
|
|
959
1044
|
if (!e) return;
|
|
960
|
-
let t =
|
|
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
|
-
|
|
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: `${
|
|
1059
|
+
}), { coalesceTag: `${V}${t}` });
|
|
975
1060
|
}
|
|
976
|
-
function
|
|
977
|
-
if (
|
|
978
|
-
|
|
979
|
-
|
|
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
|
|
1067
|
+
function pt(e) {
|
|
982
1068
|
let t = e.getState();
|
|
983
|
-
t.coalesceTag !== null && e.setState(
|
|
1069
|
+
t.coalesceTag !== null && e.setState(H(t) ?? { coalesceTag: null });
|
|
984
1070
|
}
|
|
985
|
-
function
|
|
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 =
|
|
989
|
-
return [
|
|
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
|
|
1080
|
+
function Z(e, t) {
|
|
995
1081
|
if (e.getState().readOnly) return;
|
|
996
|
-
|
|
997
|
-
let n = e.getState();
|
|
998
|
-
if (!n.exercise.allowedObjects.includes(t.tool) ||
|
|
999
|
-
|
|
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
|
-
|
|
1003
|
-
|
|
1088
|
+
let i = ht(n.exercise, n.geometry, t);
|
|
1089
|
+
if (!i) {
|
|
1090
|
+
it(e);
|
|
1004
1091
|
return;
|
|
1005
1092
|
}
|
|
1006
|
-
|
|
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
|
-
|
|
1013
|
-
constructionNotice:
|
|
1095
|
+
...q,
|
|
1096
|
+
constructionNotice: k(i.duplicateId)
|
|
1014
1097
|
});
|
|
1015
1098
|
return;
|
|
1016
1099
|
}
|
|
1017
|
-
|
|
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
|
-
|
|
1102
|
+
...q,
|
|
1024
1103
|
constructionNotice: null
|
|
1025
1104
|
},
|
|
1026
1105
|
receipt: () => ({
|
|
1027
|
-
action: t.tool
|
|
1028
|
-
entityIds: [
|
|
1106
|
+
action: `${t.tool}-created`,
|
|
1107
|
+
entityIds: [i.objectId, ...i.inventedIds]
|
|
1029
1108
|
})
|
|
1030
1109
|
});
|
|
1031
1110
|
}
|
|
1032
|
-
function
|
|
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
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
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
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
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
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
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
|
|
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
|
|
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(
|
|
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
|
|
1193
|
+
function yt(e, t) {
|
|
1083
1194
|
if (e.getState().readOnly) return;
|
|
1084
|
-
|
|
1195
|
+
U(e);
|
|
1085
1196
|
let n = e.getState();
|
|
1086
1197
|
if (!Q(n, t)) return;
|
|
1087
|
-
let r =
|
|
1088
|
-
|
|
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
|
-
|
|
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 (
|
|
1216
|
+
for (let [n, r] of e) if (m(r, t)) return n;
|
|
1106
1217
|
return null;
|
|
1107
1218
|
}
|
|
1108
|
-
function
|
|
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] : [
|
|
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
|
|
1232
|
+
var xt = {
|
|
1122
1233
|
role: "explicit",
|
|
1123
1234
|
countsAsAnswer: !1
|
|
1124
1235
|
};
|
|
1125
|
-
function
|
|
1236
|
+
function St(e, t) {
|
|
1126
1237
|
if (e.getState().readOnly) return;
|
|
1127
|
-
|
|
1128
|
-
let { exercise: n, geometry: r } = e.getState(), [i, a] =
|
|
1129
|
-
|
|
1130
|
-
extra: { constructionNotice: a ?
|
|
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:
|
|
1244
|
+
entityIds: L(e, t)
|
|
1134
1245
|
})
|
|
1135
1246
|
});
|
|
1136
1247
|
}
|
|
1137
|
-
function
|
|
1138
|
-
let r = new Map(
|
|
1139
|
-
if (n.type === "point") return
|
|
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 =
|
|
1273
|
+
s || (s = J(e, o, "student-point"), o = Y(o, s, {
|
|
1142
1274
|
kind: "point",
|
|
1143
1275
|
at: i
|
|
1144
|
-
},
|
|
1276
|
+
}, xt), r.set(s, i));
|
|
1145
1277
|
let c = $(r, a);
|
|
1146
|
-
if (c || (c =
|
|
1278
|
+
if (c || (c = J(e, o, "student-point"), o = Y(o, c, {
|
|
1147
1279
|
kind: "point",
|
|
1148
1280
|
at: a
|
|
1149
|
-
},
|
|
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 =
|
|
1154
|
-
return u ? [t, u] : [
|
|
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 {
|
|
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-
|
|
1294
|
+
//# sourceMappingURL=studentStore-CyYa0N93.js.map
|