@pie-element/match-list 5.3.3 → 5.3.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,1790 @@
1
+ import { getFeedbackForCorrectness } from '@pie-lib/feedback';
2
+ import { lockChoices, getShuffledChoices, partialScoring } from '@pie-lib/controller-utils';
3
+
4
+ function _extends() {
5
+ _extends = Object.assign || function (target) {
6
+ for (var i = 1; i < arguments.length; i++) {
7
+ var source = arguments[i];
8
+
9
+ for (var key in source) {
10
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
11
+ target[key] = source[key];
12
+ }
13
+ }
14
+ }
15
+
16
+ return target;
17
+ };
18
+
19
+ return _extends.apply(this, arguments);
20
+ }
21
+
22
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
23
+
24
+ /** Used for built-in method references. */
25
+
26
+ var objectProto$6 = Object.prototype;
27
+
28
+ /**
29
+ * Checks if `value` is likely a prototype object.
30
+ *
31
+ * @private
32
+ * @param {*} value The value to check.
33
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
34
+ */
35
+ function isPrototype$2(value) {
36
+ var Ctor = value && value.constructor,
37
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
38
+
39
+ return value === proto;
40
+ }
41
+
42
+ var _isPrototype = isPrototype$2;
43
+
44
+ /**
45
+ * Creates a unary function that invokes `func` with its argument transformed.
46
+ *
47
+ * @private
48
+ * @param {Function} func The function to wrap.
49
+ * @param {Function} transform The argument transform.
50
+ * @returns {Function} Returns the new function.
51
+ */
52
+
53
+ function overArg$1(func, transform) {
54
+ return function(arg) {
55
+ return func(transform(arg));
56
+ };
57
+ }
58
+
59
+ var _overArg = overArg$1;
60
+
61
+ var overArg = _overArg;
62
+
63
+ /* Built-in method references for those with the same name as other `lodash` methods. */
64
+ var nativeKeys$1 = overArg(Object.keys, Object);
65
+
66
+ var _nativeKeys = nativeKeys$1;
67
+
68
+ var isPrototype$1 = _isPrototype,
69
+ nativeKeys = _nativeKeys;
70
+
71
+ /** Used for built-in method references. */
72
+ var objectProto$5 = Object.prototype;
73
+
74
+ /** Used to check objects for own properties. */
75
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
76
+
77
+ /**
78
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
79
+ *
80
+ * @private
81
+ * @param {Object} object The object to query.
82
+ * @returns {Array} Returns the array of property names.
83
+ */
84
+ function baseKeys$1(object) {
85
+ if (!isPrototype$1(object)) {
86
+ return nativeKeys(object);
87
+ }
88
+ var result = [];
89
+ for (var key in Object(object)) {
90
+ if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
91
+ result.push(key);
92
+ }
93
+ }
94
+ return result;
95
+ }
96
+
97
+ var _baseKeys = baseKeys$1;
98
+
99
+ /** Detect free variable `global` from Node.js. */
100
+
101
+ var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
102
+
103
+ var _freeGlobal = freeGlobal$1;
104
+
105
+ var freeGlobal = _freeGlobal;
106
+
107
+ /** Detect free variable `self`. */
108
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
109
+
110
+ /** Used as a reference to the global object. */
111
+ var root$7 = freeGlobal || freeSelf || Function('return this')();
112
+
113
+ var _root = root$7;
114
+
115
+ var root$6 = _root;
116
+
117
+ /** Built-in value references. */
118
+ var Symbol$3 = root$6.Symbol;
119
+
120
+ var _Symbol = Symbol$3;
121
+
122
+ var Symbol$2 = _Symbol;
123
+
124
+ /** Used for built-in method references. */
125
+ var objectProto$4 = Object.prototype;
126
+
127
+ /** Used to check objects for own properties. */
128
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
129
+
130
+ /**
131
+ * Used to resolve the
132
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
133
+ * of values.
134
+ */
135
+ var nativeObjectToString$1 = objectProto$4.toString;
136
+
137
+ /** Built-in value references. */
138
+ var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
139
+
140
+ /**
141
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
142
+ *
143
+ * @private
144
+ * @param {*} value The value to query.
145
+ * @returns {string} Returns the raw `toStringTag`.
146
+ */
147
+ function getRawTag$1(value) {
148
+ var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
149
+ tag = value[symToStringTag$1];
150
+
151
+ try {
152
+ value[symToStringTag$1] = undefined;
153
+ var unmasked = true;
154
+ } catch (e) {}
155
+
156
+ var result = nativeObjectToString$1.call(value);
157
+ if (unmasked) {
158
+ if (isOwn) {
159
+ value[symToStringTag$1] = tag;
160
+ } else {
161
+ delete value[symToStringTag$1];
162
+ }
163
+ }
164
+ return result;
165
+ }
166
+
167
+ var _getRawTag = getRawTag$1;
168
+
169
+ /** Used for built-in method references. */
170
+
171
+ var objectProto$3 = Object.prototype;
172
+
173
+ /**
174
+ * Used to resolve the
175
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
176
+ * of values.
177
+ */
178
+ var nativeObjectToString = objectProto$3.toString;
179
+
180
+ /**
181
+ * Converts `value` to a string using `Object.prototype.toString`.
182
+ *
183
+ * @private
184
+ * @param {*} value The value to convert.
185
+ * @returns {string} Returns the converted string.
186
+ */
187
+ function objectToString$1(value) {
188
+ return nativeObjectToString.call(value);
189
+ }
190
+
191
+ var _objectToString = objectToString$1;
192
+
193
+ var Symbol$1 = _Symbol,
194
+ getRawTag = _getRawTag,
195
+ objectToString = _objectToString;
196
+
197
+ /** `Object#toString` result references. */
198
+ var nullTag = '[object Null]',
199
+ undefinedTag = '[object Undefined]';
200
+
201
+ /** Built-in value references. */
202
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
203
+
204
+ /**
205
+ * The base implementation of `getTag` without fallbacks for buggy environments.
206
+ *
207
+ * @private
208
+ * @param {*} value The value to query.
209
+ * @returns {string} Returns the `toStringTag`.
210
+ */
211
+ function baseGetTag$4(value) {
212
+ if (value == null) {
213
+ return value === undefined ? undefinedTag : nullTag;
214
+ }
215
+ return (symToStringTag && symToStringTag in Object(value))
216
+ ? getRawTag(value)
217
+ : objectToString(value);
218
+ }
219
+
220
+ var _baseGetTag = baseGetTag$4;
221
+
222
+ /**
223
+ * Checks if `value` is the
224
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
225
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
226
+ *
227
+ * @static
228
+ * @memberOf _
229
+ * @since 0.1.0
230
+ * @category Lang
231
+ * @param {*} value The value to check.
232
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
233
+ * @example
234
+ *
235
+ * _.isObject({});
236
+ * // => true
237
+ *
238
+ * _.isObject([1, 2, 3]);
239
+ * // => true
240
+ *
241
+ * _.isObject(_.noop);
242
+ * // => true
243
+ *
244
+ * _.isObject(null);
245
+ * // => false
246
+ */
247
+
248
+ function isObject$2(value) {
249
+ var type = typeof value;
250
+ return value != null && (type == 'object' || type == 'function');
251
+ }
252
+
253
+ var isObject_1 = isObject$2;
254
+
255
+ var baseGetTag$3 = _baseGetTag,
256
+ isObject$1 = isObject_1;
257
+
258
+ /** `Object#toString` result references. */
259
+ var asyncTag = '[object AsyncFunction]',
260
+ funcTag$1 = '[object Function]',
261
+ genTag = '[object GeneratorFunction]',
262
+ proxyTag = '[object Proxy]';
263
+
264
+ /**
265
+ * Checks if `value` is classified as a `Function` object.
266
+ *
267
+ * @static
268
+ * @memberOf _
269
+ * @since 0.1.0
270
+ * @category Lang
271
+ * @param {*} value The value to check.
272
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
273
+ * @example
274
+ *
275
+ * _.isFunction(_);
276
+ * // => true
277
+ *
278
+ * _.isFunction(/abc/);
279
+ * // => false
280
+ */
281
+ function isFunction$2(value) {
282
+ if (!isObject$1(value)) {
283
+ return false;
284
+ }
285
+ // The use of `Object#toString` avoids issues with the `typeof` operator
286
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
287
+ var tag = baseGetTag$3(value);
288
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
289
+ }
290
+
291
+ var isFunction_1 = isFunction$2;
292
+
293
+ var root$5 = _root;
294
+
295
+ /** Used to detect overreaching core-js shims. */
296
+ var coreJsData$1 = root$5['__core-js_shared__'];
297
+
298
+ var _coreJsData = coreJsData$1;
299
+
300
+ var coreJsData = _coreJsData;
301
+
302
+ /** Used to detect methods masquerading as native. */
303
+ var maskSrcKey = (function() {
304
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
305
+ return uid ? ('Symbol(src)_1.' + uid) : '';
306
+ }());
307
+
308
+ /**
309
+ * Checks if `func` has its source masked.
310
+ *
311
+ * @private
312
+ * @param {Function} func The function to check.
313
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
314
+ */
315
+ function isMasked$1(func) {
316
+ return !!maskSrcKey && (maskSrcKey in func);
317
+ }
318
+
319
+ var _isMasked = isMasked$1;
320
+
321
+ /** Used for built-in method references. */
322
+
323
+ var funcProto$1 = Function.prototype;
324
+
325
+ /** Used to resolve the decompiled source of functions. */
326
+ var funcToString$1 = funcProto$1.toString;
327
+
328
+ /**
329
+ * Converts `func` to its source code.
330
+ *
331
+ * @private
332
+ * @param {Function} func The function to convert.
333
+ * @returns {string} Returns the source code.
334
+ */
335
+ function toSource$2(func) {
336
+ if (func != null) {
337
+ try {
338
+ return funcToString$1.call(func);
339
+ } catch (e) {}
340
+ try {
341
+ return (func + '');
342
+ } catch (e) {}
343
+ }
344
+ return '';
345
+ }
346
+
347
+ var _toSource = toSource$2;
348
+
349
+ var isFunction$1 = isFunction_1,
350
+ isMasked = _isMasked,
351
+ isObject = isObject_1,
352
+ toSource$1 = _toSource;
353
+
354
+ /**
355
+ * Used to match `RegExp`
356
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
357
+ */
358
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
359
+
360
+ /** Used to detect host constructors (Safari). */
361
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
362
+
363
+ /** Used for built-in method references. */
364
+ var funcProto = Function.prototype,
365
+ objectProto$2 = Object.prototype;
366
+
367
+ /** Used to resolve the decompiled source of functions. */
368
+ var funcToString = funcProto.toString;
369
+
370
+ /** Used to check objects for own properties. */
371
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
372
+
373
+ /** Used to detect if a method is native. */
374
+ var reIsNative = RegExp('^' +
375
+ funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
376
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
377
+ );
378
+
379
+ /**
380
+ * The base implementation of `_.isNative` without bad shim checks.
381
+ *
382
+ * @private
383
+ * @param {*} value The value to check.
384
+ * @returns {boolean} Returns `true` if `value` is a native function,
385
+ * else `false`.
386
+ */
387
+ function baseIsNative$1(value) {
388
+ if (!isObject(value) || isMasked(value)) {
389
+ return false;
390
+ }
391
+ var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
392
+ return pattern.test(toSource$1(value));
393
+ }
394
+
395
+ var _baseIsNative = baseIsNative$1;
396
+
397
+ /**
398
+ * Gets the value at `key` of `object`.
399
+ *
400
+ * @private
401
+ * @param {Object} [object] The object to query.
402
+ * @param {string} key The key of the property to get.
403
+ * @returns {*} Returns the property value.
404
+ */
405
+
406
+ function getValue$1(object, key) {
407
+ return object == null ? undefined : object[key];
408
+ }
409
+
410
+ var _getValue = getValue$1;
411
+
412
+ var baseIsNative = _baseIsNative,
413
+ getValue = _getValue;
414
+
415
+ /**
416
+ * Gets the native function at `key` of `object`.
417
+ *
418
+ * @private
419
+ * @param {Object} object The object to query.
420
+ * @param {string} key The key of the method to get.
421
+ * @returns {*} Returns the function if it's native, else `undefined`.
422
+ */
423
+ function getNative$5(object, key) {
424
+ var value = getValue(object, key);
425
+ return baseIsNative(value) ? value : undefined;
426
+ }
427
+
428
+ var _getNative = getNative$5;
429
+
430
+ var getNative$4 = _getNative,
431
+ root$4 = _root;
432
+
433
+ /* Built-in method references that are verified to be native. */
434
+ var DataView$1 = getNative$4(root$4, 'DataView');
435
+
436
+ var _DataView = DataView$1;
437
+
438
+ var getNative$3 = _getNative,
439
+ root$3 = _root;
440
+
441
+ /* Built-in method references that are verified to be native. */
442
+ var Map$1 = getNative$3(root$3, 'Map');
443
+
444
+ var _Map = Map$1;
445
+
446
+ var getNative$2 = _getNative,
447
+ root$2 = _root;
448
+
449
+ /* Built-in method references that are verified to be native. */
450
+ var Promise$2 = getNative$2(root$2, 'Promise');
451
+
452
+ var _Promise = Promise$2;
453
+
454
+ var getNative$1 = _getNative,
455
+ root$1 = _root;
456
+
457
+ /* Built-in method references that are verified to be native. */
458
+ var Set$1 = getNative$1(root$1, 'Set');
459
+
460
+ var _Set = Set$1;
461
+
462
+ var getNative = _getNative,
463
+ root = _root;
464
+
465
+ /* Built-in method references that are verified to be native. */
466
+ var WeakMap$1 = getNative(root, 'WeakMap');
467
+
468
+ var _WeakMap = WeakMap$1;
469
+
470
+ var DataView = _DataView,
471
+ Map = _Map,
472
+ Promise$1 = _Promise,
473
+ Set = _Set,
474
+ WeakMap = _WeakMap,
475
+ baseGetTag$2 = _baseGetTag,
476
+ toSource = _toSource;
477
+
478
+ /** `Object#toString` result references. */
479
+ var mapTag$2 = '[object Map]',
480
+ objectTag$1 = '[object Object]',
481
+ promiseTag = '[object Promise]',
482
+ setTag$2 = '[object Set]',
483
+ weakMapTag$1 = '[object WeakMap]';
484
+
485
+ var dataViewTag$1 = '[object DataView]';
486
+
487
+ /** Used to detect maps, sets, and weakmaps. */
488
+ var dataViewCtorString = toSource(DataView),
489
+ mapCtorString = toSource(Map),
490
+ promiseCtorString = toSource(Promise$1),
491
+ setCtorString = toSource(Set),
492
+ weakMapCtorString = toSource(WeakMap);
493
+
494
+ /**
495
+ * Gets the `toStringTag` of `value`.
496
+ *
497
+ * @private
498
+ * @param {*} value The value to query.
499
+ * @returns {string} Returns the `toStringTag`.
500
+ */
501
+ var getTag$1 = baseGetTag$2;
502
+
503
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
504
+ if ((DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
505
+ (Map && getTag$1(new Map) != mapTag$2) ||
506
+ (Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag) ||
507
+ (Set && getTag$1(new Set) != setTag$2) ||
508
+ (WeakMap && getTag$1(new WeakMap) != weakMapTag$1)) {
509
+ getTag$1 = function(value) {
510
+ var result = baseGetTag$2(value),
511
+ Ctor = result == objectTag$1 ? value.constructor : undefined,
512
+ ctorString = Ctor ? toSource(Ctor) : '';
513
+
514
+ if (ctorString) {
515
+ switch (ctorString) {
516
+ case dataViewCtorString: return dataViewTag$1;
517
+ case mapCtorString: return mapTag$2;
518
+ case promiseCtorString: return promiseTag;
519
+ case setCtorString: return setTag$2;
520
+ case weakMapCtorString: return weakMapTag$1;
521
+ }
522
+ }
523
+ return result;
524
+ };
525
+ }
526
+
527
+ var _getTag = getTag$1;
528
+
529
+ /**
530
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
531
+ * and has a `typeof` result of "object".
532
+ *
533
+ * @static
534
+ * @memberOf _
535
+ * @since 4.0.0
536
+ * @category Lang
537
+ * @param {*} value The value to check.
538
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
539
+ * @example
540
+ *
541
+ * _.isObjectLike({});
542
+ * // => true
543
+ *
544
+ * _.isObjectLike([1, 2, 3]);
545
+ * // => true
546
+ *
547
+ * _.isObjectLike(_.noop);
548
+ * // => false
549
+ *
550
+ * _.isObjectLike(null);
551
+ * // => false
552
+ */
553
+
554
+ function isObjectLike$3(value) {
555
+ return value != null && typeof value == 'object';
556
+ }
557
+
558
+ var isObjectLike_1 = isObjectLike$3;
559
+
560
+ var baseGetTag$1 = _baseGetTag,
561
+ isObjectLike$2 = isObjectLike_1;
562
+
563
+ /** `Object#toString` result references. */
564
+ var argsTag$1 = '[object Arguments]';
565
+
566
+ /**
567
+ * The base implementation of `_.isArguments`.
568
+ *
569
+ * @private
570
+ * @param {*} value The value to check.
571
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
572
+ */
573
+ function baseIsArguments$1(value) {
574
+ return isObjectLike$2(value) && baseGetTag$1(value) == argsTag$1;
575
+ }
576
+
577
+ var _baseIsArguments = baseIsArguments$1;
578
+
579
+ var baseIsArguments = _baseIsArguments,
580
+ isObjectLike$1 = isObjectLike_1;
581
+
582
+ /** Used for built-in method references. */
583
+ var objectProto$1 = Object.prototype;
584
+
585
+ /** Used to check objects for own properties. */
586
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
587
+
588
+ /** Built-in value references. */
589
+ var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
590
+
591
+ /**
592
+ * Checks if `value` is likely an `arguments` object.
593
+ *
594
+ * @static
595
+ * @memberOf _
596
+ * @since 0.1.0
597
+ * @category Lang
598
+ * @param {*} value The value to check.
599
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
600
+ * else `false`.
601
+ * @example
602
+ *
603
+ * _.isArguments(function() { return arguments; }());
604
+ * // => true
605
+ *
606
+ * _.isArguments([1, 2, 3]);
607
+ * // => false
608
+ */
609
+ var isArguments$1 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
610
+ return isObjectLike$1(value) && hasOwnProperty$1.call(value, 'callee') &&
611
+ !propertyIsEnumerable.call(value, 'callee');
612
+ };
613
+
614
+ var isArguments_1 = isArguments$1;
615
+
616
+ /**
617
+ * Checks if `value` is classified as an `Array` object.
618
+ *
619
+ * @static
620
+ * @memberOf _
621
+ * @since 0.1.0
622
+ * @category Lang
623
+ * @param {*} value The value to check.
624
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
625
+ * @example
626
+ *
627
+ * _.isArray([1, 2, 3]);
628
+ * // => true
629
+ *
630
+ * _.isArray(document.body.children);
631
+ * // => false
632
+ *
633
+ * _.isArray('abc');
634
+ * // => false
635
+ *
636
+ * _.isArray(_.noop);
637
+ * // => false
638
+ */
639
+
640
+ var isArray$1 = Array.isArray;
641
+
642
+ var isArray_1 = isArray$1;
643
+
644
+ /** Used as references for various `Number` constants. */
645
+
646
+ var MAX_SAFE_INTEGER = 9007199254740991;
647
+
648
+ /**
649
+ * Checks if `value` is a valid array-like length.
650
+ *
651
+ * **Note:** This method is loosely based on
652
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
653
+ *
654
+ * @static
655
+ * @memberOf _
656
+ * @since 4.0.0
657
+ * @category Lang
658
+ * @param {*} value The value to check.
659
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
660
+ * @example
661
+ *
662
+ * _.isLength(3);
663
+ * // => true
664
+ *
665
+ * _.isLength(Number.MIN_VALUE);
666
+ * // => false
667
+ *
668
+ * _.isLength(Infinity);
669
+ * // => false
670
+ *
671
+ * _.isLength('3');
672
+ * // => false
673
+ */
674
+ function isLength$2(value) {
675
+ return typeof value == 'number' &&
676
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
677
+ }
678
+
679
+ var isLength_1 = isLength$2;
680
+
681
+ var isFunction = isFunction_1,
682
+ isLength$1 = isLength_1;
683
+
684
+ /**
685
+ * Checks if `value` is array-like. A value is considered array-like if it's
686
+ * not a function and has a `value.length` that's an integer greater than or
687
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
688
+ *
689
+ * @static
690
+ * @memberOf _
691
+ * @since 4.0.0
692
+ * @category Lang
693
+ * @param {*} value The value to check.
694
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
695
+ * @example
696
+ *
697
+ * _.isArrayLike([1, 2, 3]);
698
+ * // => true
699
+ *
700
+ * _.isArrayLike(document.body.children);
701
+ * // => true
702
+ *
703
+ * _.isArrayLike('abc');
704
+ * // => true
705
+ *
706
+ * _.isArrayLike(_.noop);
707
+ * // => false
708
+ */
709
+ function isArrayLike$1(value) {
710
+ return value != null && isLength$1(value.length) && !isFunction(value);
711
+ }
712
+
713
+ var isArrayLike_1 = isArrayLike$1;
714
+
715
+ var isBuffer$1 = {exports: {}};
716
+
717
+ /**
718
+ * This method returns `false`.
719
+ *
720
+ * @static
721
+ * @memberOf _
722
+ * @since 4.13.0
723
+ * @category Util
724
+ * @returns {boolean} Returns `false`.
725
+ * @example
726
+ *
727
+ * _.times(2, _.stubFalse);
728
+ * // => [false, false]
729
+ */
730
+
731
+ function stubFalse() {
732
+ return false;
733
+ }
734
+
735
+ var stubFalse_1 = stubFalse;
736
+
737
+ (function (module, exports) {
738
+ var root = _root,
739
+ stubFalse = stubFalse_1;
740
+
741
+ /** Detect free variable `exports`. */
742
+ var freeExports = exports && !exports.nodeType && exports;
743
+
744
+ /** Detect free variable `module`. */
745
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
746
+
747
+ /** Detect the popular CommonJS extension `module.exports`. */
748
+ var moduleExports = freeModule && freeModule.exports === freeExports;
749
+
750
+ /** Built-in value references. */
751
+ var Buffer = moduleExports ? root.Buffer : undefined;
752
+
753
+ /* Built-in method references for those with the same name as other `lodash` methods. */
754
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
755
+
756
+ /**
757
+ * Checks if `value` is a buffer.
758
+ *
759
+ * @static
760
+ * @memberOf _
761
+ * @since 4.3.0
762
+ * @category Lang
763
+ * @param {*} value The value to check.
764
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
765
+ * @example
766
+ *
767
+ * _.isBuffer(new Buffer(2));
768
+ * // => true
769
+ *
770
+ * _.isBuffer(new Uint8Array(2));
771
+ * // => false
772
+ */
773
+ var isBuffer = nativeIsBuffer || stubFalse;
774
+
775
+ module.exports = isBuffer;
776
+ }(isBuffer$1, isBuffer$1.exports));
777
+
778
+ var baseGetTag = _baseGetTag,
779
+ isLength = isLength_1,
780
+ isObjectLike = isObjectLike_1;
781
+
782
+ /** `Object#toString` result references. */
783
+ var argsTag = '[object Arguments]',
784
+ arrayTag = '[object Array]',
785
+ boolTag = '[object Boolean]',
786
+ dateTag = '[object Date]',
787
+ errorTag = '[object Error]',
788
+ funcTag = '[object Function]',
789
+ mapTag$1 = '[object Map]',
790
+ numberTag = '[object Number]',
791
+ objectTag = '[object Object]',
792
+ regexpTag = '[object RegExp]',
793
+ setTag$1 = '[object Set]',
794
+ stringTag = '[object String]',
795
+ weakMapTag = '[object WeakMap]';
796
+
797
+ var arrayBufferTag = '[object ArrayBuffer]',
798
+ dataViewTag = '[object DataView]',
799
+ float32Tag = '[object Float32Array]',
800
+ float64Tag = '[object Float64Array]',
801
+ int8Tag = '[object Int8Array]',
802
+ int16Tag = '[object Int16Array]',
803
+ int32Tag = '[object Int32Array]',
804
+ uint8Tag = '[object Uint8Array]',
805
+ uint8ClampedTag = '[object Uint8ClampedArray]',
806
+ uint16Tag = '[object Uint16Array]',
807
+ uint32Tag = '[object Uint32Array]';
808
+
809
+ /** Used to identify `toStringTag` values of typed arrays. */
810
+ var typedArrayTags = {};
811
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
812
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
813
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
814
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
815
+ typedArrayTags[uint32Tag] = true;
816
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
817
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
818
+ typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
819
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
820
+ typedArrayTags[mapTag$1] = typedArrayTags[numberTag] =
821
+ typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
822
+ typedArrayTags[setTag$1] = typedArrayTags[stringTag] =
823
+ typedArrayTags[weakMapTag] = false;
824
+
825
+ /**
826
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
827
+ *
828
+ * @private
829
+ * @param {*} value The value to check.
830
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
831
+ */
832
+ function baseIsTypedArray$1(value) {
833
+ return isObjectLike(value) &&
834
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
835
+ }
836
+
837
+ var _baseIsTypedArray = baseIsTypedArray$1;
838
+
839
+ /**
840
+ * The base implementation of `_.unary` without support for storing metadata.
841
+ *
842
+ * @private
843
+ * @param {Function} func The function to cap arguments for.
844
+ * @returns {Function} Returns the new capped function.
845
+ */
846
+
847
+ function baseUnary$1(func) {
848
+ return function(value) {
849
+ return func(value);
850
+ };
851
+ }
852
+
853
+ var _baseUnary = baseUnary$1;
854
+
855
+ var _nodeUtil = {exports: {}};
856
+
857
+ (function (module, exports) {
858
+ var freeGlobal = _freeGlobal;
859
+
860
+ /** Detect free variable `exports`. */
861
+ var freeExports = exports && !exports.nodeType && exports;
862
+
863
+ /** Detect free variable `module`. */
864
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
865
+
866
+ /** Detect the popular CommonJS extension `module.exports`. */
867
+ var moduleExports = freeModule && freeModule.exports === freeExports;
868
+
869
+ /** Detect free variable `process` from Node.js. */
870
+ var freeProcess = moduleExports && freeGlobal.process;
871
+
872
+ /** Used to access faster Node.js helpers. */
873
+ var nodeUtil = (function() {
874
+ try {
875
+ // Use `util.types` for Node.js 10+.
876
+ var types = freeModule && freeModule.require && freeModule.require('util').types;
877
+
878
+ if (types) {
879
+ return types;
880
+ }
881
+
882
+ // Legacy `process.binding('util')` for Node.js < 10.
883
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
884
+ } catch (e) {}
885
+ }());
886
+
887
+ module.exports = nodeUtil;
888
+ }(_nodeUtil, _nodeUtil.exports));
889
+
890
+ var baseIsTypedArray = _baseIsTypedArray,
891
+ baseUnary = _baseUnary,
892
+ nodeUtil = _nodeUtil.exports;
893
+
894
+ /* Node.js helper references. */
895
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
896
+
897
+ /**
898
+ * Checks if `value` is classified as a typed array.
899
+ *
900
+ * @static
901
+ * @memberOf _
902
+ * @since 3.0.0
903
+ * @category Lang
904
+ * @param {*} value The value to check.
905
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
906
+ * @example
907
+ *
908
+ * _.isTypedArray(new Uint8Array);
909
+ * // => true
910
+ *
911
+ * _.isTypedArray([]);
912
+ * // => false
913
+ */
914
+ var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
915
+
916
+ var isTypedArray_1 = isTypedArray$1;
917
+
918
+ var baseKeys = _baseKeys,
919
+ getTag = _getTag,
920
+ isArguments = isArguments_1,
921
+ isArray = isArray_1,
922
+ isArrayLike = isArrayLike_1,
923
+ isBuffer = isBuffer$1.exports,
924
+ isPrototype = _isPrototype,
925
+ isTypedArray = isTypedArray_1;
926
+
927
+ /** `Object#toString` result references. */
928
+ var mapTag = '[object Map]',
929
+ setTag = '[object Set]';
930
+
931
+ /** Used for built-in method references. */
932
+ var objectProto = Object.prototype;
933
+
934
+ /** Used to check objects for own properties. */
935
+ var hasOwnProperty = objectProto.hasOwnProperty;
936
+
937
+ /**
938
+ * Checks if `value` is an empty object, collection, map, or set.
939
+ *
940
+ * Objects are considered empty if they have no own enumerable string keyed
941
+ * properties.
942
+ *
943
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
944
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
945
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
946
+ *
947
+ * @static
948
+ * @memberOf _
949
+ * @since 0.1.0
950
+ * @category Lang
951
+ * @param {*} value The value to check.
952
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
953
+ * @example
954
+ *
955
+ * _.isEmpty(null);
956
+ * // => true
957
+ *
958
+ * _.isEmpty(true);
959
+ * // => true
960
+ *
961
+ * _.isEmpty(1);
962
+ * // => true
963
+ *
964
+ * _.isEmpty([1, 2, 3]);
965
+ * // => false
966
+ *
967
+ * _.isEmpty({ 'a': 1 });
968
+ * // => false
969
+ */
970
+ function isEmpty(value) {
971
+ if (value == null) {
972
+ return true;
973
+ }
974
+ if (isArrayLike(value) &&
975
+ (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
976
+ isBuffer(value) || isTypedArray(value) || isArguments(value))) {
977
+ return !value.length;
978
+ }
979
+ var tag = getTag(value);
980
+ if (tag == mapTag || tag == setTag) {
981
+ return !value.size;
982
+ }
983
+ if (isPrototype(value)) {
984
+ return !baseKeys(value).length;
985
+ }
986
+ for (var key in value) {
987
+ if (hasOwnProperty.call(value, key)) {
988
+ return false;
989
+ }
990
+ }
991
+ return true;
992
+ }
993
+
994
+ var isEmpty_1 = isEmpty;
995
+
996
+ var browser = {exports: {}};
997
+
998
+ /**
999
+ * Helpers.
1000
+ */
1001
+
1002
+ var s = 1000;
1003
+ var m = s * 60;
1004
+ var h = m * 60;
1005
+ var d = h * 24;
1006
+ var w = d * 7;
1007
+ var y = d * 365.25;
1008
+
1009
+ /**
1010
+ * Parse or format the given `val`.
1011
+ *
1012
+ * Options:
1013
+ *
1014
+ * - `long` verbose formatting [false]
1015
+ *
1016
+ * @param {String|Number} val
1017
+ * @param {Object} [options]
1018
+ * @throws {Error} throw an error if val is not a non-empty string or a number
1019
+ * @return {String|Number}
1020
+ * @api public
1021
+ */
1022
+
1023
+ var ms = function (val, options) {
1024
+ options = options || {};
1025
+ var type = typeof val;
1026
+ if (type === 'string' && val.length > 0) {
1027
+ return parse(val);
1028
+ } else if (type === 'number' && isFinite(val)) {
1029
+ return options.long ? fmtLong(val) : fmtShort(val);
1030
+ }
1031
+ throw new Error(
1032
+ 'val is not a non-empty string or a valid number. val=' +
1033
+ JSON.stringify(val)
1034
+ );
1035
+ };
1036
+
1037
+ /**
1038
+ * Parse the given `str` and return milliseconds.
1039
+ *
1040
+ * @param {String} str
1041
+ * @return {Number}
1042
+ * @api private
1043
+ */
1044
+
1045
+ function parse(str) {
1046
+ str = String(str);
1047
+ if (str.length > 100) {
1048
+ return;
1049
+ }
1050
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
1051
+ str
1052
+ );
1053
+ if (!match) {
1054
+ return;
1055
+ }
1056
+ var n = parseFloat(match[1]);
1057
+ var type = (match[2] || 'ms').toLowerCase();
1058
+ switch (type) {
1059
+ case 'years':
1060
+ case 'year':
1061
+ case 'yrs':
1062
+ case 'yr':
1063
+ case 'y':
1064
+ return n * y;
1065
+ case 'weeks':
1066
+ case 'week':
1067
+ case 'w':
1068
+ return n * w;
1069
+ case 'days':
1070
+ case 'day':
1071
+ case 'd':
1072
+ return n * d;
1073
+ case 'hours':
1074
+ case 'hour':
1075
+ case 'hrs':
1076
+ case 'hr':
1077
+ case 'h':
1078
+ return n * h;
1079
+ case 'minutes':
1080
+ case 'minute':
1081
+ case 'mins':
1082
+ case 'min':
1083
+ case 'm':
1084
+ return n * m;
1085
+ case 'seconds':
1086
+ case 'second':
1087
+ case 'secs':
1088
+ case 'sec':
1089
+ case 's':
1090
+ return n * s;
1091
+ case 'milliseconds':
1092
+ case 'millisecond':
1093
+ case 'msecs':
1094
+ case 'msec':
1095
+ case 'ms':
1096
+ return n;
1097
+ default:
1098
+ return undefined;
1099
+ }
1100
+ }
1101
+
1102
+ /**
1103
+ * Short format for `ms`.
1104
+ *
1105
+ * @param {Number} ms
1106
+ * @return {String}
1107
+ * @api private
1108
+ */
1109
+
1110
+ function fmtShort(ms) {
1111
+ var msAbs = Math.abs(ms);
1112
+ if (msAbs >= d) {
1113
+ return Math.round(ms / d) + 'd';
1114
+ }
1115
+ if (msAbs >= h) {
1116
+ return Math.round(ms / h) + 'h';
1117
+ }
1118
+ if (msAbs >= m) {
1119
+ return Math.round(ms / m) + 'm';
1120
+ }
1121
+ if (msAbs >= s) {
1122
+ return Math.round(ms / s) + 's';
1123
+ }
1124
+ return ms + 'ms';
1125
+ }
1126
+
1127
+ /**
1128
+ * Long format for `ms`.
1129
+ *
1130
+ * @param {Number} ms
1131
+ * @return {String}
1132
+ * @api private
1133
+ */
1134
+
1135
+ function fmtLong(ms) {
1136
+ var msAbs = Math.abs(ms);
1137
+ if (msAbs >= d) {
1138
+ return plural(ms, msAbs, d, 'day');
1139
+ }
1140
+ if (msAbs >= h) {
1141
+ return plural(ms, msAbs, h, 'hour');
1142
+ }
1143
+ if (msAbs >= m) {
1144
+ return plural(ms, msAbs, m, 'minute');
1145
+ }
1146
+ if (msAbs >= s) {
1147
+ return plural(ms, msAbs, s, 'second');
1148
+ }
1149
+ return ms + ' ms';
1150
+ }
1151
+
1152
+ /**
1153
+ * Pluralization helper.
1154
+ */
1155
+
1156
+ function plural(ms, msAbs, n, name) {
1157
+ var isPlural = msAbs >= n * 1.5;
1158
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
1159
+ }
1160
+
1161
+ /**
1162
+ * This is the common logic for both the Node.js and web browser
1163
+ * implementations of `debug()`.
1164
+ */
1165
+ function setup(env) {
1166
+ createDebug.debug = createDebug;
1167
+ createDebug.default = createDebug;
1168
+ createDebug.coerce = coerce;
1169
+ createDebug.disable = disable;
1170
+ createDebug.enable = enable;
1171
+ createDebug.enabled = enabled;
1172
+ createDebug.humanize = ms;
1173
+ Object.keys(env).forEach(function (key) {
1174
+ createDebug[key] = env[key];
1175
+ });
1176
+ /**
1177
+ * Active `debug` instances.
1178
+ */
1179
+
1180
+ createDebug.instances = [];
1181
+ /**
1182
+ * The currently active debug mode names, and names to skip.
1183
+ */
1184
+
1185
+ createDebug.names = [];
1186
+ createDebug.skips = [];
1187
+ /**
1188
+ * Map of special "%n" handling functions, for the debug "format" argument.
1189
+ *
1190
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
1191
+ */
1192
+
1193
+ createDebug.formatters = {};
1194
+ /**
1195
+ * Selects a color for a debug namespace
1196
+ * @param {String} namespace The namespace string for the for the debug instance to be colored
1197
+ * @return {Number|String} An ANSI color code for the given namespace
1198
+ * @api private
1199
+ */
1200
+
1201
+ function selectColor(namespace) {
1202
+ var hash = 0;
1203
+
1204
+ for (var i = 0; i < namespace.length; i++) {
1205
+ hash = (hash << 5) - hash + namespace.charCodeAt(i);
1206
+ hash |= 0; // Convert to 32bit integer
1207
+ }
1208
+
1209
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
1210
+ }
1211
+
1212
+ createDebug.selectColor = selectColor;
1213
+ /**
1214
+ * Create a debugger with the given `namespace`.
1215
+ *
1216
+ * @param {String} namespace
1217
+ * @return {Function}
1218
+ * @api public
1219
+ */
1220
+
1221
+ function createDebug(namespace) {
1222
+ var prevTime;
1223
+
1224
+ function debug() {
1225
+ // Disabled?
1226
+ if (!debug.enabled) {
1227
+ return;
1228
+ }
1229
+
1230
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1231
+ args[_key] = arguments[_key];
1232
+ }
1233
+
1234
+ var self = debug; // Set `diff` timestamp
1235
+
1236
+ var curr = Number(new Date());
1237
+ var ms = curr - (prevTime || curr);
1238
+ self.diff = ms;
1239
+ self.prev = prevTime;
1240
+ self.curr = curr;
1241
+ prevTime = curr;
1242
+ args[0] = createDebug.coerce(args[0]);
1243
+
1244
+ if (typeof args[0] !== 'string') {
1245
+ // Anything else let's inspect with %O
1246
+ args.unshift('%O');
1247
+ } // Apply any `formatters` transformations
1248
+
1249
+
1250
+ var index = 0;
1251
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
1252
+ // If we encounter an escaped % then don't increase the array index
1253
+ if (match === '%%') {
1254
+ return match;
1255
+ }
1256
+
1257
+ index++;
1258
+ var formatter = createDebug.formatters[format];
1259
+
1260
+ if (typeof formatter === 'function') {
1261
+ var val = args[index];
1262
+ match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
1263
+
1264
+ args.splice(index, 1);
1265
+ index--;
1266
+ }
1267
+
1268
+ return match;
1269
+ }); // Apply env-specific formatting (colors, etc.)
1270
+
1271
+ createDebug.formatArgs.call(self, args);
1272
+ var logFn = self.log || createDebug.log;
1273
+ logFn.apply(self, args);
1274
+ }
1275
+
1276
+ debug.namespace = namespace;
1277
+ debug.enabled = createDebug.enabled(namespace);
1278
+ debug.useColors = createDebug.useColors();
1279
+ debug.color = selectColor(namespace);
1280
+ debug.destroy = destroy;
1281
+ debug.extend = extend; // Debug.formatArgs = formatArgs;
1282
+ // debug.rawLog = rawLog;
1283
+ // env-specific initialization logic for debug instances
1284
+
1285
+ if (typeof createDebug.init === 'function') {
1286
+ createDebug.init(debug);
1287
+ }
1288
+
1289
+ createDebug.instances.push(debug);
1290
+ return debug;
1291
+ }
1292
+
1293
+ function destroy() {
1294
+ var index = createDebug.instances.indexOf(this);
1295
+
1296
+ if (index !== -1) {
1297
+ createDebug.instances.splice(index, 1);
1298
+ return true;
1299
+ }
1300
+
1301
+ return false;
1302
+ }
1303
+
1304
+ function extend(namespace, delimiter) {
1305
+ return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
1306
+ }
1307
+ /**
1308
+ * Enables a debug mode by namespaces. This can include modes
1309
+ * separated by a colon and wildcards.
1310
+ *
1311
+ * @param {String} namespaces
1312
+ * @api public
1313
+ */
1314
+
1315
+
1316
+ function enable(namespaces) {
1317
+ createDebug.save(namespaces);
1318
+ createDebug.names = [];
1319
+ createDebug.skips = [];
1320
+ var i;
1321
+ var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
1322
+ var len = split.length;
1323
+
1324
+ for (i = 0; i < len; i++) {
1325
+ if (!split[i]) {
1326
+ // ignore empty strings
1327
+ continue;
1328
+ }
1329
+
1330
+ namespaces = split[i].replace(/\*/g, '.*?');
1331
+
1332
+ if (namespaces[0] === '-') {
1333
+ createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
1334
+ } else {
1335
+ createDebug.names.push(new RegExp('^' + namespaces + '$'));
1336
+ }
1337
+ }
1338
+
1339
+ for (i = 0; i < createDebug.instances.length; i++) {
1340
+ var instance = createDebug.instances[i];
1341
+ instance.enabled = createDebug.enabled(instance.namespace);
1342
+ }
1343
+ }
1344
+ /**
1345
+ * Disable debug output.
1346
+ *
1347
+ * @api public
1348
+ */
1349
+
1350
+
1351
+ function disable() {
1352
+ createDebug.enable('');
1353
+ }
1354
+ /**
1355
+ * Returns true if the given mode name is enabled, false otherwise.
1356
+ *
1357
+ * @param {String} name
1358
+ * @return {Boolean}
1359
+ * @api public
1360
+ */
1361
+
1362
+
1363
+ function enabled(name) {
1364
+ if (name[name.length - 1] === '*') {
1365
+ return true;
1366
+ }
1367
+
1368
+ var i;
1369
+ var len;
1370
+
1371
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
1372
+ if (createDebug.skips[i].test(name)) {
1373
+ return false;
1374
+ }
1375
+ }
1376
+
1377
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
1378
+ if (createDebug.names[i].test(name)) {
1379
+ return true;
1380
+ }
1381
+ }
1382
+
1383
+ return false;
1384
+ }
1385
+ /**
1386
+ * Coerce `val`.
1387
+ *
1388
+ * @param {Mixed} val
1389
+ * @return {Mixed}
1390
+ * @api private
1391
+ */
1392
+
1393
+
1394
+ function coerce(val) {
1395
+ if (val instanceof Error) {
1396
+ return val.stack || val.message;
1397
+ }
1398
+
1399
+ return val;
1400
+ }
1401
+
1402
+ createDebug.enable(createDebug.load());
1403
+ return createDebug;
1404
+ }
1405
+
1406
+ var common = setup;
1407
+
1408
+ (function (module, exports) {
1409
+
1410
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
1411
+
1412
+ /* eslint-env browser */
1413
+
1414
+ /**
1415
+ * This is the web browser implementation of `debug()`.
1416
+ */
1417
+ exports.log = log;
1418
+ exports.formatArgs = formatArgs;
1419
+ exports.save = save;
1420
+ exports.load = load;
1421
+ exports.useColors = useColors;
1422
+ exports.storage = localstorage();
1423
+ /**
1424
+ * Colors.
1425
+ */
1426
+
1427
+ exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
1428
+ /**
1429
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
1430
+ * and the Firebug extension (any Firefox version) are known
1431
+ * to support "%c" CSS customizations.
1432
+ *
1433
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
1434
+ */
1435
+ // eslint-disable-next-line complexity
1436
+
1437
+ function useColors() {
1438
+ // NB: In an Electron preload script, document will be defined but not fully
1439
+ // initialized. Since we know we're in Chrome, we'll just detect this case
1440
+ // explicitly
1441
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
1442
+ return true;
1443
+ } // Internet Explorer and Edge do not support colors.
1444
+
1445
+
1446
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1447
+ return false;
1448
+ } // Is webkit? http://stackoverflow.com/a/16459606/376773
1449
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
1450
+
1451
+
1452
+ return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
1453
+ typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
1454
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1455
+ typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
1456
+ typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
1457
+ }
1458
+ /**
1459
+ * Colorize log arguments if enabled.
1460
+ *
1461
+ * @api public
1462
+ */
1463
+
1464
+
1465
+ function formatArgs(args) {
1466
+ args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
1467
+
1468
+ if (!this.useColors) {
1469
+ return;
1470
+ }
1471
+
1472
+ var c = 'color: ' + this.color;
1473
+ args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
1474
+ // arguments passed either before or after the %c, so we need to
1475
+ // figure out the correct index to insert the CSS into
1476
+
1477
+ var index = 0;
1478
+ var lastC = 0;
1479
+ args[0].replace(/%[a-zA-Z%]/g, function (match) {
1480
+ if (match === '%%') {
1481
+ return;
1482
+ }
1483
+
1484
+ index++;
1485
+
1486
+ if (match === '%c') {
1487
+ // We only are interested in the *last* %c
1488
+ // (the user may have provided their own)
1489
+ lastC = index;
1490
+ }
1491
+ });
1492
+ args.splice(lastC, 0, c);
1493
+ }
1494
+ /**
1495
+ * Invokes `console.log()` when available.
1496
+ * No-op when `console.log` is not a "function".
1497
+ *
1498
+ * @api public
1499
+ */
1500
+
1501
+
1502
+ function log() {
1503
+ var _console;
1504
+
1505
+ // This hackery is required for IE8/9, where
1506
+ // the `console.log` function doesn't have 'apply'
1507
+ return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
1508
+ }
1509
+ /**
1510
+ * Save `namespaces`.
1511
+ *
1512
+ * @param {String} namespaces
1513
+ * @api private
1514
+ */
1515
+
1516
+
1517
+ function save(namespaces) {
1518
+ try {
1519
+ if (namespaces) {
1520
+ exports.storage.setItem('debug', namespaces);
1521
+ } else {
1522
+ exports.storage.removeItem('debug');
1523
+ }
1524
+ } catch (error) {// Swallow
1525
+ // XXX (@Qix-) should we be logging these?
1526
+ }
1527
+ }
1528
+ /**
1529
+ * Load `namespaces`.
1530
+ *
1531
+ * @return {String} returns the previously persisted debug modes
1532
+ * @api private
1533
+ */
1534
+
1535
+
1536
+ function load() {
1537
+ var r;
1538
+
1539
+ try {
1540
+ r = exports.storage.getItem('debug');
1541
+ } catch (error) {} // Swallow
1542
+ // XXX (@Qix-) should we be logging these?
1543
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
1544
+
1545
+
1546
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
1547
+ r = process.env.DEBUG;
1548
+ }
1549
+
1550
+ return r;
1551
+ }
1552
+ /**
1553
+ * Localstorage attempts to return the localstorage.
1554
+ *
1555
+ * This is necessary because safari throws
1556
+ * when a user disables cookies/localstorage
1557
+ * and you attempt to access it.
1558
+ *
1559
+ * @return {LocalStorage}
1560
+ * @api private
1561
+ */
1562
+
1563
+
1564
+ function localstorage() {
1565
+ try {
1566
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
1567
+ // The Browser also has localStorage in the global context.
1568
+ return localStorage;
1569
+ } catch (error) {// Swallow
1570
+ // XXX (@Qix-) should we be logging these?
1571
+ }
1572
+ }
1573
+
1574
+ module.exports = common(exports);
1575
+ var formatters = module.exports.formatters;
1576
+ /**
1577
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
1578
+ */
1579
+
1580
+ formatters.j = function (v) {
1581
+ try {
1582
+ return JSON.stringify(v);
1583
+ } catch (error) {
1584
+ return '[UnexpectedJSONParseError]: ' + error.message;
1585
+ }
1586
+ };
1587
+ }(browser, browser.exports));
1588
+
1589
+ var debug = browser.exports;
1590
+
1591
+ var defaults = {
1592
+ config: {
1593
+ answers: [],
1594
+ prompt: '',
1595
+ prompts: [],
1596
+ shuffled: false
1597
+ }
1598
+ };
1599
+
1600
+ const log = debug('@pie-element:match-list:controller');
1601
+
1602
+ const getResponseCorrectness = (model, answers, env) => {
1603
+ const isPartialScoring = partialScoring.enabled(model, env);
1604
+ const prompts = model.prompts;
1605
+
1606
+ if (!answers || Object.keys(answers).length === 0) {
1607
+ return 'unanswered';
1608
+ }
1609
+
1610
+ const totalCorrectAnswers = getTotalCorrect(model);
1611
+ const correctAnswers = getCorrectSelected(prompts, answers);
1612
+
1613
+ if (totalCorrectAnswers === correctAnswers) {
1614
+ return 'correct';
1615
+ } else if (correctAnswers === 0) {
1616
+ return 'incorrect';
1617
+ } else if (isPartialScoring) {
1618
+ return 'partial';
1619
+ }
1620
+
1621
+ return 'incorrect';
1622
+ };
1623
+
1624
+ const getCorrectness = (question, env, answers) => {
1625
+ if (env.mode === 'evaluate') {
1626
+ return getResponseCorrectness(question, answers, env);
1627
+ }
1628
+ };
1629
+
1630
+ const getCorrectSelected = (prompts = [], answers) => {
1631
+ let correctAnswers = 0;
1632
+ prompts.forEach(p => {
1633
+ if (p.relatedAnswer === answers[p.id]) {
1634
+ correctAnswers += 1;
1635
+ }
1636
+ });
1637
+ return correctAnswers;
1638
+ };
1639
+
1640
+ const getTotalCorrect = question => {
1641
+ return question && question.prompts ? question.prompts.length : 0;
1642
+ };
1643
+
1644
+ const getPartialScore = (question, answers) => {
1645
+ const count = getCorrectSelected(question && question.prompts, answers);
1646
+ const totalCorrect = getTotalCorrect(question);
1647
+ return parseFloat((count / totalCorrect).toFixed(2));
1648
+ };
1649
+
1650
+ const getOutComeScore = (question, env, answers) => {
1651
+ const correctness = getCorrectness(question, env, answers);
1652
+ return correctness === 'correct' ? 1 : correctness === 'partial' && true ? getPartialScore(question, answers) : 0;
1653
+ };
1654
+
1655
+ const outcome = (question, session, env) => {
1656
+ return new Promise(resolve => {
1657
+ if (env.mode !== 'evaluate') {
1658
+ resolve({
1659
+ score: undefined,
1660
+ completed: undefined
1661
+ });
1662
+ } else {
1663
+ if (!session || isEmpty_1(session)) {
1664
+ resolve({
1665
+ score: 0,
1666
+ empty: true
1667
+ });
1668
+ } else {
1669
+ const out = {
1670
+ score: getOutComeScore(question, env, session.value)
1671
+ };
1672
+ resolve(out);
1673
+ }
1674
+ }
1675
+ });
1676
+ };
1677
+ function createDefaultModel(model = {}) {
1678
+ return new Promise(resolve => {
1679
+ resolve(_extends({}, defaults, model));
1680
+ });
1681
+ }
1682
+ const normalize = model => _extends({}, defaults, model);
1683
+ /**
1684
+ *
1685
+ * @param {*} question
1686
+ * @param {*} session
1687
+ * @param {*} env
1688
+ * @param {*} updateSession - optional - a function that will set the properties passed into it on the session.
1689
+ */
1690
+
1691
+ function model(question, session, env, updateSession) {
1692
+ return new Promise(async resolve => {
1693
+ question = normalize(question);
1694
+ const correctness = getCorrectness(question, env, session && session.value);
1695
+ const correctResponse = {};
1696
+ const score = `${getOutComeScore(question, env, session && session.value) * 100}%`;
1697
+ const correctInfo = {
1698
+ score,
1699
+ correctness
1700
+ };
1701
+ const shuffledValues = {};
1702
+ let prompts = question.prompts;
1703
+ let answers = question.answers;
1704
+
1705
+ const us = part => (id, element, update) => {
1706
+ return new Promise(resolve => {
1707
+ shuffledValues[part] = update.shuffledValues;
1708
+ resolve();
1709
+ });
1710
+ };
1711
+
1712
+ const lockChoiceOrder = lockChoices(question, session, env);
1713
+
1714
+ if (!lockChoiceOrder) {
1715
+ prompts = await getShuffledChoices(prompts, {
1716
+ shuffledValues: (session && session.shuffledValues || {}).prompts
1717
+ }, us('prompts'), 'id');
1718
+ answers = await getShuffledChoices(answers, {
1719
+ shuffledValues: (session && session.shuffledValues || {}).answers
1720
+ }, us('answers'), 'id');
1721
+ }
1722
+
1723
+ if (!isEmpty_1(shuffledValues)) {
1724
+ if (updateSession && typeof updateSession === 'function') {
1725
+ updateSession(session.id, session.element, {
1726
+ shuffledValues
1727
+ }).catch(e => {
1728
+ // eslint-disable-next-line no-console
1729
+ console.error('update session failed', e);
1730
+ });
1731
+ }
1732
+ }
1733
+
1734
+ if (question && prompts) {
1735
+ prompts.forEach(prompt => {
1736
+ correctResponse[prompt.id] = prompt.relatedAnswer;
1737
+ });
1738
+ }
1739
+
1740
+ const fb = env.mode === 'evaluate' ? getFeedbackForCorrectness(correctInfo.correctness, question.feedback) : Promise.resolve(undefined);
1741
+ fb.then(feedback => {
1742
+ const base = {
1743
+ config: _extends({}, question, {
1744
+ prompts,
1745
+ answers
1746
+ }),
1747
+ correctness: correctInfo,
1748
+ feedback,
1749
+ mode: env.mode
1750
+ };
1751
+
1752
+ if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
1753
+ base.rationale = question.rationale;
1754
+ } else {
1755
+ base.rationale = null;
1756
+ }
1757
+
1758
+ const out = Object.assign(base, {
1759
+ correctResponse
1760
+ });
1761
+ log('out: ', out);
1762
+ resolve(out);
1763
+ });
1764
+ });
1765
+ }
1766
+ const createCorrectResponseSession = (question, env) => {
1767
+ return new Promise(resolve => {
1768
+ if (env.mode !== 'evaluate' && env.role === 'instructor') {
1769
+ const {
1770
+ prompts,
1771
+ answers
1772
+ } = question;
1773
+ const value = {};
1774
+ prompts.forEach(p => {
1775
+ if (answers.filter(a => a.id === p.relatedAnswer).length) {
1776
+ value[p.id] = p.relatedAnswer;
1777
+ }
1778
+ });
1779
+ resolve({
1780
+ value,
1781
+ id: '1'
1782
+ });
1783
+ } else {
1784
+ resolve(null);
1785
+ }
1786
+ });
1787
+ };
1788
+
1789
+ export { createCorrectResponseSession, createDefaultModel, model, normalize, outcome };
1790
+ //# sourceMappingURL=controller.js.map