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