@pie-element/math-inline 7.6.1-next.11 → 7.6.1-next.12

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.
Files changed (40) hide show
  1. package/configure/lib/configure.js +251 -0
  2. package/configure/lib/configure.js.map +1 -0
  3. package/configure/lib/defaults.js +173 -0
  4. package/configure/lib/defaults.js.map +1 -0
  5. package/configure/lib/general-config-block.js +645 -0
  6. package/configure/lib/general-config-block.js.map +1 -0
  7. package/configure/lib/index.js +201 -0
  8. package/configure/lib/index.js.map +1 -0
  9. package/configure/lib/response.js +431 -0
  10. package/configure/lib/response.js.map +1 -0
  11. package/configure/lib/utils.js +46 -0
  12. package/configure/lib/utils.js.map +1 -0
  13. package/configure/package.json +1 -1
  14. package/controller/lib/defaults.js +34 -0
  15. package/controller/lib/defaults.js.map +1 -0
  16. package/controller/lib/index.js +420 -0
  17. package/controller/lib/index.js.map +1 -0
  18. package/controller/lib/utils.js +12 -0
  19. package/controller/lib/utils.js.map +1 -0
  20. package/controller/package.json +1 -1
  21. package/lib/index.js +130 -0
  22. package/lib/index.js.map +1 -0
  23. package/lib/main.js +878 -0
  24. package/lib/main.js.map +1 -0
  25. package/lib/print.js +133 -0
  26. package/lib/print.js.map +1 -0
  27. package/lib/simple-question-block.js +195 -0
  28. package/lib/simple-question-block.js.map +1 -0
  29. package/lib/utils.js +12 -0
  30. package/lib/utils.js.map +1 -0
  31. package/module/configure.js +16597 -0
  32. package/module/controller.js +4555 -0
  33. package/module/demo.js +66 -0
  34. package/module/element.js +12730 -0
  35. package/module/index.html +21 -0
  36. package/module/manifest.json +14 -0
  37. package/module/print-demo.js +104 -0
  38. package/module/print.html +18 -0
  39. package/module/print.js +12482 -0
  40. package/package.json +3 -3
