@nakafa/aksara-contracts 8.1.0 → 8.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/math/boundary.d.ts +9 -0
  2. package/dist/math/boundary.js +81 -0
  3. package/dist/math/curve.d.ts +1 -0
  4. package/dist/math/curve.js +4 -2
  5. package/dist/math/formula/affine.d.ts +22 -0
  6. package/dist/math/formula/affine.js +79 -0
  7. package/dist/math/formula/contour.js +27 -12
  8. package/dist/math/object.d.ts +12 -0
  9. package/dist/math/object.js +11 -0
  10. package/dist/math/plane.d.ts +10 -0
  11. package/dist/math/plane.js +7 -1
  12. package/dist/math/space.d.ts +8 -0
  13. package/dist/math/space.js +5 -1
  14. package/dist/math/visual.d.ts +239 -212
  15. package/dist/visual/base/math.d.ts +78 -0
  16. package/dist/visual/base/math.js +31 -3
  17. package/dist/visual/base/media.d.ts +67 -0
  18. package/dist/visual/biology/bacteria.d.ts +268 -0
  19. package/dist/visual/biology/cell.d.ts +201 -0
  20. package/dist/visual/biology/climate.d.ts +201 -0
  21. package/dist/visual/biology/ecology.d.ts +268 -0
  22. package/dist/visual/biology/physiology.d.ts +201 -0
  23. package/dist/visual/biology/plant.d.ts +335 -0
  24. package/dist/visual/biology.d.ts +16 -16
  25. package/dist/visual/biology.js +2 -2
  26. package/dist/visual/card.d.ts +79 -1
  27. package/dist/visual/card.js +18 -2
  28. package/dist/visual/catalog.d.ts +14808 -28
  29. package/dist/visual/catalog.js +26 -0
  30. package/dist/visual/chemistry/atom.d.ts +203 -2
  31. package/dist/visual/chemistry/atom.js +2 -2
  32. package/dist/visual/chemistry/balance.d.ts +335 -0
  33. package/dist/visual/chemistry/bonding.d.ts +335 -0
  34. package/dist/visual/chemistry/discovery.d.ts +469 -0
  35. package/dist/visual/chemistry/electrochemistry.d.ts +134 -0
  36. package/dist/visual/chemistry/electron.d.ts +134 -0
  37. package/dist/visual/chemistry/laws.d.ts +268 -0
  38. package/dist/visual/chemistry/particles.d.ts +335 -0
  39. package/dist/visual/chemistry/periodic.d.ts +134 -0
  40. package/dist/visual/chemistry/rate.d.ts +67 -0
  41. package/dist/visual/chemistry/reaction.d.ts +201 -0
  42. package/dist/visual/chemistry/titration.d.ts +67 -0
  43. package/dist/visual/length.d.ts +79 -0
  44. package/dist/visual/length.js +37 -0
  45. package/dist/visual/mathematics/chance.d.ts +258 -0
  46. package/dist/visual/mathematics/chance.js +117 -0
  47. package/dist/visual/mathematics/chart.d.ts +67 -0
  48. package/dist/visual/mathematics/charts.d.ts +335 -0
  49. package/dist/visual/mathematics/function.d.ts +205 -4
  50. package/dist/visual/mathematics/function.js +4 -4
  51. package/dist/visual/mathematics/geometry.d.ts +1 -1
  52. package/dist/visual/mathematics/geometry.js +1 -1
  53. package/dist/visual/mathematics/numeral.d.ts +170 -0
  54. package/dist/visual/mathematics/numeral.js +85 -0
  55. package/dist/visual/physics/braking.d.ts +268 -0
  56. package/dist/visual/physics/circuit.d.ts +343 -0
  57. package/dist/visual/physics/circuit.js +86 -0
  58. package/dist/visual/physics/circular.d.ts +134 -0
  59. package/dist/visual/physics/dynamics.d.ts +579 -0
  60. package/dist/visual/physics/dynamics.js +134 -0
  61. package/dist/visual/physics/efficiency.d.ts +402 -0
  62. package/dist/visual/physics/electronics.d.ts +260 -0
  63. package/dist/visual/physics/electronics.js +71 -0
  64. package/dist/visual/physics/falling.d.ts +268 -0
  65. package/dist/visual/physics/field.d.ts +249 -0
  66. package/dist/visual/physics/field.js +60 -0
  67. package/dist/visual/physics/fluid.d.ts +336 -0
  68. package/dist/visual/physics/fluid.js +83 -0
  69. package/dist/visual/physics/force.d.ts +335 -0
  70. package/dist/visual/physics/gravity.d.ts +172 -0
  71. package/dist/visual/physics/gravity.js +47 -0
  72. package/dist/visual/physics/heat.d.ts +255 -0
  73. package/dist/visual/physics/heat.js +66 -0
  74. package/dist/visual/physics/instrument.d.ts +469 -0
  75. package/dist/visual/physics/light.d.ts +343 -0
  76. package/dist/visual/physics/light.js +90 -0
  77. package/dist/visual/physics/measurement.d.ts +268 -0
  78. package/dist/visual/physics/motion.d.ts +402 -0
  79. package/dist/visual/physics/nuclear.d.ts +258 -0
  80. package/dist/visual/physics/nuclear.js +69 -0
  81. package/dist/visual/physics/parabolic.d.ts +69 -2
  82. package/dist/visual/physics/parabolic.js +2 -2
  83. package/dist/visual/physics/position.d.ts +402 -0
  84. package/dist/visual/physics/power.d.ts +536 -0
  85. package/dist/visual/physics/precision.d.ts +469 -0
  86. package/dist/visual/physics/product.d.ts +268 -0
  87. package/dist/visual/physics/reading.d.ts +253 -0
  88. package/dist/visual/physics/reading.js +61 -0
  89. package/dist/visual/physics/record.d.ts +134 -0
  90. package/dist/visual/physics/relative.d.ts +201 -0
  91. package/dist/visual/physics/solar.d.ts +402 -0
  92. package/dist/visual/physics/vector.d.ts +335 -0
  93. package/dist/visual/physics/velocity.d.ts +469 -0
  94. package/dist/visual/physics/wave.d.ts +338 -0
  95. package/dist/visual/physics/wave.js +85 -0
  96. package/dist/visual/politics.d.ts +403 -1
  97. package/dist/visual/politics.js +1 -1
  98. package/package.json +1 -1
