@nakafa/aksara-contracts 8.10.0 → 8.13.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 (79) hide show
  1. package/dist/visual/biology/binomial.d.ts +139 -0
  2. package/dist/visual/biology/binomial.js +46 -0
  3. package/dist/visual/biology/bone.d.ts +141 -0
  4. package/dist/visual/biology/bone.js +46 -0
  5. package/dist/visual/biology/chromosome.d.ts +139 -0
  6. package/dist/visual/biology/chromosome.js +42 -0
  7. package/dist/visual/biology/control.d.ts +17 -0
  8. package/dist/visual/biology/control.js +21 -0
  9. package/dist/visual/biology/denature.d.ts +159 -0
  10. package/dist/visual/biology/denature.js +74 -0
  11. package/dist/visual/biology/drawing.d.ts +151 -0
  12. package/dist/visual/biology/drawing.js +69 -0
  13. package/dist/visual/biology/enzyme.d.ts +145 -0
  14. package/dist/visual/biology/enzyme.js +54 -0
  15. package/dist/visual/biology/equipment.d.ts +140 -0
  16. package/dist/visual/biology/equipment.js +64 -0
  17. package/dist/visual/biology/gametogenesis.d.ts +145 -0
  18. package/dist/visual/biology/gametogenesis.js +83 -0
  19. package/dist/visual/biology/implantation.d.ts +138 -0
  20. package/dist/visual/biology/implantation.js +44 -0
  21. package/dist/visual/biology/joint.d.ts +140 -0
  22. package/dist/visual/biology/joint.js +47 -0
  23. package/dist/visual/biology/key.d.ts +141 -0
  24. package/dist/visual/biology/key.js +58 -0
  25. package/dist/visual/biology/kingdom.d.ts +142 -0
  26. package/dist/visual/biology/kingdom.js +82 -0
  27. package/dist/visual/biology/lactase.d.ts +147 -0
  28. package/dist/visual/biology/lactase.js +48 -0
  29. package/dist/visual/biology/leaf.d.ts +436 -0
  30. package/dist/visual/biology/leaf.js +151 -0
  31. package/dist/visual/biology/limb.d.ts +139 -0
  32. package/dist/visual/biology/limb.js +44 -0
  33. package/dist/visual/biology/lipid.d.ts +144 -0
  34. package/dist/visual/biology/lipid.js +43 -0
  35. package/dist/visual/biology/locomotion.d.ts +141 -0
  36. package/dist/visual/biology/locomotion.js +48 -0
  37. package/dist/visual/biology/menstrual.d.ts +148 -0
  38. package/dist/visual/biology/menstrual.js +65 -0
  39. package/dist/visual/biology/metamorphosis.d.ts +140 -0
  40. package/dist/visual/biology/metamorphosis.js +34 -0
  41. package/dist/visual/biology/placenta.d.ts +139 -0
  42. package/dist/visual/biology/placenta.js +52 -0
  43. package/dist/visual/biology/planes.d.ts +145 -0
  44. package/dist/visual/biology/planes.js +62 -0
  45. package/dist/visual/biology/protein.d.ts +142 -0
  46. package/dist/visual/biology/protein.js +41 -0
  47. package/dist/visual/biology/saturation.d.ts +149 -0
  48. package/dist/visual/biology/saturation.js +40 -0
  49. package/dist/visual/biology/secretion.d.ts +149 -0
  50. package/dist/visual/biology/secretion.js +79 -0
  51. package/dist/visual/biology/spill.d.ts +165 -0
  52. package/dist/visual/biology/spill.js +58 -0
  53. package/dist/visual/biology/sugar.d.ts +152 -0
  54. package/dist/visual/biology/sugar.js +59 -0
  55. package/dist/visual/biology/taxon.d.ts +138 -0
  56. package/dist/visual/biology/taxon.js +50 -0
  57. package/dist/visual/biology/tissue.d.ts +424 -0
  58. package/dist/visual/biology/tissue.js +140 -0
  59. package/dist/visual/biology/twins.d.ts +144 -0
  60. package/dist/visual/biology/twins.js +60 -0
  61. package/dist/visual/biology/vernacular.d.ts +141 -0
  62. package/dist/visual/biology/vernacular.js +57 -0
  63. package/dist/visual/biology/vertebra.d.ts +141 -0
  64. package/dist/visual/biology/vertebra.js +59 -0
  65. package/dist/visual/biology/waste.d.ts +140 -0
  66. package/dist/visual/biology/waste.js +57 -0
  67. package/dist/visual/biology/water.d.ts +152 -0
  68. package/dist/visual/biology/water.js +54 -0
  69. package/dist/visual/card.d.ts +11 -0
  70. package/dist/visual/card.js +17 -1
  71. package/dist/visual/catalog.d.ts +6886 -754
  72. package/dist/visual/catalog.js +72 -0
  73. package/dist/visual/chemistry/equilibrium.d.ts +449 -0
  74. package/dist/visual/chemistry/equilibrium.js +135 -0
  75. package/dist/visual/mathematics/argument.d.ts +226 -0
  76. package/dist/visual/mathematics/argument.js +150 -0
  77. package/dist/visual/mathematics/counterexample.d.ts +340 -0
  78. package/dist/visual/mathematics/counterexample.js +157 -0
  79. package/package.json +1 -1
