@pie-element/math-inline 5.9.0 → 5.9.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.
@@ -0,0 +1,3289 @@
1
+ import {_dll_lodash, _dll_react, _dll_prop_types, _dll_material_ui__core_styles, _dll_debug, _dll_classnames, _dll_material_ui__core, _dll_material_ui__core_styles_color_manipulator, _dll_pie_lib__render_ui, _dll_material_ui__icons, _dll_pie_lib__correct_answer_toggle, _dll_react_dom} from "../../../@pie-lib/shared-module@^1.2.19/module/index.js";
2
+ import {_dll_pie_lib__math_rendering} from "../../../@pie-lib/math-rendering-module@^1.0.22/module/index.js";
3
+ import {_dll_pie_framework__mathquill} from "../../../@pie-lib/math-edit-module@^1.1.18/module/index.js";
4
+ const set$f = o => ({
5
+ ...o,
6
+ category: 'comparison'
7
+ });
8
+ const lessThan = set$f({
9
+ name: 'Less than',
10
+ latex: '<',
11
+ command: '\\lt'
12
+ });
13
+ const greaterThan = set$f({
14
+ name: 'Greater than',
15
+ latex: '>',
16
+ command: '\\gt'
17
+ });
18
+ const lessThanEqual = set$f({
19
+ name: 'Less than or equal',
20
+ latex: '\\le',
21
+ symbol: '<=',
22
+ command: '\\le'
23
+ });
24
+ const greaterThanEqual = set$f({
25
+ name: 'Greater than or equal',
26
+ symbol: '>=',
27
+ command: '\\ge',
28
+ latex: '\\ge'
29
+ });
30
+ var comparison = Object.freeze({
31
+ __proto__: null,
32
+ lessThan: lessThan,
33
+ greaterThan: greaterThan,
34
+ lessThanEqual: lessThanEqual,
35
+ greaterThanEqual: greaterThanEqual
36
+ });
37
+ const _$2 = _dll_lodash;
38
+ const mkSet = category => o => ({
39
+ ...o,
40
+ category
41
+ });
42
+ const transformToKeySetStructure = (data = []) => {
43
+ const structure = [];
44
+ _$2.times(5, () => {
45
+ structure.push([]);
46
+ });
47
+ let ln = data.length;
48
+ let i = 0;
49
+ let j = 0;
50
+ while (j < ln) {
51
+ structure[i++].push(data[j++]);
52
+ if (i === 5) {
53
+ i = 0;
54
+ }
55
+ }
56
+ return structure;
57
+ };
58
+ const latexAndNameDontExist = base => k => {
59
+ const flattened = _$2.flatten(base);
60
+ const latexExists = flattened.some(b => b.latex === k.latex);
61
+ const nameExists = flattened.some(b => b.name === k.name);
62
+ return !latexExists && !nameExists;
63
+ };
64
+ const extendKeySet = (base = [], keySetData = []) => {
65
+ keySetData = keySetData.filter(latexAndNameDontExist(base));
66
+ const final = [];
67
+ _$2.times(5 - base.length, () => {
68
+ base.push([]);
69
+ });
70
+ _$2.times(5, () => {
71
+ final.push([]);
72
+ });
73
+ const extra = transformToKeySetStructure(keySetData);
74
+ for (let i = 0; i < 5; i++) {
75
+ final[i] = [...base[i], ...extra[i]];
76
+ }
77
+ return final;
78
+ };
79
+ const set$e = mkSet('vars');
80
+ const x = set$e({
81
+ name: 'X',
82
+ latex: 'x',
83
+ write: 'x'
84
+ });
85
+ const y = set$e({
86
+ name: 'Y',
87
+ latex: 'y',
88
+ write: 'y'
89
+ });
90
+ const theta = set$e({
91
+ name: 'Theta',
92
+ latex: '\\theta',
93
+ write: '\\theta'
94
+ });
95
+ var vars = Object.freeze({
96
+ __proto__: null,
97
+ x: x,
98
+ y: y,
99
+ theta: theta
100
+ });
101
+ const set$d = mkSet('fractions');
102
+ const blankOverBlank = set$d({
103
+ name: 'blank/blank',
104
+ latex: '\\frac{}{}',
105
+ command: '\\frac'
106
+ });
107
+ const xOverBlank = set$d({
108
+ latex: '\\frac{x}{ }',
109
+ name: 'X/blank',
110
+ label: 'x/[]',
111
+ command: '/'
112
+ });
113
+ const xBlankBlank = set$d({
114
+ name: 'X (blank/blank)',
115
+ latex: 'x\\frac{}{}',
116
+ label: 'x([]/[])',
117
+ command: '\\frac'
118
+ });
119
+ var fractions = Object.freeze({
120
+ __proto__: null,
121
+ blankOverBlank: blankOverBlank,
122
+ xOverBlank: xOverBlank,
123
+ xBlankBlank: xBlankBlank
124
+ });
125
+ const set$c = mkSet('exponent');
126
+ const squared = set$c({
127
+ name: 'Squared',
128
+ latex: 'x^2',
129
+ write: '^2'
130
+ });
131
+ const xToPowerOfN = set$c({
132
+ name: 'X to the power of n',
133
+ latex: 'x^{}',
134
+ command: '^'
135
+ });
136
+ const squareRoot = set$c({
137
+ name: 'Square root',
138
+ latex: '\\sqrt{}',
139
+ command: '\\sqrt'
140
+ });
141
+ const nthRoot = set$c({
142
+ name: 'Nth root',
143
+ latex: '\\sqrt[{}]{}',
144
+ command: '\\nthroot'
145
+ });
146
+ var exponent = Object.freeze({
147
+ __proto__: null,
148
+ squared: squared,
149
+ xToPowerOfN: xToPowerOfN,
150
+ squareRoot: squareRoot,
151
+ nthRoot: nthRoot
152
+ });
153
+ const set$b = mkSet('misc');
154
+ const plusMinus = set$b({
155
+ name: 'Plus/Minus',
156
+ latex: '\\pm',
157
+ write: '\\pm'
158
+ });
159
+ const absValue = set$b({
160
+ name: 'Absolute Value',
161
+ latex: '\\abs{}',
162
+ symbol: '| |',
163
+ command: '|'
164
+ });
165
+ const parenthesis = set$b({
166
+ name: 'Parenthesis',
167
+ latex: '\\left(\\right)',
168
+ symbol: '( )',
169
+ command: '('
170
+ });
171
+ const brackets = set$b({
172
+ name: 'Brackets',
173
+ latex: '\\left[\\right]',
174
+ symbol: '[ ]',
175
+ command: '['
176
+ });
177
+ const percentage = set$b({
178
+ name: 'Percentage',
179
+ latex: '%',
180
+ command: '%'
181
+ });
182
+ const approx = set$b({
183
+ latex: '\\approx',
184
+ command: '\\approx'
185
+ });
186
+ const nApprox = set$b({
187
+ latex: '\\napprox',
188
+ command: '\\napprox'
189
+ });
190
+ const notEqual = set$b({
191
+ latex: '\\neq',
192
+ command: '\\neq'
193
+ });
194
+ const similar = set$b({
195
+ latex: '\\sim',
196
+ command: '\\sim'
197
+ });
198
+ const notSimilar = set$b({
199
+ latex: '\\nsim',
200
+ command: '\\nsim'
201
+ });
202
+ var misc = Object.freeze({
203
+ __proto__: null,
204
+ plusMinus: plusMinus,
205
+ absValue: absValue,
206
+ parenthesis: parenthesis,
207
+ brackets: brackets,
208
+ percentage: percentage,
209
+ approx: approx,
210
+ nApprox: nApprox,
211
+ notEqual: notEqual,
212
+ similar: similar,
213
+ notSimilar: notSimilar
214
+ });
215
+ const set$a = mkSet('constants');
216
+ const pi = set$a({
217
+ name: 'Pi',
218
+ label: 'π',
219
+ latex: '\\pi',
220
+ command: '\\pi',
221
+ category: 'constants'
222
+ });
223
+ const eulers = set$a({
224
+ name: 'Eulers',
225
+ label: 'e',
226
+ latex: 'e',
227
+ command: 'e',
228
+ category: 'constants'
229
+ });
230
+ const infinity = set$a({
231
+ name: 'Infinity',
232
+ label: '\\infty',
233
+ latex: '\\infty',
234
+ command: '\\infty',
235
+ category: 'constants'
236
+ });
237
+ const halfInfinity = set$a({
238
+ name: 'Half Infinity',
239
+ label: '\\propto',
240
+ latex: '\\propto',
241
+ command: '\\propto',
242
+ category: 'constants'
243
+ });
244
+ var constants = Object.freeze({
245
+ __proto__: null,
246
+ pi: pi,
247
+ eulers: eulers,
248
+ infinity: infinity,
249
+ halfInfinity: halfInfinity
250
+ });
251
+ const set$9 = mkSet('trigonometry');
252
+ const sin = set$9({
253
+ name: 'sin',
254
+ label: 'sin',
255
+ command: '\\sin',
256
+ latex: '\\sin'
257
+ });
258
+ const cos = set$9({
259
+ name: 'cos',
260
+ label: 'cos',
261
+ command: '\\cos',
262
+ latex: '\\cos'
263
+ });
264
+ const tan = set$9({
265
+ name: 'tan',
266
+ label: 'tan',
267
+ command: '\\tan',
268
+ latex: '\\tan'
269
+ });
270
+ const sec = set$9({
271
+ name: 'sec',
272
+ label: 'sec',
273
+ command: '\\sec',
274
+ latex: '\\sec'
275
+ });
276
+ const csc = set$9({
277
+ name: 'csc',
278
+ label: 'csc',
279
+ command: '\\csc',
280
+ latex: '\\csc'
281
+ });
282
+ const cot = set$9({
283
+ name: 'cot',
284
+ label: 'cot',
285
+ command: '\\cot',
286
+ latex: '\\cot'
287
+ });
288
+ var trigonometry = Object.freeze({
289
+ __proto__: null,
290
+ sin: sin,
291
+ cos: cos,
292
+ tan: tan,
293
+ sec: sec,
294
+ csc: csc,
295
+ cot: cot
296
+ });
297
+ const set$8 = o => ({
298
+ ...o,
299
+ category: 'geometry'
300
+ });
301
+ const overline = set$8({
302
+ name: 'Overline',
303
+ latex: '\\overline{}',
304
+ command: '\\overline'
305
+ });
306
+ const overRightArrow = set$8({
307
+ name: 'Overline',
308
+ latex: '\\overrightarrow{}',
309
+ command: '\\overrightarrow'
310
+ });
311
+ const overLeftRightArrow = set$8({
312
+ name: 'Overline',
313
+ latex: '\\overleftrightarrow{\\overline{}}',
314
+ symbol: 'AB',
315
+ command: '\\overleftrightarrow'
316
+ });
317
+ const segment = set$8({
318
+ name: 'Segment',
319
+ latex: '\\overleftrightarrow{AB}',
320
+ write: '\\overleftrightarrow{AB}',
321
+ label: 'AB'
322
+ });
323
+ const parallel = set$8({
324
+ name: 'Parallel',
325
+ latex: '\\parallel',
326
+ command: '\\parallel'
327
+ });
328
+ const notParallel = set$8({
329
+ name: 'Not Parallel',
330
+ latex: '\\nparallel',
331
+ command: '\\nparallel'
332
+ });
333
+ const perpindicular = set$8({
334
+ name: 'Perpendicular',
335
+ latex: '\\perp',
336
+ command: '\\perpendicular'
337
+ });
338
+ const angle = set$8({
339
+ name: 'Angle',
340
+ latex: '\\angle',
341
+ command: '\\angle'
342
+ });
343
+ const overArc = set$8({
344
+ name: 'Over arc',
345
+ latex: '\\overarc{\\overline{}}',
346
+ command: '\\overarc'
347
+ });
348
+ const measureOfAngle = set$8({
349
+ name: 'Measure Of Angle',
350
+ latex: '\\measuredangle',
351
+ command: ['m', '\\angle']
352
+ });
353
+ const triangle = set$8({
354
+ name: 'Triangle',
355
+ latex: '\\triangle',
356
+ command: '\\triangle'
357
+ });
358
+ const square = set$8({
359
+ name: 'Square',
360
+ latex: '\\square',
361
+ command: '\\square'
362
+ });
363
+ const parallelogram = set$8({
364
+ name: 'Parallelogram',
365
+ latex: '\\parallelogram',
366
+ command: '\\parallelogram'
367
+ });
368
+ const circledDot = set$8({
369
+ name: 'Circled Dot',
370
+ latex: '\\odot',
371
+ command: '\\odot'
372
+ });
373
+ const degree = set$8({
374
+ name: 'Degree',
375
+ latex: '\\degree',
376
+ command: '\\degree'
377
+ });
378
+ const similarTo = set$8({
379
+ name: 'Similar To',
380
+ command: '\\sim',
381
+ latex: '\\sim'
382
+ });
383
+ const congruentTo = set$8({
384
+ name: 'Congruent To',
385
+ command: '\\cong',
386
+ latex: '\\cong'
387
+ });
388
+ const notCongruentTo = set$8({
389
+ name: 'Not Congruent To',
390
+ command: '\\ncong',
391
+ latex: '\\ncong'
392
+ });
393
+ const primeArcminute = set$8({
394
+ name: 'Prime',
395
+ label: 'pam',
396
+ latex: "'",
397
+ write: "'"
398
+ });
399
+ const doublePrimeArcSecond = set$8({
400
+ name: 'Double Prime/Arcsecond',
401
+ latex: '"',
402
+ write: '"'
403
+ });
404
+ const leftArrow = set$8({
405
+ name: 'Left Arrow',
406
+ latex: '\\leftarrow',
407
+ command: '\\leftarrow'
408
+ });
409
+ const rightArrow = set$8({
410
+ name: 'Right Arrow',
411
+ latex: '\\rightarrow',
412
+ command: '\\rightarrow'
413
+ });
414
+ const leftrightArrow = set$8({
415
+ name: 'Left Right Arrow',
416
+ latex: '\\leftrightarrow',
417
+ command: '\\leftrightarrow'
418
+ });
419
+ var geometry = Object.freeze({
420
+ __proto__: null,
421
+ overline: overline,
422
+ overRightArrow: overRightArrow,
423
+ overLeftRightArrow: overLeftRightArrow,
424
+ segment: segment,
425
+ parallel: parallel,
426
+ notParallel: notParallel,
427
+ perpindicular: perpindicular,
428
+ angle: angle,
429
+ overArc: overArc,
430
+ measureOfAngle: measureOfAngle,
431
+ triangle: triangle,
432
+ square: square,
433
+ parallelogram: parallelogram,
434
+ circledDot: circledDot,
435
+ degree: degree,
436
+ similarTo: similarTo,
437
+ congruentTo: congruentTo,
438
+ notCongruentTo: notCongruentTo,
439
+ primeArcminute: primeArcminute,
440
+ doublePrimeArcSecond: doublePrimeArcSecond,
441
+ leftArrow: leftArrow,
442
+ rightArrow: rightArrow,
443
+ leftrightArrow: leftrightArrow
444
+ });
445
+ const set$7 = mkSet('operators');
446
+ const circleDot = set$7({
447
+ name: 'CircleDot',
448
+ label: '⋅',
449
+ write: '\\cdot'
450
+ });
451
+ var operators = Object.freeze({
452
+ __proto__: null,
453
+ circleDot: circleDot
454
+ });
455
+ const set$6 = mkSet('log');
456
+ const log$6 = set$6({
457
+ name: 'Log',
458
+ label: 'log',
459
+ command: '\\log',
460
+ latex: '\\log'
461
+ });
462
+ const logSubscript = set$6({
463
+ name: 'Log with subscript',
464
+ label: 'log s',
465
+ latex: '\\log_{}',
466
+ command: ['\\log', '_', ' ']
467
+ });
468
+ const ln = set$6({
469
+ name: 'Ln',
470
+ label: 'ln',
471
+ command: '\\ln',
472
+ latex: '\\ln'
473
+ });
474
+ var log$7 = Object.freeze({
475
+ __proto__: null,
476
+ log: log$6,
477
+ logSubscript: logSubscript,
478
+ ln: ln
479
+ });
480
+ const set$5 = mkSet('sub-sup');
481
+ const superscript = set$5({
482
+ name: 'Superscript',
483
+ latex: 'x^{}',
484
+ command: '^'
485
+ });
486
+ const subscript = set$5({
487
+ name: 'Subscript',
488
+ latex: 'x_{}',
489
+ command: '_'
490
+ });
491
+ var subSup = Object.freeze({
492
+ __proto__: null,
493
+ superscript: superscript,
494
+ subscript: subscript
495
+ });
496
+ const set$4 = mkSet('statistics');
497
+ const xBar = set$4({
498
+ name: 'X Bar',
499
+ label: 'x̄',
500
+ latex: '\\overline{x}',
501
+ write: '\\overline{x}'
502
+ });
503
+ const yBar = set$4({
504
+ name: 'Y Bar',
505
+ latex: '\\overline{y}',
506
+ write: '\\overline{y}'
507
+ });
508
+ const mu = set$4({
509
+ name: 'mu',
510
+ label: 'mu',
511
+ latex: '\\mu',
512
+ write: '\\mu'
513
+ });
514
+ const sigma = set$4({
515
+ name: 'Sigma',
516
+ label: '\\Sigma',
517
+ latex: '\\Sigma',
518
+ write: '\\Sigma'
519
+ });
520
+ const smallSigma = set$4({
521
+ name: 'sigma',
522
+ label: '\\sigma',
523
+ latex: '\\sigma',
524
+ write: '\\sigma'
525
+ });
526
+ var statistics = Object.freeze({
527
+ __proto__: null,
528
+ xBar: xBar,
529
+ yBar: yBar,
530
+ mu: mu,
531
+ sigma: sigma,
532
+ smallSigma: smallSigma
533
+ });
534
+ const DELETE = '\u232B';
535
+ const LEFT_ARROW = '◀';
536
+ const RIGHT_ARROW = '▶';
537
+ const DIVIDE = '\u00F7';
538
+ const MULTIPLY = '\u00D7';
539
+ const set$3 = mkSet('operators');
540
+ const equals = set$3({
541
+ write: '=',
542
+ label: '='
543
+ });
544
+ const plus = set$3({
545
+ write: '+',
546
+ label: '+'
547
+ });
548
+ const minus = set$3({
549
+ write: '−',
550
+ label: '−'
551
+ });
552
+ const divide = set$3({
553
+ name: 'divide',
554
+ label: DIVIDE,
555
+ command: '\\divide',
556
+ otherNotation: '\\div'
557
+ });
558
+ const multiply = set$3({
559
+ name: 'multiply',
560
+ label: MULTIPLY,
561
+ command: '\\times'
562
+ });
563
+ var basicOperators = Object.freeze({
564
+ __proto__: null,
565
+ equals: equals,
566
+ plus: plus,
567
+ minus: minus,
568
+ divide: divide,
569
+ multiply: multiply
570
+ });
571
+ const set$2 = mkSet('matrices');
572
+ const singleCellMatrix = set$2({
573
+ name: 'Single Cell Matrix',
574
+ label: '[ ]',
575
+ write: '\\begin{pmatrix}\\end{pmatrix}'
576
+ });
577
+ const doubleCellMatrix = set$2({
578
+ name: 'Double Cell Matrix',
579
+ label: '[ ] [ ] \\\\newline [ ] [ ]',
580
+ write: '\\begin{bmatrix}&\\\\&\\end{bmatrix}'
581
+ });
582
+ var matrices = Object.freeze({
583
+ __proto__: null,
584
+ singleCellMatrix: singleCellMatrix,
585
+ doubleCellMatrix: doubleCellMatrix
586
+ });
587
+ const {times: times} = _dll_lodash;
588
+ const digitMap = {
589
+ 0: 'zero',
590
+ 1: 'one',
591
+ 2: 'two',
592
+ 3: 'three',
593
+ 4: 'four',
594
+ 5: 'five',
595
+ 6: 'six',
596
+ 7: 'seven',
597
+ 8: 'eight',
598
+ 9: 'nine'
599
+ };
600
+ const comma$1 = {
601
+ name: 'comma',
602
+ label: ',',
603
+ write: ',',
604
+ category: 'digit'
605
+ };
606
+ const decimalPoint$1 = {
607
+ name: 'decimal-point',
608
+ label: '.',
609
+ write: '.',
610
+ category: 'digit'
611
+ };
612
+ var digits = times(10, String).map(n => {
613
+ return {
614
+ name: digitMap[n],
615
+ write: n,
616
+ label: n,
617
+ category: 'digit'
618
+ };
619
+ }).reduce((acc, o) => {
620
+ acc[o.name] = o;
621
+ return acc;
622
+ }, {
623
+ comma: comma$1,
624
+ decimalPoint: decimalPoint$1
625
+ });
626
+ const set$1 = mkSet('logic');
627
+ const therefore = set$1({
628
+ name: 'Therefore',
629
+ label: '∴',
630
+ write: '∴'
631
+ });
632
+ const longDivision = set$1({
633
+ name: 'Long division',
634
+ latex: '\\longdiv{}',
635
+ command: '\\longdiv'
636
+ });
637
+ const set = mkSet('navigation');
638
+ const left = set({
639
+ label: LEFT_ARROW,
640
+ keystroke: 'Left'
641
+ });
642
+ const right = set({
643
+ label: RIGHT_ARROW,
644
+ keystroke: 'Right'
645
+ });
646
+ const del = {
647
+ label: DELETE,
648
+ category: 'edit',
649
+ keystroke: 'Backspace'
650
+ };
651
+ const hs = [[blankOverBlank, percentage, x, squared, squareRoot], [circleDot, y, subscript, xToPowerOfN, nthRoot], [plusMinus, lessThan, greaterThan, lessThanEqual, greaterThanEqual], [pi, theta, parenthesis, brackets, absValue], [notEqual, sin, cos, tan, degree]];
652
+ const advancedAlgebra = (() => {
653
+ const out = [...hs.map(arr => [...arr])];
654
+ out[0].push({
655
+ name: 'i',
656
+ latex: 'i',
657
+ write: 'i'
658
+ });
659
+ out[1].push(log$6);
660
+ out[2].push(logSubscript);
661
+ out[3].push(ln);
662
+ out[4].push(eulers);
663
+ return out;
664
+ })();
665
+ const statisticsSet = (() => {
666
+ const out = [...hs.map(arr => [...arr])];
667
+ out[0].push(mu);
668
+ out[1].push(xBar);
669
+ out[2].push(yBar);
670
+ out[3].push(sigma);
671
+ out[4].push(smallSigma);
672
+ return out;
673
+ })();
674
+ const gradeSets = [{
675
+ predicate: n => n >= 3 && n <= 5,
676
+ set: [[lessThan, greaterThan], [xOverBlank, xBlankBlank], [x, longDivision]]
677
+ }, {
678
+ predicate: n => n >= 6 && n <= 7,
679
+ set: [[degree, lessThan, greaterThan], [circleDot, lessThanEqual, greaterThanEqual], [x, y, squared, xToPowerOfN], [plusMinus, xOverBlank, xBlankBlank, squareRoot], [pi, parenthesis, absValue, nthRoot]]
680
+ }, {
681
+ predicate: n => n >= 8 || n === 'HS',
682
+ set: hs
683
+ }, {
684
+ predicate: 'non-negative-integers',
685
+ set: [[digits.seven, digits.eight, digits.nine], [digits.four, digits.five, digits.six], [digits.one, digits.two, digits.three], [digits.zero, {
686
+ name: '',
687
+ latex: '',
688
+ write: ''
689
+ }, {
690
+ name: '',
691
+ latex: '',
692
+ write: ''
693
+ }], [left, right, del]]
694
+ }, {
695
+ predicate: 'integers',
696
+ set: [[digits.seven, digits.eight, digits.nine], [digits.four, digits.five, digits.six], [digits.one, digits.two, digits.three], [digits.zero, {
697
+ name: '',
698
+ latex: '',
699
+ write: ''
700
+ }, minus], [left, right, del]]
701
+ }, {
702
+ predicate: 'decimals',
703
+ set: [[digits.seven, digits.eight, digits.nine], [digits.four, digits.five, digits.six], [digits.one, digits.two, digits.three], [digits.zero, digits.decimalPoint, minus], [left, right, del]]
704
+ }, {
705
+ predicate: 'fractions',
706
+ set: [[digits.seven, digits.eight, digits.nine], [digits.four, digits.five, digits.six], [digits.one, digits.two, digits.three], [digits.zero, blankOverBlank, minus], [left, right, del]]
707
+ }, {
708
+ predicate: 'geometry',
709
+ set: [[blankOverBlank, degree, primeArcminute, doublePrimeArcSecond, congruentTo, similarTo], [circleDot, angle, measureOfAngle, triangle, notCongruentTo, notSimilar], [sin, cos, tan, pi, squareRoot, nthRoot], [csc, sec, cot, theta, subscript, xToPowerOfN], [overline, overRightArrow, overLeftRightArrow, overArc, perpindicular, parallel]]
710
+ }, {
711
+ predicate: 'advanced-algebra',
712
+ set: advancedAlgebra
713
+ }, {
714
+ predicate: 'statistics',
715
+ set: statisticsSet
716
+ }, {
717
+ predicate: 'item-authoring',
718
+ set: [[divide, blankOverBlank, longDivision, halfInfinity, squared, squareRoot, overline, overRightArrow, overLeftRightArrow, log$6], [multiply, circleDot, {
719
+ name: '',
720
+ latex: '',
721
+ write: ''
722
+ }, subscript, xToPowerOfN, nthRoot, perpindicular, parallel, overArc, logSubscript], [plusMinus, pi, theta, degree, angle, leftArrow, rightArrow, triangle, square, ln], [notEqual, absValue, smallSigma, mu, therefore, sigma, leftrightArrow, sin, cos, tan], [lessThanEqual, greaterThanEqual, {
723
+ name: '',
724
+ latex: '',
725
+ write: ''
726
+ }, {
727
+ name: '',
728
+ latex: '',
729
+ write: ''
730
+ }, infinity, {
731
+ name: '',
732
+ latex: '',
733
+ write: ''
734
+ }, {
735
+ name: '',
736
+ latex: '',
737
+ write: ''
738
+ }, csc, sec, cot]]
739
+ }];
740
+ const keysForGrade = n => {
741
+ const number = parseInt(n, 10);
742
+ n = isNaN(number) ? n : number;
743
+ if (!n) {
744
+ return [];
745
+ }
746
+ const match = gradeSets.find(gs => {
747
+ if (typeof gs.predicate === 'string') {
748
+ return gs.predicate === n;
749
+ } else {
750
+ return gs.predicate(n);
751
+ }
752
+ });
753
+ if (match) {
754
+ return match.set || [];
755
+ }
756
+ };
757
+ const ALL_KEYS = [...Object.values(basicOperators), ...Object.values(comparison), ...Object.values(constants), ...Object.values(digits), ...Object.values(exponent), ...Object.values(fractions), ...Object.values(geometry), ...Object.values(log$7), ...Object.values(matrices), ...Object.values(misc), ...Object.values(operators), ...Object.values(statistics), ...Object.values(subSup), ...Object.values(trigonometry), ...Object.values(vars)];
758
+ const normalizeAdditionalKeys = additionalKeys => {
759
+ return (additionalKeys || []).map(additionalkey => {
760
+ const {latex} = additionalkey;
761
+ const predefinedKey = (ALL_KEYS || []).find(key => latex === key.latex || latex === key.write || latex === key.command || latex === key.otherNotation);
762
+ return predefinedKey || additionalkey;
763
+ });
764
+ };
765
+ const {one, two, three, four, five, six, seven, eight, nine, zero, comma, decimalPoint} = digits;
766
+ const baseSet = [[seven, eight, nine, divide], [four, five, six, multiply], [one, two, three, minus], [zero, decimalPoint, comma, plus], [left, right, del, equals]];
767
+ const _$1 = _dll_lodash;
768
+ const sortKeys = keys => {
769
+ _$1.times(5 - keys.length, () => {
770
+ keys.push([]);
771
+ });
772
+ const out = _$1.zip.apply(null, keys);
773
+ return out;
774
+ };
775
+ const registerLineBreak = function (MQ) {
776
+ MQ.registerEmbed('newLine', () => {
777
+ return {
778
+ htmlString: '<div class="newLine"></div>',
779
+ text: () => 'testText',
780
+ latex: () => '\\embed{newLine}[]'
781
+ };
782
+ });
783
+ };
784
+ const React$a = _dll_react;
785
+ const PropTypes$9 = _dll_prop_types;
786
+ const {withStyles: withStyles$7} = _dll_material_ui__core_styles;
787
+ const debug$5 = _dll_debug;
788
+ const classNames$2 = _dll_classnames;
789
+ const MathQuill$2 = _dll_pie_framework__mathquill;
790
+ const _jsxFileName$9 = "/home/circleci/repo/node_modules/@pie-lib/math-input/src/mq/input.jsx";
791
+ let MQ$1;
792
+ if (typeof window !== 'undefined') {
793
+ MQ$1 = MathQuill$2.getInterface(2);
794
+ if (MQ$1 && MQ$1.registerEmbed) {
795
+ registerLineBreak(MQ$1);
796
+ }
797
+ }
798
+ const log$5 = debug$5('math-input:mq:input');
799
+ class Input extends React$a.Component {
800
+ constructor(...args) {
801
+ super(...args);
802
+ Input.prototype.__init.call(this);
803
+ Input.prototype.__init2.call(this);
804
+ Input.prototype.__init3.call(this);
805
+ }
806
+ static __initStatic() {
807
+ this.propTypes = {
808
+ className: PropTypes$9.string,
809
+ classes: PropTypes$9.object.isRequired,
810
+ onClick: PropTypes$9.func,
811
+ onChange: PropTypes$9.func,
812
+ latex: PropTypes$9.string,
813
+ onFocus: PropTypes$9.func,
814
+ onBlur: PropTypes$9.func
815
+ };
816
+ }
817
+ componentDidMount() {
818
+ if (!MQ$1) {
819
+ throw new Error('MQ is not defined - but component has mounted?');
820
+ }
821
+ this.mathField = MQ$1.MathField(this.input, {
822
+ handlers: {
823
+ edit: this.onInputEdit.bind(this)
824
+ }
825
+ });
826
+ this.updateLatex();
827
+ }
828
+ componentDidUpdate() {
829
+ this.updateLatex();
830
+ }
831
+ updateLatex() {
832
+ if (!this.mathField) {
833
+ return;
834
+ }
835
+ const {latex} = this.props;
836
+ if (latex) {
837
+ this.mathField.latex(latex);
838
+ }
839
+ }
840
+ clear() {
841
+ this.mathField.latex('');
842
+ return '';
843
+ }
844
+ blur() {
845
+ log$5('blur mathfield');
846
+ this.mathField.blur();
847
+ }
848
+ focus() {
849
+ log$5('focus mathfield...');
850
+ this.mathField.focus();
851
+ }
852
+ command(v) {
853
+ log$5('command: ', v);
854
+ if (Array.isArray(v)) {
855
+ v.forEach(vv => {
856
+ this.mathField.cmd(vv);
857
+ });
858
+ } else {
859
+ this.mathField.cmd(v);
860
+ }
861
+ this.mathField.focus();
862
+ return this.mathField.latex();
863
+ }
864
+ keystroke(v) {
865
+ this.mathField.keystroke(v);
866
+ this.mathField.focus();
867
+ return this.mathField.latex();
868
+ }
869
+ write(v) {
870
+ log$5('write: ', v);
871
+ this.mathField.write(v);
872
+ this.mathField.focus();
873
+ return this.mathField.latex();
874
+ }
875
+ __init() {
876
+ this.onInputEdit = () => {
877
+ log$5('[onInputEdit] ...');
878
+ const {onChange} = this.props;
879
+ if (!this.mathField) {
880
+ return;
881
+ }
882
+ if (onChange) {
883
+ onChange(this.mathField.latex());
884
+ }
885
+ };
886
+ }
887
+ __init2() {
888
+ this.refresh = () => {
889
+ this.blur();
890
+ this.focus();
891
+ };
892
+ }
893
+ __init3() {
894
+ this.onKeyPress = event => {
895
+ const keys = Object.keys(this.mathField.__controller.options);
896
+ if (keys.indexOf('ignoreNextMousedown') < 0) {
897
+ this.refresh();
898
+ }
899
+ if (event.charCode === 13) {
900
+ this.write('\\embed{newLine}[]');
901
+ this.onInputEdit();
902
+ }
903
+ };
904
+ }
905
+ shouldComponentUpdate(nextProps) {
906
+ log$5('next: ', nextProps.latex);
907
+ log$5('current: ', this.mathField.latex());
908
+ return nextProps.latex !== this.mathField.latex();
909
+ }
910
+ render() {
911
+ const {onClick, onFocus, onBlur, classes, className} = this.props;
912
+ return React$a.createElement('span', {
913
+ className: classNames$2(classes.input, className),
914
+ onKeyPress: this.onKeyPress,
915
+ onClick: onClick,
916
+ onFocus: onFocus,
917
+ onBlur: onBlur,
918
+ ref: r => this.input = r,
919
+ __self: this,
920
+ __source: {
921
+ fileName: _jsxFileName$9,
922
+ lineNumber: 149
923
+ }
924
+ });
925
+ }
926
+ }
927
+ Input.__initStatic();
928
+ const styles$5 = () => ({});
929
+ var input = withStyles$7(styles$5)(Input);
930
+ const PropTypes$8 = _dll_prop_types;
931
+ const React$9 = _dll_react;
932
+ const debug$4 = _dll_debug;
933
+ const MathQuill$1 = _dll_pie_framework__mathquill;
934
+ const _jsxFileName$8 = "/home/circleci/repo/node_modules/@pie-lib/math-input/src/mq/static.jsx";
935
+ let MQ;
936
+ if (typeof window !== 'undefined') {
937
+ MQ = MathQuill$1.getInterface(2);
938
+ }
939
+ const log$4 = debug$4('pie-lib:math-input:mq:static');
940
+ const REGEX$1 = /\\MathQuillMathField\[r\d*\]\{(.*?)\}/g;
941
+ const WHITESPACE_REGEX = / /g;
942
+ function stripSpaces(string = '') {
943
+ return string.replace(WHITESPACE_REGEX, '');
944
+ }
945
+ class Static extends React$9.Component {
946
+ constructor(...args) {
947
+ super(...args);
948
+ Static.prototype.__init.call(this);
949
+ }
950
+ static __initStatic() {
951
+ this.propTypes = {
952
+ latex: PropTypes$8.string.isRequired,
953
+ onFocus: PropTypes$8.func,
954
+ onBlur: PropTypes$8.func,
955
+ className: PropTypes$8.string,
956
+ getFieldName: PropTypes$8.func,
957
+ onSubFieldChange: PropTypes$8.func,
958
+ onSubFieldFocus: PropTypes$8.func,
959
+ setInput: PropTypes$8.func
960
+ };
961
+ }
962
+ componentDidMount() {
963
+ this.update();
964
+ updateSpans();
965
+ }
966
+ componentDidUpdate() {
967
+ this.update();
968
+ updateSpans();
969
+ }
970
+ onInputEdit(field) {
971
+ if (!this.mathField) {
972
+ return;
973
+ }
974
+ const name = this.props.getFieldName(field, this.mathField.innerFields);
975
+ if (this.props.onSubFieldChange) {
976
+ this.props.onSubFieldChange(name, field.latex());
977
+ }
978
+ }
979
+ update() {
980
+ if (!MQ) {
981
+ throw new Error('MQ is not defined - but component has mounted?');
982
+ }
983
+ if (!this.mathField) {
984
+ this.mathField = MQ.StaticMath(this.input, {
985
+ handlers: {
986
+ edit: this.onInputEdit.bind(this)
987
+ }
988
+ });
989
+ }
990
+ try {
991
+ this.mathField.parseLatex(this.props.latex);
992
+ this.mathField.latex(this.props.latex);
993
+ } catch (e) {
994
+ this.mathField.latex('\\MathQuillMathField[r1]{}');
995
+ }
996
+ }
997
+ blur() {
998
+ log$4('blur mathfield');
999
+ this.mathField.blur();
1000
+ }
1001
+ focus() {
1002
+ log$4('focus mathfield...');
1003
+ this.mathField.focus();
1004
+ }
1005
+ shouldComponentUpdate(nextProps) {
1006
+ try {
1007
+ const parsedLatex = this.mathField.parseLatex(nextProps.latex);
1008
+ const stripped = stripSpaces(parsedLatex);
1009
+ const newFieldCount = (nextProps.latex.match(REGEX$1) || []).length;
1010
+ const out = stripped !== stripSpaces(this.mathField.latex().trim()) || newFieldCount !== Object.keys(this.mathField.innerFields).length / 2;
1011
+ log$4('[shouldComponentUpdate] ', out);
1012
+ return out;
1013
+ } catch (e) {
1014
+ console.warn('Error parsing latex:', e.message, 'skip update');
1015
+ console.warn(e);
1016
+ return false;
1017
+ }
1018
+ }
1019
+ __init() {
1020
+ this.onFocus = e => {
1021
+ try {
1022
+ let rootBlock = e.target.parentElement.nextSibling;
1023
+ let id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);
1024
+ if (!id) {
1025
+ rootBlock = rootBlock.parentElement;
1026
+ id = parseInt(rootBlock.getAttribute('mathquill-block-id'), 10);
1027
+ }
1028
+ const innerField = this.mathField.innerFields.find(f => f.id === id);
1029
+ if (innerField) {
1030
+ const name = this.props.getFieldName(innerField, this.mathField.innerFields);
1031
+ if (this.props.setInput) {
1032
+ this.props.setInput(innerField);
1033
+ }
1034
+ this.props.onSubFieldFocus(name, innerField);
1035
+ }
1036
+ } catch (err) {
1037
+ console.error('error finding root block', err.message);
1038
+ }
1039
+ };
1040
+ }
1041
+ render() {
1042
+ const {onBlur, className} = this.props;
1043
+ return React$9.createElement('span', {
1044
+ className: className,
1045
+ onFocus: this.onFocus,
1046
+ onBlur: onBlur,
1047
+ ref: r => this.input = r,
1048
+ __self: this,
1049
+ __source: {
1050
+ fileName: _jsxFileName$8,
1051
+ lineNumber: 137
1052
+ }
1053
+ });
1054
+ }
1055
+ }
1056
+ Static.__initStatic();
1057
+ const React$8 = _dll_react;
1058
+ const PropTypes$7 = _dll_prop_types;
1059
+ const {Button: Button$1} = _dll_material_ui__core;
1060
+ const {IconButton: IconButton$1} = _dll_material_ui__core;
1061
+ const {colors: {green: green}} = _dll_material_ui__core;
1062
+ const {withStyles: withStyles$6} = _dll_material_ui__core_styles;
1063
+ const classNames$1 = _dll_classnames;
1064
+ const {lighten: lighten} = _dll_material_ui__core_styles_color_manipulator;
1065
+ const {fade: fade} = _dll_material_ui__core_styles_color_manipulator;
1066
+ const debug$3 = _dll_debug;
1067
+ const _ = _dll_lodash;
1068
+ const _jsxFileName$7 = "/home/circleci/repo/node_modules/@pie-lib/math-input/src/keypad/index.jsx";
1069
+ const log$3 = debug$3('pie-lib:math-inline:keypad');
1070
+ const LatexButton = withStyles$6(theme => ({
1071
+ root: {
1072
+ textTransform: 'none',
1073
+ padding: 0,
1074
+ margin: 0,
1075
+ fontSize: '110% !important'
1076
+ },
1077
+ latexButton: {
1078
+ pointerEvents: 'none',
1079
+ textTransform: 'none !important',
1080
+ '& .mq-scaled.mq-sqrt-prefix': {
1081
+ transform: 'scale(1, 0.9) !important'
1082
+ },
1083
+ '& .mq-sup-only .mq-sup': {
1084
+ marginBottom: '0.9px !important'
1085
+ },
1086
+ '& .mq-empty': {
1087
+ backgroundColor: `${fade(theme.palette.secondary.main, 0.4)} !important`
1088
+ },
1089
+ '& .mq-overline .mq-overline-inner': {
1090
+ borderTop: '2px solid black'
1091
+ },
1092
+ '& .mq-overarrow': {
1093
+ width: '30px',
1094
+ marginTop: '0 !important',
1095
+ borderTop: '2px solid black',
1096
+ '&.mq-arrow-both': {
1097
+ '& *': {
1098
+ lineHeight: '1 !important'
1099
+ },
1100
+ '&:before': {
1101
+ fontSize: '80%',
1102
+ left: 'calc(-13%)',
1103
+ top: '-0.25em'
1104
+ },
1105
+ '&:after': {
1106
+ fontSize: '80% !important',
1107
+ right: 'calc(-13%) !important',
1108
+ top: '-1.5em'
1109
+ },
1110
+ '&.mq-empty:before': {
1111
+ fontSize: '80%',
1112
+ left: 'calc(-13%)',
1113
+ top: '-0.25em'
1114
+ },
1115
+ '&.mq-empty:after': {
1116
+ fontSize: '80%',
1117
+ right: 'calc(-13%)',
1118
+ top: '-0.25em'
1119
+ },
1120
+ '&.mq-empty': {
1121
+ minHeight: '1.4em'
1122
+ }
1123
+ },
1124
+ '&.mq-arrow-right:before': {
1125
+ fontSize: '80%',
1126
+ right: 'calc(-13%)',
1127
+ top: '-0.25em'
1128
+ },
1129
+ '& .mq-overarrow-inner': {
1130
+ border: 'none !important'
1131
+ },
1132
+ '& .mq-overarrow-inner .mq-overarrow-inner-right': {
1133
+ display: 'none !important'
1134
+ }
1135
+ },
1136
+ '& .mq-root-block': {
1137
+ padding: '5px'
1138
+ },
1139
+ '& .mq-overarrow.mq-arrow-both.mq-empty:after': {
1140
+ right: '-6px',
1141
+ fontSize: '80% !important',
1142
+ top: '-3px'
1143
+ },
1144
+ '& .mq-overarrow.mq-arrow-right.mq-empty:before': {
1145
+ right: '-5px',
1146
+ fontSize: '80% !important',
1147
+ top: '-3px'
1148
+ },
1149
+ '& .mq-overarrow.mq-arrow-both.mq-empty:before': {
1150
+ left: '-6px',
1151
+ fontSize: '80% !important',
1152
+ top: '-3px'
1153
+ },
1154
+ '& .mq-longdiv-inner': {
1155
+ borderTop: '1px solid !important',
1156
+ paddingTop: '1.5px !important'
1157
+ },
1158
+ '& .mq-parallelogram': {
1159
+ lineHeight: 0.85
1160
+ },
1161
+ '& .mq-overarc': {
1162
+ borderTop: '2px solid black !important',
1163
+ '& .mq-overline-inner': {
1164
+ borderTop: 'none !important',
1165
+ paddingTop: '0 !important'
1166
+ }
1167
+ }
1168
+ },
1169
+ parallelButton: {
1170
+ fontStyle: 'italic'
1171
+ },
1172
+ leftRightArrowButton: {
1173
+ '& .mq-overarrow.mq-arrow-both': {
1174
+ '& .mq-overline-inner': {
1175
+ borderTop: 'none !important',
1176
+ paddingTop: '0 !important'
1177
+ },
1178
+ '&:after': {
1179
+ top: '-1.64em !important'
1180
+ }
1181
+ }
1182
+ }
1183
+ }))(props => {
1184
+ let buttonClass;
1185
+ if (props.latex === '\\parallel') {
1186
+ buttonClass = classNames$1(props.classes.latexButton, props.mqClassName, props.classes.parallelButton);
1187
+ } else if (props.latex === '\\overleftrightarrow{\\overline{}}') {
1188
+ buttonClass = classNames$1(props.classes.latexButton, props.mqClassName, props.classes.leftRightArrowButton);
1189
+ } else {
1190
+ buttonClass = classNames$1(props.classes.latexButton, props.mqClassName);
1191
+ }
1192
+ return React$8.createElement(Button$1, {
1193
+ className: classNames$1(props.classes.root, props.className),
1194
+ onClick: props.onClick,
1195
+ __self: undefined,
1196
+ __source: {
1197
+ fileName: _jsxFileName$7,
1198
+ lineNumber: 149
1199
+ }
1200
+ }, React$8.createElement(Static, {
1201
+ className: buttonClass,
1202
+ latex: props.latex,
1203
+ __self: undefined,
1204
+ __source: {
1205
+ fileName: _jsxFileName$7,
1206
+ lineNumber: 150
1207
+ }
1208
+ }));
1209
+ });
1210
+ class KeyPad extends React$8.Component {
1211
+ constructor(...args) {
1212
+ super(...args);
1213
+ KeyPad.prototype.__init.call(this);
1214
+ KeyPad.prototype.__init2.call(this);
1215
+ KeyPad.prototype.__init3.call(this);
1216
+ }
1217
+ static __initStatic() {
1218
+ this.propTypes = {
1219
+ classes: PropTypes$7.object.isRequired,
1220
+ className: PropTypes$7.string,
1221
+ baseSet: PropTypes$7.array,
1222
+ additionalKeys: PropTypes$7.array,
1223
+ onPress: PropTypes$7.func.isRequired,
1224
+ onFocus: PropTypes$7.func,
1225
+ noDecimal: PropTypes$7.bool,
1226
+ mode: PropTypes$7.string
1227
+ };
1228
+ }
1229
+ static __initStatic2() {
1230
+ this.defaultProps = {
1231
+ baseSet: baseSet,
1232
+ noDecimal: false
1233
+ };
1234
+ }
1235
+ __init() {
1236
+ this.buttonClick = key => {
1237
+ log$3('[buttonClick]', key);
1238
+ const {onPress} = this.props;
1239
+ onPress(key);
1240
+ };
1241
+ }
1242
+ __init2() {
1243
+ this.flowKeys = (base, extras) => {
1244
+ const transposed = [...sortKeys(base), ...sortKeys(extras)];
1245
+ return _.flatten(transposed);
1246
+ };
1247
+ }
1248
+ __init3() {
1249
+ this.keyIsNotAllowed = key => {
1250
+ const {noDecimal} = this.props;
1251
+ if ((key.write === '.' && key.label === '.' || key.write === ',' && key.label === ',') && noDecimal) {
1252
+ return true;
1253
+ }
1254
+ return false;
1255
+ };
1256
+ }
1257
+ render() {
1258
+ const {classes, className, baseSet, additionalKeys, onFocus, mode} = this.props;
1259
+ const noBaseSet = ['non-negative-integers', 'integers', 'decimals', 'fractions', 'item-authoring'];
1260
+ const keysWithoutBaseSet = noBaseSet.includes(mode);
1261
+ const allKeys = keysWithoutBaseSet ? this.flowKeys([], additionalKeys || []) : this.flowKeys(baseSet, additionalKeys || []);
1262
+ const shift = allKeys.length % 5 ? 1 : 0;
1263
+ const style = {
1264
+ gridTemplateColumns: `repeat(${Math.floor(allKeys.length / 5) + shift}, minmax(min-content, 150px))`
1265
+ };
1266
+ return React$8.createElement('div', {
1267
+ className: classNames$1(classes.keys, className),
1268
+ style: style,
1269
+ onFocus: onFocus,
1270
+ __self: this,
1271
+ __source: {
1272
+ fileName: _jsxFileName$7,
1273
+ lineNumber: 217
1274
+ }
1275
+ }, allKeys.map((k, index) => {
1276
+ const onClick = this.buttonClick.bind(this, k);
1277
+ if (!k) {
1278
+ return React$8.createElement('span', {
1279
+ key: `empty-${index}`,
1280
+ __self: this,
1281
+ __source: {
1282
+ fileName: _jsxFileName$7,
1283
+ lineNumber: 222
1284
+ }
1285
+ });
1286
+ }
1287
+ const common = {
1288
+ onClick,
1289
+ className: classNames$1(classes.labelButton, !keysWithoutBaseSet && classes[k.category], k.label === ',' && classes.comma, k.label === '.' && classes.dot),
1290
+ disabled: this.keyIsNotAllowed(k),
1291
+ key: `${k.label || k.latex || k.command}-${index}`
1292
+ };
1293
+ if (k.latex) {
1294
+ return React$8.createElement(LatexButton, {
1295
+ latex: k.latex,
1296
+ ...common,
1297
+ className: classes.latexButton,
1298
+ __self: this,
1299
+ __source: {
1300
+ fileName: _jsxFileName$7,
1301
+ lineNumber: 238
1302
+ }
1303
+ });
1304
+ }
1305
+ if (k.label) {
1306
+ return React$8.createElement(Button$1, {
1307
+ ...common,
1308
+ __self: this,
1309
+ __source: {
1310
+ fileName: _jsxFileName$7,
1311
+ lineNumber: 242
1312
+ }
1313
+ }, k.label);
1314
+ } else {
1315
+ const Icon = k.icon ? k.icon : 'div';
1316
+ return React$8.createElement(IconButton$1, {
1317
+ tabIndex: '-1',
1318
+ ...common,
1319
+ __self: this,
1320
+ __source: {
1321
+ fileName: _jsxFileName$7,
1322
+ lineNumber: 247
1323
+ }
1324
+ }, React$8.createElement(Icon, {
1325
+ className: classes.icon,
1326
+ __self: this,
1327
+ __source: {
1328
+ fileName: _jsxFileName$7,
1329
+ lineNumber: 248
1330
+ }
1331
+ }));
1332
+ }
1333
+ }));
1334
+ }
1335
+ }
1336
+ KeyPad.__initStatic();
1337
+ KeyPad.__initStatic2();
1338
+ const styles$4 = theme => ({
1339
+ keys: {
1340
+ '& *': {
1341
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
1342
+ },
1343
+ width: '100%',
1344
+ display: 'grid',
1345
+ gridTemplateRows: 'repeat(5, minmax(40px, 60px))',
1346
+ gridRowGap: '0px',
1347
+ gridColumnGap: '0px',
1348
+ gridAutoFlow: 'column'
1349
+ },
1350
+ holder: {
1351
+ position: 'relative',
1352
+ width: '100%',
1353
+ height: '100%',
1354
+ backgroundColor: '#cef',
1355
+ borderRadius: 0,
1356
+ padding: `${theme.spacing.unit}px 0 ${theme.spacing.unit}px 0`
1357
+ },
1358
+ labelButton: {
1359
+ minWidth: 'auto',
1360
+ fontSize: '140% !important',
1361
+ backgroundColor: lighten(theme.palette.primary.light, 0.5),
1362
+ '&:hover': {
1363
+ backgroundColor: lighten(theme.palette.primary.light, 0.7)
1364
+ },
1365
+ borderRadius: 0
1366
+ },
1367
+ latexButton: {
1368
+ minWidth: 'auto',
1369
+ borderRadius: 0,
1370
+ backgroundColor: lighten(theme.palette.primary.light, 0.5),
1371
+ '&:hover': {
1372
+ backgroundColor: lighten(theme.palette.primary.light, 0.7)
1373
+ }
1374
+ },
1375
+ base: {},
1376
+ operators: {
1377
+ backgroundColor: lighten(theme.palette.secondary.light, 0.5),
1378
+ '&:hover': {
1379
+ backgroundColor: lighten(theme.palette.secondary.light, 0.7)
1380
+ }
1381
+ },
1382
+ comparison: {
1383
+ backgroundColor: lighten(green[500], 0.5),
1384
+ '&:hover': {
1385
+ backgroundColor: lighten(green[500], 0.7)
1386
+ }
1387
+ },
1388
+ comma: {
1389
+ fontSize: '200% !important',
1390
+ lineHeight: '100%'
1391
+ },
1392
+ dot: {
1393
+ fontSize: '200% !important',
1394
+ lineHeight: '100%'
1395
+ },
1396
+ icon: {
1397
+ height: '30px'
1398
+ }
1399
+ });
1400
+ var Keypad = withStyles$6(styles$4)(KeyPad);
1401
+ const React$7 = _dll_react;
1402
+ const PropTypes$6 = _dll_prop_types;
1403
+ const _jsxFileName$6 = "/home/circleci/repo/node_modules/@pie-lib/math-input/src/horizontal-keypad.jsx";
1404
+ const toOldModel = d => {
1405
+ if (d.command) {
1406
+ return {
1407
+ value: d.command,
1408
+ type: 'command'
1409
+ };
1410
+ } else if (d.write) {
1411
+ return {
1412
+ value: d.write
1413
+ };
1414
+ } else if (d.keystroke) {
1415
+ return {
1416
+ type: 'cursor',
1417
+ value: d.keystroke
1418
+ };
1419
+ }
1420
+ };
1421
+ class HorizontalKeypad extends React$7.Component {
1422
+ constructor(...args) {
1423
+ super(...args);
1424
+ HorizontalKeypad.prototype.__init.call(this);
1425
+ }
1426
+ static __initStatic() {
1427
+ this.propTypes = {
1428
+ className: PropTypes$6.string,
1429
+ mode: PropTypes$6.oneOfType([PropTypes$6.string, PropTypes$6.number]),
1430
+ onClick: PropTypes$6.func.isRequired,
1431
+ onFocus: PropTypes$6.func,
1432
+ noDecimal: PropTypes$6.bool,
1433
+ additionalKeys: PropTypes$6.array
1434
+ };
1435
+ }
1436
+ static __initStatic2() {
1437
+ this.defaultProps = {
1438
+ mode: 'scientific',
1439
+ noDecimal: false,
1440
+ additionalKeys: []
1441
+ };
1442
+ }
1443
+ __init() {
1444
+ this.keypadPress = data => {
1445
+ const {onClick} = this.props;
1446
+ onClick(toOldModel(data));
1447
+ };
1448
+ }
1449
+ render() {
1450
+ const {mode, onFocus, noDecimal, className, additionalKeys} = this.props;
1451
+ const normalizedKeys = normalizeAdditionalKeys(additionalKeys);
1452
+ return React$7.createElement(Keypad, {
1453
+ className: className,
1454
+ onFocus: onFocus,
1455
+ noDecimal: noDecimal,
1456
+ additionalKeys: extendKeySet(keysForGrade(mode), normalizedKeys),
1457
+ onPress: this.keypadPress,
1458
+ mode: mode,
1459
+ __self: this,
1460
+ __source: {
1461
+ fileName: _jsxFileName$6,
1462
+ lineNumber: 44
1463
+ }
1464
+ });
1465
+ }
1466
+ }
1467
+ HorizontalKeypad.__initStatic();
1468
+ HorizontalKeypad.__initStatic2();
1469
+ const updateSpans = () => {
1470
+ const spans = Array.from(document.querySelectorAll('span[mathquill-command-id]'));
1471
+ (spans || []).forEach(span => {
1472
+ if (span && span.innerText === '∥' && span.className !== 'mq-editable-field') {
1473
+ span.style.fontSize = '32px';
1474
+ }
1475
+ });
1476
+ };
1477
+ const ResponseTypes = {
1478
+ advanced: 'Advanced Multi',
1479
+ simple: 'Simple'
1480
+ };
1481
+ const React$6 = _dll_react;
1482
+ const debug$2 = _dll_debug;
1483
+ const PropTypes$5 = _dll_prop_types;
1484
+ const cx$3 = _dll_classnames;
1485
+ const {Button: Button} = _dll_material_ui__core;
1486
+ const {MenuItem: MenuItem} = _dll_material_ui__core;
1487
+ const {Select: Select} = _dll_material_ui__core;
1488
+ const {withStyles: withStyles$5} = _dll_material_ui__core_styles;
1489
+ const {color: color$2} = _dll_pie_lib__render_ui;
1490
+ const {InputContainer: InputContainer} = _dll_pie_lib__render_ui;
1491
+ const _jsxFileName$5 = "/home/circleci/repo/node_modules/@pie-lib/math-toolbar/src/editor-and-pad.jsx";
1492
+ const log$2 = debug$2('@pie-lib:math-toolbar:editor-and-pad');
1493
+ const decimalRegex = /\.|,/g;
1494
+ const toNodeData = data => {
1495
+ if (!data) {
1496
+ return;
1497
+ }
1498
+ const {type, value} = data;
1499
+ if (type === 'command' || type === 'cursor') {
1500
+ return data;
1501
+ } else if (type === 'answer') {
1502
+ return {
1503
+ type: 'answer',
1504
+ ...data
1505
+ };
1506
+ } else if (value === 'clear') {
1507
+ return {
1508
+ type: 'clear'
1509
+ };
1510
+ } else {
1511
+ return {
1512
+ type: 'write',
1513
+ value
1514
+ };
1515
+ }
1516
+ };
1517
+ class EditorAndPad extends React$6.Component {
1518
+ static __initStatic() {
1519
+ this.propTypes = {
1520
+ classNames: PropTypes$5.object,
1521
+ keypadMode: PropTypes$5.oneOfType([PropTypes$5.string, PropTypes$5.number]),
1522
+ autoFocus: PropTypes$5.bool,
1523
+ allowAnswerBlock: PropTypes$5.bool,
1524
+ showKeypad: PropTypes$5.bool,
1525
+ controlledKeypad: PropTypes$5.bool,
1526
+ controlledKeypadMode: PropTypes$5.bool,
1527
+ noDecimal: PropTypes$5.bool,
1528
+ additionalKeys: PropTypes$5.array,
1529
+ latex: PropTypes$5.string.isRequired,
1530
+ onAnswerBlockAdd: PropTypes$5.func,
1531
+ onFocus: PropTypes$5.func,
1532
+ onBlur: PropTypes$5.func,
1533
+ onChange: PropTypes$5.func.isRequired,
1534
+ classes: PropTypes$5.object
1535
+ };
1536
+ }
1537
+ constructor(props) {
1538
+ super(props);
1539
+ EditorAndPad.prototype.__init.call(this);
1540
+ EditorAndPad.prototype.__init2.call(this);
1541
+ EditorAndPad.prototype.__init3.call(this);
1542
+ EditorAndPad.prototype.__init4.call(this);
1543
+ this.state = {
1544
+ equationEditor: 'item-authoring'
1545
+ };
1546
+ }
1547
+ componentDidMount() {
1548
+ if (this.input && this.props.autoFocus) {
1549
+ this.input.focus();
1550
+ }
1551
+ }
1552
+ __init() {
1553
+ this.onClick = data => {
1554
+ const {noDecimal} = this.props;
1555
+ const c = toNodeData(data);
1556
+ log$2('mathChange: ', c);
1557
+ if (noDecimal && (c.value === '.' || c.value === ',')) {
1558
+ return;
1559
+ }
1560
+ if (c.type === 'clear') {
1561
+ log$2('call clear...');
1562
+ this.input.clear();
1563
+ } else if (c.type === 'command') {
1564
+ this.input.command(c.value);
1565
+ } else if (c.type === 'cursor') {
1566
+ this.input.keystroke(c.value);
1567
+ } else if (c.type === 'answer') {
1568
+ this.input.write('%response%');
1569
+ } else {
1570
+ this.input.write(c.value);
1571
+ }
1572
+ };
1573
+ }
1574
+ __init2() {
1575
+ this.onAnswerBlockClick = () => {
1576
+ this.props.onAnswerBlockAdd();
1577
+ this.onClick({
1578
+ type: 'answer'
1579
+ });
1580
+ };
1581
+ }
1582
+ __init3() {
1583
+ this.onEditorChange = latex => {
1584
+ const {onChange, noDecimal} = this.props;
1585
+ updateSpans();
1586
+ if (noDecimal && (latex.indexOf('.') !== -1 || latex.indexOf(',') !== -1) && this.input) {
1587
+ this.input.clear();
1588
+ this.input.write(latex.replace(decimalRegex, ''));
1589
+ return;
1590
+ }
1591
+ onChange(latex);
1592
+ };
1593
+ }
1594
+ shouldComponentUpdate(nextProps, nextState) {
1595
+ const inputIsDifferent = this.input.mathField.latex() !== nextProps.latex;
1596
+ log$2('[shouldComponentUpdate] ', 'inputIsDifferent: ', inputIsDifferent);
1597
+ if (!inputIsDifferent && this.props.keypadMode !== nextProps.keypadMode) {
1598
+ return true;
1599
+ }
1600
+ if (!inputIsDifferent && this.props.noDecimal !== nextProps.noDecimal) {
1601
+ return true;
1602
+ }
1603
+ if (!inputIsDifferent && this.state.equationEditor !== nextState.equationEditor) {
1604
+ return true;
1605
+ }
1606
+ if (!inputIsDifferent && this.props.controlledKeypad) {
1607
+ return this.props.showKeypad !== nextProps.showKeypad;
1608
+ }
1609
+ return inputIsDifferent;
1610
+ }
1611
+ __init4() {
1612
+ this.onEditorTypeChange = evt => {
1613
+ this.setState({
1614
+ equationEditor: evt.target.value
1615
+ });
1616
+ };
1617
+ }
1618
+ render() {
1619
+ const {classNames, keypadMode, allowAnswerBlock, additionalKeys, controlledKeypad, controlledKeypadMode, showKeypad, noDecimal, latex, onFocus, onBlur, classes} = this.props;
1620
+ const shouldShowKeypad = !controlledKeypad || controlledKeypad && showKeypad;
1621
+ log$2('[render]', latex);
1622
+ return React$6.createElement('div', {
1623
+ className: cx$3(classes.mathToolbar, classNames.mathToolbar),
1624
+ __self: this,
1625
+ __source: {
1626
+ fileName: _jsxFileName$5,
1627
+ lineNumber: 160
1628
+ }
1629
+ }, React$6.createElement('div', {
1630
+ className: classes.inputAndTypeContainer,
1631
+ __self: this,
1632
+ __source: {
1633
+ fileName: _jsxFileName$5,
1634
+ lineNumber: 161
1635
+ }
1636
+ }, controlledKeypadMode && React$6.createElement(InputContainer, {
1637
+ label: "Equation Editor",
1638
+ className: classes.selectContainer,
1639
+ __self: this,
1640
+ __source: {
1641
+ fileName: _jsxFileName$5,
1642
+ lineNumber: 163
1643
+ }
1644
+ }, React$6.createElement(Select, {
1645
+ className: classes.select,
1646
+ onChange: this.onEditorTypeChange,
1647
+ value: this.state.equationEditor,
1648
+ __self: this,
1649
+ __source: {
1650
+ fileName: _jsxFileName$5,
1651
+ lineNumber: 164
1652
+ }
1653
+ }, React$6.createElement(MenuItem, {
1654
+ value: "non-negative-integers",
1655
+ __self: this,
1656
+ __source: {
1657
+ fileName: _jsxFileName$5,
1658
+ lineNumber: 169
1659
+ }
1660
+ }, "Numeric - Non-Negative Integers"), React$6.createElement(MenuItem, {
1661
+ value: "integers",
1662
+ __self: this,
1663
+ __source: {
1664
+ fileName: _jsxFileName$5,
1665
+ lineNumber: 170
1666
+ }
1667
+ }, "Numeric - Integers"), React$6.createElement(MenuItem, {
1668
+ value: "decimals",
1669
+ __self: this,
1670
+ __source: {
1671
+ fileName: _jsxFileName$5,
1672
+ lineNumber: 171
1673
+ }
1674
+ }, "Numeric - Decimals"), React$6.createElement(MenuItem, {
1675
+ value: "fractions",
1676
+ __self: this,
1677
+ __source: {
1678
+ fileName: _jsxFileName$5,
1679
+ lineNumber: 172
1680
+ }
1681
+ }, "Numeric - Fractions"), React$6.createElement(MenuItem, {
1682
+ value: 1,
1683
+ __self: this,
1684
+ __source: {
1685
+ fileName: _jsxFileName$5,
1686
+ lineNumber: 173
1687
+ }
1688
+ }, "Grade 1 - 2"), React$6.createElement(MenuItem, {
1689
+ value: 3,
1690
+ __self: this,
1691
+ __source: {
1692
+ fileName: _jsxFileName$5,
1693
+ lineNumber: 174
1694
+ }
1695
+ }, "Grade 3 - 5"), React$6.createElement(MenuItem, {
1696
+ value: 6,
1697
+ __self: this,
1698
+ __source: {
1699
+ fileName: _jsxFileName$5,
1700
+ lineNumber: 175
1701
+ }
1702
+ }, "Grade 6 - 7"), React$6.createElement(MenuItem, {
1703
+ value: 8,
1704
+ __self: this,
1705
+ __source: {
1706
+ fileName: _jsxFileName$5,
1707
+ lineNumber: 176
1708
+ }
1709
+ }, "Grade 8 - HS"), React$6.createElement(MenuItem, {
1710
+ value: 'geometry',
1711
+ __self: this,
1712
+ __source: {
1713
+ fileName: _jsxFileName$5,
1714
+ lineNumber: 177
1715
+ }
1716
+ }, "Geometry"), React$6.createElement(MenuItem, {
1717
+ value: 'advanced-algebra',
1718
+ __self: this,
1719
+ __source: {
1720
+ fileName: _jsxFileName$5,
1721
+ lineNumber: 178
1722
+ }
1723
+ }, "Advanced Algebra"), React$6.createElement(MenuItem, {
1724
+ value: 'statistics',
1725
+ __self: this,
1726
+ __source: {
1727
+ fileName: _jsxFileName$5,
1728
+ lineNumber: 179
1729
+ }
1730
+ }, "Statistics"), React$6.createElement(MenuItem, {
1731
+ value: 'item-authoring',
1732
+ __self: this,
1733
+ __source: {
1734
+ fileName: _jsxFileName$5,
1735
+ lineNumber: 180
1736
+ }
1737
+ }, "Item Authoring"))), React$6.createElement(input, {
1738
+ onFocus: onFocus,
1739
+ onBlur: onBlur,
1740
+ className: cx$3(classes.mathEditor, classNames.editor, !controlledKeypadMode ? classes.longMathEditor : ''),
1741
+ innerRef: r => this.input = r,
1742
+ latex: latex,
1743
+ onChange: this.onEditorChange,
1744
+ __self: this,
1745
+ __source: {
1746
+ fileName: _jsxFileName$5,
1747
+ lineNumber: 184
1748
+ }
1749
+ })), allowAnswerBlock && React$6.createElement(Button, {
1750
+ className: classes.addAnswerBlockButton,
1751
+ type: "primary",
1752
+ style: {
1753
+ bottom: shouldShowKeypad ? '320px' : '20px'
1754
+ },
1755
+ onClick: this.onAnswerBlockClick,
1756
+ __self: this,
1757
+ __source: {
1758
+ fileName: _jsxFileName$5,
1759
+ lineNumber: 198
1760
+ }
1761
+ }, "+ Response Area"), React$6.createElement('hr', {
1762
+ className: classes.hr,
1763
+ __self: this,
1764
+ __source: {
1765
+ fileName: _jsxFileName$5,
1766
+ lineNumber: 207
1767
+ }
1768
+ }), shouldShowKeypad && React$6.createElement(HorizontalKeypad, {
1769
+ additionalKeys: additionalKeys,
1770
+ mode: controlledKeypadMode ? this.state.equationEditor : keypadMode,
1771
+ onClick: this.onClick,
1772
+ noDecimal: noDecimal,
1773
+ __self: this,
1774
+ __source: {
1775
+ fileName: _jsxFileName$5,
1776
+ lineNumber: 209
1777
+ }
1778
+ }));
1779
+ }
1780
+ }
1781
+ EditorAndPad.__initStatic();
1782
+ const styles$3 = theme => ({
1783
+ inputAndTypeContainer: {
1784
+ display: 'flex',
1785
+ alignItems: 'center',
1786
+ '& *': {
1787
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
1788
+ },
1789
+ '& .mq-overarrow.mq-arrow-both': {
1790
+ minWidth: '1.23em',
1791
+ '& *': {
1792
+ lineHeight: '1 !important'
1793
+ },
1794
+ '&:before': {
1795
+ top: '-0.4em',
1796
+ left: '-1px'
1797
+ },
1798
+ '&:after': {
1799
+ top: '-2.36em',
1800
+ right: '-1px'
1801
+ },
1802
+ '&.mq-empty:after': {
1803
+ top: '-0.45em'
1804
+ }
1805
+ },
1806
+ '& .mq-overarrow.mq-arrow-right': {
1807
+ '&:before': {
1808
+ top: '-0.4em',
1809
+ right: '-1px'
1810
+ }
1811
+ }
1812
+ },
1813
+ selectContainer: {
1814
+ flex: 'initial',
1815
+ width: '25%',
1816
+ minWidth: '100px',
1817
+ marginLeft: '15px',
1818
+ marginTop: '5px',
1819
+ marginBottom: '5px',
1820
+ marginRight: '5px'
1821
+ },
1822
+ mathEditor: {
1823
+ maxWidth: '400px',
1824
+ color: color$2.text(),
1825
+ backgroundColor: color$2.background(),
1826
+ padding: theme.spacing.unit,
1827
+ marginTop: theme.spacing.unit,
1828
+ marginBottom: theme.spacing.unit
1829
+ },
1830
+ longMathEditor: {
1831
+ maxWidth: '500px'
1832
+ },
1833
+ addAnswerBlockButton: {
1834
+ position: 'absolute',
1835
+ right: '12px',
1836
+ border: '1px solid lightgrey'
1837
+ },
1838
+ hr: {
1839
+ padding: 0,
1840
+ margin: 0,
1841
+ height: '1px',
1842
+ border: 'none',
1843
+ borderBottom: `solid 1px ${theme.palette.primary.main}`
1844
+ },
1845
+ mathToolbar: {
1846
+ zIndex: 9,
1847
+ position: 'relative',
1848
+ textAlign: 'center',
1849
+ width: 'auto',
1850
+ '& > .mq-math-mode': {
1851
+ border: 'solid 1px lightgrey'
1852
+ },
1853
+ '& > .mq-focused': {
1854
+ outline: 'none',
1855
+ boxShadow: 'none',
1856
+ border: `dotted 1px ${theme.palette.primary.main}`,
1857
+ borderRadius: '0px'
1858
+ },
1859
+ '& .mq-overarrow-inner': {
1860
+ border: 'none !important',
1861
+ paddingTop: '0 !important'
1862
+ },
1863
+ '& .mq-overarrow-inner-right': {
1864
+ display: 'none !important'
1865
+ },
1866
+ '& .mq-overarrow-inner-left': {
1867
+ display: 'none !important'
1868
+ },
1869
+ '& .mq-longdiv-inner': {
1870
+ borderTop: '1px solid !important',
1871
+ paddingTop: '1.5px !important'
1872
+ },
1873
+ '& .mq-overarrow.mq-arrow-both': {
1874
+ minWidth: '1.23em'
1875
+ },
1876
+ '& .mq-parallelogram': {
1877
+ lineHeight: 0.85
1878
+ }
1879
+ }
1880
+ });
1881
+ var EditorAndPad$1 = withStyles$5(styles$3)(EditorAndPad);
1882
+ const React$5 = _dll_react;
1883
+ const {IconButton: IconButton} = _dll_material_ui__core;
1884
+ const {Check: Check} = _dll_material_ui__icons;
1885
+ const {withStyles: withStyles$4} = _dll_material_ui__core_styles;
1886
+ const PropTypes$4 = _dll_prop_types;
1887
+ const _jsxFileName$4 = "/home/circleci/repo/node_modules/@pie-lib/math-toolbar/src/done-button.jsx";
1888
+ const RawDoneButton = ({classes, onClick}) => React$5.createElement(IconButton, {
1889
+ 'aria-label': "Done",
1890
+ className: classes.iconRoot,
1891
+ onClick: onClick,
1892
+ classes: {
1893
+ label: classes.label,
1894
+ root: classes.iconRoot
1895
+ },
1896
+ __self: undefined,
1897
+ __source: {
1898
+ fileName: _jsxFileName$4,
1899
+ lineNumber: 9
1900
+ }
1901
+ }, React$5.createElement(Check, {
1902
+ __self: undefined,
1903
+ __source: {
1904
+ fileName: _jsxFileName$4,
1905
+ lineNumber: 18
1906
+ }
1907
+ }));
1908
+ RawDoneButton.propTypes = {
1909
+ classes: PropTypes$4.object.isRequired,
1910
+ onClick: PropTypes$4.func
1911
+ };
1912
+ const styles$2 = {
1913
+ iconRoot: {
1914
+ verticalAlign: 'top',
1915
+ width: '28px',
1916
+ height: '28px',
1917
+ color: '#00bb00'
1918
+ },
1919
+ label: {
1920
+ position: 'absolute',
1921
+ top: '2px'
1922
+ }
1923
+ };
1924
+ const DoneButton = withStyles$4(styles$2)(RawDoneButton);
1925
+ const React$4 = _dll_react;
1926
+ const classNames = _dll_classnames;
1927
+ const debug$1 = _dll_debug;
1928
+ const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
1929
+ const PropTypes$3 = _dll_prop_types;
1930
+ const _jsxFileName$3 = "/home/circleci/repo/node_modules/@pie-lib/math-toolbar/src/math-preview.jsx";
1931
+ const log$1 = debug$1('@pie-lib:math-toolbar:math-preview');
1932
+ class RawMathPreview extends React$4.Component {
1933
+ static __initStatic() {
1934
+ this.propTypes = {
1935
+ latex: PropTypes$3.string,
1936
+ node: PropTypes$3.object,
1937
+ classes: PropTypes$3.object,
1938
+ isSelected: PropTypes$3.bool,
1939
+ onFocus: PropTypes$3.func,
1940
+ onBlur: PropTypes$3.func
1941
+ };
1942
+ }
1943
+ render() {
1944
+ log$1('[render] data: ', this.props.node.data);
1945
+ const latex = this.props.node.data.get('latex');
1946
+ const {classes, isSelected, onFocus, onBlur} = this.props;
1947
+ return React$4.createElement('div', {
1948
+ className: classNames(classes.root, isSelected && classes.selected),
1949
+ __self: this,
1950
+ __source: {
1951
+ fileName: _jsxFileName$3,
1952
+ lineNumber: 25
1953
+ }
1954
+ }, ' ', React$4.createElement('span', {
1955
+ className: classes.insideOverlay,
1956
+ __self: this,
1957
+ __source: {
1958
+ fileName: _jsxFileName$3,
1959
+ lineNumber: 27
1960
+ }
1961
+ }), React$4.createElement(Static, {
1962
+ latex: latex,
1963
+ onFocus: onFocus,
1964
+ onBlur: onBlur,
1965
+ __self: this,
1966
+ __source: {
1967
+ fileName: _jsxFileName$3,
1968
+ lineNumber: 28
1969
+ }
1970
+ }));
1971
+ }
1972
+ }
1973
+ RawMathPreview.__initStatic();
1974
+ const mp = theme => ({
1975
+ root: {
1976
+ display: 'inline-flex',
1977
+ alignItems: 'center',
1978
+ position: 'relative',
1979
+ '& > .mq-math-mode': {
1980
+ border: 'solid 1px lightgrey'
1981
+ },
1982
+ '& > .mq-focused': {
1983
+ outline: 'none',
1984
+ boxShadow: 'none',
1985
+ border: 'solid 1px black',
1986
+ borderRadius: '0px'
1987
+ },
1988
+ '& *': {
1989
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif !important'
1990
+ },
1991
+ '& .mq-overarrow-inner': {
1992
+ paddingTop: '0 !important',
1993
+ border: 'none !important'
1994
+ },
1995
+ '& .mq-overarrow.mq-arrow-both': {
1996
+ minWidth: '1.23em',
1997
+ '& *': {
1998
+ lineHeight: '1 !important'
1999
+ },
2000
+ '&:before': {
2001
+ top: '-0.4em',
2002
+ left: '-1px'
2003
+ },
2004
+ '&:after': {
2005
+ top: '-2.36em',
2006
+ right: '-1px'
2007
+ },
2008
+ '&.mq-empty:after': {
2009
+ top: '-0.45em'
2010
+ }
2011
+ },
2012
+ '& .mq-overarrow.mq-arrow-right': {
2013
+ '&:before': {
2014
+ top: '-0.4em',
2015
+ right: '-1px'
2016
+ }
2017
+ },
2018
+ '& .mq-overarrow-inner-right': {
2019
+ display: 'none !important'
2020
+ },
2021
+ '& .mq-overarrow-inner-left': {
2022
+ display: 'none !important'
2023
+ },
2024
+ '& .mq-longdiv-inner': {
2025
+ borderTop: '1px solid !important',
2026
+ paddingTop: '1.5px !important'
2027
+ },
2028
+ '& .mq-parallelogram': {
2029
+ lineHeight: 0.85
2030
+ }
2031
+ },
2032
+ selected: {
2033
+ border: `solid 1px ${theme.palette.primary.main}`,
2034
+ '& > .mq-math-mode': {
2035
+ border: 'solid 0px lightgrey'
2036
+ }
2037
+ },
2038
+ insideOverlay: {
2039
+ position: 'absolute',
2040
+ bottom: 0,
2041
+ left: 0,
2042
+ right: 0,
2043
+ top: 0
2044
+ }
2045
+ });
2046
+ withStyles$3(mp)(RawMathPreview);
2047
+ const React$3 = _dll_react;
2048
+ const PropTypes$2 = _dll_prop_types;
2049
+ const cx$2 = _dll_classnames;
2050
+ const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
2051
+ const _jsxFileName$2 = "/home/circleci/repo/node_modules/@pie-lib/math-toolbar/src/index.jsx";
2052
+ class MathToolbar extends React$3.Component {
2053
+ static __initStatic() {
2054
+ this.propTypes = {
2055
+ autoFocus: PropTypes$2.bool,
2056
+ allowAnswerBlock: PropTypes$2.bool,
2057
+ controlledKeypad: PropTypes$2.bool,
2058
+ controlledKeypadMode: PropTypes$2.bool,
2059
+ keypadMode: PropTypes$2.oneOfType([PropTypes$2.string, PropTypes$2.number]),
2060
+ classNames: PropTypes$2.object,
2061
+ showKeypad: PropTypes$2.bool,
2062
+ noDecimal: PropTypes$2.bool,
2063
+ additionalKeys: PropTypes$2.array,
2064
+ latex: PropTypes$2.string.isRequired,
2065
+ onAnswerBlockAdd: PropTypes$2.func,
2066
+ onChange: PropTypes$2.func,
2067
+ onDone: PropTypes$2.func.isRequired,
2068
+ onFocus: PropTypes$2.func,
2069
+ onBlur: PropTypes$2.func,
2070
+ hideDoneButton: PropTypes$2.bool
2071
+ };
2072
+ }
2073
+ static __initStatic2() {
2074
+ this.defaultProps = {
2075
+ classNames: {},
2076
+ keypadMode: 'item-authoring',
2077
+ autoFocus: false,
2078
+ allowAnswerBlock: false,
2079
+ controlledKeypad: false,
2080
+ controlledKeypadMode: false,
2081
+ noDecimal: false,
2082
+ showKeypad: true,
2083
+ additionalKeys: [],
2084
+ onChange: () => {},
2085
+ onAnswerBlockAdd: () => {},
2086
+ onFocus: () => {},
2087
+ hideDoneButton: false
2088
+ };
2089
+ }
2090
+ constructor(props) {
2091
+ super(props);
2092
+ MathToolbar.prototype.__init.call(this);
2093
+ MathToolbar.prototype.__init2.call(this);
2094
+ this.state = {
2095
+ latex: props.latex
2096
+ };
2097
+ }
2098
+ __init() {
2099
+ this.done = () => {
2100
+ this.props.onDone(this.state.latex);
2101
+ };
2102
+ }
2103
+ UNSAFE_componentWillReceiveProps(nextProps) {
2104
+ this.setState({
2105
+ latex: nextProps.latex
2106
+ });
2107
+ }
2108
+ __init2() {
2109
+ this.onChange = latex => {
2110
+ this.setState({
2111
+ latex
2112
+ });
2113
+ this.props.onChange(latex);
2114
+ };
2115
+ }
2116
+ render() {
2117
+ const {latex} = this.state;
2118
+ const {classNames, autoFocus, allowAnswerBlock, onAnswerBlockAdd, controlledKeypad, controlledKeypadMode, keypadMode, noDecimal, additionalKeys, showKeypad, onFocus, onBlur, hideDoneButton} = this.props;
2119
+ return React$3.createElement(PureToolbar, {
2120
+ autoFocus: autoFocus,
2121
+ classNames: classNames,
2122
+ onAnswerBlockAdd: onAnswerBlockAdd,
2123
+ allowAnswerBlock: allowAnswerBlock,
2124
+ latex: latex,
2125
+ additionalKeys: additionalKeys,
2126
+ noDecimal: noDecimal,
2127
+ keypadMode: keypadMode,
2128
+ onChange: this.onChange,
2129
+ onDone: this.done,
2130
+ onFocus: onFocus,
2131
+ onBlur: onBlur,
2132
+ showKeypad: showKeypad,
2133
+ controlledKeypad: controlledKeypad,
2134
+ controlledKeypadMode: controlledKeypadMode,
2135
+ hideDoneButton: hideDoneButton,
2136
+ __self: this,
2137
+ __source: {
2138
+ fileName: _jsxFileName$2,
2139
+ lineNumber: 86
2140
+ }
2141
+ });
2142
+ }
2143
+ }
2144
+ MathToolbar.__initStatic();
2145
+ MathToolbar.__initStatic2();
2146
+ class RawPureToolbar extends React$3.Component {
2147
+ static __initStatic3() {
2148
+ this.propTypes = {
2149
+ classNames: PropTypes$2.object,
2150
+ latex: PropTypes$2.string.isRequired,
2151
+ keypadMode: PropTypes$2.oneOfType([PropTypes$2.string, PropTypes$2.number]),
2152
+ onChange: PropTypes$2.func.isRequired,
2153
+ onDone: PropTypes$2.func.isRequired,
2154
+ onBlur: PropTypes$2.func,
2155
+ onAnswerBlockAdd: PropTypes$2.func,
2156
+ additionalKeys: PropTypes$2.array,
2157
+ onFocus: PropTypes$2.func,
2158
+ classes: PropTypes$2.object.isRequired,
2159
+ autoFocus: PropTypes$2.bool,
2160
+ noDecimal: PropTypes$2.bool,
2161
+ allowAnswerBlock: PropTypes$2.bool,
2162
+ controlledKeypad: PropTypes$2.bool,
2163
+ controlledKeypadMode: PropTypes$2.bool,
2164
+ showKeypad: PropTypes$2.bool,
2165
+ hideDoneButton: PropTypes$2.bool
2166
+ };
2167
+ }
2168
+ render() {
2169
+ const {classNames, autoFocus, allowAnswerBlock, onAnswerBlockAdd, controlledKeypad, controlledKeypadMode, additionalKeys, showKeypad, keypadMode, noDecimal, latex, onChange, onDone, onFocus, onBlur, hideDoneButton, classes} = this.props;
2170
+ return React$3.createElement('div', {
2171
+ className: cx$2(classes.pureToolbar, (classNames || ({})).toolbar),
2172
+ __self: this,
2173
+ __source: {
2174
+ fileName: _jsxFileName$2,
2175
+ lineNumber: 151
2176
+ }
2177
+ }, React$3.createElement('div', {
2178
+ __self: this,
2179
+ __source: {
2180
+ fileName: _jsxFileName$2,
2181
+ lineNumber: 152
2182
+ }
2183
+ }), React$3.createElement(EditorAndPad$1, {
2184
+ autoFocus: autoFocus,
2185
+ keypadMode: keypadMode,
2186
+ classNames: classNames || ({}),
2187
+ controlledKeypad: controlledKeypad,
2188
+ controlledKeypadMode: controlledKeypadMode,
2189
+ noDecimal: noDecimal,
2190
+ showKeypad: showKeypad,
2191
+ additionalKeys: additionalKeys,
2192
+ allowAnswerBlock: allowAnswerBlock,
2193
+ onAnswerBlockAdd: onAnswerBlockAdd,
2194
+ latex: latex,
2195
+ onChange: onChange,
2196
+ onFocus: onFocus,
2197
+ onBlur: onBlur,
2198
+ __self: this,
2199
+ __source: {
2200
+ fileName: _jsxFileName$2,
2201
+ lineNumber: 153
2202
+ }
2203
+ }), (!controlledKeypad || controlledKeypad && showKeypad) && !hideDoneButton && React$3.createElement(DoneButton, {
2204
+ onClick: onDone,
2205
+ __self: this,
2206
+ __source: {
2207
+ fileName: _jsxFileName$2,
2208
+ lineNumber: 170
2209
+ }
2210
+ }));
2211
+ }
2212
+ }
2213
+ RawPureToolbar.__initStatic3();
2214
+ const styles$1 = () => ({
2215
+ pureToolbar: {
2216
+ display: 'flex',
2217
+ width: '100%',
2218
+ zIndex: 8,
2219
+ alignItems: 'center'
2220
+ }
2221
+ });
2222
+ const PureToolbar = withStyles$2(styles$1)(RawPureToolbar);
2223
+ const React$2 = _dll_react;
2224
+ const cx$1 = _dll_classnames;
2225
+ const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
2226
+ const PropTypes$1 = _dll_prop_types;
2227
+ const {color: color$1} = _dll_pie_lib__render_ui;
2228
+ const _jsxFileName$1 = "/home/circleci/repo/packages/math-inline/src/simple-question-block.jsx";
2229
+ class SimpleQuestionBlockRaw extends React$2.Component {
2230
+ constructor(...args) {
2231
+ super(...args);
2232
+ SimpleQuestionBlockRaw.prototype.__init.call(this);
2233
+ SimpleQuestionBlockRaw.prototype.__init2.call(this);
2234
+ SimpleQuestionBlockRaw.prototype.__init3.call(this);
2235
+ }
2236
+ static __initStatic() {
2237
+ this.propTypes = {
2238
+ classes: PropTypes$1.object,
2239
+ onSimpleResponseChange: PropTypes$1.func,
2240
+ model: PropTypes$1.object.isRequired,
2241
+ emptyResponse: PropTypes$1.bool,
2242
+ session: PropTypes$1.object.isRequired,
2243
+ showCorrect: PropTypes$1.bool
2244
+ };
2245
+ }
2246
+ __init() {
2247
+ this.state = {
2248
+ showKeypad: true
2249
+ };
2250
+ }
2251
+ __init2() {
2252
+ this.onFocus = () => this.setState({
2253
+ showKeypad: true
2254
+ });
2255
+ }
2256
+ __init3() {
2257
+ this.onBlur = e => {
2258
+ const {relatedTarget, currentTarget} = e || ({});
2259
+ if (!relatedTarget || !currentTarget || relatedTarget.offsetParent !== currentTarget.offsetParent) {
2260
+ this.setState({
2261
+ showKeypad: false
2262
+ });
2263
+ }
2264
+ };
2265
+ }
2266
+ render() {
2267
+ const {classes, model, showCorrect, session, emptyResponse, onSimpleResponseChange} = this.props;
2268
+ const {config, disabled, correctness, view} = model || ({});
2269
+ if (!config) {
2270
+ return;
2271
+ }
2272
+ const correct = correctness && correctness.correct;
2273
+ const showAsCorrect = !emptyResponse && (showCorrect || correct);
2274
+ const showAsIncorrect = !emptyResponse && !correct && !showCorrect && !view;
2275
+ const {responses, equationEditor} = config;
2276
+ return React$2.createElement('div', {
2277
+ className: classes.expression,
2278
+ __self: this,
2279
+ __source: {
2280
+ fileName: _jsxFileName$1,
2281
+ lineNumber: 54
2282
+ }
2283
+ }, showCorrect || disabled ? React$2.createElement('div', {
2284
+ className: cx$1(classes.static, {
2285
+ [classes.correct]: showAsCorrect,
2286
+ [classes.incorrect]: showAsIncorrect
2287
+ }),
2288
+ __self: this,
2289
+ __source: {
2290
+ fileName: _jsxFileName$1,
2291
+ lineNumber: 56
2292
+ }
2293
+ }, React$2.createElement(Static, {
2294
+ latex: showCorrect ? responses && responses.length && responses[0].answer : session.response || '',
2295
+ __self: this,
2296
+ __source: {
2297
+ fileName: _jsxFileName$1,
2298
+ lineNumber: 62
2299
+ }
2300
+ })) : React$2.createElement(MathToolbar, {
2301
+ classNames: {
2302
+ editor: classes.responseEditor
2303
+ },
2304
+ latex: session.response || '',
2305
+ keypadMode: equationEditor,
2306
+ onChange: onSimpleResponseChange,
2307
+ onDone: () => {},
2308
+ onFocus: this.onFocus,
2309
+ onBlur: this.onBlur,
2310
+ controlledKeypad: true,
2311
+ showKeypad: this.state.showKeypad,
2312
+ hideDoneButton: true,
2313
+ __self: this,
2314
+ __source: {
2315
+ fileName: _jsxFileName$1,
2316
+ lineNumber: 69
2317
+ }
2318
+ }));
2319
+ }
2320
+ }
2321
+ SimpleQuestionBlockRaw.__initStatic();
2322
+ const SimpleQuestionBlock = withStyles$1(theme => ({
2323
+ responseEditor: {
2324
+ display: 'flex',
2325
+ justifyContent: 'center',
2326
+ width: 'auto',
2327
+ minWidth: '500px',
2328
+ maxWidth: '900px',
2329
+ height: 'auto',
2330
+ textAlign: 'left',
2331
+ padding: theme.spacing.unit,
2332
+ '&.mq-math-mode': {
2333
+ border: `1px solid ${color$1.primaryLight()}`
2334
+ }
2335
+ },
2336
+ expression: {
2337
+ marginTop: theme.spacing.unit * 2,
2338
+ marginBottom: theme.spacing.unit * 2,
2339
+ padding: theme.spacing.unit
2340
+ },
2341
+ static: {
2342
+ color: color$1.text(),
2343
+ background: color$1.background(),
2344
+ border: `1px solid ${color$1.primaryLight()}`,
2345
+ width: '100%',
2346
+ fontSize: '1rem',
2347
+ padding: theme.spacing.unit / 2,
2348
+ '& > .mq-math-mode': {
2349
+ '& > .mq-hasCursor': {
2350
+ '& > .mq-cursor': {
2351
+ display: 'none'
2352
+ }
2353
+ }
2354
+ }
2355
+ },
2356
+ correct: {
2357
+ color: color$1.correct(),
2358
+ border: `1px solid ${color$1.correct()} !important`
2359
+ },
2360
+ incorrect: {
2361
+ color: color$1.incorrect(),
2362
+ border: `1px solid ${color$1.incorrect()} !important`
2363
+ }
2364
+ }))(SimpleQuestionBlockRaw);
2365
+ const React$1 = _dll_react;
2366
+ const PropTypes = _dll_prop_types;
2367
+ const CorrectAnswerToggle = _dll_pie_lib__correct_answer_toggle;
2368
+ const {Feedback: Feedback} = _dll_pie_lib__render_ui;
2369
+ const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
2370
+ const {Readable: Readable} = _dll_pie_lib__render_ui;
2371
+ const {hasText: hasText} = _dll_pie_lib__render_ui;
2372
+ const {PreviewPrompt: PreviewPrompt} = _dll_pie_lib__render_ui;
2373
+ const {color: color} = _dll_pie_lib__render_ui;
2374
+ const {withStyles: withStyles} = _dll_material_ui__core_styles;
2375
+ const {Tooltip: Tooltip} = _dll_material_ui__core;
2376
+ const {isEqual: isEqual} = _dll_lodash;
2377
+ const {isEmpty: isEmpty} = _dll_lodash;
2378
+ const cx = _dll_classnames;
2379
+ const {renderMath: renderMath$1} = _dll_pie_lib__math_rendering;
2380
+ const MathQuill = _dll_pie_framework__mathquill;
2381
+ const _jsxFileName = "/home/circleci/repo/packages/math-inline/src/main.jsx";
2382
+ function _optionalChain(ops) {
2383
+ let lastAccessLHS = undefined;
2384
+ let value = ops[0];
2385
+ let i = 1;
2386
+ while (i < ops.length) {
2387
+ const op = ops[i];
2388
+ const fn = ops[i + 1];
2389
+ i += 2;
2390
+ if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) {
2391
+ return undefined;
2392
+ }
2393
+ if (op === 'access' || op === 'optionalAccess') {
2394
+ lastAccessLHS = value;
2395
+ value = fn(value);
2396
+ } else if (op === 'call' || op === 'optionalCall') {
2397
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
2398
+ lastAccessLHS = undefined;
2399
+ }
2400
+ }
2401
+ return value;
2402
+ }
2403
+ let registered = false;
2404
+ const NEWLINE_LATEX = /\\newline/g;
2405
+ const REGEX = /{{response}}/gm;
2406
+ const DEFAULT_KEYPAD_VARIANT = 6;
2407
+ const IS_SAFARI = (/^((?!chrome|android).)*safari/i).test(navigator.userAgent);
2408
+ function generateAdditionalKeys(keyData = []) {
2409
+ return keyData.map(key => ({
2410
+ name: key,
2411
+ latex: key,
2412
+ write: key,
2413
+ label: key
2414
+ }));
2415
+ }
2416
+ function getKeyPadWidth(additionalKeys = [], equationEditor) {
2417
+ return Math.floor(additionalKeys.length / 5) * 30 + (equationEditor === 'miscellaneous' ? 600 : 500);
2418
+ }
2419
+ function prepareForStatic(model, state) {
2420
+ const {config, disabled} = model || ({});
2421
+ const {expression, responses, printMode, alwaysShowCorrect} = config || ({});
2422
+ if (config && expression) {
2423
+ const modelExpression = expression;
2424
+ if (state.showCorrect) {
2425
+ return responses && responses.length && responses[0].answer;
2426
+ }
2427
+ let answerBlocks = 1;
2428
+ return (modelExpression || '').replace(REGEX, function () {
2429
+ const answer = state.session.answers[`r${answerBlocks}`];
2430
+ if (printMode && !alwaysShowCorrect) {
2431
+ const blankSpace = ('\\ \\ ').repeat(30) + '\\newline ';
2432
+ return `\\MathQuillMathField[r${answerBlocks++}]{${blankSpace.repeat(3)}}`;
2433
+ }
2434
+ if (disabled) {
2435
+ return `\\embed{answerBlock}[r${answerBlocks++}]`;
2436
+ }
2437
+ return `\\MathQuillMathField[r${answerBlocks++}]{${answer && answer.value || ''}}`;
2438
+ }).replace(NEWLINE_LATEX, '\\embed{newLine}[]');
2439
+ }
2440
+ }
2441
+ class Main extends React$1.Component {
2442
+ static __initStatic() {
2443
+ this.propTypes = {
2444
+ classes: PropTypes.object,
2445
+ session: PropTypes.object.isRequired,
2446
+ onSessionChange: PropTypes.func,
2447
+ model: PropTypes.object.isRequired
2448
+ };
2449
+ }
2450
+ constructor(props) {
2451
+ super(props);
2452
+ Main.prototype.__init.call(this);
2453
+ Main.prototype.__init2.call(this);
2454
+ Main.prototype.__init3.call(this);
2455
+ Main.prototype.__init4.call(this);
2456
+ Main.prototype.__init5.call(this);
2457
+ Main.prototype.__init6.call(this);
2458
+ Main.prototype.__init7.call(this);
2459
+ Main.prototype.__init8.call(this);
2460
+ Main.prototype.__init9.call(this);
2461
+ Main.prototype.__init10.call(this);
2462
+ Main.prototype.__init11.call(this);
2463
+ Main.prototype.__init12.call(this);
2464
+ const answers = {};
2465
+ if (props.model.config && props.model.config.expression) {
2466
+ let answerBlocks = 1;
2467
+ (props.model.config.expression || '').replace(REGEX, () => {
2468
+ answers[`r${answerBlocks}`] = {
2469
+ value: props.session && props.session.answers && props.session.answers[`r${answerBlocks}`] && props.session.answers[`r${answerBlocks}`].value || ''
2470
+ };
2471
+ answerBlocks += 1;
2472
+ });
2473
+ }
2474
+ this.state = {
2475
+ session: {
2476
+ ...props.session,
2477
+ answers
2478
+ },
2479
+ activeAnswerBlock: '',
2480
+ showCorrect: this.props.model.config.alwaysShowCorrect || false
2481
+ };
2482
+ }
2483
+ UNSAFE_componentWillMount() {
2484
+ const {classes} = this.props;
2485
+ if (typeof window !== 'undefined') {
2486
+ let MQ = MathQuill.getInterface(2);
2487
+ if (!registered) {
2488
+ MQ.registerEmbed('answerBlock', data => {
2489
+ return {
2490
+ htmlString: `<div class="${classes.blockContainer}">
2491
+ <div class="${classes.blockResponse}" id="${data}Index">R</div>
2492
+ <div class="${classes.blockMath}">
2493
+ <span id="${data}"></span>
2494
+ </div>
2495
+ </div>`,
2496
+ text: () => 'text',
2497
+ latex: () => `\\embed{answerBlock}[${data}]`
2498
+ };
2499
+ });
2500
+ registered = true;
2501
+ }
2502
+ }
2503
+ }
2504
+ __init() {
2505
+ this.handleAnswerBlockDomUpdate = () => {
2506
+ const {model, classes} = this.props;
2507
+ const {session, showCorrect} = this.state;
2508
+ const answers = session.answers;
2509
+ if (this.root && model.disabled && !showCorrect) {
2510
+ Object.keys(answers).forEach(answerId => {
2511
+ const el = this.root.querySelector(`#${answerId}`);
2512
+ const indexEl = this.root.querySelector(`#${answerId}Index`);
2513
+ if (el) {
2514
+ let MQ = MathQuill.getInterface(2);
2515
+ const answer = answers[answerId];
2516
+ el.textContent = answer && answer.value || '';
2517
+ if (!model.view) ; else {
2518
+ el.parentElement.parentElement.classList.remove(classes.correct);
2519
+ el.parentElement.parentElement.classList.remove(classes.incorrect);
2520
+ }
2521
+ MQ.StaticMath(el);
2522
+ indexEl.textContent = 'R';
2523
+ }
2524
+ });
2525
+ }
2526
+ renderMath$1(this.root);
2527
+ };
2528
+ }
2529
+ componentDidUpdate() {
2530
+ this.handleAnswerBlockDomUpdate();
2531
+ }
2532
+ UNSAFE_componentWillReceiveProps(nextProps) {
2533
+ const {config} = this.props.model;
2534
+ const {config: nextConfig = {}} = nextProps.model || ({});
2535
+ if (config.env && config.env.mode !== 'evaluate' || nextConfig.env && nextConfig.env.mode !== 'evaluate') {
2536
+ this.setState({
2537
+ ...this.state.session,
2538
+ showCorrect: false
2539
+ });
2540
+ }
2541
+ if (nextConfig.alwaysShowCorrect) {
2542
+ this.setState({
2543
+ showCorrect: true
2544
+ });
2545
+ }
2546
+ if (config && config.responses && config.responses.length !== nextConfig.responses.length || !config && nextConfig && nextConfig.responses || config && nextConfig && config.expression !== nextConfig.expression) {
2547
+ const newAnswers = {};
2548
+ const answers = this.state.session.answers;
2549
+ let answerBlocks = 1;
2550
+ (nextConfig.expression || '').replace(REGEX, () => {
2551
+ newAnswers[`r${answerBlocks}`] = {
2552
+ value: answers && answers[`r${answerBlocks}`] && answers[`r${answerBlocks}`].value || ''
2553
+ };
2554
+ answerBlocks++;
2555
+ });
2556
+ this.setState(state => ({
2557
+ session: {
2558
+ ...state.session,
2559
+ completeAnswer: this.mqStatic && this.mqStatic.mathField.latex(),
2560
+ answers: newAnswers
2561
+ }
2562
+ }), this.handleAnswerBlockDomUpdate);
2563
+ }
2564
+ }
2565
+ shouldComponentUpdate(nextProps, nextState) {
2566
+ const sameModel = isEqual(this.props.model, nextProps.model);
2567
+ const sameState = isEqual(this.state, nextState);
2568
+ return !sameModel || !sameState;
2569
+ }
2570
+ componentDidMount() {
2571
+ this.handleAnswerBlockDomUpdate();
2572
+ setTimeout(() => renderMath$1(this.root), 100);
2573
+ }
2574
+ __init2() {
2575
+ this.onDone = () => {};
2576
+ }
2577
+ __init3() {
2578
+ this.onSimpleResponseChange = response => {
2579
+ this.setState(state => ({
2580
+ session: {
2581
+ ...state.session,
2582
+ response
2583
+ }
2584
+ }), this.callOnSessionChange);
2585
+ };
2586
+ }
2587
+ __init4() {
2588
+ this.onSubFieldFocus = id => {
2589
+ this.setState({
2590
+ activeAnswerBlock: id
2591
+ });
2592
+ };
2593
+ }
2594
+ __init5() {
2595
+ this.toNodeData = data => {
2596
+ if (!data) {
2597
+ return;
2598
+ }
2599
+ const {type, value} = data;
2600
+ if (type === 'command' || type === 'cursor') {
2601
+ return data;
2602
+ } else if (type === 'answer') {
2603
+ return {
2604
+ type: 'answer',
2605
+ ...data
2606
+ };
2607
+ } else if (value === 'clear') {
2608
+ return {
2609
+ type: 'clear'
2610
+ };
2611
+ } else {
2612
+ return {
2613
+ type: 'write',
2614
+ value
2615
+ };
2616
+ }
2617
+ };
2618
+ }
2619
+ __init6() {
2620
+ this.setInput = input => {
2621
+ this.input = input;
2622
+ };
2623
+ }
2624
+ __init7() {
2625
+ this.onClick = data => {
2626
+ const c = this.toNodeData(data);
2627
+ if (c.type === 'clear') {
2628
+ this.input.clear();
2629
+ } else if (c.type === 'command') {
2630
+ if (Array.isArray(c.value)) {
2631
+ c.value.forEach(vv => {
2632
+ this.input.cmd(vv);
2633
+ });
2634
+ } else {
2635
+ this.input.cmd(c.value);
2636
+ }
2637
+ } else if (c.type === 'cursor') {
2638
+ this.input.keystroke(c.value);
2639
+ } else {
2640
+ this.input.write(c.value);
2641
+ }
2642
+ this.input.focus();
2643
+ };
2644
+ }
2645
+ __init8() {
2646
+ this.callOnSessionChange = () => {
2647
+ const {onSessionChange} = this.props;
2648
+ if (onSessionChange) {
2649
+ onSessionChange(this.state.session);
2650
+ }
2651
+ };
2652
+ }
2653
+ __init9() {
2654
+ this.toggleShowCorrect = show => {
2655
+ this.setState({
2656
+ showCorrect: show
2657
+ }, this.handleAnswerBlockDomUpdate);
2658
+ };
2659
+ }
2660
+ __init10() {
2661
+ this.subFieldChanged = (name, subfieldValue) => {
2662
+ updateSpans();
2663
+ if (name) {
2664
+ this.setState(state => ({
2665
+ session: {
2666
+ ...state.session,
2667
+ completeAnswer: this.mqStatic && this.mqStatic.mathField.latex(),
2668
+ answers: {
2669
+ ...state.session.answers,
2670
+ [name]: {
2671
+ value: subfieldValue
2672
+ }
2673
+ }
2674
+ }
2675
+ }), this.callOnSessionChange);
2676
+ }
2677
+ };
2678
+ }
2679
+ __init11() {
2680
+ this.getFieldName = (changeField, fields) => {
2681
+ const {answers} = this.state.session;
2682
+ if (Object.keys(answers || ({})).length) {
2683
+ const keys = Object.keys(answers);
2684
+ return keys.find(k => {
2685
+ const tf = fields[k];
2686
+ return tf && tf.id == changeField.id;
2687
+ });
2688
+ }
2689
+ };
2690
+ }
2691
+ __init12() {
2692
+ this.onBlur = e => {
2693
+ const {relatedTarget, currentTarget} = e || ({});
2694
+ if (!relatedTarget || !currentTarget || !IS_SAFARI && !_optionalChain([relatedTarget, 'optionalAccess', _13 => _13.offsetParent, 'optionalAccess', _14 => _14.children, 'access', _15 => _15[0], 'optionalAccess', _16 => _16.attributes, 'optionalAccess', _17 => _17['data-keypad']]) || IS_SAFARI && !_optionalChain([relatedTarget, 'optionalAccess', _18 => _18.offsetParent, 'optionalAccess', _19 => _19.children, 'access', _20 => _20[0], 'optionalAccess', _21 => _21.children, 'access', _22 => _22[0], 'optionalAccess', _23 => _23.attributes, 'optionalAccess', _24 => _24['data-keypad']])) {
2695
+ this.setState({
2696
+ activeAnswerBlock: ''
2697
+ });
2698
+ }
2699
+ };
2700
+ }
2701
+ setTooltipRef(ref) {
2702
+ setTimeout(() => {
2703
+ if (ref && IS_SAFARI) {
2704
+ const div = document.querySelector('[role=\'tooltip\']');
2705
+ if (div) {
2706
+ const el = div.firstChild;
2707
+ el.setAttribute('tabindex', '-1');
2708
+ }
2709
+ }
2710
+ }, 1);
2711
+ }
2712
+ render() {
2713
+ const {model, classes} = this.props;
2714
+ const {activeAnswerBlock, showCorrect, session} = this.state;
2715
+ const {config, correctness, disabled, view, teacherInstructions, rationale, feedback, animationsDisabled, printMode, alwaysShowCorrect} = model || ({});
2716
+ if (!config) {
2717
+ return null;
2718
+ }
2719
+ const {showNote, note, prompt, responses, responseType, equationEditor, customKeys, env: {mode, role} = {}} = config || ({});
2720
+ const displayNote = (showCorrect || mode === 'view' && role === 'instructor') && showNote && note;
2721
+ const emptyResponse = isEmpty(responses);
2722
+ const showCorrectAnswerToggle = !emptyResponse && correctness && correctness.correctness !== 'correct';
2723
+ const tooltipModeEnabled = disabled && correctness && responseType !== ResponseTypes.simple;
2724
+ const additionalKeys = generateAdditionalKeys(customKeys);
2725
+ const correct = correctness && correctness.correct;
2726
+ const staticLatex = prepareForStatic(model, this.state) || '';
2727
+ const viewMode = disabled && !correctness;
2728
+ const studentPrintMode = printMode && !alwaysShowCorrect;
2729
+ const printView = React$1.createElement('div', {
2730
+ className: classes.printContainer,
2731
+ __self: this,
2732
+ __source: {
2733
+ fileName: _jsxFileName,
2734
+ lineNumber: 411
2735
+ }
2736
+ }, React$1.createElement(Static, {
2737
+ ref: mqStatic => this.mqStatic = mqStatic || this.mqStatic,
2738
+ latex: staticLatex,
2739
+ onSubFieldChange: this.subFieldChanged,
2740
+ getFieldName: this.getFieldName,
2741
+ setInput: this.setInput,
2742
+ onSubFieldFocus: this.onSubFieldFocus,
2743
+ onBlur: this.onBlur,
2744
+ __self: this,
2745
+ __source: {
2746
+ fileName: _jsxFileName,
2747
+ lineNumber: 412
2748
+ }
2749
+ }));
2750
+ const midContent = React$1.createElement('div', {
2751
+ className: classes.main,
2752
+ __self: this,
2753
+ __source: {
2754
+ fileName: _jsxFileName,
2755
+ lineNumber: 424
2756
+ }
2757
+ }, prompt && React$1.createElement('div', {
2758
+ className: classes.content,
2759
+ __self: this,
2760
+ __source: {
2761
+ fileName: _jsxFileName,
2762
+ lineNumber: 426
2763
+ }
2764
+ }, React$1.createElement(PreviewPrompt, {
2765
+ prompt: prompt,
2766
+ __self: this,
2767
+ __source: {
2768
+ fileName: _jsxFileName,
2769
+ lineNumber: 427
2770
+ }
2771
+ })), studentPrintMode ? printView : React$1.createElement(Readable, {
2772
+ false: true,
2773
+ __self: this,
2774
+ __source: {
2775
+ fileName: _jsxFileName,
2776
+ lineNumber: 430
2777
+ }
2778
+ }, React$1.createElement('div', {
2779
+ className: classes.inputAndKeypadContainer,
2780
+ __self: this,
2781
+ __source: {
2782
+ fileName: _jsxFileName,
2783
+ lineNumber: 431
2784
+ }
2785
+ }, responseType === ResponseTypes.simple && React$1.createElement(SimpleQuestionBlock, {
2786
+ onSimpleResponseChange: this.onSimpleResponseChange,
2787
+ showCorrect: showCorrect,
2788
+ emptyResponse: emptyResponse,
2789
+ model: model,
2790
+ session: session,
2791
+ __self: this,
2792
+ __source: {
2793
+ fileName: _jsxFileName,
2794
+ lineNumber: 433
2795
+ }
2796
+ }), responseType === ResponseTypes.advanced && React$1.createElement('div', {
2797
+ className: cx(classes.expression, {
2798
+ [classes.incorrect]: !emptyResponse && !correct && !showCorrect,
2799
+ [classes.correct]: !emptyResponse && (correct || showCorrect),
2800
+ [classes.showCorrectness]: !emptyResponse && disabled && correctness && !view,
2801
+ [classes.correctAnswerShown]: showCorrect
2802
+ }),
2803
+ __self: this,
2804
+ __source: {
2805
+ fileName: _jsxFileName,
2806
+ lineNumber: 442
2807
+ }
2808
+ }, React$1.createElement(Tooltip, {
2809
+ ref: ref => this.setTooltipRef(ref),
2810
+ interactive: true,
2811
+ open: !!activeAnswerBlock,
2812
+ classes: {
2813
+ tooltip: classes.keypadTooltip,
2814
+ popper: classes.keypadTooltipPopper
2815
+ },
2816
+ title: Object.keys(session.answers).map(answerId => answerId === activeAnswerBlock && !(showCorrect || disabled) && React$1.createElement('div', {
2817
+ 'data-keypad': true,
2818
+ key: answerId,
2819
+ className: classes.responseContainer,
2820
+ style: {
2821
+ width: getKeyPadWidth(additionalKeys, equationEditor)
2822
+ },
2823
+ __self: this,
2824
+ __source: {
2825
+ fileName: _jsxFileName,
2826
+ lineNumber: 462
2827
+ }
2828
+ }, React$1.createElement(HorizontalKeypad, {
2829
+ additionalKeys: additionalKeys,
2830
+ mode: equationEditor || DEFAULT_KEYPAD_VARIANT,
2831
+ onClick: this.onClick,
2832
+ __self: this,
2833
+ __source: {
2834
+ fileName: _jsxFileName,
2835
+ lineNumber: 471
2836
+ }
2837
+ })) || null),
2838
+ __self: this,
2839
+ __source: {
2840
+ fileName: _jsxFileName,
2841
+ lineNumber: 450
2842
+ }
2843
+ }, React$1.createElement(Static, {
2844
+ ref: mqStatic => this.mqStatic = mqStatic || this.mqStatic,
2845
+ latex: staticLatex,
2846
+ onSubFieldChange: this.subFieldChanged,
2847
+ getFieldName: this.getFieldName,
2848
+ setInput: this.setInput,
2849
+ onSubFieldFocus: this.onSubFieldFocus,
2850
+ onBlur: this.onBlur,
2851
+ __self: this,
2852
+ __source: {
2853
+ fileName: _jsxFileName,
2854
+ lineNumber: 481
2855
+ }
2856
+ }))))), viewMode && teacherInstructions && hasText(teacherInstructions) && React$1.createElement(React$1.Fragment, {
2857
+ __self: this,
2858
+ __source: {
2859
+ fileName: _jsxFileName,
2860
+ lineNumber: 497
2861
+ }
2862
+ }, !animationsDisabled ? React$1.createElement(Collapsible, {
2863
+ labels: {
2864
+ hidden: 'Show Teacher Instructions',
2865
+ visible: 'Hide Teacher Instructions'
2866
+ },
2867
+ __self: this,
2868
+ __source: {
2869
+ fileName: _jsxFileName,
2870
+ lineNumber: 498
2871
+ }
2872
+ }, React$1.createElement('div', {
2873
+ dangerouslySetInnerHTML: {
2874
+ __html: teacherInstructions
2875
+ },
2876
+ __self: this,
2877
+ __source: {
2878
+ fileName: _jsxFileName,
2879
+ lineNumber: 501
2880
+ }
2881
+ })) : React$1.createElement('div', {
2882
+ dangerouslySetInnerHTML: {
2883
+ __html: teacherInstructions
2884
+ },
2885
+ __self: this,
2886
+ __source: {
2887
+ fileName: _jsxFileName,
2888
+ lineNumber: 502
2889
+ }
2890
+ }), React$1.createElement('br', {
2891
+ __self: this,
2892
+ __source: {
2893
+ fileName: _jsxFileName,
2894
+ lineNumber: 503
2895
+ }
2896
+ })), viewMode && rationale && hasText(rationale) && React$1.createElement(React$1.Fragment, {
2897
+ __self: this,
2898
+ __source: {
2899
+ fileName: _jsxFileName,
2900
+ lineNumber: 509
2901
+ }
2902
+ }, !animationsDisabled ? React$1.createElement(Collapsible, {
2903
+ labels: {
2904
+ hidden: 'Show Rationale',
2905
+ visible: 'Hide Rationale'
2906
+ },
2907
+ __self: this,
2908
+ __source: {
2909
+ fileName: _jsxFileName,
2910
+ lineNumber: 510
2911
+ }
2912
+ }, React$1.createElement('div', {
2913
+ dangerouslySetInnerHTML: {
2914
+ __html: rationale
2915
+ },
2916
+ __self: this,
2917
+ __source: {
2918
+ fileName: _jsxFileName,
2919
+ lineNumber: 513
2920
+ }
2921
+ })) : React$1.createElement('div', {
2922
+ dangerouslySetInnerHTML: {
2923
+ __html: rationale
2924
+ },
2925
+ __self: this,
2926
+ __source: {
2927
+ fileName: _jsxFileName,
2928
+ lineNumber: 514
2929
+ }
2930
+ })), displayNote && React$1.createElement('div', {
2931
+ className: classes.note,
2932
+ dangerouslySetInnerHTML: {
2933
+ __html: `<strong>Note:</strong> ${note}`
2934
+ },
2935
+ __self: this,
2936
+ __source: {
2937
+ fileName: _jsxFileName,
2938
+ lineNumber: 519
2939
+ }
2940
+ }));
2941
+ if (tooltipModeEnabled && (showCorrectAnswerToggle || teacherInstructions || rationale || feedback)) {
2942
+ return React$1.createElement(Tooltip, {
2943
+ interactive: true,
2944
+ classes: {
2945
+ tooltip: classes.tooltip,
2946
+ popper: classes.tooltipPopper
2947
+ },
2948
+ title: React$1.createElement('div', {
2949
+ __self: this,
2950
+ __source: {
2951
+ fileName: _jsxFileName,
2952
+ lineNumber: 536
2953
+ }
2954
+ }, React$1.createElement('div', {
2955
+ className: classes.main,
2956
+ __self: this,
2957
+ __source: {
2958
+ fileName: _jsxFileName,
2959
+ lineNumber: 537
2960
+ }
2961
+ }, showCorrectAnswerToggle && React$1.createElement(CorrectAnswerToggle, {
2962
+ className: classes.toggle,
2963
+ show: true,
2964
+ toggled: showCorrect,
2965
+ onToggle: this.toggleShowCorrect,
2966
+ __self: this,
2967
+ __source: {
2968
+ fileName: _jsxFileName,
2969
+ lineNumber: 539
2970
+ }
2971
+ })), teacherInstructions && hasText(teacherInstructions) && [React$1.createElement(Collapsible, {
2972
+ key: "collapsible",
2973
+ labels: {
2974
+ hidden: 'Show Teacher Instructions',
2975
+ visible: 'Hide Teacher Instructions'
2976
+ },
2977
+ className: classes.collapsible,
2978
+ __self: this,
2979
+ __source: {
2980
+ fileName: _jsxFileName,
2981
+ lineNumber: 548
2982
+ }
2983
+ }, React$1.createElement(PreviewPrompt, {
2984
+ prompt: teacherInstructions,
2985
+ __self: this,
2986
+ __source: {
2987
+ fileName: _jsxFileName,
2988
+ lineNumber: 556
2989
+ }
2990
+ })), React$1.createElement('br', {
2991
+ key: "br",
2992
+ __self: this,
2993
+ __source: {
2994
+ fileName: _jsxFileName,
2995
+ lineNumber: 558
2996
+ }
2997
+ })], rationale && hasText(rationale) && [React$1.createElement(Collapsible, {
2998
+ key: "collapsible",
2999
+ labels: {
3000
+ hidden: 'Show Rationale',
3001
+ visible: 'Hide Rationale'
3002
+ },
3003
+ __self: this,
3004
+ __source: {
3005
+ fileName: _jsxFileName,
3006
+ lineNumber: 561
3007
+ }
3008
+ }, React$1.createElement(PreviewPrompt, {
3009
+ prompt: rationale,
3010
+ __self: this,
3011
+ __source: {
3012
+ fileName: _jsxFileName,
3013
+ lineNumber: 568
3014
+ }
3015
+ })), React$1.createElement('br', {
3016
+ key: "br",
3017
+ __self: this,
3018
+ __source: {
3019
+ fileName: _jsxFileName,
3020
+ lineNumber: 570
3021
+ }
3022
+ })], feedback && React$1.createElement(Feedback, {
3023
+ correctness: correctness.correctness,
3024
+ feedback: feedback,
3025
+ __self: this,
3026
+ __source: {
3027
+ fileName: _jsxFileName,
3028
+ lineNumber: 573
3029
+ }
3030
+ })),
3031
+ __self: this,
3032
+ __source: {
3033
+ fileName: _jsxFileName,
3034
+ lineNumber: 529
3035
+ }
3036
+ }, React$1.createElement('div', {
3037
+ className: classes.mainContainer,
3038
+ ref: r => this.root = r || this.root,
3039
+ __self: this,
3040
+ __source: {
3041
+ fileName: _jsxFileName,
3042
+ lineNumber: 581
3043
+ }
3044
+ }, midContent));
3045
+ }
3046
+ return React$1.createElement('div', {
3047
+ className: classes.mainContainer,
3048
+ ref: r => this.root = r || this.root,
3049
+ __self: this,
3050
+ __source: {
3051
+ fileName: _jsxFileName,
3052
+ lineNumber: 591
3053
+ }
3054
+ }, midContent);
3055
+ }
3056
+ }
3057
+ Main.__initStatic();
3058
+ const styles = theme => ({
3059
+ mainContainer: {
3060
+ display: 'inline-block'
3061
+ },
3062
+ tooltip: {
3063
+ background: `${color.primaryLight()} !important`,
3064
+ color: color.text(),
3065
+ padding: theme.spacing.unit * 2,
3066
+ border: `1px solid ${color.secondary()}`,
3067
+ fontSize: '16px',
3068
+ '& :not(.MathJax) > table tr': {
3069
+ '&:nth-child(2n)': {
3070
+ backgroundColor: 'unset !important'
3071
+ }
3072
+ }
3073
+ },
3074
+ tooltipPopper: {
3075
+ opacity: 1
3076
+ },
3077
+ keypadTooltip: {
3078
+ fontSize: 'initial',
3079
+ background: 'transparent',
3080
+ width: '600px',
3081
+ marginTop: 0,
3082
+ paddingTop: 0
3083
+ },
3084
+ keypadTooltipPopper: {
3085
+ background: 'transparent',
3086
+ width: '650px',
3087
+ opacity: 1
3088
+ },
3089
+ main: {
3090
+ width: '100%',
3091
+ position: 'relative',
3092
+ padding: theme.spacing.unit / 2,
3093
+ backgroundColor: color.background(),
3094
+ color: color.text()
3095
+ },
3096
+ title: {
3097
+ fontSize: '1.1rem',
3098
+ display: 'block',
3099
+ marginTop: theme.spacing.unit * 2,
3100
+ marginBottom: theme.spacing.unit
3101
+ },
3102
+ content: {
3103
+ marginTop: theme.spacing.unit * 2
3104
+ },
3105
+ note: {
3106
+ paddingTop: '15px'
3107
+ },
3108
+ collapsible: {
3109
+ marginTop: theme.spacing.unit * 2
3110
+ },
3111
+ responseContainer: {
3112
+ zIndex: 10,
3113
+ minWidth: '400px',
3114
+ marginTop: theme.spacing.unit * 2
3115
+ },
3116
+ expression: {
3117
+ maxWidth: 'fit-content',
3118
+ '& > .mq-math-mode': {
3119
+ '& > .mq-root-block': {
3120
+ '& > .mq-editable-field': {
3121
+ minWidth: '10px',
3122
+ margin: theme.spacing.unit * 2 / 3,
3123
+ padding: theme.spacing.unit / 4
3124
+ }
3125
+ },
3126
+ '& sup': {
3127
+ top: 0
3128
+ }
3129
+ }
3130
+ },
3131
+ inputAndKeypadContainer: {
3132
+ position: 'relative',
3133
+ '& .mq-overarrow-inner': {
3134
+ border: 'none !important',
3135
+ padding: '0 !important'
3136
+ },
3137
+ '& .mq-overarrow-inner-right': {
3138
+ display: 'none !important'
3139
+ },
3140
+ '& .mq-overarrow-inner-left': {
3141
+ display: 'none !important'
3142
+ },
3143
+ '& .mq-overarrow.mq-arrow-both': {
3144
+ minWidth: '1.23em',
3145
+ '& *': {
3146
+ lineHeight: '1 !important'
3147
+ },
3148
+ '&:before': {
3149
+ top: '-0.4em',
3150
+ left: '-1px'
3151
+ },
3152
+ '&:after': {
3153
+ top: '-2.4em',
3154
+ right: '-1px'
3155
+ },
3156
+ '&.mq-empty:after': {
3157
+ top: '-0.45em'
3158
+ }
3159
+ },
3160
+ '& .mq-overarrow.mq-arrow-right': {
3161
+ '&:before': {
3162
+ top: '-0.4em',
3163
+ right: '-1px'
3164
+ }
3165
+ },
3166
+ '& .mq-longdiv-inner': {
3167
+ borderTop: '1px solid !important',
3168
+ paddingTop: '1.5px !important'
3169
+ },
3170
+ '& .mq-parallelogram': {
3171
+ lineHeight: 0.85
3172
+ }
3173
+ },
3174
+ showCorrectness: {
3175
+ border: '2px solid'
3176
+ },
3177
+ correctAnswerShown: {
3178
+ padding: theme.spacing.unit,
3179
+ letterSpacing: '0.5px'
3180
+ },
3181
+ correct: {
3182
+ borderColor: `${color.correct()} !important`
3183
+ },
3184
+ incorrect: {
3185
+ borderColor: `${color.incorrect()} !important`
3186
+ },
3187
+ blockContainer: {
3188
+ margin: `${theme.spacing.unit}px !important`,
3189
+ display: 'inline-flex',
3190
+ border: '2px solid grey !important'
3191
+ },
3192
+ blockResponse: {
3193
+ flex: 2,
3194
+ color: 'grey',
3195
+ background: 'lightgrey',
3196
+ fontSize: '0.8rem !important',
3197
+ padding: `${theme.spacing.unit / 2}px !important`,
3198
+ display: 'flex',
3199
+ alignItems: 'center',
3200
+ justifyContent: 'center',
3201
+ borderRight: `2px solid ${color.disabled()} !important`
3202
+ },
3203
+ toggle: {
3204
+ color: color.text()
3205
+ },
3206
+ blockMath: {
3207
+ color: color.text(),
3208
+ backgroundColor: color.background(),
3209
+ padding: `${theme.spacing.unit / 2}px !important`,
3210
+ display: 'flex',
3211
+ alignItems: 'center',
3212
+ justifyContent: 'center',
3213
+ flex: 8,
3214
+ '& > .mq-math-mode': {
3215
+ '& > .mq-hasCursor': {
3216
+ '& > .mq-cursor': {
3217
+ display: 'none'
3218
+ }
3219
+ }
3220
+ }
3221
+ },
3222
+ printContainer: {
3223
+ marginBottom: '10px',
3224
+ pointerEvents: 'none'
3225
+ }
3226
+ });
3227
+ var Main$1 = withStyles(styles)(Main);
3228
+ const React = _dll_react;
3229
+ const ReactDOM = _dll_react_dom;
3230
+ const {debounce: debounce} = _dll_lodash;
3231
+ const debug = _dll_debug;
3232
+ const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
3233
+ const log = debug('pie-element:math-inline:print');
3234
+ const preparePrintModel = (model, opts) => {
3235
+ const instr = opts.role === 'instructor';
3236
+ model.prompt = model.promptEnabled !== false ? model.prompt : undefined;
3237
+ model.teacherInstructions = instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;
3238
+ model.showTeacherInstructions = instr;
3239
+ model.alwaysShowCorrect = instr;
3240
+ model.printMode = true;
3241
+ model.feedback = undefined;
3242
+ model.animationsDisabled = true;
3243
+ return {
3244
+ ...model,
3245
+ disabled: true,
3246
+ config: {
3247
+ ...model,
3248
+ env: {
3249
+ mode: instr ? 'evaluate' : model.mode,
3250
+ role: opts.role
3251
+ }
3252
+ }
3253
+ };
3254
+ };
3255
+ class MathInlinePrint extends HTMLElement {
3256
+ constructor() {
3257
+ super();
3258
+ this._options = null;
3259
+ this._model = null;
3260
+ this._session = [];
3261
+ this._rerender = debounce(() => {
3262
+ if (this._model && this._session) {
3263
+ const printModel = preparePrintModel(this._model, this._options);
3264
+ const element = this._options && React.createElement(Main$1, {
3265
+ model: printModel,
3266
+ session: {}
3267
+ });
3268
+ ReactDOM.render(element, this, () => {
3269
+ log('render complete - render math');
3270
+ renderMath(this);
3271
+ });
3272
+ } else {
3273
+ log('skip');
3274
+ }
3275
+ }, 50, {
3276
+ leading: false,
3277
+ trailing: true
3278
+ });
3279
+ }
3280
+ set options(o) {
3281
+ this._options = o;
3282
+ }
3283
+ set model(s) {
3284
+ this._model = s;
3285
+ this._rerender();
3286
+ }
3287
+ connectedCallback() {}
3288
+ }
3289
+ export {MathInlinePrint as default};