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