@@ -10,11 +10,11 @@ export declare function functionVisuals<E>(rich: RichSlot<E>): {
10
10
  BacterialGrowth: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
11
11
  readonly formulaType: Schema.optionalKey<Schema.Literals<readonly ["geometric", "exponential"]>>;
12
12
  readonly initialCount: Schema.optionalKey<Schema.Finite>;
13
- readonly labels: Schema.optionalKey<Schema.Struct<{
13
+ readonly labels: Schema.Struct<{
14
14
  readonly bacterial: Schema.optionalKey<Schema.Trimmed>;
15
- readonly description: Schema.optionalKey<RichSlot<E>>;
16
- readonly title: Schema.optionalKey<RichSlot<E>>;
17
- }>>;
15
+ readonly description: RichSlot<E>;
16
+ readonly title: RichSlot<E>;
17
+ }>;
18
18
  readonly maxGenerations: Schema.optionalKey<Schema.Int>;
19
19
  readonly ratio: Schema.optionalKey<Schema.Finite>;
20
20
  readonly timeInterval: Schema.optionalKey<Schema.Finite>;
@@ -22,6 +22,73 @@ export declare function functionVisuals<E>(rich: RichSlot<E>): {
22
22
  }>, "figure">;
23
23
  FunctionAndNonFunctionDiagram: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
24
24
  readonly description: RichSlot<E>;
25
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
26
+ readonly attrs: {
27
+ readonly latex: string;
28
+ };
29
+ readonly type: "mathInline";
30
+ } | {
31
+ readonly marks?: readonly [{
32
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
33
+ } | {
34
+ readonly attrs: {
35
+ readonly href: string;
36
+ };
37
+ readonly type: "link";
38
+ } | {
39
+ readonly attrs: {
40
+ readonly variant: "success" | "warning" | null;
41
+ };
42
+ readonly type: "highlight";
43
+ }, ...({
44
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
45
+ } | {
46
+ readonly attrs: {
47
+ readonly href: string;
48
+ };
49
+ readonly type: "link";
50
+ } | {
51
+ readonly attrs: {
52
+ readonly variant: "success" | "warning" | null;
53
+ };
54
+ readonly type: "highlight";
55
+ })[]];
56
+ readonly text: string;
57
+ readonly type: "text";
58
+ }, ...({
59
+ readonly attrs: {
60
+ readonly latex: string;
61
+ };
62
+ readonly type: "mathInline";
63
+ } | {
64
+ readonly marks?: readonly [{
65
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
66
+ } | {
67
+ readonly attrs: {
68
+ readonly href: string;
69
+ };
70
+ readonly type: "link";
71
+ } | {
72
+ readonly attrs: {
73
+ readonly variant: "success" | "warning" | null;
74
+ };
75
+ readonly type: "highlight";
76
+ }, ...({
77
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
78
+ } | {
79
+ readonly attrs: {
80
+ readonly href: string;
81
+ };
82
+ readonly type: "link";
83
+ } | {
84
+ readonly attrs: {
85
+ readonly variant: "success" | "warning" | null;
86
+ };
87
+ readonly type: "highlight";
88
+ })[]];
89
+ readonly text: string;
90
+ readonly type: "text";
91
+ })[]], E, never, never>>;
25
92
  readonly title: RichSlot<E>;
