@pie-element/select-text 11.3.4-next.3 → 12.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1932 +0,0 @@
1
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
-
3
- /** Used for built-in method references. */
4
-
5
- var objectProto$8 = Object.prototype;
6
-
7
- /**
8
- * Checks if `value` is likely a prototype object.
9
- *
10
- * @private
11
- * @param {*} value The value to check.
12
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
13
- */
14
- function isPrototype$2(value) {
15
- var Ctor = value && value.constructor,
16
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
17
-
18
- return value === proto;
19
- }
20
-
21
- var _isPrototype = isPrototype$2;
22
-
23
- /**
24
- * Creates a unary function that invokes `func` with its argument transformed.
25
- *
26
- * @private
27
- * @param {Function} func The function to wrap.
28
- * @param {Function} transform The argument transform.
29
- * @returns {Function} Returns the new function.
30
- */
31
-
32
- function overArg$1(func, transform) {
33
- return function(arg) {
34
- return func(transform(arg));
35
- };
36
- }
37
-
38
- var _overArg = overArg$1;
39
-
40
- var overArg = _overArg;
41
-
42
- /* Built-in method references for those with the same name as other `lodash` methods. */
43
- var nativeKeys$1 = overArg(Object.keys, Object);
44
-
45
- var _nativeKeys = nativeKeys$1;
46
-
47
- var isPrototype$1 = _isPrototype,
48
- nativeKeys = _nativeKeys;
49
-
50
- /** Used for built-in method references. */
51
- var objectProto$7 = Object.prototype;
52
-
53
- /** Used to check objects for own properties. */
54
- var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
55
-
56
- /**
57
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
58
- *
59
- * @private
60
- * @param {Object} object The object to query.
61
- * @returns {Array} Returns the array of property names.
62
- */
63
- function baseKeys$1(object) {
64
- if (!isPrototype$1(object)) {
65
- return nativeKeys(object);
66
- }
67
- var result = [];
68
- for (var key in Object(object)) {
69
- if (hasOwnProperty$6.call(object, key) && key != 'constructor') {
70
- result.push(key);
71
- }
72
- }
73
- return result;
74
- }
75
-
76
- var _baseKeys = baseKeys$1;
77
-
78
- /** Detect free variable `global` from Node.js. */
79
-
80
- var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
81
-
82
- var _freeGlobal = freeGlobal$1;
83
-
84
- var freeGlobal = _freeGlobal;
85
-
86
- /** Detect free variable `self`. */
87
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
88
-
89
- /** Used as a reference to the global object. */
90
- var root$7 = freeGlobal || freeSelf || Function('return this')();
91
-
92
- var _root = root$7;
93
-
94
- var root$6 = _root;
95
-
96
- /** Built-in value references. */
97
- var Symbol$3 = root$6.Symbol;
98
-
99
- var _Symbol = Symbol$3;
100
-
101
- var Symbol$2 = _Symbol;
102
-
103
- /** Used for built-in method references. */
104
- var objectProto$6 = Object.prototype;
105
-
106
- /** Used to check objects for own properties. */
107
- var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
108
-
109
- /**
110
- * Used to resolve the
111
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
112
- * of values.
113
- */
114
- var nativeObjectToString$1 = objectProto$6.toString;
115
-
116
- /** Built-in value references. */
117
- var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
118
-
119
- /**
120
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
121
- *
122
- * @private
123
- * @param {*} value The value to query.
124
- * @returns {string} Returns the raw `toStringTag`.
125
- */
126
- function getRawTag$1(value) {
127
- var isOwn = hasOwnProperty$5.call(value, symToStringTag$1),
128
- tag = value[symToStringTag$1];
129
-
130
- try {
131
- value[symToStringTag$1] = undefined;
132
- var unmasked = true;
133
- } catch (e) {}
134
-
135
- var result = nativeObjectToString$1.call(value);
136
- if (unmasked) {
137
- if (isOwn) {
138
- value[symToStringTag$1] = tag;
139
- } else {
140
- delete value[symToStringTag$1];
141
- }
142
- }
143
- return result;
144
- }
145
-
146
- var _getRawTag = getRawTag$1;
147
-
148
- /** Used for built-in method references. */
149
-
150
- var objectProto$5 = Object.prototype;
151
-
152
- /**
153
- * Used to resolve the
154
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
155
- * of values.
156
- */
157
- var nativeObjectToString = objectProto$5.toString;
158
-
159
- /**
160
- * Converts `value` to a string using `Object.prototype.toString`.
161
- *
162
- * @private
163
- * @param {*} value The value to convert.
164
- * @returns {string} Returns the converted string.
165
- */
166
- function objectToString$1(value) {
167
- return nativeObjectToString.call(value);
168
- }
169
-
170
- var _objectToString = objectToString$1;
171
-
172
- var Symbol$1 = _Symbol,
173
- getRawTag = _getRawTag,
174
- objectToString = _objectToString;
175
-
176
- /** `Object#toString` result references. */
177
- var nullTag = '[object Null]',
178
- undefinedTag = '[object Undefined]';
179
-
180
- /** Built-in value references. */
181
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
182
-
183
- /**
184
- * The base implementation of `getTag` without fallbacks for buggy environments.
185
- *
186
- * @private
187
- * @param {*} value The value to query.
188
- * @returns {string} Returns the `toStringTag`.
189
- */
190
- function baseGetTag$4(value) {
191
- if (value == null) {
192
- return value === undefined ? undefinedTag : nullTag;
193
- }
194
- return (symToStringTag && symToStringTag in Object(value))
195
- ? getRawTag(value)
196
- : objectToString(value);
197
- }
198
-
199
- var _baseGetTag = baseGetTag$4;
200
-
201
- /**
202
- * Checks if `value` is the
203
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
204
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
205
- *
206
- * @static
207
- * @memberOf _
208
- * @since 0.1.0
209
- * @category Lang
210
- * @param {*} value The value to check.
211
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
212
- * @example
213
- *
214
- * _.isObject({});
215
- * // => true
216
- *
217
- * _.isObject([1, 2, 3]);
218
- * // => true
219
- *
220
- * _.isObject(_.noop);
221
- * // => true
222
- *
223
- * _.isObject(null);
224
- * // => false
225
- */
226
-
227
- function isObject$2(value) {
228
- var type = typeof value;
229
- return value != null && (type == 'object' || type == 'function');
230
- }
231
-
232
- var isObject_1 = isObject$2;
233
-
234
- var baseGetTag$3 = _baseGetTag,
235
- isObject$1 = isObject_1;
236
-
237
- /** `Object#toString` result references. */
238
- var asyncTag = '[object AsyncFunction]',
239
- funcTag$1 = '[object Function]',
240
- genTag = '[object GeneratorFunction]',
241
- proxyTag = '[object Proxy]';
242
-
243
- /**
244
- * Checks if `value` is classified as a `Function` object.
245
- *
246
- * @static
247
- * @memberOf _
248
- * @since 0.1.0
249
- * @category Lang
250
- * @param {*} value The value to check.
251
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
252
- * @example
253
- *
254
- * _.isFunction(_);
255
- * // => true
256
- *
257
- * _.isFunction(/abc/);
258
- * // => false
259
- */
260
- function isFunction$2(value) {
261
- if (!isObject$1(value)) {
262
- return false;
263
- }
264
- // The use of `Object#toString` avoids issues with the `typeof` operator
265
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
266
- var tag = baseGetTag$3(value);
267
- return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
268
- }
269
-
270
- var isFunction_1 = isFunction$2;
271
-
272
- var root$5 = _root;
273
-
274
- /** Used to detect overreaching core-js shims. */
275
- var coreJsData$1 = root$5['__core-js_shared__'];
276
-
277
- var _coreJsData = coreJsData$1;
278
-
279
- var coreJsData = _coreJsData;
280
-
281
- /** Used to detect methods masquerading as native. */
282
- var maskSrcKey = (function() {
283
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
284
- return uid ? ('Symbol(src)_1.' + uid) : '';
285
- }());
286
-
287
- /**
288
- * Checks if `func` has its source masked.
289
- *
290
- * @private
291
- * @param {Function} func The function to check.
292
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
293
- */
294
- function isMasked$1(func) {
295
- return !!maskSrcKey && (maskSrcKey in func);
296
- }
297
-
298
- var _isMasked = isMasked$1;
299
-
300
- /** Used for built-in method references. */
301
-
302
- var funcProto$1 = Function.prototype;
303
-
304
- /** Used to resolve the decompiled source of functions. */
305
- var funcToString$1 = funcProto$1.toString;
306
-
307
- /**
308
- * Converts `func` to its source code.
309
- *
310
- * @private
311
- * @param {Function} func The function to convert.
312
- * @returns {string} Returns the source code.
313
- */
314
- function toSource$2(func) {
315
- if (func != null) {
316
- try {
317
- return funcToString$1.call(func);
318
- } catch (e) {}
319
- try {
320
- return (func + '');
321
- } catch (e) {}
322
- }
323
- return '';
324
- }
325
-
326
- var _toSource = toSource$2;
327
-
328
- var isFunction$1 = isFunction_1,
329
- isMasked = _isMasked,
330
- isObject = isObject_1,
331
- toSource$1 = _toSource;
332
-
333
- /**
334
- * Used to match `RegExp`
335
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
336
- */
337
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
338
-
339
- /** Used to detect host constructors (Safari). */
340
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
341
-
342
- /** Used for built-in method references. */
343
- var funcProto = Function.prototype,
344
- objectProto$4 = Object.prototype;
345
-
346
- /** Used to resolve the decompiled source of functions. */
347
- var funcToString = funcProto.toString;
348
-
349
- /** Used to check objects for own properties. */
350
- var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
351
-
352
- /** Used to detect if a method is native. */
353
- var reIsNative = RegExp('^' +
354
- funcToString.call(hasOwnProperty$4).replace(reRegExpChar, '\\$&')
355
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
356
- );
357
-
358
- /**
359
- * The base implementation of `_.isNative` without bad shim checks.
360
- *
361
- * @private
362
- * @param {*} value The value to check.
363
- * @returns {boolean} Returns `true` if `value` is a native function,
364
- * else `false`.
365
- */
366
- function baseIsNative$1(value) {
367
- if (!isObject(value) || isMasked(value)) {
368
- return false;
369
- }
370
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
371
- return pattern.test(toSource$1(value));
372
- }
373
-
374
- var _baseIsNative = baseIsNative$1;
375
-
376
- /**
377
- * Gets the value at `key` of `object`.
378
- *
379
- * @private
380
- * @param {Object} [object] The object to query.
381
- * @param {string} key The key of the property to get.
382
- * @returns {*} Returns the property value.
383
- */
384
-
385
- function getValue$1(object, key) {
386
- return object == null ? undefined : object[key];
387
- }
388
-
389
- var _getValue = getValue$1;
390
-
391
- var baseIsNative = _baseIsNative,
392
- getValue = _getValue;
393
-
394
- /**
395
- * Gets the native function at `key` of `object`.
396
- *
397
- * @private
398
- * @param {Object} object The object to query.
399
- * @param {string} key The key of the method to get.
400
- * @returns {*} Returns the function if it's native, else `undefined`.
401
- */
402
- function getNative$6(object, key) {
403
- var value = getValue(object, key);
404
- return baseIsNative(value) ? value : undefined;
405
- }
406
-
407
- var _getNative = getNative$6;
408
-
409
- var getNative$5 = _getNative,
410
- root$4 = _root;
411
-
412
- /* Built-in method references that are verified to be native. */
413
- var DataView$1 = getNative$5(root$4, 'DataView');
414
-
415
- var _DataView = DataView$1;
416
-
417
- var getNative$4 = _getNative,
418
- root$3 = _root;
419
-
420
- /* Built-in method references that are verified to be native. */
421
- var Map$2 = getNative$4(root$3, 'Map');
422
-
423
- var _Map = Map$2;
424
-
425
- var getNative$3 = _getNative,
426
- root$2 = _root;
427
-
428
- /* Built-in method references that are verified to be native. */
429
- var Promise$2 = getNative$3(root$2, 'Promise');
430
-
431
- var _Promise = Promise$2;
432
-
433
- var getNative$2 = _getNative,
434
- root$1 = _root;
435
-
436
- /* Built-in method references that are verified to be native. */
437
- var Set$1 = getNative$2(root$1, 'Set');
438
-
439
- var _Set = Set$1;
440
-
441
- var getNative$1 = _getNative,
442
- root = _root;
443
-
444
- /* Built-in method references that are verified to be native. */
445
- var WeakMap$1 = getNative$1(root, 'WeakMap');
446
-
447
- var _WeakMap = WeakMap$1;
448
-
449
- var DataView = _DataView,
450
- Map$1 = _Map,
451
- Promise$1 = _Promise,
452
- Set = _Set,
453
- WeakMap = _WeakMap,
454
- baseGetTag$2 = _baseGetTag,
455
- toSource = _toSource;
456
-
457
- /** `Object#toString` result references. */
458
- var mapTag$2 = '[object Map]',
459
- objectTag$1 = '[object Object]',
460
- promiseTag = '[object Promise]',
461
- setTag$2 = '[object Set]',
462
- weakMapTag$1 = '[object WeakMap]';
463
-
464
- var dataViewTag$1 = '[object DataView]';
465
-
466
- /** Used to detect maps, sets, and weakmaps. */
467
- var dataViewCtorString = toSource(DataView),
468
- mapCtorString = toSource(Map$1),
469
- promiseCtorString = toSource(Promise$1),
470
- setCtorString = toSource(Set),
471
- weakMapCtorString = toSource(WeakMap);
472
-
473
- /**
474
- * Gets the `toStringTag` of `value`.
475
- *
476
- * @private
477
- * @param {*} value The value to query.
478
- * @returns {string} Returns the `toStringTag`.
479
- */
480
- var getTag$1 = baseGetTag$2;
481
-
482
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
483
- if ((DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
484
- (Map$1 && getTag$1(new Map$1) != mapTag$2) ||
485
- (Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag) ||
486
- (Set && getTag$1(new Set) != setTag$2) ||
487
- (WeakMap && getTag$1(new WeakMap) != weakMapTag$1)) {
488
- getTag$1 = function(value) {
489
- var result = baseGetTag$2(value),
490
- Ctor = result == objectTag$1 ? value.constructor : undefined,
491
- ctorString = Ctor ? toSource(Ctor) : '';
492
-
493
- if (ctorString) {
494
- switch (ctorString) {
495
- case dataViewCtorString: return dataViewTag$1;
496
- case mapCtorString: return mapTag$2;
497
- case promiseCtorString: return promiseTag;
498
- case setCtorString: return setTag$2;
499
- case weakMapCtorString: return weakMapTag$1;
500
- }
501
- }
502
- return result;
503
- };
504
- }
505
-
506
- var _getTag = getTag$1;
507
-
508
- /**
509
- * Checks if `value` is object-like. A value is object-like if it's not `null`
510
- * and has a `typeof` result of "object".
511
- *
512
- * @static
513
- * @memberOf _
514
- * @since 4.0.0
515
- * @category Lang
516
- * @param {*} value The value to check.
517
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
518
- * @example
519
- *
520
- * _.isObjectLike({});
521
- * // => true
522
- *
523
- * _.isObjectLike([1, 2, 3]);
524
- * // => true
525
- *
526
- * _.isObjectLike(_.noop);
527
- * // => false
528
- *
529
- * _.isObjectLike(null);
530
- * // => false
531
- */
532
-
533
- function isObjectLike$3(value) {
534
- return value != null && typeof value == 'object';
535
- }
536
-
537
- var isObjectLike_1 = isObjectLike$3;
538
-
539
- var baseGetTag$1 = _baseGetTag,
540
- isObjectLike$2 = isObjectLike_1;
541
-
542
- /** `Object#toString` result references. */
543
- var argsTag$1 = '[object Arguments]';
544
-
545
- /**
546
- * The base implementation of `_.isArguments`.
547
- *
548
- * @private
549
- * @param {*} value The value to check.
550
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
551
- */
552
- function baseIsArguments$1(value) {
553
- return isObjectLike$2(value) && baseGetTag$1(value) == argsTag$1;
554
- }
555
-
556
- var _baseIsArguments = baseIsArguments$1;
557
-
558
- var baseIsArguments = _baseIsArguments,
559
- isObjectLike$1 = isObjectLike_1;
560
-
561
- /** Used for built-in method references. */
562
- var objectProto$3 = Object.prototype;
563
-
564
- /** Used to check objects for own properties. */
565
- var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
566
-
567
- /** Built-in value references. */
568
- var propertyIsEnumerable = objectProto$3.propertyIsEnumerable;
569
-
570
- /**
571
- * Checks if `value` is likely an `arguments` object.
572
- *
573
- * @static
574
- * @memberOf _
575
- * @since 0.1.0
576
- * @category Lang
577
- * @param {*} value The value to check.
578
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
579
- * else `false`.
580
- * @example
581
- *
582
- * _.isArguments(function() { return arguments; }());
583
- * // => true
584
- *
585
- * _.isArguments([1, 2, 3]);
586
- * // => false
587
- */
588
- var isArguments$1 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
589
- return isObjectLike$1(value) && hasOwnProperty$3.call(value, 'callee') &&
590
- !propertyIsEnumerable.call(value, 'callee');
591
- };
592
-
593
- var isArguments_1 = isArguments$1;
594
-
595
- /**
596
- * Checks if `value` is classified as an `Array` object.
597
- *
598
- * @static
599
- * @memberOf _
600
- * @since 0.1.0
601
- * @category Lang
602
- * @param {*} value The value to check.
603
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
604
- * @example
605
- *
606
- * _.isArray([1, 2, 3]);
607
- * // => true
608
- *
609
- * _.isArray(document.body.children);
610
- * // => false
611
- *
612
- * _.isArray('abc');
613
- * // => false
614
- *
615
- * _.isArray(_.noop);
616
- * // => false
617
- */
618
-
619
- var isArray$1 = Array.isArray;
620
-
621
- var isArray_1 = isArray$1;
622
-
623
- /** Used as references for various `Number` constants. */
624
-
625
- var MAX_SAFE_INTEGER = 9007199254740991;
626
-
627
- /**
628
- * Checks if `value` is a valid array-like length.
629
- *
630
- * **Note:** This method is loosely based on
631
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
632
- *
633
- * @static
634
- * @memberOf _
635
- * @since 4.0.0
636
- * @category Lang
637
- * @param {*} value The value to check.
638
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
639
- * @example
640
- *
641
- * _.isLength(3);
642
- * // => true
643
- *
644
- * _.isLength(Number.MIN_VALUE);
645
- * // => false
646
- *
647
- * _.isLength(Infinity);
648
- * // => false
649
- *
650
- * _.isLength('3');
651
- * // => false
652
- */
653
- function isLength$2(value) {
654
- return typeof value == 'number' &&
655
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
656
- }
657
-
658
- var isLength_1 = isLength$2;
659
-
660
- var isFunction = isFunction_1,
661
- isLength$1 = isLength_1;
662
-
663
- /**
664
- * Checks if `value` is array-like. A value is considered array-like if it's
665
- * not a function and has a `value.length` that's an integer greater than or
666
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
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 array-like, else `false`.
674
- * @example
675
- *
676
- * _.isArrayLike([1, 2, 3]);
677
- * // => true
678
- *
679
- * _.isArrayLike(document.body.children);
680
- * // => true
681
- *
682
- * _.isArrayLike('abc');
683
- * // => true
684
- *
685
- * _.isArrayLike(_.noop);
686
- * // => false
687
- */
688
- function isArrayLike$1(value) {
689
- return value != null && isLength$1(value.length) && !isFunction(value);
690
- }
691
-
692
- var isArrayLike_1 = isArrayLike$1;
693
-
694
- var isBuffer$1 = {exports: {}};
695
-
696
- /**
697
- * This method returns `false`.
698
- *
699
- * @static
700
- * @memberOf _
701
- * @since 4.13.0
702
- * @category Util
703
- * @returns {boolean} Returns `false`.
704
- * @example
705
- *
706
- * _.times(2, _.stubFalse);
707
- * // => [false, false]
708
- */
709
-
710
- function stubFalse() {
711
- return false;
712
- }
713
-
714
- var stubFalse_1 = stubFalse;
715
-
716
- (function (module, exports) {
717
- var root = _root,
718
- stubFalse = stubFalse_1;
719
-
720
- /** Detect free variable `exports`. */
721
- var freeExports = exports && !exports.nodeType && exports;
722
-
723
- /** Detect free variable `module`. */
724
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
725
-
726
- /** Detect the popular CommonJS extension `module.exports`. */
727
- var moduleExports = freeModule && freeModule.exports === freeExports;
728
-
729
- /** Built-in value references. */
730
- var Buffer = moduleExports ? root.Buffer : undefined;
731
-
732
- /* Built-in method references for those with the same name as other `lodash` methods. */
733
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
734
-
735
- /**
736
- * Checks if `value` is a buffer.
737
- *
738
- * @static
739
- * @memberOf _
740
- * @since 4.3.0
741
- * @category Lang
742
- * @param {*} value The value to check.
743
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
744
- * @example
745
- *
746
- * _.isBuffer(new Buffer(2));
747
- * // => true
748
- *
749
- * _.isBuffer(new Uint8Array(2));
750
- * // => false
751
- */
752
- var isBuffer = nativeIsBuffer || stubFalse;
753
-
754
- module.exports = isBuffer;
755
- }(isBuffer$1, isBuffer$1.exports));
756
-
757
- var baseGetTag = _baseGetTag,
758
- isLength = isLength_1,
759
- isObjectLike = isObjectLike_1;
760
-
761
- /** `Object#toString` result references. */
762
- var argsTag = '[object Arguments]',
763
- arrayTag = '[object Array]',
764
- boolTag = '[object Boolean]',
765
- dateTag = '[object Date]',
766
- errorTag = '[object Error]',
767
- funcTag = '[object Function]',
768
- mapTag$1 = '[object Map]',
769
- numberTag = '[object Number]',
770
- objectTag = '[object Object]',
771
- regexpTag = '[object RegExp]',
772
- setTag$1 = '[object Set]',
773
- stringTag = '[object String]',
774
- weakMapTag = '[object WeakMap]';
775
-
776
- var arrayBufferTag = '[object ArrayBuffer]',
777
- dataViewTag = '[object DataView]',
778
- float32Tag = '[object Float32Array]',
779
- float64Tag = '[object Float64Array]',
780
- int8Tag = '[object Int8Array]',
781
- int16Tag = '[object Int16Array]',
782
- int32Tag = '[object Int32Array]',
783
- uint8Tag = '[object Uint8Array]',
784
- uint8ClampedTag = '[object Uint8ClampedArray]',
785
- uint16Tag = '[object Uint16Array]',
786
- uint32Tag = '[object Uint32Array]';
787
-
788
- /** Used to identify `toStringTag` values of typed arrays. */
789
- var typedArrayTags = {};
790
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
791
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
792
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
793
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
794
- typedArrayTags[uint32Tag] = true;
795
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
796
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
797
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
798
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
799
- typedArrayTags[mapTag$1] = typedArrayTags[numberTag] =
800
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
801
- typedArrayTags[setTag$1] = typedArrayTags[stringTag] =
802
- typedArrayTags[weakMapTag] = false;
803
-
804
- /**
805
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
806
- *
807
- * @private
808
- * @param {*} value The value to check.
809
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
810
- */
811
- function baseIsTypedArray$1(value) {
812
- return isObjectLike(value) &&
813
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
814
- }
815
-
816
- var _baseIsTypedArray = baseIsTypedArray$1;
817
-
818
- /**
819
- * The base implementation of `_.unary` without support for storing metadata.
820
- *
821
- * @private
822
- * @param {Function} func The function to cap arguments for.
823
- * @returns {Function} Returns the new capped function.
824
- */
825
-
826
- function baseUnary$1(func) {
827
- return function(value) {
828
- return func(value);
829
- };
830
- }
831
-
832
- var _baseUnary = baseUnary$1;
833
-
834
- var _nodeUtil = {exports: {}};
835
-
836
- (function (module, exports) {
837
- var freeGlobal = _freeGlobal;
838
-
839
- /** Detect free variable `exports`. */
840
- var freeExports = exports && !exports.nodeType && exports;
841
-
842
- /** Detect free variable `module`. */
843
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
844
-
845
- /** Detect the popular CommonJS extension `module.exports`. */
846
- var moduleExports = freeModule && freeModule.exports === freeExports;
847
-
848
- /** Detect free variable `process` from Node.js. */
849
- var freeProcess = moduleExports && freeGlobal.process;
850
-
851
- /** Used to access faster Node.js helpers. */
852
- var nodeUtil = (function() {
853
- try {
854
- // Use `util.types` for Node.js 10+.
855
- var types = freeModule && freeModule.require && freeModule.require('util').types;
856
-
857
- if (types) {
858
- return types;
859
- }
860
-
861
- // Legacy `process.binding('util')` for Node.js < 10.
862
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
863
- } catch (e) {}
864
- }());
865
-
866
- module.exports = nodeUtil;
867
- }(_nodeUtil, _nodeUtil.exports));
868
-
869
- var baseIsTypedArray = _baseIsTypedArray,
870
- baseUnary = _baseUnary,
871
- nodeUtil = _nodeUtil.exports;
872
-
873
- /* Node.js helper references. */
874
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
875
-
876
- /**
877
- * Checks if `value` is classified as a typed array.
878
- *
879
- * @static
880
- * @memberOf _
881
- * @since 3.0.0
882
- * @category Lang
883
- * @param {*} value The value to check.
884
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
885
- * @example
886
- *
887
- * _.isTypedArray(new Uint8Array);
888
- * // => true
889
- *
890
- * _.isTypedArray([]);
891
- * // => false
892
- */
893
- var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
894
-
895
- var isTypedArray_1 = isTypedArray$1;
896
-
897
- var baseKeys = _baseKeys,
898
- getTag = _getTag,
899
- isArguments = isArguments_1,
900
- isArray = isArray_1,
901
- isArrayLike = isArrayLike_1,
902
- isBuffer = isBuffer$1.exports,
903
- isPrototype = _isPrototype,
904
- isTypedArray = isTypedArray_1;
905
-
906
- /** `Object#toString` result references. */
907
- var mapTag = '[object Map]',
908
- setTag = '[object Set]';
909
-
910
- /** Used for built-in method references. */
911
- var objectProto$2 = Object.prototype;
912
-
913
- /** Used to check objects for own properties. */
914
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
915
-
916
- /**
917
- * Checks if `value` is an empty object, collection, map, or set.
918
- *
919
- * Objects are considered empty if they have no own enumerable string keyed
920
- * properties.
921
- *
922
- * Array-like values such as `arguments` objects, arrays, buffers, strings, or
923
- * jQuery-like collections are considered empty if they have a `length` of `0`.
924
- * Similarly, maps and sets are considered empty if they have a `size` of `0`.
925
- *
926
- * @static
927
- * @memberOf _
928
- * @since 0.1.0
929
- * @category Lang
930
- * @param {*} value The value to check.
931
- * @returns {boolean} Returns `true` if `value` is empty, else `false`.
932
- * @example
933
- *
934
- * _.isEmpty(null);
935
- * // => true
936
- *
937
- * _.isEmpty(true);
938
- * // => true
939
- *
940
- * _.isEmpty(1);
941
- * // => true
942
- *
943
- * _.isEmpty([1, 2, 3]);
944
- * // => false
945
- *
946
- * _.isEmpty({ 'a': 1 });
947
- * // => false
948
- */
949
- function isEmpty(value) {
950
- if (value == null) {
951
- return true;
952
- }
953
- if (isArrayLike(value) &&
954
- (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
955
- isBuffer(value) || isTypedArray(value) || isArguments(value))) {
956
- return !value.length;
957
- }
958
- var tag = getTag(value);
959
- if (tag == mapTag || tag == setTag) {
960
- return !value.size;
961
- }
962
- if (isPrototype(value)) {
963
- return !baseKeys(value).length;
964
- }
965
- for (var key in value) {
966
- if (hasOwnProperty$2.call(value, key)) {
967
- return false;
968
- }
969
- }
970
- return true;
971
- }
972
-
973
- var isEmpty_1 = isEmpty;
974
-
975
- const defaults$1 = {
976
- correct: { type: 'default', default: 'Correct', custom: 'Correct' },
977
- incorrect: { type: 'default', default: 'Incorrect', custom: 'Incorrect' },
978
- partial: { type: 'default', default: 'Nearly', custom: 'Nearly' },
979
- unanswered: {
980
- type: 'default',
981
- default: 'You have not entered a response',
982
- custom: 'You have not entered a response',
983
- },
984
- };
985
-
986
- /**
987
- * @typedef {Object} FeedbackConfig
988
- * @property {'default'|'none'|'custom'} type
989
- * @property {string} default
990
- * @property {string} custom
991
- *
992
- * @typedef {Object} Feedback
993
- * @property {FeedbackConfig} correct
994
- * @property {FeedbackConfig} incorrect
995
- * @property {FeedbackConfig} partial
996
- */
997
-
998
- const normalizeCorrectness = (c) => {
999
- if (c === 'partially-correct') {
1000
- return 'partial';
1001
- }
1002
- return c;
1003
- };
1004
-
1005
- /**
1006
- * Get the feedback for the correctness
1007
- *
1008
- * @param {'correct'|'incorrect'|'partial'} correctness
1009
- * @param {Feedback} feedback
1010
- */
1011
- const getFeedbackForCorrectness = (correctness, feedback) =>
1012
- new Promise((resolve) => {
1013
- feedback = { ...defaults$1, ...feedback };
1014
- correctness = normalizeCorrectness(correctness);
1015
- const fb = feedback[correctness] || defaults$1[correctness] || {};
1016
- const d = defaults$1[correctness] || {};
1017
- getFeedback(fb, d[fb.type || 'default']).then((result) => resolve(result));
1018
- });
1019
-
1020
- /**
1021
- * Get the feedback from a {FeedbackConfig}
1022
- *
1023
- * @param {FeedbackConfig} feedback
1024
- * @param {string} fallback
1025
- */
1026
- const getFeedback = (feedback, fallback) =>
1027
- new Promise((resolve) => {
1028
- if (!feedback || feedback.type === 'none') {
1029
- resolve(undefined);
1030
- return;
1031
- }
1032
- feedback = feedback || {};
1033
- const out = feedback[feedback.type] || fallback;
1034
- resolve(out);
1035
- });
1036
-
1037
- const enabled = (config, env, defaultValue) => {
1038
- // if model.partialScoring = false
1039
- // - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
1040
- // else if model.partialScoring = true || undefined
1041
- // - if env.partialScoring = false, use dichotomous scoring
1042
- // - else if env.partialScoring = true, use partial scoring
1043
- config = config || {};
1044
- env = env || {};
1045
-
1046
- if (config.partialScoring === false) {
1047
- return false;
1048
- }
1049
-
1050
- if (env.partialScoring === false) {
1051
- return false;
1052
- }
1053
-
1054
- return typeof defaultValue === 'boolean' ? defaultValue : true;
1055
- };
1056
-
1057
- var getNative = _getNative;
1058
-
1059
- /* Built-in method references that are verified to be native. */
1060
- var nativeCreate$4 = getNative(Object, 'create');
1061
-
1062
- var _nativeCreate = nativeCreate$4;
1063
-
1064
- var nativeCreate$3 = _nativeCreate;
1065
-
1066
- /**
1067
- * Removes all key-value entries from the hash.
1068
- *
1069
- * @private
1070
- * @name clear
1071
- * @memberOf Hash
1072
- */
1073
- function hashClear$1() {
1074
- this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
1075
- this.size = 0;
1076
- }
1077
-
1078
- var _hashClear = hashClear$1;
1079
-
1080
- /**
1081
- * Removes `key` and its value from the hash.
1082
- *
1083
- * @private
1084
- * @name delete
1085
- * @memberOf Hash
1086
- * @param {Object} hash The hash to modify.
1087
- * @param {string} key The key of the value to remove.
1088
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1089
- */
1090
-
1091
- function hashDelete$1(key) {
1092
- var result = this.has(key) && delete this.__data__[key];
1093
- this.size -= result ? 1 : 0;
1094
- return result;
1095
- }
1096
-
1097
- var _hashDelete = hashDelete$1;
1098
-
1099
- var nativeCreate$2 = _nativeCreate;
1100
-
1101
- /** Used to stand-in for `undefined` hash values. */
1102
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1103
-
1104
- /** Used for built-in method references. */
1105
- var objectProto$1 = Object.prototype;
1106
-
1107
- /** Used to check objects for own properties. */
1108
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
1109
-
1110
- /**
1111
- * Gets the hash value for `key`.
1112
- *
1113
- * @private
1114
- * @name get
1115
- * @memberOf Hash
1116
- * @param {string} key The key of the value to get.
1117
- * @returns {*} Returns the entry value.
1118
- */
1119
- function hashGet$1(key) {
1120
- var data = this.__data__;
1121
- if (nativeCreate$2) {
1122
- var result = data[key];
1123
- return result === HASH_UNDEFINED$1 ? undefined : result;
1124
- }
1125
- return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
1126
- }
1127
-
1128
- var _hashGet = hashGet$1;
1129
-
1130
- var nativeCreate$1 = _nativeCreate;
1131
-
1132
- /** Used for built-in method references. */
1133
- var objectProto = Object.prototype;
1134
-
1135
- /** Used to check objects for own properties. */
1136
- var hasOwnProperty = objectProto.hasOwnProperty;
1137
-
1138
- /**
1139
- * Checks if a hash value for `key` exists.
1140
- *
1141
- * @private
1142
- * @name has
1143
- * @memberOf Hash
1144
- * @param {string} key The key of the entry to check.
1145
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1146
- */
1147
- function hashHas$1(key) {
1148
- var data = this.__data__;
1149
- return nativeCreate$1 ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
1150
- }
1151
-
1152
- var _hashHas = hashHas$1;
1153
-
1154
- var nativeCreate = _nativeCreate;
1155
-
1156
- /** Used to stand-in for `undefined` hash values. */
1157
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
1158
-
1159
- /**
1160
- * Sets the hash `key` to `value`.
1161
- *
1162
- * @private
1163
- * @name set
1164
- * @memberOf Hash
1165
- * @param {string} key The key of the value to set.
1166
- * @param {*} value The value to set.
1167
- * @returns {Object} Returns the hash instance.
1168
- */
1169
- function hashSet$1(key, value) {
1170
- var data = this.__data__;
1171
- this.size += this.has(key) ? 0 : 1;
1172
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1173
- return this;
1174
- }
1175
-
1176
- var _hashSet = hashSet$1;
1177
-
1178
- var hashClear = _hashClear,
1179
- hashDelete = _hashDelete,
1180
- hashGet = _hashGet,
1181
- hashHas = _hashHas,
1182
- hashSet = _hashSet;
1183
-
1184
- /**
1185
- * Creates a hash object.
1186
- *
1187
- * @private
1188
- * @constructor
1189
- * @param {Array} [entries] The key-value pairs to cache.
1190
- */
1191
- function Hash$1(entries) {
1192
- var index = -1,
1193
- length = entries == null ? 0 : entries.length;
1194
-
1195
- this.clear();
1196
- while (++index < length) {
1197
- var entry = entries[index];
1198
- this.set(entry[0], entry[1]);
1199
- }
1200
- }
1201
-
1202
- // Add methods to `Hash`.
1203
- Hash$1.prototype.clear = hashClear;
1204
- Hash$1.prototype['delete'] = hashDelete;
1205
- Hash$1.prototype.get = hashGet;
1206
- Hash$1.prototype.has = hashHas;
1207
- Hash$1.prototype.set = hashSet;
1208
-
1209
- var _Hash = Hash$1;
1210
-
1211
- /**
1212
- * Removes all key-value entries from the list cache.
1213
- *
1214
- * @private
1215
- * @name clear
1216
- * @memberOf ListCache
1217
- */
1218
-
1219
- function listCacheClear$1() {
1220
- this.__data__ = [];
1221
- this.size = 0;
1222
- }
1223
-
1224
- var _listCacheClear = listCacheClear$1;
1225
-
1226
- /**
1227
- * Performs a
1228
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1229
- * comparison between two values to determine if they are equivalent.
1230
- *
1231
- * @static
1232
- * @memberOf _
1233
- * @since 4.0.0
1234
- * @category Lang
1235
- * @param {*} value The value to compare.
1236
- * @param {*} other The other value to compare.
1237
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1238
- * @example
1239
- *
1240
- * var object = { 'a': 1 };
1241
- * var other = { 'a': 1 };
1242
- *
1243
- * _.eq(object, object);
1244
- * // => true
1245
- *
1246
- * _.eq(object, other);
1247
- * // => false
1248
- *
1249
- * _.eq('a', 'a');
1250
- * // => true
1251
- *
1252
- * _.eq('a', Object('a'));
1253
- * // => false
1254
- *
1255
- * _.eq(NaN, NaN);
1256
- * // => true
1257
- */
1258
-
1259
- function eq$1(value, other) {
1260
- return value === other || (value !== value && other !== other);
1261
- }
1262
-
1263
- var eq_1 = eq$1;
1264
-
1265
- var eq = eq_1;
1266
-
1267
- /**
1268
- * Gets the index at which the `key` is found in `array` of key-value pairs.
1269
- *
1270
- * @private
1271
- * @param {Array} array The array to inspect.
1272
- * @param {*} key The key to search for.
1273
- * @returns {number} Returns the index of the matched value, else `-1`.
1274
- */
1275
- function assocIndexOf$4(array, key) {
1276
- var length = array.length;
1277
- while (length--) {
1278
- if (eq(array[length][0], key)) {
1279
- return length;
1280
- }
1281
- }
1282
- return -1;
1283
- }
1284
-
1285
- var _assocIndexOf = assocIndexOf$4;
1286
-
1287
- var assocIndexOf$3 = _assocIndexOf;
1288
-
1289
- /** Used for built-in method references. */
1290
- var arrayProto = Array.prototype;
1291
-
1292
- /** Built-in value references. */
1293
- var splice = arrayProto.splice;
1294
-
1295
- /**
1296
- * Removes `key` and its value from the list cache.
1297
- *
1298
- * @private
1299
- * @name delete
1300
- * @memberOf ListCache
1301
- * @param {string} key The key of the value to remove.
1302
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1303
- */
1304
- function listCacheDelete$1(key) {
1305
- var data = this.__data__,
1306
- index = assocIndexOf$3(data, key);
1307
-
1308
- if (index < 0) {
1309
- return false;
1310
- }
1311
- var lastIndex = data.length - 1;
1312
- if (index == lastIndex) {
1313
- data.pop();
1314
- } else {
1315
- splice.call(data, index, 1);
1316
- }
1317
- --this.size;
1318
- return true;
1319
- }
1320
-
1321
- var _listCacheDelete = listCacheDelete$1;
1322
-
1323
- var assocIndexOf$2 = _assocIndexOf;
1324
-
1325
- /**
1326
- * Gets the list cache value for `key`.
1327
- *
1328
- * @private
1329
- * @name get
1330
- * @memberOf ListCache
1331
- * @param {string} key The key of the value to get.
1332
- * @returns {*} Returns the entry value.
1333
- */
1334
- function listCacheGet$1(key) {
1335
- var data = this.__data__,
1336
- index = assocIndexOf$2(data, key);
1337
-
1338
- return index < 0 ? undefined : data[index][1];
1339
- }
1340
-
1341
- var _listCacheGet = listCacheGet$1;
1342
-
1343
- var assocIndexOf$1 = _assocIndexOf;
1344
-
1345
- /**
1346
- * Checks if a list cache value for `key` exists.
1347
- *
1348
- * @private
1349
- * @name has
1350
- * @memberOf ListCache
1351
- * @param {string} key The key of the entry to check.
1352
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1353
- */
1354
- function listCacheHas$1(key) {
1355
- return assocIndexOf$1(this.__data__, key) > -1;
1356
- }
1357
-
1358
- var _listCacheHas = listCacheHas$1;
1359
-
1360
- var assocIndexOf = _assocIndexOf;
1361
-
1362
- /**
1363
- * Sets the list cache `key` to `value`.
1364
- *
1365
- * @private
1366
- * @name set
1367
- * @memberOf ListCache
1368
- * @param {string} key The key of the value to set.
1369
- * @param {*} value The value to set.
1370
- * @returns {Object} Returns the list cache instance.
1371
- */
1372
- function listCacheSet$1(key, value) {
1373
- var data = this.__data__,
1374
- index = assocIndexOf(data, key);
1375
-
1376
- if (index < 0) {
1377
- ++this.size;
1378
- data.push([key, value]);
1379
- } else {
1380
- data[index][1] = value;
1381
- }
1382
- return this;
1383
- }
1384
-
1385
- var _listCacheSet = listCacheSet$1;
1386
-
1387
- var listCacheClear = _listCacheClear,
1388
- listCacheDelete = _listCacheDelete,
1389
- listCacheGet = _listCacheGet,
1390
- listCacheHas = _listCacheHas,
1391
- listCacheSet = _listCacheSet;
1392
-
1393
- /**
1394
- * Creates an list cache object.
1395
- *
1396
- * @private
1397
- * @constructor
1398
- * @param {Array} [entries] The key-value pairs to cache.
1399
- */
1400
- function ListCache$1(entries) {
1401
- var index = -1,
1402
- length = entries == null ? 0 : entries.length;
1403
-
1404
- this.clear();
1405
- while (++index < length) {
1406
- var entry = entries[index];
1407
- this.set(entry[0], entry[1]);
1408
- }
1409
- }
1410
-
1411
- // Add methods to `ListCache`.
1412
- ListCache$1.prototype.clear = listCacheClear;
1413
- ListCache$1.prototype['delete'] = listCacheDelete;
1414
- ListCache$1.prototype.get = listCacheGet;
1415
- ListCache$1.prototype.has = listCacheHas;
1416
- ListCache$1.prototype.set = listCacheSet;
1417
-
1418
- var _ListCache = ListCache$1;
1419
-
1420
- var Hash = _Hash,
1421
- ListCache = _ListCache,
1422
- Map = _Map;
1423
-
1424
- /**
1425
- * Removes all key-value entries from the map.
1426
- *
1427
- * @private
1428
- * @name clear
1429
- * @memberOf MapCache
1430
- */
1431
- function mapCacheClear$1() {
1432
- this.size = 0;
1433
- this.__data__ = {
1434
- 'hash': new Hash,
1435
- 'map': new (Map || ListCache),
1436
- 'string': new Hash
1437
- };
1438
- }
1439
-
1440
- var _mapCacheClear = mapCacheClear$1;
1441
-
1442
- /**
1443
- * Checks if `value` is suitable for use as unique object key.
1444
- *
1445
- * @private
1446
- * @param {*} value The value to check.
1447
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1448
- */
1449
-
1450
- function isKeyable$1(value) {
1451
- var type = typeof value;
1452
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1453
- ? (value !== '__proto__')
1454
- : (value === null);
1455
- }
1456
-
1457
- var _isKeyable = isKeyable$1;
1458
-
1459
- var isKeyable = _isKeyable;
1460
-
1461
- /**
1462
- * Gets the data for `map`.
1463
- *
1464
- * @private
1465
- * @param {Object} map The map to query.
1466
- * @param {string} key The reference key.
1467
- * @returns {*} Returns the map data.
1468
- */
1469
- function getMapData$4(map, key) {
1470
- var data = map.__data__;
1471
- return isKeyable(key)
1472
- ? data[typeof key == 'string' ? 'string' : 'hash']
1473
- : data.map;
1474
- }
1475
-
1476
- var _getMapData = getMapData$4;
1477
-
1478
- var getMapData$3 = _getMapData;
1479
-
1480
- /**
1481
- * Removes `key` and its value from the map.
1482
- *
1483
- * @private
1484
- * @name delete
1485
- * @memberOf MapCache
1486
- * @param {string} key The key of the value to remove.
1487
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1488
- */
1489
- function mapCacheDelete$1(key) {
1490
- var result = getMapData$3(this, key)['delete'](key);
1491
- this.size -= result ? 1 : 0;
1492
- return result;
1493
- }
1494
-
1495
- var _mapCacheDelete = mapCacheDelete$1;
1496
-
1497
- var getMapData$2 = _getMapData;
1498
-
1499
- /**
1500
- * Gets the map value for `key`.
1501
- *
1502
- * @private
1503
- * @name get
1504
- * @memberOf MapCache
1505
- * @param {string} key The key of the value to get.
1506
- * @returns {*} Returns the entry value.
1507
- */
1508
- function mapCacheGet$1(key) {
1509
- return getMapData$2(this, key).get(key);
1510
- }
1511
-
1512
- var _mapCacheGet = mapCacheGet$1;
1513
-
1514
- var getMapData$1 = _getMapData;
1515
-
1516
- /**
1517
- * Checks if a map value for `key` exists.
1518
- *
1519
- * @private
1520
- * @name has
1521
- * @memberOf MapCache
1522
- * @param {string} key The key of the entry to check.
1523
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1524
- */
1525
- function mapCacheHas$1(key) {
1526
- return getMapData$1(this, key).has(key);
1527
- }
1528
-
1529
- var _mapCacheHas = mapCacheHas$1;
1530
-
1531
- var getMapData = _getMapData;
1532
-
1533
- /**
1534
- * Sets the map `key` to `value`.
1535
- *
1536
- * @private
1537
- * @name set
1538
- * @memberOf MapCache
1539
- * @param {string} key The key of the value to set.
1540
- * @param {*} value The value to set.
1541
- * @returns {Object} Returns the map cache instance.
1542
- */
1543
- function mapCacheSet$1(key, value) {
1544
- var data = getMapData(this, key),
1545
- size = data.size;
1546
-
1547
- data.set(key, value);
1548
- this.size += data.size == size ? 0 : 1;
1549
- return this;
1550
- }
1551
-
1552
- var _mapCacheSet = mapCacheSet$1;
1553
-
1554
- var mapCacheClear = _mapCacheClear,
1555
- mapCacheDelete = _mapCacheDelete,
1556
- mapCacheGet = _mapCacheGet,
1557
- mapCacheHas = _mapCacheHas,
1558
- mapCacheSet = _mapCacheSet;
1559
-
1560
- /**
1561
- * Creates a map cache object to store key-value pairs.
1562
- *
1563
- * @private
1564
- * @constructor
1565
- * @param {Array} [entries] The key-value pairs to cache.
1566
- */
1567
- function MapCache$1(entries) {
1568
- var index = -1,
1569
- length = entries == null ? 0 : entries.length;
1570
-
1571
- this.clear();
1572
- while (++index < length) {
1573
- var entry = entries[index];
1574
- this.set(entry[0], entry[1]);
1575
- }
1576
- }
1577
-
1578
- // Add methods to `MapCache`.
1579
- MapCache$1.prototype.clear = mapCacheClear;
1580
- MapCache$1.prototype['delete'] = mapCacheDelete;
1581
- MapCache$1.prototype.get = mapCacheGet;
1582
- MapCache$1.prototype.has = mapCacheHas;
1583
- MapCache$1.prototype.set = mapCacheSet;
1584
-
1585
- var _MapCache = MapCache$1;
1586
-
1587
- var MapCache = _MapCache;
1588
-
1589
- /** Error message constants. */
1590
- var FUNC_ERROR_TEXT = 'Expected a function';
1591
-
1592
- /**
1593
- * Creates a function that memoizes the result of `func`. If `resolver` is
1594
- * provided, it determines the cache key for storing the result based on the
1595
- * arguments provided to the memoized function. By default, the first argument
1596
- * provided to the memoized function is used as the map cache key. The `func`
1597
- * is invoked with the `this` binding of the memoized function.
1598
- *
1599
- * **Note:** The cache is exposed as the `cache` property on the memoized
1600
- * function. Its creation may be customized by replacing the `_.memoize.Cache`
1601
- * constructor with one whose instances implement the
1602
- * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
1603
- * method interface of `clear`, `delete`, `get`, `has`, and `set`.
1604
- *
1605
- * @static
1606
- * @memberOf _
1607
- * @since 0.1.0
1608
- * @category Function
1609
- * @param {Function} func The function to have its output memoized.
1610
- * @param {Function} [resolver] The function to resolve the cache key.
1611
- * @returns {Function} Returns the new memoized function.
1612
- * @example
1613
- *
1614
- * var object = { 'a': 1, 'b': 2 };
1615
- * var other = { 'c': 3, 'd': 4 };
1616
- *
1617
- * var values = _.memoize(_.values);
1618
- * values(object);
1619
- * // => [1, 2]
1620
- *
1621
- * values(other);
1622
- * // => [3, 4]
1623
- *
1624
- * object.a = 2;
1625
- * values(object);
1626
- * // => [1, 2]
1627
- *
1628
- * // Modify the result cache.
1629
- * values.cache.set(object, ['a', 'b']);
1630
- * values(object);
1631
- * // => ['a', 'b']
1632
- *
1633
- * // Replace `_.memoize.Cache`.
1634
- * _.memoize.Cache = WeakMap;
1635
- */
1636
- function memoize$1(func, resolver) {
1637
- if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
1638
- throw new TypeError(FUNC_ERROR_TEXT);
1639
- }
1640
- var memoized = function() {
1641
- var args = arguments,
1642
- key = resolver ? resolver.apply(this, args) : args[0],
1643
- cache = memoized.cache;
1644
-
1645
- if (cache.has(key)) {
1646
- return cache.get(key);
1647
- }
1648
- var result = func.apply(this, args);
1649
- memoized.cache = cache.set(key, result) || cache;
1650
- return result;
1651
- };
1652
- memoized.cache = new (memoize$1.Cache || MapCache);
1653
- return memoized;
1654
- }
1655
-
1656
- // Expose `MapCache`.
1657
- memoize$1.Cache = MapCache;
1658
-
1659
- var memoize_1 = memoize$1;
1660
-
1661
- var memoize = memoize_1;
1662
-
1663
- /** Used as the maximum memoize cache size. */
1664
- var MAX_MEMOIZE_SIZE = 500;
1665
-
1666
- /**
1667
- * A specialized version of `_.memoize` which clears the memoized function's
1668
- * cache when it exceeds `MAX_MEMOIZE_SIZE`.
1669
- *
1670
- * @private
1671
- * @param {Function} func The function to have its output memoized.
1672
- * @returns {Function} Returns the new memoized function.
1673
- */
1674
- function memoizeCapped$1(func) {
1675
- var result = memoize(func, function(key) {
1676
- if (cache.size === MAX_MEMOIZE_SIZE) {
1677
- cache.clear();
1678
- }
1679
- return key;
1680
- });
1681
-
1682
- var cache = result.cache;
1683
- return result;
1684
- }
1685
-
1686
- var _memoizeCapped = memoizeCapped$1;
1687
-
1688
- var memoizeCapped = _memoizeCapped;
1689
-
1690
- /** Used to match property names within property paths. */
1691
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
1692
-
1693
- /** Used to match backslashes in property paths. */
1694
- var reEscapeChar = /\\(\\)?/g;
1695
-
1696
- /**
1697
- * Converts `string` to a property path array.
1698
- *
1699
- * @private
1700
- * @param {string} string The string to convert.
1701
- * @returns {Array} Returns the property path array.
1702
- */
1703
- memoizeCapped(function(string) {
1704
- var result = [];
1705
- if (string.charCodeAt(0) === 46 /* . */) {
1706
- result.push('');
1707
- }
1708
- string.replace(rePropName, function(match, number, quote, subString) {
1709
- result.push(quote ? subString.replace(reEscapeChar, '$1') : (number || match));
1710
- });
1711
- return result;
1712
- });
1713
-
1714
- var Symbol = _Symbol;
1715
-
1716
- /** Used to convert symbols to primitives and strings. */
1717
- var symbolProto = Symbol ? Symbol.prototype : undefined;
1718
- symbolProto ? symbolProto.toString : undefined;
1719
-
1720
- // eslint-disable-next-line no-console
1721
- const lg = (n) => console[n].bind(console, 'controller-utils:');
1722
- lg('debug');
1723
- lg('log');
1724
- lg('warn');
1725
- lg('error');
1726
-
1727
- var defaults = {
1728
- feedbackEnabled: false,
1729
- highlightChoices: false,
1730
- maxSelections: 0,
1731
- mode: 'sentence',
1732
- partialScoring: false,
1733
- prompt: '',
1734
- promptEnabled: true,
1735
- rationale: '',
1736
- rationaleEnabled: true,
1737
- scoringType: 'auto',
1738
- studentInstructionsEnabled: true,
1739
- teacherInstructions: '',
1740
- teacherInstructionsEnabled: true,
1741
- text: '',
1742
- tokens: [],
1743
- toolbarEditorPosition: 'bottom',
1744
- };
1745
-
1746
- const equalTokens = (token1 = {}, token2 = {}) =>
1747
- (token1?.start === token2?.start && token1?.end === token2?.end) ||
1748
- // this case is used for the cases when the token's start & end were recalculated
1749
- (token1?.start === token2?.oldStart && token1?.end === token2?.oldEnd);
1750
-
1751
- const normalizeTokens = (tokens = [], selectedTokens = [], evaluateMode = false) =>
1752
- (tokens || []).map((token) => {
1753
- const isCorrect = !!token.correct;
1754
- // search if correct token is missing from session
1755
- const isMissing = isCorrect && !(selectedTokens || []).find((selectedToken) => equalTokens(token, selectedToken));
1756
-
1757
- return {
1758
- ...token,
1759
- correct: evaluateMode ? isCorrect : undefined,
1760
- isMissing: evaluateMode ? isMissing : undefined,
1761
- };
1762
- });
1763
-
1764
- const getCorrectness = (tokens, selected) => {
1765
- const correct = tokens.filter((t) => t.correct === true);
1766
-
1767
- if (correct.length === 0) {
1768
- return 'unknown';
1769
- }
1770
-
1771
- const correctSelected = getCorrectSelected(tokens, selected);
1772
-
1773
- if (correctSelected.length === selected.length) {
1774
- if (correctSelected.length === correct.length) {
1775
- return 'correct';
1776
- } else if (correctSelected.length > 0) {
1777
- return 'partially-correct';
1778
- }
1779
- }
1780
-
1781
- if (correctSelected.length > 0) {
1782
- return 'partially-correct';
1783
- }
1784
-
1785
- return 'incorrect';
1786
- };
1787
-
1788
- const getCorrectSelected = (tokens, selected) =>
1789
- (selected || []).filter((s) => tokens.findIndex((token) => token.correct && equalTokens(token, s)) !== -1);
1790
-
1791
- const getPartialScore = (question, session, totalCorrect) => {
1792
- if (!session || isEmpty_1(session)) {
1793
- return 0;
1794
- }
1795
-
1796
- const correctCount = getCorrectSelected(question.tokens, session.selectedTokens).length;
1797
- const correctTokens = (question.tokens || []).filter((t) => t.correct === true);
1798
- const extraSelected = session.selectedTokens ? session.selectedTokens.length > correctTokens.length : 0;
1799
- const incorrectCount = extraSelected ? session.selectedTokens && session.selectedTokens.length - correctCount : 0;
1800
- const count = correctCount - incorrectCount;
1801
- const positiveCount = count < 0 ? 0 : count;
1802
-
1803
- return totalCorrect.length ? parseFloat((positiveCount / totalCorrect.length).toFixed(2)) : 0;
1804
- };
1805
-
1806
- const outcome = (question, session, env) =>
1807
- new Promise((resolve) => {
1808
- if (!session || isEmpty_1(session)) {
1809
- resolve({ score: 0, empty: true });
1810
- }
1811
-
1812
- session = normalizeSession(session);
1813
-
1814
- if (env.mode !== 'evaluate') {
1815
- resolve({ score: undefined, completed: undefined });
1816
- } else {
1817
- const enabled$1 = enabled(question, env, true);
1818
- const totalCorrect = question.tokens.filter((t) => t.correct);
1819
- const score = getPartialScore(question, session, totalCorrect);
1820
- resolve({
1821
- score: enabled$1 ? score : score === 1 ? 1 : 0,
1822
- });
1823
- }
1824
- });
1825
-
1826
- function createDefaultModel(model = {}) {
1827
- return new Promise((resolve) => {
1828
- resolve({ ...defaults, ...model });
1829
- });
1830
- }
1831
-
1832
- const normalizeSession = (session) => ({ selectedTokens: [], ...session });
1833
-
1834
- const normalize = (question) => ({ ...defaults, ...question });
1835
-
1836
- const model = (question, session, env) => {
1837
- session = session || { selectedToken: [] };
1838
- session.selectedTokens = session.selectedTokens || [];
1839
- const normalizedQuestion = normalize(question);
1840
-
1841
- return new Promise((resolve) => {
1842
-
1843
- const tokens = normalizeTokens(normalizedQuestion.tokens, session.selectedTokens, env.mode === 'evaluate');
1844
-
1845
- const correctness =
1846
- env.mode === 'evaluate' ? getCorrectness(normalizedQuestion.tokens, session.selectedTokens) : undefined;
1847
-
1848
- const fb =
1849
- env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled
1850
- ? getFeedbackForCorrectness(correctness, normalizedQuestion.feedback)
1851
- : Promise.resolve(undefined);
1852
-
1853
- fb.then((feedback) => {
1854
- const out = {
1855
- tokens,
1856
- highlightChoices: normalizedQuestion.highlightChoices,
1857
- prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
1858
- text: normalizedQuestion.text,
1859
- disabled: env.mode !== 'gather',
1860
- maxSelections: normalizedQuestion.maxSelections,
1861
- correctness,
1862
- env,
1863
- feedback,
1864
- incorrect: env.mode === 'evaluate' ? correctness !== 'correct' : undefined,
1865
- language: normalizedQuestion.language,
1866
- extraCSSRules: normalizedQuestion.extraCSSRules,
1867
- };
1868
-
1869
- if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
1870
- out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
1871
- out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled
1872
- ? normalizedQuestion.teacherInstructions
1873
- : null;
1874
- } else {
1875
- out.rationale = null;
1876
- out.teacherInstructions = null;
1877
- }
1878
-
1879
- resolve(out);
1880
- });
1881
- });
1882
- };
1883
-
1884
- const createCorrectResponseSession = (question, env) => {
1885
- return new Promise((resolve) => {
1886
- if (env.mode !== 'evaluate' && env.role === 'instructor') {
1887
- const { tokens } = question;
1888
- const selectedTokens = tokens.filter((t) => t.correct);
1889
-
1890
- resolve({
1891
- id: '1',
1892
- selectedTokens,
1893
- });
1894
- } else {
1895
- resolve(null);
1896
- }
1897
- });
1898
- };
1899
-
1900
- // remove all html tags except img, iframe and source tag for audio
1901
- const getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
1902
-
1903
- const validate = (model = {}, config = {}) => {
1904
- const { tokens } = model;
1905
- const { minTokens = 2, maxTokens, maxSelections } = config;
1906
- const errors = {};
1907
- const nbOfTokens = (tokens || []).length;
1908
-
1909
- ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {
1910
- if (config[field]?.required && !getContent(model[field])) {
1911
- errors[field] = 'This field is required.';
1912
- }
1913
- });
1914
-
1915
- const nbOfSelections = (tokens || []).reduce((acc, token) => (token.correct ? acc + 1 : acc), 0);
1916
-
1917
- if (nbOfTokens < minTokens) {
1918
- errors.tokensError = `There should be at least ${minTokens} tokens defined.`;
1919
- } else if (nbOfTokens > maxTokens) {
1920
- errors.tokensError = `No more than ${maxTokens} tokens should be defined.`;
1921
- }
1922
-
1923
- if (nbOfSelections < 1) {
1924
- errors.selectionsError = 'There should be at least 1 token selected.';
1925
- } else if (nbOfSelections > maxSelections) {
1926
- errors.selectionsError = `No more than ${maxSelections} tokens should be selected.`;
1927
- }
1928
-
1929
- return errors;
1930
- };
1931
-
1932
- export { createCorrectResponseSession, createDefaultModel, getCorrectness, getPartialScore, model, normalize, normalizeSession, outcome, validate };