@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
|
@@ -0,0 +1,1177 @@
|
|
|
1
|
+
import e from "jsxgraph";
|
|
2
|
+
import { z as t } from "zod";
|
|
3
|
+
//#region src/geometry/point.ts
|
|
4
|
+
function n(e, t) {
|
|
5
|
+
return Math.hypot(t.x - e.x, t.y - e.y);
|
|
6
|
+
}
|
|
7
|
+
function r(e, t) {
|
|
8
|
+
return {
|
|
9
|
+
x: (e.x + t.x) / 2,
|
|
10
|
+
y: (e.y + t.y) / 2
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/numerics/policy.ts
|
|
15
|
+
var i = 1e-9, a = 1e-9, o = 1e-12, s = 1e-12, c = 1e-6, l = 1e-9, ee = 24, te = 32;
|
|
16
|
+
function ne(e, t, n = i) {
|
|
17
|
+
return Math.abs(e - t) <= n;
|
|
18
|
+
}
|
|
19
|
+
function u(e, t) {
|
|
20
|
+
return Math.abs(e) <= Math.abs(t) * s;
|
|
21
|
+
}
|
|
22
|
+
function d(e, t, r = a) {
|
|
23
|
+
return n(e, t) <= r;
|
|
24
|
+
}
|
|
25
|
+
function re(e, t) {
|
|
26
|
+
return n(e, t) <= c;
|
|
27
|
+
}
|
|
28
|
+
function ie(e) {
|
|
29
|
+
return e >= -1e-12 && e <= 1.000000000001;
|
|
30
|
+
}
|
|
31
|
+
function ae(e, t, n) {
|
|
32
|
+
return Math.abs(e - t) <= n + l;
|
|
33
|
+
}
|
|
34
|
+
function oe(e, t) {
|
|
35
|
+
return e <= t + l;
|
|
36
|
+
}
|
|
37
|
+
function se(e, t) {
|
|
38
|
+
return e / t;
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/geometry/distance.ts
|
|
42
|
+
function f(e, t, r) {
|
|
43
|
+
let i = r.x - t.x, a = r.y - t.y, o = Math.hypot(i, a);
|
|
44
|
+
if (o === 0 || u(o, n(e, t))) return null;
|
|
45
|
+
let s = i / o, c = a / o;
|
|
46
|
+
return ((e.x - t.x) * s + (e.y - t.y) * c) / o;
|
|
47
|
+
}
|
|
48
|
+
function p(e, t, n) {
|
|
49
|
+
return {
|
|
50
|
+
x: e.x + (t.x - e.x) * n,
|
|
51
|
+
y: e.y + (t.y - e.y) * n
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function ce(e, t, n) {
|
|
55
|
+
let r = f(e, t, n);
|
|
56
|
+
return r === null ? t : p(t, n, r);
|
|
57
|
+
}
|
|
58
|
+
function le(e, t, n) {
|
|
59
|
+
let r = f(e, t, n);
|
|
60
|
+
return r === null ? t : p(t, n, Math.min(1, Math.max(0, r)));
|
|
61
|
+
}
|
|
62
|
+
function ue(e, t, r) {
|
|
63
|
+
return n(e, ce(e, t, r));
|
|
64
|
+
}
|
|
65
|
+
function m(e, t, r) {
|
|
66
|
+
return n(e, le(e, t, r));
|
|
67
|
+
}
|
|
68
|
+
function h(e, t, r) {
|
|
69
|
+
return Math.abs(n(e, t) - r);
|
|
70
|
+
}
|
|
71
|
+
function g(e, t, n) {
|
|
72
|
+
let r = e.x - t.x, i = e.y - t.y, a = Math.hypot(r, i);
|
|
73
|
+
return a === 0 || u(a, n) ? null : {
|
|
74
|
+
x: t.x + r / a * n,
|
|
75
|
+
y: t.y + i / a * n
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/measure/angleType.ts
|
|
80
|
+
function de(e) {
|
|
81
|
+
let t = l;
|
|
82
|
+
return e <= t || e >= 360 - t ? null : Math.abs(e - 90) <= t ? "right" : Math.abs(e - 180) <= t ? "straight" : e < 90 ? "acute" : e < 180 ? "obtuse" : "reflex";
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/measure/kernel.ts
|
|
86
|
+
var fe = Object.freeze({
|
|
87
|
+
origin: Object.freeze({ scrCoords: Object.freeze([
|
|
88
|
+
1,
|
|
89
|
+
0,
|
|
90
|
+
0
|
|
91
|
+
]) }),
|
|
92
|
+
unitX: 1,
|
|
93
|
+
unitY: 1
|
|
94
|
+
}), pe = e.default ?? e, _ = pe.Math.Geometry, v = pe.Math;
|
|
95
|
+
function y(e) {
|
|
96
|
+
return [
|
|
97
|
+
1,
|
|
98
|
+
e.x,
|
|
99
|
+
e.y
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
function me(e, t) {
|
|
103
|
+
let [n, r, i] = v.crossProduct(y(e), y(t));
|
|
104
|
+
return v.normalize([
|
|
105
|
+
n ?? 0,
|
|
106
|
+
r ?? 0,
|
|
107
|
+
i ?? 0,
|
|
108
|
+
0,
|
|
109
|
+
1,
|
|
110
|
+
0,
|
|
111
|
+
0,
|
|
112
|
+
0
|
|
113
|
+
]);
|
|
114
|
+
}
|
|
115
|
+
function b(e) {
|
|
116
|
+
return v.normalize([
|
|
117
|
+
0,
|
|
118
|
+
-e.center.x,
|
|
119
|
+
-e.center.y,
|
|
120
|
+
.5,
|
|
121
|
+
e.radius,
|
|
122
|
+
0,
|
|
123
|
+
0,
|
|
124
|
+
0
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
function x(e) {
|
|
128
|
+
let [t, n, r] = e.usrCoords;
|
|
129
|
+
return {
|
|
130
|
+
w: t ?? NaN,
|
|
131
|
+
x: n ?? NaN,
|
|
132
|
+
y: r ?? NaN
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
function he(e, t, n, r) {
|
|
136
|
+
let [i, a, o] = _.meetSegmentSegment(y(e), y(t), y(n), y(r));
|
|
137
|
+
return {
|
|
138
|
+
point: x({ usrCoords: i }),
|
|
139
|
+
t: a,
|
|
140
|
+
u: o
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function S(e, t, n) {
|
|
144
|
+
return x(_.meetLineCircle(me(e.from, e.to), b(t), n, fe));
|
|
145
|
+
}
|
|
146
|
+
function C(e, t, n) {
|
|
147
|
+
return x(_.meetCircleCircle(b(e), b(t), n, fe));
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/measure/geometryAdapter.ts
|
|
151
|
+
function w(e, t) {
|
|
152
|
+
return d(e, t);
|
|
153
|
+
}
|
|
154
|
+
function T(e, t) {
|
|
155
|
+
return n(e, t) === 0 ? NaN : Math.atan2(t.y - e.y, t.x - e.x);
|
|
156
|
+
}
|
|
157
|
+
function E(e, t) {
|
|
158
|
+
return d(e, t) ? null : _e(Math.atan2(t.y - e.y, t.x - e.x) / (2 * Math.PI));
|
|
159
|
+
}
|
|
160
|
+
function ge(e, t) {
|
|
161
|
+
return _e(t - e);
|
|
162
|
+
}
|
|
163
|
+
function _e(e) {
|
|
164
|
+
let t = e % 1, n = t < 0 ? t + 1 : t;
|
|
165
|
+
return n >= 1 || n === 0 ? 0 : n;
|
|
166
|
+
}
|
|
167
|
+
function ve(e, t, n, r) {
|
|
168
|
+
let i = ((T(e, t) - T(n, r)) * 180 / Math.PI % 180 + 180) % 180;
|
|
169
|
+
return Math.min(i, 180 - i);
|
|
170
|
+
}
|
|
171
|
+
function ye(e, t) {
|
|
172
|
+
let n = ((e - t) % 360 + 360) % 360;
|
|
173
|
+
return Math.min(n, 360 - n);
|
|
174
|
+
}
|
|
175
|
+
function D(e, t) {
|
|
176
|
+
return e.type === "line" || ie(t);
|
|
177
|
+
}
|
|
178
|
+
function be(e) {
|
|
179
|
+
return e.type === "segment" ? {
|
|
180
|
+
type: "line",
|
|
181
|
+
from: e.from,
|
|
182
|
+
to: e.to
|
|
183
|
+
} : e;
|
|
184
|
+
}
|
|
185
|
+
function O(e) {
|
|
186
|
+
let { w: t, x: n, y: r } = e;
|
|
187
|
+
return !Number.isFinite(t) || !Number.isFinite(n) || !Number.isFinite(r) || u(t, 1) ? null : {
|
|
188
|
+
x: xe(n / t),
|
|
189
|
+
y: xe(r / t)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function xe(e) {
|
|
193
|
+
return e === 0 ? 0 : e;
|
|
194
|
+
}
|
|
195
|
+
function Se(e) {
|
|
196
|
+
let t = [];
|
|
197
|
+
for (let n of e) n && (t.some((e) => w(e, n)) || t.push(n));
|
|
198
|
+
return t.sort((e, t) => e.x - t.x || e.y - t.y);
|
|
199
|
+
}
|
|
200
|
+
function Ce(e, t) {
|
|
201
|
+
let n = {
|
|
202
|
+
from: e.from,
|
|
203
|
+
to: e.to
|
|
204
|
+
}, r = {
|
|
205
|
+
center: t.center,
|
|
206
|
+
radius: t.radius
|
|
207
|
+
}, i = Se([O(S(n, r, 0)), O(S(n, r, 1))]);
|
|
208
|
+
return e.type === "line" ? i : i.filter((t) => {
|
|
209
|
+
let n = f(t, e.from, e.to);
|
|
210
|
+
return n !== null && D(e, n);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function we(e, t) {
|
|
214
|
+
return w(e.center, t.center) ? [] : Se([O(C(e, t, 0)), O(C(e, t, 1))]);
|
|
215
|
+
}
|
|
216
|
+
function Te(e, t) {
|
|
217
|
+
let { point: n, t: r, u: i } = he(e.from, e.to, t.from, t.to);
|
|
218
|
+
if (!Number.isFinite(r) || !Number.isFinite(i)) return [];
|
|
219
|
+
let a = O(n);
|
|
220
|
+
return !a || !D(e, r) || !D(t, i) ? [] : [a];
|
|
221
|
+
}
|
|
222
|
+
function Ee(e, t) {
|
|
223
|
+
return e.type === "circle" ? t.type === "circle" ? we(e, t) : Ce(t, e) : t.type === "circle" ? Ce(e, t) : Te(e, t);
|
|
224
|
+
}
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region src/geometry/entities/angle.ts
|
|
227
|
+
var De = .4, Oe = {
|
|
228
|
+
kind: "angle",
|
|
229
|
+
parents: (e) => e.parents,
|
|
230
|
+
resolve: (e, [t, r, i]) => {
|
|
231
|
+
if (t?.kind !== "point" || r?.kind !== "point" || i?.kind !== "point") return null;
|
|
232
|
+
let a = E(r.at, t.at), o = E(r.at, i.at);
|
|
233
|
+
if (a === null || o === null) return null;
|
|
234
|
+
let s = Math.min(n(r.at, t.at), n(r.at, i.at)) * De;
|
|
235
|
+
return {
|
|
236
|
+
kind: "angle",
|
|
237
|
+
vertex: r.at,
|
|
238
|
+
startTurn: a,
|
|
239
|
+
sweepTurn: ge(a, o),
|
|
240
|
+
markRadius: s
|
|
241
|
+
};
|
|
242
|
+
},
|
|
243
|
+
toShape: (e) => ({
|
|
244
|
+
shape: "angle",
|
|
245
|
+
vertex: e.vertex,
|
|
246
|
+
startTurn: e.startTurn,
|
|
247
|
+
sweepTurn: e.sweepTurn,
|
|
248
|
+
radius: e.markRadius
|
|
249
|
+
}),
|
|
250
|
+
toMeasured: () => null,
|
|
251
|
+
distanceTo: (e, t) => {
|
|
252
|
+
let n = ke(e);
|
|
253
|
+
if (!n) return Ae(e, t);
|
|
254
|
+
let [r, i, a] = n;
|
|
255
|
+
return Math.min(m(t, r, i), m(t, i, a));
|
|
256
|
+
},
|
|
257
|
+
describe: (e, t) => {
|
|
258
|
+
let [n, r, i] = e.parents;
|
|
259
|
+
return `angle at ${t(r)} from ${t(n)} to ${t(i)}`;
|
|
260
|
+
},
|
|
261
|
+
hitPriority: 1,
|
|
262
|
+
identityKey: (e) => `angle:${JSON.stringify(e.parents)}`
|
|
263
|
+
};
|
|
264
|
+
function ke(e) {
|
|
265
|
+
let { vertex: t, startTurn: n, sweepTurn: r, markRadius: i } = e;
|
|
266
|
+
if (de(r * 360) !== "right") return null;
|
|
267
|
+
let a = i * Math.SQRT1_2, o = k(t, n, a), s = k(t, n + r, a);
|
|
268
|
+
return [
|
|
269
|
+
o,
|
|
270
|
+
{
|
|
271
|
+
x: o.x + s.x - t.x,
|
|
272
|
+
y: o.y + s.y - t.y
|
|
273
|
+
},
|
|
274
|
+
s
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
function Ae(e, t) {
|
|
278
|
+
let { vertex: r, startTurn: i, sweepTurn: a, markRadius: o } = e, s = E(r, t);
|
|
279
|
+
return s === null ? o : ((s - i) % 1 + 1) % 1 <= a ? Math.abs(n(r, t) - o) : Math.min(n(t, k(r, i, o)), n(t, k(r, i + a, o)));
|
|
280
|
+
}
|
|
281
|
+
function k(e, t, n) {
|
|
282
|
+
return {
|
|
283
|
+
x: e.x + n * Math.cos(2 * Math.PI * t),
|
|
284
|
+
y: e.y + n * Math.sin(2 * Math.PI * t)
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/geometry/entities/circle.ts
|
|
289
|
+
var je = {
|
|
290
|
+
kind: "circle",
|
|
291
|
+
parents: (e) => e.parents,
|
|
292
|
+
resolve: (e, [t, r]) => {
|
|
293
|
+
if (t?.kind !== "point" || r?.kind !== "point") return null;
|
|
294
|
+
let i = n(t.at, r.at);
|
|
295
|
+
return i === 0 ? null : {
|
|
296
|
+
kind: "circle",
|
|
297
|
+
center: t.at,
|
|
298
|
+
radius: i
|
|
299
|
+
};
|
|
300
|
+
},
|
|
301
|
+
toShape: (e) => ({
|
|
302
|
+
shape: "circle",
|
|
303
|
+
center: e.center,
|
|
304
|
+
radius: e.radius
|
|
305
|
+
}),
|
|
306
|
+
toMeasured: (e) => ({
|
|
307
|
+
type: "circle",
|
|
308
|
+
center: e.center,
|
|
309
|
+
radius: e.radius
|
|
310
|
+
}),
|
|
311
|
+
distanceTo: (e, t) => h(t, e.center, e.radius),
|
|
312
|
+
describe: (e, t) => `circle centred on ${t(e.parents[0])} through ${t(e.parents[1])}`,
|
|
313
|
+
hitPriority: 1,
|
|
314
|
+
identityKey: (e) => `circle:${JSON.stringify(e.parents)}`
|
|
315
|
+
}, A = (e) => ({
|
|
316
|
+
type: "segment",
|
|
317
|
+
from: e.from,
|
|
318
|
+
to: e.to
|
|
319
|
+
}), j = (e) => ({
|
|
320
|
+
type: "line",
|
|
321
|
+
from: e.through[0],
|
|
322
|
+
to: e.through[1]
|
|
323
|
+
}), M = (e) => ({
|
|
324
|
+
type: "circle",
|
|
325
|
+
center: e.center,
|
|
326
|
+
radius: e.radius
|
|
327
|
+
});
|
|
328
|
+
function N(e, t, n) {
|
|
329
|
+
return Ee(e, t)[n] ?? null;
|
|
330
|
+
}
|
|
331
|
+
var P = () => null, Me = {
|
|
332
|
+
"point:point": P,
|
|
333
|
+
"point:segment": P,
|
|
334
|
+
"point:line": P,
|
|
335
|
+
"segment:point": P,
|
|
336
|
+
"line:point": P,
|
|
337
|
+
"point:circle": P,
|
|
338
|
+
"circle:point": P,
|
|
339
|
+
"point:angle": P,
|
|
340
|
+
"angle:point": P,
|
|
341
|
+
"segment:angle": P,
|
|
342
|
+
"angle:segment": P,
|
|
343
|
+
"line:angle": P,
|
|
344
|
+
"angle:line": P,
|
|
345
|
+
"circle:angle": P,
|
|
346
|
+
"angle:circle": P,
|
|
347
|
+
"angle:angle": P,
|
|
348
|
+
"segment:segment": ([e, t], n) => N(A(e), A(t), n),
|
|
349
|
+
"segment:line": ([e, t], n) => N(A(e), j(t), n),
|
|
350
|
+
"line:segment": ([e, t], n) => N(j(e), A(t), n),
|
|
351
|
+
"line:line": ([e, t], n) => N(j(e), j(t), n),
|
|
352
|
+
"segment:circle": ([e, t], n) => N(A(e), M(t), n),
|
|
353
|
+
"circle:segment": ([e, t], n) => N(M(e), A(t), n),
|
|
354
|
+
"line:circle": ([e, t], n) => N(j(e), M(t), n),
|
|
355
|
+
"circle:line": ([e, t], n) => N(M(e), j(t), n),
|
|
356
|
+
"circle:circle": ([e, t], n) => N(M(e), M(t), n)
|
|
357
|
+
};
|
|
358
|
+
function Ne(e, t, n = 0) {
|
|
359
|
+
let r = Me[`${e.kind}:${t.kind}`];
|
|
360
|
+
return r([e, t], n);
|
|
361
|
+
}
|
|
362
|
+
var F = () => null, I = {
|
|
363
|
+
point: F,
|
|
364
|
+
angle: F,
|
|
365
|
+
segment: (e, t) => p(e.from, e.to, t),
|
|
366
|
+
line: (e, t) => p(e.through[0], e.through[1], t),
|
|
367
|
+
circle: (e, t) => ({
|
|
368
|
+
x: e.center.x + e.radius * Math.cos(2 * Math.PI * t),
|
|
369
|
+
y: e.center.y + e.radius * Math.sin(2 * Math.PI * t)
|
|
370
|
+
})
|
|
371
|
+
};
|
|
372
|
+
function Pe(e) {
|
|
373
|
+
return I[e] !== F;
|
|
374
|
+
}
|
|
375
|
+
function L(e, t) {
|
|
376
|
+
let n = I[e.kind];
|
|
377
|
+
return n(e, t);
|
|
378
|
+
}
|
|
379
|
+
var Fe = {
|
|
380
|
+
point: () => null,
|
|
381
|
+
angle: () => null,
|
|
382
|
+
segment: (e, t) => {
|
|
383
|
+
let n = f(t, e.from, e.to);
|
|
384
|
+
return n === null ? null : Math.min(1, Math.max(0, n));
|
|
385
|
+
},
|
|
386
|
+
line: (e, t) => f(t, e.through[0], e.through[1]),
|
|
387
|
+
circle: (e, t) => {
|
|
388
|
+
let n = g(t, e.center, e.radius);
|
|
389
|
+
if (!n) return null;
|
|
390
|
+
let r = Math.atan2(n.y - e.center.y, n.x - e.center.x) / (2 * Math.PI);
|
|
391
|
+
return r < 0 ? r + 1 : r;
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
function Ie(e, t) {
|
|
395
|
+
let n = Fe[e.kind];
|
|
396
|
+
return n(e, t);
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/geometry/entities/line.ts
|
|
400
|
+
var Le = {
|
|
401
|
+
kind: "line",
|
|
402
|
+
parents: (e) => e.parents,
|
|
403
|
+
resolve: (e, [t, n]) => t?.kind !== "point" || n?.kind !== "point" ? null : {
|
|
404
|
+
kind: "line",
|
|
405
|
+
through: [t.at, n.at]
|
|
406
|
+
},
|
|
407
|
+
toShape: (e) => ({
|
|
408
|
+
shape: "line",
|
|
409
|
+
through: e.through
|
|
410
|
+
}),
|
|
411
|
+
toMeasured: (e) => ({
|
|
412
|
+
type: "line",
|
|
413
|
+
from: e.through[0],
|
|
414
|
+
to: e.through[1]
|
|
415
|
+
}),
|
|
416
|
+
distanceTo: (e, t) => ue(t, e.through[0], e.through[1]),
|
|
417
|
+
describe: (e, t) => `line through ${t(e.parents[0])} and ${t(e.parents[1])}`,
|
|
418
|
+
hitPriority: 2,
|
|
419
|
+
identityKey: (e) => `line:${JSON.stringify([...e.parents].sort())}`
|
|
420
|
+
}, Re = Object.freeze([]);
|
|
421
|
+
function R(e) {
|
|
422
|
+
return String(Number(e.toFixed(2)));
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/geometry/entities/index.ts
|
|
426
|
+
var z = Object.freeze({
|
|
427
|
+
point: {
|
|
428
|
+
kind: "point",
|
|
429
|
+
parents: (e) => "at" in e ? Re : "on" in e ? [e.on] : e.intersectionOf,
|
|
430
|
+
resolve: (e, t) => {
|
|
431
|
+
if ("at" in e) return {
|
|
432
|
+
kind: "point",
|
|
433
|
+
at: e.at
|
|
434
|
+
};
|
|
435
|
+
if ("on" in e) {
|
|
436
|
+
let n = t[0];
|
|
437
|
+
if (!n) return null;
|
|
438
|
+
let r = L(n, e.t);
|
|
439
|
+
return r ? {
|
|
440
|
+
kind: "point",
|
|
441
|
+
at: r
|
|
442
|
+
} : null;
|
|
443
|
+
}
|
|
444
|
+
let [n, r] = t;
|
|
445
|
+
if (!n || !r) return null;
|
|
446
|
+
let i = Ne(n, r, e.which ?? 0);
|
|
447
|
+
return i ? {
|
|
448
|
+
kind: "point",
|
|
449
|
+
at: i
|
|
450
|
+
} : null;
|
|
451
|
+
},
|
|
452
|
+
toShape: (e) => ({
|
|
453
|
+
shape: "point",
|
|
454
|
+
at: e.at
|
|
455
|
+
}),
|
|
456
|
+
toMeasured: () => null,
|
|
457
|
+
distanceTo: (e, t) => n(t, e.at),
|
|
458
|
+
describe: (e, t) => {
|
|
459
|
+
if ("at" in e) return `point at (${R(e.at.x)}, ${R(e.at.y)})`;
|
|
460
|
+
if ("on" in e) return `point on ${t(e.on)}`;
|
|
461
|
+
let [n, r] = e.intersectionOf;
|
|
462
|
+
return `point where ${t(n)} and ${t(r)} meet`;
|
|
463
|
+
},
|
|
464
|
+
hitPriority: 0,
|
|
465
|
+
identityKey: (e) => "at" in e ? `point:at:${e.at.x}:${e.at.y}` : "on" in e ? `point:on:${e.on}:${e.t}` : `point:meet:${JSON.stringify(e.intersectionOf)}:${e.which ?? 0}`
|
|
466
|
+
},
|
|
467
|
+
segment: {
|
|
468
|
+
kind: "segment",
|
|
469
|
+
parents: (e) => e.parents,
|
|
470
|
+
resolve: (e, [t, n]) => t?.kind !== "point" || n?.kind !== "point" ? null : {
|
|
471
|
+
kind: "segment",
|
|
472
|
+
from: t.at,
|
|
473
|
+
to: n.at
|
|
474
|
+
},
|
|
475
|
+
toShape: (e) => ({
|
|
476
|
+
shape: "segment",
|
|
477
|
+
from: e.from,
|
|
478
|
+
to: e.to
|
|
479
|
+
}),
|
|
480
|
+
toMeasured: (e) => ({
|
|
481
|
+
type: "segment",
|
|
482
|
+
from: e.from,
|
|
483
|
+
to: e.to
|
|
484
|
+
}),
|
|
485
|
+
distanceTo: (e, t) => m(t, e.from, e.to),
|
|
486
|
+
describe: (e, t) => `segment from ${t(e.parents[0])} to ${t(e.parents[1])}`,
|
|
487
|
+
hitPriority: 1,
|
|
488
|
+
identityKey: (e) => `segment:${JSON.stringify([...e.parents].sort())}`
|
|
489
|
+
},
|
|
490
|
+
line: Le,
|
|
491
|
+
circle: je,
|
|
492
|
+
angle: Oe
|
|
493
|
+
}), ze = Object.freeze(Object.keys(z)), Be = Object.freeze(ze.filter((e) => e !== "point" && Pe(e)));
|
|
494
|
+
function B(e) {
|
|
495
|
+
return z[e];
|
|
496
|
+
}
|
|
497
|
+
function V(e) {
|
|
498
|
+
return B(e.kind).parents(e);
|
|
499
|
+
}
|
|
500
|
+
function Ve(e, t) {
|
|
501
|
+
return B(e.kind).resolve(e, t);
|
|
502
|
+
}
|
|
503
|
+
function He(e, t) {
|
|
504
|
+
let n = [];
|
|
505
|
+
for (let r of V(e)) {
|
|
506
|
+
let e = t.get(r);
|
|
507
|
+
if (!e) return null;
|
|
508
|
+
n.push({
|
|
509
|
+
kind: "point",
|
|
510
|
+
at: e
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
return Ve(e, n);
|
|
514
|
+
}
|
|
515
|
+
function Ue(e) {
|
|
516
|
+
return B(e.kind).toShape(e);
|
|
517
|
+
}
|
|
518
|
+
function We(e) {
|
|
519
|
+
return B(e.kind).toMeasured(e);
|
|
520
|
+
}
|
|
521
|
+
function Ge(e, t) {
|
|
522
|
+
return B(e.kind).distanceTo(e, t);
|
|
523
|
+
}
|
|
524
|
+
function Ke(e) {
|
|
525
|
+
return B(e).hitPriority;
|
|
526
|
+
}
|
|
527
|
+
function qe(e) {
|
|
528
|
+
return B(e.kind).identityKey(e);
|
|
529
|
+
}
|
|
530
|
+
function Je(e, t) {
|
|
531
|
+
return B(e.kind).describe(e, t);
|
|
532
|
+
}
|
|
533
|
+
//#endregion
|
|
534
|
+
//#region src/geometry/entityRecord.ts
|
|
535
|
+
var H = "__proto__";
|
|
536
|
+
function Ye(e) {
|
|
537
|
+
return e === H;
|
|
538
|
+
}
|
|
539
|
+
function Xe(e) {
|
|
540
|
+
return `${e} cannot be used as an entity id`;
|
|
541
|
+
}
|
|
542
|
+
function U(e, t) {
|
|
543
|
+
return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
|
|
544
|
+
}
|
|
545
|
+
function W() {
|
|
546
|
+
return Object.create(null);
|
|
547
|
+
}
|
|
548
|
+
//#endregion
|
|
549
|
+
//#region src/schemas/identifier.schema.ts
|
|
550
|
+
var G = t.string().min(1).refine((e) => e === e.trim(), { message: "id must not have leading or trailing spaces" });
|
|
551
|
+
//#endregion
|
|
552
|
+
//#region src/schemas/entityDocument.ts
|
|
553
|
+
function K(e) {
|
|
554
|
+
return t.preprocess((e, n) => typeof e == "object" && e && Object.prototype.hasOwnProperty.call(e, "__proto__") ? (n.addIssue({
|
|
555
|
+
code: "custom",
|
|
556
|
+
path: [H],
|
|
557
|
+
message: Xe(H)
|
|
558
|
+
}), t.NEVER) : e, t.record(G, e));
|
|
559
|
+
}
|
|
560
|
+
function q(e) {
|
|
561
|
+
return e === "angle" ? `an ${e}` : `a ${e}`;
|
|
562
|
+
}
|
|
563
|
+
function Ze(e, t, n, r) {
|
|
564
|
+
return t.kind === "point" ? r.kind !== "point" && r.kind !== "angle" ? null : "on" in t ? `${e} is on ${n}, which is ${q(r.kind)}` : `${e} intersects ${n}, which is ${q(r.kind)}` : r.kind === "point" ? null : `${e} references ${n}, which is ${q(r.kind)} and not a point`;
|
|
565
|
+
}
|
|
566
|
+
function Qe(e, t) {
|
|
567
|
+
let n = [], r = Object.entries(e.entities), i = (t) => Object.prototype.hasOwnProperty.call(e.entities, t), a = /* @__PURE__ */ new Map();
|
|
568
|
+
for (let [i, o] of r) {
|
|
569
|
+
let r = V(o), s = ["entities", i];
|
|
570
|
+
r.includes(i) && n.push({
|
|
571
|
+
path: s,
|
|
572
|
+
message: `${i} is its own parent`
|
|
573
|
+
}), new Set(r).size !== r.length && n.push({
|
|
574
|
+
path: s,
|
|
575
|
+
message: `${i} must reference distinct entities`
|
|
576
|
+
});
|
|
577
|
+
for (let a of r) {
|
|
578
|
+
let r = U(e.entities, a);
|
|
579
|
+
if (!r) {
|
|
580
|
+
t.parentsMustBeDeclared && n.push({
|
|
581
|
+
path: s,
|
|
582
|
+
message: `${i} references missing entity ${a}`
|
|
583
|
+
});
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
let c = Ze(i, o, a, r);
|
|
587
|
+
c && n.push({
|
|
588
|
+
path: s,
|
|
589
|
+
message: c
|
|
590
|
+
}), "on" in o && r.kind === "segment" && (o.t < 0 || o.t > 1) && n.push({
|
|
591
|
+
path: [...s, "t"],
|
|
592
|
+
message: `${i} must have t within [0, 1] on segment ${a}`
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
if (o.kind === "point") continue;
|
|
596
|
+
let c = qe(o), l = a.get(c);
|
|
597
|
+
l === void 0 ? a.set(c, i) : n.push({
|
|
598
|
+
path: s,
|
|
599
|
+
message: `${i} duplicates the geometry of ${l}`
|
|
600
|
+
});
|
|
601
|
+
}
|
|
602
|
+
for (let [t, r] of Object.entries(e.presentation)) {
|
|
603
|
+
if (!i(t)) {
|
|
604
|
+
n.push({
|
|
605
|
+
path: ["presentation", t],
|
|
606
|
+
message: `presentation entry for unknown entity ${t}`
|
|
607
|
+
});
|
|
608
|
+
continue;
|
|
609
|
+
}
|
|
610
|
+
r.measureLabel !== void 0 && U(e.entities, t)?.kind !== "angle" && n.push({
|
|
611
|
+
path: ["presentation", t],
|
|
612
|
+
message: `presentation entry for ${t} sets measureLabel, which only an angle has`
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
return n;
|
|
616
|
+
}
|
|
617
|
+
function $e(e, t) {
|
|
618
|
+
let n = [];
|
|
619
|
+
for (let [r, i] of Object.entries(e.entities)) {
|
|
620
|
+
let a = ["entities", r], o = U(t, r) !== void 0;
|
|
621
|
+
for (let s of V(i)) {
|
|
622
|
+
if (Object.prototype.hasOwnProperty.call(e.entities, s)) {
|
|
623
|
+
o && !U(t, s) && n.push({
|
|
624
|
+
path: a,
|
|
625
|
+
message: `${r} is declared by the exercise and cannot be defined on ${s}, which it does not declare`
|
|
626
|
+
});
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
let c = U(t, s);
|
|
630
|
+
if (!c) {
|
|
631
|
+
n.push({
|
|
632
|
+
path: a,
|
|
633
|
+
message: `${r} references missing entity ${s}`
|
|
634
|
+
});
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
637
|
+
let l = Ze(r, i, s, c);
|
|
638
|
+
l && n.push({
|
|
639
|
+
path: a,
|
|
640
|
+
message: l
|
|
641
|
+
}), !o && "on" in i && c.kind === "segment" && (i.t < 0 || i.t > 1) && n.push({
|
|
642
|
+
path: [...a, "t"],
|
|
643
|
+
message: `${r} must have t within [0, 1] on segment ${s}`
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
return n;
|
|
648
|
+
}
|
|
649
|
+
function et(e, t) {
|
|
650
|
+
let n = U(e.entities, t);
|
|
651
|
+
return n?.kind !== "point" || "intersectionOf" in n ? !1 : e.draggableEntityIds.includes(t);
|
|
652
|
+
}
|
|
653
|
+
function tt(e, t, n, r) {
|
|
654
|
+
return n.kind !== "point" || r.kind !== "point" ? "collision" : et(e, t) ? "at" in n ? "at" in r ? "override" : "collision" : !("on" in n) || !("on" in r) || r.on !== n.on || U(e.entities, n.on)?.kind === "segment" && !(r.t >= 0 && r.t <= 1) ? "collision" : "override" : "ignored";
|
|
655
|
+
}
|
|
656
|
+
function nt(e, t) {
|
|
657
|
+
let n = [];
|
|
658
|
+
for (let [r, i] of Object.entries(e.entities)) {
|
|
659
|
+
let e = U(t.entities, r);
|
|
660
|
+
e && tt(t, r, e, i) === "collision" && n.push({
|
|
661
|
+
path: ["entities", r],
|
|
662
|
+
message: e.kind === "point" && i.kind === "point" ? `${r} is a point the exercise declares, and an attempt may change only its position` : `${r} is already declared by the exercise as a ${e.kind}`
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
return n;
|
|
666
|
+
}
|
|
667
|
+
function rt(e, t, n, r = {}) {
|
|
668
|
+
let i = [], a = /* @__PURE__ */ new Set();
|
|
669
|
+
return e.forEach((e, o) => {
|
|
670
|
+
let s = [t, o], c = U(n.entities, e);
|
|
671
|
+
c ? r.pointsOnly && c.kind !== "point" && i.push({
|
|
672
|
+
path: s,
|
|
673
|
+
message: `${t} names ${e}, which is ${q(c.kind)}`
|
|
674
|
+
}) : i.push({
|
|
675
|
+
path: s,
|
|
676
|
+
message: `${t} names unknown entity ${e}`
|
|
677
|
+
}), a.has(e) && i.push({
|
|
678
|
+
path: s,
|
|
679
|
+
message: `duplicate ${t} entry: ${e}`
|
|
680
|
+
}), a.add(e);
|
|
681
|
+
}), i;
|
|
682
|
+
}
|
|
683
|
+
//#endregion
|
|
684
|
+
//#region src/schemas/objectTypeName.schema.ts
|
|
685
|
+
var J = t.enum([
|
|
686
|
+
"point",
|
|
687
|
+
"segment",
|
|
688
|
+
"line",
|
|
689
|
+
"circle",
|
|
690
|
+
"angle"
|
|
691
|
+
]), it = t.object({
|
|
692
|
+
id: G,
|
|
693
|
+
type: t.literal("angleBisector"),
|
|
694
|
+
objectType: J,
|
|
695
|
+
referenceAngleId: G,
|
|
696
|
+
toleranceDegrees: t.number().positive().max(90)
|
|
697
|
+
}).strict(), at = t.enum([
|
|
698
|
+
"acute",
|
|
699
|
+
"right",
|
|
700
|
+
"obtuse",
|
|
701
|
+
"straight",
|
|
702
|
+
"reflex"
|
|
703
|
+
]), ot = t.discriminatedUnion("kind", [t.object({
|
|
704
|
+
kind: t.literal("degrees"),
|
|
705
|
+
targetDegrees: t.number().min(0).lt(360),
|
|
706
|
+
toleranceDegrees: t.number().positive().max(180)
|
|
707
|
+
}).strict(), t.object({
|
|
708
|
+
kind: t.literal("type"),
|
|
709
|
+
angleType: at
|
|
710
|
+
}).strict()]), st = t.object({
|
|
711
|
+
id: G,
|
|
712
|
+
type: t.literal("angleMeasure"),
|
|
713
|
+
objectType: t.literal("angle"),
|
|
714
|
+
vertexPointId: G,
|
|
715
|
+
interpretation: t.enum(["directed", "undirected"]),
|
|
716
|
+
criterion: ot
|
|
717
|
+
}).strict(), ct = t.object({
|
|
718
|
+
id: G,
|
|
719
|
+
type: t.literal("create"),
|
|
720
|
+
objectType: J
|
|
721
|
+
}).strict(), lt = t.object({
|
|
722
|
+
id: G,
|
|
723
|
+
type: t.literal("givenAngle"),
|
|
724
|
+
angleId: G,
|
|
725
|
+
interpretation: t.enum(["directed", "undirected"]),
|
|
726
|
+
criterion: ot
|
|
727
|
+
}).strict(), ut = t.object({
|
|
728
|
+
id: G,
|
|
729
|
+
type: t.literal("midpoint"),
|
|
730
|
+
objectType: t.literal("point"),
|
|
731
|
+
referenceObjectId: G,
|
|
732
|
+
toleranceUnits: t.number().positive().finite()
|
|
733
|
+
}).strict(), dt = t.object({
|
|
734
|
+
id: G,
|
|
735
|
+
type: t.literal("parallel"),
|
|
736
|
+
objectType: J,
|
|
737
|
+
referenceObjectId: G,
|
|
738
|
+
throughPointId: G,
|
|
739
|
+
toleranceDegrees: t.number().positive().max(90)
|
|
740
|
+
}).strict(), ft = t.object({
|
|
741
|
+
id: G,
|
|
742
|
+
type: t.literal("perpendicular"),
|
|
743
|
+
objectType: J,
|
|
744
|
+
referenceObjectId: G,
|
|
745
|
+
throughPointId: G,
|
|
746
|
+
toleranceDegrees: t.number().positive().max(90)
|
|
747
|
+
}).strict(), pt = t.object({
|
|
748
|
+
id: G,
|
|
749
|
+
type: t.literal("segmentLength"),
|
|
750
|
+
objectType: t.literal("segment"),
|
|
751
|
+
targetLength: t.number().positive().finite(),
|
|
752
|
+
toleranceUnits: t.number().positive().finite()
|
|
753
|
+
}).strict(), mt = t.object({
|
|
754
|
+
id: G,
|
|
755
|
+
type: t.literal("throughPoints"),
|
|
756
|
+
objectType: J,
|
|
757
|
+
pointIds: t.array(G).min(1)
|
|
758
|
+
}).strict();
|
|
759
|
+
//#endregion
|
|
760
|
+
//#region src/schemas/goals/goalKindDeclaration.ts
|
|
761
|
+
function Y(e) {
|
|
762
|
+
return e === "segment" || e === "line";
|
|
763
|
+
}
|
|
764
|
+
var ht = () => [], gt = () => [];
|
|
765
|
+
function _t(e, t, n) {
|
|
766
|
+
let r = [];
|
|
767
|
+
Y(e.objectType) || r.push({
|
|
768
|
+
path: ["objectType"],
|
|
769
|
+
message: `${e.type} requires segment or line`
|
|
770
|
+
});
|
|
771
|
+
let i = t.definitionOf(e.referenceObjectId);
|
|
772
|
+
return i ? Y(i.kind) || r.push({
|
|
773
|
+
path: ["referenceObjectId"],
|
|
774
|
+
message: `${e.type} requires a segment or line reference, got ${i.kind} ${e.referenceObjectId}`
|
|
775
|
+
}) : r.push({
|
|
776
|
+
path: ["referenceObjectId"],
|
|
777
|
+
message: `unknown reference object ${e.referenceObjectId}`
|
|
778
|
+
}), t.definitionOf(e.throughPointId)?.kind !== "point" && r.push({
|
|
779
|
+
path: ["throughPointId"],
|
|
780
|
+
message: `unknown point ${e.throughPointId}`
|
|
781
|
+
}), n(i) && r.push({
|
|
782
|
+
path: ["throughPointId"],
|
|
783
|
+
message: `parallel through ${e.throughPointId} is degenerate: it defines ${e.referenceObjectId}`
|
|
784
|
+
}), r;
|
|
785
|
+
}
|
|
786
|
+
function vt({ interpretation: e, criterion: t }) {
|
|
787
|
+
return e === "undirected" ? t.kind === "degrees" && t.targetDegrees > 180 ? [{
|
|
788
|
+
path: ["criterion", "targetDegrees"],
|
|
789
|
+
message: "an undirected angle cannot measure more than 180 degrees"
|
|
790
|
+
}] : t.kind === "type" && t.angleType === "reflex" ? [{
|
|
791
|
+
path: ["criterion", "angleType"],
|
|
792
|
+
message: "an undirected angle cannot be reflex"
|
|
793
|
+
}] : [] : [];
|
|
794
|
+
}
|
|
795
|
+
function yt(e, t) {
|
|
796
|
+
let n = /* @__PURE__ */ new Set([e]), r = [e];
|
|
797
|
+
for (; r.length > 0;) {
|
|
798
|
+
let i = r.pop();
|
|
799
|
+
if (i === void 0) continue;
|
|
800
|
+
if (i !== e && t.isStudentDraggable(i)) return !0;
|
|
801
|
+
let a = t.definitionOf(i);
|
|
802
|
+
if (a) for (let e of V(a)) n.has(e) || (n.add(e), r.push(e));
|
|
803
|
+
}
|
|
804
|
+
return !1;
|
|
805
|
+
}
|
|
806
|
+
var bt = Object.freeze({
|
|
807
|
+
create: {
|
|
808
|
+
kind: "create",
|
|
809
|
+
schema: ct,
|
|
810
|
+
referencedGivenIds: ht,
|
|
811
|
+
crossReferenceIssues(e) {
|
|
812
|
+
return e.objectType === "angle" ? [{
|
|
813
|
+
path: ["objectType"],
|
|
814
|
+
message: "create does not support angle; use angleMeasure"
|
|
815
|
+
}] : [];
|
|
816
|
+
}
|
|
817
|
+
},
|
|
818
|
+
throughPoints: {
|
|
819
|
+
kind: "throughPoints",
|
|
820
|
+
schema: mt,
|
|
821
|
+
referencedGivenIds: (e) => e.pointIds,
|
|
822
|
+
crossReferenceIssues(e, t) {
|
|
823
|
+
let n = [];
|
|
824
|
+
Y(e.objectType) || n.push({
|
|
825
|
+
path: ["objectType"],
|
|
826
|
+
message: "throughPoints requires segment or line"
|
|
827
|
+
}), (e.pointIds.length !== 2 || new Set(e.pointIds).size !== 2) && n.push({
|
|
828
|
+
path: ["pointIds"],
|
|
829
|
+
message: "throughPoints requires two distinct points"
|
|
830
|
+
});
|
|
831
|
+
for (let r of e.pointIds) t.definitionOf(r)?.kind !== "point" && n.push({
|
|
832
|
+
path: ["pointIds"],
|
|
833
|
+
message: `unknown point ${r}`
|
|
834
|
+
});
|
|
835
|
+
return n;
|
|
836
|
+
}
|
|
837
|
+
},
|
|
838
|
+
perpendicular: {
|
|
839
|
+
kind: "perpendicular",
|
|
840
|
+
schema: ft,
|
|
841
|
+
referencedGivenIds: (e) => [e.throughPointId, e.referenceObjectId],
|
|
842
|
+
crossReferenceIssues: (e, t) => _t(e, t, () => !1)
|
|
843
|
+
},
|
|
844
|
+
parallel: {
|
|
845
|
+
kind: "parallel",
|
|
846
|
+
schema: dt,
|
|
847
|
+
referencedGivenIds: (e) => [e.throughPointId, e.referenceObjectId],
|
|
848
|
+
crossReferenceIssues: (e, t) => _t(e, t, (t) => t !== void 0 && Y(t.kind) && V(t).includes(e.throughPointId))
|
|
849
|
+
},
|
|
850
|
+
segmentLength: {
|
|
851
|
+
kind: "segmentLength",
|
|
852
|
+
schema: pt,
|
|
853
|
+
referencedGivenIds: ht,
|
|
854
|
+
crossReferenceIssues: gt
|
|
855
|
+
},
|
|
856
|
+
midpoint: {
|
|
857
|
+
kind: "midpoint",
|
|
858
|
+
schema: ut,
|
|
859
|
+
referencedGivenIds: (e) => [e.referenceObjectId],
|
|
860
|
+
crossReferenceIssues(e, t) {
|
|
861
|
+
let n = t.definitionOf(e.referenceObjectId);
|
|
862
|
+
return !n || n.kind !== "segment" ? [{
|
|
863
|
+
path: ["referenceObjectId"],
|
|
864
|
+
message: `midpoint requires a given segment, got ${e.referenceObjectId}`
|
|
865
|
+
}] : [];
|
|
866
|
+
}
|
|
867
|
+
},
|
|
868
|
+
angleMeasure: {
|
|
869
|
+
kind: "angleMeasure",
|
|
870
|
+
schema: st,
|
|
871
|
+
referencedGivenIds: (e) => [e.vertexPointId],
|
|
872
|
+
crossReferenceIssues(e, t) {
|
|
873
|
+
let n = [];
|
|
874
|
+
return t.definitionOf(e.vertexPointId)?.kind !== "point" && n.push({
|
|
875
|
+
path: ["vertexPointId"],
|
|
876
|
+
message: `unknown point ${e.vertexPointId}`
|
|
877
|
+
}), n.push(...vt(e)), n;
|
|
878
|
+
}
|
|
879
|
+
},
|
|
880
|
+
angleBisector: {
|
|
881
|
+
kind: "angleBisector",
|
|
882
|
+
schema: it,
|
|
883
|
+
referencedGivenIds: (e) => [e.referenceAngleId],
|
|
884
|
+
crossReferenceIssues(e, t) {
|
|
885
|
+
let n = [];
|
|
886
|
+
return Y(e.objectType) || n.push({
|
|
887
|
+
path: ["objectType"],
|
|
888
|
+
message: "angleBisector requires segment or line"
|
|
889
|
+
}), t.definitionOf(e.referenceAngleId)?.kind !== "angle" && n.push({
|
|
890
|
+
path: ["referenceAngleId"],
|
|
891
|
+
message: `angleBisector requires a given angle, got ${e.referenceAngleId}`
|
|
892
|
+
}), n;
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
givenAngle: {
|
|
896
|
+
kind: "givenAngle",
|
|
897
|
+
schema: lt,
|
|
898
|
+
referencedGivenIds: (e) => [e.angleId],
|
|
899
|
+
crossReferenceIssues(e, t) {
|
|
900
|
+
let n = [];
|
|
901
|
+
return t.definitionOf(e.angleId)?.kind === "angle" ? yt(e.angleId, t) || n.push({
|
|
902
|
+
path: ["angleId"],
|
|
903
|
+
message: `goal ${e.id} grades ${e.angleId}, and nothing it is built on can be dragged`
|
|
904
|
+
}) : n.push({
|
|
905
|
+
path: ["angleId"],
|
|
906
|
+
message: `givenAngle requires a given angle, got ${e.angleId}`
|
|
907
|
+
}), n.push(...vt(e)), n;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
});
|
|
911
|
+
function xt(e) {
|
|
912
|
+
return bt[e.type];
|
|
913
|
+
}
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/schemas/exerciseProjection.ts
|
|
916
|
+
function St(e) {
|
|
917
|
+
if (!("solution" in e)) return e;
|
|
918
|
+
let t = { ...e };
|
|
919
|
+
return delete t.solution, t;
|
|
920
|
+
}
|
|
921
|
+
//#endregion
|
|
922
|
+
//#region src/schemas/point.schema.ts
|
|
923
|
+
var Ct = t.object({
|
|
924
|
+
x: t.number().finite(),
|
|
925
|
+
y: t.number().finite()
|
|
926
|
+
}).strict();
|
|
927
|
+
t.object({
|
|
928
|
+
id: G,
|
|
929
|
+
type: t.literal("point"),
|
|
930
|
+
x: t.number().finite(),
|
|
931
|
+
y: t.number().finite(),
|
|
932
|
+
label: t.string().min(1).optional(),
|
|
933
|
+
draggable: t.boolean().optional()
|
|
934
|
+
}).strict();
|
|
935
|
+
//#endregion
|
|
936
|
+
//#region src/schemas/entityDefinition.schema.ts
|
|
937
|
+
var wt = t.object({
|
|
938
|
+
kind: t.literal("point"),
|
|
939
|
+
at: Ct
|
|
940
|
+
}).strict(), Tt = t.object({
|
|
941
|
+
kind: t.literal("point"),
|
|
942
|
+
on: G,
|
|
943
|
+
t: t.number().finite()
|
|
944
|
+
}).strict(), Et = t.object({
|
|
945
|
+
kind: t.literal("point"),
|
|
946
|
+
intersectionOf: t.tuple([G, G]).readonly(),
|
|
947
|
+
which: t.union([t.literal(0), t.literal(1)]).optional()
|
|
948
|
+
}).strict(), Dt = t.union([
|
|
949
|
+
wt,
|
|
950
|
+
Tt,
|
|
951
|
+
Et
|
|
952
|
+
]), X = t.tuple([G, G]).readonly(), Ot = t.tuple([
|
|
953
|
+
G,
|
|
954
|
+
G,
|
|
955
|
+
G
|
|
956
|
+
]).readonly(), kt = t.object({
|
|
957
|
+
kind: t.literal("segment"),
|
|
958
|
+
parents: X
|
|
959
|
+
}).strict(), At = t.object({
|
|
960
|
+
kind: t.literal("line"),
|
|
961
|
+
parents: X
|
|
962
|
+
}).strict(), jt = t.object({
|
|
963
|
+
kind: t.literal("circle"),
|
|
964
|
+
parents: X
|
|
965
|
+
}).strict(), Mt = t.object({
|
|
966
|
+
kind: t.literal("angle"),
|
|
967
|
+
parents: Ot
|
|
968
|
+
}).strict(), Nt = t.union([
|
|
969
|
+
Dt,
|
|
970
|
+
kt,
|
|
971
|
+
At,
|
|
972
|
+
jt,
|
|
973
|
+
Mt
|
|
974
|
+
]), Pt = t.enum(["implicit", "explicit"]), Z = t.object({
|
|
975
|
+
role: Pt,
|
|
976
|
+
label: t.string().min(1).optional(),
|
|
977
|
+
measureLabel: t.enum(["degrees"]).optional()
|
|
978
|
+
}).strict();
|
|
979
|
+
//#endregion
|
|
980
|
+
//#region src/schemas/migrate.ts
|
|
981
|
+
function Ft(e) {
|
|
982
|
+
let t = e.schemaVersion;
|
|
983
|
+
return typeof t == "number" && Number.isInteger(t) ? t : null;
|
|
984
|
+
}
|
|
985
|
+
function It(e, t, n) {
|
|
986
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return {
|
|
987
|
+
success: !1,
|
|
988
|
+
message: "expected an object"
|
|
989
|
+
};
|
|
990
|
+
let r = { ...e }, i = Ft(r);
|
|
991
|
+
if (i === null) return {
|
|
992
|
+
success: !1,
|
|
993
|
+
message: "missing or invalid schemaVersion"
|
|
994
|
+
};
|
|
995
|
+
if (i > n) return {
|
|
996
|
+
success: !1,
|
|
997
|
+
message: `schemaVersion ${i} is newer than the supported version ${n}`
|
|
998
|
+
};
|
|
999
|
+
let a = i;
|
|
1000
|
+
for (; a < n;) {
|
|
1001
|
+
let e = t.find((e) => e.from === a);
|
|
1002
|
+
if (!e) return {
|
|
1003
|
+
success: !1,
|
|
1004
|
+
message: `no migration from schemaVersion ${a} to ${n}`
|
|
1005
|
+
};
|
|
1006
|
+
if (e.to <= a) return {
|
|
1007
|
+
success: !1,
|
|
1008
|
+
message: `migration from ${a} does not advance the version`
|
|
1009
|
+
};
|
|
1010
|
+
try {
|
|
1011
|
+
r = {
|
|
1012
|
+
...e.migrate(r),
|
|
1013
|
+
schemaVersion: e.to
|
|
1014
|
+
};
|
|
1015
|
+
} catch (t) {
|
|
1016
|
+
return {
|
|
1017
|
+
success: !1,
|
|
1018
|
+
message: `migration from ${a} to ${e.to} failed: ${t instanceof Error ? t.message : String(t)}`
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
a = e.to;
|
|
1022
|
+
}
|
|
1023
|
+
return {
|
|
1024
|
+
success: !0,
|
|
1025
|
+
data: r
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
//#endregion
|
|
1029
|
+
//#region src/geometry/pointOrigin.ts
|
|
1030
|
+
function Lt(e) {
|
|
1031
|
+
return "x" in e;
|
|
1032
|
+
}
|
|
1033
|
+
function Rt(e) {
|
|
1034
|
+
return "onObject" in e;
|
|
1035
|
+
}
|
|
1036
|
+
//#endregion
|
|
1037
|
+
//#region src/geometry/v1Bridge.ts
|
|
1038
|
+
var zt = {
|
|
1039
|
+
segment: (e) => ({
|
|
1040
|
+
kind: "segment",
|
|
1041
|
+
parents: [e.from, e.to]
|
|
1042
|
+
}),
|
|
1043
|
+
line: (e) => ({
|
|
1044
|
+
kind: "line",
|
|
1045
|
+
parents: e.through
|
|
1046
|
+
}),
|
|
1047
|
+
circle: (e) => ({
|
|
1048
|
+
kind: "circle",
|
|
1049
|
+
parents: [e.center, e.through]
|
|
1050
|
+
})
|
|
1051
|
+
};
|
|
1052
|
+
function Bt(e) {
|
|
1053
|
+
let t = zt[e.type];
|
|
1054
|
+
return t(e);
|
|
1055
|
+
}
|
|
1056
|
+
function Vt(e) {
|
|
1057
|
+
return Lt(e) ? {
|
|
1058
|
+
kind: "point",
|
|
1059
|
+
at: e
|
|
1060
|
+
} : Rt(e) ? {
|
|
1061
|
+
kind: "point",
|
|
1062
|
+
on: e.onObject,
|
|
1063
|
+
t: e.t
|
|
1064
|
+
} : {
|
|
1065
|
+
kind: "point",
|
|
1066
|
+
intersectionOf: e.intersectionOf
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
function Ht(e) {
|
|
1070
|
+
return e.type === "point" ? {
|
|
1071
|
+
kind: "point",
|
|
1072
|
+
at: {
|
|
1073
|
+
x: e.x,
|
|
1074
|
+
y: e.y
|
|
1075
|
+
}
|
|
1076
|
+
} : Bt(e);
|
|
1077
|
+
}
|
|
1078
|
+
function Q(e, t) {
|
|
1079
|
+
if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`${t} is not an object`);
|
|
1080
|
+
return e;
|
|
1081
|
+
}
|
|
1082
|
+
function $(e, t) {
|
|
1083
|
+
let n = e[t];
|
|
1084
|
+
if (!Array.isArray(n)) throw Error(`${t} is not an array`);
|
|
1085
|
+
return n;
|
|
1086
|
+
}
|
|
1087
|
+
function Ut(e, t) {
|
|
1088
|
+
let n = e.id;
|
|
1089
|
+
if (typeof n != "string") throw Error(`${t}.id is not a string`);
|
|
1090
|
+
return Wt(n, `${t}.id`), n;
|
|
1091
|
+
}
|
|
1092
|
+
function Wt(e, t) {
|
|
1093
|
+
if (Ye(e)) throw Error(`${t}: ${Xe(e)}`);
|
|
1094
|
+
}
|
|
1095
|
+
function Gt(e, t, n, r) {
|
|
1096
|
+
if (e.has(t)) throw Error(`${n}.id duplicates ${r}`);
|
|
1097
|
+
e.add(t);
|
|
1098
|
+
}
|
|
1099
|
+
var Kt = [
|
|
1100
|
+
"segment",
|
|
1101
|
+
"line",
|
|
1102
|
+
"circle"
|
|
1103
|
+
];
|
|
1104
|
+
function qt(e, t) {
|
|
1105
|
+
let n = e.type;
|
|
1106
|
+
if (typeof n != "string" || !Kt.includes(n)) throw Error(`${t} has unknown type ${JSON.stringify(n)}`);
|
|
1107
|
+
return Bt(e);
|
|
1108
|
+
}
|
|
1109
|
+
function Jt(e, t) {
|
|
1110
|
+
let n = Q(t, `points.${e}`);
|
|
1111
|
+
if (!("x" in n) && !("onObject" in n) && !("intersectionOf" in n)) throw Error(`points.${e} is not a free, on-object or intersection origin`);
|
|
1112
|
+
return Vt(n);
|
|
1113
|
+
}
|
|
1114
|
+
var Yt = {
|
|
1115
|
+
from: 1,
|
|
1116
|
+
to: 2,
|
|
1117
|
+
migrate: (e) => {
|
|
1118
|
+
let t = Q(e.points, "points"), n = $(e, "constructions"), r = W(), i = W(), a = [...$(e, "constructedPointIds")], o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set();
|
|
1119
|
+
for (let [e, n] of Object.entries(t)) Wt(e, `points.${e}`), r[e] = Jt(e, n), i[e] = { role: "explicit" }, s.add(e), o.set(e, `points.${e}`);
|
|
1120
|
+
return n.forEach((e, t) => {
|
|
1121
|
+
let n = `constructions[${t}]`, c = Q(e, n), l = Ut(c, n);
|
|
1122
|
+
Gt(s, l, n, o.get(l) ?? n), o.set(l, n), r[l] = qt(c, n), i[l] = { role: "explicit" }, a.push(l);
|
|
1123
|
+
}), {
|
|
1124
|
+
schemaVersion: 2,
|
|
1125
|
+
entities: r,
|
|
1126
|
+
presentation: i,
|
|
1127
|
+
answerEntityIds: a
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
}, Xt = {
|
|
1131
|
+
from: 1,
|
|
1132
|
+
to: 2,
|
|
1133
|
+
migrate: (e) => {
|
|
1134
|
+
let t = $(e, "givens"), n = W(), r = W(), i = [], a = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
|
|
1135
|
+
t.forEach((e, t) => {
|
|
1136
|
+
let s = `givens[${t}]`, c = Q(e, s), l = Ut(c, s);
|
|
1137
|
+
if (Gt(a, l, s, o.get(l) ?? s), o.set(l, s), n[l] = c.type === "point" ? Ht(c) : qt(c, s), c.label !== void 0 && (r[l] = {
|
|
1138
|
+
role: "explicit",
|
|
1139
|
+
label: c.label
|
|
1140
|
+
}), c.draggable !== void 0) {
|
|
1141
|
+
if (typeof c.draggable != "boolean") throw Error(`${s}.draggable is not a boolean`);
|
|
1142
|
+
c.draggable && i.push(l);
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
let s = { ...e };
|
|
1146
|
+
return delete s.givens, {
|
|
1147
|
+
...s,
|
|
1148
|
+
schemaVersion: 2,
|
|
1149
|
+
entities: n,
|
|
1150
|
+
presentation: r,
|
|
1151
|
+
draggableEntityIds: i
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
}, Zt = 2, Qt = [Yt], $t = t.object({
|
|
1155
|
+
schemaVersion: t.literal(2),
|
|
1156
|
+
entities: K(Nt),
|
|
1157
|
+
presentation: K(Z),
|
|
1158
|
+
answerEntityIds: t.array(G)
|
|
1159
|
+
}).strict().superRefine((e, t) => {
|
|
1160
|
+
for (let n of Qe(e, { parentsMustBeDeclared: !1 })) t.addIssue({
|
|
1161
|
+
code: "custom",
|
|
1162
|
+
path: n.path,
|
|
1163
|
+
message: n.message
|
|
1164
|
+
});
|
|
1165
|
+
for (let n of rt(e.answerEntityIds, "answerEntityIds", e)) t.addIssue({
|
|
1166
|
+
code: "custom",
|
|
1167
|
+
path: n.path,
|
|
1168
|
+
message: n.message
|
|
1169
|
+
});
|
|
1170
|
+
});
|
|
1171
|
+
function en(e) {
|
|
1172
|
+
return It(e, Qt, 2);
|
|
1173
|
+
}
|
|
1174
|
+
//#endregion
|
|
1175
|
+
export { de as $, et as A, He as B, J as C, ae as Ct, Qe as D, $e as E, Ke as F, ke as G, Ue as H, qe as I, Ee as J, ye as K, We as L, U as M, Je as N, rt as O, Ge as P, be as Q, Be as R, it as S, oe as St, nt as T, r as Tt, Ie as U, Ve as V, L as W, w as X, ve as Y, ge as Z, dt as _, d as _t, Xt as a, m as at, ct as b, ie as bt, Nt as c, i as ct, xt as d, l as dt, g as et, bt as f, o as ft, ft as g, ne as gt, pt as h, s as ht, en as i, ue as it, G as j, K as k, Ct as l, te as lt, mt as m, c as mt, $t as n, le as nt, It as o, p as ot, Y as p, ee as pt, E as q, Zt as r, h as rt, Z as s, f as st, Qt as t, ce as tt, St as u, a as ut, ut as v, u as vt, tt as w, n as wt, st as x, se as xt, lt as y, re as yt, V as z };
|
|
1176
|
+
|
|
1177
|
+
//# sourceMappingURL=geometryState.schema-CKFPlX8j.js.map
|