26
93
  }>, "markup">;
27
94
  FunctionAndNonFunctionRelationVisualizer: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
@@ -55,11 +122,145 @@ export declare function functionVisuals<E>(rich: RichSlot<E>): {
55
122
  }>, "figure">;
56
123
  FunctionMachine: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
57
124
  readonly description: RichSlot<E>;
125
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
126
+ readonly attrs: {
127
+ readonly latex: string;
128
+ };
129
+ readonly type: "mathInline";
130
+ } | {
131
+ readonly marks?: readonly [{
132
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
133
+ } | {
134
+ readonly attrs: {
135
+ readonly href: string;
136
+ };
137
+ readonly type: "link";
138
+ } | {
139
+ readonly attrs: {
140
+ readonly variant: "success" | "warning" | null;
141
+ };
142
+ readonly type: "highlight";
143
+ }, ...({
144
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
145
+ } | {
146
+ readonly attrs: {
147
+ readonly href: string;
148
+ };
149
+ readonly type: "link";
150
+ } | {
151
+ readonly attrs: {
152
+ readonly variant: "success" | "warning" | null;
153
+ };
154
+ readonly type: "highlight";
155
+ })[]];
156
+ readonly text: string;
157
+ readonly type: "text";
158
+ }, ...({
159
+ readonly attrs: {
160
+ readonly latex: string;
161
+ };
162
+ readonly type: "mathInline";
163
+ } | {
164
+ readonly marks?: readonly [{
165
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
166
+ } | {
167
+ readonly attrs: {
168
+ readonly href: string;
169
+ };
170
+ readonly type: "link";
171
+ } | {
172
+ readonly attrs: {
173
+ readonly variant: "success" | "warning" | null;
174
+ };
175
+ readonly type: "highlight";
176
+ }, ...({
177
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
178
+ } | {
179
+ readonly attrs: {
180
+ readonly href: string;
181
+ };
182
+ readonly type: "link";
183
+ } | {
184
+ readonly attrs: {
185
+ readonly variant: "success" | "warning" | null;
186
+ };
187
+ readonly type: "highlight";
188
+ })[]];
189
+ readonly text: string;
190
+ readonly type: "text";
191
+ })[]], E, never, never>>;
58
192
  readonly title: RichSlot<E>;
59
193
  readonly inputLabel: Schema.Trimmed;
60
194
  }>, "figure">;
61
195
  InverseFunctionIllustration: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
62
196
  readonly description: RichSlot<E>;
