@pie-element/multiple-choice 11.4.3 → 11.4.4-next.3

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,2827 @@
1
+ import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';
2
+
3
+ function _extends() {
4
+ _extends = Object.assign || function (target) {
5
+ for (var i = 1; i < arguments.length; i++) {
6
+ var source = arguments[i];
7
+
8
+ for (var key in source) {
9
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
10
+ target[key] = source[key];
11
+ }
12
+ }
13
+ }
14
+
15
+ return target;
16
+ };
17
+
18
+ return _extends.apply(this, arguments);
19
+ }
20
+
21
+ function _objectWithoutPropertiesLoose(source, excluded) {
22
+ if (source == null) return {};
23
+ var target = {};
24
+ var sourceKeys = Object.keys(source);
25
+ var key, i;
26
+
27
+ for (i = 0; i < sourceKeys.length; i++) {
28
+ key = sourceKeys[i];
29
+ if (excluded.indexOf(key) >= 0) continue;
30
+ target[key] = source[key];
31
+ }
32
+
33
+ return target;
34
+ }
35
+
36
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
37
+
38
+ /** Used for built-in method references. */
39
+
40
+ var objectProto$c = Object.prototype;
41
+
42
+ /**
43
+ * Checks if `value` is likely a prototype object.
44
+ *
45
+ * @private
46
+ * @param {*} value The value to check.
47
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
48
+ */
49
+ function isPrototype$2(value) {
50
+ var Ctor = value && value.constructor,
51
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$c;
52
+
53
+ return value === proto;
54
+ }
55
+
56
+ var _isPrototype = isPrototype$2;
57
+
58
+ /**
59
+ * Creates a unary function that invokes `func` with its argument transformed.
60
+ *
61
+ * @private
62
+ * @param {Function} func The function to wrap.
63
+ * @param {Function} transform The argument transform.
64
+ * @returns {Function} Returns the new function.
65
+ */
66
+
67
+ function overArg$1(func, transform) {
68
+ return function(arg) {
69
+ return func(transform(arg));
70
+ };
71
+ }
72
+
73
+ var _overArg = overArg$1;
74
+
75
+ var overArg = _overArg;
76
+
77
+ /* Built-in method references for those with the same name as other `lodash` methods. */
78
+ var nativeKeys$1 = overArg(Object.keys, Object);
79
+
80
+ var _nativeKeys = nativeKeys$1;
81
+
82
+ var isPrototype$1 = _isPrototype,
83
+ nativeKeys = _nativeKeys;
84
+
85
+ /** Used for built-in method references. */
86
+ var objectProto$b = Object.prototype;
87
+
88
+ /** Used to check objects for own properties. */
89
+ var hasOwnProperty$9 = objectProto$b.hasOwnProperty;
90
+
91
+ /**
92
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
93
+ *
94
+ * @private
95
+ * @param {Object} object The object to query.
96
+ * @returns {Array} Returns the array of property names.
97
+ */
98
+ function baseKeys$2(object) {
99
+ if (!isPrototype$1(object)) {
100
+ return nativeKeys(object);
101
+ }
102
+ var result = [];
103
+ for (var key in Object(object)) {
104
+ if (hasOwnProperty$9.call(object, key) && key != 'constructor') {
105
+ result.push(key);
106
+ }
107
+ }
108
+ return result;
109
+ }
110
+
111
+ var _baseKeys = baseKeys$2;
112
+
113
+ /** Detect free variable `global` from Node.js. */
114
+
115
+ var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
116
+
117
+ var _freeGlobal = freeGlobal$1;
118
+
119
+ var freeGlobal = _freeGlobal;
120
+
121
+ /** Detect free variable `self`. */
122
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
123
+
124
+ /** Used as a reference to the global object. */
125
+ var root$8 = freeGlobal || freeSelf || Function('return this')();
126
+
127
+ var _root = root$8;
128
+
129
+ var root$7 = _root;
130
+
131
+ /** Built-in value references. */
132
+ var Symbol$3 = root$7.Symbol;
133
+
134
+ var _Symbol = Symbol$3;
135
+
136
+ var Symbol$2 = _Symbol;
137
+
138
+ /** Used for built-in method references. */
139
+ var objectProto$a = Object.prototype;
140
+
141
+ /** Used to check objects for own properties. */
142
+ var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
143
+
144
+ /**
145
+ * Used to resolve the
146
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
147
+ * of values.
148
+ */
149
+ var nativeObjectToString$1 = objectProto$a.toString;
150
+
151
+ /** Built-in value references. */
152
+ var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
153
+
154
+ /**
155
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
156
+ *
157
+ * @private
158
+ * @param {*} value The value to query.
159
+ * @returns {string} Returns the raw `toStringTag`.
160
+ */
161
+ function getRawTag$1(value) {
162
+ var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
163
+ tag = value[symToStringTag$1];
164
+
165
+ try {
166
+ value[symToStringTag$1] = undefined;
167
+ var unmasked = true;
168
+ } catch (e) {}
169
+
170
+ var result = nativeObjectToString$1.call(value);
171
+ if (unmasked) {
172
+ if (isOwn) {
173
+ value[symToStringTag$1] = tag;
174
+ } else {
175
+ delete value[symToStringTag$1];
176
+ }
177
+ }
178
+ return result;
179
+ }
180
+
181
+ var _getRawTag = getRawTag$1;
182
+
183
+ /** Used for built-in method references. */
184
+
185
+ var objectProto$9 = Object.prototype;
186
+
187
+ /**
188
+ * Used to resolve the
189
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
190
+ * of values.
191
+ */
192
+ var nativeObjectToString = objectProto$9.toString;
193
+
194
+ /**
195
+ * Converts `value` to a string using `Object.prototype.toString`.
196
+ *
197
+ * @private
198
+ * @param {*} value The value to convert.
199
+ * @returns {string} Returns the converted string.
200
+ */
201
+ function objectToString$1(value) {
202
+ return nativeObjectToString.call(value);
203
+ }
204
+
205
+ var _objectToString = objectToString$1;
206
+
207
+ var Symbol$1 = _Symbol,
208
+ getRawTag = _getRawTag,
209
+ objectToString = _objectToString;
210
+
211
+ /** `Object#toString` result references. */
212
+ var nullTag = '[object Null]',
213
+ undefinedTag = '[object Undefined]';
214
+
215
+ /** Built-in value references. */
216
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
217
+
218
+ /**
219
+ * The base implementation of `getTag` without fallbacks for buggy environments.
220
+ *
221
+ * @private
222
+ * @param {*} value The value to query.
223
+ * @returns {string} Returns the `toStringTag`.
224
+ */
225
+ function baseGetTag$4(value) {
226
+ if (value == null) {
227
+ return value === undefined ? undefinedTag : nullTag;
228
+ }
229
+ return (symToStringTag && symToStringTag in Object(value))
230
+ ? getRawTag(value)
231
+ : objectToString(value);
232
+ }
233
+
234
+ var _baseGetTag = baseGetTag$4;
235
+
236
+ /**
237
+ * Checks if `value` is the
238
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
239
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
240
+ *
241
+ * @static
242
+ * @memberOf _
243
+ * @since 0.1.0
244
+ * @category Lang
245
+ * @param {*} value The value to check.
246
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
247
+ * @example
248
+ *
249
+ * _.isObject({});
250
+ * // => true
251
+ *
252
+ * _.isObject([1, 2, 3]);
253
+ * // => true
254
+ *
255
+ * _.isObject(_.noop);
256
+ * // => true
257
+ *
258
+ * _.isObject(null);
259
+ * // => false
260
+ */
261
+
262
+ function isObject$2(value) {
263
+ var type = typeof value;
264
+ return value != null && (type == 'object' || type == 'function');
265
+ }
266
+
267
+ var isObject_1 = isObject$2;
268
+
269
+ var baseGetTag$3 = _baseGetTag,
270
+ isObject$1 = isObject_1;
271
+
272
+ /** `Object#toString` result references. */
273
+ var asyncTag = '[object AsyncFunction]',
274
+ funcTag$1 = '[object Function]',
275
+ genTag = '[object GeneratorFunction]',
276
+ proxyTag = '[object Proxy]';
277
+
278
+ /**
279
+ * Checks if `value` is classified as a `Function` object.
280
+ *
281
+ * @static
282
+ * @memberOf _
283
+ * @since 0.1.0
284
+ * @category Lang
285
+ * @param {*} value The value to check.
286
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
287
+ * @example
288
+ *
289
+ * _.isFunction(_);
290
+ * // => true
291
+ *
292
+ * _.isFunction(/abc/);
293
+ * // => false
294
+ */
295
+ function isFunction$2(value) {
296
+ if (!isObject$1(value)) {
297
+ return false;
298
+ }
299
+ // The use of `Object#toString` avoids issues with the `typeof` operator
300
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
301
+ var tag = baseGetTag$3(value);
302
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
303
+ }
304
+
305
+ var isFunction_1 = isFunction$2;
306
+
307
+ var root$6 = _root;
308
+
309
+ /** Used to detect overreaching core-js shims. */
310
+ var coreJsData$1 = root$6['__core-js_shared__'];
311
+
312
+ var _coreJsData = coreJsData$1;
313
+
314
+ var coreJsData = _coreJsData;
315
+
316
+ /** Used to detect methods masquerading as native. */
317
+ var maskSrcKey = (function() {
318
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
319
+ return uid ? ('Symbol(src)_1.' + uid) : '';
320
+ }());
321
+
322
+ /**
323
+ * Checks if `func` has its source masked.
324
+ *
325
+ * @private
326
+ * @param {Function} func The function to check.
327
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
328
+ */
329
+ function isMasked$1(func) {
330
+ return !!maskSrcKey && (maskSrcKey in func);
331
+ }
332
+
333
+ var _isMasked = isMasked$1;
334
+
335
+ /** Used for built-in method references. */
336
+
337
+ var funcProto$1 = Function.prototype;
338
+
339
+ /** Used to resolve the decompiled source of functions. */
340
+ var funcToString$1 = funcProto$1.toString;
341
+
342
+ /**
343
+ * Converts `func` to its source code.
344
+ *
345
+ * @private
346
+ * @param {Function} func The function to convert.
347
+ * @returns {string} Returns the source code.
348
+ */
349
+ function toSource$2(func) {
350
+ if (func != null) {
351
+ try {
352
+ return funcToString$1.call(func);
353
+ } catch (e) {}
354
+ try {
355
+ return (func + '');
356
+ } catch (e) {}
357
+ }
358
+ return '';
359
+ }
360
+
361
+ var _toSource = toSource$2;
362
+
363
+ var isFunction$1 = isFunction_1,
364
+ isMasked = _isMasked,
365
+ isObject = isObject_1,
366
+ toSource$1 = _toSource;
367
+
368
+ /**
369
+ * Used to match `RegExp`
370
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
371
+ */
372
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
373
+
374
+ /** Used to detect host constructors (Safari). */
375
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
376
+
377
+ /** Used for built-in method references. */
378
+ var funcProto = Function.prototype,
379
+ objectProto$8 = Object.prototype;
380
+
381
+ /** Used to resolve the decompiled source of functions. */
382
+ var funcToString = funcProto.toString;
383
+
384
+ /** Used to check objects for own properties. */
385
+ var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
386
+
387
+ /** Used to detect if a method is native. */
388
+ var reIsNative = RegExp('^' +
389
+ funcToString.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
390
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
391
+ );
392
+
393
+ /**
394
+ * The base implementation of `_.isNative` without bad shim checks.
395
+ *
396
+ * @private
397
+ * @param {*} value The value to check.
398
+ * @returns {boolean} Returns `true` if `value` is a native function,
399
+ * else `false`.
400
+ */
401
+ function baseIsNative$1(value) {
402
+ if (!isObject(value) || isMasked(value)) {
403
+ return false;
404
+ }
405
+ var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
406
+ return pattern.test(toSource$1(value));
407
+ }
408
+
409
+ var _baseIsNative = baseIsNative$1;
410
+
411
+ /**
412
+ * Gets the value at `key` of `object`.
413
+ *
414
+ * @private
415
+ * @param {Object} [object] The object to query.
416
+ * @param {string} key The key of the property to get.
417
+ * @returns {*} Returns the property value.
418
+ */
419
+
420
+ function getValue$1(object, key) {
421
+ return object == null ? undefined : object[key];
422
+ }
423
+
424
+ var _getValue = getValue$1;
425
+
426
+ var baseIsNative = _baseIsNative,
427
+ getValue = _getValue;
428
+
429
+ /**
430
+ * Gets the native function at `key` of `object`.
431
+ *
432
+ * @private
433
+ * @param {Object} object The object to query.
434
+ * @param {string} key The key of the method to get.
435
+ * @returns {*} Returns the function if it's native, else `undefined`.
436
+ */
437
+ function getNative$6(object, key) {
438
+ var value = getValue(object, key);
439
+ return baseIsNative(value) ? value : undefined;
440
+ }
441
+
442
+ var _getNative = getNative$6;
443
+
444
+ var getNative$5 = _getNative,
445
+ root$5 = _root;
446
+
447
+ /* Built-in method references that are verified to be native. */
448
+ var DataView$1 = getNative$5(root$5, 'DataView');
449
+
450
+ var _DataView = DataView$1;
451
+
452
+ var getNative$4 = _getNative,
453
+ root$4 = _root;
454
+
455
+ /* Built-in method references that are verified to be native. */
456
+ var Map$3 = getNative$4(root$4, 'Map');
457
+
458
+ var _Map = Map$3;
459
+
460
+ var getNative$3 = _getNative,
461
+ root$3 = _root;
462
+
463
+ /* Built-in method references that are verified to be native. */
464
+ var Promise$2 = getNative$3(root$3, 'Promise');
465
+
466
+ var _Promise = Promise$2;
467
+
468
+ var getNative$2 = _getNative,
469
+ root$2 = _root;
470
+
471
+ /* Built-in method references that are verified to be native. */
472
+ var Set$1 = getNative$2(root$2, 'Set');
473
+
474
+ var _Set = Set$1;
475
+
476
+ var getNative$1 = _getNative,
477
+ root$1 = _root;
478
+
479
+ /* Built-in method references that are verified to be native. */
480
+ var WeakMap$1 = getNative$1(root$1, 'WeakMap');
481
+
482
+ var _WeakMap = WeakMap$1;
483
+
484
+ var DataView = _DataView,
485
+ Map$2 = _Map,
486
+ Promise$1 = _Promise,
487
+ Set = _Set,
488
+ WeakMap = _WeakMap,
489
+ baseGetTag$2 = _baseGetTag,
490
+ toSource = _toSource;
491
+
492
+ /** `Object#toString` result references. */
493
+ var mapTag$3 = '[object Map]',
494
+ objectTag$2 = '[object Object]',
495
+ promiseTag = '[object Promise]',
496
+ setTag$3 = '[object Set]',
497
+ weakMapTag$1 = '[object WeakMap]';
498
+
499
+ var dataViewTag$2 = '[object DataView]';
500
+
501
+ /** Used to detect maps, sets, and weakmaps. */
502
+ var dataViewCtorString = toSource(DataView),
503
+ mapCtorString = toSource(Map$2),
504
+ promiseCtorString = toSource(Promise$1),
505
+ setCtorString = toSource(Set),
506
+ weakMapCtorString = toSource(WeakMap);
507
+
508
+ /**
509
+ * Gets the `toStringTag` of `value`.
510
+ *
511
+ * @private
512
+ * @param {*} value The value to query.
513
+ * @returns {string} Returns the `toStringTag`.
514
+ */
515
+ var getTag$2 = baseGetTag$2;
516
+
517
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
518
+ if ((DataView && getTag$2(new DataView(new ArrayBuffer(1))) != dataViewTag$2) ||
519
+ (Map$2 && getTag$2(new Map$2) != mapTag$3) ||
520
+ (Promise$1 && getTag$2(Promise$1.resolve()) != promiseTag) ||
521
+ (Set && getTag$2(new Set) != setTag$3) ||
522
+ (WeakMap && getTag$2(new WeakMap) != weakMapTag$1)) {
523
+ getTag$2 = function(value) {
524
+ var result = baseGetTag$2(value),
525
+ Ctor = result == objectTag$2 ? value.constructor : undefined,
526
+ ctorString = Ctor ? toSource(Ctor) : '';
527
+
528
+ if (ctorString) {
529
+ switch (ctorString) {
530
+ case dataViewCtorString: return dataViewTag$2;
531
+ case mapCtorString: return mapTag$3;
532
+ case promiseCtorString: return promiseTag;
533
+ case setCtorString: return setTag$3;
534
+ case weakMapCtorString: return weakMapTag$1;
535
+ }
536
+ }
537
+ return result;
538
+ };
539
+ }
540
+
541
+ var _getTag = getTag$2;
542
+
543
+ /**
544
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
545
+ * and has a `typeof` result of "object".
546
+ *
547
+ * @static
548
+ * @memberOf _
549
+ * @since 4.0.0
550
+ * @category Lang
551
+ * @param {*} value The value to check.
552
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
553
+ * @example
554
+ *
555
+ * _.isObjectLike({});
556
+ * // => true
557
+ *
558
+ * _.isObjectLike([1, 2, 3]);
559
+ * // => true
560
+ *
561
+ * _.isObjectLike(_.noop);
562
+ * // => false
563
+ *
564
+ * _.isObjectLike(null);
565
+ * // => false
566
+ */
567
+
568
+ function isObjectLike$4(value) {
569
+ return value != null && typeof value == 'object';
570
+ }
571
+
572
+ var isObjectLike_1 = isObjectLike$4;
573
+
574
+ var baseGetTag$1 = _baseGetTag,
575
+ isObjectLike$3 = isObjectLike_1;
576
+
577
+ /** `Object#toString` result references. */
578
+ var argsTag$2 = '[object Arguments]';
579
+
580
+ /**
581
+ * The base implementation of `_.isArguments`.
582
+ *
583
+ * @private
584
+ * @param {*} value The value to check.
585
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
586
+ */
587
+ function baseIsArguments$1(value) {
588
+ return isObjectLike$3(value) && baseGetTag$1(value) == argsTag$2;
589
+ }
590
+
591
+ var _baseIsArguments = baseIsArguments$1;
592
+
593
+ var baseIsArguments = _baseIsArguments,
594
+ isObjectLike$2 = isObjectLike_1;
595
+
596
+ /** Used for built-in method references. */
597
+ var objectProto$7 = Object.prototype;
598
+
599
+ /** Used to check objects for own properties. */
600
+ var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
601
+
602
+ /** Built-in value references. */
603
+ var propertyIsEnumerable$1 = objectProto$7.propertyIsEnumerable;
604
+
605
+ /**
606
+ * Checks if `value` is likely an `arguments` object.
607
+ *
608
+ * @static
609
+ * @memberOf _
610
+ * @since 0.1.0
611
+ * @category Lang
612
+ * @param {*} value The value to check.
613
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
614
+ * else `false`.
615
+ * @example
616
+ *
617
+ * _.isArguments(function() { return arguments; }());
618
+ * // => true
619
+ *
620
+ * _.isArguments([1, 2, 3]);
621
+ * // => false
622
+ */
623
+ var isArguments$2 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
624
+ return isObjectLike$2(value) && hasOwnProperty$6.call(value, 'callee') &&
625
+ !propertyIsEnumerable$1.call(value, 'callee');
626
+ };
627
+
628
+ var isArguments_1 = isArguments$2;
629
+
630
+ /**
631
+ * Checks if `value` is classified as an `Array` object.
632
+ *
633
+ * @static
634
+ * @memberOf _
635
+ * @since 0.1.0
636
+ * @category Lang
637
+ * @param {*} value The value to check.
638
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
639
+ * @example
640
+ *
641
+ * _.isArray([1, 2, 3]);
642
+ * // => true
643
+ *
644
+ * _.isArray(document.body.children);
645
+ * // => false
646
+ *
647
+ * _.isArray('abc');
648
+ * // => false
649
+ *
650
+ * _.isArray(_.noop);
651
+ * // => false
652
+ */
653
+
654
+ var isArray$4 = Array.isArray;
655
+
656
+ var isArray_1 = isArray$4;
657
+
658
+ /** Used as references for various `Number` constants. */
659
+
660
+ var MAX_SAFE_INTEGER$1 = 9007199254740991;
661
+
662
+ /**
663
+ * Checks if `value` is a valid array-like length.
664
+ *
665
+ * **Note:** This method is loosely based on
666
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
667
+ *
668
+ * @static
669
+ * @memberOf _
670
+ * @since 4.0.0
671
+ * @category Lang
672
+ * @param {*} value The value to check.
673
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
674
+ * @example
675
+ *
676
+ * _.isLength(3);
677
+ * // => true
678
+ *
679
+ * _.isLength(Number.MIN_VALUE);
680
+ * // => false
681
+ *
682
+ * _.isLength(Infinity);
683
+ * // => false
684
+ *
685
+ * _.isLength('3');
686
+ * // => false
687
+ */
688
+ function isLength$2(value) {
689
+ return typeof value == 'number' &&
690
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
691
+ }
692
+
693
+ var isLength_1 = isLength$2;
694
+
695
+ var isFunction = isFunction_1,
696
+ isLength$1 = isLength_1;
697
+
698
+ /**
699
+ * Checks if `value` is array-like. A value is considered array-like if it's
700
+ * not a function and has a `value.length` that's an integer greater than or
701
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
702
+ *
703
+ * @static
704
+ * @memberOf _
705
+ * @since 4.0.0
706
+ * @category Lang
707
+ * @param {*} value The value to check.
708
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
709
+ * @example
710
+ *
711
+ * _.isArrayLike([1, 2, 3]);
712
+ * // => true
713
+ *
714
+ * _.isArrayLike(document.body.children);
715
+ * // => true
716
+ *
717
+ * _.isArrayLike('abc');
718
+ * // => true
719
+ *
720
+ * _.isArrayLike(_.noop);
721
+ * // => false
722
+ */
723
+ function isArrayLike$2(value) {
724
+ return value != null && isLength$1(value.length) && !isFunction(value);
725
+ }
726
+
727
+ var isArrayLike_1 = isArrayLike$2;
728
+
729
+ var isBuffer$3 = {exports: {}};
730
+
731
+ /**
732
+ * This method returns `false`.
733
+ *
734
+ * @static
735
+ * @memberOf _
736
+ * @since 4.13.0
737
+ * @category Util
738
+ * @returns {boolean} Returns `false`.
739
+ * @example
740
+ *
741
+ * _.times(2, _.stubFalse);
742
+ * // => [false, false]
743
+ */
744
+
745
+ function stubFalse() {
746
+ return false;
747
+ }
748
+
749
+ var stubFalse_1 = stubFalse;
750
+
751
+ (function (module, exports) {
752
+ var root = _root,
753
+ stubFalse = stubFalse_1;
754
+
755
+ /** Detect free variable `exports`. */
756
+ var freeExports = exports && !exports.nodeType && exports;
757
+
758
+ /** Detect free variable `module`. */
759
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
760
+
761
+ /** Detect the popular CommonJS extension `module.exports`. */
762
+ var moduleExports = freeModule && freeModule.exports === freeExports;
763
+
764
+ /** Built-in value references. */
765
+ var Buffer = moduleExports ? root.Buffer : undefined;
766
+
767
+ /* Built-in method references for those with the same name as other `lodash` methods. */
768
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
769
+
770
+ /**
771
+ * Checks if `value` is a buffer.
772
+ *
773
+ * @static
774
+ * @memberOf _
775
+ * @since 4.3.0
776
+ * @category Lang
777
+ * @param {*} value The value to check.
778
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
779
+ * @example
780
+ *
781
+ * _.isBuffer(new Buffer(2));
782
+ * // => true
783
+ *
784
+ * _.isBuffer(new Uint8Array(2));
785
+ * // => false
786
+ */
787
+ var isBuffer = nativeIsBuffer || stubFalse;
788
+
789
+ module.exports = isBuffer;
790
+ }(isBuffer$3, isBuffer$3.exports));
791
+
792
+ var baseGetTag = _baseGetTag,
793
+ isLength = isLength_1,
794
+ isObjectLike$1 = isObjectLike_1;
795
+
796
+ /** `Object#toString` result references. */
797
+ var argsTag$1 = '[object Arguments]',
798
+ arrayTag$1 = '[object Array]',
799
+ boolTag$1 = '[object Boolean]',
800
+ dateTag$1 = '[object Date]',
801
+ errorTag$1 = '[object Error]',
802
+ funcTag = '[object Function]',
803
+ mapTag$2 = '[object Map]',
804
+ numberTag$1 = '[object Number]',
805
+ objectTag$1 = '[object Object]',
806
+ regexpTag$1 = '[object RegExp]',
807
+ setTag$2 = '[object Set]',
808
+ stringTag$1 = '[object String]',
809
+ weakMapTag = '[object WeakMap]';
810
+
811
+ var arrayBufferTag$1 = '[object ArrayBuffer]',
812
+ dataViewTag$1 = '[object DataView]',
813
+ float32Tag = '[object Float32Array]',
814
+ float64Tag = '[object Float64Array]',
815
+ int8Tag = '[object Int8Array]',
816
+ int16Tag = '[object Int16Array]',
817
+ int32Tag = '[object Int32Array]',
818
+ uint8Tag = '[object Uint8Array]',
819
+ uint8ClampedTag = '[object Uint8ClampedArray]',
820
+ uint16Tag = '[object Uint16Array]',
821
+ uint32Tag = '[object Uint32Array]';
822
+
823
+ /** Used to identify `toStringTag` values of typed arrays. */
824
+ var typedArrayTags = {};
825
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
826
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
827
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
828
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
829
+ typedArrayTags[uint32Tag] = true;
830
+ typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] =
831
+ typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] =
832
+ typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag$1] =
833
+ typedArrayTags[errorTag$1] = typedArrayTags[funcTag] =
834
+ typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] =
835
+ typedArrayTags[objectTag$1] = typedArrayTags[regexpTag$1] =
836
+ typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] =
837
+ typedArrayTags[weakMapTag] = false;
838
+
839
+ /**
840
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
841
+ *
842
+ * @private
843
+ * @param {*} value The value to check.
844
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
845
+ */
846
+ function baseIsTypedArray$1(value) {
847
+ return isObjectLike$1(value) &&
848
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
849
+ }
850
+
851
+ var _baseIsTypedArray = baseIsTypedArray$1;
852
+
853
+ /**
854
+ * The base implementation of `_.unary` without support for storing metadata.
855
+ *
856
+ * @private
857
+ * @param {Function} func The function to cap arguments for.
858
+ * @returns {Function} Returns the new capped function.
859
+ */
860
+
861
+ function baseUnary$1(func) {
862
+ return function(value) {
863
+ return func(value);
864
+ };
865
+ }
866
+
867
+ var _baseUnary = baseUnary$1;
868
+
869
+ var _nodeUtil = {exports: {}};
870
+
871
+ (function (module, exports) {
872
+ var freeGlobal = _freeGlobal;
873
+
874
+ /** Detect free variable `exports`. */
875
+ var freeExports = exports && !exports.nodeType && exports;
876
+
877
+ /** Detect free variable `module`. */
878
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
879
+
880
+ /** Detect the popular CommonJS extension `module.exports`. */
881
+ var moduleExports = freeModule && freeModule.exports === freeExports;
882
+
883
+ /** Detect free variable `process` from Node.js. */
884
+ var freeProcess = moduleExports && freeGlobal.process;
885
+
886
+ /** Used to access faster Node.js helpers. */
887
+ var nodeUtil = (function() {
888
+ try {
889
+ // Use `util.types` for Node.js 10+.
890
+ var types = freeModule && freeModule.require && freeModule.require('util').types;
891
+
892
+ if (types) {
893
+ return types;
894
+ }
895
+
896
+ // Legacy `process.binding('util')` for Node.js < 10.
897
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
898
+ } catch (e) {}
899
+ }());
900
+
901
+ module.exports = nodeUtil;
902
+ }(_nodeUtil, _nodeUtil.exports));
903
+
904
+ var baseIsTypedArray = _baseIsTypedArray,
905
+ baseUnary = _baseUnary,
906
+ nodeUtil = _nodeUtil.exports;
907
+
908
+ /* Node.js helper references. */
909
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
910
+
911
+ /**
912
+ * Checks if `value` is classified as a typed array.
913
+ *
914
+ * @static
915
+ * @memberOf _
916
+ * @since 3.0.0
917
+ * @category Lang
918
+ * @param {*} value The value to check.
919
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
920
+ * @example
921
+ *
922
+ * _.isTypedArray(new Uint8Array);
923
+ * // => true
924
+ *
925
+ * _.isTypedArray([]);
926
+ * // => false
927
+ */
928
+ var isTypedArray$3 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
929
+
930
+ var isTypedArray_1 = isTypedArray$3;
931
+
932
+ var baseKeys$1 = _baseKeys,
933
+ getTag$1 = _getTag,
934
+ isArguments$1 = isArguments_1,
935
+ isArray$3 = isArray_1,
936
+ isArrayLike$1 = isArrayLike_1,
937
+ isBuffer$2 = isBuffer$3.exports,
938
+ isPrototype = _isPrototype,
939
+ isTypedArray$2 = isTypedArray_1;
940
+
941
+ /** `Object#toString` result references. */
942
+ var mapTag$1 = '[object Map]',
943
+ setTag$1 = '[object Set]';
944
+
945
+ /** Used for built-in method references. */
946
+ var objectProto$6 = Object.prototype;
947
+
948
+ /** Used to check objects for own properties. */
949
+ var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
950
+
951
+ /**
952
+ * Checks if `value` is an empty object, collection, map, or set.
953
+ *
954
+ * Objects are considered empty if they have no own enumerable string keyed
955
+ * properties.
956
+ *
957
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
958
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
959
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
960
+ *
961
+ * @static
962
+ * @memberOf _
963
+ * @since 0.1.0
964
+ * @category Lang
965
+ * @param {*} value The value to check.
966
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
967
+ * @example
968
+ *
969
+ * _.isEmpty(null);
970
+ * // => true
971
+ *
972
+ * _.isEmpty(true);
973
+ * // => true
974
+ *
975
+ * _.isEmpty(1);
976
+ * // => true
977
+ *
978
+ * _.isEmpty([1, 2, 3]);
979
+ * // => false
980
+ *
981
+ * _.isEmpty({ 'a': 1 });
982
+ * // => false
983
+ */
984
+ function isEmpty(value) {
985
+ if (value == null) {
986
+ return true;
987
+ }
988
+ if (isArrayLike$1(value) &&
989
+ (isArray$3(value) || typeof value == 'string' || typeof value.splice == 'function' ||
990
+ isBuffer$2(value) || isTypedArray$2(value) || isArguments$1(value))) {
991
+ return !value.length;
992
+ }
993
+ var tag = getTag$1(value);
994
+ if (tag == mapTag$1 || tag == setTag$1) {
995
+ return !value.size;
996
+ }
997
+ if (isPrototype(value)) {
998
+ return !baseKeys$1(value).length;
999
+ }
1000
+ for (var key in value) {
1001
+ if (hasOwnProperty$5.call(value, key)) {
1002
+ return false;
1003
+ }
1004
+ }
1005
+ return true;
1006
+ }
1007
+
1008
+ var isEmpty_1 = isEmpty;
1009
+
1010
+ /**
1011
+ * Removes all key-value entries from the list cache.
1012
+ *
1013
+ * @private
1014
+ * @name clear
1015
+ * @memberOf ListCache
1016
+ */
1017
+
1018
+ function listCacheClear$1() {
1019
+ this.__data__ = [];
1020
+ this.size = 0;
1021
+ }
1022
+
1023
+ var _listCacheClear = listCacheClear$1;
1024
+
1025
+ /**
1026
+ * Performs a
1027
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1028
+ * comparison between two values to determine if they are equivalent.
1029
+ *
1030
+ * @static
1031
+ * @memberOf _
1032
+ * @since 4.0.0
1033
+ * @category Lang
1034
+ * @param {*} value The value to compare.
1035
+ * @param {*} other The other value to compare.
1036
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1037
+ * @example
1038
+ *
1039
+ * var object = { 'a': 1 };
1040
+ * var other = { 'a': 1 };
1041
+ *
1042
+ * _.eq(object, object);
1043
+ * // => true
1044
+ *
1045
+ * _.eq(object, other);
1046
+ * // => false
1047
+ *
1048
+ * _.eq('a', 'a');
1049
+ * // => true
1050
+ *
1051
+ * _.eq('a', Object('a'));
1052
+ * // => false
1053
+ *
1054
+ * _.eq(NaN, NaN);
1055
+ * // => true
1056
+ */
1057
+
1058
+ function eq$2(value, other) {
1059
+ return value === other || (value !== value && other !== other);
1060
+ }
1061
+
1062
+ var eq_1 = eq$2;
1063
+
1064
+ var eq$1 = eq_1;
1065
+
1066
+ /**
1067
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
1068
+ *
1069
+ * @private
1070
+ * @param {Array} array The array to inspect.
1071
+ * @param {*} key The key to search for.
1072
+ * @returns {number} Returns the index of the matched value, else `-1`.
1073
+ */
1074
+ function assocIndexOf$4(array, key) {
1075
+ var length = array.length;
1076
+ while (length--) {
1077
+ if (eq$1(array[length][0], key)) {
1078
+ return length;
1079
+ }
1080
+ }
1081
+ return -1;
1082
+ }
1083
+
1084
+ var _assocIndexOf = assocIndexOf$4;
1085
+
1086
+ var assocIndexOf$3 = _assocIndexOf;
1087
+
1088
+ /** Used for built-in method references. */
1089
+ var arrayProto = Array.prototype;
1090
+
1091
+ /** Built-in value references. */
1092
+ var splice = arrayProto.splice;
1093
+
1094
+ /**
1095
+ * Removes `key` and its value from the list cache.
1096
+ *
1097
+ * @private
1098
+ * @name delete
1099
+ * @memberOf ListCache
1100
+ * @param {string} key The key of the value to remove.
1101
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1102
+ */
1103
+ function listCacheDelete$1(key) {
1104
+ var data = this.__data__,
1105
+ index = assocIndexOf$3(data, key);
1106
+
1107
+ if (index < 0) {
1108
+ return false;
1109
+ }
1110
+ var lastIndex = data.length - 1;
1111
+ if (index == lastIndex) {
1112
+ data.pop();
1113
+ } else {
1114
+ splice.call(data, index, 1);
1115
+ }
1116
+ --this.size;
1117
+ return true;
1118
+ }
1119
+
1120
+ var _listCacheDelete = listCacheDelete$1;
1121
+
1122
+ var assocIndexOf$2 = _assocIndexOf;
1123
+
1124
+ /**
1125
+ * Gets the list cache value for `key`.
1126
+ *
1127
+ * @private
1128
+ * @name get
1129
+ * @memberOf ListCache
1130
+ * @param {string} key The key of the value to get.
1131
+ * @returns {*} Returns the entry value.
1132
+ */
1133
+ function listCacheGet$1(key) {
1134
+ var data = this.__data__,
1135
+ index = assocIndexOf$2(data, key);
1136
+
1137
+ return index < 0 ? undefined : data[index][1];
1138
+ }
1139
+
1140
+ var _listCacheGet = listCacheGet$1;
1141
+
1142
+ var assocIndexOf$1 = _assocIndexOf;
1143
+
1144
+ /**
1145
+ * Checks if a list cache value for `key` exists.
1146
+ *
1147
+ * @private
1148
+ * @name has
1149
+ * @memberOf ListCache
1150
+ * @param {string} key The key of the entry to check.
1151
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1152
+ */
1153
+ function listCacheHas$1(key) {
1154
+ return assocIndexOf$1(this.__data__, key) > -1;
1155
+ }
1156
+
1157
+ var _listCacheHas = listCacheHas$1;
1158
+
1159
+ var assocIndexOf = _assocIndexOf;
1160
+
1161
+ /**
1162
+ * Sets the list cache `key` to `value`.
1163
+ *
1164
+ * @private
1165
+ * @name set
1166
+ * @memberOf ListCache
1167
+ * @param {string} key The key of the value to set.
1168
+ * @param {*} value The value to set.
1169
+ * @returns {Object} Returns the list cache instance.
1170
+ */
1171
+ function listCacheSet$1(key, value) {
1172
+ var data = this.__data__,
1173
+ index = assocIndexOf(data, key);
1174
+
1175
+ if (index < 0) {
1176
+ ++this.size;
1177
+ data.push([key, value]);
1178
+ } else {
1179
+ data[index][1] = value;
1180
+ }
1181
+ return this;
1182
+ }
1183
+
1184
+ var _listCacheSet = listCacheSet$1;
1185
+
1186
+ var listCacheClear = _listCacheClear,
1187
+ listCacheDelete = _listCacheDelete,
1188
+ listCacheGet = _listCacheGet,
1189
+ listCacheHas = _listCacheHas,
1190
+ listCacheSet = _listCacheSet;
1191
+
1192
+ /**
1193
+ * Creates an list cache object.
1194
+ *
1195
+ * @private
1196
+ * @constructor
1197
+ * @param {Array} [entries] The key-value pairs to cache.
1198
+ */
1199
+ function ListCache$4(entries) {
1200
+ var index = -1,
1201
+ length = entries == null ? 0 : entries.length;
1202
+
1203
+ this.clear();
1204
+ while (++index < length) {
1205
+ var entry = entries[index];
1206
+ this.set(entry[0], entry[1]);
1207
+ }
1208
+ }
1209
+
1210
+ // Add methods to `ListCache`.
1211
+ ListCache$4.prototype.clear = listCacheClear;
1212
+ ListCache$4.prototype['delete'] = listCacheDelete;
1213
+ ListCache$4.prototype.get = listCacheGet;
1214
+ ListCache$4.prototype.has = listCacheHas;
1215
+ ListCache$4.prototype.set = listCacheSet;
1216
+
1217
+ var _ListCache = ListCache$4;
1218
+
1219
+ var ListCache$3 = _ListCache;
1220
+
1221
+ /**
1222
+ * Removes all key-value entries from the stack.
1223
+ *
1224
+ * @private
1225
+ * @name clear
1226
+ * @memberOf Stack
1227
+ */
1228
+ function stackClear$1() {
1229
+ this.__data__ = new ListCache$3;
1230
+ this.size = 0;
1231
+ }
1232
+
1233
+ var _stackClear = stackClear$1;
1234
+
1235
+ /**
1236
+ * Removes `key` and its value from the stack.
1237
+ *
1238
+ * @private
1239
+ * @name delete
1240
+ * @memberOf Stack
1241
+ * @param {string} key The key of the value to remove.
1242
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1243
+ */
1244
+
1245
+ function stackDelete$1(key) {
1246
+ var data = this.__data__,
1247
+ result = data['delete'](key);
1248
+
1249
+ this.size = data.size;
1250
+ return result;
1251
+ }
1252
+
1253
+ var _stackDelete = stackDelete$1;
1254
+
1255
+ /**
1256
+ * Gets the stack value for `key`.
1257
+ *
1258
+ * @private
1259
+ * @name get
1260
+ * @memberOf Stack
1261
+ * @param {string} key The key of the value to get.
1262
+ * @returns {*} Returns the entry value.
1263
+ */
1264
+
1265
+ function stackGet$1(key) {
1266
+ return this.__data__.get(key);
1267
+ }
1268
+
1269
+ var _stackGet = stackGet$1;
1270
+
1271
+ /**
1272
+ * Checks if a stack value for `key` exists.
1273
+ *
1274
+ * @private
1275
+ * @name has
1276
+ * @memberOf Stack
1277
+ * @param {string} key The key of the entry to check.
1278
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1279
+ */
1280
+
1281
+ function stackHas$1(key) {
1282
+ return this.__data__.has(key);
1283
+ }
1284
+
1285
+ var _stackHas = stackHas$1;
1286
+
1287
+ var getNative = _getNative;
1288
+
1289
+ /* Built-in method references that are verified to be native. */
1290
+ var nativeCreate$4 = getNative(Object, 'create');
1291
+
1292
+ var _nativeCreate = nativeCreate$4;
1293
+
1294
+ var nativeCreate$3 = _nativeCreate;
1295
+
1296
+ /**
1297
+ * Removes all key-value entries from the hash.
1298
+ *
1299
+ * @private
1300
+ * @name clear
1301
+ * @memberOf Hash
1302
+ */
1303
+ function hashClear$1() {
1304
+ this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
1305
+ this.size = 0;
1306
+ }
1307
+
1308
+ var _hashClear = hashClear$1;
1309
+
1310
+ /**
1311
+ * Removes `key` and its value from the hash.
1312
+ *
1313
+ * @private
1314
+ * @name delete
1315
+ * @memberOf Hash
1316
+ * @param {Object} hash The hash to modify.
1317
+ * @param {string} key The key of the value to remove.
1318
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1319
+ */
1320
+
1321
+ function hashDelete$1(key) {
1322
+ var result = this.has(key) && delete this.__data__[key];
1323
+ this.size -= result ? 1 : 0;
1324
+ return result;
1325
+ }
1326
+
1327
+ var _hashDelete = hashDelete$1;
1328
+
1329
+ var nativeCreate$2 = _nativeCreate;
1330
+
1331
+ /** Used to stand-in for `undefined` hash values. */
1332
+ var HASH_UNDEFINED$2 = '__lodash_hash_undefined__';
1333
+
1334
+ /** Used for built-in method references. */
1335
+ var objectProto$5 = Object.prototype;
1336
+
1337
+ /** Used to check objects for own properties. */
1338
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
1339
+
1340
+ /**
1341
+ * Gets the hash value for `key`.
1342
+ *
1343
+ * @private
1344
+ * @name get
1345
+ * @memberOf Hash
1346
+ * @param {string} key The key of the value to get.
1347
+ * @returns {*} Returns the entry value.
1348
+ */
1349
+ function hashGet$1(key) {
1350
+ var data = this.__data__;
1351
+ if (nativeCreate$2) {
1352
+ var result = data[key];
1353
+ return result === HASH_UNDEFINED$2 ? undefined : result;
1354
+ }
1355
+ return hasOwnProperty$4.call(data, key) ? data[key] : undefined;
1356
+ }
1357
+
1358
+ var _hashGet = hashGet$1;
1359
+
1360
+ var nativeCreate$1 = _nativeCreate;
1361
+
1362
+ /** Used for built-in method references. */
1363
+ var objectProto$4 = Object.prototype;
1364
+
1365
+ /** Used to check objects for own properties. */
1366
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
1367
+
1368
+ /**
1369
+ * Checks if a hash value for `key` exists.
1370
+ *
1371
+ * @private
1372
+ * @name has
1373
+ * @memberOf Hash
1374
+ * @param {string} key The key of the entry to check.
1375
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1376
+ */
1377
+ function hashHas$1(key) {
1378
+ var data = this.__data__;
1379
+ return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty$3.call(data, key);
1380
+ }
1381
+
1382
+ var _hashHas = hashHas$1;
1383
+
1384
+ var nativeCreate = _nativeCreate;
1385
+
1386
+ /** Used to stand-in for `undefined` hash values. */
1387
+ var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1388
+
1389
+ /**
1390
+ * Sets the hash `key` to `value`.
1391
+ *
1392
+ * @private
1393
+ * @name set
1394
+ * @memberOf Hash
1395
+ * @param {string} key The key of the value to set.
1396
+ * @param {*} value The value to set.
1397
+ * @returns {Object} Returns the hash instance.
1398
+ */
1399
+ function hashSet$1(key, value) {
1400
+ var data = this.__data__;
1401
+ this.size += this.has(key) ? 0 : 1;
1402
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
1403
+ return this;
1404
+ }
1405
+
1406
+ var _hashSet = hashSet$1;
1407
+
1408
+ var hashClear = _hashClear,
1409
+ hashDelete = _hashDelete,
1410
+ hashGet = _hashGet,
1411
+ hashHas = _hashHas,
1412
+ hashSet = _hashSet;
1413
+
1414
+ /**
1415
+ * Creates a hash object.
1416
+ *
1417
+ * @private
1418
+ * @constructor
1419
+ * @param {Array} [entries] The key-value pairs to cache.
1420
+ */
1421
+ function Hash$1(entries) {
1422
+ var index = -1,
1423
+ length = entries == null ? 0 : entries.length;
1424
+
1425
+ this.clear();
1426
+ while (++index < length) {
1427
+ var entry = entries[index];
1428
+ this.set(entry[0], entry[1]);
1429
+ }
1430
+ }
1431
+
1432
+ // Add methods to `Hash`.
1433
+ Hash$1.prototype.clear = hashClear;
1434
+ Hash$1.prototype['delete'] = hashDelete;
1435
+ Hash$1.prototype.get = hashGet;
1436
+ Hash$1.prototype.has = hashHas;
1437
+ Hash$1.prototype.set = hashSet;
1438
+
1439
+ var _Hash = Hash$1;
1440
+
1441
+ var Hash = _Hash,
1442
+ ListCache$2 = _ListCache,
1443
+ Map$1 = _Map;
1444
+
1445
+ /**
1446
+ * Removes all key-value entries from the map.
1447
+ *
1448
+ * @private
1449
+ * @name clear
1450
+ * @memberOf MapCache
1451
+ */
1452
+ function mapCacheClear$1() {
1453
+ this.size = 0;
1454
+ this.__data__ = {
1455
+ 'hash': new Hash,
1456
+ 'map': new (Map$1 || ListCache$2),
1457
+ 'string': new Hash
1458
+ };
1459
+ }
1460
+
1461
+ var _mapCacheClear = mapCacheClear$1;
1462
+
1463
+ /**
1464
+ * Checks if `value` is suitable for use as unique object key.
1465
+ *
1466
+ * @private
1467
+ * @param {*} value The value to check.
1468
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1469
+ */
1470
+
1471
+ function isKeyable$1(value) {
1472
+ var type = typeof value;
1473
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1474
+ ? (value !== '__proto__')
1475
+ : (value === null);
1476
+ }
1477
+
1478
+ var _isKeyable = isKeyable$1;
1479
+
1480
+ var isKeyable = _isKeyable;
1481
+
1482
+ /**
1483
+ * Gets the data for `map`.
1484
+ *
1485
+ * @private
1486
+ * @param {Object} map The map to query.
1487
+ * @param {string} key The reference key.
1488
+ * @returns {*} Returns the map data.
1489
+ */
1490
+ function getMapData$4(map, key) {
1491
+ var data = map.__data__;
1492
+ return isKeyable(key)
1493
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1494
+ : data.map;
1495
+ }
1496
+
1497
+ var _getMapData = getMapData$4;
1498
+
1499
+ var getMapData$3 = _getMapData;
1500
+
1501
+ /**
1502
+ * Removes `key` and its value from the map.
1503
+ *
1504
+ * @private
1505
+ * @name delete
1506
+ * @memberOf MapCache
1507
+ * @param {string} key The key of the value to remove.
1508
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1509
+ */
1510
+ function mapCacheDelete$1(key) {
1511
+ var result = getMapData$3(this, key)['delete'](key);
1512
+ this.size -= result ? 1 : 0;
1513
+ return result;
1514
+ }
1515
+
1516
+ var _mapCacheDelete = mapCacheDelete$1;
1517
+
1518
+ var getMapData$2 = _getMapData;
1519
+
1520
+ /**
1521
+ * Gets the map value for `key`.
1522
+ *
1523
+ * @private
1524
+ * @name get
1525
+ * @memberOf MapCache
1526
+ * @param {string} key The key of the value to get.
1527
+ * @returns {*} Returns the entry value.
1528
+ */
1529
+ function mapCacheGet$1(key) {
1530
+ return getMapData$2(this, key).get(key);
1531
+ }
1532
+
1533
+ var _mapCacheGet = mapCacheGet$1;
1534
+
1535
+ var getMapData$1 = _getMapData;
1536
+
1537
+ /**
1538
+ * Checks if a map value for `key` exists.
1539
+ *
1540
+ * @private
1541
+ * @name has
1542
+ * @memberOf MapCache
1543
+ * @param {string} key The key of the entry to check.
1544
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1545
+ */
1546
+ function mapCacheHas$1(key) {
1547
+ return getMapData$1(this, key).has(key);
1548
+ }
1549
+
1550
+ var _mapCacheHas = mapCacheHas$1;
1551
+
1552
+ var getMapData = _getMapData;
1553
+
1554
+ /**
1555
+ * Sets the map `key` to `value`.
1556
+ *
1557
+ * @private
1558
+ * @name set
1559
+ * @memberOf MapCache
1560
+ * @param {string} key The key of the value to set.
1561
+ * @param {*} value The value to set.
1562
+ * @returns {Object} Returns the map cache instance.
1563
+ */
1564
+ function mapCacheSet$1(key, value) {
1565
+ var data = getMapData(this, key),
1566
+ size = data.size;
1567
+
1568
+ data.set(key, value);
1569
+ this.size += data.size == size ? 0 : 1;
1570
+ return this;
1571
+ }
1572
+
1573
+ var _mapCacheSet = mapCacheSet$1;
1574
+
1575
+ var mapCacheClear = _mapCacheClear,
1576
+ mapCacheDelete = _mapCacheDelete,
1577
+ mapCacheGet = _mapCacheGet,
1578
+ mapCacheHas = _mapCacheHas,
1579
+ mapCacheSet = _mapCacheSet;
1580
+
1581
+ /**
1582
+ * Creates a map cache object to store key-value pairs.
1583
+ *
1584
+ * @private
1585
+ * @constructor
1586
+ * @param {Array} [entries] The key-value pairs to cache.
1587
+ */
1588
+ function MapCache$2(entries) {
1589
+ var index = -1,
1590
+ length = entries == null ? 0 : entries.length;
1591
+
1592
+ this.clear();
1593
+ while (++index < length) {
1594
+ var entry = entries[index];
1595
+ this.set(entry[0], entry[1]);
1596
+ }
1597
+ }
1598
+
1599
+ // Add methods to `MapCache`.
1600
+ MapCache$2.prototype.clear = mapCacheClear;
1601
+ MapCache$2.prototype['delete'] = mapCacheDelete;
1602
+ MapCache$2.prototype.get = mapCacheGet;
1603
+ MapCache$2.prototype.has = mapCacheHas;
1604
+ MapCache$2.prototype.set = mapCacheSet;
1605
+
1606
+ var _MapCache = MapCache$2;
1607
+
1608
+ var ListCache$1 = _ListCache,
1609
+ Map = _Map,
1610
+ MapCache$1 = _MapCache;
1611
+
1612
+ /** Used as the size to enable large array optimizations. */
1613
+ var LARGE_ARRAY_SIZE = 200;
1614
+
1615
+ /**
1616
+ * Sets the stack `key` to `value`.
1617
+ *
1618
+ * @private
1619
+ * @name set
1620
+ * @memberOf Stack
1621
+ * @param {string} key The key of the value to set.
1622
+ * @param {*} value The value to set.
1623
+ * @returns {Object} Returns the stack cache instance.
1624
+ */
1625
+ function stackSet$1(key, value) {
1626
+ var data = this.__data__;
1627
+ if (data instanceof ListCache$1) {
1628
+ var pairs = data.__data__;
1629
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
1630
+ pairs.push([key, value]);
1631
+ this.size = ++data.size;
1632
+ return this;
1633
+ }
1634
+ data = this.__data__ = new MapCache$1(pairs);
1635
+ }
1636
+ data.set(key, value);
1637
+ this.size = data.size;
1638
+ return this;
1639
+ }
1640
+
1641
+ var _stackSet = stackSet$1;
1642
+
1643
+ var ListCache = _ListCache,
1644
+ stackClear = _stackClear,
1645
+ stackDelete = _stackDelete,
1646
+ stackGet = _stackGet,
1647
+ stackHas = _stackHas,
1648
+ stackSet = _stackSet;
1649
+
1650
+ /**
1651
+ * Creates a stack cache object to store key-value pairs.
1652
+ *
1653
+ * @private
1654
+ * @constructor
1655
+ * @param {Array} [entries] The key-value pairs to cache.
1656
+ */
1657
+ function Stack$1(entries) {
1658
+ var data = this.__data__ = new ListCache(entries);
1659
+ this.size = data.size;
1660
+ }
1661
+
1662
+ // Add methods to `Stack`.
1663
+ Stack$1.prototype.clear = stackClear;
1664
+ Stack$1.prototype['delete'] = stackDelete;
1665
+ Stack$1.prototype.get = stackGet;
1666
+ Stack$1.prototype.has = stackHas;
1667
+ Stack$1.prototype.set = stackSet;
1668
+
1669
+ var _Stack = Stack$1;
1670
+
1671
+ /** Used to stand-in for `undefined` hash values. */
1672
+
1673
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
1674
+
1675
+ /**
1676
+ * Adds `value` to the array cache.
1677
+ *
1678
+ * @private
1679
+ * @name add
1680
+ * @memberOf SetCache
1681
+ * @alias push
1682
+ * @param {*} value The value to cache.
1683
+ * @returns {Object} Returns the cache instance.
1684
+ */
1685
+ function setCacheAdd$1(value) {
1686
+ this.__data__.set(value, HASH_UNDEFINED);
1687
+ return this;
1688
+ }
1689
+
1690
+ var _setCacheAdd = setCacheAdd$1;
1691
+
1692
+ /**
1693
+ * Checks if `value` is in the array cache.
1694
+ *
1695
+ * @private
1696
+ * @name has
1697
+ * @memberOf SetCache
1698
+ * @param {*} value The value to search for.
1699
+ * @returns {number} Returns `true` if `value` is found, else `false`.
1700
+ */
1701
+
1702
+ function setCacheHas$1(value) {
1703
+ return this.__data__.has(value);
1704
+ }
1705
+
1706
+ var _setCacheHas = setCacheHas$1;
1707
+
1708
+ var MapCache = _MapCache,
1709
+ setCacheAdd = _setCacheAdd,
1710
+ setCacheHas = _setCacheHas;
1711
+
1712
+ /**
1713
+ *
1714
+ * Creates an array cache object to store unique values.
1715
+ *
1716
+ * @private
1717
+ * @constructor
1718
+ * @param {Array} [values] The values to cache.
1719
+ */
1720
+ function SetCache$1(values) {
1721
+ var index = -1,
1722
+ length = values == null ? 0 : values.length;
1723
+
1724
+ this.__data__ = new MapCache;
1725
+ while (++index < length) {
1726
+ this.add(values[index]);
1727
+ }
1728
+ }
1729
+
1730
+ // Add methods to `SetCache`.
1731
+ SetCache$1.prototype.add = SetCache$1.prototype.push = setCacheAdd;
1732
+ SetCache$1.prototype.has = setCacheHas;
1733
+
1734
+ var _SetCache = SetCache$1;
1735
+
1736
+ /**
1737
+ * A specialized version of `_.some` for arrays without support for iteratee
1738
+ * shorthands.
1739
+ *
1740
+ * @private
1741
+ * @param {Array} [array] The array to iterate over.
1742
+ * @param {Function} predicate The function invoked per iteration.
1743
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
1744
+ * else `false`.
1745
+ */
1746
+
1747
+ function arraySome$1(array, predicate) {
1748
+ var index = -1,
1749
+ length = array == null ? 0 : array.length;
1750
+
1751
+ while (++index < length) {
1752
+ if (predicate(array[index], index, array)) {
1753
+ return true;
1754
+ }
1755
+ }
1756
+ return false;
1757
+ }
1758
+
1759
+ var _arraySome = arraySome$1;
1760
+
1761
+ /**
1762
+ * Checks if a `cache` value for `key` exists.
1763
+ *
1764
+ * @private
1765
+ * @param {Object} cache The cache to query.
1766
+ * @param {string} key The key of the entry to check.
1767
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1768
+ */
1769
+
1770
+ function cacheHas$1(cache, key) {
1771
+ return cache.has(key);
1772
+ }
1773
+
1774
+ var _cacheHas = cacheHas$1;
1775
+
1776
+ var SetCache = _SetCache,
1777
+ arraySome = _arraySome,
1778
+ cacheHas = _cacheHas;
1779
+
1780
+ /** Used to compose bitmasks for value comparisons. */
1781
+ var COMPARE_PARTIAL_FLAG$3 = 1,
1782
+ COMPARE_UNORDERED_FLAG$1 = 2;
1783
+
1784
+ /**
1785
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
1786
+ * partial deep comparisons.
1787
+ *
1788
+ * @private
1789
+ * @param {Array} array The array to compare.
1790
+ * @param {Array} other The other array to compare.
1791
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1792
+ * @param {Function} customizer The function to customize comparisons.
1793
+ * @param {Function} equalFunc The function to determine equivalents of values.
1794
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
1795
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1796
+ */
1797
+ function equalArrays$2(array, other, bitmask, customizer, equalFunc, stack) {
1798
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3,
1799
+ arrLength = array.length,
1800
+ othLength = other.length;
1801
+
1802
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1803
+ return false;
1804
+ }
1805
+ // Check that cyclic values are equal.
1806
+ var arrStacked = stack.get(array);
1807
+ var othStacked = stack.get(other);
1808
+ if (arrStacked && othStacked) {
1809
+ return arrStacked == other && othStacked == array;
1810
+ }
1811
+ var index = -1,
1812
+ result = true,
1813
+ seen = (bitmask & COMPARE_UNORDERED_FLAG$1) ? new SetCache : undefined;
1814
+
1815
+ stack.set(array, other);
1816
+ stack.set(other, array);
1817
+
1818
+ // Ignore non-index properties.
1819
+ while (++index < arrLength) {
1820
+ var arrValue = array[index],
1821
+ othValue = other[index];
1822
+
1823
+ if (customizer) {
1824
+ var compared = isPartial
1825
+ ? customizer(othValue, arrValue, index, other, array, stack)
1826
+ : customizer(arrValue, othValue, index, array, other, stack);
1827
+ }
1828
+ if (compared !== undefined) {
1829
+ if (compared) {
1830
+ continue;
1831
+ }
1832
+ result = false;
1833
+ break;
1834
+ }
1835
+ // Recursively compare arrays (susceptible to call stack limits).
1836
+ if (seen) {
1837
+ if (!arraySome(other, function(othValue, othIndex) {
1838
+ if (!cacheHas(seen, othIndex) &&
1839
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
1840
+ return seen.push(othIndex);
1841
+ }
1842
+ })) {
1843
+ result = false;
1844
+ break;
1845
+ }
1846
+ } else if (!(
1847
+ arrValue === othValue ||
1848
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
1849
+ )) {
1850
+ result = false;
1851
+ break;
1852
+ }
1853
+ }
1854
+ stack['delete'](array);
1855
+ stack['delete'](other);
1856
+ return result;
1857
+ }
1858
+
1859
+ var _equalArrays = equalArrays$2;
1860
+
1861
+ var root = _root;
1862
+
1863
+ /** Built-in value references. */
1864
+ var Uint8Array$1 = root.Uint8Array;
1865
+
1866
+ var _Uint8Array = Uint8Array$1;
1867
+
1868
+ /**
1869
+ * Converts `map` to its key-value pairs.
1870
+ *
1871
+ * @private
1872
+ * @param {Object} map The map to convert.
1873
+ * @returns {Array} Returns the key-value pairs.
1874
+ */
1875
+
1876
+ function mapToArray$1(map) {
1877
+ var index = -1,
1878
+ result = Array(map.size);
1879
+
1880
+ map.forEach(function(value, key) {
1881
+ result[++index] = [key, value];
1882
+ });
1883
+ return result;
1884
+ }
1885
+
1886
+ var _mapToArray = mapToArray$1;
1887
+
1888
+ /**
1889
+ * Converts `set` to an array of its values.
1890
+ *
1891
+ * @private
1892
+ * @param {Object} set The set to convert.
1893
+ * @returns {Array} Returns the values.
1894
+ */
1895
+
1896
+ function setToArray$1(set) {
1897
+ var index = -1,
1898
+ result = Array(set.size);
1899
+
1900
+ set.forEach(function(value) {
1901
+ result[++index] = value;
1902
+ });
1903
+ return result;
1904
+ }
1905
+
1906
+ var _setToArray = setToArray$1;
1907
+
1908
+ var Symbol = _Symbol,
1909
+ Uint8Array = _Uint8Array,
1910
+ eq = eq_1,
1911
+ equalArrays$1 = _equalArrays,
1912
+ mapToArray = _mapToArray,
1913
+ setToArray = _setToArray;
1914
+
1915
+ /** Used to compose bitmasks for value comparisons. */
1916
+ var COMPARE_PARTIAL_FLAG$2 = 1,
1917
+ COMPARE_UNORDERED_FLAG = 2;
1918
+
1919
+ /** `Object#toString` result references. */
1920
+ var boolTag = '[object Boolean]',
1921
+ dateTag = '[object Date]',
1922
+ errorTag = '[object Error]',
1923
+ mapTag = '[object Map]',
1924
+ numberTag = '[object Number]',
1925
+ regexpTag = '[object RegExp]',
1926
+ setTag = '[object Set]',
1927
+ stringTag = '[object String]',
1928
+ symbolTag = '[object Symbol]';
1929
+
1930
+ var arrayBufferTag = '[object ArrayBuffer]',
1931
+ dataViewTag = '[object DataView]';
1932
+
1933
+ /** Used to convert symbols to primitives and strings. */
1934
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
1935
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
1936
+
1937
+ /**
1938
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
1939
+ * the same `toStringTag`.
1940
+ *
1941
+ * **Note:** This function only supports comparing values with tags of
1942
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1943
+ *
1944
+ * @private
1945
+ * @param {Object} object The object to compare.
1946
+ * @param {Object} other The other object to compare.
1947
+ * @param {string} tag The `toStringTag` of the objects to compare.
1948
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1949
+ * @param {Function} customizer The function to customize comparisons.
1950
+ * @param {Function} equalFunc The function to determine equivalents of values.
1951
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
1952
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1953
+ */
1954
+ function equalByTag$1(object, other, tag, bitmask, customizer, equalFunc, stack) {
1955
+ switch (tag) {
1956
+ case dataViewTag:
1957
+ if ((object.byteLength != other.byteLength) ||
1958
+ (object.byteOffset != other.byteOffset)) {
1959
+ return false;
1960
+ }
1961
+ object = object.buffer;
1962
+ other = other.buffer;
1963
+
1964
+ case arrayBufferTag:
1965
+ if ((object.byteLength != other.byteLength) ||
1966
+ !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
1967
+ return false;
1968
+ }
1969
+ return true;
1970
+
1971
+ case boolTag:
1972
+ case dateTag:
1973
+ case numberTag:
1974
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
1975
+ // Invalid dates are coerced to `NaN`.
1976
+ return eq(+object, +other);
1977
+
1978
+ case errorTag:
1979
+ return object.name == other.name && object.message == other.message;
1980
+
1981
+ case regexpTag:
1982
+ case stringTag:
1983
+ // Coerce regexes to strings and treat strings, primitives and objects,
1984
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1985
+ // for more details.
1986
+ return object == (other + '');
1987
+
1988
+ case mapTag:
1989
+ var convert = mapToArray;
1990
+
1991
+ case setTag:
1992
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2;
1993
+ convert || (convert = setToArray);
1994
+
1995
+ if (object.size != other.size && !isPartial) {
1996
+ return false;
1997
+ }
1998
+ // Assume cyclic values are equal.
1999
+ var stacked = stack.get(object);
2000
+ if (stacked) {
2001
+ return stacked == other;
2002
+ }
2003
+ bitmask |= COMPARE_UNORDERED_FLAG;
2004
+
2005
+ // Recursively compare objects (susceptible to call stack limits).
2006
+ stack.set(object, other);
2007
+ var result = equalArrays$1(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
2008
+ stack['delete'](object);
2009
+ return result;
2010
+
2011
+ case symbolTag:
2012
+ if (symbolValueOf) {
2013
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
2014
+ }
2015
+ }
2016
+ return false;
2017
+ }
2018
+
2019
+ var _equalByTag = equalByTag$1;
2020
+
2021
+ /**
2022
+ * Appends the elements of `values` to `array`.
2023
+ *
2024
+ * @private
2025
+ * @param {Array} array The array to modify.
2026
+ * @param {Array} values The values to append.
2027
+ * @returns {Array} Returns `array`.
2028
+ */
2029
+
2030
+ function arrayPush$1(array, values) {
2031
+ var index = -1,
2032
+ length = values.length,
2033
+ offset = array.length;
2034
+
2035
+ while (++index < length) {
2036
+ array[offset + index] = values[index];
2037
+ }
2038
+ return array;
2039
+ }
2040
+
2041
+ var _arrayPush = arrayPush$1;
2042
+
2043
+ var arrayPush = _arrayPush,
2044
+ isArray$2 = isArray_1;
2045
+
2046
+ /**
2047
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
2048
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
2049
+ * symbols of `object`.
2050
+ *
2051
+ * @private
2052
+ * @param {Object} object The object to query.
2053
+ * @param {Function} keysFunc The function to get the keys of `object`.
2054
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
2055
+ * @returns {Array} Returns the array of property names and symbols.
2056
+ */
2057
+ function baseGetAllKeys$1(object, keysFunc, symbolsFunc) {
2058
+ var result = keysFunc(object);
2059
+ return isArray$2(object) ? result : arrayPush(result, symbolsFunc(object));
2060
+ }
2061
+
2062
+ var _baseGetAllKeys = baseGetAllKeys$1;
2063
+
2064
+ /**
2065
+ * A specialized version of `_.filter` for arrays without support for
2066
+ * iteratee shorthands.
2067
+ *
2068
+ * @private
2069
+ * @param {Array} [array] The array to iterate over.
2070
+ * @param {Function} predicate The function invoked per iteration.
2071
+ * @returns {Array} Returns the new filtered array.
2072
+ */
2073
+
2074
+ function arrayFilter$1(array, predicate) {
2075
+ var index = -1,
2076
+ length = array == null ? 0 : array.length,
2077
+ resIndex = 0,
2078
+ result = [];
2079
+
2080
+ while (++index < length) {
2081
+ var value = array[index];
2082
+ if (predicate(value, index, array)) {
2083
+ result[resIndex++] = value;
2084
+ }
2085
+ }
2086
+ return result;
2087
+ }
2088
+
2089
+ var _arrayFilter = arrayFilter$1;
2090
+
2091
+ /**
2092
+ * This method returns a new empty array.
2093
+ *
2094
+ * @static
2095
+ * @memberOf _
2096
+ * @since 4.13.0
2097
+ * @category Util
2098
+ * @returns {Array} Returns the new empty array.
2099
+ * @example
2100
+ *
2101
+ * var arrays = _.times(2, _.stubArray);
2102
+ *
2103
+ * console.log(arrays);
2104
+ * // => [[], []]
2105
+ *
2106
+ * console.log(arrays[0] === arrays[1]);
2107
+ * // => false
2108
+ */
2109
+
2110
+ function stubArray$1() {
2111
+ return [];
2112
+ }
2113
+
2114
+ var stubArray_1 = stubArray$1;
2115
+
2116
+ var arrayFilter = _arrayFilter,
2117
+ stubArray = stubArray_1;
2118
+
2119
+ /** Used for built-in method references. */
2120
+ var objectProto$3 = Object.prototype;
2121
+
2122
+ /** Built-in value references. */
2123
+ var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
2124
+
2125
+ /* Built-in method references for those with the same name as other `lodash` methods. */
2126
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
2127
+
2128
+ /**
2129
+ * Creates an array of the own enumerable symbols of `object`.
2130
+ *
2131
+ * @private
2132
+ * @param {Object} object The object to query.
2133
+ * @returns {Array} Returns the array of symbols.
2134
+ */
2135
+ var getSymbols$1 = !nativeGetSymbols ? stubArray : function(object) {
2136
+ if (object == null) {
2137
+ return [];
2138
+ }
2139
+ object = Object(object);
2140
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
2141
+ return propertyIsEnumerable.call(object, symbol);
2142
+ });
2143
+ };
2144
+
2145
+ var _getSymbols = getSymbols$1;
2146
+
2147
+ /**
2148
+ * The base implementation of `_.times` without support for iteratee shorthands
2149
+ * or max array length checks.
2150
+ *
2151
+ * @private
2152
+ * @param {number} n The number of times to invoke `iteratee`.
2153
+ * @param {Function} iteratee The function invoked per iteration.
2154
+ * @returns {Array} Returns the array of results.
2155
+ */
2156
+
2157
+ function baseTimes$1(n, iteratee) {
2158
+ var index = -1,
2159
+ result = Array(n);
2160
+
2161
+ while (++index < n) {
2162
+ result[index] = iteratee(index);
2163
+ }
2164
+ return result;
2165
+ }
2166
+
2167
+ var _baseTimes = baseTimes$1;
2168
+
2169
+ /** Used as references for various `Number` constants. */
2170
+
2171
+ var MAX_SAFE_INTEGER = 9007199254740991;
2172
+
2173
+ /** Used to detect unsigned integer values. */
2174
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
2175
+
2176
+ /**
2177
+ * Checks if `value` is a valid array-like index.
2178
+ *
2179
+ * @private
2180
+ * @param {*} value The value to check.
2181
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
2182
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
2183
+ */
2184
+ function isIndex$1(value, length) {
2185
+ var type = typeof value;
2186
+ length = length == null ? MAX_SAFE_INTEGER : length;
2187
+
2188
+ return !!length &&
2189
+ (type == 'number' ||
2190
+ (type != 'symbol' && reIsUint.test(value))) &&
2191
+ (value > -1 && value % 1 == 0 && value < length);
2192
+ }
2193
+
2194
+ var _isIndex = isIndex$1;
2195
+
2196
+ var baseTimes = _baseTimes,
2197
+ isArguments = isArguments_1,
2198
+ isArray$1 = isArray_1,
2199
+ isBuffer$1 = isBuffer$3.exports,
2200
+ isIndex = _isIndex,
2201
+ isTypedArray$1 = isTypedArray_1;
2202
+
2203
+ /** Used for built-in method references. */
2204
+ var objectProto$2 = Object.prototype;
2205
+
2206
+ /** Used to check objects for own properties. */
2207
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
2208
+
2209
+ /**
2210
+ * Creates an array of the enumerable property names of the array-like `value`.
2211
+ *
2212
+ * @private
2213
+ * @param {*} value The value to query.
2214
+ * @param {boolean} inherited Specify returning inherited property names.
2215
+ * @returns {Array} Returns the array of property names.
2216
+ */
2217
+ function arrayLikeKeys$1(value, inherited) {
2218
+ var isArr = isArray$1(value),
2219
+ isArg = !isArr && isArguments(value),
2220
+ isBuff = !isArr && !isArg && isBuffer$1(value),
2221
+ isType = !isArr && !isArg && !isBuff && isTypedArray$1(value),
2222
+ skipIndexes = isArr || isArg || isBuff || isType,
2223
+ result = skipIndexes ? baseTimes(value.length, String) : [],
2224
+ length = result.length;
2225
+
2226
+ for (var key in value) {
2227
+ if ((inherited || hasOwnProperty$2.call(value, key)) &&
2228
+ !(skipIndexes && (
2229
+ // Safari 9 has enumerable `arguments.length` in strict mode.
2230
+ key == 'length' ||
2231
+ // Node.js 0.10 has enumerable non-index properties on buffers.
2232
+ (isBuff && (key == 'offset' || key == 'parent')) ||
2233
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
2234
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2235
+ // Skip index properties.
2236
+ isIndex(key, length)
2237
+ ))) {
2238
+ result.push(key);
2239
+ }
2240
+ }
2241
+ return result;
2242
+ }
2243
+
2244
+ var _arrayLikeKeys = arrayLikeKeys$1;
2245
+
2246
+ var arrayLikeKeys = _arrayLikeKeys,
2247
+ baseKeys = _baseKeys,
2248
+ isArrayLike = isArrayLike_1;
2249
+
2250
+ /**
2251
+ * Creates an array of the own enumerable property names of `object`.
2252
+ *
2253
+ * **Note:** Non-object values are coerced to objects. See the
2254
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2255
+ * for more details.
2256
+ *
2257
+ * @static
2258
+ * @since 0.1.0
2259
+ * @memberOf _
2260
+ * @category Object
2261
+ * @param {Object} object The object to query.
2262
+ * @returns {Array} Returns the array of property names.
2263
+ * @example
2264
+ *
2265
+ * function Foo() {
2266
+ * this.a = 1;
2267
+ * this.b = 2;
2268
+ * }
2269
+ *
2270
+ * Foo.prototype.c = 3;
2271
+ *
2272
+ * _.keys(new Foo);
2273
+ * // => ['a', 'b'] (iteration order is not guaranteed)
2274
+ *
2275
+ * _.keys('hi');
2276
+ * // => ['0', '1']
2277
+ */
2278
+ function keys$1(object) {
2279
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
2280
+ }
2281
+
2282
+ var keys_1 = keys$1;
2283
+
2284
+ var baseGetAllKeys = _baseGetAllKeys,
2285
+ getSymbols = _getSymbols,
2286
+ keys = keys_1;
2287
+
2288
+ /**
2289
+ * Creates an array of own enumerable property names and symbols of `object`.
2290
+ *
2291
+ * @private
2292
+ * @param {Object} object The object to query.
2293
+ * @returns {Array} Returns the array of property names and symbols.
2294
+ */
2295
+ function getAllKeys$1(object) {
2296
+ return baseGetAllKeys(object, keys, getSymbols);
2297
+ }
2298
+
2299
+ var _getAllKeys = getAllKeys$1;
2300
+
2301
+ var getAllKeys = _getAllKeys;
2302
+
2303
+ /** Used to compose bitmasks for value comparisons. */
2304
+ var COMPARE_PARTIAL_FLAG$1 = 1;
2305
+
2306
+ /** Used for built-in method references. */
2307
+ var objectProto$1 = Object.prototype;
2308
+
2309
+ /** Used to check objects for own properties. */
2310
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
2311
+
2312
+ /**
2313
+ * A specialized version of `baseIsEqualDeep` for objects with support for
2314
+ * partial deep comparisons.
2315
+ *
2316
+ * @private
2317
+ * @param {Object} object The object to compare.
2318
+ * @param {Object} other The other object to compare.
2319
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2320
+ * @param {Function} customizer The function to customize comparisons.
2321
+ * @param {Function} equalFunc The function to determine equivalents of values.
2322
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
2323
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2324
+ */
2325
+ function equalObjects$1(object, other, bitmask, customizer, equalFunc, stack) {
2326
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1,
2327
+ objProps = getAllKeys(object),
2328
+ objLength = objProps.length,
2329
+ othProps = getAllKeys(other),
2330
+ othLength = othProps.length;
2331
+
2332
+ if (objLength != othLength && !isPartial) {
2333
+ return false;
2334
+ }
2335
+ var index = objLength;
2336
+ while (index--) {
2337
+ var key = objProps[index];
2338
+ if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
2339
+ return false;
2340
+ }
2341
+ }
2342
+ // Check that cyclic values are equal.
2343
+ var objStacked = stack.get(object);
2344
+ var othStacked = stack.get(other);
2345
+ if (objStacked && othStacked) {
2346
+ return objStacked == other && othStacked == object;
2347
+ }
2348
+ var result = true;
2349
+ stack.set(object, other);
2350
+ stack.set(other, object);
2351
+
2352
+ var skipCtor = isPartial;
2353
+ while (++index < objLength) {
2354
+ key = objProps[index];
2355
+ var objValue = object[key],
2356
+ othValue = other[key];
2357
+
2358
+ if (customizer) {
2359
+ var compared = isPartial
2360
+ ? customizer(othValue, objValue, key, other, object, stack)
2361
+ : customizer(objValue, othValue, key, object, other, stack);
2362
+ }
2363
+ // Recursively compare objects (susceptible to call stack limits).
2364
+ if (!(compared === undefined
2365
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
2366
+ : compared
2367
+ )) {
2368
+ result = false;
2369
+ break;
2370
+ }
2371
+ skipCtor || (skipCtor = key == 'constructor');
2372
+ }
2373
+ if (result && !skipCtor) {
2374
+ var objCtor = object.constructor,
2375
+ othCtor = other.constructor;
2376
+
2377
+ // Non `Object` object instances with different constructors are not equal.
2378
+ if (objCtor != othCtor &&
2379
+ ('constructor' in object && 'constructor' in other) &&
2380
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
2381
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
2382
+ result = false;
2383
+ }
2384
+ }
2385
+ stack['delete'](object);
2386
+ stack['delete'](other);
2387
+ return result;
2388
+ }
2389
+
2390
+ var _equalObjects = equalObjects$1;
2391
+
2392
+ var Stack = _Stack,
2393
+ equalArrays = _equalArrays,
2394
+ equalByTag = _equalByTag,
2395
+ equalObjects = _equalObjects,
2396
+ getTag = _getTag,
2397
+ isArray = isArray_1,
2398
+ isBuffer = isBuffer$3.exports,
2399
+ isTypedArray = isTypedArray_1;
2400
+
2401
+ /** Used to compose bitmasks for value comparisons. */
2402
+ var COMPARE_PARTIAL_FLAG = 1;
2403
+
2404
+ /** `Object#toString` result references. */
2405
+ var argsTag = '[object Arguments]',
2406
+ arrayTag = '[object Array]',
2407
+ objectTag = '[object Object]';
2408
+
2409
+ /** Used for built-in method references. */
2410
+ var objectProto = Object.prototype;
2411
+
2412
+ /** Used to check objects for own properties. */
2413
+ var hasOwnProperty = objectProto.hasOwnProperty;
2414
+
2415
+ /**
2416
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
2417
+ * deep comparisons and tracks traversed objects enabling objects with circular
2418
+ * references to be compared.
2419
+ *
2420
+ * @private
2421
+ * @param {Object} object The object to compare.
2422
+ * @param {Object} other The other object to compare.
2423
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
2424
+ * @param {Function} customizer The function to customize comparisons.
2425
+ * @param {Function} equalFunc The function to determine equivalents of values.
2426
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
2427
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
2428
+ */
2429
+ function baseIsEqualDeep$1(object, other, bitmask, customizer, equalFunc, stack) {
2430
+ var objIsArr = isArray(object),
2431
+ othIsArr = isArray(other),
2432
+ objTag = objIsArr ? arrayTag : getTag(object),
2433
+ othTag = othIsArr ? arrayTag : getTag(other);
2434
+
2435
+ objTag = objTag == argsTag ? objectTag : objTag;
2436
+ othTag = othTag == argsTag ? objectTag : othTag;
2437
+
2438
+ var objIsObj = objTag == objectTag,
2439
+ othIsObj = othTag == objectTag,
2440
+ isSameTag = objTag == othTag;
2441
+
2442
+ if (isSameTag && isBuffer(object)) {
2443
+ if (!isBuffer(other)) {
2444
+ return false;
2445
+ }
2446
+ objIsArr = true;
2447
+ objIsObj = false;
2448
+ }
2449
+ if (isSameTag && !objIsObj) {
2450
+ stack || (stack = new Stack);
2451
+ return (objIsArr || isTypedArray(object))
2452
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
2453
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
2454
+ }
2455
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
2456
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
2457
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
2458
+
2459
+ if (objIsWrapped || othIsWrapped) {
2460
+ var objUnwrapped = objIsWrapped ? object.value() : object,
2461
+ othUnwrapped = othIsWrapped ? other.value() : other;
2462
+
2463
+ stack || (stack = new Stack);
2464
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
2465
+ }
2466
+ }
2467
+ if (!isSameTag) {
2468
+ return false;
2469
+ }
2470
+ stack || (stack = new Stack);
2471
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
2472
+ }
2473
+
2474
+ var _baseIsEqualDeep = baseIsEqualDeep$1;
2475
+
2476
+ var baseIsEqualDeep = _baseIsEqualDeep,
2477
+ isObjectLike = isObjectLike_1;
2478
+
2479
+ /**
2480
+ * The base implementation of `_.isEqual` which supports partial comparisons
2481
+ * and tracks traversed objects.
2482
+ *
2483
+ * @private
2484
+ * @param {*} value The value to compare.
2485
+ * @param {*} other The other value to compare.
2486
+ * @param {boolean} bitmask The bitmask flags.
2487
+ * 1 - Unordered comparison
2488
+ * 2 - Partial comparison
2489
+ * @param {Function} [customizer] The function to customize comparisons.
2490
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
2491
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2492
+ */
2493
+ function baseIsEqual$1(value, other, bitmask, customizer, stack) {
2494
+ if (value === other) {
2495
+ return true;
2496
+ }
2497
+ if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
2498
+ return value !== value && other !== other;
2499
+ }
2500
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual$1, stack);
2501
+ }
2502
+
2503
+ var _baseIsEqual = baseIsEqual$1;
2504
+
2505
+ var baseIsEqual = _baseIsEqual;
2506
+
2507
+ /**
2508
+ * Performs a deep comparison between two values to determine if they are
2509
+ * equivalent.
2510
+ *
2511
+ * **Note:** This method supports comparing arrays, array buffers, booleans,
2512
+ * date objects, error objects, maps, numbers, `Object` objects, regexes,
2513
+ * sets, strings, symbols, and typed arrays. `Object` objects are compared
2514
+ * by their own, not inherited, enumerable properties. Functions and DOM
2515
+ * nodes are compared by strict equality, i.e. `===`.
2516
+ *
2517
+ * @static
2518
+ * @memberOf _
2519
+ * @since 0.1.0
2520
+ * @category Lang
2521
+ * @param {*} value The value to compare.
2522
+ * @param {*} other The other value to compare.
2523
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2524
+ * @example
2525
+ *
2526
+ * var object = { 'a': 1 };
2527
+ * var other = { 'a': 1 };
2528
+ *
2529
+ * _.isEqual(object, other);
2530
+ * // => true
2531
+ *
2532
+ * object === other;
2533
+ * // => false
2534
+ */
2535
+ function isEqual(value, other) {
2536
+ return baseIsEqual(value, other);
2537
+ }
2538
+
2539
+ var isEqual_1 = isEqual;
2540
+
2541
+ const getCorrectResponse = choices => choices.filter(c => c.correct).map(c => c.value).sort();
2542
+ const isResponseCorrect = (question, session) => {
2543
+ let correctResponse = getCorrectResponse(question.choices);
2544
+ return session && isEqual_1((session.value || []).sort(), correctResponse);
2545
+ };
2546
+
2547
+ var defaults = {
2548
+ choiceMode: 'checkbox',
2549
+ choicePrefix: 'letters',
2550
+ choices: [],
2551
+ choicesLayout: 'vertical',
2552
+ feedbackEnabled: false,
2553
+ gridColumns: 2,
2554
+ lockChoiceOrder: true,
2555
+ partialScoring: true,
2556
+ prompt: '',
2557
+ promptEnabled: true,
2558
+ rationale: '',
2559
+ rationaleEnabled: true,
2560
+ scoringType: 'auto',
2561
+ studentInstructionsEnabled: true,
2562
+ teacherInstructions: '',
2563
+ teacherInstructionsEnabled: true,
2564
+ toolbarEditorPosition: 'bottom',
2565
+ selectedAnswerBackgroundColor: 'initial',
2566
+ selectedAnswerStrokeColor: 'initial',
2567
+ selectedAnswerStrokeWidth: 'initial',
2568
+ hoverAnswerBackgroundColor: 'initial',
2569
+ hoverAnswerStrokeColor: 'initial',
2570
+ hoverAnswerStrokeWidth: 'initial',
2571
+ keyboardEventsEnabled: false
2572
+ };
2573
+
2574
+ const _excluded = ["verticalMode", "choicesLayout"];
2575
+
2576
+ const prepareChoice = (model, env, defaultFeedback) => choice => {
2577
+ const {
2578
+ role,
2579
+ mode
2580
+ } = env || {};
2581
+ const out = {
2582
+ label: choice.label,
2583
+ value: choice.value
2584
+ };
2585
+
2586
+ if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
2587
+ out.rationale = model.rationaleEnabled ? choice.rationale : null;
2588
+ } else {
2589
+ out.rationale = null;
2590
+ }
2591
+
2592
+ if (mode === 'evaluate') {
2593
+ out.correct = !!choice.correct;
2594
+
2595
+ if (model.feedbackEnabled) {
2596
+ const feedbackType = choice.feedback && choice.feedback.type || 'none';
2597
+
2598
+ if (feedbackType === 'default') {
2599
+ out.feedback = defaultFeedback[choice.correct ? 'correct' : 'incorrect'];
2600
+ } else if (feedbackType === 'custom') {
2601
+ out.feedback = choice.feedback.value;
2602
+ }
2603
+ }
2604
+ }
2605
+
2606
+ return out;
2607
+ };
2608
+
2609
+ function createDefaultModel(model = {}) {
2610
+ return new Promise(resolve => resolve(_extends({}, defaults, model)));
2611
+ }
2612
+ const normalize = question => {
2613
+ const _ref = question || {},
2614
+ {
2615
+ verticalMode,
2616
+ choicesLayout
2617
+ } = _ref,
2618
+ questionProps = _objectWithoutPropertiesLoose(_ref, _excluded);
2619
+
2620
+ return _extends({}, defaults, questionProps, {
2621
+ // This is used for offering support for old models which have the property verticalMode
2622
+ // Same thing is set in authoring : packages/multiple-choice/configure/src/index.jsx - createDefaultModel
2623
+ choicesLayout: choicesLayout || verticalMode === false && 'horizontal' || defaults.choicesLayout
2624
+ });
2625
+ };
2626
+ /**
2627
+ *
2628
+ * @param {*} question
2629
+ * @param {*} session
2630
+ * @param {*} env
2631
+ * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
2632
+ */
2633
+
2634
+ async function model(question, session, env, updateSession) {
2635
+ const normalizedQuestion = normalize(question);
2636
+ const defaultFeedback = Object.assign({
2637
+ correct: 'Correct',
2638
+ incorrect: 'Incorrect'
2639
+ }, normalizedQuestion.defaultFeedback);
2640
+ let choices = (normalizedQuestion.choices || []).map(prepareChoice(normalizedQuestion, env, defaultFeedback));
2641
+ const lockChoiceOrder = lockChoices(normalizedQuestion, session, env);
2642
+
2643
+ if (!lockChoiceOrder) {
2644
+ choices = await getShuffledChoices(choices, session, updateSession, 'value');
2645
+ }
2646
+
2647
+ const out = {
2648
+ disabled: env.mode !== 'gather',
2649
+ mode: env.mode,
2650
+ prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
2651
+ choicesLayout: normalizedQuestion.choicesLayout,
2652
+ gridColumns: normalizedQuestion.gridColumns,
2653
+ choiceMode: normalizedQuestion.choiceMode,
2654
+ keyMode: normalizedQuestion.choicePrefix,
2655
+ choices,
2656
+ responseCorrect: env.mode === 'evaluate' ? isResponseCorrect(normalizedQuestion, session) : undefined,
2657
+ language: normalizedQuestion.language,
2658
+ extraCSSRules: normalizedQuestion.extraCSSRules,
2659
+ fontSizeFactor: normalizedQuestion.fontSizeFactor,
2660
+ isSelectionButtonBelow: normalizedQuestion.isSelectionButtonBelow,
2661
+ selectedAnswerBackgroundColor: normalizedQuestion.selectedAnswerBackgroundColor || 'initial',
2662
+ selectedAnswerStrokeColor: normalizedQuestion.selectedAnswerStrokeColor || 'initial',
2663
+ selectedAnswerStrokeWidth: normalizedQuestion.selectedAnswerStrokeWidth || 'initial',
2664
+ hoverAnswerBackgroundColor: normalizedQuestion.hoverAnswerBackgroundColor || 'initial',
2665
+ hoverAnswerStrokeColor: normalizedQuestion.hoverAnswerStrokeColor || 'initial',
2666
+ hoverAnswerStrokeWidth: normalizedQuestion.hoverAnswerStrokeWidth || 'initial',
2667
+ minSelections: normalizedQuestion.minSelections,
2668
+ maxSelections: normalizedQuestion.maxSelections,
2669
+ keyboardEventsEnabled: normalizedQuestion.keyboardEventsEnabled,
2670
+ autoplayAudioEnabled: normalizedQuestion.autoplayAudioEnabled,
2671
+ completeAudioEnabled: normalizedQuestion.completeAudioEnabled,
2672
+ customAudioButton: normalizedQuestion.customAudioButton
2673
+ };
2674
+ const {
2675
+ role,
2676
+ mode
2677
+ } = env || {};
2678
+
2679
+ if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
2680
+ out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
2681
+ } else {
2682
+ out.teacherInstructions = null;
2683
+ }
2684
+
2685
+ return out;
2686
+ }
2687
+ const getScore = (config, session) => {
2688
+ if (!session || isEmpty_1(session)) {
2689
+ return 0;
2690
+ }
2691
+
2692
+ const selectedChoices = session.value || [];
2693
+ const correctChoices = (config.choices || []).filter(ch => ch.correct);
2694
+ let score = selectedChoices.reduce((acc, selectedChoice) => acc + (correctChoices.find(ch => ch.value === selectedChoice) ? 1 : 0), 0);
2695
+
2696
+ if (correctChoices.length < selectedChoices.length) {
2697
+ score -= selectedChoices.length - correctChoices.length;
2698
+
2699
+ if (score < 0) {
2700
+ score = 0;
2701
+ }
2702
+ }
2703
+
2704
+ const str = correctChoices.length ? score / correctChoices.length : 0;
2705
+ return parseFloat(str.toFixed(2));
2706
+ };
2707
+ /**
2708
+ *
2709
+ * The score is partial by default for checkbox mode, allOrNothing for radio mode.
2710
+ * To disable partial scoring for checkbox mode you either set model.partialScoring = false or env.partialScoring = false. the value in `env` will
2711
+ * override the value in `model`.
2712
+ * @param {Object} model - the main model
2713
+ * @param {*} session
2714
+ * @param {Object} env
2715
+ */
2716
+
2717
+ function outcome(model, session, env) {
2718
+ return new Promise(resolve => {
2719
+ if (!session || isEmpty_1(session)) {
2720
+ resolve({
2721
+ score: 0,
2722
+ empty: true
2723
+ });
2724
+ } else {
2725
+ const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';
2726
+ const score = getScore(model, session);
2727
+ resolve({
2728
+ score: partialScoringEnabled ? score : score === 1 ? 1 : 0,
2729
+ empty: false
2730
+ });
2731
+ }
2732
+ });
2733
+ }
2734
+ const createCorrectResponseSession = (question, env) => {
2735
+ return new Promise(resolve => {
2736
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
2737
+ const {
2738
+ choices
2739
+ } = question || {
2740
+ choices: []
2741
+ };
2742
+ resolve({
2743
+ id: '1',
2744
+ value: choices.filter(c => c.correct).map(c => c.value)
2745
+ });
2746
+ } else {
2747
+ resolve(null);
2748
+ }
2749
+ });
2750
+ }; // remove all html tags
2751
+
2752
+
2753
+ const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
2754
+
2755
+ const validate = (model = {}, config = {}) => {
2756
+ const {
2757
+ choices
2758
+ } = model;
2759
+ const {
2760
+ minAnswerChoices = 2,
2761
+ maxAnswerChoices
2762
+ } = config;
2763
+ const reversedChoices = [...(choices || [])].reverse();
2764
+ const choicesErrors = {};
2765
+ const rationaleErrors = {};
2766
+ const errors = {};
2767
+ ['teacherInstructions', 'prompt'].forEach(field => {
2768
+ var _config$field;
2769
+
2770
+ if ((_config$field = config[field]) != null && _config$field.required && !getContent(model[field])) {
2771
+ errors[field] = 'This field is required.';
2772
+ }
2773
+ });
2774
+ let hasCorrectResponse = false;
2775
+ reversedChoices.forEach((choice, index) => {
2776
+ var _config$rationale;
2777
+
2778
+ const {
2779
+ correct,
2780
+ value,
2781
+ label,
2782
+ rationale
2783
+ } = choice;
2784
+
2785
+ if (correct) {
2786
+ hasCorrectResponse = true;
2787
+ }
2788
+
2789
+ if (!getContent(label)) {
2790
+ choicesErrors[value] = 'Content should not be empty.';
2791
+ } else {
2792
+ const identicalAnswer = reversedChoices.slice(index + 1).some(c => c.label === label);
2793
+
2794
+ if (identicalAnswer) {
2795
+ choicesErrors[value] = 'Content should be unique.';
2796
+ }
2797
+ }
2798
+
2799
+ if ((_config$rationale = config.rationale) != null && _config$rationale.required && !getContent(rationale)) {
2800
+ rationaleErrors[value] = 'This field is required.';
2801
+ }
2802
+ });
2803
+ const nbOfChoices = (choices || []).length;
2804
+
2805
+ if (nbOfChoices < minAnswerChoices) {
2806
+ errors.answerChoices = `There should be at least ${minAnswerChoices} choices defined.`;
2807
+ } else if (nbOfChoices > maxAnswerChoices) {
2808
+ errors.answerChoices = `No more than ${maxAnswerChoices} choices should be defined.`;
2809
+ }
2810
+
2811
+ if (!hasCorrectResponse) {
2812
+ errors.correctResponse = 'No correct response defined.';
2813
+ }
2814
+
2815
+ if (!isEmpty_1(choicesErrors)) {
2816
+ errors.choices = choicesErrors;
2817
+ }
2818
+
2819
+ if (!isEmpty_1(rationaleErrors)) {
2820
+ errors.rationale = rationaleErrors;
2821
+ }
2822
+
2823
+ return errors;
2824
+ };
2825
+
2826
+ export { createCorrectResponseSession, createDefaultModel, getScore, model, normalize, outcome, validate };
2827
+ //# sourceMappingURL=controller.js.map