@@ -0,0 +1,4555 @@
1
+ import * as mv from '@pie-framework/math-validation';
2
+
3
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
4
+
5
+ function getDefaultExportFromCjs (x) {
6
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
7
+ }
8
+
9
+ /** Used for built-in method references. */
10
+
11
+ var objectProto$6 = Object.prototype;
12
+
13
+ /**
14
+ * Checks if `value` is likely a prototype object.
15
+ *
16
+ * @private
17
+ * @param {*} value The value to check.
18
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
19
+ */
20
+ function isPrototype$2(value) {
21
+ var Ctor = value && value.constructor,
22
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
23
+
24
+ return value === proto;
25
+ }
26
+
27
+ var _isPrototype = isPrototype$2;
28
+
29
+ /**
30
+ * Creates a unary function that invokes `func` with its argument transformed.
31
+ *
32
+ * @private
33
+ * @param {Function} func The function to wrap.
34
+ * @param {Function} transform The argument transform.
35
+ * @returns {Function} Returns the new function.
36
+ */
37
+
38
+ function overArg$1(func, transform) {
39
+ return function(arg) {
40
+ return func(transform(arg));
41
+ };
42
+ }
43
+
44
+ var _overArg = overArg$1;
45
+
46
+ var overArg = _overArg;
47
+
48
+ /* Built-in method references for those with the same name as other `lodash` methods. */
49
+ var nativeKeys$1 = overArg(Object.keys, Object);
50
+
51
+ var _nativeKeys = nativeKeys$1;
52
+
53
+ var isPrototype$1 = _isPrototype,
54
+ nativeKeys = _nativeKeys;
55
+
56
+ /** Used for built-in method references. */
57
+ var objectProto$5 = Object.prototype;
58
+
59
+ /** Used to check objects for own properties. */
60
+ var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
61
+
62
+ /**
63
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
64
+ *
65
+ * @private
66
+ * @param {Object} object The object to query.
67
+ * @returns {Array} Returns the array of property names.
68
+ */
69
+ function baseKeys$1(object) {
70
+ if (!isPrototype$1(object)) {
71
+ return nativeKeys(object);
72
+ }
73
+ var result = [];
74
+ for (var key in Object(object)) {
75
+ if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
76
+ result.push(key);
77
+ }
78
+ }
79
+ return result;
80
+ }
81
+
82
+ var _baseKeys = baseKeys$1;
83
+
84
+ /** Detect free variable `global` from Node.js. */
85
+
86
+ var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
87
+
88
+ var _freeGlobal = freeGlobal$1;
89
+
90
+ var freeGlobal = _freeGlobal;
91
+
92
+ /** Detect free variable `self`. */
93
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
94
+
95
+ /** Used as a reference to the global object. */
96
+ var root$7 = freeGlobal || freeSelf || Function('return this')();
97
+
98
+ var _root = root$7;
99
+
100
+ var root$6 = _root;
101
+
102
+ /** Built-in value references. */
103
+ var Symbol$3 = root$6.Symbol;
104
+
105
+ var _Symbol = Symbol$3;
106
+
107
+ var Symbol$2 = _Symbol;
108
+
109
+ /** Used for built-in method references. */
110
+ var objectProto$4 = Object.prototype;
111
+
112
+ /** Used to check objects for own properties. */
113
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
114
+
115
+ /**
116
+ * Used to resolve the
117
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
118
+ * of values.
119
+ */
120
+ var nativeObjectToString$1 = objectProto$4.toString;
121
+
122
+ /** Built-in value references. */
123
+ var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
124
+
125
+ /**
126
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
127
+ *
128
+ * @private
129
+ * @param {*} value The value to query.
130
+ * @returns {string} Returns the raw `toStringTag`.
131
+ */
132
+ function getRawTag$1(value) {
133
+ var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
134
+ tag = value[symToStringTag$1];
135
+
136
+ try {
137
+ value[symToStringTag$1] = undefined;
138
+ var unmasked = true;
139
+ } catch (e) {}
140
+
141
+ var result = nativeObjectToString$1.call(value);
142
+ if (unmasked) {
143
+ if (isOwn) {
144
+ value[symToStringTag$1] = tag;
145
+ } else {
146
+ delete value[symToStringTag$1];
147
+ }
148
+ }
149
+ return result;
150
+ }
151
+
152
+ var _getRawTag = getRawTag$1;
153
+
154
+ /** Used for built-in method references. */
155
+
156
+ var objectProto$3 = Object.prototype;
157
+
158
+ /**
159
+ * Used to resolve the
160
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
161
+ * of values.
162
+ */
163
+ var nativeObjectToString = objectProto$3.toString;
164
+
165
+ /**
166
+ * Converts `value` to a string using `Object.prototype.toString`.
167
+ *
168
+ * @private
169
+ * @param {*} value The value to convert.
170
+ * @returns {string} Returns the converted string.
171
+ */
172
+ function objectToString$1(value) {
173
+ return nativeObjectToString.call(value);
174
+ }
175
+
176
+ var _objectToString = objectToString$1;
177
+
178
+ var Symbol$1 = _Symbol,
179
+ getRawTag = _getRawTag,
180
+ objectToString = _objectToString;
181
+
182
+ /** `Object#toString` result references. */
183
+ var nullTag = '[object Null]',
184
+ undefinedTag = '[object Undefined]';
185
+
186
+ /** Built-in value references. */
187
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
188
+
189
+ /**
190
+ * The base implementation of `getTag` without fallbacks for buggy environments.
191
+ *
192
+ * @private
193
+ * @param {*} value The value to query.
194
+ * @returns {string} Returns the `toStringTag`.
195
+ */
196
+ function baseGetTag$4(value) {
197
+ if (value == null) {
198
+ return value === undefined ? undefinedTag : nullTag;
199
+ }
200
+ return (symToStringTag && symToStringTag in Object(value))
201
+ ? getRawTag(value)
202
+ : objectToString(value);
203
+ }
204
+
205
+ var _baseGetTag = baseGetTag$4;
206
+
207
+ /**
208
+ * Checks if `value` is the
209
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
210
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
211
+ *
212
+ * @static
213
+ * @memberOf _
214
+ * @since 0.1.0
215
+ * @category Lang
216
+ * @param {*} value The value to check.
217
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
218
+ * @example
219
+ *
220
+ * _.isObject({});
221
+ * // => true
222
+ *
223
+ * _.isObject([1, 2, 3]);
224
+ * // => true
225
+ *
226
+ * _.isObject(_.noop);
227
+ * // => true
228
+ *
229
+ * _.isObject(null);
230
+ * // => false
231
+ */
232
+
233
+ function isObject$2(value) {
234
+ var type = typeof value;
235
+ return value != null && (type == 'object' || type == 'function');
236
+ }
237
+
238
+ var isObject_1 = isObject$2;
239
+
240
+ var baseGetTag$3 = _baseGetTag,
241
+ isObject$1 = isObject_1;
242
+
243
+ /** `Object#toString` result references. */
244
+ var asyncTag = '[object AsyncFunction]',
245
+ funcTag$1 = '[object Function]',
246
+ genTag = '[object GeneratorFunction]',
247
+ proxyTag = '[object Proxy]';
248
+
249
+ /**
250
+ * Checks if `value` is classified as a `Function` object.
251
+ *
252
+ * @static
253
+ * @memberOf _
254
+ * @since 0.1.0
255
+ * @category Lang
256
+ * @param {*} value The value to check.
257
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
258
+ * @example
259
+ *
260
+ * _.isFunction(_);
261
+ * // => true
262
+ *
263
+ * _.isFunction(/abc/);
264
+ * // => false
265
+ */
266
+ function isFunction$2(value) {
267
+ if (!isObject$1(value)) {
268
+ return false;
269
+ }
270
+ // The use of `Object#toString` avoids issues with the `typeof` operator
271
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
272
+ var tag = baseGetTag$3(value);
273
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
274
+ }
275
+
276
+ var isFunction_1 = isFunction$2;
277
+
278
+ var root$5 = _root;
279
+
280
+ /** Used to detect overreaching core-js shims. */
281
+ var coreJsData$1 = root$5['__core-js_shared__'];
282
+
283
+ var _coreJsData = coreJsData$1;
284
+
285
+ var coreJsData = _coreJsData;
286
+
287
+ /** Used to detect methods masquerading as native. */
288
+ var maskSrcKey = (function() {
289
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
290
+ return uid ? ('Symbol(src)_1.' + uid) : '';
291
+ }());
292
+
293
+ /**
294
+ * Checks if `func` has its source masked.
295
+ *
296
+ * @private
297
+ * @param {Function} func The function to check.
298
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
299
+ */
300
+ function isMasked$1(func) {
301
+ return !!maskSrcKey && (maskSrcKey in func);
302
+ }
303
+
304
+ var _isMasked = isMasked$1;
305
+
306
+ /** Used for built-in method references. */
307
+
308
+ var funcProto$1 = Function.prototype;
309
+
310
+ /** Used to resolve the decompiled source of functions. */
311
+ var funcToString$1 = funcProto$1.toString;
312
+
313
+ /**
314
+ * Converts `func` to its source code.
315
+ *
316
+ * @private
317
+ * @param {Function} func The function to convert.
318
+ * @returns {string} Returns the source code.
319
+ */
320
+ function toSource$2(func) {
321
+ if (func != null) {
322
+ try {
323
+ return funcToString$1.call(func);
324
+ } catch (e) {}
325
+ try {
326
+ return (func + '');
327
+ } catch (e) {}
328
+ }
329
+ return '';
330
+ }
331
+
332
+ var _toSource = toSource$2;
333
+
334
+ var isFunction$1 = isFunction_1,
335
+ isMasked = _isMasked,
336
+ isObject = isObject_1,
337
+ toSource$1 = _toSource;
338
+
339
+ /**
340
+ * Used to match `RegExp`
341
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
342
+ */
343
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
344
+
345
+ /** Used to detect host constructors (Safari). */
346
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
347
+
348
+ /** Used for built-in method references. */
349
+ var funcProto = Function.prototype,
350
+ objectProto$2 = Object.prototype;
351
+
352
+ /** Used to resolve the decompiled source of functions. */
353
+ var funcToString = funcProto.toString;
354
+
355
+ /** Used to check objects for own properties. */
356
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
357
+
358
+ /** Used to detect if a method is native. */
359
+ var reIsNative = RegExp('^' +
360
+ funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
361
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
362
+ );
363
+
364
+ /**
365
+ * The base implementation of `_.isNative` without bad shim checks.
366
+ *
367
+ * @private
368
+ * @param {*} value The value to check.
369
+ * @returns {boolean} Returns `true` if `value` is a native function,
370
+ * else `false`.
371
+ */
372
+ function baseIsNative$1(value) {
373
+ if (!isObject(value) || isMasked(value)) {
374
+ return false;
375
+ }
376
+ var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
377
+ return pattern.test(toSource$1(value));
378
+ }
379
+
380
+ var _baseIsNative = baseIsNative$1;
381
+
382
+ /**
383
+ * Gets the value at `key` of `object`.
384
+ *
385
+ * @private
386
+ * @param {Object} [object] The object to query.
387
+ * @param {string} key The key of the property to get.
388
+ * @returns {*} Returns the property value.
389
+ */
390
+
391
+ function getValue$1(object, key) {
392
+ return object == null ? undefined : object[key];
393
+ }
394
+
395
+ var _getValue = getValue$1;
396
+
397
+ var baseIsNative = _baseIsNative,
398
+ getValue = _getValue;
399
+
400
+ /**
401
+ * Gets the native function at `key` of `object`.
402
+ *
403
+ * @private
404
+ * @param {Object} object The object to query.
405
+ * @param {string} key The key of the method to get.
406
+ * @returns {*} Returns the function if it's native, else `undefined`.
407
+ */
408
+ function getNative$5(object, key) {
409
+ var value = getValue(object, key);
410
+ return baseIsNative(value) ? value : undefined;
411
+ }
412
+
413
+ var _getNative = getNative$5;
414
+
415
+ var getNative$4 = _getNative,
416
+ root$4 = _root;
417
+
418
+ /* Built-in method references that are verified to be native. */
419
+ var DataView$1 = getNative$4(root$4, 'DataView');
420
+
421
+ var _DataView = DataView$1;
422
+
423
+ var getNative$3 = _getNative,
424
+ root$3 = _root;
425
+
426
+ /* Built-in method references that are verified to be native. */
427
+ var Map$1 = getNative$3(root$3, 'Map');
428
+
429
+ var _Map = Map$1;
430
+
431
+ var getNative$2 = _getNative,
432
+ root$2 = _root;
433
+
434
+ /* Built-in method references that are verified to be native. */
435
+ var Promise$2 = getNative$2(root$2, 'Promise');
436
+
437
+ var _Promise = Promise$2;
438
+
439
+ var getNative$1 = _getNative,
440
+ root$1 = _root;
441
+
442
+ /* Built-in method references that are verified to be native. */
443
+ var Set$1 = getNative$1(root$1, 'Set');
444
+
445
+ var _Set = Set$1;
446
+
447
+ var getNative = _getNative,
448
+ root = _root;
449
+
450
+ /* Built-in method references that are verified to be native. */
451
+ var WeakMap$1 = getNative(root, 'WeakMap');
452
+
453
+ var _WeakMap = WeakMap$1;
454
+
455
+ var DataView = _DataView,
456
+ Map = _Map,
457
+ Promise$1 = _Promise,
458
+ Set = _Set,
459
+ WeakMap = _WeakMap,
460
+ baseGetTag$2 = _baseGetTag,
461
+ toSource = _toSource;
462
+
463
+ /** `Object#toString` result references. */
464
+ var mapTag$2 = '[object Map]',
465
+ objectTag$1 = '[object Object]',
466
+ promiseTag = '[object Promise]',
467
+ setTag$2 = '[object Set]',
468
+ weakMapTag$1 = '[object WeakMap]';
469
+
470
+ var dataViewTag$1 = '[object DataView]';
471
+
472
+ /** Used to detect maps, sets, and weakmaps. */
473
+ var dataViewCtorString = toSource(DataView),
474
+ mapCtorString = toSource(Map),
475
+ promiseCtorString = toSource(Promise$1),
476
+ setCtorString = toSource(Set),
477
+ weakMapCtorString = toSource(WeakMap);
478
+
479
+ /**
480
+ * Gets the `toStringTag` of `value`.
481
+ *
482
+ * @private
483
+ * @param {*} value The value to query.
484
+ * @returns {string} Returns the `toStringTag`.
485
+ */
486
+ var getTag$1 = baseGetTag$2;
487
+
488
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
489
+ if ((DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
490
+ (Map && getTag$1(new Map) != mapTag$2) ||
491
+ (Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag) ||
492
+ (Set && getTag$1(new Set) != setTag$2) ||
493
+ (WeakMap && getTag$1(new WeakMap) != weakMapTag$1)) {
494
+ getTag$1 = function(value) {
495
+ var result = baseGetTag$2(value),
496
+ Ctor = result == objectTag$1 ? value.constructor : undefined,
497
+ ctorString = Ctor ? toSource(Ctor) : '';
498
+
499
+ if (ctorString) {
500
+ switch (ctorString) {
501
+ case dataViewCtorString: return dataViewTag$1;
502
+ case mapCtorString: return mapTag$2;
503
+ case promiseCtorString: return promiseTag;
504
+ case setCtorString: return setTag$2;
505
+ case weakMapCtorString: return weakMapTag$1;
506
+ }
507
+ }
508
+ return result;
509
+ };
510
+ }
511
+
512
+ var _getTag = getTag$1;
513
+
514
+ /**
515
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
516
+ * and has a `typeof` result of "object".
517
+ *
518
+ * @static
519
+ * @memberOf _
520
+ * @since 4.0.0
521
+ * @category Lang
522
+ * @param {*} value The value to check.
523
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
524
+ * @example
525
+ *
526
+ * _.isObjectLike({});
527
+ * // => true
528
+ *
529
+ * _.isObjectLike([1, 2, 3]);
530
+ * // => true
531
+ *
532
+ * _.isObjectLike(_.noop);
533
+ * // => false
534
+ *
535
+ * _.isObjectLike(null);
536
+ * // => false
537
+ */
538
+
539
+ function isObjectLike$3(value) {
540
+ return value != null && typeof value == 'object';
541
+ }
542
+
543
+ var isObjectLike_1 = isObjectLike$3;
544
+
545
+ var baseGetTag$1 = _baseGetTag,
546
+ isObjectLike$2 = isObjectLike_1;
547
+
548
+ /** `Object#toString` result references. */
549
+ var argsTag$1 = '[object Arguments]';
550
+
551
+ /**
552
+ * The base implementation of `_.isArguments`.
553
+ *
554
+ * @private
555
+ * @param {*} value The value to check.
556
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
557
+ */
558
+ function baseIsArguments$1(value) {
559
+ return isObjectLike$2(value) && baseGetTag$1(value) == argsTag$1;
560
+ }
561
+
562
+ var _baseIsArguments = baseIsArguments$1;
563
+
564
+ var baseIsArguments = _baseIsArguments,
565
+ isObjectLike$1 = isObjectLike_1;
566
+
567
+ /** Used for built-in method references. */
568
+ var objectProto$1 = Object.prototype;
569
+
570
+ /** Used to check objects for own properties. */
571
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
572
+
573
+ /** Built-in value references. */
574
+ var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
575
+
576
+ /**
577
+ * Checks if `value` is likely an `arguments` object.
578
+ *
579
+ * @static
580
+ * @memberOf _
581
+ * @since 0.1.0
582
+ * @category Lang
583
+ * @param {*} value The value to check.
584
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
585
+ * else `false`.
586
+ * @example
587
+ *
588
+ * _.isArguments(function() { return arguments; }());
589
+ * // => true
590
+ *
591
+ * _.isArguments([1, 2, 3]);
592
+ * // => false
593
+ */
594
+ var isArguments$1 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
595
+ return isObjectLike$1(value) && hasOwnProperty$1.call(value, 'callee') &&
596
+ !propertyIsEnumerable.call(value, 'callee');
597
+ };
598
+
599
+ var isArguments_1 = isArguments$1;
600
+
601
+ /**
602
+ * Checks if `value` is classified as an `Array` object.
603
+ *
604
+ * @static
605
+ * @memberOf _
606
+ * @since 0.1.0
607
+ * @category Lang
608
+ * @param {*} value The value to check.
609
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
610
+ * @example
611
+ *
612
+ * _.isArray([1, 2, 3]);
613
+ * // => true
614
+ *
615
+ * _.isArray(document.body.children);
616
+ * // => false
617
+ *
618
+ * _.isArray('abc');
619
+ * // => false
620
+ *
621
+ * _.isArray(_.noop);
622
+ * // => false
623
+ */
624
+
625
+ var isArray$1 = Array.isArray;
626
+
627
+ var isArray_1 = isArray$1;
628
+
629
+ /** Used as references for various `Number` constants. */
630
+
631
+ var MAX_SAFE_INTEGER = 9007199254740991;
632
+
633
+ /**
634
+ * Checks if `value` is a valid array-like length.
635
+ *
636
+ * **Note:** This method is loosely based on
637
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
638
+ *
639
+ * @static
640
+ * @memberOf _
641
+ * @since 4.0.0
642
+ * @category Lang
643
+ * @param {*} value The value to check.
644
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
645
+ * @example
646
+ *
647
+ * _.isLength(3);
648
+ * // => true
649
+ *
650
+ * _.isLength(Number.MIN_VALUE);
651
+ * // => false
652
+ *
653
+ * _.isLength(Infinity);
654
+ * // => false
655
+ *
656
+ * _.isLength('3');
657
+ * // => false
658
+ */
659
+ function isLength$2(value) {
660
+ return typeof value == 'number' &&
661
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
662
+ }
663
+
664
+ var isLength_1 = isLength$2;
665
+
666
+ var isFunction = isFunction_1,
667
+ isLength$1 = isLength_1;
668
+
669
+ /**
670
+ * Checks if `value` is array-like. A value is considered array-like if it's
671
+ * not a function and has a `value.length` that's an integer greater than or
672
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
673
+ *
674
+ * @static
675
+ * @memberOf _
676
+ * @since 4.0.0
677
+ * @category Lang
678
+ * @param {*} value The value to check.
679
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
680
+ * @example
681
+ *
682
+ * _.isArrayLike([1, 2, 3]);
683
+ * // => true
684
+ *
685
+ * _.isArrayLike(document.body.children);
686
+ * // => true
687
+ *
688
+ * _.isArrayLike('abc');
689
+ * // => true
690
+ *
691
+ * _.isArrayLike(_.noop);
692
+ * // => false
693
+ */
694
+ function isArrayLike$1(value) {
695
+ return value != null && isLength$1(value.length) && !isFunction(value);
696
+ }
697
+
698
+ var isArrayLike_1 = isArrayLike$1;
699
+
700
+ var isBuffer$1 = {exports: {}};
701
+
702
+ /**
703
+ * This method returns `false`.
704
+ *
705
+ * @static
706
+ * @memberOf _
707
+ * @since 4.13.0
708
+ * @category Util
709
+ * @returns {boolean} Returns `false`.
710
+ * @example
711
+ *
712
+ * _.times(2, _.stubFalse);
713
+ * // => [false, false]
714
+ */
715
+
716
+ function stubFalse() {
717
+ return false;
718
+ }
719
+
720
+ var stubFalse_1 = stubFalse;
721
+
722
+ (function (module, exports) {
723
+ var root = _root,
724
+ stubFalse = stubFalse_1;
725
+
726
+ /** Detect free variable `exports`. */
727
+ var freeExports = exports && !exports.nodeType && exports;
728
+
729
+ /** Detect free variable `module`. */
730
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
731
+
732
+ /** Detect the popular CommonJS extension `module.exports`. */
733
+ var moduleExports = freeModule && freeModule.exports === freeExports;
734
+
735
+ /** Built-in value references. */
736
+ var Buffer = moduleExports ? root.Buffer : undefined;
737
+
738
+ /* Built-in method references for those with the same name as other `lodash` methods. */
739
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
740
+
741
+ /**
742
+ * Checks if `value` is a buffer.
743
+ *
744
+ * @static
745
+ * @memberOf _
746
+ * @since 4.3.0
747
+ * @category Lang
748
+ * @param {*} value The value to check.
749
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
750
+ * @example
751
+ *
752
+ * _.isBuffer(new Buffer(2));
753
+ * // => true
754
+ *
755
+ * _.isBuffer(new Uint8Array(2));
756
+ * // => false
757
+ */
758
+ var isBuffer = nativeIsBuffer || stubFalse;
759
+
760
+ module.exports = isBuffer;
761
+ }(isBuffer$1, isBuffer$1.exports));
762
+
763
+ var baseGetTag = _baseGetTag,
764
+ isLength = isLength_1,
765
+ isObjectLike = isObjectLike_1;
766
+
767
+ /** `Object#toString` result references. */
768
+ var argsTag = '[object Arguments]',
769
+ arrayTag = '[object Array]',
770
+ boolTag = '[object Boolean]',
771
+ dateTag = '[object Date]',
772
+ errorTag = '[object Error]',
773
+ funcTag = '[object Function]',
774
+ mapTag$1 = '[object Map]',
775
+ numberTag = '[object Number]',
776
+ objectTag = '[object Object]',
777
+ regexpTag = '[object RegExp]',
778
+ setTag$1 = '[object Set]',
779
+ stringTag = '[object String]',
780
+ weakMapTag = '[object WeakMap]';
781
+
782
+ var arrayBufferTag = '[object ArrayBuffer]',
783
+ dataViewTag = '[object DataView]',
784
+ float32Tag = '[object Float32Array]',
785
+ float64Tag = '[object Float64Array]',
786
+ int8Tag = '[object Int8Array]',
787
+ int16Tag = '[object Int16Array]',
788
+ int32Tag = '[object Int32Array]',
789
+ uint8Tag = '[object Uint8Array]',
790
+ uint8ClampedTag = '[object Uint8ClampedArray]',
791
+ uint16Tag = '[object Uint16Array]',
792
+ uint32Tag = '[object Uint32Array]';
793
+
794
+ /** Used to identify `toStringTag` values of typed arrays. */
795
+ var typedArrayTags = {};
796
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
797
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
798
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
799
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
800
+ typedArrayTags[uint32Tag] = true;
801
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
802
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
803
+ typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
804
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
805
+ typedArrayTags[mapTag$1] = typedArrayTags[numberTag] =
806
+ typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
807
+ typedArrayTags[setTag$1] = typedArrayTags[stringTag] =
808
+ typedArrayTags[weakMapTag] = false;
809
+
810
+ /**
811
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
812
+ *
813
+ * @private
814
+ * @param {*} value The value to check.
815
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
816
+ */
817
+ function baseIsTypedArray$1(value) {
818
+ return isObjectLike(value) &&
819
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
820
+ }
821
+
822
+ var _baseIsTypedArray = baseIsTypedArray$1;
823
+
824
+ /**
825
+ * The base implementation of `_.unary` without support for storing metadata.
826
+ *
827
+ * @private
828
+ * @param {Function} func The function to cap arguments for.
829
+ * @returns {Function} Returns the new capped function.
830
+ */
831
+
832
+ function baseUnary$1(func) {
833
+ return function(value) {
834
+ return func(value);
835
+ };
836
+ }
837
+
838
+ var _baseUnary = baseUnary$1;
839
+
840
+ var _nodeUtil = {exports: {}};
841
+
842
+ (function (module, exports) {
843
+ var freeGlobal = _freeGlobal;
844
+
845
+ /** Detect free variable `exports`. */
846
+ var freeExports = exports && !exports.nodeType && exports;
847
+
848
+ /** Detect free variable `module`. */
849
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
850
+
851
+ /** Detect the popular CommonJS extension `module.exports`. */
852
+ var moduleExports = freeModule && freeModule.exports === freeExports;
853
+
854
+ /** Detect free variable `process` from Node.js. */
855
+ var freeProcess = moduleExports && freeGlobal.process;
856
+
857
+ /** Used to access faster Node.js helpers. */
858
+ var nodeUtil = (function() {
859
+ try {
860
+ // Use `util.types` for Node.js 10+.
861
+ var types = freeModule && freeModule.require && freeModule.require('util').types;
862
+
863
+ if (types) {
864
+ return types;
865
+ }
866
+
867
+ // Legacy `process.binding('util')` for Node.js < 10.
868
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
869
+ } catch (e) {}
870
+ }());
871
+
872
+ module.exports = nodeUtil;
873
+ }(_nodeUtil, _nodeUtil.exports));
874
+
875
+ var baseIsTypedArray = _baseIsTypedArray,
876
+ baseUnary = _baseUnary,
877
+ nodeUtil = _nodeUtil.exports;
878
+
879
+ /* Node.js helper references. */
880
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
881
+
882
+ /**
883
+ * Checks if `value` is classified as a typed array.
884
+ *
885
+ * @static
886
+ * @memberOf _
887
+ * @since 3.0.0
888
+ * @category Lang
889
+ * @param {*} value The value to check.
890
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
891
+ * @example
892
+ *
893
+ * _.isTypedArray(new Uint8Array);
894
+ * // => true
895
+ *
896
+ * _.isTypedArray([]);
897
+ * // => false
898
+ */
899
+ var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
900
+
901
+ var isTypedArray_1 = isTypedArray$1;
902
+
903
+ var baseKeys = _baseKeys,
904
+ getTag = _getTag,
905
+ isArguments = isArguments_1,
906
+ isArray = isArray_1,
907
+ isArrayLike = isArrayLike_1,
908
+ isBuffer = isBuffer$1.exports,
909
+ isPrototype = _isPrototype,
910
+ isTypedArray = isTypedArray_1;
911
+
912
+ /** `Object#toString` result references. */
913
+ var mapTag = '[object Map]',
914
+ setTag = '[object Set]';
915
+
916
+ /** Used for built-in method references. */
917
+ var objectProto = Object.prototype;
918
+
919
+ /** Used to check objects for own properties. */
920
+ var hasOwnProperty = objectProto.hasOwnProperty;
921
+
922
+ /**
923
+ * Checks if `value` is an empty object, collection, map, or set.
924
+ *
925
+ * Objects are considered empty if they have no own enumerable string keyed
926
+ * properties.
927
+ *
928
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
929
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
930
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
931
+ *
932
+ * @static
933
+ * @memberOf _
934
+ * @since 0.1.0
935
+ * @category Lang
936
+ * @param {*} value The value to check.
937
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
938
+ * @example
939
+ *
940
+ * _.isEmpty(null);
941
+ * // => true
942
+ *
943
+ * _.isEmpty(true);
944
+ * // => true
945
+ *
946
+ * _.isEmpty(1);
947
+ * // => true
948
+ *
949
+ * _.isEmpty([1, 2, 3]);
950
+ * // => false
951
+ *
952
+ * _.isEmpty({ 'a': 1 });
953
+ * // => false
954
+ */
955
+ function isEmpty(value) {
956
+ if (value == null) {
957
+ return true;
958
+ }
959
+ if (isArrayLike(value) &&
960
+ (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
961
+ isBuffer(value) || isTypedArray(value) || isArguments(value))) {
962
+ return !value.length;
963
+ }
964
+ var tag = getTag(value);
965
+ if (tag == mapTag || tag == setTag) {
966
+ return !value.size;
967
+ }
968
+ if (isPrototype(value)) {
969
+ return !baseKeys(value).length;
970
+ }
971
+ for (var key in value) {
972
+ if (hasOwnProperty.call(value, key)) {
973
+ return false;
974
+ }
975
+ }
976
+ return true;
977
+ }
978
+
979
+ var isEmpty_1 = isEmpty;
980
+
981
+ var feedback$1 = {};
982
+
983
+ var feedback = {};
984
+
985
+ var interopRequireDefault = {exports: {}};
986
+
987
+ (function (module) {
988
+ function _interopRequireDefault(obj) {
989
+ return obj && obj.__esModule ? obj : {
990
+ "default": obj
991
+ };
992
+ }
993
+
994
+ module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
995
+ }(interopRequireDefault));
996
+
997
+ var defineProperty$1 = {exports: {}};
998
+
999
+ (function (module) {
1000
+ function _defineProperty(obj, key, value) {
1001
+ if (key in obj) {
1002
+ Object.defineProperty(obj, key, {
1003
+ value: value,
1004
+ enumerable: true,
1005
+ configurable: true,
1006
+ writable: true
1007
+ });
1008
+ } else {
1009
+ obj[key] = value;
1010
+ }
1011
+
1012
+ return obj;
1013
+ }
1014
+
1015
+ module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
1016
+ }(defineProperty$1));
1017
+
1018
+ var _interopRequireDefault = interopRequireDefault.exports;
1019
+
1020
+ Object.defineProperty(feedback, "__esModule", {
1021
+ value: true
1022
+ });
1023
+ feedback.getFeedbackForCorrectness = feedback.getFeedback = feedback.defaults = void 0;
1024
+
1025
+ var _defineProperty2 = _interopRequireDefault(defineProperty$1.exports);
1026
+
1027
+ function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1028
+
1029
+ function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1030
+
1031
+ var defaults$1 = {
1032
+ correct: {
1033
+ type: 'default',
1034
+ "default": 'Correct',
1035
+ custom: 'Correct'
1036
+ },
1037
+ incorrect: {
1038
+ type: 'default',
1039
+ "default": 'Incorrect',
1040
+ custom: 'Incorrect'
1041
+ },
1042
+ partial: {
1043
+ type: 'default',
1044
+ "default": 'Nearly',
1045
+ custom: 'Nearly'
1046
+ },
1047
+ unanswered: {
1048
+ type: 'default',
1049
+ "default": 'You have not entered a response',
1050
+ custom: 'You have not entered a response'
1051
+ }
1052
+ };
1053
+ /**
1054
+ * @typedef {Object} FeedbackConfig
1055
+ * @property {'default'|'none'|'custom'} type
1056
+ * @property {string} default
1057
+ * @property {string} custom
1058
+ *
1059
+ * @typedef {Object} Feedback
1060
+ * @property {FeedbackConfig} correct
1061
+ * @property {FeedbackConfig} incorrect
1062
+ * @property {FeedbackConfig} partial
1063
+ */
1064
+
1065
+ feedback.defaults = defaults$1;
1066
+
1067
+ var normalizeCorrectness = function normalizeCorrectness(c) {
1068
+ if (c === 'partially-correct') {
1069
+ return 'partial';
1070
+ }
1071
+
1072
+ return c;
1073
+ };
1074
+ /**
1075
+ * Get the feedback for the correctness
1076
+ *
1077
+ * @param {'correct'|'incorrect'|'partial'} correctness
1078
+ * @param {Feedback} feedback
1079
+ */
1080
+
1081
+
1082
+ var getFeedbackForCorrectness = function getFeedbackForCorrectness(correctness, feedback) {
1083
+ return new Promise(function (resolve) {
1084
+ feedback = _objectSpread$7(_objectSpread$7({}, defaults$1), feedback);
1085
+ correctness = normalizeCorrectness(correctness);
1086
+ var fb = feedback[correctness] || defaults$1[correctness] || {};
1087
+ var d = defaults$1[correctness] || {};
1088
+ getFeedback(fb, d[fb.type || 'default']).then(function (result) {
1089
+ return resolve(result);
1090
+ });
1091
+ });
1092
+ };
1093
+ /**
1094
+ * Get the feedback from a {FeedbackConfig}
1095
+ *
1096
+ * @param {FeedbackConfig} feedback
1097
+ * @param {string} fallback
1098
+ */
1099
+
1100
+
1101
+ feedback.getFeedbackForCorrectness = getFeedbackForCorrectness;
1102
+
1103
+ var getFeedback = function getFeedback(feedback, fallback) {
1104
+ return new Promise(function (resolve) {
1105
+ if (!feedback || feedback.type === 'none') {
1106
+ resolve(undefined);
1107
+ return;
1108
+ }
1109
+
1110
+ feedback = feedback || {};
1111
+ var out = feedback[feedback.type] || fallback;
1112
+ resolve(out);
1113
+ });
1114
+ };
1115
+
1116
+ feedback.getFeedback = getFeedback;
1117
+
1118
+ (function (exports) {
1119
+
1120
+ Object.defineProperty(exports, "__esModule", {
1121
+ value: true
1122
+ });
1123
+ Object.defineProperty(exports, "defaults", {
1124
+ enumerable: true,
1125
+ get: function get() {
1126
+ return _feedback.defaults;
1127
+ }
1128
+ });
1129
+ Object.defineProperty(exports, "getFeedback", {
1130
+ enumerable: true,
1131
+ get: function get() {
1132
+ return _feedback.getFeedback;
1133
+ }
1134
+ });
1135
+ Object.defineProperty(exports, "getFeedbackForCorrectness", {
1136
+ enumerable: true,
1137
+ get: function get() {
1138
+ return _feedback.getFeedbackForCorrectness;
1139
+ }
1140
+ });
1141
+
1142
+ var _feedback = feedback;
1143
+
1144
+ }(feedback$1));
1145
+
1146
+ const ResponseTypes = {
1147
+ advanced: 'Advanced Multi',
1148
+ simple: 'Simple',
1149
+ };
1150
+
1151
+ var translator$2 = {};
1152
+
1153
+ var translator$1 = {};
1154
+
1155
+ var _typeof$1 = {exports: {}};
1156
+
1157
+ (function (module) {
1158
+ function _typeof(obj) {
1159
+ "@babel/helpers - typeof";
1160
+
1161
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
1162
+ return typeof obj;
1163
+ } : function (obj) {
1164
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1165
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
1166
+ }
1167
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
1168
+ }(_typeof$1));
1169
+
1170
+ var classCallCheck = {exports: {}};
1171
+
1172
+ (function (module) {
1173
+ function _classCallCheck(instance, Constructor) {
1174
+ if (!(instance instanceof Constructor)) {
1175
+ throw new TypeError("Cannot call a class as a function");
1176
+ }
1177
+ }
1178
+ module.exports = _classCallCheck, module.exports.__esModule = true, module.exports["default"] = module.exports;
1179
+ }(classCallCheck));
1180
+
1181
+ var createClass = {exports: {}};
1182
+
1183
+ var toPropertyKey = {exports: {}};
1184
+
1185
+ var toPrimitive = {exports: {}};
1186
+
1187
+ (function (module) {
1188
+ var _typeof = _typeof$1.exports["default"];
1189
+ function _toPrimitive(input, hint) {
1190
+ if (_typeof(input) !== "object" || input === null) return input;
1191
+ var prim = input[Symbol.toPrimitive];
1192
+ if (prim !== undefined) {
1193
+ var res = prim.call(input, hint || "default");
1194
+ if (_typeof(res) !== "object") return res;
1195
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1196
+ }
1197
+ return (hint === "string" ? String : Number)(input);
1198
+ }
1199
+ module.exports = _toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
1200
+ }(toPrimitive));
1201
+
1202
+ (function (module) {
1203
+ var _typeof = _typeof$1.exports["default"];
1204
+ var toPrimitive$1 = toPrimitive.exports;
1205
+ function _toPropertyKey(arg) {
1206
+ var key = toPrimitive$1(arg, "string");
1207
+ return _typeof(key) === "symbol" ? key : String(key);
1208
+ }
1209
+ module.exports = _toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
1210
+ }(toPropertyKey));
1211
+
1212
+ (function (module) {
1213
+ var toPropertyKey$1 = toPropertyKey.exports;
1214
+ function _defineProperties(target, props) {
1215
+ for (var i = 0; i < props.length; i++) {
1216
+ var descriptor = props[i];
1217
+ descriptor.enumerable = descriptor.enumerable || false;
1218
+ descriptor.configurable = true;
1219
+ if ("value" in descriptor) descriptor.writable = true;
1220
+ Object.defineProperty(target, toPropertyKey$1(descriptor.key), descriptor);
1221
+ }
1222
+ }
1223
+ function _createClass(Constructor, protoProps, staticProps) {
1224
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1225
+ if (staticProps) _defineProperties(Constructor, staticProps);
1226
+ Object.defineProperty(Constructor, "prototype", {
1227
+ writable: false
1228
+ });
1229
+ return Constructor;
1230
+ }
1231
+ module.exports = _createClass, module.exports.__esModule = true, module.exports["default"] = module.exports;
1232
+ }(createClass));
1233
+
1234
+ var assertThisInitialized = {exports: {}};
1235
+
1236
+ (function (module) {
1237
+ function _assertThisInitialized(self) {
1238
+ if (self === void 0) {
1239
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1240
+ }
1241
+ return self;
1242
+ }
1243
+ module.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports["default"] = module.exports;
1244
+ }(assertThisInitialized));
1245
+
1246
+ var inherits = {exports: {}};
1247
+
1248
+ var setPrototypeOf = {exports: {}};
1249
+
1250
+ (function (module) {
1251
+ function _setPrototypeOf(o, p) {
1252
+ module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
1253
+ o.__proto__ = p;
1254
+ return o;
1255
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
1256
+ return _setPrototypeOf(o, p);
1257
+ }
1258
+ module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
1259
+ }(setPrototypeOf));
1260
+
1261
+ (function (module) {
1262
+ var setPrototypeOf$1 = setPrototypeOf.exports;
1263
+ function _inherits(subClass, superClass) {
1264
+ if (typeof superClass !== "function" && superClass !== null) {
1265
+ throw new TypeError("Super expression must either be null or a function");
1266
+ }
1267
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
1268
+ constructor: {
1269
+ value: subClass,
1270
+ writable: true,
1271
+ configurable: true
1272
+ }
1273
+ });
1274
+ Object.defineProperty(subClass, "prototype", {
1275
+ writable: false
1276
+ });
1277
+ if (superClass) setPrototypeOf$1(subClass, superClass);
1278
+ }
1279
+ module.exports = _inherits, module.exports.__esModule = true, module.exports["default"] = module.exports;
1280
+ }(inherits));
1281
+
1282
+ var possibleConstructorReturn = {exports: {}};
1283
+
1284
+ (function (module) {
1285
+ var _typeof = _typeof$1.exports["default"];
1286
+ var assertThisInitialized$1 = assertThisInitialized.exports;
1287
+ function _possibleConstructorReturn(self, call) {
1288
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
1289
+ return call;
1290
+ } else if (call !== void 0) {
1291
+ throw new TypeError("Derived constructors may only return object or undefined");
1292
+ }
1293
+ return assertThisInitialized$1(self);
1294
+ }
1295
+ module.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports["default"] = module.exports;
1296
+ }(possibleConstructorReturn));
1297
+
1298
+ var getPrototypeOf = {exports: {}};
1299
+
1300
+ (function (module) {
1301
+ function _getPrototypeOf(o) {
1302
+ module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
1303
+ return o.__proto__ || Object.getPrototypeOf(o);
1304
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
1305
+ return _getPrototypeOf(o);
1306
+ }
1307
+ module.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
1308
+ }(getPrototypeOf));
1309
+
1310
+ var defineProperty = {exports: {}};
1311
+
1312
+ (function (module) {
1313
+ var toPropertyKey$1 = toPropertyKey.exports;
1314
+ function _defineProperty(obj, key, value) {
1315
+ key = toPropertyKey$1(key);
1316
+ if (key in obj) {
1317
+ Object.defineProperty(obj, key, {
1318
+ value: value,
1319
+ enumerable: true,
1320
+ configurable: true,
1321
+ writable: true
1322
+ });
1323
+ } else {
1324
+ obj[key] = value;
1325
+ }
1326
+ return obj;
1327
+ }
1328
+ module.exports = _defineProperty, module.exports.__esModule = true, module.exports["default"] = module.exports;
1329
+ }(defineProperty));
1330
+
1331
+ var toArray = {exports: {}};
1332
+
1333
+ var arrayWithHoles = {exports: {}};
1334
+
1335
+ (function (module) {
1336
+ function _arrayWithHoles(arr) {
1337
+ if (Array.isArray(arr)) return arr;
1338
+ }
1339
+ module.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports["default"] = module.exports;
1340
+ }(arrayWithHoles));
1341
+
1342
+ var iterableToArray = {exports: {}};
1343
+
1344
+ (function (module) {
1345
+ function _iterableToArray(iter) {
1346
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1347
+ }
1348
+ module.exports = _iterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
1349
+ }(iterableToArray));
1350
+
1351
+ var unsupportedIterableToArray = {exports: {}};
1352
+
1353
+ var arrayLikeToArray = {exports: {}};
1354
+
1355
+ (function (module) {
1356
+ function _arrayLikeToArray(arr, len) {
1357
+ if (len == null || len > arr.length) len = arr.length;
1358
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1359
+ return arr2;
1360
+ }
1361
+ module.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
1362
+ }(arrayLikeToArray));
1363
+
1364
+ (function (module) {
1365
+ var arrayLikeToArray$1 = arrayLikeToArray.exports;
1366
+ function _unsupportedIterableToArray(o, minLen) {
1367
+ if (!o) return;
1368
+ if (typeof o === "string") return arrayLikeToArray$1(o, minLen);
1369
+ var n = Object.prototype.toString.call(o).slice(8, -1);
1370
+ if (n === "Object" && o.constructor) n = o.constructor.name;
1371
+ if (n === "Map" || n === "Set") return Array.from(o);
1372
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray$1(o, minLen);
1373
+ }
1374
+ module.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
1375
+ }(unsupportedIterableToArray));
1376
+
1377
+ var nonIterableRest = {exports: {}};
1378
+
1379
+ (function (module) {
1380
+ function _nonIterableRest() {
1381
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1382
+ }
1383
+ module.exports = _nonIterableRest, module.exports.__esModule = true, module.exports["default"] = module.exports;
1384
+ }(nonIterableRest));
1385
+
1386
+ (function (module) {
1387
+ var arrayWithHoles$1 = arrayWithHoles.exports;
1388
+ var iterableToArray$1 = iterableToArray.exports;
1389
+ var unsupportedIterableToArray$1 = unsupportedIterableToArray.exports;
1390
+ var nonIterableRest$1 = nonIterableRest.exports;
1391
+ function _toArray(arr) {
1392
+ return arrayWithHoles$1(arr) || iterableToArray$1(arr) || unsupportedIterableToArray$1(arr) || nonIterableRest$1();
1393
+ }
1394
+ module.exports = _toArray, module.exports.__esModule = true, module.exports["default"] = module.exports;
1395
+ }(toArray));
1396
+
1397
+ var _typeof = _typeof$1.exports;
1398
+ var _classCallCheck = classCallCheck.exports;
1399
+ var _createClass = createClass.exports;
1400
+ var _assertThisInitialized = assertThisInitialized.exports;
1401
+ var _inherits = inherits.exports;
1402
+ var _possibleConstructorReturn = possibleConstructorReturn.exports;
1403
+ var _getPrototypeOf = getPrototypeOf.exports;
1404
+ var _defineProperty = defineProperty.exports;
1405
+ var _toArray = toArray.exports;
1406
+
1407
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
1408
+
1409
+ var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
1410
+ var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck);
1411
+ var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
1412
+ var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
1413
+ var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
1414
+ var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
1415
+ var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
1416
+ var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
1417
+ var _toArray__default = /*#__PURE__*/_interopDefaultLegacy(_toArray);
1418
+
1419
+ function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1420
+ function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1421
+ var consoleLogger = {
1422
+ type: 'logger',
1423
+ log: function log(args) {
1424
+ this.output('log', args);
1425
+ },
1426
+ warn: function warn(args) {
1427
+ this.output('warn', args);
1428
+ },
1429
+ error: function error(args) {
1430
+ this.output('error', args);
1431
+ },
1432
+ output: function output(type, args) {
1433
+ if (console && console[type]) console[type].apply(console, args);
1434
+ }
1435
+ };
1436
+ var Logger = function () {
1437
+ function Logger(concreteLogger) {
1438
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1439
+ _classCallCheck__default["default"](this, Logger);
1440
+ this.init(concreteLogger, options);
1441
+ }
1442
+ _createClass__default["default"](Logger, [{
1443
+ key: "init",
1444
+ value: function init(concreteLogger) {
1445
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1446
+ this.prefix = options.prefix || 'i18next:';
1447
+ this.logger = concreteLogger || consoleLogger;
1448
+ this.options = options;
1449
+ this.debug = options.debug;
1450
+ }
1451
+ }, {
1452
+ key: "setDebug",
1453
+ value: function setDebug(bool) {
1454
+ this.debug = bool;
1455
+ }
1456
+ }, {
1457
+ key: "log",
1458
+ value: function log() {
1459
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1460
+ args[_key] = arguments[_key];
1461
+ }
1462
+ return this.forward(args, 'log', '', true);
1463
+ }
1464
+ }, {
1465
+ key: "warn",
1466
+ value: function warn() {
1467
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
1468
+ args[_key2] = arguments[_key2];
1469
+ }
1470
+ return this.forward(args, 'warn', '', true);
1471
+ }
1472
+ }, {
1473
+ key: "error",
1474
+ value: function error() {
1475
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1476
+ args[_key3] = arguments[_key3];
1477
+ }
1478
+ return this.forward(args, 'error', '');
1479
+ }
1480
+ }, {
1481
+ key: "deprecate",
1482
+ value: function deprecate() {
1483
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
1484
+ args[_key4] = arguments[_key4];
1485
+ }
1486
+ return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
1487
+ }
1488
+ }, {
1489
+ key: "forward",
1490
+ value: function forward(args, lvl, prefix, debugOnly) {
1491
+ if (debugOnly && !this.debug) return null;
1492
+ if (typeof args[0] === 'string') args[0] = "".concat(prefix).concat(this.prefix, " ").concat(args[0]);
1493
+ return this.logger[lvl](args);
1494
+ }
1495
+ }, {
1496
+ key: "create",
1497
+ value: function create(moduleName) {
1498
+ return new Logger(this.logger, _objectSpread$6(_objectSpread$6({}, {
1499
+ prefix: "".concat(this.prefix, ":").concat(moduleName, ":")
1500
+ }), this.options));
1501
+ }
1502
+ }, {
1503
+ key: "clone",
1504
+ value: function clone(options) {
1505
+ options = options || this.options;
1506
+ options.prefix = options.prefix || this.prefix;
1507
+ return new Logger(this.logger, options);
1508
+ }
1509
+ }]);
1510
+ return Logger;
1511
+ }();
1512
+ var baseLogger = new Logger();
1513
+
1514
+ var EventEmitter = function () {
1515
+ function EventEmitter() {
1516
+ _classCallCheck__default["default"](this, EventEmitter);
1517
+ this.observers = {};
1518
+ }
1519
+ _createClass__default["default"](EventEmitter, [{
1520
+ key: "on",
1521
+ value: function on(events, listener) {
1522
+ var _this = this;
1523
+ events.split(' ').forEach(function (event) {
1524
+ _this.observers[event] = _this.observers[event] || [];
1525
+ _this.observers[event].push(listener);
1526
+ });
1527
+ return this;
1528
+ }
1529
+ }, {
1530
+ key: "off",
1531
+ value: function off(event, listener) {
1532
+ if (!this.observers[event]) return;
1533
+ if (!listener) {
1534
+ delete this.observers[event];
1535
+ return;
1536
+ }
1537
+ this.observers[event] = this.observers[event].filter(function (l) {
1538
+ return l !== listener;
1539
+ });
1540
+ }
1541
+ }, {
1542
+ key: "emit",
1543
+ value: function emit(event) {
1544
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1545
+ args[_key - 1] = arguments[_key];
1546
+ }
1547
+ if (this.observers[event]) {
1548
+ var cloned = [].concat(this.observers[event]);
1549
+ cloned.forEach(function (observer) {
1550
+ observer.apply(void 0, args);
1551
+ });
1552
+ }
1553
+ if (this.observers['*']) {
1554
+ var _cloned = [].concat(this.observers['*']);
1555
+ _cloned.forEach(function (observer) {
1556
+ observer.apply(observer, [event].concat(args));
1557
+ });
1558
+ }
1559
+ }
1560
+ }]);
1561
+ return EventEmitter;
1562
+ }();
1563
+
1564
+ function defer() {
1565
+ var res;
1566
+ var rej;
1567
+ var promise = new Promise(function (resolve, reject) {
1568
+ res = resolve;
1569
+ rej = reject;
1570
+ });
1571
+ promise.resolve = res;
1572
+ promise.reject = rej;
1573
+ return promise;
1574
+ }
1575
+ function makeString(object) {
1576
+ if (object == null) return '';
1577
+ return '' + object;
1578
+ }
1579
+ function copy(a, s, t) {
1580
+ a.forEach(function (m) {
1581
+ if (s[m]) t[m] = s[m];
1582
+ });
1583
+ }
1584
+ function getLastOfPath(object, path, Empty) {
1585
+ function cleanKey(key) {
1586
+ return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
1587
+ }
1588
+ function canNotTraverseDeeper() {
1589
+ return !object || typeof object === 'string';
1590
+ }
1591
+ var stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
1592
+ while (stack.length > 1) {
1593
+ if (canNotTraverseDeeper()) return {};
1594
+ var key = cleanKey(stack.shift());
1595
+ if (!object[key] && Empty) object[key] = new Empty();
1596
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
1597
+ object = object[key];
1598
+ } else {
1599
+ object = {};
1600
+ }
1601
+ }
1602
+ if (canNotTraverseDeeper()) return {};
1603
+ return {
1604
+ obj: object,
1605
+ k: cleanKey(stack.shift())
1606
+ };
1607
+ }
1608
+ function setPath(object, path, newValue) {
1609
+ var _getLastOfPath = getLastOfPath(object, path, Object),
1610
+ obj = _getLastOfPath.obj,
1611
+ k = _getLastOfPath.k;
1612
+ obj[k] = newValue;
1613
+ }
1614
+ function pushPath(object, path, newValue, concat) {
1615
+ var _getLastOfPath2 = getLastOfPath(object, path, Object),
1616
+ obj = _getLastOfPath2.obj,
1617
+ k = _getLastOfPath2.k;
1618
+ obj[k] = obj[k] || [];
1619
+ if (concat) obj[k] = obj[k].concat(newValue);
1620
+ if (!concat) obj[k].push(newValue);
1621
+ }
1622
+ function getPath(object, path) {
1623
+ var _getLastOfPath3 = getLastOfPath(object, path),
1624
+ obj = _getLastOfPath3.obj,
1625
+ k = _getLastOfPath3.k;
1626
+ if (!obj) return undefined;
1627
+ return obj[k];
1628
+ }
1629
+ function getPathWithDefaults(data, defaultData, key) {
1630
+ var value = getPath(data, key);
1631
+ if (value !== undefined) {
1632
+ return value;
1633
+ }
1634
+ return getPath(defaultData, key);
1635
+ }
1636
+ function deepExtend(target, source, overwrite) {
1637
+ for (var prop in source) {
1638
+ if (prop !== '__proto__' && prop !== 'constructor') {
1639
+ if (prop in target) {
1640
+ if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
1641
+ if (overwrite) target[prop] = source[prop];
1642
+ } else {
1643
+ deepExtend(target[prop], source[prop], overwrite);
1644
+ }
1645
+ } else {
1646
+ target[prop] = source[prop];
1647
+ }
1648
+ }
1649
+ }
1650
+ return target;
1651
+ }
1652
+ function regexEscape(str) {
1653
+ return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
1654
+ }
1655
+ var _entityMap = {
1656
+ '&': '&amp;',
1657
+ '<': '&lt;',
1658
+ '>': '&gt;',
1659
+ '"': '&quot;',
1660
+ "'": '&#39;',
1661
+ '/': '&#x2F;'
1662
+ };
1663
+ function escape$1(data) {
1664
+ if (typeof data === 'string') {
1665
+ return data.replace(/[&<>"'\/]/g, function (s) {
1666
+ return _entityMap[s];
1667
+ });
1668
+ }
1669
+ return data;
1670
+ }
1671
+ var isIE10 = typeof window !== 'undefined' && window.navigator && typeof window.navigator.userAgentData === 'undefined' && window.navigator.userAgent && window.navigator.userAgent.indexOf('MSIE') > -1;
1672
+ var chars = [' ', ',', '?', '!', ';'];
1673
+ function looksLikeObjectPath(key, nsSeparator, keySeparator) {
1674
+ nsSeparator = nsSeparator || '';
1675
+ keySeparator = keySeparator || '';
1676
+ var possibleChars = chars.filter(function (c) {
1677
+ return nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0;
1678
+ });
1679
+ if (possibleChars.length === 0) return true;
1680
+ var r = new RegExp("(".concat(possibleChars.map(function (c) {
1681
+ return c === '?' ? '\\?' : c;
1682
+ }).join('|'), ")"));
1683
+ var matched = !r.test(key);
1684
+ if (!matched) {
1685
+ var ki = key.indexOf(keySeparator);
1686
+ if (ki > 0 && !r.test(key.substring(0, ki))) {
1687
+ matched = true;
1688
+ }
1689
+ }
1690
+ return matched;
1691
+ }
1692
+ function deepFind(obj, path) {
1693
+ var keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
1694
+ if (!obj) return undefined;
1695
+ if (obj[path]) return obj[path];
1696
+ var paths = path.split(keySeparator);
1697
+ var current = obj;
1698
+ for (var i = 0; i < paths.length; ++i) {
1699
+ if (!current) return undefined;
1700
+ if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
1701
+ return undefined;
1702
+ }
1703
+ if (current[paths[i]] === undefined) {
1704
+ var j = 2;
1705
+ var p = paths.slice(i, i + j).join(keySeparator);
1706
+ var mix = current[p];
1707
+ while (mix === undefined && paths.length > i + j) {
1708
+ j++;
1709
+ p = paths.slice(i, i + j).join(keySeparator);
1710
+ mix = current[p];
1711
+ }
1712
+ if (mix === undefined) return undefined;
1713
+ if (mix === null) return null;
1714
+ if (path.endsWith(p)) {
1715
+ if (typeof mix === 'string') return mix;
1716
+ if (p && typeof mix[p] === 'string') return mix[p];
1717
+ }
1718
+ var joinedPath = paths.slice(i + j).join(keySeparator);
1719
+ if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
1720
+ return undefined;
1721
+ }
1722
+ current = current[paths[i]];
1723
+ }
1724
+ return current;
1725
+ }
1726
+
1727
+ function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1728
+ function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1729
+ function _createSuper$3(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$3(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
1730
+ function _isNativeReflectConstruct$3() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1731
+ var ResourceStore = function (_EventEmitter) {
1732
+ _inherits__default["default"](ResourceStore, _EventEmitter);
1733
+ var _super = _createSuper$3(ResourceStore);
1734
+ function ResourceStore(data) {
1735
+ var _this;
1736
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1737
+ ns: ['translation'],
1738
+ defaultNS: 'translation'
1739
+ };
1740
+ _classCallCheck__default["default"](this, ResourceStore);
1741
+ _this = _super.call(this);
1742
+ if (isIE10) {
1743
+ EventEmitter.call(_assertThisInitialized__default["default"](_this));
1744
+ }
1745
+ _this.data = data || {};
1746
+ _this.options = options;
1747
+ if (_this.options.keySeparator === undefined) {
1748
+ _this.options.keySeparator = '.';
1749
+ }
1750
+ if (_this.options.ignoreJSONStructure === undefined) {
1751
+ _this.options.ignoreJSONStructure = true;
1752
+ }
1753
+ return _this;
1754
+ }
1755
+ _createClass__default["default"](ResourceStore, [{
1756
+ key: "addNamespaces",
1757
+ value: function addNamespaces(ns) {
1758
+ if (this.options.ns.indexOf(ns) < 0) {
1759
+ this.options.ns.push(ns);
1760
+ }
1761
+ }
1762
+ }, {
1763
+ key: "removeNamespaces",
1764
+ value: function removeNamespaces(ns) {
1765
+ var index = this.options.ns.indexOf(ns);
1766
+ if (index > -1) {
1767
+ this.options.ns.splice(index, 1);
1768
+ }
1769
+ }
1770
+ }, {
1771
+ key: "getResource",
1772
+ value: function getResource(lng, ns, key) {
1773
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1774
+ var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
1775
+ var ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
1776
+ var path = [lng, ns];
1777
+ if (key && typeof key !== 'string') path = path.concat(key);
1778
+ if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
1779
+ if (lng.indexOf('.') > -1) {
1780
+ path = lng.split('.');
1781
+ }
1782
+ var result = getPath(this.data, path);
1783
+ if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
1784
+ return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
1785
+ }
1786
+ }, {
1787
+ key: "addResource",
1788
+ value: function addResource(lng, ns, key, value) {
1789
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
1790
+ silent: false
1791
+ };
1792
+ var keySeparator = this.options.keySeparator;
1793
+ if (keySeparator === undefined) keySeparator = '.';
1794
+ var path = [lng, ns];
1795
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
1796
+ if (lng.indexOf('.') > -1) {
1797
+ path = lng.split('.');
1798
+ value = ns;
1799
+ ns = path[1];
1800
+ }
1801
+ this.addNamespaces(ns);
1802
+ setPath(this.data, path, value);
1803
+ if (!options.silent) this.emit('added', lng, ns, key, value);
1804
+ }
1805
+ }, {
1806
+ key: "addResources",
1807
+ value: function addResources(lng, ns, resources) {
1808
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
1809
+ silent: false
1810
+ };
1811
+ for (var m in resources) {
1812
+ if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
1813
+ silent: true
1814
+ });
1815
+ }
1816
+ if (!options.silent) this.emit('added', lng, ns, resources);
1817
+ }
1818
+ }, {
1819
+ key: "addResourceBundle",
1820
+ value: function addResourceBundle(lng, ns, resources, deep, overwrite) {
1821
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
1822
+ silent: false
1823
+ };
1824
+ var path = [lng, ns];
1825
+ if (lng.indexOf('.') > -1) {
1826
+ path = lng.split('.');
1827
+ deep = resources;
1828
+ resources = ns;
1829
+ ns = path[1];
1830
+ }
1831
+ this.addNamespaces(ns);
1832
+ var pack = getPath(this.data, path) || {};
1833
+ if (deep) {
1834
+ deepExtend(pack, resources, overwrite);
1835
+ } else {
1836
+ pack = _objectSpread$5(_objectSpread$5({}, pack), resources);
1837
+ }
1838
+ setPath(this.data, path, pack);
1839
+ if (!options.silent) this.emit('added', lng, ns, resources);
1840
+ }
1841
+ }, {
1842
+ key: "removeResourceBundle",
1843
+ value: function removeResourceBundle(lng, ns) {
1844
+ if (this.hasResourceBundle(lng, ns)) {
1845
+ delete this.data[lng][ns];
1846
+ }
1847
+ this.removeNamespaces(ns);
1848
+ this.emit('removed', lng, ns);
1849
+ }
1850
+ }, {
1851
+ key: "hasResourceBundle",
1852
+ value: function hasResourceBundle(lng, ns) {
1853
+ return this.getResource(lng, ns) !== undefined;
1854
+ }
1855
+ }, {
1856
+ key: "getResourceBundle",
1857
+ value: function getResourceBundle(lng, ns) {
1858
+ if (!ns) ns = this.options.defaultNS;
1859
+ if (this.options.compatibilityAPI === 'v1') return _objectSpread$5(_objectSpread$5({}, {}), this.getResource(lng, ns));
1860
+ return this.getResource(lng, ns);
1861
+ }
1862
+ }, {
1863
+ key: "getDataByLanguage",
1864
+ value: function getDataByLanguage(lng) {
1865
+ return this.data[lng];
1866
+ }
1867
+ }, {
1868
+ key: "hasLanguageSomeTranslations",
1869
+ value: function hasLanguageSomeTranslations(lng) {
1870
+ var data = this.getDataByLanguage(lng);
1871
+ var n = data && Object.keys(data) || [];
1872
+ return !!n.find(function (v) {
1873
+ return data[v] && Object.keys(data[v]).length > 0;
1874
+ });
1875
+ }
1876
+ }, {
1877
+ key: "toJSON",
1878
+ value: function toJSON() {
1879
+ return this.data;
1880
+ }
1881
+ }]);
1882
+ return ResourceStore;
1883
+ }(EventEmitter);
1884
+
1885
+ var postProcessor = {
1886
+ processors: {},
1887
+ addPostProcessor: function addPostProcessor(module) {
1888
+ this.processors[module.name] = module;
1889
+ },
1890
+ handle: function handle(processors, value, key, options, translator) {
1891
+ var _this = this;
1892
+ processors.forEach(function (processor) {
1893
+ if (_this.processors[processor]) value = _this.processors[processor].process(value, key, options, translator);
1894
+ });
1895
+ return value;
1896
+ }
1897
+ };
1898
+
1899
+ function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1900
+ function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1901
+ function _createSuper$2(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$2(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
1902
+ function _isNativeReflectConstruct$2() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1903
+ var checkedLoadedFor = {};
1904
+ var Translator$1 = function (_EventEmitter) {
1905
+ _inherits__default["default"](Translator, _EventEmitter);
1906
+ var _super = _createSuper$2(Translator);
1907
+ function Translator(services) {
1908
+ var _this;
1909
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1910
+ _classCallCheck__default["default"](this, Translator);
1911
+ _this = _super.call(this);
1912
+ if (isIE10) {
1913
+ EventEmitter.call(_assertThisInitialized__default["default"](_this));
1914
+ }
1915
+ copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, _assertThisInitialized__default["default"](_this));
1916
+ _this.options = options;
1917
+ if (_this.options.keySeparator === undefined) {
1918
+ _this.options.keySeparator = '.';
1919
+ }
1920
+ _this.logger = baseLogger.create('translator');
1921
+ return _this;
1922
+ }
1923
+ _createClass__default["default"](Translator, [{
1924
+ key: "changeLanguage",
1925
+ value: function changeLanguage(lng) {
1926
+ if (lng) this.language = lng;
1927
+ }
1928
+ }, {
1929
+ key: "exists",
1930
+ value: function exists(key) {
1931
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1932
+ interpolation: {}
1933
+ };
1934
+ if (key === undefined || key === null) {
1935
+ return false;
1936
+ }
1937
+ var resolved = this.resolve(key, options);
1938
+ return resolved && resolved.res !== undefined;
1939
+ }
1940
+ }, {
1941
+ key: "extractFromKey",
1942
+ value: function extractFromKey(key, options) {
1943
+ var nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
1944
+ if (nsSeparator === undefined) nsSeparator = ':';
1945
+ var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
1946
+ var namespaces = options.ns || this.options.defaultNS || [];
1947
+ var wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
1948
+ var seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
1949
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
1950
+ var m = key.match(this.interpolator.nestingRegexp);
1951
+ if (m && m.length > 0) {
1952
+ return {
1953
+ key: key,
1954
+ namespaces: namespaces
1955
+ };
1956
+ }
1957
+ var parts = key.split(nsSeparator);
1958
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
1959
+ key = parts.join(keySeparator);
1960
+ }
1961
+ if (typeof namespaces === 'string') namespaces = [namespaces];
1962
+ return {
1963
+ key: key,
1964
+ namespaces: namespaces
1965
+ };
1966
+ }
1967
+ }, {
1968
+ key: "translate",
1969
+ value: function translate(keys, options, lastKey) {
1970
+ var _this2 = this;
1971
+ if (_typeof__default["default"](options) !== 'object' && this.options.overloadTranslationOptionHandler) {
1972
+ options = this.options.overloadTranslationOptionHandler(arguments);
1973
+ }
1974
+ if (_typeof__default["default"](options) === 'object') options = _objectSpread$4({}, options);
1975
+ if (!options) options = {};
1976
+ if (keys === undefined || keys === null) return '';
1977
+ if (!Array.isArray(keys)) keys = [String(keys)];
1978
+ var returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
1979
+ var keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
1980
+ var _this$extractFromKey = this.extractFromKey(keys[keys.length - 1], options),
1981
+ key = _this$extractFromKey.key,
1982
+ namespaces = _this$extractFromKey.namespaces;
1983
+ var namespace = namespaces[namespaces.length - 1];
1984
+ var lng = options.lng || this.language;
1985
+ var appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
1986
+ if (lng && lng.toLowerCase() === 'cimode') {
1987
+ if (appendNamespaceToCIMode) {
1988
+ var nsSeparator = options.nsSeparator || this.options.nsSeparator;
1989
+ if (returnDetails) {
1990
+ return {
1991
+ res: "".concat(namespace).concat(nsSeparator).concat(key),
1992
+ usedKey: key,
1993
+ exactUsedKey: key,
1994
+ usedLng: lng,
1995
+ usedNS: namespace
1996
+ };
1997
+ }
1998
+ return "".concat(namespace).concat(nsSeparator).concat(key);
1999
+ }
2000
+ if (returnDetails) {
2001
+ return {
2002
+ res: key,
2003
+ usedKey: key,
2004
+ exactUsedKey: key,
2005
+ usedLng: lng,
2006
+ usedNS: namespace
2007
+ };
2008
+ }
2009
+ return key;
2010
+ }
2011
+ var resolved = this.resolve(keys, options);
2012
+ var res = resolved && resolved.res;
2013
+ var resUsedKey = resolved && resolved.usedKey || key;
2014
+ var resExactUsedKey = resolved && resolved.exactUsedKey || key;
2015
+ var resType = Object.prototype.toString.apply(res);
2016
+ var noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
2017
+ var joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
2018
+ var handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
2019
+ var handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
2020
+ if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
2021
+ if (!options.returnObjects && !this.options.returnObjects) {
2022
+ if (!this.options.returnedObjectHandler) {
2023
+ this.logger.warn('accessing an object - but returnObjects options is not enabled!');
2024
+ }
2025
+ var r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, _objectSpread$4(_objectSpread$4({}, options), {}, {
2026
+ ns: namespaces
2027
+ })) : "key '".concat(key, " (").concat(this.language, ")' returned an object instead of string.");
2028
+ if (returnDetails) {
2029
+ resolved.res = r;
2030
+ return resolved;
2031
+ }
2032
+ return r;
2033
+ }
2034
+ if (keySeparator) {
2035
+ var resTypeIsArray = resType === '[object Array]';
2036
+ var copy = resTypeIsArray ? [] : {};
2037
+ var newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
2038
+ for (var m in res) {
2039
+ if (Object.prototype.hasOwnProperty.call(res, m)) {
2040
+ var deepKey = "".concat(newKeyToUse).concat(keySeparator).concat(m);
2041
+ copy[m] = this.translate(deepKey, _objectSpread$4(_objectSpread$4({}, options), {
2042
+ joinArrays: false,
2043
+ ns: namespaces
2044
+ }));
2045
+ if (copy[m] === deepKey) copy[m] = res[m];
2046
+ }
2047
+ }
2048
+ res = copy;
2049
+ }
2050
+ } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
2051
+ res = res.join(joinArrays);
2052
+ if (res) res = this.extendTranslation(res, keys, options, lastKey);
2053
+ } else {
2054
+ var usedDefault = false;
2055
+ var usedKey = false;
2056
+ var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
2057
+ var hasDefaultValue = Translator.hasDefaultValue(options);
2058
+ var defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
2059
+ var defaultValue = options["defaultValue".concat(defaultValueSuffix)] || options.defaultValue;
2060
+ if (!this.isValidLookup(res) && hasDefaultValue) {
2061
+ usedDefault = true;
2062
+ res = defaultValue;
2063
+ }
2064
+ if (!this.isValidLookup(res)) {
2065
+ usedKey = true;
2066
+ res = key;
2067
+ }
2068
+ var missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
2069
+ var resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
2070
+ var updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
2071
+ if (usedKey || usedDefault || updateMissing) {
2072
+ this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
2073
+ if (keySeparator) {
2074
+ var fk = this.resolve(key, _objectSpread$4(_objectSpread$4({}, options), {}, {
2075
+ keySeparator: false
2076
+ }));
2077
+ if (fk && fk.res) this.logger.warn('Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.');
2078
+ }
2079
+ var lngs = [];
2080
+ var fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
2081
+ if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
2082
+ for (var i = 0; i < fallbackLngs.length; i++) {
2083
+ lngs.push(fallbackLngs[i]);
2084
+ }
2085
+ } else if (this.options.saveMissingTo === 'all') {
2086
+ lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
2087
+ } else {
2088
+ lngs.push(options.lng || this.language);
2089
+ }
2090
+ var send = function send(l, k, specificDefaultValue) {
2091
+ var defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
2092
+ if (_this2.options.missingKeyHandler) {
2093
+ _this2.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
2094
+ } else if (_this2.backendConnector && _this2.backendConnector.saveMissing) {
2095
+ _this2.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
2096
+ }
2097
+ _this2.emit('missingKey', l, namespace, k, res);
2098
+ };
2099
+ if (this.options.saveMissing) {
2100
+ if (this.options.saveMissingPlurals && needsPluralHandling) {
2101
+ lngs.forEach(function (language) {
2102
+ _this2.pluralResolver.getSuffixes(language, options).forEach(function (suffix) {
2103
+ send([language], key + suffix, options["defaultValue".concat(suffix)] || defaultValue);
2104
+ });
2105
+ });
2106
+ } else {
2107
+ send(lngs, key, defaultValue);
2108
+ }
2109
+ }
2110
+ }
2111
+ res = this.extendTranslation(res, keys, options, resolved, lastKey);
2112
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = "".concat(namespace, ":").concat(key);
2113
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
2114
+ if (this.options.compatibilityAPI !== 'v1') {
2115
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? "".concat(namespace, ":").concat(key) : key, usedDefault ? res : undefined);
2116
+ } else {
2117
+ res = this.options.parseMissingKeyHandler(res);
2118
+ }
2119
+ }
2120
+ }
2121
+ if (returnDetails) {
2122
+ resolved.res = res;
2123
+ return resolved;
2124
+ }
2125
+ return res;
2126
+ }
2127
+ }, {
2128
+ key: "extendTranslation",
2129
+ value: function extendTranslation(res, key, options, resolved, lastKey) {
2130
+ var _this3 = this;
2131
+ if (this.i18nFormat && this.i18nFormat.parse) {
2132
+ res = this.i18nFormat.parse(res, _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), options), resolved.usedLng, resolved.usedNS, resolved.usedKey, {
2133
+ resolved: resolved
2134
+ });
2135
+ } else if (!options.skipInterpolation) {
2136
+ if (options.interpolation) this.interpolator.init(_objectSpread$4(_objectSpread$4({}, options), {
2137
+ interpolation: _objectSpread$4(_objectSpread$4({}, this.options.interpolation), options.interpolation)
2138
+ }));
2139
+ var skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
2140
+ var nestBef;
2141
+ if (skipOnVariables) {
2142
+ var nb = res.match(this.interpolator.nestingRegexp);
2143
+ nestBef = nb && nb.length;
2144
+ }
2145
+ var data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
2146
+ if (this.options.interpolation.defaultVariables) data = _objectSpread$4(_objectSpread$4({}, this.options.interpolation.defaultVariables), data);
2147
+ res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
2148
+ if (skipOnVariables) {
2149
+ var na = res.match(this.interpolator.nestingRegexp);
2150
+ var nestAft = na && na.length;
2151
+ if (nestBef < nestAft) options.nest = false;
2152
+ }
2153
+ if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = resolved.usedLng;
2154
+ if (options.nest !== false) res = this.interpolator.nest(res, function () {
2155
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2156
+ args[_key] = arguments[_key];
2157
+ }
2158
+ if (lastKey && lastKey[0] === args[0] && !options.context) {
2159
+ _this3.logger.warn("It seems you are nesting recursively key: ".concat(args[0], " in key: ").concat(key[0]));
2160
+ return null;
2161
+ }
2162
+ return _this3.translate.apply(_this3, args.concat([key]));
2163
+ }, options);
2164
+ if (options.interpolation) this.interpolator.reset();
2165
+ }
2166
+ var postProcess = options.postProcess || this.options.postProcess;
2167
+ var postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
2168
+ if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
2169
+ res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? _objectSpread$4({
2170
+ i18nResolved: resolved
2171
+ }, options) : options, this);
2172
+ }
2173
+ return res;
2174
+ }
2175
+ }, {
2176
+ key: "resolve",
2177
+ value: function resolve(keys) {
2178
+ var _this4 = this;
2179
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2180
+ var found;
2181
+ var usedKey;
2182
+ var exactUsedKey;
2183
+ var usedLng;
2184
+ var usedNS;
2185
+ if (typeof keys === 'string') keys = [keys];
2186
+ keys.forEach(function (k) {
2187
+ if (_this4.isValidLookup(found)) return;
2188
+ var extracted = _this4.extractFromKey(k, options);
2189
+ var key = extracted.key;
2190
+ usedKey = key;
2191
+ var namespaces = extracted.namespaces;
2192
+ if (_this4.options.fallbackNS) namespaces = namespaces.concat(_this4.options.fallbackNS);
2193
+ var needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
2194
+ var needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && _this4.pluralResolver.shouldUseIntlApi();
2195
+ var needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
2196
+ var codes = options.lngs ? options.lngs : _this4.languageUtils.toResolveHierarchy(options.lng || _this4.language, options.fallbackLng);
2197
+ namespaces.forEach(function (ns) {
2198
+ if (_this4.isValidLookup(found)) return;
2199
+ usedNS = ns;
2200
+ if (!checkedLoadedFor["".concat(codes[0], "-").concat(ns)] && _this4.utils && _this4.utils.hasLoadedNamespace && !_this4.utils.hasLoadedNamespace(usedNS)) {
2201
+ checkedLoadedFor["".concat(codes[0], "-").concat(ns)] = true;
2202
+ _this4.logger.warn("key \"".concat(usedKey, "\" for languages \"").concat(codes.join(', '), "\" won't get resolved as namespace \"").concat(usedNS, "\" was not yet loaded"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
2203
+ }
2204
+ codes.forEach(function (code) {
2205
+ if (_this4.isValidLookup(found)) return;
2206
+ usedLng = code;
2207
+ var finalKeys = [key];
2208
+ if (_this4.i18nFormat && _this4.i18nFormat.addLookupKeys) {
2209
+ _this4.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
2210
+ } else {
2211
+ var pluralSuffix;
2212
+ if (needsPluralHandling) pluralSuffix = _this4.pluralResolver.getSuffix(code, options.count, options);
2213
+ var zeroSuffix = "".concat(_this4.options.pluralSeparator, "zero");
2214
+ if (needsPluralHandling) {
2215
+ finalKeys.push(key + pluralSuffix);
2216
+ if (needsZeroSuffixLookup) {
2217
+ finalKeys.push(key + zeroSuffix);
2218
+ }
2219
+ }
2220
+ if (needsContextHandling) {
2221
+ var contextKey = "".concat(key).concat(_this4.options.contextSeparator).concat(options.context);
2222
+ finalKeys.push(contextKey);
2223
+ if (needsPluralHandling) {
2224
+ finalKeys.push(contextKey + pluralSuffix);
2225
+ if (needsZeroSuffixLookup) {
2226
+ finalKeys.push(contextKey + zeroSuffix);
2227
+ }
2228
+ }
2229
+ }
2230
+ }
2231
+ var possibleKey;
2232
+ while (possibleKey = finalKeys.pop()) {
2233
+ if (!_this4.isValidLookup(found)) {
2234
+ exactUsedKey = possibleKey;
2235
+ found = _this4.getResource(code, ns, possibleKey, options);
2236
+ }
2237
+ }
2238
+ });
2239
+ });
2240
+ });
2241
+ return {
2242
+ res: found,
2243
+ usedKey: usedKey,
2244
+ exactUsedKey: exactUsedKey,
2245
+ usedLng: usedLng,
2246
+ usedNS: usedNS
2247
+ };
2248
+ }
2249
+ }, {
2250
+ key: "isValidLookup",
2251
+ value: function isValidLookup(res) {
2252
+ return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
2253
+ }
2254
+ }, {
2255
+ key: "getResource",
2256
+ value: function getResource(code, ns, key) {
2257
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2258
+ if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
2259
+ return this.resourceStore.getResource(code, ns, key, options);
2260
+ }
2261
+ }], [{
2262
+ key: "hasDefaultValue",
2263
+ value: function hasDefaultValue(options) {
2264
+ var prefix = 'defaultValue';
2265
+ for (var option in options) {
2266
+ if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
2267
+ return true;
2268
+ }
2269
+ }
2270
+ return false;
2271
+ }
2272
+ }]);
2273
+ return Translator;
2274
+ }(EventEmitter);
2275
+
2276
+ function capitalize(string) {
2277
+ return string.charAt(0).toUpperCase() + string.slice(1);
2278
+ }
2279
+ var LanguageUtil = function () {
2280
+ function LanguageUtil(options) {
2281
+ _classCallCheck__default["default"](this, LanguageUtil);
2282
+ this.options = options;
2283
+ this.supportedLngs = this.options.supportedLngs || false;
2284
+ this.logger = baseLogger.create('languageUtils');
2285
+ }
2286
+ _createClass__default["default"](LanguageUtil, [{
2287
+ key: "getScriptPartFromCode",
2288
+ value: function getScriptPartFromCode(code) {
2289
+ if (!code || code.indexOf('-') < 0) return null;
2290
+ var p = code.split('-');
2291
+ if (p.length === 2) return null;
2292
+ p.pop();
2293
+ if (p[p.length - 1].toLowerCase() === 'x') return null;
2294
+ return this.formatLanguageCode(p.join('-'));
2295
+ }
2296
+ }, {
2297
+ key: "getLanguagePartFromCode",
2298
+ value: function getLanguagePartFromCode(code) {
2299
+ if (!code || code.indexOf('-') < 0) return code;
2300
+ var p = code.split('-');
2301
+ return this.formatLanguageCode(p[0]);
2302
+ }
2303
+ }, {
2304
+ key: "formatLanguageCode",
2305
+ value: function formatLanguageCode(code) {
2306
+ if (typeof code === 'string' && code.indexOf('-') > -1) {
2307
+ var specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
2308
+ var p = code.split('-');
2309
+ if (this.options.lowerCaseLng) {
2310
+ p = p.map(function (part) {
2311
+ return part.toLowerCase();
2312
+ });
2313
+ } else if (p.length === 2) {
2314
+ p[0] = p[0].toLowerCase();
2315
+ p[1] = p[1].toUpperCase();
2316
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
2317
+ } else if (p.length === 3) {
2318
+ p[0] = p[0].toLowerCase();
2319
+ if (p[1].length === 2) p[1] = p[1].toUpperCase();
2320
+ if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
2321
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
2322
+ if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
2323
+ }
2324
+ return p.join('-');
2325
+ }
2326
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
2327
+ }
2328
+ }, {
2329
+ key: "isSupportedCode",
2330
+ value: function isSupportedCode(code) {
2331
+ if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
2332
+ code = this.getLanguagePartFromCode(code);
2333
+ }
2334
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
2335
+ }
2336
+ }, {
2337
+ key: "getBestMatchFromCodes",
2338
+ value: function getBestMatchFromCodes(codes) {
2339
+ var _this = this;
2340
+ if (!codes) return null;
2341
+ var found;
2342
+ codes.forEach(function (code) {
2343
+ if (found) return;
2344
+ var cleanedLng = _this.formatLanguageCode(code);
2345
+ if (!_this.options.supportedLngs || _this.isSupportedCode(cleanedLng)) found = cleanedLng;
2346
+ });
2347
+ if (!found && this.options.supportedLngs) {
2348
+ codes.forEach(function (code) {
2349
+ if (found) return;
2350
+ var lngOnly = _this.getLanguagePartFromCode(code);
2351
+ if (_this.isSupportedCode(lngOnly)) return found = lngOnly;
2352
+ found = _this.options.supportedLngs.find(function (supportedLng) {
2353
+ if (supportedLng === lngOnly) return supportedLng;
2354
+ if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
2355
+ if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
2356
+ });
2357
+ });
2358
+ }
2359
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
2360
+ return found;
2361
+ }
2362
+ }, {
2363
+ key: "getFallbackCodes",
2364
+ value: function getFallbackCodes(fallbacks, code) {
2365
+ if (!fallbacks) return [];
2366
+ if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
2367
+ if (typeof fallbacks === 'string') fallbacks = [fallbacks];
2368
+ if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
2369
+ if (!code) return fallbacks["default"] || [];
2370
+ var found = fallbacks[code];
2371
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
2372
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
2373
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
2374
+ if (!found) found = fallbacks["default"];
2375
+ return found || [];
2376
+ }
2377
+ }, {
2378
+ key: "toResolveHierarchy",
2379
+ value: function toResolveHierarchy(code, fallbackCode) {
2380
+ var _this2 = this;
2381
+ var fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
2382
+ var codes = [];
2383
+ var addCode = function addCode(c) {
2384
+ if (!c) return;
2385
+ if (_this2.isSupportedCode(c)) {
2386
+ codes.push(c);
2387
+ } else {
2388
+ _this2.logger.warn("rejecting language code not found in supportedLngs: ".concat(c));
2389
+ }
2390
+ };
2391
+ if (typeof code === 'string' && code.indexOf('-') > -1) {
2392
+ if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
2393
+ if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
2394
+ if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
2395
+ } else if (typeof code === 'string') {
2396
+ addCode(this.formatLanguageCode(code));
2397
+ }
2398
+ fallbackCodes.forEach(function (fc) {
2399
+ if (codes.indexOf(fc) < 0) addCode(_this2.formatLanguageCode(fc));
2400
+ });
2401
+ return codes;
2402
+ }
2403
+ }]);
2404
+ return LanguageUtil;
2405
+ }();
2406
+
2407
+ var sets = [{
2408
+ lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
2409
+ nr: [1, 2],
2410
+ fc: 1
2411
+ }, {
2412
+ lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
2413
+ nr: [1, 2],
2414
+ fc: 2
2415
+ }, {
2416
+ lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
2417
+ nr: [1],
2418
+ fc: 3
2419
+ }, {
2420
+ lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
2421
+ nr: [1, 2, 5],
2422
+ fc: 4
2423
+ }, {
2424
+ lngs: ['ar'],
2425
+ nr: [0, 1, 2, 3, 11, 100],
2426
+ fc: 5
2427
+ }, {
2428
+ lngs: ['cs', 'sk'],
2429
+ nr: [1, 2, 5],
2430
+ fc: 6
2431
+ }, {
2432
+ lngs: ['csb', 'pl'],
2433
+ nr: [1, 2, 5],
2434
+ fc: 7
2435
+ }, {
2436
+ lngs: ['cy'],
2437
+ nr: [1, 2, 3, 8],
2438
+ fc: 8
2439
+ }, {
2440
+ lngs: ['fr'],
2441
+ nr: [1, 2],
2442
+ fc: 9
2443
+ }, {
2444
+ lngs: ['ga'],
2445
+ nr: [1, 2, 3, 7, 11],
2446
+ fc: 10
2447
+ }, {
2448
+ lngs: ['gd'],
2449
+ nr: [1, 2, 3, 20],
2450
+ fc: 11
2451
+ }, {
2452
+ lngs: ['is'],
2453
+ nr: [1, 2],
2454
+ fc: 12
2455
+ }, {
2456
+ lngs: ['jv'],
2457
+ nr: [0, 1],
2458
+ fc: 13
2459
+ }, {
2460
+ lngs: ['kw'],
2461
+ nr: [1, 2, 3, 4],
2462
+ fc: 14
2463
+ }, {
2464
+ lngs: ['lt'],
2465
+ nr: [1, 2, 10],
2466
+ fc: 15
2467
+ }, {
2468
+ lngs: ['lv'],
2469
+ nr: [1, 2, 0],
2470
+ fc: 16
2471
+ }, {
2472
+ lngs: ['mk'],
2473
+ nr: [1, 2],
2474
+ fc: 17
2475
+ }, {
2476
+ lngs: ['mnk'],
2477
+ nr: [0, 1, 2],
2478
+ fc: 18
2479
+ }, {
2480
+ lngs: ['mt'],
2481
+ nr: [1, 2, 11, 20],
2482
+ fc: 19
2483
+ }, {
2484
+ lngs: ['or'],
2485
+ nr: [2, 1],
2486
+ fc: 2
2487
+ }, {
2488
+ lngs: ['ro'],
2489
+ nr: [1, 2, 20],
2490
+ fc: 20
2491
+ }, {
2492
+ lngs: ['sl'],
2493
+ nr: [5, 1, 2, 3],
2494
+ fc: 21
2495
+ }, {
2496
+ lngs: ['he', 'iw'],
2497
+ nr: [1, 2, 20, 21],
2498
+ fc: 22
2499
+ }];
2500
+ var _rulesPluralsTypes = {
2501
+ 1: function _(n) {
2502
+ return Number(n > 1);
2503
+ },
2504
+ 2: function _(n) {
2505
+ return Number(n != 1);
2506
+ },
2507
+ 3: function _(n) {
2508
+ return 0;
2509
+ },
2510
+ 4: function _(n) {
2511
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
2512
+ },
2513
+ 5: function _(n) {
2514
+ return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
2515
+ },
2516
+ 6: function _(n) {
2517
+ return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
2518
+ },
2519
+ 7: function _(n) {
2520
+ return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
2521
+ },
2522
+ 8: function _(n) {
2523
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
2524
+ },
2525
+ 9: function _(n) {
2526
+ return Number(n >= 2);
2527
+ },
2528
+ 10: function _(n) {
2529
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
2530
+ },
2531
+ 11: function _(n) {
2532
+ return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
2533
+ },
2534
+ 12: function _(n) {
2535
+ return Number(n % 10 != 1 || n % 100 == 11);
2536
+ },
2537
+ 13: function _(n) {
2538
+ return Number(n !== 0);
2539
+ },
2540
+ 14: function _(n) {
2541
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
2542
+ },
2543
+ 15: function _(n) {
2544
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
2545
+ },
2546
+ 16: function _(n) {
2547
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
2548
+ },
2549
+ 17: function _(n) {
2550
+ return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
2551
+ },
2552
+ 18: function _(n) {
2553
+ return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
2554
+ },
2555
+ 19: function _(n) {
2556
+ return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
2557
+ },
2558
+ 20: function _(n) {
2559
+ return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
2560
+ },
2561
+ 21: function _(n) {
2562
+ return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
2563
+ },
2564
+ 22: function _(n) {
2565
+ return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
2566
+ }
2567
+ };
2568
+ var deprecatedJsonVersions = ['v1', 'v2', 'v3'];
2569
+ var suffixesOrder = {
2570
+ zero: 0,
2571
+ one: 1,
2572
+ two: 2,
2573
+ few: 3,
2574
+ many: 4,
2575
+ other: 5
2576
+ };
2577
+ function createRules() {
2578
+ var rules = {};
2579
+ sets.forEach(function (set) {
2580
+ set.lngs.forEach(function (l) {
2581
+ rules[l] = {
2582
+ numbers: set.nr,
2583
+ plurals: _rulesPluralsTypes[set.fc]
2584
+ };
2585
+ });
2586
+ });
2587
+ return rules;
2588
+ }
2589
+ var PluralResolver = function () {
2590
+ function PluralResolver(languageUtils) {
2591
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2592
+ _classCallCheck__default["default"](this, PluralResolver);
2593
+ this.languageUtils = languageUtils;
2594
+ this.options = options;
2595
+ this.logger = baseLogger.create('pluralResolver');
2596
+ if ((!this.options.compatibilityJSON || this.options.compatibilityJSON === 'v4') && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
2597
+ this.options.compatibilityJSON = 'v3';
2598
+ this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
2599
+ }
2600
+ this.rules = createRules();
2601
+ }
2602
+ _createClass__default["default"](PluralResolver, [{
2603
+ key: "addRule",
2604
+ value: function addRule(lng, obj) {
2605
+ this.rules[lng] = obj;
2606
+ }
2607
+ }, {
2608
+ key: "getRule",
2609
+ value: function getRule(code) {
2610
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2611
+ if (this.shouldUseIntlApi()) {
2612
+ try {
2613
+ return new Intl.PluralRules(code, {
2614
+ type: options.ordinal ? 'ordinal' : 'cardinal'
2615
+ });
2616
+ } catch (_unused) {
2617
+ return;
2618
+ }
2619
+ }
2620
+ return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
2621
+ }
2622
+ }, {
2623
+ key: "needsPlural",
2624
+ value: function needsPlural(code) {
2625
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2626
+ var rule = this.getRule(code, options);
2627
+ if (this.shouldUseIntlApi()) {
2628
+ return rule && rule.resolvedOptions().pluralCategories.length > 1;
2629
+ }
2630
+ return rule && rule.numbers.length > 1;
2631
+ }
2632
+ }, {
2633
+ key: "getPluralFormsOfKey",
2634
+ value: function getPluralFormsOfKey(code, key) {
2635
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2636
+ return this.getSuffixes(code, options).map(function (suffix) {
2637
+ return "".concat(key).concat(suffix);
2638
+ });
2639
+ }
2640
+ }, {
2641
+ key: "getSuffixes",
2642
+ value: function getSuffixes(code) {
2643
+ var _this = this;
2644
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2645
+ var rule = this.getRule(code, options);
2646
+ if (!rule) {
2647
+ return [];
2648
+ }
2649
+ if (this.shouldUseIntlApi()) {
2650
+ return rule.resolvedOptions().pluralCategories.sort(function (pluralCategory1, pluralCategory2) {
2651
+ return suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2];
2652
+ }).map(function (pluralCategory) {
2653
+ return "".concat(_this.options.prepend).concat(pluralCategory);
2654
+ });
2655
+ }
2656
+ return rule.numbers.map(function (number) {
2657
+ return _this.getSuffix(code, number, options);
2658
+ });
2659
+ }
2660
+ }, {
2661
+ key: "getSuffix",
2662
+ value: function getSuffix(code, count) {
2663
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2664
+ var rule = this.getRule(code, options);
2665
+ if (rule) {
2666
+ if (this.shouldUseIntlApi()) {
2667
+ return "".concat(this.options.prepend).concat(rule.select(count));
2668
+ }
2669
+ return this.getSuffixRetroCompatible(rule, count);
2670
+ }
2671
+ this.logger.warn("no plural rule found for: ".concat(code));
2672
+ return '';
2673
+ }
2674
+ }, {
2675
+ key: "getSuffixRetroCompatible",
2676
+ value: function getSuffixRetroCompatible(rule, count) {
2677
+ var _this2 = this;
2678
+ var idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
2679
+ var suffix = rule.numbers[idx];
2680
+ if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
2681
+ if (suffix === 2) {
2682
+ suffix = 'plural';
2683
+ } else if (suffix === 1) {
2684
+ suffix = '';
2685
+ }
2686
+ }
2687
+ var returnSuffix = function returnSuffix() {
2688
+ return _this2.options.prepend && suffix.toString() ? _this2.options.prepend + suffix.toString() : suffix.toString();
2689
+ };
2690
+ if (this.options.compatibilityJSON === 'v1') {
2691
+ if (suffix === 1) return '';
2692
+ if (typeof suffix === 'number') return "_plural_".concat(suffix.toString());
2693
+ return returnSuffix();
2694
+ } else if (this.options.compatibilityJSON === 'v2') {
2695
+ return returnSuffix();
2696
+ } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
2697
+ return returnSuffix();
2698
+ }
2699
+ return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
2700
+ }
2701
+ }, {
2702
+ key: "shouldUseIntlApi",
2703
+ value: function shouldUseIntlApi() {
2704
+ return !deprecatedJsonVersions.includes(this.options.compatibilityJSON);
2705
+ }
2706
+ }]);
2707
+ return PluralResolver;
2708
+ }();
2709
+
2710
+ function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2711
+ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2712
+ function deepFindWithDefaults(data, defaultData, key) {
2713
+ var keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
2714
+ var ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
2715
+ var path = getPathWithDefaults(data, defaultData, key);
2716
+ if (!path && ignoreJSONStructure && typeof key === 'string') {
2717
+ path = deepFind(data, key, keySeparator);
2718
+ if (path === undefined) path = deepFind(defaultData, key, keySeparator);
2719
+ }
2720
+ return path;
2721
+ }
2722
+ var Interpolator = function () {
2723
+ function Interpolator() {
2724
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2725
+ _classCallCheck__default["default"](this, Interpolator);
2726
+ this.logger = baseLogger.create('interpolator');
2727
+ this.options = options;
2728
+ this.format = options.interpolation && options.interpolation.format || function (value) {
2729
+ return value;
2730
+ };
2731
+ this.init(options);
2732
+ }
2733
+ _createClass__default["default"](Interpolator, [{
2734
+ key: "init",
2735
+ value: function init() {
2736
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2737
+ if (!options.interpolation) options.interpolation = {
2738
+ escapeValue: true
2739
+ };
2740
+ var iOpts = options.interpolation;
2741
+ this.escape = iOpts.escape !== undefined ? iOpts.escape : escape$1;
2742
+ this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
2743
+ this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
2744
+ this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
2745
+ this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
2746
+ this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
2747
+ this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
2748
+ this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
2749
+ this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
2750
+ this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
2751
+ this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
2752
+ this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
2753
+ this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
2754
+ this.resetRegExp();
2755
+ }
2756
+ }, {
2757
+ key: "reset",
2758
+ value: function reset() {
2759
+ if (this.options) this.init(this.options);
2760
+ }
2761
+ }, {
2762
+ key: "resetRegExp",
2763
+ value: function resetRegExp() {
2764
+ var regexpStr = "".concat(this.prefix, "(.+?)").concat(this.suffix);
2765
+ this.regexp = new RegExp(regexpStr, 'g');
2766
+ var regexpUnescapeStr = "".concat(this.prefix).concat(this.unescapePrefix, "(.+?)").concat(this.unescapeSuffix).concat(this.suffix);
2767
+ this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
2768
+ var nestingRegexpStr = "".concat(this.nestingPrefix, "(.+?)").concat(this.nestingSuffix);
2769
+ this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
2770
+ }
2771
+ }, {
2772
+ key: "interpolate",
2773
+ value: function interpolate(str, data, lng, options) {
2774
+ var _this = this;
2775
+ var match;
2776
+ var value;
2777
+ var replaces;
2778
+ var defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
2779
+ function regexSafe(val) {
2780
+ return val.replace(/\$/g, '$$$$');
2781
+ }
2782
+ var handleFormat = function handleFormat(key) {
2783
+ if (key.indexOf(_this.formatSeparator) < 0) {
2784
+ var path = deepFindWithDefaults(data, defaultData, key, _this.options.keySeparator, _this.options.ignoreJSONStructure);
2785
+ return _this.alwaysFormat ? _this.format(path, undefined, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
2786
+ interpolationkey: key
2787
+ })) : path;
2788
+ }
2789
+ var p = key.split(_this.formatSeparator);
2790
+ var k = p.shift().trim();
2791
+ var f = p.join(_this.formatSeparator).trim();
2792
+ return _this.format(deepFindWithDefaults(data, defaultData, k, _this.options.keySeparator, _this.options.ignoreJSONStructure), f, lng, _objectSpread$3(_objectSpread$3(_objectSpread$3({}, options), data), {}, {
2793
+ interpolationkey: k
2794
+ }));
2795
+ };
2796
+ this.resetRegExp();
2797
+ var missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
2798
+ var skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
2799
+ var todos = [{
2800
+ regex: this.regexpUnescape,
2801
+ safeValue: function safeValue(val) {
2802
+ return regexSafe(val);
2803
+ }
2804
+ }, {
2805
+ regex: this.regexp,
2806
+ safeValue: function safeValue(val) {
2807
+ return _this.escapeValue ? regexSafe(_this.escape(val)) : regexSafe(val);
2808
+ }
2809
+ }];
2810
+ todos.forEach(function (todo) {
2811
+ replaces = 0;
2812
+ while (match = todo.regex.exec(str)) {
2813
+ var matchedVar = match[1].trim();
2814
+ value = handleFormat(matchedVar);
2815
+ if (value === undefined) {
2816
+ if (typeof missingInterpolationHandler === 'function') {
2817
+ var temp = missingInterpolationHandler(str, match, options);
2818
+ value = typeof temp === 'string' ? temp : '';
2819
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
2820
+ value = '';
2821
+ } else if (skipOnVariables) {
2822
+ value = match[0];
2823
+ continue;
2824
+ } else {
2825
+ _this.logger.warn("missed to pass in variable ".concat(matchedVar, " for interpolating ").concat(str));
2826
+ value = '';
2827
+ }
2828
+ } else if (typeof value !== 'string' && !_this.useRawValueToEscape) {
2829
+ value = makeString(value);
2830
+ }
2831
+ var safeValue = todo.safeValue(value);
2832
+ str = str.replace(match[0], safeValue);
2833
+ if (skipOnVariables) {
2834
+ todo.regex.lastIndex += value.length;
2835
+ todo.regex.lastIndex -= match[0].length;
2836
+ } else {
2837
+ todo.regex.lastIndex = 0;
2838
+ }
2839
+ replaces++;
2840
+ if (replaces >= _this.maxReplaces) {
2841
+ break;
2842
+ }
2843
+ }
2844
+ });
2845
+ return str;
2846
+ }
2847
+ }, {
2848
+ key: "nest",
2849
+ value: function nest(str, fc) {
2850
+ var _this2 = this;
2851
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2852
+ var match;
2853
+ var value;
2854
+ var clonedOptions;
2855
+ function handleHasOptions(key, inheritedOptions) {
2856
+ var sep = this.nestingOptionsSeparator;
2857
+ if (key.indexOf(sep) < 0) return key;
2858
+ var c = key.split(new RegExp("".concat(sep, "[ ]*{")));
2859
+ var optionsString = "{".concat(c[1]);
2860
+ key = c[0];
2861
+ optionsString = this.interpolate(optionsString, clonedOptions);
2862
+ var matchedSingleQuotes = optionsString.match(/'/g);
2863
+ var matchedDoubleQuotes = optionsString.match(/"/g);
2864
+ if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
2865
+ optionsString = optionsString.replace(/'/g, '"');
2866
+ }
2867
+ try {
2868
+ clonedOptions = JSON.parse(optionsString);
2869
+ if (inheritedOptions) clonedOptions = _objectSpread$3(_objectSpread$3({}, inheritedOptions), clonedOptions);
2870
+ } catch (e) {
2871
+ this.logger.warn("failed parsing options string in nesting for key ".concat(key), e);
2872
+ return "".concat(key).concat(sep).concat(optionsString);
2873
+ }
2874
+ delete clonedOptions.defaultValue;
2875
+ return key;
2876
+ }
2877
+ while (match = this.nestingRegexp.exec(str)) {
2878
+ var formatters = [];
2879
+ clonedOptions = _objectSpread$3({}, options);
2880
+ clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
2881
+ clonedOptions.applyPostProcessor = false;
2882
+ delete clonedOptions.defaultValue;
2883
+ var doReduce = false;
2884
+ if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
2885
+ var r = match[1].split(this.formatSeparator).map(function (elem) {
2886
+ return elem.trim();
2887
+ });
2888
+ match[1] = r.shift();
2889
+ formatters = r;
2890
+ doReduce = true;
2891
+ }
2892
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
2893
+ if (value && match[0] === str && typeof value !== 'string') return value;
2894
+ if (typeof value !== 'string') value = makeString(value);
2895
+ if (!value) {
2896
+ this.logger.warn("missed to resolve ".concat(match[1], " for nesting ").concat(str));
2897
+ value = '';
2898
+ }
2899
+ if (doReduce) {
2900
+ value = formatters.reduce(function (v, f) {
2901
+ return _this2.format(v, f, options.lng, _objectSpread$3(_objectSpread$3({}, options), {}, {
2902
+ interpolationkey: match[1].trim()
2903
+ }));
2904
+ }, value.trim());
2905
+ }
2906
+ str = str.replace(match[0], value);
2907
+ this.regexp.lastIndex = 0;
2908
+ }
2909
+ return str;
2910
+ }
2911
+ }]);
2912
+ return Interpolator;
2913
+ }();
2914
+
2915
+ function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2916
+ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2917
+ function parseFormatStr(formatStr) {
2918
+ var formatName = formatStr.toLowerCase().trim();
2919
+ var formatOptions = {};
2920
+ if (formatStr.indexOf('(') > -1) {
2921
+ var p = formatStr.split('(');
2922
+ formatName = p[0].toLowerCase().trim();
2923
+ var optStr = p[1].substring(0, p[1].length - 1);
2924
+ if (formatName === 'currency' && optStr.indexOf(':') < 0) {
2925
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
2926
+ } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
2927
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
2928
+ } else {
2929
+ var opts = optStr.split(';');
2930
+ opts.forEach(function (opt) {
2931
+ if (!opt) return;
2932
+ var _opt$split = opt.split(':'),
2933
+ _opt$split2 = _toArray__default["default"](_opt$split),
2934
+ key = _opt$split2[0],
2935
+ rest = _opt$split2.slice(1);
2936
+ var val = rest.join(':').trim().replace(/^'+|'+$/g, '');
2937
+ if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
2938
+ if (val === 'false') formatOptions[key.trim()] = false;
2939
+ if (val === 'true') formatOptions[key.trim()] = true;
2940
+ if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);
2941
+ });
2942
+ }
2943
+ }
2944
+ return {
2945
+ formatName: formatName,
2946
+ formatOptions: formatOptions
2947
+ };
2948
+ }
2949
+ function createCachedFormatter(fn) {
2950
+ var cache = {};
2951
+ return function invokeFormatter(val, lng, options) {
2952
+ var key = lng + JSON.stringify(options);
2953
+ var formatter = cache[key];
2954
+ if (!formatter) {
2955
+ formatter = fn(lng, options);
2956
+ cache[key] = formatter;
2957
+ }
2958
+ return formatter(val);
2959
+ };
2960
+ }
2961
+ var Formatter = function () {
2962
+ function Formatter() {
2963
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2964
+ _classCallCheck__default["default"](this, Formatter);
2965
+ this.logger = baseLogger.create('formatter');
2966
+ this.options = options;
2967
+ this.formats = {
2968
+ number: createCachedFormatter(function (lng, opt) {
2969
+ var formatter = new Intl.NumberFormat(lng, _objectSpread$2({}, opt));
2970
+ return function (val) {
2971
+ return formatter.format(val);
2972
+ };
2973
+ }),
2974
+ currency: createCachedFormatter(function (lng, opt) {
2975
+ var formatter = new Intl.NumberFormat(lng, _objectSpread$2(_objectSpread$2({}, opt), {}, {
2976
+ style: 'currency'
2977
+ }));
2978
+ return function (val) {
2979
+ return formatter.format(val);
2980
+ };
2981
+ }),
2982
+ datetime: createCachedFormatter(function (lng, opt) {
2983
+ var formatter = new Intl.DateTimeFormat(lng, _objectSpread$2({}, opt));
2984
+ return function (val) {
2985
+ return formatter.format(val);
2986
+ };
2987
+ }),
2988
+ relativetime: createCachedFormatter(function (lng, opt) {
2989
+ var formatter = new Intl.RelativeTimeFormat(lng, _objectSpread$2({}, opt));
2990
+ return function (val) {
2991
+ return formatter.format(val, opt.range || 'day');
2992
+ };
2993
+ }),
2994
+ list: createCachedFormatter(function (lng, opt) {
2995
+ var formatter = new Intl.ListFormat(lng, _objectSpread$2({}, opt));
2996
+ return function (val) {
2997
+ return formatter.format(val);
2998
+ };
2999
+ })
3000
+ };
3001
+ this.init(options);
3002
+ }
3003
+ _createClass__default["default"](Formatter, [{
3004
+ key: "init",
3005
+ value: function init(services) {
3006
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
3007
+ interpolation: {}
3008
+ };
3009
+ var iOpts = options.interpolation;
3010
+ this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
3011
+ }
3012
+ }, {
3013
+ key: "add",
3014
+ value: function add(name, fc) {
3015
+ this.formats[name.toLowerCase().trim()] = fc;
3016
+ }
3017
+ }, {
3018
+ key: "addCached",
3019
+ value: function addCached(name, fc) {
3020
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
3021
+ }
3022
+ }, {
3023
+ key: "format",
3024
+ value: function format(value, _format, lng) {
3025
+ var _this = this;
3026
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3027
+ var formats = _format.split(this.formatSeparator);
3028
+ var result = formats.reduce(function (mem, f) {
3029
+ var _parseFormatStr = parseFormatStr(f),
3030
+ formatName = _parseFormatStr.formatName,
3031
+ formatOptions = _parseFormatStr.formatOptions;
3032
+ if (_this.formats[formatName]) {
3033
+ var formatted = mem;
3034
+ try {
3035
+ var valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
3036
+ var l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
3037
+ formatted = _this.formats[formatName](mem, l, _objectSpread$2(_objectSpread$2(_objectSpread$2({}, formatOptions), options), valOptions));
3038
+ } catch (error) {
3039
+ _this.logger.warn(error);
3040
+ }
3041
+ return formatted;
3042
+ } else {
3043
+ _this.logger.warn("there was no format function for ".concat(formatName));
3044
+ }
3045
+ return mem;
3046
+ }, value);
3047
+ return result;
3048
+ }
3049
+ }]);
3050
+ return Formatter;
3051
+ }();
3052
+
3053
+ function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3054
+ function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3055
+ function _createSuper$1(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$1(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
3056
+ function _isNativeReflectConstruct$1() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
3057
+ function removePending(q, name) {
3058
+ if (q.pending[name] !== undefined) {
3059
+ delete q.pending[name];
3060
+ q.pendingCount--;
3061
+ }
3062
+ }
3063
+ var Connector = function (_EventEmitter) {
3064
+ _inherits__default["default"](Connector, _EventEmitter);
3065
+ var _super = _createSuper$1(Connector);
3066
+ function Connector(backend, store, services) {
3067
+ var _this;
3068
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
3069
+ _classCallCheck__default["default"](this, Connector);
3070
+ _this = _super.call(this);
3071
+ if (isIE10) {
3072
+ EventEmitter.call(_assertThisInitialized__default["default"](_this));
3073
+ }
3074
+ _this.backend = backend;
3075
+ _this.store = store;
3076
+ _this.services = services;
3077
+ _this.languageUtils = services.languageUtils;
3078
+ _this.options = options;
3079
+ _this.logger = baseLogger.create('backendConnector');
3080
+ _this.waitingReads = [];
3081
+ _this.maxParallelReads = options.maxParallelReads || 10;
3082
+ _this.readingCalls = 0;
3083
+ _this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
3084
+ _this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
3085
+ _this.state = {};
3086
+ _this.queue = [];
3087
+ if (_this.backend && _this.backend.init) {
3088
+ _this.backend.init(services, options.backend, options);
3089
+ }
3090
+ return _this;
3091
+ }
3092
+ _createClass__default["default"](Connector, [{
3093
+ key: "queueLoad",
3094
+ value: function queueLoad(languages, namespaces, options, callback) {
3095
+ var _this2 = this;
3096
+ var toLoad = {};
3097
+ var pending = {};
3098
+ var toLoadLanguages = {};
3099
+ var toLoadNamespaces = {};
3100
+ languages.forEach(function (lng) {
3101
+ var hasAllNamespaces = true;
3102
+ namespaces.forEach(function (ns) {
3103
+ var name = "".concat(lng, "|").concat(ns);
3104
+ if (!options.reload && _this2.store.hasResourceBundle(lng, ns)) {
3105
+ _this2.state[name] = 2;
3106
+ } else if (_this2.state[name] < 0) ; else if (_this2.state[name] === 1) {
3107
+ if (pending[name] === undefined) pending[name] = true;
3108
+ } else {
3109
+ _this2.state[name] = 1;
3110
+ hasAllNamespaces = false;
3111
+ if (pending[name] === undefined) pending[name] = true;
3112
+ if (toLoad[name] === undefined) toLoad[name] = true;
3113
+ if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
3114
+ }
3115
+ });
3116
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
3117
+ });
3118
+ if (Object.keys(toLoad).length || Object.keys(pending).length) {
3119
+ this.queue.push({
3120
+ pending: pending,
3121
+ pendingCount: Object.keys(pending).length,
3122
+ loaded: {},
3123
+ errors: [],
3124
+ callback: callback
3125
+ });
3126
+ }
3127
+ return {
3128
+ toLoad: Object.keys(toLoad),
3129
+ pending: Object.keys(pending),
3130
+ toLoadLanguages: Object.keys(toLoadLanguages),
3131
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
3132
+ };
3133
+ }
3134
+ }, {
3135
+ key: "loaded",
3136
+ value: function loaded(name, err, data) {
3137
+ var s = name.split('|');
3138
+ var lng = s[0];
3139
+ var ns = s[1];
3140
+ if (err) this.emit('failedLoading', lng, ns, err);
3141
+ if (data) {
3142
+ this.store.addResourceBundle(lng, ns, data);
3143
+ }
3144
+ this.state[name] = err ? -1 : 2;
3145
+ var loaded = {};
3146
+ this.queue.forEach(function (q) {
3147
+ pushPath(q.loaded, [lng], ns);
3148
+ removePending(q, name);
3149
+ if (err) q.errors.push(err);
3150
+ if (q.pendingCount === 0 && !q.done) {
3151
+ Object.keys(q.loaded).forEach(function (l) {
3152
+ if (!loaded[l]) loaded[l] = {};
3153
+ var loadedKeys = q.loaded[l];
3154
+ if (loadedKeys.length) {
3155
+ loadedKeys.forEach(function (n) {
3156
+ if (loaded[l][n] === undefined) loaded[l][n] = true;
3157
+ });
3158
+ }
3159
+ });
3160
+ q.done = true;
3161
+ if (q.errors.length) {
3162
+ q.callback(q.errors);
3163
+ } else {
3164
+ q.callback();
3165
+ }
3166
+ }
3167
+ });
3168
+ this.emit('loaded', loaded);
3169
+ this.queue = this.queue.filter(function (q) {
3170
+ return !q.done;
3171
+ });
3172
+ }
3173
+ }, {
3174
+ key: "read",
3175
+ value: function read(lng, ns, fcName) {
3176
+ var _this3 = this;
3177
+ var tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
3178
+ var wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
3179
+ var callback = arguments.length > 5 ? arguments[5] : undefined;
3180
+ if (!lng.length) return callback(null, {});
3181
+ if (this.readingCalls >= this.maxParallelReads) {
3182
+ this.waitingReads.push({
3183
+ lng: lng,
3184
+ ns: ns,
3185
+ fcName: fcName,
3186
+ tried: tried,
3187
+ wait: wait,
3188
+ callback: callback
3189
+ });
3190
+ return;
3191
+ }
3192
+ this.readingCalls++;
3193
+ var resolver = function resolver(err, data) {
3194
+ _this3.readingCalls--;
3195
+ if (_this3.waitingReads.length > 0) {
3196
+ var next = _this3.waitingReads.shift();
3197
+ _this3.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
3198
+ }
3199
+ if (err && data && tried < _this3.maxRetries) {
3200
+ setTimeout(function () {
3201
+ _this3.read.call(_this3, lng, ns, fcName, tried + 1, wait * 2, callback);
3202
+ }, wait);
3203
+ return;
3204
+ }
3205
+ callback(err, data);
3206
+ };
3207
+ var fc = this.backend[fcName].bind(this.backend);
3208
+ if (fc.length === 2) {
3209
+ try {
3210
+ var r = fc(lng, ns);
3211
+ if (r && typeof r.then === 'function') {
3212
+ r.then(function (data) {
3213
+ return resolver(null, data);
3214
+ })["catch"](resolver);
3215
+ } else {
3216
+ resolver(null, r);
3217
+ }
3218
+ } catch (err) {
3219
+ resolver(err);
3220
+ }
3221
+ return;
3222
+ }
3223
+ return fc(lng, ns, resolver);
3224
+ }
3225
+ }, {
3226
+ key: "prepareLoading",
3227
+ value: function prepareLoading(languages, namespaces) {
3228
+ var _this4 = this;
3229
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
3230
+ var callback = arguments.length > 3 ? arguments[3] : undefined;
3231
+ if (!this.backend) {
3232
+ this.logger.warn('No backend was added via i18next.use. Will not load resources.');
3233
+ return callback && callback();
3234
+ }
3235
+ if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
3236
+ if (typeof namespaces === 'string') namespaces = [namespaces];
3237
+ var toLoad = this.queueLoad(languages, namespaces, options, callback);
3238
+ if (!toLoad.toLoad.length) {
3239
+ if (!toLoad.pending.length) callback();
3240
+ return null;
3241
+ }
3242
+ toLoad.toLoad.forEach(function (name) {
3243
+ _this4.loadOne(name);
3244
+ });
3245
+ }
3246
+ }, {
3247
+ key: "load",
3248
+ value: function load(languages, namespaces, callback) {
3249
+ this.prepareLoading(languages, namespaces, {}, callback);
3250
+ }
3251
+ }, {
3252
+ key: "reload",
3253
+ value: function reload(languages, namespaces, callback) {
3254
+ this.prepareLoading(languages, namespaces, {
3255
+ reload: true
3256
+ }, callback);
3257
+ }
3258
+ }, {
3259
+ key: "loadOne",
3260
+ value: function loadOne(name) {
3261
+ var _this5 = this;
3262
+ var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
3263
+ var s = name.split('|');
3264
+ var lng = s[0];
3265
+ var ns = s[1];
3266
+ this.read(lng, ns, 'read', undefined, undefined, function (err, data) {
3267
+ if (err) _this5.logger.warn("".concat(prefix, "loading namespace ").concat(ns, " for language ").concat(lng, " failed"), err);
3268
+ if (!err && data) _this5.logger.log("".concat(prefix, "loaded namespace ").concat(ns, " for language ").concat(lng), data);
3269
+ _this5.loaded(name, err, data);
3270
+ });
3271
+ }
3272
+ }, {
3273
+ key: "saveMissing",
3274
+ value: function saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
3275
+ var options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
3276
+ var clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : function () {};
3277
+ if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
3278
+ this.logger.warn("did not save key \"".concat(key, "\" as the namespace \"").concat(namespace, "\" was not yet loaded"), 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
3279
+ return;
3280
+ }
3281
+ if (key === undefined || key === null || key === '') return;
3282
+ if (this.backend && this.backend.create) {
3283
+ var opts = _objectSpread$1(_objectSpread$1({}, options), {}, {
3284
+ isUpdate: isUpdate
3285
+ });
3286
+ var fc = this.backend.create.bind(this.backend);
3287
+ if (fc.length < 6) {
3288
+ try {
3289
+ var r;
3290
+ if (fc.length === 5) {
3291
+ r = fc(languages, namespace, key, fallbackValue, opts);
3292
+ } else {
3293
+ r = fc(languages, namespace, key, fallbackValue);
3294
+ }
3295
+ if (r && typeof r.then === 'function') {
3296
+ r.then(function (data) {
3297
+ return clb(null, data);
3298
+ })["catch"](clb);
3299
+ } else {
3300
+ clb(null, r);
3301
+ }
3302
+ } catch (err) {
3303
+ clb(err);
3304
+ }
3305
+ } else {
3306
+ fc(languages, namespace, key, fallbackValue, clb, opts);
3307
+ }
3308
+ }
3309
+ if (!languages || !languages[0]) return;
3310
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
3311
+ }
3312
+ }]);
3313
+ return Connector;
3314
+ }(EventEmitter);
3315
+
3316
+ function get() {
3317
+ return {
3318
+ debug: false,
3319
+ initImmediate: true,
3320
+ ns: ['translation'],
3321
+ defaultNS: ['translation'],
3322
+ fallbackLng: ['dev'],
3323
+ fallbackNS: false,
3324
+ supportedLngs: false,
3325
+ nonExplicitSupportedLngs: false,
3326
+ load: 'all',
3327
+ preload: false,
3328
+ simplifyPluralSuffix: true,
3329
+ keySeparator: '.',
3330
+ nsSeparator: ':',
3331
+ pluralSeparator: '_',
3332
+ contextSeparator: '_',
3333
+ partialBundledLanguages: false,
3334
+ saveMissing: false,
3335
+ updateMissing: false,
3336
+ saveMissingTo: 'fallback',
3337
+ saveMissingPlurals: true,
3338
+ missingKeyHandler: false,
3339
+ missingInterpolationHandler: false,
3340
+ postProcess: false,
3341
+ postProcessPassResolved: false,
3342
+ returnNull: true,
3343
+ returnEmptyString: true,
3344
+ returnObjects: false,
3345
+ joinArrays: false,
3346
+ returnedObjectHandler: false,
3347
+ parseMissingKeyHandler: false,
3348
+ appendNamespaceToMissingKey: false,
3349
+ appendNamespaceToCIMode: false,
3350
+ overloadTranslationOptionHandler: function handle(args) {
3351
+ var ret = {};
3352
+ if (_typeof__default["default"](args[1]) === 'object') ret = args[1];
3353
+ if (typeof args[1] === 'string') ret.defaultValue = args[1];
3354
+ if (typeof args[2] === 'string') ret.tDescription = args[2];
3355
+ if (_typeof__default["default"](args[2]) === 'object' || _typeof__default["default"](args[3]) === 'object') {
3356
+ var options = args[3] || args[2];
3357
+ Object.keys(options).forEach(function (key) {
3358
+ ret[key] = options[key];
3359
+ });
3360
+ }
3361
+ return ret;
3362
+ },
3363
+ interpolation: {
3364
+ escapeValue: true,
3365
+ format: function format(value, _format, lng, options) {
3366
+ return value;
3367
+ },
3368
+ prefix: '{{',
3369
+ suffix: '}}',
3370
+ formatSeparator: ',',
3371
+ unescapePrefix: '-',
3372
+ nestingPrefix: '$t(',
3373
+ nestingSuffix: ')',
3374
+ nestingOptionsSeparator: ',',
3375
+ maxReplaces: 1000,
3376
+ skipOnVariables: true
3377
+ }
3378
+ };
3379
+ }
3380
+ function transformOptions(options) {
3381
+ if (typeof options.ns === 'string') options.ns = [options.ns];
3382
+ if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
3383
+ if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
3384
+ if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
3385
+ options.supportedLngs = options.supportedLngs.concat(['cimode']);
3386
+ }
3387
+ return options;
3388
+ }
3389
+
3390
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3391
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3392
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf__default["default"](Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf__default["default"](this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn__default["default"](this, result); }; }
3393
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
3394
+ function noop() {}
3395
+ function bindMemberFunctions(inst) {
3396
+ var mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
3397
+ mems.forEach(function (mem) {
3398
+ if (typeof inst[mem] === 'function') {
3399
+ inst[mem] = inst[mem].bind(inst);
3400
+ }
3401
+ });
3402
+ }
3403
+ var I18n = function (_EventEmitter) {
3404
+ _inherits__default["default"](I18n, _EventEmitter);
3405
+ var _super = _createSuper(I18n);
3406
+ function I18n() {
3407
+ var _this;
3408
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3409
+ var callback = arguments.length > 1 ? arguments[1] : undefined;
3410
+ _classCallCheck__default["default"](this, I18n);
3411
+ _this = _super.call(this);
3412
+ if (isIE10) {
3413
+ EventEmitter.call(_assertThisInitialized__default["default"](_this));
3414
+ }
3415
+ _this.options = transformOptions(options);
3416
+ _this.services = {};
3417
+ _this.logger = baseLogger;
3418
+ _this.modules = {
3419
+ external: []
3420
+ };
3421
+ bindMemberFunctions(_assertThisInitialized__default["default"](_this));
3422
+ if (callback && !_this.isInitialized && !options.isClone) {
3423
+ if (!_this.options.initImmediate) {
3424
+ _this.init(options, callback);
3425
+ return _possibleConstructorReturn__default["default"](_this, _assertThisInitialized__default["default"](_this));
3426
+ }
3427
+ setTimeout(function () {
3428
+ _this.init(options, callback);
3429
+ }, 0);
3430
+ }
3431
+ return _this;
3432
+ }
3433
+ _createClass__default["default"](I18n, [{
3434
+ key: "init",
3435
+ value: function init() {
3436
+ var _this2 = this;
3437
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3438
+ var callback = arguments.length > 1 ? arguments[1] : undefined;
3439
+ if (typeof options === 'function') {
3440
+ callback = options;
3441
+ options = {};
3442
+ }
3443
+ if (!options.defaultNS && options.defaultNS !== false && options.ns) {
3444
+ if (typeof options.ns === 'string') {
3445
+ options.defaultNS = options.ns;
3446
+ } else if (options.ns.indexOf('translation') < 0) {
3447
+ options.defaultNS = options.ns[0];
3448
+ }
3449
+ }
3450
+ var defOpts = get();
3451
+ this.options = _objectSpread(_objectSpread(_objectSpread({}, defOpts), this.options), transformOptions(options));
3452
+ if (this.options.compatibilityAPI !== 'v1') {
3453
+ this.options.interpolation = _objectSpread(_objectSpread({}, defOpts.interpolation), this.options.interpolation);
3454
+ }
3455
+ if (options.keySeparator !== undefined) {
3456
+ this.options.userDefinedKeySeparator = options.keySeparator;
3457
+ }
3458
+ if (options.nsSeparator !== undefined) {
3459
+ this.options.userDefinedNsSeparator = options.nsSeparator;
3460
+ }
3461
+ function createClassOnDemand(ClassOrObject) {
3462
+ if (!ClassOrObject) return null;
3463
+ if (typeof ClassOrObject === 'function') return new ClassOrObject();
3464
+ return ClassOrObject;
3465
+ }
3466
+ if (!this.options.isClone) {
3467
+ if (this.modules.logger) {
3468
+ baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
3469
+ } else {
3470
+ baseLogger.init(null, this.options);
3471
+ }
3472
+ var formatter;
3473
+ if (this.modules.formatter) {
3474
+ formatter = this.modules.formatter;
3475
+ } else if (typeof Intl !== 'undefined') {
3476
+ formatter = Formatter;
3477
+ }
3478
+ var lu = new LanguageUtil(this.options);
3479
+ this.store = new ResourceStore(this.options.resources, this.options);
3480
+ var s = this.services;
3481
+ s.logger = baseLogger;
3482
+ s.resourceStore = this.store;
3483
+ s.languageUtils = lu;
3484
+ s.pluralResolver = new PluralResolver(lu, {
3485
+ prepend: this.options.pluralSeparator,
3486
+ compatibilityJSON: this.options.compatibilityJSON,
3487
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
3488
+ });
3489
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
3490
+ s.formatter = createClassOnDemand(formatter);
3491
+ s.formatter.init(s, this.options);
3492
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
3493
+ }
3494
+ s.interpolator = new Interpolator(this.options);
3495
+ s.utils = {
3496
+ hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
3497
+ };
3498
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
3499
+ s.backendConnector.on('*', function (event) {
3500
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
3501
+ args[_key - 1] = arguments[_key];
3502
+ }
3503
+ _this2.emit.apply(_this2, [event].concat(args));
3504
+ });
3505
+ if (this.modules.languageDetector) {
3506
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
3507
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
3508
+ }
3509
+ if (this.modules.i18nFormat) {
3510
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
3511
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
3512
+ }
3513
+ this.translator = new Translator$1(this.services, this.options);
3514
+ this.translator.on('*', function (event) {
3515
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
3516
+ args[_key2 - 1] = arguments[_key2];
3517
+ }
3518
+ _this2.emit.apply(_this2, [event].concat(args));
3519
+ });
3520
+ this.modules.external.forEach(function (m) {
3521
+ if (m.init) m.init(_this2);
3522
+ });
3523
+ }
3524
+ this.format = this.options.interpolation.format;
3525
+ if (!callback) callback = noop;
3526
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
3527
+ var codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
3528
+ if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
3529
+ }
3530
+ if (!this.services.languageDetector && !this.options.lng) {
3531
+ this.logger.warn('init: no languageDetector is used and no lng is defined');
3532
+ }
3533
+ var storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
3534
+ storeApi.forEach(function (fcName) {
3535
+ _this2[fcName] = function () {
3536
+ var _this2$store;
3537
+ return (_this2$store = _this2.store)[fcName].apply(_this2$store, arguments);
3538
+ };
3539
+ });
3540
+ var storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
3541
+ storeApiChained.forEach(function (fcName) {
3542
+ _this2[fcName] = function () {
3543
+ var _this2$store2;
3544
+ (_this2$store2 = _this2.store)[fcName].apply(_this2$store2, arguments);
3545
+ return _this2;
3546
+ };
3547
+ });
3548
+ var deferred = defer();
3549
+ var load = function load() {
3550
+ var finish = function finish(err, t) {
3551
+ if (_this2.isInitialized && !_this2.initializedStoreOnce) _this2.logger.warn('init: i18next is already initialized. You should call init just once!');
3552
+ _this2.isInitialized = true;
3553
+ if (!_this2.options.isClone) _this2.logger.log('initialized', _this2.options);
3554
+ _this2.emit('initialized', _this2.options);
3555
+ deferred.resolve(t);
3556
+ callback(err, t);
3557
+ };
3558
+ if (_this2.languages && _this2.options.compatibilityAPI !== 'v1' && !_this2.isInitialized) return finish(null, _this2.t.bind(_this2));
3559
+ _this2.changeLanguage(_this2.options.lng, finish);
3560
+ };
3561
+ if (this.options.resources || !this.options.initImmediate) {
3562
+ load();
3563
+ } else {
3564
+ setTimeout(load, 0);
3565
+ }
3566
+ return deferred;
3567
+ }
3568
+ }, {
3569
+ key: "loadResources",
3570
+ value: function loadResources(language) {
3571
+ var _this3 = this;
3572
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
3573
+ var usedCallback = callback;
3574
+ var usedLng = typeof language === 'string' ? language : this.language;
3575
+ if (typeof language === 'function') usedCallback = language;
3576
+ if (!this.options.resources || this.options.partialBundledLanguages) {
3577
+ if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
3578
+ var toLoad = [];
3579
+ var append = function append(lng) {
3580
+ if (!lng) return;
3581
+ var lngs = _this3.services.languageUtils.toResolveHierarchy(lng);
3582
+ lngs.forEach(function (l) {
3583
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
3584
+ });
3585
+ };
3586
+ if (!usedLng) {
3587
+ var fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
3588
+ fallbacks.forEach(function (l) {
3589
+ return append(l);
3590
+ });
3591
+ } else {
3592
+ append(usedLng);
3593
+ }
3594
+ if (this.options.preload) {
3595
+ this.options.preload.forEach(function (l) {
3596
+ return append(l);
3597
+ });
3598
+ }
3599
+ this.services.backendConnector.load(toLoad, this.options.ns, function (e) {
3600
+ if (!e && !_this3.resolvedLanguage && _this3.language) _this3.setResolvedLanguage(_this3.language);
3601
+ usedCallback(e);
3602
+ });
3603
+ } else {
3604
+ usedCallback(null);
3605
+ }
3606
+ }
3607
+ }, {
3608
+ key: "reloadResources",
3609
+ value: function reloadResources(lngs, ns, callback) {
3610
+ var deferred = defer();
3611
+ if (!lngs) lngs = this.languages;
3612
+ if (!ns) ns = this.options.ns;
3613
+ if (!callback) callback = noop;
3614
+ this.services.backendConnector.reload(lngs, ns, function (err) {
3615
+ deferred.resolve();
3616
+ callback(err);
3617
+ });
3618
+ return deferred;
3619
+ }
3620
+ }, {
3621
+ key: "use",
3622
+ value: function use(module) {
3623
+ if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
3624
+ if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
3625
+ if (module.type === 'backend') {
3626
+ this.modules.backend = module;
3627
+ }
3628
+ if (module.type === 'logger' || module.log && module.warn && module.error) {
3629
+ this.modules.logger = module;
3630
+ }
3631
+ if (module.type === 'languageDetector') {
3632
+ this.modules.languageDetector = module;
3633
+ }
3634
+ if (module.type === 'i18nFormat') {
3635
+ this.modules.i18nFormat = module;
3636
+ }
3637
+ if (module.type === 'postProcessor') {
3638
+ postProcessor.addPostProcessor(module);
3639
+ }
3640
+ if (module.type === 'formatter') {
3641
+ this.modules.formatter = module;
3642
+ }
3643
+ if (module.type === '3rdParty') {
3644
+ this.modules.external.push(module);
3645
+ }
3646
+ return this;
3647
+ }
3648
+ }, {
3649
+ key: "setResolvedLanguage",
3650
+ value: function setResolvedLanguage(l) {
3651
+ if (!l || !this.languages) return;
3652
+ if (['cimode', 'dev'].indexOf(l) > -1) return;
3653
+ for (var li = 0; li < this.languages.length; li++) {
3654
+ var lngInLngs = this.languages[li];
3655
+ if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
3656
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
3657
+ this.resolvedLanguage = lngInLngs;
3658
+ break;
3659
+ }
3660
+ }
3661
+ }
3662
+ }, {
3663
+ key: "changeLanguage",
3664
+ value: function changeLanguage(lng, callback) {
3665
+ var _this4 = this;
3666
+ this.isLanguageChangingTo = lng;
3667
+ var deferred = defer();
3668
+ this.emit('languageChanging', lng);
3669
+ var setLngProps = function setLngProps(l) {
3670
+ _this4.language = l;
3671
+ _this4.languages = _this4.services.languageUtils.toResolveHierarchy(l);
3672
+ _this4.resolvedLanguage = undefined;
3673
+ _this4.setResolvedLanguage(l);
3674
+ };
3675
+ var done = function done(err, l) {
3676
+ if (l) {
3677
+ setLngProps(l);
3678
+ _this4.translator.changeLanguage(l);
3679
+ _this4.isLanguageChangingTo = undefined;
3680
+ _this4.emit('languageChanged', l);
3681
+ _this4.logger.log('languageChanged', l);
3682
+ } else {
3683
+ _this4.isLanguageChangingTo = undefined;
3684
+ }
3685
+ deferred.resolve(function () {
3686
+ return _this4.t.apply(_this4, arguments);
3687
+ });
3688
+ if (callback) callback(err, function () {
3689
+ return _this4.t.apply(_this4, arguments);
3690
+ });
3691
+ };
3692
+ var setLng = function setLng(lngs) {
3693
+ if (!lng && !lngs && _this4.services.languageDetector) lngs = [];
3694
+ var l = typeof lngs === 'string' ? lngs : _this4.services.languageUtils.getBestMatchFromCodes(lngs);
3695
+ if (l) {
3696
+ if (!_this4.language) {
3697
+ setLngProps(l);
3698
+ }
3699
+ if (!_this4.translator.language) _this4.translator.changeLanguage(l);
3700
+ if (_this4.services.languageDetector && _this4.services.languageDetector.cacheUserLanguage) _this4.services.languageDetector.cacheUserLanguage(l);
3701
+ }
3702
+ _this4.loadResources(l, function (err) {
3703
+ done(err, l);
3704
+ });
3705
+ };
3706
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
3707
+ setLng(this.services.languageDetector.detect());
3708
+ } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
3709
+ if (this.services.languageDetector.detect.length === 0) {
3710
+ this.services.languageDetector.detect().then(setLng);
3711
+ } else {
3712
+ this.services.languageDetector.detect(setLng);
3713
+ }
3714
+ } else {
3715
+ setLng(lng);
3716
+ }
3717
+ return deferred;
3718
+ }
3719
+ }, {
3720
+ key: "getFixedT",
3721
+ value: function getFixedT(lng, ns, keyPrefix) {
3722
+ var _this5 = this;
3723
+ var fixedT = function fixedT(key, opts) {
3724
+ var options;
3725
+ if (_typeof__default["default"](opts) !== 'object') {
3726
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
3727
+ rest[_key3 - 2] = arguments[_key3];
3728
+ }
3729
+ options = _this5.options.overloadTranslationOptionHandler([key, opts].concat(rest));
3730
+ } else {
3731
+ options = _objectSpread({}, opts);
3732
+ }
3733
+ options.lng = options.lng || fixedT.lng;
3734
+ options.lngs = options.lngs || fixedT.lngs;
3735
+ options.ns = options.ns || fixedT.ns;
3736
+ options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
3737
+ var keySeparator = _this5.options.keySeparator || '.';
3738
+ var resultKey;
3739
+ if (options.keyPrefix && Array.isArray(key)) {
3740
+ resultKey = key.map(function (k) {
3741
+ return "".concat(options.keyPrefix).concat(keySeparator).concat(k);
3742
+ });
3743
+ } else {
3744
+ resultKey = options.keyPrefix ? "".concat(options.keyPrefix).concat(keySeparator).concat(key) : key;
3745
+ }
3746
+ return _this5.t(resultKey, options);
3747
+ };
3748
+ if (typeof lng === 'string') {
3749
+ fixedT.lng = lng;
3750
+ } else {
3751
+ fixedT.lngs = lng;
3752
+ }
3753
+ fixedT.ns = ns;
3754
+ fixedT.keyPrefix = keyPrefix;
3755
+ return fixedT;
3756
+ }
3757
+ }, {
3758
+ key: "t",
3759
+ value: function t() {
3760
+ var _this$translator;
3761
+ return this.translator && (_this$translator = this.translator).translate.apply(_this$translator, arguments);
3762
+ }
3763
+ }, {
3764
+ key: "exists",
3765
+ value: function exists() {
3766
+ var _this$translator2;
3767
+ return this.translator && (_this$translator2 = this.translator).exists.apply(_this$translator2, arguments);
3768
+ }
3769
+ }, {
3770
+ key: "setDefaultNamespace",
3771
+ value: function setDefaultNamespace(ns) {
3772
+ this.options.defaultNS = ns;
3773
+ }
3774
+ }, {
3775
+ key: "hasLoadedNamespace",
3776
+ value: function hasLoadedNamespace(ns) {
3777
+ var _this6 = this;
3778
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3779
+ if (!this.isInitialized) {
3780
+ this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
3781
+ return false;
3782
+ }
3783
+ if (!this.languages || !this.languages.length) {
3784
+ this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
3785
+ return false;
3786
+ }
3787
+ var lng = options.lng || this.resolvedLanguage || this.languages[0];
3788
+ var fallbackLng = this.options ? this.options.fallbackLng : false;
3789
+ var lastLng = this.languages[this.languages.length - 1];
3790
+ if (lng.toLowerCase() === 'cimode') return true;
3791
+ var loadNotPending = function loadNotPending(l, n) {
3792
+ var loadState = _this6.services.backendConnector.state["".concat(l, "|").concat(n)];
3793
+ return loadState === -1 || loadState === 2;
3794
+ };
3795
+ if (options.precheck) {
3796
+ var preResult = options.precheck(this, loadNotPending);
3797
+ if (preResult !== undefined) return preResult;
3798
+ }
3799
+ if (this.hasResourceBundle(lng, ns)) return true;
3800
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
3801
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
3802
+ return false;
3803
+ }
3804
+ }, {
3805
+ key: "loadNamespaces",
3806
+ value: function loadNamespaces(ns, callback) {
3807
+ var _this7 = this;
3808
+ var deferred = defer();
3809
+ if (!this.options.ns) {
3810
+ if (callback) callback();
3811
+ return Promise.resolve();
3812
+ }
3813
+ if (typeof ns === 'string') ns = [ns];
3814
+ ns.forEach(function (n) {
3815
+ if (_this7.options.ns.indexOf(n) < 0) _this7.options.ns.push(n);
3816
+ });
3817
+ this.loadResources(function (err) {
3818
+ deferred.resolve();
3819
+ if (callback) callback(err);
3820
+ });
3821
+ return deferred;
3822
+ }
3823
+ }, {
3824
+ key: "loadLanguages",
3825
+ value: function loadLanguages(lngs, callback) {
3826
+ var deferred = defer();
3827
+ if (typeof lngs === 'string') lngs = [lngs];
3828
+ var preloaded = this.options.preload || [];
3829
+ var newLngs = lngs.filter(function (lng) {
3830
+ return preloaded.indexOf(lng) < 0;
3831
+ });
3832
+ if (!newLngs.length) {
3833
+ if (callback) callback();
3834
+ return Promise.resolve();
3835
+ }
3836
+ this.options.preload = preloaded.concat(newLngs);
3837
+ this.loadResources(function (err) {
3838
+ deferred.resolve();
3839
+ if (callback) callback(err);
3840
+ });
3841
+ return deferred;
3842
+ }
3843
+ }, {
3844
+ key: "dir",
3845
+ value: function dir(lng) {
3846
+ if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
3847
+ if (!lng) return 'rtl';
3848
+ var rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
3849
+ var languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
3850
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
3851
+ }
3852
+ }, {
3853
+ key: "cloneInstance",
3854
+ value: function cloneInstance() {
3855
+ var _this8 = this;
3856
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3857
+ var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
3858
+ var mergedOptions = _objectSpread(_objectSpread(_objectSpread({}, this.options), options), {
3859
+ isClone: true
3860
+ });
3861
+ var clone = new I18n(mergedOptions);
3862
+ if (options.debug !== undefined || options.prefix !== undefined) {
3863
+ clone.logger = clone.logger.clone(options);
3864
+ }
3865
+ var membersToCopy = ['store', 'services', 'language'];
3866
+ membersToCopy.forEach(function (m) {
3867
+ clone[m] = _this8[m];
3868
+ });
3869
+ clone.services = _objectSpread({}, this.services);
3870
+ clone.services.utils = {
3871
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
3872
+ };
3873
+ clone.translator = new Translator$1(clone.services, clone.options);
3874
+ clone.translator.on('*', function (event) {
3875
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
3876
+ args[_key4 - 1] = arguments[_key4];
3877
+ }
3878
+ clone.emit.apply(clone, [event].concat(args));
3879
+ });
3880
+ clone.init(mergedOptions, callback);
3881
+ clone.translator.options = clone.options;
3882
+ clone.translator.backendConnector.services.utils = {
3883
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
3884
+ };
3885
+ return clone;
3886
+ }
3887
+ }, {
3888
+ key: "toJSON",
3889
+ value: function toJSON() {
3890
+ return {
3891
+ options: this.options,
3892
+ store: this.store,
3893
+ language: this.language,
3894
+ languages: this.languages,
3895
+ resolvedLanguage: this.resolvedLanguage
3896
+ };
3897
+ }
3898
+ }]);
3899
+ return I18n;
3900
+ }(EventEmitter);
3901
+ _defineProperty__default["default"](I18n, "createInstance", function () {
3902
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3903
+ var callback = arguments.length > 1 ? arguments[1] : undefined;
3904
+ return new I18n(options, callback);
3905
+ });
3906
+ var instance = I18n.createInstance();
3907
+ instance.createInstance = I18n.createInstance;
3908
+
3909
+ var i18next = instance;
3910
+
3911
+ var en = {};
3912
+
3913
+ (function (exports) {
3914
+
3915
+ Object.defineProperty(exports, "__esModule", {
3916
+ value: true
3917
+ });
3918
+ exports["default"] = void 0;
3919
+ var _default = {
3920
+ translation: {
3921
+ categorize: {
3922
+ limitMaxChoicesPerCategory: "You've reached the limit of {{maxChoicesPerCategory}} responses per area. To add another response, one must first be removed.",
3923
+ maxChoicesPerCategoryRestriction: 'To change this value to {{maxChoicesPerCategory}}, each category must have {{maxChoicesPerCategory}} or fewer answer choice[s].'
3924
+ },
3925
+ ebsr: {
3926
+ part: 'Part {{index}}'
3927
+ },
3928
+ numberLine: {
3929
+ addElementLimit_one: 'You can only add {{count}} element',
3930
+ addElementLimit_other: 'You can only add {{count}} elements',
3931
+ clearAll: 'Clear all'
3932
+ },
3933
+ imageClozeAssociation: {
3934
+ reachedLimit_one: 'You’ve reached the limit of {{count}} response per area. To add another response, one must first be removed.',
3935
+ reachedLimit_other: 'You’ve reached the limit of {{count}} responses per area. To add another response, one must first be removed.'
3936
+ },
3937
+ drawingResponse: {
3938
+ fillColor: 'Fill color',
3939
+ outlineColor: 'Outline color',
3940
+ noFill: 'No fill',
3941
+ lightblue: 'Light blue',
3942
+ lightyellow: 'Light yellow',
3943
+ red: 'Red',
3944
+ orange: 'Orange',
3945
+ yellow: 'Yellow',
3946
+ violet: 'Violet',
3947
+ blue: 'Blue',
3948
+ green: 'Green',
3949
+ white: 'White',
3950
+ black: 'Black',
3951
+ onDoubleClick: 'Double click to edit this text. Press Enter to submit.'
3952
+ },
3953
+ charting: {
3954
+ addCategory: 'Add category',
3955
+ newLabel: 'New label',
3956
+ reachedLimit_other: "There can't be more than {{count}} categories."
3957
+ },
3958
+ graphing: {
3959
+ point: 'Point',
3960
+ circle: 'Circle',
3961
+ line: 'Line',
3962
+ parabola: 'Parabola',
3963
+ absolute: 'Absolute Value',
3964
+ exponential: 'Exponential',
3965
+ polygon: 'Polygon',
3966
+ ray: 'Ray',
3967
+ segment: 'Segment',
3968
+ sine: 'Sine',
3969
+ vector: 'Vector',
3970
+ label: 'Label',
3971
+ redo: 'Redo',
3972
+ reset: 'Reset'
3973
+ },
3974
+ mathInline: {
3975
+ primaryCorrectWithAlternates: 'Note: The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct.'
3976
+ },
3977
+ selectText: {
3978
+ correctAnswerSelected: 'Correct answer selected',
3979
+ correctAnswerNotSelected: 'Correct answer not selected',
3980
+ incorrectSelection: 'Incorrect selection'
3981
+ }
3982
+ },
3983
+ common: {
3984
+ undo: 'Undo',
3985
+ clearAll: 'Clear all',
3986
+ correct: 'Correct',
3987
+ incorrect: 'Incorrect',
3988
+ showCorrectAnswer: 'Show correct answer',
3989
+ hideCorrectAnswer: 'Hide correct answer',
3990
+ commonCorrectAnswerWithAlternates: 'Note: The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct.',
3991
+ warning: 'Warning',
3992
+ showNote: 'Show Note',
3993
+ hideNote: 'Hide Note'
3994
+ }
3995
+ };
3996
+ exports["default"] = _default;
3997
+
3998
+ }(en));
3999
+
4000
+ var es = {};
4001
+
4002
+ (function (exports) {
4003
+
4004
+ Object.defineProperty(exports, "__esModule", {
4005
+ value: true
4006
+ });
4007
+ exports["default"] = void 0;
4008
+ var _default = {
4009
+ translation: {
4010
+ categorize: {
4011
+ limitMaxChoicesPerCategory: 'Has alcanzado el límite de {{maxChoicesPerCategory}} respuestas por área. Para agregar otra respuesta, primero se debe eliminar una respuesta',
4012
+ maxChoicesPerCategoryRestriction: 'Para cambiar este valor a {{maxChoicesPerCategory}}, cada categoría debe tener {{maxChoicesPerCategory}} o menos opciones de respuesta'
4013
+ },
4014
+ ebsr: {
4015
+ part: 'Parte {{index}}'
4016
+ },
4017
+ numberLine: {
4018
+ addElementLimit_one: 'Solo puedes agregar {{count}} elemento',
4019
+ addElementLimit_other: 'Solo puedes agregar {{count}} elementos',
4020
+ clearAll: 'Borrar todo'
4021
+ },
4022
+ imageClozeAssociation: {
4023
+ reachedLimit_one: 'Has alcanzado el límite de {{count}} respuesta por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.',
4024
+ reachedLimit_other: 'Has alcanzado el límite de {{count}} respuestas por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.'
4025
+ },
4026
+ drawingResponse: {
4027
+ fillColor: 'Color de relleno',
4028
+ outlineColor: 'Color del contorno',
4029
+ noFill: 'Sin relleno',
4030
+ lightblue: 'Azul claro',
4031
+ lightyellow: 'Amarillo claro',
4032
+ red: 'Rojo',
4033
+ orange: 'Naranja',
4034
+ yellow: 'Amarillo',
4035
+ violet: 'Violeta',
4036
+ blue: 'Azul',
4037
+ green: 'Verde',
4038
+ white: 'Blanco',
4039
+ black: 'Negro',
4040
+ onDoubleClick: 'Haz doble clic para revisar este texto. Presiona el botón de ingreso para enviar'
4041
+ },
4042
+ charting: {
4043
+ addCategory: 'Añadir categoría',
4044
+ newLabel: 'Nueva etiqueta',
4045
+ reachedLimit_other: 'No puede haber más de {{count}} categorías.'
4046
+ },
4047
+ graphing: {
4048
+ point: 'Punto',
4049
+ circle: 'Circulo',
4050
+ line: 'Línea',
4051
+ parabola: 'Parábola',
4052
+ absolute: 'Valor absoluto',
4053
+ exponential: 'Exponencial',
4054
+ polygon: 'Polígono',
4055
+ ray: 'Semirrecta',
4056
+ segment: 'Segmento ',
4057
+ sine: 'Seno',
4058
+ vector: 'Vector',
4059
+ label: 'Etiqueta',
4060
+ redo: 'Rehacer',
4061
+ reset: 'Reiniciar'
4062
+ },
4063
+ mathInline: {
4064
+ primaryCorrectWithAlternates: 'Nota: La respuesta que se muestra arriba es la respuesta correcta principal especificada por el autor para esta pregunta, pero también se pueden reconocer otras respuestas como correctas.'
4065
+ },
4066
+ selectText: {
4067
+ correctAnswerSelected: 'Respuesta correcta seleccionada',
4068
+ correctAnswerNotSelected: 'Respuesta correcta no seleccionada',
4069
+ incorrectSelection: 'Selección incorrecta'
4070
+ }
4071
+ },
4072
+ common: {
4073
+ undo: 'Deshacer',
4074
+ clearAll: 'Borrar todo',
4075
+ correct: 'Correct',
4076
+ incorrect: 'Incorrect',
4077
+ showCorrectAnswer: 'Mostrar respuesta correcta',
4078
+ hideCorrectAnswer: 'Ocultar respuesta correcta',
4079
+ commonCorrectAnswerWithAlternates: 'Nota: La respuesta que se muestra arriba es la respuesta correcta más común para esta pregunta. También se definen una o más respuestas correctas adicionales, y también se reconocerán como correctas.',
4080
+ warning: 'Advertencia',
4081
+ showNote: 'Mostrar Nota',
4082
+ hideNote: 'Ocultar Nota'
4083
+ }
4084
+ };
4085
+ exports["default"] = _default;
4086
+
4087
+ }(es));
4088
+
4089
+ (function (exports) {
4090
+
4091
+ var _interopRequireDefault = interopRequireDefault.exports;
4092
+
4093
+ Object.defineProperty(exports, "__esModule", {
4094
+ value: true
4095
+ });
4096
+ exports["default"] = void 0;
4097
+
4098
+ var _defineProperty2 = _interopRequireDefault(defineProperty$1.exports);
4099
+
4100
+ var _i18next = _interopRequireDefault(i18next);
4101
+
4102
+ var _en = _interopRequireDefault(en);
4103
+
4104
+ var _es = _interopRequireDefault(es);
4105
+
4106
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4107
+
4108
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4109
+
4110
+ _i18next["default"].init({
4111
+ fallbackLng: "en",
4112
+ lng: "en",
4113
+ debug: true,
4114
+ resources: {
4115
+ en: _en["default"],
4116
+ es: _es["default"]
4117
+ }
4118
+ });
4119
+
4120
+ var _default = {
4121
+ translator: _objectSpread(_objectSpread({}, _i18next["default"]), {}, {
4122
+ t: function t(key, options) {
4123
+ var lng = options.lng;
4124
+
4125
+ switch (lng) {
4126
+ // these keys don't work with plurals, don't know why, so I added a workaround to convert them to the correct lng
4127
+ case "en_US":
4128
+ case "en-US":
4129
+ options.lng = "en";
4130
+ break;
4131
+
4132
+ case "es_ES":
4133
+ case "es-ES":
4134
+ case "es_MX":
4135
+ case "es-MX":
4136
+ options.lng = "es";
4137
+ break;
4138
+ }
4139
+
4140
+ return _i18next["default"].t(key, _objectSpread({
4141
+ lng: lng
4142
+ }, options));
4143
+ }
4144
+ }),
4145
+ languageOptions: [{
4146
+ value: "en_US",
4147
+ label: "English (US)"
4148
+ }, {
4149
+ value: "es_ES",
4150
+ label: "Spanish"
4151
+ }]
4152
+ };
4153
+ exports["default"] = _default;
4154
+
4155
+ }(translator$1));
4156
+
4157
+ (function (exports) {
4158
+
4159
+ var _interopRequireDefault = interopRequireDefault.exports;
4160
+
4161
+ Object.defineProperty(exports, "__esModule", {
4162
+ value: true
4163
+ });
4164
+ Object.defineProperty(exports, "Translator", {
4165
+ enumerable: true,
4166
+ get: function get() {
4167
+ return _translator["default"];
4168
+ }
4169
+ });
4170
+ exports["default"] = void 0;
4171
+
4172
+ var _translator = _interopRequireDefault(translator$1);
4173
+
4174
+ var _default = _translator["default"];
4175
+ exports["default"] = _default;
4176
+
4177
+ }(translator$2));
4178
+
4179
+ var Translator = /*@__PURE__*/getDefaultExportFromCjs(translator$2);
4180
+
4181
+ var defaults = {
4182
+ responseType: ResponseTypes.advanced,
4183
+ element: 'math-inline',
4184
+ feedback: {
4185
+ correct: {
4186
+ default: 'Correct',
4187
+ type: 'none',
4188
+ },
4189
+ incorrect: {
4190
+ default: 'Incorrect',
4191
+ type: 'none',
4192
+ },
4193
+ partial: {
4194
+ default: 'Nearly',
4195
+ type: 'none',
4196
+ },
4197
+ },
4198
+ equationEditor: '8',
4199
+ expression: '',
4200
+ question: '',
4201
+ responses: [],
4202
+ customKeys: [],
4203
+ };
4204
+
4205
+ const { translator } = Translator;
4206
+
4207
+ const getResponseCorrectness = (model, answerItem, isOutcome) => {
4208
+ const correctResponses = model.responses;
4209
+ const isAdvanced = model.responseType === ResponseTypes.advanced;
4210
+
4211
+ if (!answerItem) {
4212
+ return {
4213
+ correctness: 'unanswered',
4214
+ score: isOutcome ? 0 : '0%',
4215
+ correct: false,
4216
+ };
4217
+ }
4218
+
4219
+ const isAnswerCorrect = getIsAnswerCorrect(isAdvanced ? correctResponses : correctResponses.slice(0, 1), answerItem);
4220
+
4221
+ const correctnessObject = {
4222
+ correctness: 'incorrect',
4223
+ score: isOutcome ? 0 : '0%',
4224
+ correct: false,
4225
+ };
4226
+
4227
+ if (isAnswerCorrect) {
4228
+ correctnessObject.correctness = 'correct';
4229
+ correctnessObject.score = isOutcome ? 1 : '100%';
4230
+ correctnessObject.correct = true;
4231
+ }
4232
+
4233
+ return correctnessObject;
4234
+ };
4235
+
4236
+ function getIsAnswerCorrect(correctResponseItem, answerItem) {
4237
+ let answerCorrect = false;
4238
+
4239
+ (correctResponseItem || []).forEach((correctResponse) => {
4240
+ let opts = {
4241
+ mode: correctResponse.validation || defaults.validationDefault,
4242
+ };
4243
+
4244
+ if (opts.mode == 'literal') {
4245
+ opts.literal = {
4246
+ allowTrailingZeros: correctResponse.allowTrailingZeros || false,
4247
+ ignoreOrder: correctResponse.ignoreOrder || false,
4248
+ };
4249
+ }
4250
+
4251
+ if (!answerCorrect) {
4252
+ const acceptedValues =
4253
+ [correctResponse.answer].concat(
4254
+ Object.keys(correctResponse.alternates || {}).map((alternateId) => correctResponse.alternates[alternateId]),
4255
+ ) || [];
4256
+
4257
+ try {
4258
+ for (let i = 0; i < acceptedValues.length; i++) {
4259
+ answerCorrect = mv.latexEqual(answerItem, acceptedValues[i], opts);
4260
+
4261
+ if (answerCorrect) {
4262
+ break;
4263
+ }
4264
+ }
4265
+ } catch (e) {
4266
+
4267
+ answerCorrect = false;
4268
+ }
4269
+ }
4270
+ });
4271
+
4272
+ return answerCorrect;
4273
+ }
4274
+
4275
+ const getCorrectness = (question, env, session, isOutcome) => {
4276
+ if (env.mode === 'evaluate') {
4277
+ return getResponseCorrectness(
4278
+ question,
4279
+ question.responseType === ResponseTypes.advanced
4280
+ ? (session && session.completeAnswer) || ''
4281
+ : session && session.response,
4282
+ isOutcome,
4283
+ );
4284
+ }
4285
+ };
4286
+
4287
+ function createDefaultModel(model = {}) {
4288
+ return new Promise((resolve) => {
4289
+ resolve({
4290
+ config: {
4291
+ ...defaults,
4292
+ ...model,
4293
+ },
4294
+ });
4295
+ });
4296
+ }
4297
+
4298
+ const outcome = (question, session, env) => {
4299
+ return new Promise((resolve) => {
4300
+ if (env.mode !== 'evaluate') {
4301
+ resolve({ score: undefined, completed: undefined });
4302
+ } else {
4303
+ if (!session || isEmpty_1(session)) {
4304
+ resolve({ score: 0, empty: true });
4305
+ } else {
4306
+ const correctness = getCorrectness(question, env, session, true);
4307
+
4308
+ resolve({ score: correctness.score });
4309
+ }
4310
+ }
4311
+ });
4312
+ };
4313
+
4314
+ const normalize = (question) => {
4315
+ // making sure that defaults are set
4316
+ if (!isEmpty_1(question.responses)) {
4317
+ question.responses = question.responses.map((correctResponse) => ({
4318
+ ...correctResponse,
4319
+ validation: correctResponse.validation || question.validationDefault,
4320
+ allowTrailingZeros: correctResponse.allowTrailingZeros || question.allowTrailingZerosDefault,
4321
+ ignoreOrder: correctResponse.ignoreOrder || question.ignoreOrderDefault,
4322
+ }));
4323
+ }
4324
+
4325
+ return {
4326
+ ...defaults,
4327
+ feedbackEnabled: false,
4328
+ promptEnabled: true,
4329
+ rationaleEnabled: true,
4330
+ teacherInstructionsEnabled: true,
4331
+ studentInstructionsEnabled: true,
4332
+ ...question,
4333
+ };
4334
+ };
4335
+
4336
+ function model(question, session, env) {
4337
+ return new Promise((resolve) => {
4338
+ const normalizedQuestion = normalize(question);
4339
+ const correctness = getCorrectness(normalizedQuestion, env, session);
4340
+ const { responses, language, ...config } = normalizedQuestion;
4341
+ let { note } = normalizedQuestion;
4342
+
4343
+ if (config.responseType === ResponseTypes.simple) {
4344
+ config.responses = responses.slice(0, 1);
4345
+ } else {
4346
+ config.responses = responses;
4347
+ }
4348
+
4349
+ const fb =
4350
+ env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled
4351
+ ? feedback$1.getFeedbackForCorrectness(correctness, normalizedQuestion.feedback)
4352
+ : Promise.resolve(undefined);
4353
+
4354
+ fb.then((feedback) => {
4355
+ const base = {
4356
+ config,
4357
+ correctness,
4358
+ feedback,
4359
+ disabled: env.mode !== 'gather',
4360
+ view: env.mode === 'view',
4361
+ };
4362
+
4363
+ const out = base;
4364
+ let showNote = !!(config?.responses?.length > 1);
4365
+
4366
+ if (!note) {
4367
+ note = translator.t('mathInline.primaryCorrectWithAlternates', { lng: language });
4368
+ }
4369
+ ((config && config.responses) || []).forEach((response) => {
4370
+ if (response.validation === 'symbolic' || Object.keys(response.alternates || {}).length > 0) {
4371
+ showNote = true;
4372
+ return;
4373
+ }
4374
+ });
4375
+
4376
+ if (env.mode === 'evaluate') {
4377
+ out.correctResponse = {};
4378
+ out.config.showNote = showNote;
4379
+ out.config.note = note;
4380
+ } else {
4381
+ out.config.responses = [];
4382
+ out.config.showNote = false;
4383
+ }
4384
+
4385
+ if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
4386
+ out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
4387
+ out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled
4388
+ ? normalizedQuestion.teacherInstructions
4389
+ : null;
4390
+ } else {
4391
+ out.rationale = null;
4392
+ out.teacherInstructions = null;
4393
+ out.config.rationale = null;
4394
+ out.config.teacherInstructions = null;
4395
+ }
4396
+
4397
+ out.config.env = env;
4398
+ out.config.prompt = normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null;
4399
+ out.language = language;
4400
+ resolve(out);
4401
+ });
4402
+ });
4403
+ }
4404
+
4405
+ const escape = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
4406
+
4407
+ const simpleSessionResponse = (question) =>
4408
+ new Promise((resolve) => {
4409
+ const { responses, id } = question;
4410
+ const { answer } = responses && responses.length ? responses[0] : {};
4411
+
4412
+ resolve({
4413
+ id,
4414
+ response: answer || '',
4415
+ completeAnswer: answer || '',
4416
+ });
4417
+ });
4418
+
4419
+ // use this for items like E672793
4420
+ const removeTrailingEscape = (str) => {
4421
+ return str.endsWith('\\') ? str.slice(0, -1) : str;
4422
+ };
4423
+
4424
+ const advancedSessionResponse = (question) =>
4425
+ new Promise((resolve) => {
4426
+ const { responses, id } = question;
4427
+ const { answer } = responses && responses.length ? responses[0] : {};
4428
+
4429
+ if (!answer) {
4430
+ resolve({
4431
+ id,
4432
+ answers: {},
4433
+ completeAnswer: '',
4434
+ });
4435
+
4436
+ return;
4437
+ }
4438
+
4439
+ try {
4440
+ const e = question.expression;
4441
+ const RESPONSE_TOKEN = /\\{\\{\s*response\s*\\}\\}/g;
4442
+
4443
+ const o = escape(e).split(RESPONSE_TOKEN);
4444
+ const to = o.map((t) => (t === '' ? t : t.replace(/\s+/g, () => '\\s*')));
4445
+ const tt = to.join('(.*)');
4446
+
4447
+ const m = answer.match(new RegExp(tt));
4448
+
4449
+ const count = o.length - 1;
4450
+
4451
+ if (!m) {
4452
+ resolve({
4453
+ id,
4454
+ answers: {},
4455
+ completeAnswer: answer,
4456
+ });
4457
+
4458
+ // eslint-disable-next-line no-console
4459
+ console.log(`can not find match: ${o} in ${answer}`);
4460
+
4461
+ return;
4462
+ }
4463
+
4464
+ m.shift();
4465
+
4466
+ const answers = {};
4467
+
4468
+ for (var i = 0; i < count; i++) {
4469
+ answers[`r${i + 1}`] = { value: removeTrailingEscape(m[i].trim()) };
4470
+ }
4471
+
4472
+ resolve({
4473
+ id,
4474
+ answers,
4475
+ completeAnswer: answer,
4476
+ });
4477
+ } catch (e) {
4478
+ resolve({
4479
+ id,
4480
+ answers: {},
4481
+ completeAnswer: answer,
4482
+ });
4483
+ // eslint-disable-next-line no-console
4484
+ console.error(e.toString());
4485
+ }
4486
+ });
4487
+
4488
+ const createCorrectResponseSession = (question, env) => {
4489
+ if (env.mode === 'evaluate' || env.role !== 'instructor') {
4490
+ // eslint-disable-next-line no-console
4491
+ console.error('can not create correct response session if mode is evaluate or role is not instructor');
4492
+
4493
+ return Promise.resolve(null);
4494
+ }
4495
+
4496
+ if ((question.responseType || '').toLowerCase() === 'simple') {
4497
+ return simpleSessionResponse(question);
4498
+ } else {
4499
+ return advancedSessionResponse(question);
4500
+ }
4501
+ };
4502
+
4503
+ const validate = (model = {}, config = {}) => {
4504
+ const { expression = '', responses, responseType } = model;
4505
+ const { maxResponseAreas } = config;
4506
+ const responsesErrors = {};
4507
+
4508
+ (responses || []).forEach((response, index) => {
4509
+ const { answer } = response;
4510
+ const reversedAlternates = [...Object.entries(response.alternates || {})].reverse();
4511
+ const alternatesErrors = {};
4512
+ const responseError = {};
4513
+
4514
+ if (answer === '') {
4515
+ responseError.answer = 'Content should not be empty.';
4516
+ }
4517
+
4518
+ reversedAlternates.forEach(([key, value], index) => {
4519
+ if (value === '') {
4520
+ alternatesErrors[key] = 'Content should not be empty.';
4521
+ } else {
4522
+ const identicalAnswer =
4523
+ answer === value || reversedAlternates.slice(index + 1).some(([, val]) => val === value);
4524
+
4525
+ if (identicalAnswer) {
4526
+ alternatesErrors[key] = 'Content should be unique.';
4527
+ }
4528
+ }
4529
+ });
4530
+
4531
+ if (!isEmpty_1(responseError) || !isEmpty_1(alternatesErrors)) {
4532
+ responsesErrors[index] = { ...responseError, ...alternatesErrors };
4533
+ }
4534
+ });
4535
+
4536
+ const errors = {};
4537
+
4538
+ if (responseType === 'Advanced Multi') {
4539
+ const nbOfResponseAreas = (expression.match(/\{\{response\}\}/g) || []).length;
4540
+
4541
+ if (nbOfResponseAreas > maxResponseAreas) {
4542
+ errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;
4543
+ } else if (nbOfResponseAreas < 1) {
4544
+ errors.responseAreasError = 'There should be at least 1 response area defined.';
4545
+ }
4546
+ }
4547
+
4548
+ if (!isEmpty_1(responsesErrors)) {
4549
+ errors.responsesErrors = responsesErrors;
4550
+ }
4551
+
4552
+ return errors;
4553
+ };
4554
+
4555
+ export { createCorrectResponseSession, createDefaultModel, model, normalize, outcome, validate };