197
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
198
+ readonly attrs: {
199
+ readonly latex: string;
200
+ };
201
+ readonly type: "mathInline";
202
+ } | {
203
+ readonly marks?: readonly [{
204
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
205
+ } | {
206
+ readonly attrs: {
207
+ readonly href: string;
208
+ };
209
+ readonly type: "link";
210
+ } | {
211
+ readonly attrs: {
212
+ readonly variant: "success" | "warning" | null;
213
+ };
214
+ readonly type: "highlight";
215
+ }, ...({
216
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
217
+ } | {
218
+ readonly attrs: {
219
+ readonly href: string;
220
+ };
221
+ readonly type: "link";
222
+ } | {
223
+ readonly attrs: {
224
+ readonly variant: "success" | "warning" | null;
225
+ };
226
+ readonly type: "highlight";
227
+ })[]];
228
+ readonly text: string;
229
+ readonly type: "text";
230
+ }, ...({
231
+ readonly attrs: {
232
+ readonly latex: string;
233
+ };
234
+ readonly type: "mathInline";
235
+ } | {
236
+ readonly marks?: readonly [{
237
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
238
+ } | {
239
+ readonly attrs: {
240
+ readonly href: string;
241
+ };
242
+ readonly type: "link";
243
+ } | {
244
+ readonly attrs: {
245
+ readonly variant: "success" | "warning" | null;
246
+ };
247
+ readonly type: "highlight";
248
+ }, ...({
249
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
250
+ } | {
251
+ readonly attrs: {
252
+ readonly href: string;
253
+ };
254
+ readonly type: "link";
255
+ } | {
256
+ readonly attrs: {
257
+ readonly variant: "success" | "warning" | null;
258
+ };
259
+ readonly type: "highlight";
260
+ })[]];
261
+ readonly text: string;
262
+ readonly type: "text";
263
+ })[]], E, never, never>>;
63
264
  readonly title: RichSlot<E>;
