@bigbinary/neeto-thank-you-frontend 1.0.10 → 1.0.11

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.
package/dist/index.cjs.js CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var i18n = require('i18next');
6
- var reactI18next = require('react-i18next');
7
5
  var React = require('react');
8
6
  var Scrollable = require('@bigbinary/neeto-molecules/Scrollable');
9
7
  var neetoEditor = require('@bigbinary/neeto-editor');
@@ -40,7 +38,6 @@ function _interopNamespace(e) {
40
38
  return Object.freeze(n);
41
39
  }
42
40
 
43
- var i18n__default = /*#__PURE__*/_interopDefaultLegacy(i18n);
44
41
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
45
42
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
46
43
  var Scrollable__default = /*#__PURE__*/_interopDefaultLegacy(Scrollable);
@@ -50,6 +47,2844 @@ var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
50
47
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
51
48
  var NeetoUIHeader__default = /*#__PURE__*/_interopDefaultLegacy(NeetoUIHeader);
52
49
 
50
+ const consoleLogger = {
51
+ type: 'logger',
52
+ log(args) {
53
+ this.output('log', args);
54
+ },
55
+ warn(args) {
56
+ this.output('warn', args);
57
+ },
58
+ error(args) {
59
+ this.output('error', args);
60
+ },
61
+ output(type, args) {
62
+ if (console && console[type]) console[type].apply(console, args);
63
+ }
64
+ };
65
+ class Logger {
66
+ constructor(concreteLogger) {
67
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
68
+ this.init(concreteLogger, options);
69
+ }
70
+ init(concreteLogger) {
71
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
72
+ this.prefix = options.prefix || 'i18next:';
73
+ this.logger = concreteLogger || consoleLogger;
74
+ this.options = options;
75
+ this.debug = options.debug;
76
+ }
77
+ log() {
78
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
79
+ args[_key] = arguments[_key];
80
+ }
81
+ return this.forward(args, 'log', '', true);
82
+ }
83
+ warn() {
84
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
85
+ args[_key2] = arguments[_key2];
86
+ }
87
+ return this.forward(args, 'warn', '', true);
88
+ }
89
+ error() {
90
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
91
+ args[_key3] = arguments[_key3];
92
+ }
93
+ return this.forward(args, 'error', '');
94
+ }
95
+ deprecate() {
96
+ for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
97
+ args[_key4] = arguments[_key4];
98
+ }
99
+ return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
100
+ }
101
+ forward(args, lvl, prefix, debugOnly) {
102
+ if (debugOnly && !this.debug) return null;
103
+ if (typeof args[0] === 'string') args[0] = `${prefix}${this.prefix} ${args[0]}`;
104
+ return this.logger[lvl](args);
105
+ }
106
+ create(moduleName) {
107
+ return new Logger(this.logger, {
108
+ ...{
109
+ prefix: `${this.prefix}:${moduleName}:`
110
+ },
111
+ ...this.options
112
+ });
113
+ }
114
+ clone(options) {
115
+ options = options || this.options;
116
+ options.prefix = options.prefix || this.prefix;
117
+ return new Logger(this.logger, options);
118
+ }
119
+ }
120
+ var baseLogger = new Logger();
121
+
122
+ class EventEmitter {
123
+ constructor() {
124
+ this.observers = {};
125
+ }
126
+ on(events, listener) {
127
+ events.split(' ').forEach(event => {
128
+ this.observers[event] = this.observers[event] || [];
129
+ this.observers[event].push(listener);
130
+ });
131
+ return this;
132
+ }
133
+ off(event, listener) {
134
+ if (!this.observers[event]) return;
135
+ if (!listener) {
136
+ delete this.observers[event];
137
+ return;
138
+ }
139
+ this.observers[event] = this.observers[event].filter(l => l !== listener);
140
+ }
141
+ emit(event) {
142
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
143
+ args[_key - 1] = arguments[_key];
144
+ }
145
+ if (this.observers[event]) {
146
+ const cloned = [].concat(this.observers[event]);
147
+ cloned.forEach(observer => {
148
+ observer(...args);
149
+ });
150
+ }
151
+ if (this.observers['*']) {
152
+ const cloned = [].concat(this.observers['*']);
153
+ cloned.forEach(observer => {
154
+ observer.apply(observer, [event, ...args]);
155
+ });
156
+ }
157
+ }
158
+ }
159
+
160
+ function defer() {
161
+ let res;
162
+ let rej;
163
+ const promise = new Promise((resolve, reject) => {
164
+ res = resolve;
165
+ rej = reject;
166
+ });
167
+ promise.resolve = res;
168
+ promise.reject = rej;
169
+ return promise;
170
+ }
171
+ function makeString(object) {
172
+ if (object == null) return '';
173
+ return '' + object;
174
+ }
175
+ function copy(a, s, t) {
176
+ a.forEach(m => {
177
+ if (s[m]) t[m] = s[m];
178
+ });
179
+ }
180
+ function getLastOfPath(object, path, Empty) {
181
+ function cleanKey(key) {
182
+ return key && key.indexOf('###') > -1 ? key.replace(/###/g, '.') : key;
183
+ }
184
+ function canNotTraverseDeeper() {
185
+ return !object || typeof object === 'string';
186
+ }
187
+ const stack = typeof path !== 'string' ? [].concat(path) : path.split('.');
188
+ while (stack.length > 1) {
189
+ if (canNotTraverseDeeper()) return {};
190
+ const key = cleanKey(stack.shift());
191
+ if (!object[key] && Empty) object[key] = new Empty();
192
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
193
+ object = object[key];
194
+ } else {
195
+ object = {};
196
+ }
197
+ }
198
+ if (canNotTraverseDeeper()) return {};
199
+ return {
200
+ obj: object,
201
+ k: cleanKey(stack.shift())
202
+ };
203
+ }
204
+ function setPath(object, path, newValue) {
205
+ const {
206
+ obj,
207
+ k
208
+ } = getLastOfPath(object, path, Object);
209
+ obj[k] = newValue;
210
+ }
211
+ function pushPath(object, path, newValue, concat) {
212
+ const {
213
+ obj,
214
+ k
215
+ } = getLastOfPath(object, path, Object);
216
+ obj[k] = obj[k] || [];
217
+ if (concat) obj[k] = obj[k].concat(newValue);
218
+ if (!concat) obj[k].push(newValue);
219
+ }
220
+ function getPath(object, path) {
221
+ const {
222
+ obj,
223
+ k
224
+ } = getLastOfPath(object, path);
225
+ if (!obj) return undefined;
226
+ return obj[k];
227
+ }
228
+ function getPathWithDefaults(data, defaultData, key) {
229
+ const value = getPath(data, key);
230
+ if (value !== undefined) {
231
+ return value;
232
+ }
233
+ return getPath(defaultData, key);
234
+ }
235
+ function deepExtend(target, source, overwrite) {
236
+ for (const prop in source) {
237
+ if (prop !== '__proto__' && prop !== 'constructor') {
238
+ if (prop in target) {
239
+ if (typeof target[prop] === 'string' || target[prop] instanceof String || typeof source[prop] === 'string' || source[prop] instanceof String) {
240
+ if (overwrite) target[prop] = source[prop];
241
+ } else {
242
+ deepExtend(target[prop], source[prop], overwrite);
243
+ }
244
+ } else {
245
+ target[prop] = source[prop];
246
+ }
247
+ }
248
+ }
249
+ return target;
250
+ }
251
+ function regexEscape(str) {
252
+ return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
253
+ }
254
+ var _entityMap = {
255
+ '&': '&amp;',
256
+ '<': '&lt;',
257
+ '>': '&gt;',
258
+ '"': '&quot;',
259
+ "'": '&#39;',
260
+ '/': '&#x2F;'
261
+ };
262
+ function escape(data) {
263
+ if (typeof data === 'string') {
264
+ return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
265
+ }
266
+ return data;
267
+ }
268
+ const chars = [' ', ',', '?', '!', ';'];
269
+ function looksLikeObjectPath(key, nsSeparator, keySeparator) {
270
+ nsSeparator = nsSeparator || '';
271
+ keySeparator = keySeparator || '';
272
+ const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
273
+ if (possibleChars.length === 0) return true;
274
+ const r = new RegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
275
+ let matched = !r.test(key);
276
+ if (!matched) {
277
+ const ki = key.indexOf(keySeparator);
278
+ if (ki > 0 && !r.test(key.substring(0, ki))) {
279
+ matched = true;
280
+ }
281
+ }
282
+ return matched;
283
+ }
284
+ function deepFind(obj, path) {
285
+ let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
286
+ if (!obj) return undefined;
287
+ if (obj[path]) return obj[path];
288
+ const paths = path.split(keySeparator);
289
+ let current = obj;
290
+ for (let i = 0; i < paths.length; ++i) {
291
+ if (!current) return undefined;
292
+ if (typeof current[paths[i]] === 'string' && i + 1 < paths.length) {
293
+ return undefined;
294
+ }
295
+ if (current[paths[i]] === undefined) {
296
+ let j = 2;
297
+ let p = paths.slice(i, i + j).join(keySeparator);
298
+ let mix = current[p];
299
+ while (mix === undefined && paths.length > i + j) {
300
+ j++;
301
+ p = paths.slice(i, i + j).join(keySeparator);
302
+ mix = current[p];
303
+ }
304
+ if (mix === undefined) return undefined;
305
+ if (mix === null) return null;
306
+ if (path.endsWith(p)) {
307
+ if (typeof mix === 'string') return mix;
308
+ if (p && typeof mix[p] === 'string') return mix[p];
309
+ }
310
+ const joinedPath = paths.slice(i + j).join(keySeparator);
311
+ if (joinedPath) return deepFind(mix, joinedPath, keySeparator);
312
+ return undefined;
313
+ }
314
+ current = current[paths[i]];
315
+ }
316
+ return current;
317
+ }
318
+ function getCleanedCode(code) {
319
+ if (code && code.indexOf('_') > 0) return code.replace('_', '-');
320
+ return code;
321
+ }
322
+
323
+ class ResourceStore extends EventEmitter {
324
+ constructor(data) {
325
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
326
+ ns: ['translation'],
327
+ defaultNS: 'translation'
328
+ };
329
+ super();
330
+ this.data = data || {};
331
+ this.options = options;
332
+ if (this.options.keySeparator === undefined) {
333
+ this.options.keySeparator = '.';
334
+ }
335
+ if (this.options.ignoreJSONStructure === undefined) {
336
+ this.options.ignoreJSONStructure = true;
337
+ }
338
+ }
339
+ addNamespaces(ns) {
340
+ if (this.options.ns.indexOf(ns) < 0) {
341
+ this.options.ns.push(ns);
342
+ }
343
+ }
344
+ removeNamespaces(ns) {
345
+ const index = this.options.ns.indexOf(ns);
346
+ if (index > -1) {
347
+ this.options.ns.splice(index, 1);
348
+ }
349
+ }
350
+ getResource(lng, ns, key) {
351
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
352
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
353
+ const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
354
+ let path = [lng, ns];
355
+ if (key && typeof key !== 'string') path = path.concat(key);
356
+ if (key && typeof key === 'string') path = path.concat(keySeparator ? key.split(keySeparator) : key);
357
+ if (lng.indexOf('.') > -1) {
358
+ path = lng.split('.');
359
+ }
360
+ const result = getPath(this.data, path);
361
+ if (result || !ignoreJSONStructure || typeof key !== 'string') return result;
362
+ return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
363
+ }
364
+ addResource(lng, ns, key, value) {
365
+ let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
366
+ silent: false
367
+ };
368
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
369
+ let path = [lng, ns];
370
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
371
+ if (lng.indexOf('.') > -1) {
372
+ path = lng.split('.');
373
+ value = ns;
374
+ ns = path[1];
375
+ }
376
+ this.addNamespaces(ns);
377
+ setPath(this.data, path, value);
378
+ if (!options.silent) this.emit('added', lng, ns, key, value);
379
+ }
380
+ addResources(lng, ns, resources) {
381
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
382
+ silent: false
383
+ };
384
+ for (const m in resources) {
385
+ if (typeof resources[m] === 'string' || Object.prototype.toString.apply(resources[m]) === '[object Array]') this.addResource(lng, ns, m, resources[m], {
386
+ silent: true
387
+ });
388
+ }
389
+ if (!options.silent) this.emit('added', lng, ns, resources);
390
+ }
391
+ addResourceBundle(lng, ns, resources, deep, overwrite) {
392
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
393
+ silent: false
394
+ };
395
+ let path = [lng, ns];
396
+ if (lng.indexOf('.') > -1) {
397
+ path = lng.split('.');
398
+ deep = resources;
399
+ resources = ns;
400
+ ns = path[1];
401
+ }
402
+ this.addNamespaces(ns);
403
+ let pack = getPath(this.data, path) || {};
404
+ if (deep) {
405
+ deepExtend(pack, resources, overwrite);
406
+ } else {
407
+ pack = {
408
+ ...pack,
409
+ ...resources
410
+ };
411
+ }
412
+ setPath(this.data, path, pack);
413
+ if (!options.silent) this.emit('added', lng, ns, resources);
414
+ }
415
+ removeResourceBundle(lng, ns) {
416
+ if (this.hasResourceBundle(lng, ns)) {
417
+ delete this.data[lng][ns];
418
+ }
419
+ this.removeNamespaces(ns);
420
+ this.emit('removed', lng, ns);
421
+ }
422
+ hasResourceBundle(lng, ns) {
423
+ return this.getResource(lng, ns) !== undefined;
424
+ }
425
+ getResourceBundle(lng, ns) {
426
+ if (!ns) ns = this.options.defaultNS;
427
+ if (this.options.compatibilityAPI === 'v1') return {
428
+ ...{},
429
+ ...this.getResource(lng, ns)
430
+ };
431
+ return this.getResource(lng, ns);
432
+ }
433
+ getDataByLanguage(lng) {
434
+ return this.data[lng];
435
+ }
436
+ hasLanguageSomeTranslations(lng) {
437
+ const data = this.getDataByLanguage(lng);
438
+ const n = data && Object.keys(data) || [];
439
+ return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
440
+ }
441
+ toJSON() {
442
+ return this.data;
443
+ }
444
+ }
445
+
446
+ var postProcessor = {
447
+ processors: {},
448
+ addPostProcessor(module) {
449
+ this.processors[module.name] = module;
450
+ },
451
+ handle(processors, value, key, options, translator) {
452
+ processors.forEach(processor => {
453
+ if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
454
+ });
455
+ return value;
456
+ }
457
+ };
458
+
459
+ const checkedLoadedFor = {};
460
+ class Translator extends EventEmitter {
461
+ constructor(services) {
462
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
463
+ super();
464
+ copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
465
+ this.options = options;
466
+ if (this.options.keySeparator === undefined) {
467
+ this.options.keySeparator = '.';
468
+ }
469
+ this.logger = baseLogger.create('translator');
470
+ }
471
+ changeLanguage(lng) {
472
+ if (lng) this.language = lng;
473
+ }
474
+ exists(key) {
475
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
476
+ interpolation: {}
477
+ };
478
+ if (key === undefined || key === null) {
479
+ return false;
480
+ }
481
+ const resolved = this.resolve(key, options);
482
+ return resolved && resolved.res !== undefined;
483
+ }
484
+ extractFromKey(key, options) {
485
+ let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
486
+ if (nsSeparator === undefined) nsSeparator = ':';
487
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
488
+ let namespaces = options.ns || this.options.defaultNS || [];
489
+ const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
490
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
491
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
492
+ const m = key.match(this.interpolator.nestingRegexp);
493
+ if (m && m.length > 0) {
494
+ return {
495
+ key,
496
+ namespaces
497
+ };
498
+ }
499
+ const parts = key.split(nsSeparator);
500
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
501
+ key = parts.join(keySeparator);
502
+ }
503
+ if (typeof namespaces === 'string') namespaces = [namespaces];
504
+ return {
505
+ key,
506
+ namespaces
507
+ };
508
+ }
509
+ translate(keys, options, lastKey) {
510
+ if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
511
+ options = this.options.overloadTranslationOptionHandler(arguments);
512
+ }
513
+ if (typeof options === 'object') options = {
514
+ ...options
515
+ };
516
+ if (!options) options = {};
517
+ if (keys === undefined || keys === null) return '';
518
+ if (!Array.isArray(keys)) keys = [String(keys)];
519
+ const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
520
+ const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
521
+ const {
522
+ key,
523
+ namespaces
524
+ } = this.extractFromKey(keys[keys.length - 1], options);
525
+ const namespace = namespaces[namespaces.length - 1];
526
+ const lng = options.lng || this.language;
527
+ const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
528
+ if (lng && lng.toLowerCase() === 'cimode') {
529
+ if (appendNamespaceToCIMode) {
530
+ const nsSeparator = options.nsSeparator || this.options.nsSeparator;
531
+ if (returnDetails) {
532
+ return {
533
+ res: `${namespace}${nsSeparator}${key}`,
534
+ usedKey: key,
535
+ exactUsedKey: key,
536
+ usedLng: lng,
537
+ usedNS: namespace
538
+ };
539
+ }
540
+ return `${namespace}${nsSeparator}${key}`;
541
+ }
542
+ if (returnDetails) {
543
+ return {
544
+ res: key,
545
+ usedKey: key,
546
+ exactUsedKey: key,
547
+ usedLng: lng,
548
+ usedNS: namespace
549
+ };
550
+ }
551
+ return key;
552
+ }
553
+ const resolved = this.resolve(keys, options);
554
+ let res = resolved && resolved.res;
555
+ const resUsedKey = resolved && resolved.usedKey || key;
556
+ const resExactUsedKey = resolved && resolved.exactUsedKey || key;
557
+ const resType = Object.prototype.toString.apply(res);
558
+ const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
559
+ const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
560
+ const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
561
+ const handleAsObject = typeof res !== 'string' && typeof res !== 'boolean' && typeof res !== 'number';
562
+ if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(typeof joinArrays === 'string' && resType === '[object Array]')) {
563
+ if (!options.returnObjects && !this.options.returnObjects) {
564
+ if (!this.options.returnedObjectHandler) {
565
+ this.logger.warn('accessing an object - but returnObjects options is not enabled!');
566
+ }
567
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
568
+ ...options,
569
+ ns: namespaces
570
+ }) : `key '${key} (${this.language})' returned an object instead of string.`;
571
+ if (returnDetails) {
572
+ resolved.res = r;
573
+ return resolved;
574
+ }
575
+ return r;
576
+ }
577
+ if (keySeparator) {
578
+ const resTypeIsArray = resType === '[object Array]';
579
+ const copy = resTypeIsArray ? [] : {};
580
+ const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
581
+ for (const m in res) {
582
+ if (Object.prototype.hasOwnProperty.call(res, m)) {
583
+ const deepKey = `${newKeyToUse}${keySeparator}${m}`;
584
+ copy[m] = this.translate(deepKey, {
585
+ ...options,
586
+ ...{
587
+ joinArrays: false,
588
+ ns: namespaces
589
+ }
590
+ });
591
+ if (copy[m] === deepKey) copy[m] = res[m];
592
+ }
593
+ }
594
+ res = copy;
595
+ }
596
+ } else if (handleAsObjectInI18nFormat && typeof joinArrays === 'string' && resType === '[object Array]') {
597
+ res = res.join(joinArrays);
598
+ if (res) res = this.extendTranslation(res, keys, options, lastKey);
599
+ } else {
600
+ let usedDefault = false;
601
+ let usedKey = false;
602
+ const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
603
+ const hasDefaultValue = Translator.hasDefaultValue(options);
604
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
605
+ const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
606
+ ordinal: false
607
+ }) : '';
608
+ const defaultValue = options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
609
+ if (!this.isValidLookup(res) && hasDefaultValue) {
610
+ usedDefault = true;
611
+ res = defaultValue;
612
+ }
613
+ if (!this.isValidLookup(res)) {
614
+ usedKey = true;
615
+ res = key;
616
+ }
617
+ const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
618
+ const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
619
+ const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
620
+ if (usedKey || usedDefault || updateMissing) {
621
+ this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
622
+ if (keySeparator) {
623
+ const fk = this.resolve(key, {
624
+ ...options,
625
+ keySeparator: false
626
+ });
627
+ 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.');
628
+ }
629
+ let lngs = [];
630
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
631
+ if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
632
+ for (let i = 0; i < fallbackLngs.length; i++) {
633
+ lngs.push(fallbackLngs[i]);
634
+ }
635
+ } else if (this.options.saveMissingTo === 'all') {
636
+ lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
637
+ } else {
638
+ lngs.push(options.lng || this.language);
639
+ }
640
+ const send = (l, k, specificDefaultValue) => {
641
+ const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
642
+ if (this.options.missingKeyHandler) {
643
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
644
+ } else if (this.backendConnector && this.backendConnector.saveMissing) {
645
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
646
+ }
647
+ this.emit('missingKey', l, namespace, k, res);
648
+ };
649
+ if (this.options.saveMissing) {
650
+ if (this.options.saveMissingPlurals && needsPluralHandling) {
651
+ lngs.forEach(language => {
652
+ this.pluralResolver.getSuffixes(language, options).forEach(suffix => {
653
+ send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
654
+ });
655
+ });
656
+ } else {
657
+ send(lngs, key, defaultValue);
658
+ }
659
+ }
660
+ }
661
+ res = this.extendTranslation(res, keys, options, resolved, lastKey);
662
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
663
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
664
+ if (this.options.compatibilityAPI !== 'v1') {
665
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
666
+ } else {
667
+ res = this.options.parseMissingKeyHandler(res);
668
+ }
669
+ }
670
+ }
671
+ if (returnDetails) {
672
+ resolved.res = res;
673
+ return resolved;
674
+ }
675
+ return res;
676
+ }
677
+ extendTranslation(res, key, options, resolved, lastKey) {
678
+ var _this = this;
679
+ if (this.i18nFormat && this.i18nFormat.parse) {
680
+ res = this.i18nFormat.parse(res, {
681
+ ...this.options.interpolation.defaultVariables,
682
+ ...options
683
+ }, resolved.usedLng, resolved.usedNS, resolved.usedKey, {
684
+ resolved
685
+ });
686
+ } else if (!options.skipInterpolation) {
687
+ if (options.interpolation) this.interpolator.init({
688
+ ...options,
689
+ ...{
690
+ interpolation: {
691
+ ...this.options.interpolation,
692
+ ...options.interpolation
693
+ }
694
+ }
695
+ });
696
+ const skipOnVariables = typeof res === 'string' && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
697
+ let nestBef;
698
+ if (skipOnVariables) {
699
+ const nb = res.match(this.interpolator.nestingRegexp);
700
+ nestBef = nb && nb.length;
701
+ }
702
+ let data = options.replace && typeof options.replace !== 'string' ? options.replace : options;
703
+ if (this.options.interpolation.defaultVariables) data = {
704
+ ...this.options.interpolation.defaultVariables,
705
+ ...data
706
+ };
707
+ res = this.interpolator.interpolate(res, data, options.lng || this.language, options);
708
+ if (skipOnVariables) {
709
+ const na = res.match(this.interpolator.nestingRegexp);
710
+ const nestAft = na && na.length;
711
+ if (nestBef < nestAft) options.nest = false;
712
+ }
713
+ if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = resolved.usedLng;
714
+ if (options.nest !== false) res = this.interpolator.nest(res, function () {
715
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
716
+ args[_key] = arguments[_key];
717
+ }
718
+ if (lastKey && lastKey[0] === args[0] && !options.context) {
719
+ _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
720
+ return null;
721
+ }
722
+ return _this.translate(...args, key);
723
+ }, options);
724
+ if (options.interpolation) this.interpolator.reset();
725
+ }
726
+ const postProcess = options.postProcess || this.options.postProcess;
727
+ const postProcessorNames = typeof postProcess === 'string' ? [postProcess] : postProcess;
728
+ if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
729
+ res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
730
+ i18nResolved: resolved,
731
+ ...options
732
+ } : options, this);
733
+ }
734
+ return res;
735
+ }
736
+ resolve(keys) {
737
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
738
+ let found;
739
+ let usedKey;
740
+ let exactUsedKey;
741
+ let usedLng;
742
+ let usedNS;
743
+ if (typeof keys === 'string') keys = [keys];
744
+ keys.forEach(k => {
745
+ if (this.isValidLookup(found)) return;
746
+ const extracted = this.extractFromKey(k, options);
747
+ const key = extracted.key;
748
+ usedKey = key;
749
+ let namespaces = extracted.namespaces;
750
+ if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
751
+ const needsPluralHandling = options.count !== undefined && typeof options.count !== 'string';
752
+ const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
753
+ const needsContextHandling = options.context !== undefined && (typeof options.context === 'string' || typeof options.context === 'number') && options.context !== '';
754
+ const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
755
+ namespaces.forEach(ns => {
756
+ if (this.isValidLookup(found)) return;
757
+ usedNS = ns;
758
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
759
+ checkedLoadedFor[`${codes[0]}-${ns}`] = true;
760
+ this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${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!!!');
761
+ }
762
+ codes.forEach(code => {
763
+ if (this.isValidLookup(found)) return;
764
+ usedLng = code;
765
+ const finalKeys = [key];
766
+ if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
767
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
768
+ } else {
769
+ let pluralSuffix;
770
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
771
+ const zeroSuffix = `${this.options.pluralSeparator}zero`;
772
+ const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
773
+ if (needsPluralHandling) {
774
+ finalKeys.push(key + pluralSuffix);
775
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
776
+ finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
777
+ }
778
+ if (needsZeroSuffixLookup) {
779
+ finalKeys.push(key + zeroSuffix);
780
+ }
781
+ }
782
+ if (needsContextHandling) {
783
+ const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
784
+ finalKeys.push(contextKey);
785
+ if (needsPluralHandling) {
786
+ finalKeys.push(contextKey + pluralSuffix);
787
+ if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
788
+ finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
789
+ }
790
+ if (needsZeroSuffixLookup) {
791
+ finalKeys.push(contextKey + zeroSuffix);
792
+ }
793
+ }
794
+ }
795
+ }
796
+ let possibleKey;
797
+ while (possibleKey = finalKeys.pop()) {
798
+ if (!this.isValidLookup(found)) {
799
+ exactUsedKey = possibleKey;
800
+ found = this.getResource(code, ns, possibleKey, options);
801
+ }
802
+ }
803
+ });
804
+ });
805
+ });
806
+ return {
807
+ res: found,
808
+ usedKey,
809
+ exactUsedKey,
810
+ usedLng,
811
+ usedNS
812
+ };
813
+ }
814
+ isValidLookup(res) {
815
+ return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
816
+ }
817
+ getResource(code, ns, key) {
818
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
819
+ if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
820
+ return this.resourceStore.getResource(code, ns, key, options);
821
+ }
822
+ static hasDefaultValue(options) {
823
+ const prefix = 'defaultValue';
824
+ for (const option in options) {
825
+ if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
826
+ return true;
827
+ }
828
+ }
829
+ return false;
830
+ }
831
+ }
832
+
833
+ function capitalize(string) {
834
+ return string.charAt(0).toUpperCase() + string.slice(1);
835
+ }
836
+ class LanguageUtil {
837
+ constructor(options) {
838
+ this.options = options;
839
+ this.supportedLngs = this.options.supportedLngs || false;
840
+ this.logger = baseLogger.create('languageUtils');
841
+ }
842
+ getScriptPartFromCode(code) {
843
+ code = getCleanedCode(code);
844
+ if (!code || code.indexOf('-') < 0) return null;
845
+ const p = code.split('-');
846
+ if (p.length === 2) return null;
847
+ p.pop();
848
+ if (p[p.length - 1].toLowerCase() === 'x') return null;
849
+ return this.formatLanguageCode(p.join('-'));
850
+ }
851
+ getLanguagePartFromCode(code) {
852
+ code = getCleanedCode(code);
853
+ if (!code || code.indexOf('-') < 0) return code;
854
+ const p = code.split('-');
855
+ return this.formatLanguageCode(p[0]);
856
+ }
857
+ formatLanguageCode(code) {
858
+ if (typeof code === 'string' && code.indexOf('-') > -1) {
859
+ const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
860
+ let p = code.split('-');
861
+ if (this.options.lowerCaseLng) {
862
+ p = p.map(part => part.toLowerCase());
863
+ } else if (p.length === 2) {
864
+ p[0] = p[0].toLowerCase();
865
+ p[1] = p[1].toUpperCase();
866
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
867
+ } else if (p.length === 3) {
868
+ p[0] = p[0].toLowerCase();
869
+ if (p[1].length === 2) p[1] = p[1].toUpperCase();
870
+ if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
871
+ if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
872
+ if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
873
+ }
874
+ return p.join('-');
875
+ }
876
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
877
+ }
878
+ isSupportedCode(code) {
879
+ if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
880
+ code = this.getLanguagePartFromCode(code);
881
+ }
882
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
883
+ }
884
+ getBestMatchFromCodes(codes) {
885
+ if (!codes) return null;
886
+ let found;
887
+ codes.forEach(code => {
888
+ if (found) return;
889
+ const cleanedLng = this.formatLanguageCode(code);
890
+ if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
891
+ });
892
+ if (!found && this.options.supportedLngs) {
893
+ codes.forEach(code => {
894
+ if (found) return;
895
+ const lngOnly = this.getLanguagePartFromCode(code);
896
+ if (this.isSupportedCode(lngOnly)) return found = lngOnly;
897
+ found = this.options.supportedLngs.find(supportedLng => {
898
+ if (supportedLng === lngOnly) return supportedLng;
899
+ if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
900
+ if (supportedLng.indexOf(lngOnly) === 0) return supportedLng;
901
+ });
902
+ });
903
+ }
904
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
905
+ return found;
906
+ }
907
+ getFallbackCodes(fallbacks, code) {
908
+ if (!fallbacks) return [];
909
+ if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
910
+ if (typeof fallbacks === 'string') fallbacks = [fallbacks];
911
+ if (Object.prototype.toString.apply(fallbacks) === '[object Array]') return fallbacks;
912
+ if (!code) return fallbacks.default || [];
913
+ let found = fallbacks[code];
914
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
915
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
916
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
917
+ if (!found) found = fallbacks.default;
918
+ return found || [];
919
+ }
920
+ toResolveHierarchy(code, fallbackCode) {
921
+ const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
922
+ const codes = [];
923
+ const addCode = c => {
924
+ if (!c) return;
925
+ if (this.isSupportedCode(c)) {
926
+ codes.push(c);
927
+ } else {
928
+ this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
929
+ }
930
+ };
931
+ if (typeof code === 'string' && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
932
+ if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
933
+ if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
934
+ if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
935
+ } else if (typeof code === 'string') {
936
+ addCode(this.formatLanguageCode(code));
937
+ }
938
+ fallbackCodes.forEach(fc => {
939
+ if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
940
+ });
941
+ return codes;
942
+ }
943
+ }
944
+
945
+ let sets = [{
946
+ lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
947
+ nr: [1, 2],
948
+ fc: 1
949
+ }, {
950
+ 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'],
951
+ nr: [1, 2],
952
+ fc: 2
953
+ }, {
954
+ lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
955
+ nr: [1],
956
+ fc: 3
957
+ }, {
958
+ lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
959
+ nr: [1, 2, 5],
960
+ fc: 4
961
+ }, {
962
+ lngs: ['ar'],
963
+ nr: [0, 1, 2, 3, 11, 100],
964
+ fc: 5
965
+ }, {
966
+ lngs: ['cs', 'sk'],
967
+ nr: [1, 2, 5],
968
+ fc: 6
969
+ }, {
970
+ lngs: ['csb', 'pl'],
971
+ nr: [1, 2, 5],
972
+ fc: 7
973
+ }, {
974
+ lngs: ['cy'],
975
+ nr: [1, 2, 3, 8],
976
+ fc: 8
977
+ }, {
978
+ lngs: ['fr'],
979
+ nr: [1, 2],
980
+ fc: 9
981
+ }, {
982
+ lngs: ['ga'],
983
+ nr: [1, 2, 3, 7, 11],
984
+ fc: 10
985
+ }, {
986
+ lngs: ['gd'],
987
+ nr: [1, 2, 3, 20],
988
+ fc: 11
989
+ }, {
990
+ lngs: ['is'],
991
+ nr: [1, 2],
992
+ fc: 12
993
+ }, {
994
+ lngs: ['jv'],
995
+ nr: [0, 1],
996
+ fc: 13
997
+ }, {
998
+ lngs: ['kw'],
999
+ nr: [1, 2, 3, 4],
1000
+ fc: 14
1001
+ }, {
1002
+ lngs: ['lt'],
1003
+ nr: [1, 2, 10],
1004
+ fc: 15
1005
+ }, {
1006
+ lngs: ['lv'],
1007
+ nr: [1, 2, 0],
1008
+ fc: 16
1009
+ }, {
1010
+ lngs: ['mk'],
1011
+ nr: [1, 2],
1012
+ fc: 17
1013
+ }, {
1014
+ lngs: ['mnk'],
1015
+ nr: [0, 1, 2],
1016
+ fc: 18
1017
+ }, {
1018
+ lngs: ['mt'],
1019
+ nr: [1, 2, 11, 20],
1020
+ fc: 19
1021
+ }, {
1022
+ lngs: ['or'],
1023
+ nr: [2, 1],
1024
+ fc: 2
1025
+ }, {
1026
+ lngs: ['ro'],
1027
+ nr: [1, 2, 20],
1028
+ fc: 20
1029
+ }, {
1030
+ lngs: ['sl'],
1031
+ nr: [5, 1, 2, 3],
1032
+ fc: 21
1033
+ }, {
1034
+ lngs: ['he', 'iw'],
1035
+ nr: [1, 2, 20, 21],
1036
+ fc: 22
1037
+ }];
1038
+ let _rulesPluralsTypes = {
1039
+ 1: function (n) {
1040
+ return Number(n > 1);
1041
+ },
1042
+ 2: function (n) {
1043
+ return Number(n != 1);
1044
+ },
1045
+ 3: function (n) {
1046
+ return 0;
1047
+ },
1048
+ 4: function (n) {
1049
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1050
+ },
1051
+ 5: function (n) {
1052
+ return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
1053
+ },
1054
+ 6: function (n) {
1055
+ return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
1056
+ },
1057
+ 7: function (n) {
1058
+ return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1059
+ },
1060
+ 8: function (n) {
1061
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
1062
+ },
1063
+ 9: function (n) {
1064
+ return Number(n >= 2);
1065
+ },
1066
+ 10: function (n) {
1067
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
1068
+ },
1069
+ 11: function (n) {
1070
+ return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
1071
+ },
1072
+ 12: function (n) {
1073
+ return Number(n % 10 != 1 || n % 100 == 11);
1074
+ },
1075
+ 13: function (n) {
1076
+ return Number(n !== 0);
1077
+ },
1078
+ 14: function (n) {
1079
+ return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
1080
+ },
1081
+ 15: function (n) {
1082
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
1083
+ },
1084
+ 16: function (n) {
1085
+ return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
1086
+ },
1087
+ 17: function (n) {
1088
+ return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
1089
+ },
1090
+ 18: function (n) {
1091
+ return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
1092
+ },
1093
+ 19: function (n) {
1094
+ return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
1095
+ },
1096
+ 20: function (n) {
1097
+ return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
1098
+ },
1099
+ 21: function (n) {
1100
+ return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
1101
+ },
1102
+ 22: function (n) {
1103
+ return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
1104
+ }
1105
+ };
1106
+ const nonIntlVersions = ['v1', 'v2', 'v3'];
1107
+ const intlVersions = ['v4'];
1108
+ const suffixesOrder = {
1109
+ zero: 0,
1110
+ one: 1,
1111
+ two: 2,
1112
+ few: 3,
1113
+ many: 4,
1114
+ other: 5
1115
+ };
1116
+ function createRules() {
1117
+ const rules = {};
1118
+ sets.forEach(set => {
1119
+ set.lngs.forEach(l => {
1120
+ rules[l] = {
1121
+ numbers: set.nr,
1122
+ plurals: _rulesPluralsTypes[set.fc]
1123
+ };
1124
+ });
1125
+ });
1126
+ return rules;
1127
+ }
1128
+ class PluralResolver {
1129
+ constructor(languageUtils) {
1130
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1131
+ this.languageUtils = languageUtils;
1132
+ this.options = options;
1133
+ this.logger = baseLogger.create('pluralResolver');
1134
+ if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
1135
+ this.options.compatibilityJSON = 'v3';
1136
+ 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.');
1137
+ }
1138
+ this.rules = createRules();
1139
+ }
1140
+ addRule(lng, obj) {
1141
+ this.rules[lng] = obj;
1142
+ }
1143
+ getRule(code) {
1144
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1145
+ if (this.shouldUseIntlApi()) {
1146
+ try {
1147
+ return new Intl.PluralRules(getCleanedCode(code), {
1148
+ type: options.ordinal ? 'ordinal' : 'cardinal'
1149
+ });
1150
+ } catch {
1151
+ return;
1152
+ }
1153
+ }
1154
+ return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1155
+ }
1156
+ needsPlural(code) {
1157
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1158
+ const rule = this.getRule(code, options);
1159
+ if (this.shouldUseIntlApi()) {
1160
+ return rule && rule.resolvedOptions().pluralCategories.length > 1;
1161
+ }
1162
+ return rule && rule.numbers.length > 1;
1163
+ }
1164
+ getPluralFormsOfKey(code, key) {
1165
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1166
+ return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1167
+ }
1168
+ getSuffixes(code) {
1169
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1170
+ const rule = this.getRule(code, options);
1171
+ if (!rule) {
1172
+ return [];
1173
+ }
1174
+ if (this.shouldUseIntlApi()) {
1175
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1176
+ }
1177
+ return rule.numbers.map(number => this.getSuffix(code, number, options));
1178
+ }
1179
+ getSuffix(code, count) {
1180
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1181
+ const rule = this.getRule(code, options);
1182
+ if (rule) {
1183
+ if (this.shouldUseIntlApi()) {
1184
+ return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1185
+ }
1186
+ return this.getSuffixRetroCompatible(rule, count);
1187
+ }
1188
+ this.logger.warn(`no plural rule found for: ${code}`);
1189
+ return '';
1190
+ }
1191
+ getSuffixRetroCompatible(rule, count) {
1192
+ const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1193
+ let suffix = rule.numbers[idx];
1194
+ if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1195
+ if (suffix === 2) {
1196
+ suffix = 'plural';
1197
+ } else if (suffix === 1) {
1198
+ suffix = '';
1199
+ }
1200
+ }
1201
+ const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
1202
+ if (this.options.compatibilityJSON === 'v1') {
1203
+ if (suffix === 1) return '';
1204
+ if (typeof suffix === 'number') return `_plural_${suffix.toString()}`;
1205
+ return returnSuffix();
1206
+ } else if (this.options.compatibilityJSON === 'v2') {
1207
+ return returnSuffix();
1208
+ } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1209
+ return returnSuffix();
1210
+ }
1211
+ return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1212
+ }
1213
+ shouldUseIntlApi() {
1214
+ return !nonIntlVersions.includes(this.options.compatibilityJSON);
1215
+ }
1216
+ }
1217
+
1218
+ function deepFindWithDefaults(data, defaultData, key) {
1219
+ let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1220
+ let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1221
+ let path = getPathWithDefaults(data, defaultData, key);
1222
+ if (!path && ignoreJSONStructure && typeof key === 'string') {
1223
+ path = deepFind(data, key, keySeparator);
1224
+ if (path === undefined) path = deepFind(defaultData, key, keySeparator);
1225
+ }
1226
+ return path;
1227
+ }
1228
+ class Interpolator {
1229
+ constructor() {
1230
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1231
+ this.logger = baseLogger.create('interpolator');
1232
+ this.options = options;
1233
+ this.format = options.interpolation && options.interpolation.format || (value => value);
1234
+ this.init(options);
1235
+ }
1236
+ init() {
1237
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1238
+ if (!options.interpolation) options.interpolation = {
1239
+ escapeValue: true
1240
+ };
1241
+ const iOpts = options.interpolation;
1242
+ this.escape = iOpts.escape !== undefined ? iOpts.escape : escape;
1243
+ this.escapeValue = iOpts.escapeValue !== undefined ? iOpts.escapeValue : true;
1244
+ this.useRawValueToEscape = iOpts.useRawValueToEscape !== undefined ? iOpts.useRawValueToEscape : false;
1245
+ this.prefix = iOpts.prefix ? regexEscape(iOpts.prefix) : iOpts.prefixEscaped || '{{';
1246
+ this.suffix = iOpts.suffix ? regexEscape(iOpts.suffix) : iOpts.suffixEscaped || '}}';
1247
+ this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1248
+ this.unescapePrefix = iOpts.unescapeSuffix ? '' : iOpts.unescapePrefix || '-';
1249
+ this.unescapeSuffix = this.unescapePrefix ? '' : iOpts.unescapeSuffix || '';
1250
+ this.nestingPrefix = iOpts.nestingPrefix ? regexEscape(iOpts.nestingPrefix) : iOpts.nestingPrefixEscaped || regexEscape('$t(');
1251
+ this.nestingSuffix = iOpts.nestingSuffix ? regexEscape(iOpts.nestingSuffix) : iOpts.nestingSuffixEscaped || regexEscape(')');
1252
+ this.nestingOptionsSeparator = iOpts.nestingOptionsSeparator ? iOpts.nestingOptionsSeparator : iOpts.nestingOptionsSeparator || ',';
1253
+ this.maxReplaces = iOpts.maxReplaces ? iOpts.maxReplaces : 1000;
1254
+ this.alwaysFormat = iOpts.alwaysFormat !== undefined ? iOpts.alwaysFormat : false;
1255
+ this.resetRegExp();
1256
+ }
1257
+ reset() {
1258
+ if (this.options) this.init(this.options);
1259
+ }
1260
+ resetRegExp() {
1261
+ const regexpStr = `${this.prefix}(.+?)${this.suffix}`;
1262
+ this.regexp = new RegExp(regexpStr, 'g');
1263
+ const regexpUnescapeStr = `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;
1264
+ this.regexpUnescape = new RegExp(regexpUnescapeStr, 'g');
1265
+ const nestingRegexpStr = `${this.nestingPrefix}(.+?)${this.nestingSuffix}`;
1266
+ this.nestingRegexp = new RegExp(nestingRegexpStr, 'g');
1267
+ }
1268
+ interpolate(str, data, lng, options) {
1269
+ let match;
1270
+ let value;
1271
+ let replaces;
1272
+ const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1273
+ function regexSafe(val) {
1274
+ return val.replace(/\$/g, '$$$$');
1275
+ }
1276
+ const handleFormat = key => {
1277
+ if (key.indexOf(this.formatSeparator) < 0) {
1278
+ const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1279
+ return this.alwaysFormat ? this.format(path, undefined, lng, {
1280
+ ...options,
1281
+ ...data,
1282
+ interpolationkey: key
1283
+ }) : path;
1284
+ }
1285
+ const p = key.split(this.formatSeparator);
1286
+ const k = p.shift().trim();
1287
+ const f = p.join(this.formatSeparator).trim();
1288
+ return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1289
+ ...options,
1290
+ ...data,
1291
+ interpolationkey: k
1292
+ });
1293
+ };
1294
+ this.resetRegExp();
1295
+ const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
1296
+ const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1297
+ const todos = [{
1298
+ regex: this.regexpUnescape,
1299
+ safeValue: val => regexSafe(val)
1300
+ }, {
1301
+ regex: this.regexp,
1302
+ safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1303
+ }];
1304
+ todos.forEach(todo => {
1305
+ replaces = 0;
1306
+ while (match = todo.regex.exec(str)) {
1307
+ const matchedVar = match[1].trim();
1308
+ value = handleFormat(matchedVar);
1309
+ if (value === undefined) {
1310
+ if (typeof missingInterpolationHandler === 'function') {
1311
+ const temp = missingInterpolationHandler(str, match, options);
1312
+ value = typeof temp === 'string' ? temp : '';
1313
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1314
+ value = '';
1315
+ } else if (skipOnVariables) {
1316
+ value = match[0];
1317
+ continue;
1318
+ } else {
1319
+ this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1320
+ value = '';
1321
+ }
1322
+ } else if (typeof value !== 'string' && !this.useRawValueToEscape) {
1323
+ value = makeString(value);
1324
+ }
1325
+ const safeValue = todo.safeValue(value);
1326
+ str = str.replace(match[0], safeValue);
1327
+ if (skipOnVariables) {
1328
+ todo.regex.lastIndex += value.length;
1329
+ todo.regex.lastIndex -= match[0].length;
1330
+ } else {
1331
+ todo.regex.lastIndex = 0;
1332
+ }
1333
+ replaces++;
1334
+ if (replaces >= this.maxReplaces) {
1335
+ break;
1336
+ }
1337
+ }
1338
+ });
1339
+ return str;
1340
+ }
1341
+ nest(str, fc) {
1342
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1343
+ let match;
1344
+ let value;
1345
+ let clonedOptions;
1346
+ function handleHasOptions(key, inheritedOptions) {
1347
+ const sep = this.nestingOptionsSeparator;
1348
+ if (key.indexOf(sep) < 0) return key;
1349
+ const c = key.split(new RegExp(`${sep}[ ]*{`));
1350
+ let optionsString = `{${c[1]}`;
1351
+ key = c[0];
1352
+ optionsString = this.interpolate(optionsString, clonedOptions);
1353
+ const matchedSingleQuotes = optionsString.match(/'/g);
1354
+ const matchedDoubleQuotes = optionsString.match(/"/g);
1355
+ if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1356
+ optionsString = optionsString.replace(/'/g, '"');
1357
+ }
1358
+ try {
1359
+ clonedOptions = JSON.parse(optionsString);
1360
+ if (inheritedOptions) clonedOptions = {
1361
+ ...inheritedOptions,
1362
+ ...clonedOptions
1363
+ };
1364
+ } catch (e) {
1365
+ this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1366
+ return `${key}${sep}${optionsString}`;
1367
+ }
1368
+ delete clonedOptions.defaultValue;
1369
+ return key;
1370
+ }
1371
+ while (match = this.nestingRegexp.exec(str)) {
1372
+ let formatters = [];
1373
+ clonedOptions = {
1374
+ ...options
1375
+ };
1376
+ clonedOptions = clonedOptions.replace && typeof clonedOptions.replace !== 'string' ? clonedOptions.replace : clonedOptions;
1377
+ clonedOptions.applyPostProcessor = false;
1378
+ delete clonedOptions.defaultValue;
1379
+ let doReduce = false;
1380
+ if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1381
+ const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1382
+ match[1] = r.shift();
1383
+ formatters = r;
1384
+ doReduce = true;
1385
+ }
1386
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1387
+ if (value && match[0] === str && typeof value !== 'string') return value;
1388
+ if (typeof value !== 'string') value = makeString(value);
1389
+ if (!value) {
1390
+ this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1391
+ value = '';
1392
+ }
1393
+ if (doReduce) {
1394
+ value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1395
+ ...options,
1396
+ interpolationkey: match[1].trim()
1397
+ }), value.trim());
1398
+ }
1399
+ str = str.replace(match[0], value);
1400
+ this.regexp.lastIndex = 0;
1401
+ }
1402
+ return str;
1403
+ }
1404
+ }
1405
+
1406
+ function parseFormatStr(formatStr) {
1407
+ let formatName = formatStr.toLowerCase().trim();
1408
+ const formatOptions = {};
1409
+ if (formatStr.indexOf('(') > -1) {
1410
+ const p = formatStr.split('(');
1411
+ formatName = p[0].toLowerCase().trim();
1412
+ const optStr = p[1].substring(0, p[1].length - 1);
1413
+ if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1414
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1415
+ } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1416
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
1417
+ } else {
1418
+ const opts = optStr.split(';');
1419
+ opts.forEach(opt => {
1420
+ if (!opt) return;
1421
+ const [key, ...rest] = opt.split(':');
1422
+ const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
1423
+ if (!formatOptions[key.trim()]) formatOptions[key.trim()] = val;
1424
+ if (val === 'false') formatOptions[key.trim()] = false;
1425
+ if (val === 'true') formatOptions[key.trim()] = true;
1426
+ if (!isNaN(val)) formatOptions[key.trim()] = parseInt(val, 10);
1427
+ });
1428
+ }
1429
+ }
1430
+ return {
1431
+ formatName,
1432
+ formatOptions
1433
+ };
1434
+ }
1435
+ function createCachedFormatter(fn) {
1436
+ const cache = {};
1437
+ return function invokeFormatter(val, lng, options) {
1438
+ const key = lng + JSON.stringify(options);
1439
+ let formatter = cache[key];
1440
+ if (!formatter) {
1441
+ formatter = fn(getCleanedCode(lng), options);
1442
+ cache[key] = formatter;
1443
+ }
1444
+ return formatter(val);
1445
+ };
1446
+ }
1447
+ class Formatter {
1448
+ constructor() {
1449
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1450
+ this.logger = baseLogger.create('formatter');
1451
+ this.options = options;
1452
+ this.formats = {
1453
+ number: createCachedFormatter((lng, opt) => {
1454
+ const formatter = new Intl.NumberFormat(lng, {
1455
+ ...opt
1456
+ });
1457
+ return val => formatter.format(val);
1458
+ }),
1459
+ currency: createCachedFormatter((lng, opt) => {
1460
+ const formatter = new Intl.NumberFormat(lng, {
1461
+ ...opt,
1462
+ style: 'currency'
1463
+ });
1464
+ return val => formatter.format(val);
1465
+ }),
1466
+ datetime: createCachedFormatter((lng, opt) => {
1467
+ const formatter = new Intl.DateTimeFormat(lng, {
1468
+ ...opt
1469
+ });
1470
+ return val => formatter.format(val);
1471
+ }),
1472
+ relativetime: createCachedFormatter((lng, opt) => {
1473
+ const formatter = new Intl.RelativeTimeFormat(lng, {
1474
+ ...opt
1475
+ });
1476
+ return val => formatter.format(val, opt.range || 'day');
1477
+ }),
1478
+ list: createCachedFormatter((lng, opt) => {
1479
+ const formatter = new Intl.ListFormat(lng, {
1480
+ ...opt
1481
+ });
1482
+ return val => formatter.format(val);
1483
+ })
1484
+ };
1485
+ this.init(options);
1486
+ }
1487
+ init(services) {
1488
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1489
+ interpolation: {}
1490
+ };
1491
+ const iOpts = options.interpolation;
1492
+ this.formatSeparator = iOpts.formatSeparator ? iOpts.formatSeparator : iOpts.formatSeparator || ',';
1493
+ }
1494
+ add(name, fc) {
1495
+ this.formats[name.toLowerCase().trim()] = fc;
1496
+ }
1497
+ addCached(name, fc) {
1498
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1499
+ }
1500
+ format(value, format, lng) {
1501
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1502
+ const formats = format.split(this.formatSeparator);
1503
+ const result = formats.reduce((mem, f) => {
1504
+ const {
1505
+ formatName,
1506
+ formatOptions
1507
+ } = parseFormatStr(f);
1508
+ if (this.formats[formatName]) {
1509
+ let formatted = mem;
1510
+ try {
1511
+ const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
1512
+ const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1513
+ formatted = this.formats[formatName](mem, l, {
1514
+ ...formatOptions,
1515
+ ...options,
1516
+ ...valOptions
1517
+ });
1518
+ } catch (error) {
1519
+ this.logger.warn(error);
1520
+ }
1521
+ return formatted;
1522
+ } else {
1523
+ this.logger.warn(`there was no format function for ${formatName}`);
1524
+ }
1525
+ return mem;
1526
+ }, value);
1527
+ return result;
1528
+ }
1529
+ }
1530
+
1531
+ function removePending(q, name) {
1532
+ if (q.pending[name] !== undefined) {
1533
+ delete q.pending[name];
1534
+ q.pendingCount--;
1535
+ }
1536
+ }
1537
+ class Connector extends EventEmitter {
1538
+ constructor(backend, store, services) {
1539
+ let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1540
+ super();
1541
+ this.backend = backend;
1542
+ this.store = store;
1543
+ this.services = services;
1544
+ this.languageUtils = services.languageUtils;
1545
+ this.options = options;
1546
+ this.logger = baseLogger.create('backendConnector');
1547
+ this.waitingReads = [];
1548
+ this.maxParallelReads = options.maxParallelReads || 10;
1549
+ this.readingCalls = 0;
1550
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1551
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1552
+ this.state = {};
1553
+ this.queue = [];
1554
+ if (this.backend && this.backend.init) {
1555
+ this.backend.init(services, options.backend, options);
1556
+ }
1557
+ }
1558
+ queueLoad(languages, namespaces, options, callback) {
1559
+ const toLoad = {};
1560
+ const pending = {};
1561
+ const toLoadLanguages = {};
1562
+ const toLoadNamespaces = {};
1563
+ languages.forEach(lng => {
1564
+ let hasAllNamespaces = true;
1565
+ namespaces.forEach(ns => {
1566
+ const name = `${lng}|${ns}`;
1567
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
1568
+ this.state[name] = 2;
1569
+ } else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
1570
+ if (pending[name] === undefined) pending[name] = true;
1571
+ } else {
1572
+ this.state[name] = 1;
1573
+ hasAllNamespaces = false;
1574
+ if (pending[name] === undefined) pending[name] = true;
1575
+ if (toLoad[name] === undefined) toLoad[name] = true;
1576
+ if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
1577
+ }
1578
+ });
1579
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1580
+ });
1581
+ if (Object.keys(toLoad).length || Object.keys(pending).length) {
1582
+ this.queue.push({
1583
+ pending,
1584
+ pendingCount: Object.keys(pending).length,
1585
+ loaded: {},
1586
+ errors: [],
1587
+ callback
1588
+ });
1589
+ }
1590
+ return {
1591
+ toLoad: Object.keys(toLoad),
1592
+ pending: Object.keys(pending),
1593
+ toLoadLanguages: Object.keys(toLoadLanguages),
1594
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
1595
+ };
1596
+ }
1597
+ loaded(name, err, data) {
1598
+ const s = name.split('|');
1599
+ const lng = s[0];
1600
+ const ns = s[1];
1601
+ if (err) this.emit('failedLoading', lng, ns, err);
1602
+ if (data) {
1603
+ this.store.addResourceBundle(lng, ns, data);
1604
+ }
1605
+ this.state[name] = err ? -1 : 2;
1606
+ const loaded = {};
1607
+ this.queue.forEach(q => {
1608
+ pushPath(q.loaded, [lng], ns);
1609
+ removePending(q, name);
1610
+ if (err) q.errors.push(err);
1611
+ if (q.pendingCount === 0 && !q.done) {
1612
+ Object.keys(q.loaded).forEach(l => {
1613
+ if (!loaded[l]) loaded[l] = {};
1614
+ const loadedKeys = q.loaded[l];
1615
+ if (loadedKeys.length) {
1616
+ loadedKeys.forEach(n => {
1617
+ if (loaded[l][n] === undefined) loaded[l][n] = true;
1618
+ });
1619
+ }
1620
+ });
1621
+ q.done = true;
1622
+ if (q.errors.length) {
1623
+ q.callback(q.errors);
1624
+ } else {
1625
+ q.callback();
1626
+ }
1627
+ }
1628
+ });
1629
+ this.emit('loaded', loaded);
1630
+ this.queue = this.queue.filter(q => !q.done);
1631
+ }
1632
+ read(lng, ns, fcName) {
1633
+ let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1634
+ let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1635
+ let callback = arguments.length > 5 ? arguments[5] : undefined;
1636
+ if (!lng.length) return callback(null, {});
1637
+ if (this.readingCalls >= this.maxParallelReads) {
1638
+ this.waitingReads.push({
1639
+ lng,
1640
+ ns,
1641
+ fcName,
1642
+ tried,
1643
+ wait,
1644
+ callback
1645
+ });
1646
+ return;
1647
+ }
1648
+ this.readingCalls++;
1649
+ const resolver = (err, data) => {
1650
+ this.readingCalls--;
1651
+ if (this.waitingReads.length > 0) {
1652
+ const next = this.waitingReads.shift();
1653
+ this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1654
+ }
1655
+ if (err && data && tried < this.maxRetries) {
1656
+ setTimeout(() => {
1657
+ this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1658
+ }, wait);
1659
+ return;
1660
+ }
1661
+ callback(err, data);
1662
+ };
1663
+ const fc = this.backend[fcName].bind(this.backend);
1664
+ if (fc.length === 2) {
1665
+ try {
1666
+ const r = fc(lng, ns);
1667
+ if (r && typeof r.then === 'function') {
1668
+ r.then(data => resolver(null, data)).catch(resolver);
1669
+ } else {
1670
+ resolver(null, r);
1671
+ }
1672
+ } catch (err) {
1673
+ resolver(err);
1674
+ }
1675
+ return;
1676
+ }
1677
+ return fc(lng, ns, resolver);
1678
+ }
1679
+ prepareLoading(languages, namespaces) {
1680
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1681
+ let callback = arguments.length > 3 ? arguments[3] : undefined;
1682
+ if (!this.backend) {
1683
+ this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1684
+ return callback && callback();
1685
+ }
1686
+ if (typeof languages === 'string') languages = this.languageUtils.toResolveHierarchy(languages);
1687
+ if (typeof namespaces === 'string') namespaces = [namespaces];
1688
+ const toLoad = this.queueLoad(languages, namespaces, options, callback);
1689
+ if (!toLoad.toLoad.length) {
1690
+ if (!toLoad.pending.length) callback();
1691
+ return null;
1692
+ }
1693
+ toLoad.toLoad.forEach(name => {
1694
+ this.loadOne(name);
1695
+ });
1696
+ }
1697
+ load(languages, namespaces, callback) {
1698
+ this.prepareLoading(languages, namespaces, {}, callback);
1699
+ }
1700
+ reload(languages, namespaces, callback) {
1701
+ this.prepareLoading(languages, namespaces, {
1702
+ reload: true
1703
+ }, callback);
1704
+ }
1705
+ loadOne(name) {
1706
+ let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1707
+ const s = name.split('|');
1708
+ const lng = s[0];
1709
+ const ns = s[1];
1710
+ this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
1711
+ if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1712
+ if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1713
+ this.loaded(name, err, data);
1714
+ });
1715
+ }
1716
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1717
+ let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1718
+ let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1719
+ if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
1720
+ this.logger.warn(`did not save key "${key}" as the namespace "${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!!!');
1721
+ return;
1722
+ }
1723
+ if (key === undefined || key === null || key === '') return;
1724
+ if (this.backend && this.backend.create) {
1725
+ const opts = {
1726
+ ...options,
1727
+ isUpdate
1728
+ };
1729
+ const fc = this.backend.create.bind(this.backend);
1730
+ if (fc.length < 6) {
1731
+ try {
1732
+ let r;
1733
+ if (fc.length === 5) {
1734
+ r = fc(languages, namespace, key, fallbackValue, opts);
1735
+ } else {
1736
+ r = fc(languages, namespace, key, fallbackValue);
1737
+ }
1738
+ if (r && typeof r.then === 'function') {
1739
+ r.then(data => clb(null, data)).catch(clb);
1740
+ } else {
1741
+ clb(null, r);
1742
+ }
1743
+ } catch (err) {
1744
+ clb(err);
1745
+ }
1746
+ } else {
1747
+ fc(languages, namespace, key, fallbackValue, clb, opts);
1748
+ }
1749
+ }
1750
+ if (!languages || !languages[0]) return;
1751
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
1752
+ }
1753
+ }
1754
+
1755
+ function get() {
1756
+ return {
1757
+ debug: false,
1758
+ initImmediate: true,
1759
+ ns: ['translation'],
1760
+ defaultNS: ['translation'],
1761
+ fallbackLng: ['dev'],
1762
+ fallbackNS: false,
1763
+ supportedLngs: false,
1764
+ nonExplicitSupportedLngs: false,
1765
+ load: 'all',
1766
+ preload: false,
1767
+ simplifyPluralSuffix: true,
1768
+ keySeparator: '.',
1769
+ nsSeparator: ':',
1770
+ pluralSeparator: '_',
1771
+ contextSeparator: '_',
1772
+ partialBundledLanguages: false,
1773
+ saveMissing: false,
1774
+ updateMissing: false,
1775
+ saveMissingTo: 'fallback',
1776
+ saveMissingPlurals: true,
1777
+ missingKeyHandler: false,
1778
+ missingInterpolationHandler: false,
1779
+ postProcess: false,
1780
+ postProcessPassResolved: false,
1781
+ returnNull: false,
1782
+ returnEmptyString: true,
1783
+ returnObjects: false,
1784
+ joinArrays: false,
1785
+ returnedObjectHandler: false,
1786
+ parseMissingKeyHandler: false,
1787
+ appendNamespaceToMissingKey: false,
1788
+ appendNamespaceToCIMode: false,
1789
+ overloadTranslationOptionHandler: function handle(args) {
1790
+ let ret = {};
1791
+ if (typeof args[1] === 'object') ret = args[1];
1792
+ if (typeof args[1] === 'string') ret.defaultValue = args[1];
1793
+ if (typeof args[2] === 'string') ret.tDescription = args[2];
1794
+ if (typeof args[2] === 'object' || typeof args[3] === 'object') {
1795
+ const options = args[3] || args[2];
1796
+ Object.keys(options).forEach(key => {
1797
+ ret[key] = options[key];
1798
+ });
1799
+ }
1800
+ return ret;
1801
+ },
1802
+ interpolation: {
1803
+ escapeValue: true,
1804
+ format: (value, format, lng, options) => value,
1805
+ prefix: '{{',
1806
+ suffix: '}}',
1807
+ formatSeparator: ',',
1808
+ unescapePrefix: '-',
1809
+ nestingPrefix: '$t(',
1810
+ nestingSuffix: ')',
1811
+ nestingOptionsSeparator: ',',
1812
+ maxReplaces: 1000,
1813
+ skipOnVariables: true
1814
+ }
1815
+ };
1816
+ }
1817
+ function transformOptions(options) {
1818
+ if (typeof options.ns === 'string') options.ns = [options.ns];
1819
+ if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
1820
+ if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
1821
+ if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
1822
+ options.supportedLngs = options.supportedLngs.concat(['cimode']);
1823
+ }
1824
+ return options;
1825
+ }
1826
+
1827
+ function noop$2() {}
1828
+ function bindMemberFunctions(inst) {
1829
+ const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
1830
+ mems.forEach(mem => {
1831
+ if (typeof inst[mem] === 'function') {
1832
+ inst[mem] = inst[mem].bind(inst);
1833
+ }
1834
+ });
1835
+ }
1836
+ class I18n extends EventEmitter {
1837
+ constructor() {
1838
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1839
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
1840
+ super();
1841
+ this.options = transformOptions(options);
1842
+ this.services = {};
1843
+ this.logger = baseLogger;
1844
+ this.modules = {
1845
+ external: []
1846
+ };
1847
+ bindMemberFunctions(this);
1848
+ if (callback && !this.isInitialized && !options.isClone) {
1849
+ if (!this.options.initImmediate) {
1850
+ this.init(options, callback);
1851
+ return this;
1852
+ }
1853
+ setTimeout(() => {
1854
+ this.init(options, callback);
1855
+ }, 0);
1856
+ }
1857
+ }
1858
+ init() {
1859
+ var _this = this;
1860
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1861
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
1862
+ if (typeof options === 'function') {
1863
+ callback = options;
1864
+ options = {};
1865
+ }
1866
+ if (!options.defaultNS && options.defaultNS !== false && options.ns) {
1867
+ if (typeof options.ns === 'string') {
1868
+ options.defaultNS = options.ns;
1869
+ } else if (options.ns.indexOf('translation') < 0) {
1870
+ options.defaultNS = options.ns[0];
1871
+ }
1872
+ }
1873
+ const defOpts = get();
1874
+ this.options = {
1875
+ ...defOpts,
1876
+ ...this.options,
1877
+ ...transformOptions(options)
1878
+ };
1879
+ if (this.options.compatibilityAPI !== 'v1') {
1880
+ this.options.interpolation = {
1881
+ ...defOpts.interpolation,
1882
+ ...this.options.interpolation
1883
+ };
1884
+ }
1885
+ if (options.keySeparator !== undefined) {
1886
+ this.options.userDefinedKeySeparator = options.keySeparator;
1887
+ }
1888
+ if (options.nsSeparator !== undefined) {
1889
+ this.options.userDefinedNsSeparator = options.nsSeparator;
1890
+ }
1891
+ function createClassOnDemand(ClassOrObject) {
1892
+ if (!ClassOrObject) return null;
1893
+ if (typeof ClassOrObject === 'function') return new ClassOrObject();
1894
+ return ClassOrObject;
1895
+ }
1896
+ if (!this.options.isClone) {
1897
+ if (this.modules.logger) {
1898
+ baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1899
+ } else {
1900
+ baseLogger.init(null, this.options);
1901
+ }
1902
+ let formatter;
1903
+ if (this.modules.formatter) {
1904
+ formatter = this.modules.formatter;
1905
+ } else if (typeof Intl !== 'undefined') {
1906
+ formatter = Formatter;
1907
+ }
1908
+ const lu = new LanguageUtil(this.options);
1909
+ this.store = new ResourceStore(this.options.resources, this.options);
1910
+ const s = this.services;
1911
+ s.logger = baseLogger;
1912
+ s.resourceStore = this.store;
1913
+ s.languageUtils = lu;
1914
+ s.pluralResolver = new PluralResolver(lu, {
1915
+ prepend: this.options.pluralSeparator,
1916
+ compatibilityJSON: this.options.compatibilityJSON,
1917
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
1918
+ });
1919
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1920
+ s.formatter = createClassOnDemand(formatter);
1921
+ s.formatter.init(s, this.options);
1922
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1923
+ }
1924
+ s.interpolator = new Interpolator(this.options);
1925
+ s.utils = {
1926
+ hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1927
+ };
1928
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1929
+ s.backendConnector.on('*', function (event) {
1930
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1931
+ args[_key - 1] = arguments[_key];
1932
+ }
1933
+ _this.emit(event, ...args);
1934
+ });
1935
+ if (this.modules.languageDetector) {
1936
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1937
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1938
+ }
1939
+ if (this.modules.i18nFormat) {
1940
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1941
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
1942
+ }
1943
+ this.translator = new Translator(this.services, this.options);
1944
+ this.translator.on('*', function (event) {
1945
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1946
+ args[_key2 - 1] = arguments[_key2];
1947
+ }
1948
+ _this.emit(event, ...args);
1949
+ });
1950
+ this.modules.external.forEach(m => {
1951
+ if (m.init) m.init(this);
1952
+ });
1953
+ }
1954
+ this.format = this.options.interpolation.format;
1955
+ if (!callback) callback = noop$2;
1956
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1957
+ const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1958
+ if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
1959
+ }
1960
+ if (!this.services.languageDetector && !this.options.lng) {
1961
+ this.logger.warn('init: no languageDetector is used and no lng is defined');
1962
+ }
1963
+ const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
1964
+ storeApi.forEach(fcName => {
1965
+ this[fcName] = function () {
1966
+ return _this.store[fcName](...arguments);
1967
+ };
1968
+ });
1969
+ const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
1970
+ storeApiChained.forEach(fcName => {
1971
+ this[fcName] = function () {
1972
+ _this.store[fcName](...arguments);
1973
+ return _this;
1974
+ };
1975
+ });
1976
+ const deferred = defer();
1977
+ const load = () => {
1978
+ const finish = (err, t) => {
1979
+ if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
1980
+ this.isInitialized = true;
1981
+ if (!this.options.isClone) this.logger.log('initialized', this.options);
1982
+ this.emit('initialized', this.options);
1983
+ deferred.resolve(t);
1984
+ callback(err, t);
1985
+ };
1986
+ if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));
1987
+ this.changeLanguage(this.options.lng, finish);
1988
+ };
1989
+ if (this.options.resources || !this.options.initImmediate) {
1990
+ load();
1991
+ } else {
1992
+ setTimeout(load, 0);
1993
+ }
1994
+ return deferred;
1995
+ }
1996
+ loadResources(language) {
1997
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
1998
+ let usedCallback = callback;
1999
+ const usedLng = typeof language === 'string' ? language : this.language;
2000
+ if (typeof language === 'function') usedCallback = language;
2001
+ if (!this.options.resources || this.options.partialBundledLanguages) {
2002
+ if (usedLng && usedLng.toLowerCase() === 'cimode') return usedCallback();
2003
+ const toLoad = [];
2004
+ const append = lng => {
2005
+ if (!lng) return;
2006
+ const lngs = this.services.languageUtils.toResolveHierarchy(lng);
2007
+ lngs.forEach(l => {
2008
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
2009
+ });
2010
+ };
2011
+ if (!usedLng) {
2012
+ const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
2013
+ fallbacks.forEach(l => append(l));
2014
+ } else {
2015
+ append(usedLng);
2016
+ }
2017
+ if (this.options.preload) {
2018
+ this.options.preload.forEach(l => append(l));
2019
+ }
2020
+ this.services.backendConnector.load(toLoad, this.options.ns, e => {
2021
+ if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
2022
+ usedCallback(e);
2023
+ });
2024
+ } else {
2025
+ usedCallback(null);
2026
+ }
2027
+ }
2028
+ reloadResources(lngs, ns, callback) {
2029
+ const deferred = defer();
2030
+ if (!lngs) lngs = this.languages;
2031
+ if (!ns) ns = this.options.ns;
2032
+ if (!callback) callback = noop$2;
2033
+ this.services.backendConnector.reload(lngs, ns, err => {
2034
+ deferred.resolve();
2035
+ callback(err);
2036
+ });
2037
+ return deferred;
2038
+ }
2039
+ use(module) {
2040
+ if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
2041
+ if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
2042
+ if (module.type === 'backend') {
2043
+ this.modules.backend = module;
2044
+ }
2045
+ if (module.type === 'logger' || module.log && module.warn && module.error) {
2046
+ this.modules.logger = module;
2047
+ }
2048
+ if (module.type === 'languageDetector') {
2049
+ this.modules.languageDetector = module;
2050
+ }
2051
+ if (module.type === 'i18nFormat') {
2052
+ this.modules.i18nFormat = module;
2053
+ }
2054
+ if (module.type === 'postProcessor') {
2055
+ postProcessor.addPostProcessor(module);
2056
+ }
2057
+ if (module.type === 'formatter') {
2058
+ this.modules.formatter = module;
2059
+ }
2060
+ if (module.type === '3rdParty') {
2061
+ this.modules.external.push(module);
2062
+ }
2063
+ return this;
2064
+ }
2065
+ setResolvedLanguage(l) {
2066
+ if (!l || !this.languages) return;
2067
+ if (['cimode', 'dev'].indexOf(l) > -1) return;
2068
+ for (let li = 0; li < this.languages.length; li++) {
2069
+ const lngInLngs = this.languages[li];
2070
+ if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
2071
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
2072
+ this.resolvedLanguage = lngInLngs;
2073
+ break;
2074
+ }
2075
+ }
2076
+ }
2077
+ changeLanguage(lng, callback) {
2078
+ var _this2 = this;
2079
+ this.isLanguageChangingTo = lng;
2080
+ const deferred = defer();
2081
+ this.emit('languageChanging', lng);
2082
+ const setLngProps = l => {
2083
+ this.language = l;
2084
+ this.languages = this.services.languageUtils.toResolveHierarchy(l);
2085
+ this.resolvedLanguage = undefined;
2086
+ this.setResolvedLanguage(l);
2087
+ };
2088
+ const done = (err, l) => {
2089
+ if (l) {
2090
+ setLngProps(l);
2091
+ this.translator.changeLanguage(l);
2092
+ this.isLanguageChangingTo = undefined;
2093
+ this.emit('languageChanged', l);
2094
+ this.logger.log('languageChanged', l);
2095
+ } else {
2096
+ this.isLanguageChangingTo = undefined;
2097
+ }
2098
+ deferred.resolve(function () {
2099
+ return _this2.t(...arguments);
2100
+ });
2101
+ if (callback) callback(err, function () {
2102
+ return _this2.t(...arguments);
2103
+ });
2104
+ };
2105
+ const setLng = lngs => {
2106
+ if (!lng && !lngs && this.services.languageDetector) lngs = [];
2107
+ const l = typeof lngs === 'string' ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
2108
+ if (l) {
2109
+ if (!this.language) {
2110
+ setLngProps(l);
2111
+ }
2112
+ if (!this.translator.language) this.translator.changeLanguage(l);
2113
+ if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
2114
+ }
2115
+ this.loadResources(l, err => {
2116
+ done(err, l);
2117
+ });
2118
+ };
2119
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
2120
+ setLng(this.services.languageDetector.detect());
2121
+ } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
2122
+ if (this.services.languageDetector.detect.length === 0) {
2123
+ this.services.languageDetector.detect().then(setLng);
2124
+ } else {
2125
+ this.services.languageDetector.detect(setLng);
2126
+ }
2127
+ } else {
2128
+ setLng(lng);
2129
+ }
2130
+ return deferred;
2131
+ }
2132
+ getFixedT(lng, ns, keyPrefix) {
2133
+ var _this3 = this;
2134
+ const fixedT = function (key, opts) {
2135
+ let options;
2136
+ if (typeof opts !== 'object') {
2137
+ for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2138
+ rest[_key3 - 2] = arguments[_key3];
2139
+ }
2140
+ options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2141
+ } else {
2142
+ options = {
2143
+ ...opts
2144
+ };
2145
+ }
2146
+ options.lng = options.lng || fixedT.lng;
2147
+ options.lngs = options.lngs || fixedT.lngs;
2148
+ options.ns = options.ns || fixedT.ns;
2149
+ options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2150
+ const keySeparator = _this3.options.keySeparator || '.';
2151
+ let resultKey;
2152
+ if (options.keyPrefix && Array.isArray(key)) {
2153
+ resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2154
+ } else {
2155
+ resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2156
+ }
2157
+ return _this3.t(resultKey, options);
2158
+ };
2159
+ if (typeof lng === 'string') {
2160
+ fixedT.lng = lng;
2161
+ } else {
2162
+ fixedT.lngs = lng;
2163
+ }
2164
+ fixedT.ns = ns;
2165
+ fixedT.keyPrefix = keyPrefix;
2166
+ return fixedT;
2167
+ }
2168
+ t() {
2169
+ return this.translator && this.translator.translate(...arguments);
2170
+ }
2171
+ exists() {
2172
+ return this.translator && this.translator.exists(...arguments);
2173
+ }
2174
+ setDefaultNamespace(ns) {
2175
+ this.options.defaultNS = ns;
2176
+ }
2177
+ hasLoadedNamespace(ns) {
2178
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2179
+ if (!this.isInitialized) {
2180
+ this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2181
+ return false;
2182
+ }
2183
+ if (!this.languages || !this.languages.length) {
2184
+ this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2185
+ return false;
2186
+ }
2187
+ const lng = options.lng || this.resolvedLanguage || this.languages[0];
2188
+ const fallbackLng = this.options ? this.options.fallbackLng : false;
2189
+ const lastLng = this.languages[this.languages.length - 1];
2190
+ if (lng.toLowerCase() === 'cimode') return true;
2191
+ const loadNotPending = (l, n) => {
2192
+ const loadState = this.services.backendConnector.state[`${l}|${n}`];
2193
+ return loadState === -1 || loadState === 2;
2194
+ };
2195
+ if (options.precheck) {
2196
+ const preResult = options.precheck(this, loadNotPending);
2197
+ if (preResult !== undefined) return preResult;
2198
+ }
2199
+ if (this.hasResourceBundle(lng, ns)) return true;
2200
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2201
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2202
+ return false;
2203
+ }
2204
+ loadNamespaces(ns, callback) {
2205
+ const deferred = defer();
2206
+ if (!this.options.ns) {
2207
+ if (callback) callback();
2208
+ return Promise.resolve();
2209
+ }
2210
+ if (typeof ns === 'string') ns = [ns];
2211
+ ns.forEach(n => {
2212
+ if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2213
+ });
2214
+ this.loadResources(err => {
2215
+ deferred.resolve();
2216
+ if (callback) callback(err);
2217
+ });
2218
+ return deferred;
2219
+ }
2220
+ loadLanguages(lngs, callback) {
2221
+ const deferred = defer();
2222
+ if (typeof lngs === 'string') lngs = [lngs];
2223
+ const preloaded = this.options.preload || [];
2224
+ const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0);
2225
+ if (!newLngs.length) {
2226
+ if (callback) callback();
2227
+ return Promise.resolve();
2228
+ }
2229
+ this.options.preload = preloaded.concat(newLngs);
2230
+ this.loadResources(err => {
2231
+ deferred.resolve();
2232
+ if (callback) callback(err);
2233
+ });
2234
+ return deferred;
2235
+ }
2236
+ dir(lng) {
2237
+ if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
2238
+ if (!lng) return 'rtl';
2239
+ const 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'];
2240
+ const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
2241
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2242
+ }
2243
+ static createInstance() {
2244
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2245
+ let callback = arguments.length > 1 ? arguments[1] : undefined;
2246
+ return new I18n(options, callback);
2247
+ }
2248
+ cloneInstance() {
2249
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2250
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$2;
2251
+ const forkResourceStore = options.forkResourceStore;
2252
+ if (forkResourceStore) delete options.forkResourceStore;
2253
+ const mergedOptions = {
2254
+ ...this.options,
2255
+ ...options,
2256
+ ...{
2257
+ isClone: true
2258
+ }
2259
+ };
2260
+ const clone = new I18n(mergedOptions);
2261
+ if (options.debug !== undefined || options.prefix !== undefined) {
2262
+ clone.logger = clone.logger.clone(options);
2263
+ }
2264
+ const membersToCopy = ['store', 'services', 'language'];
2265
+ membersToCopy.forEach(m => {
2266
+ clone[m] = this[m];
2267
+ });
2268
+ clone.services = {
2269
+ ...this.services
2270
+ };
2271
+ clone.services.utils = {
2272
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2273
+ };
2274
+ if (forkResourceStore) {
2275
+ clone.store = new ResourceStore(this.store.data, mergedOptions);
2276
+ clone.services.resourceStore = clone.store;
2277
+ }
2278
+ clone.translator = new Translator(clone.services, mergedOptions);
2279
+ clone.translator.on('*', function (event) {
2280
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
2281
+ args[_key4 - 1] = arguments[_key4];
2282
+ }
2283
+ clone.emit(event, ...args);
2284
+ });
2285
+ clone.init(mergedOptions, callback);
2286
+ clone.translator.options = mergedOptions;
2287
+ clone.translator.backendConnector.services.utils = {
2288
+ hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2289
+ };
2290
+ return clone;
2291
+ }
2292
+ toJSON() {
2293
+ return {
2294
+ options: this.options,
2295
+ store: this.store,
2296
+ language: this.language,
2297
+ languages: this.languages,
2298
+ resolvedLanguage: this.resolvedLanguage
2299
+ };
2300
+ }
2301
+ }
2302
+ const instance = I18n.createInstance();
2303
+ instance.createInstance = I18n.createInstance;
2304
+
2305
+ instance.createInstance;
2306
+ instance.dir;
2307
+ instance.init;
2308
+ instance.loadResources;
2309
+ instance.reloadResources;
2310
+ instance.use;
2311
+ instance.changeLanguage;
2312
+ instance.getFixedT;
2313
+ const t$2 = instance.t;
2314
+ instance.exists;
2315
+ instance.setDefaultNamespace;
2316
+ instance.hasLoadedNamespace;
2317
+ instance.loadNamespaces;
2318
+ instance.loadLanguages;
2319
+
2320
+ function getDefaultExportFromCjs (x) {
2321
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2322
+ }
2323
+
2324
+ /**
2325
+ * This file automatically generated from `pre-publish.js`.
2326
+ * Do not manually edit.
2327
+ */
2328
+
2329
+ var voidElements = {
2330
+ "area": true,
2331
+ "base": true,
2332
+ "br": true,
2333
+ "col": true,
2334
+ "embed": true,
2335
+ "hr": true,
2336
+ "img": true,
2337
+ "input": true,
2338
+ "link": true,
2339
+ "meta": true,
2340
+ "param": true,
2341
+ "source": true,
2342
+ "track": true,
2343
+ "wbr": true
2344
+ };
2345
+
2346
+ var e$1 = /*@__PURE__*/getDefaultExportFromCjs(voidElements);
2347
+
2348
+ var t$1=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n$1(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(e$1[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t$1),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i=/^\s*$/,s=Object.create(null);function a$1(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a$1,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c$1={parse:function(e,t){t||(t={}),t.components||(t.components=s);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n$1(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n$1(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a$1("",t)},"")}};
2349
+
2350
+ function warn() {
2351
+ if (console && console.warn) {
2352
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2353
+ args[_key] = arguments[_key];
2354
+ }
2355
+ if (typeof args[0] === 'string') args[0] = `react-i18next:: ${args[0]}`;
2356
+ console.warn(...args);
2357
+ }
2358
+ }
2359
+ const alreadyWarned = {};
2360
+ function warnOnce() {
2361
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2362
+ args[_key2] = arguments[_key2];
2363
+ }
2364
+ if (typeof args[0] === 'string' && alreadyWarned[args[0]]) return;
2365
+ if (typeof args[0] === 'string') alreadyWarned[args[0]] = new Date();
2366
+ warn(...args);
2367
+ }
2368
+ const loadedClb = (i18n, cb) => () => {
2369
+ if (i18n.isInitialized) {
2370
+ cb();
2371
+ } else {
2372
+ const initialized = () => {
2373
+ setTimeout(() => {
2374
+ i18n.off('initialized', initialized);
2375
+ }, 0);
2376
+ cb();
2377
+ };
2378
+ i18n.on('initialized', initialized);
2379
+ }
2380
+ };
2381
+ function loadNamespaces(i18n, ns, cb) {
2382
+ i18n.loadNamespaces(ns, loadedClb(i18n, cb));
2383
+ }
2384
+ function loadLanguages(i18n, lng, ns, cb) {
2385
+ if (typeof ns === 'string') ns = [ns];
2386
+ ns.forEach(n => {
2387
+ if (i18n.options.ns.indexOf(n) < 0) i18n.options.ns.push(n);
2388
+ });
2389
+ i18n.loadLanguages(lng, loadedClb(i18n, cb));
2390
+ }
2391
+ function oldI18nextHasLoadedNamespace(ns, i18n) {
2392
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2393
+ const lng = i18n.languages[0];
2394
+ const fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
2395
+ const lastLng = i18n.languages[i18n.languages.length - 1];
2396
+ if (lng.toLowerCase() === 'cimode') return true;
2397
+ const loadNotPending = (l, n) => {
2398
+ const loadState = i18n.services.backendConnector.state[`${l}|${n}`];
2399
+ return loadState === -1 || loadState === 2;
2400
+ };
2401
+ if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns)) return false;
2402
+ if (i18n.hasResourceBundle(lng, ns)) return true;
2403
+ if (!i18n.services.backendConnector.backend || i18n.options.resources && !i18n.options.partialBundledLanguages) return true;
2404
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2405
+ return false;
2406
+ }
2407
+ function hasLoadedNamespace(ns, i18n) {
2408
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2409
+ if (!i18n.languages || !i18n.languages.length) {
2410
+ warnOnce('i18n.languages were undefined or empty', i18n.languages);
2411
+ return true;
2412
+ }
2413
+ const isNewerI18next = i18n.options.ignoreJSONStructure !== undefined;
2414
+ if (!isNewerI18next) {
2415
+ return oldI18nextHasLoadedNamespace(ns, i18n, options);
2416
+ }
2417
+ return i18n.hasLoadedNamespace(ns, {
2418
+ lng: options.lng,
2419
+ precheck: (i18nInstance, loadNotPending) => {
2420
+ if (options.bindI18n && options.bindI18n.indexOf('languageChanging') > -1 && i18nInstance.services.backendConnector.backend && i18nInstance.isLanguageChangingTo && !loadNotPending(i18nInstance.isLanguageChangingTo, ns)) return false;
2421
+ }
2422
+ });
2423
+ }
2424
+
2425
+ const matchHtmlEntity = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g;
2426
+ const htmlEntities = {
2427
+ '&amp;': '&',
2428
+ '&#38;': '&',
2429
+ '&lt;': '<',
2430
+ '&#60;': '<',
2431
+ '&gt;': '>',
2432
+ '&#62;': '>',
2433
+ '&apos;': "'",
2434
+ '&#39;': "'",
2435
+ '&quot;': '"',
2436
+ '&#34;': '"',
2437
+ '&nbsp;': ' ',
2438
+ '&#160;': ' ',
2439
+ '&copy;': '©',
2440
+ '&#169;': '©',
2441
+ '&reg;': '®',
2442
+ '&#174;': '®',
2443
+ '&hellip;': '…',
2444
+ '&#8230;': '…',
2445
+ '&#x2F;': '/',
2446
+ '&#47;': '/'
2447
+ };
2448
+ const unescapeHtmlEntity = m => htmlEntities[m];
2449
+ const unescape$1 = text => text.replace(matchHtmlEntity, unescapeHtmlEntity);
2450
+
2451
+ let defaultOptions = {
2452
+ bindI18n: 'languageChanged',
2453
+ bindI18nStore: '',
2454
+ transEmptyNodeValue: '',
2455
+ transSupportBasicHtmlNodes: true,
2456
+ transWrapTextNodes: '',
2457
+ transKeepBasicHtmlNodesFor: ['br', 'strong', 'i', 'p'],
2458
+ useSuspense: true,
2459
+ unescape: unescape$1
2460
+ };
2461
+ function setDefaults() {
2462
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2463
+ defaultOptions = {
2464
+ ...defaultOptions,
2465
+ ...options
2466
+ };
2467
+ }
2468
+ function getDefaults() {
2469
+ return defaultOptions;
2470
+ }
2471
+
2472
+ let i18nInstance;
2473
+ function setI18n(instance) {
2474
+ i18nInstance = instance;
2475
+ }
2476
+ function getI18n() {
2477
+ return i18nInstance;
2478
+ }
2479
+
2480
+ function hasChildren(node, checkLength) {
2481
+ if (!node) return false;
2482
+ const base = node.props ? node.props.children : node.children;
2483
+ if (checkLength) return base.length > 0;
2484
+ return !!base;
2485
+ }
2486
+ function getChildren(node) {
2487
+ if (!node) return [];
2488
+ return node.props ? node.props.children : node.children;
2489
+ }
2490
+ function hasValidReactChildren(children) {
2491
+ if (Object.prototype.toString.call(children) !== '[object Array]') return false;
2492
+ return children.every(child => React.isValidElement(child));
2493
+ }
2494
+ function getAsArray(data) {
2495
+ return Array.isArray(data) ? data : [data];
2496
+ }
2497
+ function mergeProps(source, target) {
2498
+ const newTarget = {
2499
+ ...target
2500
+ };
2501
+ newTarget.props = Object.assign(source.props, target.props);
2502
+ return newTarget;
2503
+ }
2504
+ function nodesToString(children, i18nOptions) {
2505
+ if (!children) return '';
2506
+ let stringNode = '';
2507
+ const childrenArray = getAsArray(children);
2508
+ const keepArray = i18nOptions.transSupportBasicHtmlNodes && i18nOptions.transKeepBasicHtmlNodesFor ? i18nOptions.transKeepBasicHtmlNodesFor : [];
2509
+ childrenArray.forEach((child, childIndex) => {
2510
+ if (typeof child === 'string') {
2511
+ stringNode += `${child}`;
2512
+ } else if (React.isValidElement(child)) {
2513
+ const childPropsCount = Object.keys(child.props).length;
2514
+ const shouldKeepChild = keepArray.indexOf(child.type) > -1;
2515
+ const childChildren = child.props.children;
2516
+ if (!childChildren && shouldKeepChild && childPropsCount === 0) {
2517
+ stringNode += `<${child.type}/>`;
2518
+ } else if (!childChildren && (!shouldKeepChild || childPropsCount !== 0)) {
2519
+ stringNode += `<${childIndex}></${childIndex}>`;
2520
+ } else if (child.props.i18nIsDynamicList) {
2521
+ stringNode += `<${childIndex}></${childIndex}>`;
2522
+ } else if (shouldKeepChild && childPropsCount === 1 && typeof childChildren === 'string') {
2523
+ stringNode += `<${child.type}>${childChildren}</${child.type}>`;
2524
+ } else {
2525
+ const content = nodesToString(childChildren, i18nOptions);
2526
+ stringNode += `<${childIndex}>${content}</${childIndex}>`;
2527
+ }
2528
+ } else if (child === null) {
2529
+ warn(`Trans: the passed in value is invalid - seems you passed in a null child.`);
2530
+ } else if (typeof child === 'object') {
2531
+ const {
2532
+ format,
2533
+ ...clone
2534
+ } = child;
2535
+ const keys = Object.keys(clone);
2536
+ if (keys.length === 1) {
2537
+ const value = format ? `${keys[0]}, ${format}` : keys[0];
2538
+ stringNode += `{{${value}}}`;
2539
+ } else {
2540
+ warn(`react-i18next: the passed in object contained more than one variable - the object should look like {{ value, format }} where format is optional.`, child);
2541
+ }
2542
+ } else {
2543
+ warn(`Trans: the passed in value is invalid - seems you passed in a variable like {number} - please pass in variables for interpolation as full objects like {{number}}.`, child);
2544
+ }
2545
+ });
2546
+ return stringNode;
2547
+ }
2548
+ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts, shouldUnescape) {
2549
+ if (targetString === '') return [];
2550
+ const keepArray = i18nOptions.transKeepBasicHtmlNodesFor || [];
2551
+ const emptyChildrenButNeedsHandling = targetString && new RegExp(keepArray.join('|')).test(targetString);
2552
+ if (!children && !emptyChildrenButNeedsHandling) return [targetString];
2553
+ const data = {};
2554
+ function getData(childs) {
2555
+ const childrenArray = getAsArray(childs);
2556
+ childrenArray.forEach(child => {
2557
+ if (typeof child === 'string') return;
2558
+ if (hasChildren(child)) getData(getChildren(child));else if (typeof child === 'object' && !React.isValidElement(child)) Object.assign(data, child);
2559
+ });
2560
+ }
2561
+ getData(children);
2562
+ const ast = c$1.parse(`<0>${targetString}</0>`);
2563
+ const opts = {
2564
+ ...data,
2565
+ ...combinedTOpts
2566
+ };
2567
+ function renderInner(child, node, rootReactNode) {
2568
+ const childs = getChildren(child);
2569
+ const mappedChildren = mapAST(childs, node.children, rootReactNode);
2570
+ return hasValidReactChildren(childs) && mappedChildren.length === 0 ? childs : mappedChildren;
2571
+ }
2572
+ function pushTranslatedJSX(child, inner, mem, i, isVoid) {
2573
+ if (child.dummy) child.children = inner;
2574
+ mem.push(React.cloneElement(child, {
2575
+ ...child.props,
2576
+ key: i
2577
+ }, isVoid ? undefined : inner));
2578
+ }
2579
+ function mapAST(reactNode, astNode, rootReactNode) {
2580
+ const reactNodes = getAsArray(reactNode);
2581
+ const astNodes = getAsArray(astNode);
2582
+ return astNodes.reduce((mem, node, i) => {
2583
+ const translationContent = node.children && node.children[0] && node.children[0].content && i18n.services.interpolator.interpolate(node.children[0].content, opts, i18n.language);
2584
+ if (node.type === 'tag') {
2585
+ let tmp = reactNodes[parseInt(node.name, 10)];
2586
+ if (!tmp && rootReactNode.length === 1 && rootReactNode[0][node.name]) tmp = rootReactNode[0][node.name];
2587
+ if (!tmp) tmp = {};
2588
+ const child = Object.keys(node.attrs).length !== 0 ? mergeProps({
2589
+ props: node.attrs
2590
+ }, tmp) : tmp;
2591
+ const isElement = React.isValidElement(child);
2592
+ const isValidTranslationWithChildren = isElement && hasChildren(node, true) && !node.voidElement;
2593
+ const isEmptyTransWithHTML = emptyChildrenButNeedsHandling && typeof child === 'object' && child.dummy && !isElement;
2594
+ const isKnownComponent = typeof children === 'object' && children !== null && Object.hasOwnProperty.call(children, node.name);
2595
+ if (typeof child === 'string') {
2596
+ const value = i18n.services.interpolator.interpolate(child, opts, i18n.language);
2597
+ mem.push(value);
2598
+ } else if (hasChildren(child) || isValidTranslationWithChildren) {
2599
+ const inner = renderInner(child, node, rootReactNode);
2600
+ pushTranslatedJSX(child, inner, mem, i);
2601
+ } else if (isEmptyTransWithHTML) {
2602
+ const inner = mapAST(reactNodes, node.children, rootReactNode);
2603
+ mem.push(React.cloneElement(child, {
2604
+ ...child.props,
2605
+ key: i
2606
+ }, inner));
2607
+ } else if (Number.isNaN(parseFloat(node.name))) {
2608
+ if (isKnownComponent) {
2609
+ const inner = renderInner(child, node, rootReactNode);
2610
+ pushTranslatedJSX(child, inner, mem, i, node.voidElement);
2611
+ } else if (i18nOptions.transSupportBasicHtmlNodes && keepArray.indexOf(node.name) > -1) {
2612
+ if (node.voidElement) {
2613
+ mem.push(React.createElement(node.name, {
2614
+ key: `${node.name}-${i}`
2615
+ }));
2616
+ } else {
2617
+ const inner = mapAST(reactNodes, node.children, rootReactNode);
2618
+ mem.push(React.createElement(node.name, {
2619
+ key: `${node.name}-${i}`
2620
+ }, inner));
2621
+ }
2622
+ } else if (node.voidElement) {
2623
+ mem.push(`<${node.name} />`);
2624
+ } else {
2625
+ const inner = mapAST(reactNodes, node.children, rootReactNode);
2626
+ mem.push(`<${node.name}>${inner}</${node.name}>`);
2627
+ }
2628
+ } else if (typeof child === 'object' && !isElement) {
2629
+ const content = node.children[0] ? translationContent : null;
2630
+ if (content) mem.push(content);
2631
+ } else if (node.children.length === 1 && translationContent) {
2632
+ mem.push(React.cloneElement(child, {
2633
+ ...child.props,
2634
+ key: i
2635
+ }, translationContent));
2636
+ } else {
2637
+ mem.push(React.cloneElement(child, {
2638
+ ...child.props,
2639
+ key: i
2640
+ }));
2641
+ }
2642
+ } else if (node.type === 'text') {
2643
+ const wrapTextNodes = i18nOptions.transWrapTextNodes;
2644
+ const content = shouldUnescape ? i18nOptions.unescape(i18n.services.interpolator.interpolate(node.content, opts, i18n.language)) : i18n.services.interpolator.interpolate(node.content, opts, i18n.language);
2645
+ if (wrapTextNodes) {
2646
+ mem.push(React.createElement(wrapTextNodes, {
2647
+ key: `${node.name}-${i}`
2648
+ }, content));
2649
+ } else {
2650
+ mem.push(content);
2651
+ }
2652
+ }
2653
+ return mem;
2654
+ }, []);
2655
+ }
2656
+ const result = mapAST([{
2657
+ dummy: true,
2658
+ children: children || []
2659
+ }], ast, getAsArray(children || []));
2660
+ return getChildren(result[0]);
2661
+ }
2662
+ function Trans$1(_ref) {
2663
+ let {
2664
+ children,
2665
+ count,
2666
+ parent,
2667
+ i18nKey,
2668
+ context,
2669
+ tOptions = {},
2670
+ values,
2671
+ defaults,
2672
+ components,
2673
+ ns,
2674
+ i18n: i18nFromProps,
2675
+ t: tFromProps,
2676
+ shouldUnescape,
2677
+ ...additionalProps
2678
+ } = _ref;
2679
+ const i18n = i18nFromProps || getI18n();
2680
+ if (!i18n) {
2681
+ warnOnce('You will need to pass in an i18next instance by using i18nextReactModule');
2682
+ return children;
2683
+ }
2684
+ const t = tFromProps || i18n.t.bind(i18n) || (k => k);
2685
+ if (context) tOptions.context = context;
2686
+ const reactI18nextOptions = {
2687
+ ...getDefaults(),
2688
+ ...(i18n.options && i18n.options.react)
2689
+ };
2690
+ let namespaces = ns || t.ns || i18n.options && i18n.options.defaultNS;
2691
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
2692
+ const defaultValue = defaults || nodesToString(children, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue || i18nKey;
2693
+ const {
2694
+ hashTransKey
2695
+ } = reactI18nextOptions;
2696
+ const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
2697
+ const interpolationOverride = values ? tOptions.interpolation : {
2698
+ interpolation: {
2699
+ ...tOptions.interpolation,
2700
+ prefix: '#$?',
2701
+ suffix: '?$#'
2702
+ }
2703
+ };
2704
+ const combinedTOpts = {
2705
+ ...tOptions,
2706
+ count,
2707
+ ...values,
2708
+ ...interpolationOverride,
2709
+ defaultValue,
2710
+ ns: namespaces
2711
+ };
2712
+ const translation = key ? t(key, combinedTOpts) : defaultValue;
2713
+ const content = renderNodes(components || children, translation, i18n, reactI18nextOptions, combinedTOpts, shouldUnescape);
2714
+ const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
2715
+ return useAsParent ? React.createElement(useAsParent, additionalProps, content) : content;
2716
+ }
2717
+
2718
+ const initReactI18next = {
2719
+ type: '3rdParty',
2720
+ init(instance) {
2721
+ setDefaults(instance.options.react);
2722
+ setI18n(instance);
2723
+ }
2724
+ };
2725
+
2726
+ const I18nContext = React.createContext();
2727
+ class ReportNamespaces {
2728
+ constructor() {
2729
+ this.usedNamespaces = {};
2730
+ }
2731
+ addUsedNamespaces(namespaces) {
2732
+ namespaces.forEach(ns => {
2733
+ if (!this.usedNamespaces[ns]) this.usedNamespaces[ns] = true;
2734
+ });
2735
+ }
2736
+ getUsedNamespaces() {
2737
+ return Object.keys(this.usedNamespaces);
2738
+ }
2739
+ }
2740
+
2741
+ function Trans(_ref) {
2742
+ let {
2743
+ children,
2744
+ count,
2745
+ parent,
2746
+ i18nKey,
2747
+ context,
2748
+ tOptions = {},
2749
+ values,
2750
+ defaults,
2751
+ components,
2752
+ ns,
2753
+ i18n: i18nFromProps,
2754
+ t: tFromProps,
2755
+ shouldUnescape,
2756
+ ...additionalProps
2757
+ } = _ref;
2758
+ const {
2759
+ i18n: i18nFromContext,
2760
+ defaultNS: defaultNSFromContext
2761
+ } = React.useContext(I18nContext) || {};
2762
+ const i18n = i18nFromProps || i18nFromContext || getI18n();
2763
+ const t = tFromProps || i18n && i18n.t.bind(i18n);
2764
+ return Trans$1({
2765
+ children,
2766
+ count,
2767
+ parent,
2768
+ i18nKey,
2769
+ context,
2770
+ tOptions,
2771
+ values,
2772
+ defaults,
2773
+ components,
2774
+ ns: ns || t && t.ns || defaultNSFromContext || i18n && i18n.options && i18n.options.defaultNS,
2775
+ i18n,
2776
+ t: tFromProps,
2777
+ shouldUnescape,
2778
+ ...additionalProps
2779
+ });
2780
+ }
2781
+
2782
+ const usePrevious = (value, ignore) => {
2783
+ const ref = React.useRef();
2784
+ React.useEffect(() => {
2785
+ ref.current = ignore ? ref.current : value;
2786
+ }, [value, ignore]);
2787
+ return ref.current;
2788
+ };
2789
+ function useTranslation(ns) {
2790
+ let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2791
+ const {
2792
+ i18n: i18nFromProps
2793
+ } = props;
2794
+ const {
2795
+ i18n: i18nFromContext,
2796
+ defaultNS: defaultNSFromContext
2797
+ } = React.useContext(I18nContext) || {};
2798
+ const i18n = i18nFromProps || i18nFromContext || getI18n();
2799
+ if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
2800
+ if (!i18n) {
2801
+ warnOnce('You will need to pass in an i18next instance by using initReactI18next');
2802
+ const notReadyT = (k, optsOrDefaultValue) => {
2803
+ if (typeof optsOrDefaultValue === 'string') return optsOrDefaultValue;
2804
+ if (optsOrDefaultValue && typeof optsOrDefaultValue === 'object' && typeof optsOrDefaultValue.defaultValue === 'string') return optsOrDefaultValue.defaultValue;
2805
+ return Array.isArray(k) ? k[k.length - 1] : k;
2806
+ };
2807
+ const retNotReady = [notReadyT, {}, false];
2808
+ retNotReady.t = notReadyT;
2809
+ retNotReady.i18n = {};
2810
+ retNotReady.ready = false;
2811
+ return retNotReady;
2812
+ }
2813
+ if (i18n.options.react && i18n.options.react.wait !== undefined) warnOnce('It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.');
2814
+ const i18nOptions = {
2815
+ ...getDefaults(),
2816
+ ...i18n.options.react,
2817
+ ...props
2818
+ };
2819
+ const {
2820
+ useSuspense,
2821
+ keyPrefix
2822
+ } = i18nOptions;
2823
+ let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
2824
+ namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
2825
+ if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces);
2826
+ const ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(n => hasLoadedNamespace(n, i18n, i18nOptions));
2827
+ function getT() {
2828
+ return i18n.getFixedT(props.lng || null, i18nOptions.nsMode === 'fallback' ? namespaces : namespaces[0], keyPrefix);
2829
+ }
2830
+ const [t, setT] = React.useState(getT);
2831
+ let joinedNS = namespaces.join();
2832
+ if (props.lng) joinedNS = `${props.lng}${joinedNS}`;
2833
+ const previousJoinedNS = usePrevious(joinedNS);
2834
+ const isMounted = React.useRef(true);
2835
+ React.useEffect(() => {
2836
+ const {
2837
+ bindI18n,
2838
+ bindI18nStore
2839
+ } = i18nOptions;
2840
+ isMounted.current = true;
2841
+ if (!ready && !useSuspense) {
2842
+ if (props.lng) {
2843
+ loadLanguages(i18n, props.lng, namespaces, () => {
2844
+ if (isMounted.current) setT(getT);
2845
+ });
2846
+ } else {
2847
+ loadNamespaces(i18n, namespaces, () => {
2848
+ if (isMounted.current) setT(getT);
2849
+ });
2850
+ }
2851
+ }
2852
+ if (ready && previousJoinedNS && previousJoinedNS !== joinedNS && isMounted.current) {
2853
+ setT(getT);
2854
+ }
2855
+ function boundReset() {
2856
+ if (isMounted.current) setT(getT);
2857
+ }
2858
+ if (bindI18n && i18n) i18n.on(bindI18n, boundReset);
2859
+ if (bindI18nStore && i18n) i18n.store.on(bindI18nStore, boundReset);
2860
+ return () => {
2861
+ isMounted.current = false;
2862
+ if (bindI18n && i18n) bindI18n.split(' ').forEach(e => i18n.off(e, boundReset));
2863
+ if (bindI18nStore && i18n) bindI18nStore.split(' ').forEach(e => i18n.store.off(e, boundReset));
2864
+ };
2865
+ }, [i18n, joinedNS]);
2866
+ const isInitial = React.useRef(true);
2867
+ React.useEffect(() => {
2868
+ if (isMounted.current && !isInitial.current) {
2869
+ setT(getT);
2870
+ }
2871
+ isInitial.current = false;
2872
+ }, [i18n, keyPrefix]);
2873
+ const ret = [t, i18n, ready];
2874
+ ret.t = t;
2875
+ ret.i18n = i18n;
2876
+ ret.ready = ready;
2877
+ if (ready) return ret;
2878
+ if (!ready && !useSuspense) return ret;
2879
+ throw new Promise(resolve => {
2880
+ if (props.lng) {
2881
+ loadLanguages(i18n, props.lng, namespaces, () => resolve());
2882
+ } else {
2883
+ loadNamespaces(i18n, namespaces, () => resolve());
2884
+ }
2885
+ });
2886
+ }
2887
+
53
2888
  var common = {
54
2889
  thankYou: "Thank You",
55
2890
  alert: "Alert",
@@ -102,7 +2937,7 @@ var en = {
102
2937
  buttons: buttons
103
2938
  };
104
2939
 
105
- i18n__default["default"].use(reactI18next.initReactI18next).init({
2940
+ instance.use(initReactI18next).init({
106
2941
  resources: {
107
2942
  en: {
108
2943
  translation: en
@@ -113,13 +2948,13 @@ i18n__default["default"].use(reactI18next.initReactI18next).init({
113
2948
 
114
2949
  var FORM_OPTIONS = {
115
2950
  customize: {
116
- label: i18n.t("thankYou.customize"),
117
- description: i18n.t("thankYou.customizeDescription"),
2951
+ label: t$2("thankYou.customize"),
2952
+ description: t$2("thankYou.customizeDescription"),
118
2953
  kind: "custom_message"
119
2954
  },
120
2955
  externalLink: {
121
- label: i18n.t("thankYou.externalLink"),
122
- description: i18n.t("thankYou.externalLinkDescription"),
2956
+ label: t$2("thankYou.externalLink"),
2957
+ description: t$2("thankYou.externalLinkDescription"),
123
2958
  kind: "redirect_to_url"
124
2959
  }
125
2960
  };
@@ -129,18 +2964,18 @@ var DEFAULT_IMAGE_PROPERTIES = {
129
2964
  };
130
2965
  var VALIDATION_SCHEMA = yup__namespace.object().shape({
131
2966
  kind: yup__namespace.string().required(),
132
- message: yup__namespace.string().test("message", i18n.t("thankYou.validations.messageRequired"), function (value) {
2967
+ message: yup__namespace.string().test("message", t$2("thankYou.validations.messageRequired"), function (value) {
133
2968
  return !neetoEditor.isEditorEmpty(value);
134
2969
  }),
135
2970
  socialSharingEnabled: yup__namespace.bool(),
136
2971
  showResubmitLink: yup__namespace.bool(),
137
2972
  resubmitLinkText: yup__namespace.string().when("showResubmitLink", {
138
2973
  is: true,
139
- then: yup__namespace.string().required(i18n.t("thankYou.validations.resubmitLinkTextIsRequired"))
2974
+ then: yup__namespace.string().required(t$2("thankYou.validations.resubmitLinkTextIsRequired"))
140
2975
  }),
141
2976
  redirectUrl: yup__namespace.string().when("kind", {
142
2977
  is: FORM_OPTIONS.externalLink.kind,
143
- then: yup__namespace.string().url(i18n.t("thankYou.validations.invalidLink")).required(i18n.t("thankYou.validations.invalidLink")).when("kind", {
2978
+ then: yup__namespace.string().url(t$2("thankYou.validations.invalidLink")).required(t$2("thankYou.validations.invalidLink")).when("kind", {
144
2979
  is: FORM_OPTIONS.customize.kind,
145
2980
  then: yup__namespace.string()
146
2981
  })
@@ -321,7 +3156,7 @@ function _slicedToArray$2(arr, i) {
321
3156
  var Preview$1 = function Preview(_ref) {
322
3157
  var handleRemove = _ref.handleRemove,
323
3158
  url = _ref.url;
324
- var _useTranslation = reactI18next.useTranslation(),
3159
+ var _useTranslation = useTranslation(),
325
3160
  t = _useTranslation.t;
326
3161
  return /*#__PURE__*/React__default["default"].createElement("div", {
327
3162
  className: "w-100 flex flex-row justify-center"
@@ -7800,10 +10635,6 @@ function _asyncToGenerator(fn) {
7800
10635
  };
7801
10636
  }
7802
10637
 
7803
- function getDefaultExportFromCjs (x) {
7804
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
7805
- }
7806
-
7807
10638
  var regeneratorRuntime$1 = {exports: {}};
7808
10639
 
7809
10640
  var _typeof = {exports: {}};
@@ -10542,7 +13373,7 @@ var useDropzoneWithValidation = function useDropzoneWithValidation(_ref) {
10542
13373
  uploadProgress = _useState6[0],
10543
13374
  setUploadProgress = _useState6[1];
10544
13375
  var maxSizeInReadableUnits = bytesToSize(maxSize);
10545
- var _useTranslation = reactI18next.useTranslation(),
13376
+ var _useTranslation = useTranslation(),
10546
13377
  t = _useTranslation.t;
10547
13378
  var fileErrors = {
10548
13379
  "file-invalid-type": t("thankYou.errors.fileTypeError", {
@@ -10657,7 +13488,7 @@ var HEADER_IMAGE_KIND = "image/png, image/jpg, image/jpeg, image/gif, image/svg+
10657
13488
  var Upload = function Upload(_ref) {
10658
13489
  var _classnames;
10659
13490
  var handleChangeUrl = _ref.handleChangeUrl;
10660
- var _useTranslation = reactI18next.useTranslation(),
13491
+ var _useTranslation = useTranslation(),
10661
13492
  t = _useTranslation.t;
10662
13493
  var _useDropzoneWithValid = useDropzoneWithValidation({
10663
13494
  acceptedTypes: HEADER_IMAGE_KIND,
@@ -10691,7 +13522,7 @@ var Upload = function Upload(_ref) {
10691
13522
  className: "flex flex-col items-center gap-y-3"
10692
13523
  }, /*#__PURE__*/React__default["default"].createElement(neetoIcons.ImageUpload, null), /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
10693
13524
  style: "body2"
10694
- }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
13525
+ }, /*#__PURE__*/React__default["default"].createElement(Trans, {
10695
13526
  i18nKey: "thankYou.imageUpload",
10696
13527
  components: {
10697
13528
  span: /*#__PURE__*/React__default["default"].createElement("span", {
@@ -10728,7 +13559,7 @@ var ResubmissionWarningModal = function ResubmissionWarningModal(_ref) {
10728
13559
  var isOpen = _ref.isOpen,
10729
13560
  setIsOpen = _ref.setIsOpen,
10730
13561
  uniqueSubmissionLink = _ref.uniqueSubmissionLink;
10731
- var _useTranslation = reactI18next.useTranslation(),
13562
+ var _useTranslation = useTranslation(),
10732
13563
  t = _useTranslation.t;
10733
13564
  return /*#__PURE__*/React__default["default"].createElement(neetoui.Modal, {
10734
13565
  isOpen: isOpen,
@@ -10764,7 +13595,7 @@ var Customize = function Customize(_ref) {
10764
13595
  var editorRef = React.useRef({
10765
13596
  editor: {}
10766
13597
  });
10767
- var _useTranslation = reactI18next.useTranslation(),
13598
+ var _useTranslation = useTranslation(),
10768
13599
  t = _useTranslation.t;
10769
13600
  var _useFormikContext = formik.useFormikContext(),
10770
13601
  values = _useFormikContext.values,
@@ -10852,7 +13683,7 @@ const SvgBrowserControls = props => /*#__PURE__*/React__namespace.createElement(
10852
13683
  var SocialShare = function SocialShare(_ref) {
10853
13684
  var socialHandles = _ref.socialHandles,
10854
13685
  publicLinkId = _ref.publicLinkId;
10855
- var _useTranslation = reactI18next.useTranslation(),
13686
+ var _useTranslation = useTranslation(),
10856
13687
  t = _useTranslation.t;
10857
13688
  return /*#__PURE__*/React__default["default"].createElement("div", {
10858
13689
  className: "neeto-thank-you-configuration__social-share"
@@ -10884,7 +13715,7 @@ var Preview = function Preview(_ref) {
10884
13715
  isPublished = _ref.isPublished;
10885
13716
  var _useFormikContext = formik.useFormikContext(),
10886
13717
  values = _useFormikContext.values;
10887
- var _useTranslation = reactI18next.useTranslation(),
13718
+ var _useTranslation = useTranslation(),
10888
13719
  t = _useTranslation.t;
10889
13720
  return /*#__PURE__*/React__default["default"].createElement("div", {
10890
13721
  className: classNames__default["default"]("neeto-thank-you-configuration-preview", {
@@ -10921,7 +13752,7 @@ var Preview = function Preview(_ref) {
10921
13752
  className: "neeto-thank-you-configuration__nav"
10922
13753
  }, /*#__PURE__*/React__default["default"].createElement("div", {
10923
13754
  className: "neeto-thank-you-configuration__nav-footer"
10924
- }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
13755
+ }, /*#__PURE__*/React__default["default"].createElement(Trans, {
10925
13756
  i18nKey: "thankYou.formBranding",
10926
13757
  components: {
10927
13758
  a: /*#__PURE__*/React__default["default"].createElement("a", {
@@ -10937,7 +13768,7 @@ var Preview = function Preview(_ref) {
10937
13768
  }, /*#__PURE__*/React__default["default"].createElement(neetoui.Typography, {
10938
13769
  className: "neeto-ui-text-gray-500",
10939
13770
  style: "body3"
10940
- }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
13771
+ }, /*#__PURE__*/React__default["default"].createElement(Trans, {
10941
13772
  components: {
10942
13773
  strong: /*#__PURE__*/React__default["default"].createElement("strong", null)
10943
13774
  },
@@ -10946,7 +13777,7 @@ var Preview = function Preview(_ref) {
10946
13777
  };
10947
13778
 
10948
13779
  var ExternalLink = function ExternalLink() {
10949
- var _useTranslation = reactI18next.useTranslation(),
13780
+ var _useTranslation = useTranslation(),
10950
13781
  t = _useTranslation.t;
10951
13782
  return /*#__PURE__*/React__default["default"].createElement(formik$1.Input, {
10952
13783
  autoFocus: true,
@@ -10982,7 +13813,7 @@ var Form = function Form(_ref) {
10982
13813
  thankYouTextAlignment = _ref.thankYouTextAlignment,
10983
13814
  resubmitLink = _ref.resubmitLink,
10984
13815
  isPublished = _ref.isPublished;
10985
- var _useTranslation = reactI18next.useTranslation(),
13816
+ var _useTranslation = useTranslation(),
10986
13817
  t = _useTranslation.t;
10987
13818
  var _useShowThankYouConfi = useShowThankYouConfiguration({
10988
13819
  entityId: entityId
@@ -11074,7 +13905,7 @@ var Form = function Form(_ref) {
11074
13905
 
11075
13906
  var Header = function Header(_ref) {
11076
13907
  var breadcrumbs = _ref.breadcrumbs;
11077
- var _useTranslation = reactI18next.useTranslation(),
13908
+ var _useTranslation = useTranslation(),
11078
13909
  t = _useTranslation.t;
11079
13910
  return /*#__PURE__*/React__default["default"].createElement("div", {
11080
13911
  className: "w-full px-6"
@@ -11160,7 +13991,7 @@ var ShowThankYou = function ShowThankYou(_ref) {
11160
13991
  socialHandles = _ref.socialHandles,
11161
13992
  isThankYouPageLoading = _ref.isThankYouPageLoading,
11162
13993
  publicLinkId = _ref.publicLinkId;
11163
- var _useTranslation = reactI18next.useTranslation(),
13994
+ var _useTranslation = useTranslation(),
11164
13995
  t = _useTranslation.t;
11165
13996
  var _useShowThankYouPage = useShowThankYouPage({
11166
13997
  entityId: entityId
@@ -11203,7 +14034,7 @@ var ShowThankYou = function ShowThankYou(_ref) {
11203
14034
  className: "neeto-thank-you-configuration__nav"
11204
14035
  }, /*#__PURE__*/React__default["default"].createElement("div", {
11205
14036
  className: "neeto-thank-you-configuration__nav-footer"
11206
- }, /*#__PURE__*/React__default["default"].createElement(reactI18next.Trans, {
14037
+ }, /*#__PURE__*/React__default["default"].createElement(Trans, {
11207
14038
  i18nKey: "thankYou.formBranding",
11208
14039
  components: {
11209
14040
  a: /*#__PURE__*/React__default["default"].createElement("a", {