@@ -0,0 +1,135 @@
1
+ import { Schema } from "effect";
2
+ import { byIds, byPickedIds, cardFields, namesEach, TextSchema, } from "#contracts/visual/card";
3
+ import { answerAt, figure } from "#contracts/visual/entry";
4
+ /** A strictly positive finite physical quantity. */
5
+ const PositiveSchema = Schema.Finite.check(Schema.isGreaterThan(0));
6
+ /** A non-negative finite concentration or rate parameter. */
7
+ const NonNegativeSchema = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
8
+ /** A slider range with minimum below maximum and starting value inside bounds. */
9
+ const SliderSchema = Schema.Struct({
10
+ max: PositiveSchema,
11
+ min: NonNegativeSchema,
12
+ value: NonNegativeSchema,
13
+ }).check(Schema.makeFilter(({ max, min, value }) => min < max && min <= value && value <= max, {
14
+ message: "Expected a slider range whose minimum is below its maximum, with the starting value between them.",
15
+ }));
16
+ const DYNAMIC_SYSTEMS = [
17
+ "generic",
18
+ "nitrogenDioxide",
19
+ "hydrogenIodide",
20
+ ];
21
+ const LE_CHATELIER_SYSTEMS = ["haber", "nitrogenDioxide", "contact"];
22
+ const DISTURBANCES = [
23
+ "pressure",
24
+ "temperature",
25
+ "concentration",
26
+ "catalyst",
27
+ ];
28
+ /**
29
+ * Props of `DynamicEquilibriumLab`: a 3D reversible particle reactor showing
30
+ * forward and reverse reactions occurring simultaneously as forward rate and
31
+ * reverse rate converge to a nonzero steady value while concentrations stay
32
+ * constant. The equilibrium composition readout shows only when
33
+ * `labels.equilibrium` names it.
34
+ */
35
+ function dynamicEquilibriumLab(rich) {
36
+ return figure(Schema.Struct({
37
+ ...cardFields(rich),
38
+ forwardRate: SliderSchema,
39
+ initialReactant: SliderSchema,
40
+ labels: Schema.Struct({
41
+ equilibrium: Schema.optionalKey(rich),
42
+ forwardRate: TextSchema,
43
+ initial: TextSchema,
44
+ rateForward: rich,
45
+ rateReverse: rich,
46
+ reverseRate: TextSchema,
47
+ state: rich,
48
+ states: byIds(["approaching", "balanced"], TextSchema),
49
+ system: TextSchema,
50
+ systems: byPickedIds(DYNAMIC_SYSTEMS, Schema.Struct({
51
+ equation: rich,
52
+ name: TextSchema,
53
+ product: TextSchema,
54
+ reactant: TextSchema,
55
+ })),
56
+ view: TextSchema,
57
+ }),
58
+ reverseRate: SliderSchema,
59
+ systems: Schema.NonEmptyArray(Schema.Literals(DYNAMIC_SYSTEMS)).check(Schema.isUnique()),
60
+ }).check(Schema.makeFilter(({ labels, systems }) => namesEach(systems, labels.systems), {
61
+ message: "Expected a name and species labels for every reversible system shown, and no other.",
62
+ })), answerAt(["labels", "equilibrium"]));
63
+ }
64
+ /**
65
+ * Props of `EquilibriumQuotientLab`: a 3D reaction vessel coupled to a live
66
+ * reaction quotient scale comparing Q_c against K_c so learners see whether a
67
+ * mixture shifts forward, stays at equilibrium, or shifts in reverse. The
68
+ * quotient and direction readouts are optional answer state.
69
+ */
70
+ function equilibriumQuotientLab(rich) {
71
+ return figure(Schema.Struct({
72
+ ...cardFields(rich),
73
+ kc: PositiveSchema,
74
+ labels: Schema.Struct({
75
+ direction: Schema.optionalKey(rich),
76
+ directions: byIds(["forward", "equilibrium", "reverse"], rich),
77
+ equation: rich,
78
+ kc: rich,
79
+ product: TextSchema,
80
+ quotient: Schema.optionalKey(rich),
81
+ reactant: TextSchema,
82
+ view: TextSchema,
83
+ }),
84
+ product: SliderSchema,
85
+ reactant: SliderSchema,
86
+ stoichiometry: Schema.Literals(["oneToOne", "oneToTwo", "twoToTwo"]),
87
+ }), answerAt(["labels", "direction"], ["labels", "quotient"]));
88
+ }
89
+ /**
90
+ * Props of `LeChatelierLab`: a 3D piston-cylinder gas reactor with heating,
91
+ * cooling, species injection, and catalyst controls for gas equilibria such as
92
+ * Haber-Bosch and nitrogen dioxide dimerisation. The shift direction and K_c
93
+ * response readouts show only when named so questions can withhold them.
94
+ */
95
+ function leChatelierLab(rich) {
96
+ return figure(Schema.Struct({
97
+ ...cardFields(rich),
98
+ disturbances: Schema.NonEmptyArray(Schema.Literals(DISTURBANCES)).check(Schema.isUnique()),
99
+ labels: Schema.Struct({
100
+ catalyst: TextSchema,
101
+ concentration: TextSchema,
102
+ disturbance: TextSchema,
103
+ disturbances: byPickedIds(DISTURBANCES, TextSchema),
104
+ kcChange: Schema.optionalKey(rich),
105
+ kcStates: byIds(["increases", "constant", "decreases"], TextSchema),
106
+ pressure: TextSchema,
107
+ shift: Schema.optionalKey(rich),
108
+ shifts: byIds(["forward", "none", "reverse"], rich),
109
+ system: TextSchema,
110
+ systems: byPickedIds(LE_CHATELIER_SYSTEMS, Schema.Struct({
111
+ enthalpy: TextSchema,
112
+ equation: rich,
113
+ name: TextSchema,
114
+ })),
115
+ temperature: TextSchema,
116
+ view: TextSchema,
117
+ yield: rich,
118
+ }),
119
+ systems: Schema.NonEmptyArray(Schema.Literals(LE_CHATELIER_SYSTEMS)).check(Schema.isUnique()),
120
+ }).check(Schema.makeFilter(({ disturbances, labels, systems }) => namesEach(systems, labels.systems) &&
121
+ namesEach(disturbances, labels.disturbances), {
122
+ message: "Expected labels for every equilibrium system and disturbance shown, and no other.",
123
+ })), answerAt(["labels", "shift"], ["labels", "kcChange"]));
124
+ }
125
+ /**
126
+ * Chemical equilibrium labs covering dynamic reversible kinetics, reaction
127
+ * quotient comparisons against K_c, and Le Chatelier disturbances.
128
+ */
129
+ export function equilibriumVisuals(rich) {
130
+ return {
131
+ DynamicEquilibriumLab: dynamicEquilibriumLab(rich),
132
+ EquilibriumQuotientLab: equilibriumQuotientLab(rich),
133
+ LeChatelierLab: leChatelierLab(rich),
134
+ };
135
+ }
@@ -0,0 +1,226 @@
1
+ import { Schema } from "effect";
2
+ import type { RichSlot } from "#contracts/visual/card";
3
+ /** The argument labs, where an argument is checked for its form. */
4
+ export declare function argumentVisuals<E>(rich: RichSlot<E>): {
5
+ ArgumentChainLab: import("#contracts/visual/entry").VisualEntry<Schema.Struct<{
6
+ readonly description: RichSlot<E>;
7
+ readonly footer: Schema.optionalKey<Schema.Codec<readonly [{
8
+ readonly marks?: readonly [{
9
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
10
+ } | {
11
+ readonly attrs: {
12
+ readonly href: string;
13
+ };
14
+ readonly type: "link";
15
+ } | {
16
+ readonly attrs: {
17
+ readonly variant: "success" | "warning" | null;
18
+ };
19
+ readonly type: "highlight";
20
+ }, ...({
21
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
22
+ } | {
23
+ readonly attrs: {
24
+ readonly href: string;
25
+ };
26
+ readonly type: "link";
27
+ } | {
28
+ readonly attrs: {
29
+ readonly variant: "success" | "warning" | null;
30
+ };
31
+ readonly type: "highlight";
32
+ })[]];
33
+ readonly text: string;
34
+ readonly type: "text";
35
+ } | {
36
+ readonly attrs: {
37
+ readonly latex: string;
38
+ };
39
+ readonly marks?: readonly [{
40
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
41
+ } | {
42
+ readonly attrs: {
43
+ readonly href: string;
44
+ };
45
+ readonly type: "link";
46
+ } | {
47
+ readonly attrs: {
48
+ readonly variant: "success" | "warning" | null;
49
+ };
50
+ readonly type: "highlight";
51
+ }, ...({
52
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
53
+ } | {
54
+ readonly attrs: {
55
+ readonly href: string;
56
+ };
57
+ readonly type: "link";
58
+ } | {
59
+ readonly attrs: {
60
+ readonly variant: "success" | "warning" | null;
61
+ };
62
+ readonly type: "highlight";
63
+ })[]];
64
+ readonly type: "mathInline";
65
+ }, ...({
66
+ readonly marks?: readonly [{
67
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
68
+ } | {
69
+ readonly attrs: {
70
+ readonly href: string;
71
+ };
72
+ readonly type: "link";
73
+ } | {
74
+ readonly attrs: {
75
+ readonly variant: "success" | "warning" | null;
76
+ };
77
+ readonly type: "highlight";
78
+ }, ...({
79
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
80
+ } | {
81
+ readonly attrs: {
82
+ readonly href: string;
83
+ };
84
+ readonly type: "link";
85
+ } | {
86
+ readonly attrs: {
87
+ readonly variant: "success" | "warning" | null;
88
+ };
89
+ readonly type: "highlight";
90
+ })[]];
91
+ readonly text: string;
92
+ readonly type: "text";
93
+ } | {
94
+ readonly attrs: {
95
+ readonly latex: string;
96
+ };
97
+ readonly marks?: readonly [{
98
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
99
+ } | {
100
+ readonly attrs: {
101
+ readonly href: string;
102
+ };
103
+ readonly type: "link";
104
+ } | {
105
+ readonly attrs: {
106
+ readonly variant: "success" | "warning" | null;
107
+ };
108
+ readonly type: "highlight";
109
+ }, ...({
110
+ readonly type: "bold" | "code" | "italic" | "subscript" | "superscript" | "underline";
111
+ } | {
112
+ readonly attrs: {
113
+ readonly href: string;
114
+ };
115
+ readonly type: "link";
116
+ } | {
117
+ readonly attrs: {
118
+ readonly variant: "success" | "warning" | null;
119
+ };
120
+ readonly type: "highlight";
121
+ })[]];
122
+ readonly type: "mathInline";
123
+ })[]], E, never, never>>;
124
+ readonly title: RichSlot<E>;
125
+ readonly conclusion: Schema.Union<readonly [Schema.Struct<{
126
+ readonly statement: Schema.Union<readonly [Schema.Struct<{
127
+ readonly kind: Schema.Literal<"all">;
128
+ readonly predicate: Schema.Trimmed;
129
+ readonly subject: Schema.Trimmed;
130
+ }>, Schema.Struct<{
131
+ readonly kind: Schema.Literal<"member">;
132
+ readonly member: Schema.Trimmed;
133
+ readonly set: Schema.Trimmed;
134
+ }>, Schema.Struct<{
135
+ readonly antecedent: Schema.Trimmed;
136
+ readonly consequent: Schema.Trimmed;
137
+ readonly kind: Schema.Literal<"conditional">;
138
+ }>, Schema.Struct<{
139
+ readonly kind: Schema.Literal<"claim">;
140
+ readonly negated: Schema.Boolean;
141
+ readonly statement: Schema.Trimmed;
142
+ }>]>;
143
+ readonly text: Schema.Trimmed;
144
+ readonly truth: Schema.Boolean;
145
+ }>, Schema.Literal<"open">]>;
146
+ readonly hand: Schema.NonEmptyArray<Schema.Struct<{
147
+ readonly statement: Schema.Union<readonly [Schema.Struct<{
148
+ readonly kind: Schema.Literal<"all">;
149
+ readonly predicate: Schema.Trimmed;
150
+ readonly subject: Schema.Trimmed;
151
+ }>, Schema.Struct<{
152
+ readonly kind: Schema.Literal<"member">;
153
+ readonly member: Schema.Trimmed;
154
+ readonly set: Schema.Trimmed;
155
+ }>, Schema.Struct<{
156
+ readonly antecedent: Schema.Trimmed;
157
+ readonly consequent: Schema.Trimmed;
158
+ readonly kind: Schema.Literal<"conditional">;
159
+ }>, Schema.Struct<{
160
+ readonly kind: Schema.Literal<"claim">;
161
+ readonly negated: Schema.Boolean;
162
+ readonly statement: Schema.Trimmed;
163
+ }>]>;
164
+ readonly text: Schema.Trimmed;
165
+ readonly truth: Schema.Boolean;
166
+ }>>;
167
+ readonly premises: Schema.Tuple<readonly [Schema.Union<readonly [Schema.Struct<{
168
+ readonly statement: Schema.Union<readonly [Schema.Struct<{
169
+ readonly kind: Schema.Literal<"all">;
170
+ readonly predicate: Schema.Trimmed;
171
+ readonly subject: Schema.Trimmed;
172
+ }>, Schema.Struct<{
173
+ readonly kind: Schema.Literal<"member">;
174
+ readonly member: Schema.Trimmed;
175
+ readonly set: Schema.Trimmed;
176
+ }>, Schema.Struct<{
177
+ readonly antecedent: Schema.Trimmed;
178
+ readonly consequent: Schema.Trimmed;
179
+ readonly kind: Schema.Literal<"conditional">;
180
+ }>, Schema.Struct<{
181
+ readonly kind: Schema.Literal<"claim">;
182
+ readonly negated: Schema.Boolean;
183
+ readonly statement: Schema.Trimmed;
184
+ }>]>;
185
+ readonly text: Schema.Trimmed;
186
+ readonly truth: Schema.Boolean;
187
+ }>, Schema.Literal<"open">]>, Schema.Union<readonly [Schema.Struct<{
188
+ readonly statement: Schema.Union<readonly [Schema.Struct<{
189
+ readonly kind: Schema.Literal<"all">;
190
+ readonly predicate: Schema.Trimmed;
191
+ readonly subject: Schema.Trimmed;
192
+ }>, Schema.Struct<{
193
+ readonly kind: Schema.Literal<"member">;
194
+ readonly member: Schema.Trimmed;
195
+ readonly set: Schema.Trimmed;
196
+ }>, Schema.Struct<{
197
+ readonly antecedent: Schema.Trimmed;
198
+ readonly consequent: Schema.Trimmed;
199
+ readonly kind: Schema.Literal<"conditional">;
200
+ }>, Schema.Struct<{
201
+ readonly kind: Schema.Literal<"claim">;
202
+ readonly negated: Schema.Boolean;
203
+ readonly statement: Schema.Trimmed;
204
+ }>]>;
205
+ readonly text: Schema.Trimmed;
206
+ readonly truth: Schema.Boolean;
207
+ }>, Schema.Literal<"open">]>]>;
208
+ readonly labels: Schema.Struct<{
209
+ readonly conclusion: Schema.Trimmed;
210
+ readonly fallacies: Schema.$Record<Schema.Literals<readonly ["consequent", "antecedent", "middle"]>, RichSlot<E>>;
211
+ readonly form: RichSlot<E>;
212
+ readonly forms: Schema.$Record<Schema.Literals<readonly ["I", "II", "III"]>, RichSlot<E>>;
213
+ readonly hand: Schema.Trimmed;
214
+ readonly no: RichSlot<E>;
215
+ readonly premises: Schema.Tuple<readonly [Schema.Trimmed, Schema.Trimmed]>;
216
+ readonly sound: RichSlot<E>;
217
+ readonly truth: RichSlot<E>;
218
+ readonly unfollowed: RichSlot<E>;
219
+ readonly unlinked: RichSlot<E>;
220
+ readonly valid: RichSlot<E>;
221
+ readonly viewLabel: Schema.Trimmed;
222
+ readonly yes: RichSlot<E>;
223
+ }>;
224
+ readonly showVerdict: Schema.optionalKey<Schema.Boolean>;
225
+ }>, "figure">;
226
+ };
@@ -0,0 +1,150 @@
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
+ /** The textbook's three valid forms of argument, and the fallacies that look like them. */
5
+ const ARGUMENT_FORMS = ["I", "II", "III"];
6
+ const ARGUMENT_FALLACIES = ["consequent", "antecedent", "middle"];
7
+ /** The most cards the hand holds, the longest card text, and the longest slot name. */
8
+ const HAND_LIMIT = 3;
9
+ const CARD_TEXT_LIMIT = 100;
10
+ const SLOT_NAME_LIMIT = 12;
11
+ /**
12
+ * What one card says, in the shapes the three forms are built from: "All A
13
+ * are B" (`all`), "c is A" (`member`), "If p, then q" (`conditional`), and
14
+ * "p is true" or "Not p is true" (`claim`). The names are the lesson's own
15
+ * ids for its sets and statements, never shown: two cards that speak of one
16
+ * set or one statement use one name.
17
+ */
18
+ const StatementSchema = Schema.Union([
19
+ Schema.Struct({
20
+ kind: Schema.Literal("all"),
21
+ predicate: TextSchema,
22
+ subject: TextSchema,
23
+ }),
24
+ Schema.Struct({
25
+ kind: Schema.Literal("member"),
26
+ member: TextSchema,
27
+ set: TextSchema,
28
+ }),
29
+ Schema.Struct({
30
+ antecedent: TextSchema,
31
+ consequent: TextSchema,
32
+ kind: Schema.Literal("conditional"),
33
+ }),
34
+ Schema.Struct({
35
+ kind: Schema.Literal("claim"),
36
+ negated: Schema.Boolean,
37
+ statement: TextSchema,
38
+ }),
39
+ ]);
40
+ /** One card: the words the learner reads, what they say, and whether that is true. */
41
+ const ArgumentCardSchema = Schema.Struct({
42
+ statement: StatementSchema,
43
+ text: TextSchema.check(Schema.isMaxLength(CARD_TEXT_LIMIT)),
44
+ truth: Schema.Boolean,
45
+ });
46
+ /** A slot of the chain: a card the lesson places, or `open` for the learner to fill from the hand. */
47
+ const ArgumentSlotSchema = Schema.Union([
48
+ ArgumentCardSchema,
49
+ Schema.Literal("open"),
50
+ ]);
51
+ /** The chain's three slots and the hand the learner fills the open ones from. */
52
+ const ArgumentChainSchema = Schema.Struct({
53
+ conclusion: ArgumentSlotSchema,
54
+ hand: Schema.NonEmptyArray(ArgumentCardSchema).check(Schema.isMaxLength(HAND_LIMIT)),
55
+ premises: Schema.Tuple([ArgumentSlotSchema, ArgumentSlotSchema]),
56
+ });
57
+ /** A slot's name on its brass plate. */
58
+ const SlotNameSchema = TextSchema.check(Schema.isMaxLength(SLOT_NAME_LIMIT));
59
+ const sameStatement = Schema.toEquivalence(StatementSchema);
60
+ /** Every card a single slot can take, paired with the hand left after placing it. */
61
+ function picksFor(slot, hand) {
62
+ return slot === "open"
63
+ ? Arr.map(hand, (card, index) => [card, Arr.remove(hand, index)])
64
+ : [[slot, hand]];
65
+ }
66
+ /** Every way the hand fills the open slots, one card to a slot and no card twice, with the placed cards kept. */
67
+ function dealsOf([firstSlot, secondSlot, thirdSlot], hand) {
68
+ return Arr.flatMap(picksFor(firstSlot, hand), ([first, afterFirst]) => Arr.flatMap(picksFor(secondSlot, afterFirst), ([second, afterSecond]) => Arr.map(picksFor(thirdSlot, afterSecond), ([conclusion]) => [first, second, conclusion])));
69
+ }
70
+ /** Whether a statement is general: a rule about every member or every case. */
71
+ function isGeneral(statement) {
72
+ return statement.kind === "all" || statement.kind === "conditional";
73
+ }
74
+ /** Whether two statements say one thing and its opposite. */
75
+ function contradicts(left, right) {
76
+ return (left.kind === "claim" &&
77
+ right.kind === "claim" &&
78
+ left.statement === right.statement &&
79
+ left.negated !== right.negated);
80
+ }
81
+ /**
82
+ * Whether a full chain is one the lab can judge: valid only through form I,
83
+ * II or III, or invalid. Two general premises chain into a valid argument the
84
+ * lab does not teach, premises that contradict each other prove anything, and
85
+ * a conclusion that repeats a premise follows trivially; none of these may
86
+ * be dealt.
87
+ */
88
+ function isJudgeable([first, second, conclusion]) {
89
+ return !((isGeneral(first.statement) && isGeneral(second.statement)) ||
90
+ contradicts(first.statement, second.statement) ||
91
+ sameStatement(conclusion.statement, first.statement) ||
92
+ sameStatement(conclusion.statement, second.statement));
93
+ }
94
+ /**
95
+ * Whether the learner has a slot to fill and a card for each open slot, the
96
+ * hand's cards read differently, and every chain the hand can deal is one
97
+ * the lab can judge.
98
+ */
99
+ function isDealable({ conclusion, hand, premises, }) {
100
+ const slots = [
101
+ premises[0],
102
+ premises[1],
103
+ conclusion,
104
+ ];
105
+ const open = Arr.filter(slots, (slot) => slot === "open").length;
106
+ const texts = Arr.map(hand, ({ text }) => text);
107
+ return (open > 0 &&
108
+ hand.length >= open &&
109
+ Arr.dedupe(texts).length === texts.length &&
110
+ Arr.every(dealsOf(slots, hand), isJudgeable));
111
+ }
112
+ /**
113
+ * Props of `ArgumentChainLab`: an argument built from cards on a rail, two
114
+ * `premises` and a `conclusion` joined by two chain links. Each slot holds a
115
+ * card the lesson places, or is `open` for the learner to fill from the
116
+ * `hand`, whose cards the toolbar deals in. With `showVerdict`, each link
117
+ * locks when the step holds and breaks where the argument fails, a seal marks
118
+ * each false card, and the footer names the form or the fallacy and reads
119
+ * whether the argument is valid, its premises true and the argument sound,
120
+ * so it is answer state.
121
+ */
122
+ function argumentChainLab(rich) {
123
+ return figure(Schema.Struct({
124
+ ...cardFields(rich),
125
+ ...ArgumentChainSchema.fields,
126
+ labels: Schema.Struct({
127
+ conclusion: SlotNameSchema,
128
+ fallacies: byIds(ARGUMENT_FALLACIES, rich),
129
+ form: rich,
130
+ forms: byIds(ARGUMENT_FORMS, rich),
131
+ hand: TextSchema,
132
+ no: rich,
133
+ premises: Schema.Tuple([SlotNameSchema, SlotNameSchema]),
134
+ sound: rich,
135
+ truth: rich,
136
+ unfollowed: rich,
137
+ unlinked: rich,
138
+ valid: rich,
139
+ viewLabel: TextSchema,
140
+ yes: rich,
141
+ }),
142
+ showVerdict: Schema.optionalKey(Schema.Boolean),
143
+ }).check(Schema.makeFilter(isDealable, {
144
+ message: "Expected an open slot, a hand with a different card for each open slot, and no deal the lab cannot judge: two general premises, contradicting premises, or a conclusion that repeats a premise.",
145
+ })), answerAt(["showVerdict"]));
146
+ }
147
+ /** The argument labs, where an argument is checked for its form. */
148
+ export function argumentVisuals(rich) {
149
+ return { ArgumentChainLab: argumentChainLab(rich) };
150
+ }