64
265
  readonly content: Schema.Struct<{
65
266
  readonly input: RichSlot<E>;
@@ -57,11 +57,11 @@ function bacterialGrowth(rich) {
57
57
  return figure(Schema.Struct({
58
58
  formulaType: Schema.optionalKey(Schema.Literals(GROWTH_FORMULAS)),
59
59
  initialCount: Schema.optionalKey(Schema.Finite),
60
- labels: Schema.optionalKey(Schema.Struct({
60
+ labels: Schema.Struct({
61
61
  bacterial: Schema.optionalKey(TextSchema),
62
- description: Schema.optionalKey(rich),
63
- title: Schema.optionalKey(rich),
64
- })),
62
+ description: rich,
63
+ title: rich,
64
+ }),
65
65
  maxGenerations: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
66
66
  ratio: Schema.optionalKey(Schema.Finite),
67
67
  timeInterval: Schema.optionalKey(Schema.Finite),
@@ -6,7 +6,7 @@ import type { RichSlot } from "#contracts/visual/card";
6
6
  */
7
7
  export declare function geometryVisuals<E>(rich: RichSlot<E>): {
8
8
  QuadraticEquationReadingRoomProblem: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
9
- readonly description: Schema.optionalKey<RichSlot<E>>;
9
+ readonly description: RichSlot<E>;
10
10
  readonly heightLabel: RichSlot<E>;
11
11
  readonly widthLabel: RichSlot<E>;
12
12
  }>, "figure">;
@@ -3,7 +3,7 @@ import { figure } from "#contracts/visual/entry";
3
3
  /** Props of `QuadraticEquationReadingRoomProblem`: a room whose sides are unknown. */
4
4
  function readingRoom(rich) {
5
5
  return figure(Schema.Struct({
6
- description: Schema.optionalKey(rich),
6
+ description: rich,
7
7
  heightLabel: rich,
8
8
  widthLabel: rich,
9
9
  }));
@@ -0,0 +1,170 @@
1
+ import { Schema } from "effect";
2
+ import { type RichSlot } from "#contracts/visual/card";
3
+ /** The place-value labs, where a number is written in a base. */
4
+ export declare function numeralVisuals<E>(rich: RichSlot<E>): {
5
+ AbacusBaseLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
6
+ readonly description: RichSlot<E>;
7
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
8
+ readonly attrs: {
9
+ readonly latex: string;
10
+ };
11
+ readonly type: "mathInline";
12
+ } | {
13
+ readonly marks?: readonly [{
14
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
15
+ } | {
16
+ readonly attrs: {
17
+ readonly href: string;
18
+ };
19
+ readonly type: "link";
20
+ } | {
21
+ readonly attrs: {
22
+ readonly variant: "success" | "warning" | null;
23
+ };
24
+ readonly type: "highlight";
25
+ }, ...({
26
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
27
+ } | {
28
+ readonly attrs: {
29
+ readonly href: string;
30
+ };
31
+ readonly type: "link";
32
+ } | {
33
+ readonly attrs: {
34
+ readonly variant: "success" | "warning" | null;
35
+ };
36
+ readonly type: "highlight";
37
+ })[]];
38
+ readonly text: string;
39
+ readonly type: "text";
40
+ }, ...({
41
+ readonly attrs: {
42
+ readonly latex: string;
43
+ };
44
+ readonly type: "mathInline";
45
+ } | {
46
+ readonly marks?: readonly [{
47
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
48
+ } | {
49
+ readonly attrs: {
50
+ readonly href: string;
51
+ };
52
+ readonly type: "link";
53
+ } | {
54
+ readonly attrs: {
55
+ readonly variant: "success" | "warning" | null;
56
+ };
57
+ readonly type: "highlight";
58
+ }, ...({
59
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
60
+ } | {
61
+ readonly attrs: {
62
+ readonly href: string;
63
+ };
64
+ readonly type: "link";
65
+ } | {
66
+ readonly attrs: {
67
+ readonly variant: "success" | "warning" | null;
68
+ };
69
+ readonly type: "highlight";
70
+ })[]];
71
+ readonly text: string;
72
+ readonly type: "text";
73
+ })[]], E, never, never>>;
74
+ readonly title: RichSlot<E>;
75
+ readonly bases: Schema.NonEmptyArray<Schema.Int>;
76
+ readonly value: Schema.Int;
77
+ readonly labels: Schema.Struct<{
78
+ readonly base: Schema.Trimmed;
79
+ readonly decimal: RichSlot<E>;
80
+ readonly digits: RichSlot<E>;
81
+ readonly expanded: RichSlot<E>;
82
+ readonly value: Schema.Trimmed;
83
+ readonly viewLabel: Schema.Trimmed;
84
+ }>;
85
+ readonly showReadout: Schema.optionalKey<Schema.Boolean>;
86
+ }>, "figure">;
87
+ BinaryLampLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
88
+ readonly description: RichSlot<E>;
89
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
90
+ readonly attrs: {
91
+ readonly latex: string;
92
+ };
93
+ readonly type: "mathInline";
94
+ } | {
95
+ readonly marks?: readonly [{
96
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
97
+ } | {
98
+ readonly attrs: {
99
+ readonly href: string;
100
+ };
101
+ readonly type: "link";
102
+ } | {
103
+ readonly attrs: {
104
+ readonly variant: "success" | "warning" | null;
105
+ };
106
+ readonly type: "highlight";
107
+ }, ...({
108
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
109
+ } | {
110
+ readonly attrs: {
111
+ readonly href: string;
112
+ };
113
+ readonly type: "link";
114
+ } | {
115
+ readonly attrs: {
116
+ readonly variant: "success" | "warning" | null;
117
+ };
118
+ readonly type: "highlight";
119
+ })[]];
120
+ readonly text: string;
121
+ readonly type: "text";
122
+ }, ...({
123
+ readonly attrs: {
124
+ readonly latex: string;
125
+ };
126
+ readonly type: "mathInline";
127
+ } | {
128
+ readonly marks?: readonly [{
129
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
130
+ } | {
131
+ readonly attrs: {
132
+ readonly href: string;
133
+ };
134
+ readonly type: "link";
135
+ } | {
136
+ readonly attrs: {
137
+ readonly variant: "success" | "warning" | null;
138
+ };
139
+ readonly type: "highlight";
140
+ }, ...({
141
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
142
+ } | {
143
+ readonly attrs: {
144
+ readonly href: string;
145
+ };
146
+ readonly type: "link";
147
+ } | {
148
+ readonly attrs: {
149
+ readonly variant: "success" | "warning" | null;
150
+ };
151
+ readonly type: "highlight";
152
+ })[]];
153
+ readonly text: string;
154
+ readonly type: "text";
155
+ })[]], E, never, never>>;
156
+ readonly title: RichSlot<E>;
157
+ readonly bits: Schema.Int;
158
+ readonly value: Schema.Int;
159
+ readonly labels: Schema.Struct<{
160
+ readonly binary: RichSlot<E>;
161
+ readonly decimal: RichSlot<E>;
162
+ readonly grouped: RichSlot<E>;
163
+ readonly grouping: Schema.Trimmed;
164
+ readonly groups: Schema.$Record<Schema.Literals<readonly ["none", "pairs", "triples"]>, Schema.Trimmed>;
165
+ readonly value: Schema.Trimmed;
166
+ readonly viewLabel: Schema.Trimmed;
167
+ }>;
168
+ readonly showReadout: Schema.optionalKey<Schema.Boolean>;
169
+ }>, "figure">;
170
+ };
@@ -0,0 +1,85 @@
1
+ import { Array as Arr, Schema } from "effect";
2
+ import { byIds, cardFields, TextSchema, } from "#contracts/visual/card";
3
+ import { answerAt, figure } from "#contracts/visual/entry";
4
+ /** How many places the spike abacus has: b^3, b^2, b and 1. */
5
+ const ABACUS_PLACES = 4;
6
+ /** A base the spike abacus can count in: at most nine beads fit a spike. */
7
+ const AbacusBaseSchema = Schema.Int.check(Schema.isBetween({ maximum: 10, minimum: 2 }));
8
+ /** The bases a spike abacus offers and the number it starts from, in the first base. */
9
+ const AbacusStartSchema = Schema.Struct({
10
+ bases: Schema.NonEmptyArray(AbacusBaseSchema),
11
+ value: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
12
+ });
13
+ /** Whether each base is offered once and the first base's spikes hold the number. */
14
+ function fitsAbacus({ bases, value }) {
15
+ const [first] = bases;
16
+ return (Arr.dedupe(bases).length === bases.length &&
17
+ value <= first ** ABACUS_PLACES - 1);
18
+ }
19
+ /**
20
+ * Props of `AbacusBaseLab`: a classroom spike abacus whose four spikes hold
21
+ * the digits of a number in the base the learner picks, starting from
22
+ * `value` in the first of `bases`. With `showReadout`, the slider shows the
23
+ * number and the footer reads its numeral, its expanded form and its value
24
+ * in base ten, so it is answer state.
25
+ */
26
+ function abacusBaseLab(rich) {
27
+ return figure(Schema.Struct({
28
+ ...cardFields(rich),
29
+ ...AbacusStartSchema.fields,
30
+ labels: Schema.Struct({
31
+ base: TextSchema,
32
+ decimal: rich,
33
+ digits: rich,
34
+ expanded: rich,
35
+ value: TextSchema,
36
+ viewLabel: TextSchema,
37
+ }),
38
+ showReadout: Schema.optionalKey(Schema.Boolean),
39
+ }).check(Schema.makeFilter(fitsAbacus, {
40
+ message: "Expected each base once and a number the first base's four spikes can hold.",
41
+ })), answerAt(["showReadout"]));
42
+ }
43
+ /** How a row of bits can be read: one by one, in pairs for base four, in threes for base eight. */
44
+ const BIT_GROUPINGS = ["none", "pairs", "triples"];
45
+ /** The lamps of a binary lamp panel and the number it starts from. */
46
+ const LampStartSchema = Schema.Struct({
47
+ bits: Schema.Int.check(Schema.isBetween({ maximum: 8, minimum: 4 })),
48
+ value: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
49
+ });
50
+ /** Whether the lamps can show the number. */
51
+ function fitsLamps({ bits, value }) {
52
+ return value <= 2 ** bits - 1;
53
+ }
54
+ /**
55
+ * Props of `BinaryLampLab`: a counting panel whose row of `bits` lamps shows
56
+ * `value` in base two, read one by one, in pairs for base four, or in threes
57
+ * for base eight. With `showReadout`, the slider shows the number, each group
58
+ * shows its digit, and the footer reads the numeral in base two, the grouped
59
+ * reading and the value in base ten, so it is answer state.
60
+ */
61
+ function binaryLampLab(rich) {
62
+ return figure(Schema.Struct({
63
+ ...cardFields(rich),
64
+ ...LampStartSchema.fields,
65
+ labels: Schema.Struct({
66
+ binary: rich,
67
+ decimal: rich,
68
+ grouped: rich,
69
+ grouping: TextSchema,
70
+ groups: byIds(BIT_GROUPINGS, TextSchema),
71
+ value: TextSchema,
72
+ viewLabel: TextSchema,
73
+ }),
74
+ showReadout: Schema.optionalKey(Schema.Boolean),
75
+ }).check(Schema.makeFilter(fitsLamps, {
76
+ message: "Expected a number the row of lamps can show.",
77
+ })), answerAt(["showReadout"]));
78
+ }
79
+ /** The place-value labs, where a number is written in a base. */
80
+ export function numeralVisuals(rich) {
81
+ return {
82
+ AbacusBaseLab: abacusBaseLab(rich),
83
+ BinaryLampLab: binaryLampLab(rich),
84
+ };
85
+ }