mp-front-cli 0.0.52 → 0.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/package.json +5 -1
  2. package/dist/core/errors/error-catalog.d.ts +0 -15
  3. package/dist/core/errors/error-catalog.d.ts.map +0 -1
  4. package/dist/core/errors/index.d.ts +0 -2
  5. package/dist/core/errors/index.d.ts.map +0 -1
  6. package/dist/core/errors/message-error.d.ts +0 -16
  7. package/dist/core/errors/message-error.d.ts.map +0 -1
  8. package/dist/core/index.d.ts +0 -6
  9. package/dist/core/index.d.ts.map +0 -1
  10. package/dist/core/interfaces/api-response.d.ts +0 -41
  11. package/dist/core/interfaces/api-response.d.ts.map +0 -1
  12. package/dist/core/interfaces/index.d.ts +0 -3
  13. package/dist/core/interfaces/index.d.ts.map +0 -1
  14. package/dist/core/interfaces/message.d.ts +0 -15
  15. package/dist/core/interfaces/message.d.ts.map +0 -1
  16. package/dist/core/interfaces/method.d.ts +0 -2
  17. package/dist/core/interfaces/method.d.ts.map +0 -1
  18. package/dist/core/interfaces/session.d.ts +0 -19
  19. package/dist/core/interfaces/session.d.ts.map +0 -1
  20. package/dist/core/middleware/index.d.ts +0 -17
  21. package/dist/core/middleware/index.d.ts.map +0 -1
  22. package/dist/core/services/index.d.ts +0 -2
  23. package/dist/core/services/index.d.ts.map +0 -1
  24. package/dist/core/services/service-token.d.ts +0 -13
  25. package/dist/core/services/service-token.d.ts.map +0 -1
  26. package/dist/core/utils/api-request/fetch-service-be.d.ts +0 -12
  27. package/dist/core/utils/api-request/fetch-service-be.d.ts.map +0 -1
  28. package/dist/core/utils/api-request/fetch-service-fe.d.ts +0 -14
  29. package/dist/core/utils/api-request/fetch-service-fe.d.ts.map +0 -1
  30. package/dist/core/utils/api-request/index.d.ts +0 -3
  31. package/dist/core/utils/api-request/index.d.ts.map +0 -1
  32. package/dist/core/utils/custom-cache.d.ts +0 -57
  33. package/dist/core/utils/custom-cache.d.ts.map +0 -1
  34. package/dist/core/utils/custom-encoder.d.ts +0 -8
  35. package/dist/core/utils/custom-encoder.d.ts.map +0 -1
  36. package/dist/core/utils/custom-encrypter.d.ts +0 -10
  37. package/dist/core/utils/custom-encrypter.d.ts.map +0 -1
  38. package/dist/core/utils/custom-header.d.ts +0 -9
  39. package/dist/core/utils/custom-header.d.ts.map +0 -1
  40. package/dist/core/utils/custom-logger.d.ts +0 -16
  41. package/dist/core/utils/custom-logger.d.ts.map +0 -1
  42. package/dist/core/utils/index.d.ts +0 -3
  43. package/dist/core/utils/index.d.ts.map +0 -1
  44. package/dist/core/utils/rxjs/index.d.ts +0 -4
  45. package/dist/core/utils/rxjs/index.d.ts.map +0 -1
  46. package/dist/core/utils/rxjs/loading-handler.d.ts +0 -7
  47. package/dist/core/utils/rxjs/loading-handler.d.ts.map +0 -1
  48. package/dist/core/utils/rxjs/message-handler.d.ts +0 -8
  49. package/dist/core/utils/rxjs/message-handler.d.ts.map +0 -1
  50. package/dist/core/utils/rxjs/rx-subject-manager.d.ts +0 -9
  51. package/dist/core/utils/rxjs/rx-subject-manager.d.ts.map +0 -1
  52. package/dist/custom-encoder-70a77460.js +0 -3734
  53. package/dist/custom-encrypter-8d9d2783.js +0 -20318
  54. package/dist/custom-header-17ded9ec.js +0 -866
  55. package/dist/index-df4e0539.js +0 -31
  56. package/dist/index.d.ts +0 -2
  57. package/dist/index.d.ts.map +0 -1
  58. package/dist/lang/common/errors/en_EN/index.d.ts +0 -5
  59. package/dist/lang/common/errors/en_EN/index.d.ts.map +0 -1
  60. package/dist/lang/common/errors/es_MX/index.d.ts +0 -30
  61. package/dist/lang/common/errors/es_MX/index.d.ts.map +0 -1
  62. package/dist/lang/common/errors/index.d.ts +0 -3
  63. package/dist/lang/common/errors/index.d.ts.map +0 -1
  64. package/dist/lang/common/index.d.ts +0 -2
  65. package/dist/lang/common/index.d.ts.map +0 -1
  66. package/dist/lang/index.d.ts +0 -3
  67. package/dist/lang/index.d.ts.map +0 -1
  68. package/dist/lang/validator/en_EN/index.d.ts +0 -5
  69. package/dist/lang/validator/en_EN/index.d.ts.map +0 -1
  70. package/dist/lang/validator/es_MX/index.d.ts +0 -41
  71. package/dist/lang/validator/es_MX/index.d.ts.map +0 -1
  72. package/dist/lang/validator/index.d.ts +0 -3
  73. package/dist/lang/validator/index.d.ts.map +0 -1
  74. package/dist/mp-front-cli-all.es.js +0 -19
  75. package/dist/mp-front-cli-cache.es.js +0 -6858
  76. package/dist/mp-front-cli-core.es.js +0 -1780
  77. package/dist/mp-front-cli-encoder.es.js +0 -5
  78. package/dist/mp-front-cli-encrypter.es.js +0 -7
  79. package/dist/mp-front-cli-header.es.js +0 -9
  80. package/dist/mp-front-cli-locale.es.js +0 -50
  81. package/dist/mp-front-cli-logger.es.js +0 -55
  82. package/dist/mp-front-cli-utils-rxjs.es.js +0 -46
@@ -1,1780 +0,0 @@
1
- var ve = Object.defineProperty;
2
- var we = (i, e, t) => e in i ? ve(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var $ = (i, e, t) => (we(i, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { C as Re, f as pe } from "./custom-header-17ded9ec.js";
5
- import { S as ht } from "./custom-header-17ded9ec.js";
6
- import { MessageHandler as ne, LoadingHandler as M } from "./mp-front-cli-utils-rxjs.es.js";
7
- import { RxSubjectManager as dt } from "./mp-front-cli-utils-rxjs.es.js";
8
- import { t as Ne } from "./index-df4e0539.js";
9
- import { CustomLogger as Pe } from "./mp-front-cli-logger.es.js";
10
- import { of as w, switchMap as N, forkJoin as ie, catchError as me, EMPTY as ye, filter as be } from "rxjs";
11
- import { C as $e, c as re } from "./custom-encrypter-8d9d2783.js";
12
- import { C as Ce } from "./custom-encoder-70a77460.js";
13
- import "crypto";
14
- const Ee = {
15
- type: "logger",
16
- log(i) {
17
- this.output("log", i);
18
- },
19
- warn(i) {
20
- this.output("warn", i);
21
- },
22
- error(i) {
23
- this.output("error", i);
24
- },
25
- output(i, e) {
26
- console && console[i] && console[i].apply(console, e);
27
- }
28
- };
29
- class z {
30
- constructor(e) {
31
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
32
- this.init(e, t);
33
- }
34
- init(e) {
35
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
36
- this.prefix = t.prefix || "i18next:", this.logger = e || Ee, this.options = t, this.debug = t.debug;
37
- }
38
- log() {
39
- for (var e = arguments.length, t = new Array(e), s = 0; s < e; s++)
40
- t[s] = arguments[s];
41
- return this.forward(t, "log", "", !0);
42
- }
43
- warn() {
44
- for (var e = arguments.length, t = new Array(e), s = 0; s < e; s++)
45
- t[s] = arguments[s];
46
- return this.forward(t, "warn", "", !0);
47
- }
48
- error() {
49
- for (var e = arguments.length, t = new Array(e), s = 0; s < e; s++)
50
- t[s] = arguments[s];
51
- return this.forward(t, "error", "");
52
- }
53
- deprecate() {
54
- for (var e = arguments.length, t = new Array(e), s = 0; s < e; s++)
55
- t[s] = arguments[s];
56
- return this.forward(t, "warn", "WARNING DEPRECATED: ", !0);
57
- }
58
- forward(e, t, s, n) {
59
- return n && !this.debug ? null : (typeof e[0] == "string" && (e[0] = `${s}${this.prefix} ${e[0]}`), this.logger[t](e));
60
- }
61
- create(e) {
62
- return new z(this.logger, {
63
- prefix: `${this.prefix}:${e}:`,
64
- ...this.options
65
- });
66
- }
67
- clone(e) {
68
- return e = e || this.options, e.prefix = e.prefix || this.prefix, new z(this.logger, e);
69
- }
70
- }
71
- var P = new z();
72
- class Q {
73
- constructor() {
74
- this.observers = {};
75
- }
76
- on(e, t) {
77
- return e.split(" ").forEach((s) => {
78
- this.observers[s] = this.observers[s] || [], this.observers[s].push(t);
79
- }), this;
80
- }
81
- off(e, t) {
82
- if (this.observers[e]) {
83
- if (!t) {
84
- delete this.observers[e];
85
- return;
86
- }
87
- this.observers[e] = this.observers[e].filter((s) => s !== t);
88
- }
89
- }
90
- emit(e) {
91
- for (var t = arguments.length, s = new Array(t > 1 ? t - 1 : 0), n = 1; n < t; n++)
92
- s[n - 1] = arguments[n];
93
- this.observers[e] && [].concat(this.observers[e]).forEach((a) => {
94
- a(...s);
95
- }), this.observers["*"] && [].concat(this.observers["*"]).forEach((a) => {
96
- a.apply(a, [e, ...s]);
97
- });
98
- }
99
- }
100
- function U() {
101
- let i, e;
102
- const t = new Promise((s, n) => {
103
- i = s, e = n;
104
- });
105
- return t.resolve = i, t.reject = e, t;
106
- }
107
- function ae(i) {
108
- return i == null ? "" : "" + i;
109
- }
110
- function je(i, e, t) {
111
- i.forEach((s) => {
112
- e[s] && (t[s] = e[s]);
113
- });
114
- }
115
- function q(i, e, t) {
116
- function s(a) {
117
- return a && a.indexOf("###") > -1 ? a.replace(/###/g, ".") : a;
118
- }
119
- function n() {
120
- return !i || typeof i == "string";
121
- }
122
- const r = typeof e != "string" ? [].concat(e) : e.split(".");
123
- for (; r.length > 1; ) {
124
- if (n())
125
- return {};
126
- const a = s(r.shift());
127
- !i[a] && t && (i[a] = new t()), Object.prototype.hasOwnProperty.call(i, a) ? i = i[a] : i = {};
128
- }
129
- return n() ? {} : {
130
- obj: i,
131
- k: s(r.shift())
132
- };
133
- }
134
- function oe(i, e, t) {
135
- const {
136
- obj: s,
137
- k: n
138
- } = q(i, e, Object);
139
- s[n] = t;
140
- }
141
- function ke(i, e, t, s) {
142
- const {
143
- obj: n,
144
- k: r
145
- } = q(i, e, Object);
146
- n[r] = n[r] || [], s && (n[r] = n[r].concat(t)), s || n[r].push(t);
147
- }
148
- function W(i, e) {
149
- const {
150
- obj: t,
151
- k: s
152
- } = q(i, e);
153
- if (t)
154
- return t[s];
155
- }
156
- function Fe(i, e, t) {
157
- const s = W(i, t);
158
- return s !== void 0 ? s : W(e, t);
159
- }
160
- function xe(i, e, t) {
161
- for (const s in e)
162
- s !== "__proto__" && s !== "constructor" && (s in i ? typeof i[s] == "string" || i[s] instanceof String || typeof e[s] == "string" || e[s] instanceof String ? t && (i[s] = e[s]) : xe(i[s], e[s], t) : i[s] = e[s]);
163
- return i;
164
- }
165
- function j(i) {
166
- return i.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
167
- }
168
- var Ae = {
169
- "&": "&amp;",
170
- "<": "&lt;",
171
- ">": "&gt;",
172
- '"': "&quot;",
173
- "'": "&#39;",
174
- "/": "&#x2F;"
175
- };
176
- function De(i) {
177
- return typeof i == "string" ? i.replace(/[&<>"'\/]/g, (e) => Ae[e]) : i;
178
- }
179
- const Ie = [" ", ",", "?", "!", ";"];
180
- function Ue(i, e, t) {
181
- e = e || "", t = t || "";
182
- const s = Ie.filter((a) => e.indexOf(a) < 0 && t.indexOf(a) < 0);
183
- if (s.length === 0)
184
- return !0;
185
- const n = new RegExp(`(${s.map((a) => a === "?" ? "\\?" : a).join("|")})`);
186
- let r = !n.test(i);
187
- if (!r) {
188
- const a = i.indexOf(t);
189
- a > 0 && !n.test(i.substring(0, a)) && (r = !0);
190
- }
191
- return r;
192
- }
193
- function Y(i, e) {
194
- let t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : ".";
195
- if (!i)
196
- return;
197
- if (i[e])
198
- return i[e];
199
- const s = e.split(t);
200
- let n = i;
201
- for (let r = 0; r < s.length; ++r) {
202
- if (!n || typeof n[s[r]] == "string" && r + 1 < s.length)
203
- return;
204
- if (n[s[r]] === void 0) {
205
- let a = 2, l = s.slice(r, r + a).join(t), o = n[l];
206
- for (; o === void 0 && s.length > r + a; )
207
- a++, l = s.slice(r, r + a).join(t), o = n[l];
208
- if (o === void 0)
209
- return;
210
- if (o === null)
211
- return null;
212
- if (e.endsWith(l)) {
213
- if (typeof o == "string")
214
- return o;
215
- if (l && typeof o[l] == "string")
216
- return o[l];
217
- }
218
- const f = s.slice(r + a).join(t);
219
- return f ? Y(o, f, t) : void 0;
220
- }
221
- n = n[s[r]];
222
- }
223
- return n;
224
- }
225
- function G(i) {
226
- return i && i.indexOf("_") > 0 ? i.replace("_", "-") : i;
227
- }
228
- class le extends Q {
229
- constructor(e) {
230
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
231
- ns: ["translation"],
232
- defaultNS: "translation"
233
- };
234
- super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
235
- }
236
- addNamespaces(e) {
237
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
238
- }
239
- removeNamespaces(e) {
240
- const t = this.options.ns.indexOf(e);
241
- t > -1 && this.options.ns.splice(t, 1);
242
- }
243
- getResource(e, t, s) {
244
- let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
245
- const r = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator, a = n.ignoreJSONStructure !== void 0 ? n.ignoreJSONStructure : this.options.ignoreJSONStructure;
246
- let l = [e, t];
247
- s && typeof s != "string" && (l = l.concat(s)), s && typeof s == "string" && (l = l.concat(r ? s.split(r) : s)), e.indexOf(".") > -1 && (l = e.split("."));
248
- const o = W(this.data, l);
249
- return o || !a || typeof s != "string" ? o : Y(this.data && this.data[e] && this.data[e][t], s, r);
250
- }
251
- addResource(e, t, s, n) {
252
- let r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
253
- silent: !1
254
- };
255
- const a = r.keySeparator !== void 0 ? r.keySeparator : this.options.keySeparator;
256
- let l = [e, t];
257
- s && (l = l.concat(a ? s.split(a) : s)), e.indexOf(".") > -1 && (l = e.split("."), n = t, t = l[1]), this.addNamespaces(t), oe(this.data, l, n), r.silent || this.emit("added", e, t, s, n);
258
- }
259
- addResources(e, t, s) {
260
- let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {
261
- silent: !1
262
- };
263
- for (const r in s)
264
- (typeof s[r] == "string" || Object.prototype.toString.apply(s[r]) === "[object Array]") && this.addResource(e, t, r, s[r], {
265
- silent: !0
266
- });
267
- n.silent || this.emit("added", e, t, s);
268
- }
269
- addResourceBundle(e, t, s, n, r) {
270
- let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {
271
- silent: !1
272
- }, l = [e, t];
273
- e.indexOf(".") > -1 && (l = e.split("."), n = s, s = t, t = l[1]), this.addNamespaces(t);
274
- let o = W(this.data, l) || {};
275
- n ? xe(o, s, r) : o = {
276
- ...o,
277
- ...s
278
- }, oe(this.data, l, o), a.silent || this.emit("added", e, t, s);
279
- }
280
- removeResourceBundle(e, t) {
281
- this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
282
- }
283
- hasResourceBundle(e, t) {
284
- return this.getResource(e, t) !== void 0;
285
- }
286
- getResourceBundle(e, t) {
287
- return t || (t = this.options.defaultNS), this.options.compatibilityAPI === "v1" ? {
288
- ...this.getResource(e, t)
289
- } : this.getResource(e, t);
290
- }
291
- getDataByLanguage(e) {
292
- return this.data[e];
293
- }
294
- hasLanguageSomeTranslations(e) {
295
- const t = this.getDataByLanguage(e);
296
- return !!(t && Object.keys(t) || []).find((n) => t[n] && Object.keys(t[n]).length > 0);
297
- }
298
- toJSON() {
299
- return this.data;
300
- }
301
- }
302
- var Se = {
303
- processors: {},
304
- addPostProcessor(i) {
305
- this.processors[i.name] = i;
306
- },
307
- handle(i, e, t, s, n) {
308
- return i.forEach((r) => {
309
- this.processors[r] && (e = this.processors[r].process(e, t, s, n));
310
- }), e;
311
- }
312
- };
313
- const ue = {};
314
- class Z extends Q {
315
- constructor(e) {
316
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
317
- super(), je(["resourceStore", "languageUtils", "pluralResolver", "interpolator", "backendConnector", "i18nFormat", "utils"], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = P.create("translator");
318
- }
319
- changeLanguage(e) {
320
- e && (this.language = e);
321
- }
322
- exists(e) {
323
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
324
- interpolation: {}
325
- };
326
- if (e == null)
327
- return !1;
328
- const s = this.resolve(e, t);
329
- return s && s.res !== void 0;
330
- }
331
- extractFromKey(e, t) {
332
- let s = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
333
- s === void 0 && (s = ":");
334
- const n = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
335
- let r = t.ns || this.options.defaultNS || [];
336
- const a = s && e.indexOf(s) > -1, l = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !Ue(e, s, n);
337
- if (a && !l) {
338
- const o = e.match(this.interpolator.nestingRegexp);
339
- if (o && o.length > 0)
340
- return {
341
- key: e,
342
- namespaces: r
343
- };
344
- const f = e.split(s);
345
- (s !== n || s === n && this.options.ns.indexOf(f[0]) > -1) && (r = f.shift()), e = f.join(n);
346
- }
347
- return typeof r == "string" && (r = [r]), {
348
- key: e,
349
- namespaces: r
350
- };
351
- }
352
- translate(e, t, s) {
353
- if (typeof t != "object" && this.options.overloadTranslationOptionHandler && (t = this.options.overloadTranslationOptionHandler(arguments)), typeof t == "object" && (t = {
354
- ...t
355
- }), t || (t = {}), e == null)
356
- return "";
357
- Array.isArray(e) || (e = [String(e)]);
358
- const n = t.returnDetails !== void 0 ? t.returnDetails : this.options.returnDetails, r = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator, {
359
- key: a,
360
- namespaces: l
361
- } = this.extractFromKey(e[e.length - 1], t), o = l[l.length - 1], f = t.lng || this.language, g = t.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
362
- if (f && f.toLowerCase() === "cimode") {
363
- if (g) {
364
- const y = t.nsSeparator || this.options.nsSeparator;
365
- return n ? {
366
- res: `${o}${y}${a}`,
367
- usedKey: a,
368
- exactUsedKey: a,
369
- usedLng: f,
370
- usedNS: o,
371
- usedParams: this.getUsedParamsDetails(t)
372
- } : `${o}${y}${a}`;
373
- }
374
- return n ? {
375
- res: a,
376
- usedKey: a,
377
- exactUsedKey: a,
378
- usedLng: f,
379
- usedNS: o,
380
- usedParams: this.getUsedParamsDetails(t)
381
- } : a;
382
- }
383
- const h = this.resolve(e, t);
384
- let u = h && h.res;
385
- const d = h && h.usedKey || a, c = h && h.exactUsedKey || a, p = Object.prototype.toString.apply(u), m = ["[object Number]", "[object Function]", "[object RegExp]"], L = t.joinArrays !== void 0 ? t.joinArrays : this.options.joinArrays, x = !this.i18nFormat || this.i18nFormat.handleAsObject;
386
- if (x && u && (typeof u != "string" && typeof u != "boolean" && typeof u != "number") && m.indexOf(p) < 0 && !(typeof L == "string" && p === "[object Array]")) {
387
- if (!t.returnObjects && !this.options.returnObjects) {
388
- this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
389
- const y = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(d, u, {
390
- ...t,
391
- ns: l
392
- }) : `key '${a} (${this.language})' returned an object instead of string.`;
393
- return n ? (h.res = y, h.usedParams = this.getUsedParamsDetails(t), h) : y;
394
- }
395
- if (r) {
396
- const y = p === "[object Array]", O = y ? [] : {}, R = y ? c : d;
397
- for (const S in u)
398
- if (Object.prototype.hasOwnProperty.call(u, S)) {
399
- const K = `${R}${r}${S}`;
400
- O[S] = this.translate(K, {
401
- ...t,
402
- joinArrays: !1,
403
- ns: l
404
- }), O[S] === K && (O[S] = u[S]);
405
- }
406
- u = O;
407
- }
408
- } else if (x && typeof L == "string" && p === "[object Array]")
409
- u = u.join(L), u && (u = this.extendTranslation(u, e, t, s));
410
- else {
411
- let y = !1, O = !1;
412
- const R = t.count !== void 0 && typeof t.count != "string", S = Z.hasDefaultValue(t), K = R ? this.pluralResolver.getSuffix(f, t.count, t) : "", Le = t.ordinal && R ? this.pluralResolver.getSuffix(f, t.count, {
413
- ordinal: !1
414
- }) : "", ee = R && !t.ordinal && t.count === 0 && this.pluralResolver.shouldUseIntlApi(), F = ee && t[`defaultValue${this.options.pluralSeparator}zero`] || t[`defaultValue${K}`] || t[`defaultValue${Le}`] || t.defaultValue;
415
- !this.isValidLookup(u) && S && (y = !0, u = F), this.isValidLookup(u) || (O = !0, u = a);
416
- const Oe = (t.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && O ? void 0 : u, A = S && F !== u && this.options.updateMissing;
417
- if (O || y || A) {
418
- if (this.logger.log(A ? "updateKey" : "missingKey", f, o, a, A ? F : u), r) {
419
- const v = this.resolve(a, {
420
- ...t,
421
- keySeparator: !1
422
- });
423
- v && v.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.");
424
- }
425
- let D = [];
426
- const B = this.languageUtils.getFallbackCodes(this.options.fallbackLng, t.lng || this.language);
427
- if (this.options.saveMissingTo === "fallback" && B && B[0])
428
- for (let v = 0; v < B.length; v++)
429
- D.push(B[v]);
430
- else
431
- this.options.saveMissingTo === "all" ? D = this.languageUtils.toResolveHierarchy(t.lng || this.language) : D.push(t.lng || this.language);
432
- const te = (v, E, I) => {
433
- const se = S && I !== u ? I : Oe;
434
- this.options.missingKeyHandler ? this.options.missingKeyHandler(v, o, E, se, A, t) : this.backendConnector && this.backendConnector.saveMissing && this.backendConnector.saveMissing(v, o, E, se, A, t), this.emit("missingKey", v, o, E, u);
435
- };
436
- this.options.saveMissing && (this.options.saveMissingPlurals && R ? D.forEach((v) => {
437
- const E = this.pluralResolver.getSuffixes(v, t);
438
- ee && t[`defaultValue${this.options.pluralSeparator}zero`] && E.indexOf(`${this.options.pluralSeparator}zero`) < 0 && E.push(`${this.options.pluralSeparator}zero`), E.forEach((I) => {
439
- te([v], a + I, t[`defaultValue${I}`] || F);
440
- });
441
- }) : te(D, a, F));
442
- }
443
- u = this.extendTranslation(u, e, t, h, s), O && u === a && this.options.appendNamespaceToMissingKey && (u = `${o}:${a}`), (O || y) && this.options.parseMissingKeyHandler && (this.options.compatibilityAPI !== "v1" ? u = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${o}:${a}` : a, y ? u : void 0) : u = this.options.parseMissingKeyHandler(u));
444
- }
445
- return n ? (h.res = u, h.usedParams = this.getUsedParamsDetails(t), h) : u;
446
- }
447
- extendTranslation(e, t, s, n, r) {
448
- var a = this;
449
- if (this.i18nFormat && this.i18nFormat.parse)
450
- e = this.i18nFormat.parse(e, {
451
- ...this.options.interpolation.defaultVariables,
452
- ...s
453
- }, s.lng || this.language || n.usedLng, n.usedNS, n.usedKey, {
454
- resolved: n
455
- });
456
- else if (!s.skipInterpolation) {
457
- s.interpolation && this.interpolator.init({
458
- ...s,
459
- interpolation: {
460
- ...this.options.interpolation,
461
- ...s.interpolation
462
- }
463
- });
464
- const f = typeof e == "string" && (s && s.interpolation && s.interpolation.skipOnVariables !== void 0 ? s.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
465
- let g;
466
- if (f) {
467
- const u = e.match(this.interpolator.nestingRegexp);
468
- g = u && u.length;
469
- }
470
- let h = s.replace && typeof s.replace != "string" ? s.replace : s;
471
- if (this.options.interpolation.defaultVariables && (h = {
472
- ...this.options.interpolation.defaultVariables,
473
- ...h
474
- }), e = this.interpolator.interpolate(e, h, s.lng || this.language, s), f) {
475
- const u = e.match(this.interpolator.nestingRegexp), d = u && u.length;
476
- g < d && (s.nest = !1);
477
- }
478
- !s.lng && this.options.compatibilityAPI !== "v1" && n && n.res && (s.lng = n.usedLng), s.nest !== !1 && (e = this.interpolator.nest(e, function() {
479
- for (var u = arguments.length, d = new Array(u), c = 0; c < u; c++)
480
- d[c] = arguments[c];
481
- return r && r[0] === d[0] && !s.context ? (a.logger.warn(`It seems you are nesting recursively key: ${d[0]} in key: ${t[0]}`), null) : a.translate(...d, t);
482
- }, s)), s.interpolation && this.interpolator.reset();
483
- }
484
- const l = s.postProcess || this.options.postProcess, o = typeof l == "string" ? [l] : l;
485
- return e != null && o && o.length && s.applyPostProcessor !== !1 && (e = Se.handle(o, e, t, this.options && this.options.postProcessPassResolved ? {
486
- i18nResolved: {
487
- ...n,
488
- usedParams: this.getUsedParamsDetails(s)
489
- },
490
- ...s
491
- } : s, this)), e;
492
- }
493
- resolve(e) {
494
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s, n, r, a, l;
495
- return typeof e == "string" && (e = [e]), e.forEach((o) => {
496
- if (this.isValidLookup(s))
497
- return;
498
- const f = this.extractFromKey(o, t), g = f.key;
499
- n = g;
500
- let h = f.namespaces;
501
- this.options.fallbackNS && (h = h.concat(this.options.fallbackNS));
502
- const u = t.count !== void 0 && typeof t.count != "string", d = u && !t.ordinal && t.count === 0 && this.pluralResolver.shouldUseIntlApi(), c = t.context !== void 0 && (typeof t.context == "string" || typeof t.context == "number") && t.context !== "", p = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
503
- h.forEach((m) => {
504
- this.isValidLookup(s) || (l = m, !ue[`${p[0]}-${m}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(l) && (ue[`${p[0]}-${m}`] = !0, this.logger.warn(`key "${n}" for languages "${p.join(", ")}" won't get resolved as namespace "${l}" 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!!!")), p.forEach((L) => {
505
- if (this.isValidLookup(s))
506
- return;
507
- a = L;
508
- const x = [g];
509
- if (this.i18nFormat && this.i18nFormat.addLookupKeys)
510
- this.i18nFormat.addLookupKeys(x, g, L, m, t);
511
- else {
512
- let y;
513
- u && (y = this.pluralResolver.getSuffix(L, t.count, t));
514
- const O = `${this.options.pluralSeparator}zero`, R = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
515
- if (u && (x.push(g + y), t.ordinal && y.indexOf(R) === 0 && x.push(g + y.replace(R, this.options.pluralSeparator)), d && x.push(g + O)), c) {
516
- const S = `${g}${this.options.contextSeparator}${t.context}`;
517
- x.push(S), u && (x.push(S + y), t.ordinal && y.indexOf(R) === 0 && x.push(S + y.replace(R, this.options.pluralSeparator)), d && x.push(S + O));
518
- }
519
- }
520
- let V;
521
- for (; V = x.pop(); )
522
- this.isValidLookup(s) || (r = V, s = this.getResource(L, m, V, t));
523
- }));
524
- });
525
- }), {
526
- res: s,
527
- usedKey: n,
528
- exactUsedKey: r,
529
- usedLng: a,
530
- usedNS: l
531
- };
532
- }
533
- isValidLookup(e) {
534
- return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
535
- }
536
- getResource(e, t, s) {
537
- let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
538
- return this.i18nFormat && this.i18nFormat.getResource ? this.i18nFormat.getResource(e, t, s, n) : this.resourceStore.getResource(e, t, s, n);
539
- }
540
- getUsedParamsDetails() {
541
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
542
- const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], s = e.replace && typeof e.replace != "string";
543
- let n = s ? e.replace : e;
544
- if (s && typeof e.count < "u" && (n.count = e.count), this.options.interpolation.defaultVariables && (n = {
545
- ...this.options.interpolation.defaultVariables,
546
- ...n
547
- }), !s) {
548
- n = {
549
- ...n
550
- };
551
- for (const r of t)
552
- delete n[r];
553
- }
554
- return n;
555
- }
556
- static hasDefaultValue(e) {
557
- const t = "defaultValue";
558
- for (const s in e)
559
- if (Object.prototype.hasOwnProperty.call(e, s) && t === s.substring(0, t.length) && e[s] !== void 0)
560
- return !0;
561
- return !1;
562
- }
563
- }
564
- function X(i) {
565
- return i.charAt(0).toUpperCase() + i.slice(1);
566
- }
567
- class fe {
568
- constructor(e) {
569
- this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = P.create("languageUtils");
570
- }
571
- getScriptPartFromCode(e) {
572
- if (e = G(e), !e || e.indexOf("-") < 0)
573
- return null;
574
- const t = e.split("-");
575
- return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
576
- }
577
- getLanguagePartFromCode(e) {
578
- if (e = G(e), !e || e.indexOf("-") < 0)
579
- return e;
580
- const t = e.split("-");
581
- return this.formatLanguageCode(t[0]);
582
- }
583
- formatLanguageCode(e) {
584
- if (typeof e == "string" && e.indexOf("-") > -1) {
585
- const t = ["hans", "hant", "latn", "cyrl", "cans", "mong", "arab"];
586
- let s = e.split("-");
587
- return this.options.lowerCaseLng ? s = s.map((n) => n.toLowerCase()) : s.length === 2 ? (s[0] = s[0].toLowerCase(), s[1] = s[1].toUpperCase(), t.indexOf(s[1].toLowerCase()) > -1 && (s[1] = X(s[1].toLowerCase()))) : s.length === 3 && (s[0] = s[0].toLowerCase(), s[1].length === 2 && (s[1] = s[1].toUpperCase()), s[0] !== "sgn" && s[2].length === 2 && (s[2] = s[2].toUpperCase()), t.indexOf(s[1].toLowerCase()) > -1 && (s[1] = X(s[1].toLowerCase())), t.indexOf(s[2].toLowerCase()) > -1 && (s[2] = X(s[2].toLowerCase()))), s.join("-");
588
- }
589
- return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
590
- }
591
- isSupportedCode(e) {
592
- return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
593
- }
594
- getBestMatchFromCodes(e) {
595
- if (!e)
596
- return null;
597
- let t;
598
- return e.forEach((s) => {
599
- if (t)
600
- return;
601
- const n = this.formatLanguageCode(s);
602
- (!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n);
603
- }), !t && this.options.supportedLngs && e.forEach((s) => {
604
- if (t)
605
- return;
606
- const n = this.getLanguagePartFromCode(s);
607
- if (this.isSupportedCode(n))
608
- return t = n;
609
- t = this.options.supportedLngs.find((r) => {
610
- if (r === n)
611
- return r;
612
- if (!(r.indexOf("-") < 0 && n.indexOf("-") < 0) && r.indexOf(n) === 0)
613
- return r;
614
- });
615
- }), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
616
- }
617
- getFallbackCodes(e, t) {
618
- if (!e)
619
- return [];
620
- if (typeof e == "function" && (e = e(t)), typeof e == "string" && (e = [e]), Object.prototype.toString.apply(e) === "[object Array]")
621
- return e;
622
- if (!t)
623
- return e.default || [];
624
- let s = e[t];
625
- return s || (s = e[this.getScriptPartFromCode(t)]), s || (s = e[this.formatLanguageCode(t)]), s || (s = e[this.getLanguagePartFromCode(t)]), s || (s = e.default), s || [];
626
- }
627
- toResolveHierarchy(e, t) {
628
- const s = this.getFallbackCodes(t || this.options.fallbackLng || [], e), n = [], r = (a) => {
629
- a && (this.isSupportedCode(a) ? n.push(a) : this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`));
630
- };
631
- return typeof e == "string" && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && r(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && r(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && r(this.getLanguagePartFromCode(e))) : typeof e == "string" && r(this.formatLanguageCode(e)), s.forEach((a) => {
632
- n.indexOf(a) < 0 && r(this.formatLanguageCode(a));
633
- }), n;
634
- }
635
- }
636
- let Te = [{
637
- lngs: ["ach", "ak", "am", "arn", "br", "fil", "gun", "ln", "mfe", "mg", "mi", "oc", "pt", "pt-BR", "tg", "tl", "ti", "tr", "uz", "wa"],
638
- nr: [1, 2],
639
- fc: 1
640
- }, {
641
- 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"],
642
- nr: [1, 2],
643
- fc: 2
644
- }, {
645
- lngs: ["ay", "bo", "cgg", "fa", "ht", "id", "ja", "jbo", "ka", "km", "ko", "ky", "lo", "ms", "sah", "su", "th", "tt", "ug", "vi", "wo", "zh"],
646
- nr: [1],
647
- fc: 3
648
- }, {
649
- lngs: ["be", "bs", "cnr", "dz", "hr", "ru", "sr", "uk"],
650
- nr: [1, 2, 5],
651
- fc: 4
652
- }, {
653
- lngs: ["ar"],
654
- nr: [0, 1, 2, 3, 11, 100],
655
- fc: 5
656
- }, {
657
- lngs: ["cs", "sk"],
658
- nr: [1, 2, 5],
659
- fc: 6
660
- }, {
661
- lngs: ["csb", "pl"],
662
- nr: [1, 2, 5],
663
- fc: 7
664
- }, {
665
- lngs: ["cy"],
666
- nr: [1, 2, 3, 8],
667
- fc: 8
668
- }, {
669
- lngs: ["fr"],
670
- nr: [1, 2],
671
- fc: 9
672
- }, {
673
- lngs: ["ga"],
674
- nr: [1, 2, 3, 7, 11],
675
- fc: 10
676
- }, {
677
- lngs: ["gd"],
678
- nr: [1, 2, 3, 20],
679
- fc: 11
680
- }, {
681
- lngs: ["is"],
682
- nr: [1, 2],
683
- fc: 12
684
- }, {
685
- lngs: ["jv"],
686
- nr: [0, 1],
687
- fc: 13
688
- }, {
689
- lngs: ["kw"],
690
- nr: [1, 2, 3, 4],
691
- fc: 14
692
- }, {
693
- lngs: ["lt"],
694
- nr: [1, 2, 10],
695
- fc: 15
696
- }, {
697
- lngs: ["lv"],
698
- nr: [1, 2, 0],
699
- fc: 16
700
- }, {
701
- lngs: ["mk"],
702
- nr: [1, 2],
703
- fc: 17
704
- }, {
705
- lngs: ["mnk"],
706
- nr: [0, 1, 2],
707
- fc: 18
708
- }, {
709
- lngs: ["mt"],
710
- nr: [1, 2, 11, 20],
711
- fc: 19
712
- }, {
713
- lngs: ["or"],
714
- nr: [2, 1],
715
- fc: 2
716
- }, {
717
- lngs: ["ro"],
718
- nr: [1, 2, 20],
719
- fc: 20
720
- }, {
721
- lngs: ["sl"],
722
- nr: [5, 1, 2, 3],
723
- fc: 21
724
- }, {
725
- lngs: ["he", "iw"],
726
- nr: [1, 2, 20, 21],
727
- fc: 22
728
- }], Ve = {
729
- 1: function(i) {
730
- return +(i > 1);
731
- },
732
- 2: function(i) {
733
- return +(i != 1);
734
- },
735
- 3: function(i) {
736
- return 0;
737
- },
738
- 4: function(i) {
739
- return i % 10 == 1 && i % 100 != 11 ? 0 : i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 10 || i % 100 >= 20) ? 1 : 2;
740
- },
741
- 5: function(i) {
742
- return i == 0 ? 0 : i == 1 ? 1 : i == 2 ? 2 : i % 100 >= 3 && i % 100 <= 10 ? 3 : i % 100 >= 11 ? 4 : 5;
743
- },
744
- 6: function(i) {
745
- return i == 1 ? 0 : i >= 2 && i <= 4 ? 1 : 2;
746
- },
747
- 7: function(i) {
748
- return i == 1 ? 0 : i % 10 >= 2 && i % 10 <= 4 && (i % 100 < 10 || i % 100 >= 20) ? 1 : 2;
749
- },
750
- 8: function(i) {
751
- return i == 1 ? 0 : i == 2 ? 1 : i != 8 && i != 11 ? 2 : 3;
752
- },
753
- 9: function(i) {
754
- return +(i >= 2);
755
- },
756
- 10: function(i) {
757
- return i == 1 ? 0 : i == 2 ? 1 : i < 7 ? 2 : i < 11 ? 3 : 4;
758
- },
759
- 11: function(i) {
760
- return i == 1 || i == 11 ? 0 : i == 2 || i == 12 ? 1 : i > 2 && i < 20 ? 2 : 3;
761
- },
762
- 12: function(i) {
763
- return +(i % 10 != 1 || i % 100 == 11);
764
- },
765
- 13: function(i) {
766
- return +(i !== 0);
767
- },
768
- 14: function(i) {
769
- return i == 1 ? 0 : i == 2 ? 1 : i == 3 ? 2 : 3;
770
- },
771
- 15: function(i) {
772
- return i % 10 == 1 && i % 100 != 11 ? 0 : i % 10 >= 2 && (i % 100 < 10 || i % 100 >= 20) ? 1 : 2;
773
- },
774
- 16: function(i) {
775
- return i % 10 == 1 && i % 100 != 11 ? 0 : i !== 0 ? 1 : 2;
776
- },
777
- 17: function(i) {
778
- return i == 1 || i % 10 == 1 && i % 100 != 11 ? 0 : 1;
779
- },
780
- 18: function(i) {
781
- return i == 0 ? 0 : i == 1 ? 1 : 2;
782
- },
783
- 19: function(i) {
784
- return i == 1 ? 0 : i == 0 || i % 100 > 1 && i % 100 < 11 ? 1 : i % 100 > 10 && i % 100 < 20 ? 2 : 3;
785
- },
786
- 20: function(i) {
787
- return i == 1 ? 0 : i == 0 || i % 100 > 0 && i % 100 < 20 ? 1 : 2;
788
- },
789
- 21: function(i) {
790
- return i % 100 == 1 ? 1 : i % 100 == 2 ? 2 : i % 100 == 3 || i % 100 == 4 ? 3 : 0;
791
- },
792
- 22: function(i) {
793
- return i == 1 ? 0 : i == 2 ? 1 : (i < 0 || i > 10) && i % 10 == 0 ? 2 : 3;
794
- }
795
- };
796
- const Ke = ["v1", "v2", "v3"], Be = ["v4"], ge = {
797
- zero: 0,
798
- one: 1,
799
- two: 2,
800
- few: 3,
801
- many: 4,
802
- other: 5
803
- };
804
- function Me() {
805
- const i = {};
806
- return Te.forEach((e) => {
807
- e.lngs.forEach((t) => {
808
- i[t] = {
809
- numbers: e.nr,
810
- plurals: Ve[e.fc]
811
- };
812
- });
813
- }), i;
814
- }
815
- class He {
816
- constructor(e) {
817
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
818
- this.languageUtils = e, this.options = t, this.logger = P.create("pluralResolver"), (!this.options.compatibilityJSON || Be.includes(this.options.compatibilityJSON)) && (typeof Intl > "u" || !Intl.PluralRules) && (this.options.compatibilityJSON = "v3", 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.")), this.rules = Me();
819
- }
820
- addRule(e, t) {
821
- this.rules[e] = t;
822
- }
823
- getRule(e) {
824
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
825
- if (this.shouldUseIntlApi())
826
- try {
827
- return new Intl.PluralRules(G(e === "dev" ? "en" : e), {
828
- type: t.ordinal ? "ordinal" : "cardinal"
829
- });
830
- } catch {
831
- return;
832
- }
833
- return this.rules[e] || this.rules[this.languageUtils.getLanguagePartFromCode(e)];
834
- }
835
- needsPlural(e) {
836
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
837
- const s = this.getRule(e, t);
838
- return this.shouldUseIntlApi() ? s && s.resolvedOptions().pluralCategories.length > 1 : s && s.numbers.length > 1;
839
- }
840
- getPluralFormsOfKey(e, t) {
841
- let s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
842
- return this.getSuffixes(e, s).map((n) => `${t}${n}`);
843
- }
844
- getSuffixes(e) {
845
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
846
- const s = this.getRule(e, t);
847
- return s ? this.shouldUseIntlApi() ? s.resolvedOptions().pluralCategories.sort((n, r) => ge[n] - ge[r]).map((n) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${n}`) : s.numbers.map((n) => this.getSuffix(e, n, t)) : [];
848
- }
849
- getSuffix(e, t) {
850
- let s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
851
- const n = this.getRule(e, s);
852
- return n ? this.shouldUseIntlApi() ? `${this.options.prepend}${s.ordinal ? `ordinal${this.options.prepend}` : ""}${n.select(t)}` : this.getSuffixRetroCompatible(n, t) : (this.logger.warn(`no plural rule found for: ${e}`), "");
853
- }
854
- getSuffixRetroCompatible(e, t) {
855
- const s = e.noAbs ? e.plurals(t) : e.plurals(Math.abs(t));
856
- let n = e.numbers[s];
857
- this.options.simplifyPluralSuffix && e.numbers.length === 2 && e.numbers[0] === 1 && (n === 2 ? n = "plural" : n === 1 && (n = ""));
858
- const r = () => this.options.prepend && n.toString() ? this.options.prepend + n.toString() : n.toString();
859
- return this.options.compatibilityJSON === "v1" ? n === 1 ? "" : typeof n == "number" ? `_plural_${n.toString()}` : r() : this.options.compatibilityJSON === "v2" || this.options.simplifyPluralSuffix && e.numbers.length === 2 && e.numbers[0] === 1 ? r() : this.options.prepend && s.toString() ? this.options.prepend + s.toString() : s.toString();
860
- }
861
- shouldUseIntlApi() {
862
- return !Ke.includes(this.options.compatibilityJSON);
863
- }
864
- }
865
- function he(i, e, t) {
866
- let s = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : ".", n = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : !0, r = Fe(i, e, t);
867
- return !r && n && typeof t == "string" && (r = Y(i, t, s), r === void 0 && (r = Y(e, t, s))), r;
868
- }
869
- class Je {
870
- constructor() {
871
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
872
- this.logger = P.create("interpolator"), this.options = e, this.format = e.interpolation && e.interpolation.format || ((t) => t), this.init(e);
873
- }
874
- init() {
875
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
876
- e.interpolation || (e.interpolation = {
877
- escapeValue: !0
878
- });
879
- const t = e.interpolation;
880
- this.escape = t.escape !== void 0 ? t.escape : De, this.escapeValue = t.escapeValue !== void 0 ? t.escapeValue : !0, this.useRawValueToEscape = t.useRawValueToEscape !== void 0 ? t.useRawValueToEscape : !1, this.prefix = t.prefix ? j(t.prefix) : t.prefixEscaped || "{{", this.suffix = t.suffix ? j(t.suffix) : t.suffixEscaped || "}}", this.formatSeparator = t.formatSeparator ? t.formatSeparator : t.formatSeparator || ",", this.unescapePrefix = t.unescapeSuffix ? "" : t.unescapePrefix || "-", this.unescapeSuffix = this.unescapePrefix ? "" : t.unescapeSuffix || "", this.nestingPrefix = t.nestingPrefix ? j(t.nestingPrefix) : t.nestingPrefixEscaped || j("$t("), this.nestingSuffix = t.nestingSuffix ? j(t.nestingSuffix) : t.nestingSuffixEscaped || j(")"), this.nestingOptionsSeparator = t.nestingOptionsSeparator ? t.nestingOptionsSeparator : t.nestingOptionsSeparator || ",", this.maxReplaces = t.maxReplaces ? t.maxReplaces : 1e3, this.alwaysFormat = t.alwaysFormat !== void 0 ? t.alwaysFormat : !1, this.resetRegExp();
881
- }
882
- reset() {
883
- this.options && this.init(this.options);
884
- }
885
- resetRegExp() {
886
- const e = `${this.prefix}(.+?)${this.suffix}`;
887
- this.regexp = new RegExp(e, "g");
888
- const t = `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`;
889
- this.regexpUnescape = new RegExp(t, "g");
890
- const s = `${this.nestingPrefix}(.+?)${this.nestingSuffix}`;
891
- this.nestingRegexp = new RegExp(s, "g");
892
- }
893
- interpolate(e, t, s, n) {
894
- let r, a, l;
895
- const o = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
896
- function f(c) {
897
- return c.replace(/\$/g, "$$$$");
898
- }
899
- const g = (c) => {
900
- if (c.indexOf(this.formatSeparator) < 0) {
901
- const x = he(t, o, c, this.options.keySeparator, this.options.ignoreJSONStructure);
902
- return this.alwaysFormat ? this.format(x, void 0, s, {
903
- ...n,
904
- ...t,
905
- interpolationkey: c
906
- }) : x;
907
- }
908
- const p = c.split(this.formatSeparator), m = p.shift().trim(), L = p.join(this.formatSeparator).trim();
909
- return this.format(he(t, o, m, this.options.keySeparator, this.options.ignoreJSONStructure), L, s, {
910
- ...n,
911
- ...t,
912
- interpolationkey: m
913
- });
914
- };
915
- this.resetRegExp();
916
- const h = n && n.missingInterpolationHandler || this.options.missingInterpolationHandler, u = n && n.interpolation && n.interpolation.skipOnVariables !== void 0 ? n.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
917
- return [{
918
- regex: this.regexpUnescape,
919
- safeValue: (c) => f(c)
920
- }, {
921
- regex: this.regexp,
922
- safeValue: (c) => this.escapeValue ? f(this.escape(c)) : f(c)
923
- }].forEach((c) => {
924
- for (l = 0; r = c.regex.exec(e); ) {
925
- const p = r[1].trim();
926
- if (a = g(p), a === void 0)
927
- if (typeof h == "function") {
928
- const L = h(e, r, n);
929
- a = typeof L == "string" ? L : "";
930
- } else if (n && Object.prototype.hasOwnProperty.call(n, p))
931
- a = "";
932
- else if (u) {
933
- a = r[0];
934
- continue;
935
- } else
936
- this.logger.warn(`missed to pass in variable ${p} for interpolating ${e}`), a = "";
937
- else
938
- typeof a != "string" && !this.useRawValueToEscape && (a = ae(a));
939
- const m = c.safeValue(a);
940
- if (e = e.replace(r[0], m), u ? (c.regex.lastIndex += a.length, c.regex.lastIndex -= r[0].length) : c.regex.lastIndex = 0, l++, l >= this.maxReplaces)
941
- break;
942
- }
943
- }), e;
944
- }
945
- nest(e, t) {
946
- let s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, n, r, a;
947
- function l(o, f) {
948
- const g = this.nestingOptionsSeparator;
949
- if (o.indexOf(g) < 0)
950
- return o;
951
- const h = o.split(new RegExp(`${g}[ ]*{`));
952
- let u = `{${h[1]}`;
953
- o = h[0], u = this.interpolate(u, a);
954
- const d = u.match(/'/g), c = u.match(/"/g);
955
- (d && d.length % 2 === 0 && !c || c.length % 2 !== 0) && (u = u.replace(/'/g, '"'));
956
- try {
957
- a = JSON.parse(u), f && (a = {
958
- ...f,
959
- ...a
960
- });
961
- } catch (p) {
962
- return this.logger.warn(`failed parsing options string in nesting for key ${o}`, p), `${o}${g}${u}`;
963
- }
964
- return delete a.defaultValue, o;
965
- }
966
- for (; n = this.nestingRegexp.exec(e); ) {
967
- let o = [];
968
- a = {
969
- ...s
970
- }, a = a.replace && typeof a.replace != "string" ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
971
- let f = !1;
972
- if (n[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(n[1])) {
973
- const g = n[1].split(this.formatSeparator).map((h) => h.trim());
974
- n[1] = g.shift(), o = g, f = !0;
975
- }
976
- if (r = t(l.call(this, n[1].trim(), a), a), r && n[0] === e && typeof r != "string")
977
- return r;
978
- typeof r != "string" && (r = ae(r)), r || (this.logger.warn(`missed to resolve ${n[1]} for nesting ${e}`), r = ""), f && (r = o.reduce((g, h) => this.format(g, h, s.lng, {
979
- ...s,
980
- interpolationkey: n[1].trim()
981
- }), r.trim())), e = e.replace(n[0], r), this.regexp.lastIndex = 0;
982
- }
983
- return e;
984
- }
985
- }
986
- function ze(i) {
987
- let e = i.toLowerCase().trim();
988
- const t = {};
989
- if (i.indexOf("(") > -1) {
990
- const s = i.split("(");
991
- e = s[0].toLowerCase().trim();
992
- const n = s[1].substring(0, s[1].length - 1);
993
- e === "currency" && n.indexOf(":") < 0 ? t.currency || (t.currency = n.trim()) : e === "relativetime" && n.indexOf(":") < 0 ? t.range || (t.range = n.trim()) : n.split(";").forEach((a) => {
994
- if (!a)
995
- return;
996
- const [l, ...o] = a.split(":"), f = o.join(":").trim().replace(/^'+|'+$/g, "");
997
- t[l.trim()] || (t[l.trim()] = f), f === "false" && (t[l.trim()] = !1), f === "true" && (t[l.trim()] = !0), isNaN(f) || (t[l.trim()] = parseInt(f, 10));
998
- });
999
- }
1000
- return {
1001
- formatName: e,
1002
- formatOptions: t
1003
- };
1004
- }
1005
- function k(i) {
1006
- const e = {};
1007
- return function(s, n, r) {
1008
- const a = n + JSON.stringify(r);
1009
- let l = e[a];
1010
- return l || (l = i(G(n), r), e[a] = l), l(s);
1011
- };
1012
- }
1013
- class We {
1014
- constructor() {
1015
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1016
- this.logger = P.create("formatter"), this.options = e, this.formats = {
1017
- number: k((t, s) => {
1018
- const n = new Intl.NumberFormat(t, {
1019
- ...s
1020
- });
1021
- return (r) => n.format(r);
1022
- }),
1023
- currency: k((t, s) => {
1024
- const n = new Intl.NumberFormat(t, {
1025
- ...s,
1026
- style: "currency"
1027
- });
1028
- return (r) => n.format(r);
1029
- }),
1030
- datetime: k((t, s) => {
1031
- const n = new Intl.DateTimeFormat(t, {
1032
- ...s
1033
- });
1034
- return (r) => n.format(r);
1035
- }),
1036
- relativetime: k((t, s) => {
1037
- const n = new Intl.RelativeTimeFormat(t, {
1038
- ...s
1039
- });
1040
- return (r) => n.format(r, s.range || "day");
1041
- }),
1042
- list: k((t, s) => {
1043
- const n = new Intl.ListFormat(t, {
1044
- ...s
1045
- });
1046
- return (r) => n.format(r);
1047
- })
1048
- }, this.init(e);
1049
- }
1050
- init(e) {
1051
- const s = (arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
1052
- interpolation: {}
1053
- }).interpolation;
1054
- this.formatSeparator = s.formatSeparator ? s.formatSeparator : s.formatSeparator || ",";
1055
- }
1056
- add(e, t) {
1057
- this.formats[e.toLowerCase().trim()] = t;
1058
- }
1059
- addCached(e, t) {
1060
- this.formats[e.toLowerCase().trim()] = k(t);
1061
- }
1062
- format(e, t, s) {
1063
- let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
1064
- return t.split(this.formatSeparator).reduce((l, o) => {
1065
- const {
1066
- formatName: f,
1067
- formatOptions: g
1068
- } = ze(o);
1069
- if (this.formats[f]) {
1070
- let h = l;
1071
- try {
1072
- const u = n && n.formatParams && n.formatParams[n.interpolationkey] || {}, d = u.locale || u.lng || n.locale || n.lng || s;
1073
- h = this.formats[f](l, d, {
1074
- ...g,
1075
- ...n,
1076
- ...u
1077
- });
1078
- } catch (u) {
1079
- this.logger.warn(u);
1080
- }
1081
- return h;
1082
- } else
1083
- this.logger.warn(`there was no format function for ${f}`);
1084
- return l;
1085
- }, e);
1086
- }
1087
- }
1088
- function Ye(i, e) {
1089
- i.pending[e] !== void 0 && (delete i.pending[e], i.pendingCount--);
1090
- }
1091
- class Ge extends Q {
1092
- constructor(e, t, s) {
1093
- let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {};
1094
- super(), this.backend = e, this.store = t, this.services = s, this.languageUtils = s.languageUtils, this.options = n, this.logger = P.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = n.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = n.maxRetries >= 0 ? n.maxRetries : 5, this.retryTimeout = n.retryTimeout >= 1 ? n.retryTimeout : 350, this.state = {}, this.queue = [], this.backend && this.backend.init && this.backend.init(s, n.backend, n);
1095
- }
1096
- queueLoad(e, t, s, n) {
1097
- const r = {}, a = {}, l = {}, o = {};
1098
- return e.forEach((f) => {
1099
- let g = !0;
1100
- t.forEach((h) => {
1101
- const u = `${f}|${h}`;
1102
- !s.reload && this.store.hasResourceBundle(f, h) ? this.state[u] = 2 : this.state[u] < 0 || (this.state[u] === 1 ? a[u] === void 0 && (a[u] = !0) : (this.state[u] = 1, g = !1, a[u] === void 0 && (a[u] = !0), r[u] === void 0 && (r[u] = !0), o[h] === void 0 && (o[h] = !0)));
1103
- }), g || (l[f] = !0);
1104
- }), (Object.keys(r).length || Object.keys(a).length) && this.queue.push({
1105
- pending: a,
1106
- pendingCount: Object.keys(a).length,
1107
- loaded: {},
1108
- errors: [],
1109
- callback: n
1110
- }), {
1111
- toLoad: Object.keys(r),
1112
- pending: Object.keys(a),
1113
- toLoadLanguages: Object.keys(l),
1114
- toLoadNamespaces: Object.keys(o)
1115
- };
1116
- }
1117
- loaded(e, t, s) {
1118
- const n = e.split("|"), r = n[0], a = n[1];
1119
- t && this.emit("failedLoading", r, a, t), s && this.store.addResourceBundle(r, a, s), this.state[e] = t ? -1 : 2;
1120
- const l = {};
1121
- this.queue.forEach((o) => {
1122
- ke(o.loaded, [r], a), Ye(o, e), t && o.errors.push(t), o.pendingCount === 0 && !o.done && (Object.keys(o.loaded).forEach((f) => {
1123
- l[f] || (l[f] = {});
1124
- const g = o.loaded[f];
1125
- g.length && g.forEach((h) => {
1126
- l[f][h] === void 0 && (l[f][h] = !0);
1127
- });
1128
- }), o.done = !0, o.errors.length ? o.callback(o.errors) : o.callback());
1129
- }), this.emit("loaded", l), this.queue = this.queue.filter((o) => !o.done);
1130
- }
1131
- read(e, t, s) {
1132
- let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 0, r = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : this.retryTimeout, a = arguments.length > 5 ? arguments[5] : void 0;
1133
- if (!e.length)
1134
- return a(null, {});
1135
- if (this.readingCalls >= this.maxParallelReads) {
1136
- this.waitingReads.push({
1137
- lng: e,
1138
- ns: t,
1139
- fcName: s,
1140
- tried: n,
1141
- wait: r,
1142
- callback: a
1143
- });
1144
- return;
1145
- }
1146
- this.readingCalls++;
1147
- const l = (f, g) => {
1148
- if (this.readingCalls--, this.waitingReads.length > 0) {
1149
- const h = this.waitingReads.shift();
1150
- this.read(h.lng, h.ns, h.fcName, h.tried, h.wait, h.callback);
1151
- }
1152
- if (f && g && n < this.maxRetries) {
1153
- setTimeout(() => {
1154
- this.read.call(this, e, t, s, n + 1, r * 2, a);
1155
- }, r);
1156
- return;
1157
- }
1158
- a(f, g);
1159
- }, o = this.backend[s].bind(this.backend);
1160
- if (o.length === 2) {
1161
- try {
1162
- const f = o(e, t);
1163
- f && typeof f.then == "function" ? f.then((g) => l(null, g)).catch(l) : l(null, f);
1164
- } catch (f) {
1165
- l(f);
1166
- }
1167
- return;
1168
- }
1169
- return o(e, t, l);
1170
- }
1171
- prepareLoading(e, t) {
1172
- let s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, n = arguments.length > 3 ? arguments[3] : void 0;
1173
- if (!this.backend)
1174
- return this.logger.warn("No backend was added via i18next.use. Will not load resources."), n && n();
1175
- typeof e == "string" && (e = this.languageUtils.toResolveHierarchy(e)), typeof t == "string" && (t = [t]);
1176
- const r = this.queueLoad(e, t, s, n);
1177
- if (!r.toLoad.length)
1178
- return r.pending.length || n(), null;
1179
- r.toLoad.forEach((a) => {
1180
- this.loadOne(a);
1181
- });
1182
- }
1183
- load(e, t, s) {
1184
- this.prepareLoading(e, t, {}, s);
1185
- }
1186
- reload(e, t, s) {
1187
- this.prepareLoading(e, t, {
1188
- reload: !0
1189
- }, s);
1190
- }
1191
- loadOne(e) {
1192
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
1193
- const s = e.split("|"), n = s[0], r = s[1];
1194
- this.read(n, r, "read", void 0, void 0, (a, l) => {
1195
- a && this.logger.warn(`${t}loading namespace ${r} for language ${n} failed`, a), !a && l && this.logger.log(`${t}loaded namespace ${r} for language ${n}`, l), this.loaded(e, a, l);
1196
- });
1197
- }
1198
- saveMissing(e, t, s, n, r) {
1199
- let a = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {}, l = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : () => {
1200
- };
1201
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(t)) {
1202
- this.logger.warn(`did not save key "${s}" as the namespace "${t}" 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!!!");
1203
- return;
1204
- }
1205
- if (!(s == null || s === "")) {
1206
- if (this.backend && this.backend.create) {
1207
- const o = {
1208
- ...a,
1209
- isUpdate: r
1210
- }, f = this.backend.create.bind(this.backend);
1211
- if (f.length < 6)
1212
- try {
1213
- let g;
1214
- f.length === 5 ? g = f(e, t, s, n, o) : g = f(e, t, s, n), g && typeof g.then == "function" ? g.then((h) => l(null, h)).catch(l) : l(null, g);
1215
- } catch (g) {
1216
- l(g);
1217
- }
1218
- else
1219
- f(e, t, s, n, l, o);
1220
- }
1221
- !e || !e[0] || this.store.addResource(e[0], t, s, n);
1222
- }
1223
- }
1224
- }
1225
- function ce() {
1226
- return {
1227
- debug: !1,
1228
- initImmediate: !0,
1229
- ns: ["translation"],
1230
- defaultNS: ["translation"],
1231
- fallbackLng: ["dev"],
1232
- fallbackNS: !1,
1233
- supportedLngs: !1,
1234
- nonExplicitSupportedLngs: !1,
1235
- load: "all",
1236
- preload: !1,
1237
- simplifyPluralSuffix: !0,
1238
- keySeparator: ".",
1239
- nsSeparator: ":",
1240
- pluralSeparator: "_",
1241
- contextSeparator: "_",
1242
- partialBundledLanguages: !1,
1243
- saveMissing: !1,
1244
- updateMissing: !1,
1245
- saveMissingTo: "fallback",
1246
- saveMissingPlurals: !0,
1247
- missingKeyHandler: !1,
1248
- missingInterpolationHandler: !1,
1249
- postProcess: !1,
1250
- postProcessPassResolved: !1,
1251
- returnNull: !1,
1252
- returnEmptyString: !0,
1253
- returnObjects: !1,
1254
- joinArrays: !1,
1255
- returnedObjectHandler: !1,
1256
- parseMissingKeyHandler: !1,
1257
- appendNamespaceToMissingKey: !1,
1258
- appendNamespaceToCIMode: !1,
1259
- overloadTranslationOptionHandler: function(e) {
1260
- let t = {};
1261
- if (typeof e[1] == "object" && (t = e[1]), typeof e[1] == "string" && (t.defaultValue = e[1]), typeof e[2] == "string" && (t.tDescription = e[2]), typeof e[2] == "object" || typeof e[3] == "object") {
1262
- const s = e[3] || e[2];
1263
- Object.keys(s).forEach((n) => {
1264
- t[n] = s[n];
1265
- });
1266
- }
1267
- return t;
1268
- },
1269
- interpolation: {
1270
- escapeValue: !0,
1271
- format: (i) => i,
1272
- prefix: "{{",
1273
- suffix: "}}",
1274
- formatSeparator: ",",
1275
- unescapePrefix: "-",
1276
- nestingPrefix: "$t(",
1277
- nestingSuffix: ")",
1278
- nestingOptionsSeparator: ",",
1279
- maxReplaces: 1e3,
1280
- skipOnVariables: !0
1281
- }
1282
- };
1283
- }
1284
- function de(i) {
1285
- return typeof i.ns == "string" && (i.ns = [i.ns]), typeof i.fallbackLng == "string" && (i.fallbackLng = [i.fallbackLng]), typeof i.fallbackNS == "string" && (i.fallbackNS = [i.fallbackNS]), i.supportedLngs && i.supportedLngs.indexOf("cimode") < 0 && (i.supportedLngs = i.supportedLngs.concat(["cimode"])), i;
1286
- }
1287
- function H() {
1288
- }
1289
- function Ze(i) {
1290
- Object.getOwnPropertyNames(Object.getPrototypeOf(i)).forEach((t) => {
1291
- typeof i[t] == "function" && (i[t] = i[t].bind(i));
1292
- });
1293
- }
1294
- class T extends Q {
1295
- constructor() {
1296
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
1297
- if (super(), this.options = de(e), this.services = {}, this.logger = P, this.modules = {
1298
- external: []
1299
- }, Ze(this), t && !this.isInitialized && !e.isClone) {
1300
- if (!this.options.initImmediate)
1301
- return this.init(e, t), this;
1302
- setTimeout(() => {
1303
- this.init(e, t);
1304
- }, 0);
1305
- }
1306
- }
1307
- init() {
1308
- var e = this;
1309
- let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, s = arguments.length > 1 ? arguments[1] : void 0;
1310
- typeof t == "function" && (s = t, t = {}), !t.defaultNS && t.defaultNS !== !1 && t.ns && (typeof t.ns == "string" ? t.defaultNS = t.ns : t.ns.indexOf("translation") < 0 && (t.defaultNS = t.ns[0]));
1311
- const n = ce();
1312
- this.options = {
1313
- ...n,
1314
- ...this.options,
1315
- ...de(t)
1316
- }, this.options.compatibilityAPI !== "v1" && (this.options.interpolation = {
1317
- ...n.interpolation,
1318
- ...this.options.interpolation
1319
- }), t.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = t.keySeparator), t.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = t.nsSeparator);
1320
- function r(g) {
1321
- return g ? typeof g == "function" ? new g() : g : null;
1322
- }
1323
- if (!this.options.isClone) {
1324
- this.modules.logger ? P.init(r(this.modules.logger), this.options) : P.init(null, this.options);
1325
- let g;
1326
- this.modules.formatter ? g = this.modules.formatter : typeof Intl < "u" && (g = We);
1327
- const h = new fe(this.options);
1328
- this.store = new le(this.options.resources, this.options);
1329
- const u = this.services;
1330
- u.logger = P, u.resourceStore = this.store, u.languageUtils = h, u.pluralResolver = new He(h, {
1331
- prepend: this.options.pluralSeparator,
1332
- compatibilityJSON: this.options.compatibilityJSON,
1333
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1334
- }), g && (!this.options.interpolation.format || this.options.interpolation.format === n.interpolation.format) && (u.formatter = r(g), u.formatter.init(u, this.options), this.options.interpolation.format = u.formatter.format.bind(u.formatter)), u.interpolator = new Je(this.options), u.utils = {
1335
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1336
- }, u.backendConnector = new Ge(r(this.modules.backend), u.resourceStore, u, this.options), u.backendConnector.on("*", function(d) {
1337
- for (var c = arguments.length, p = new Array(c > 1 ? c - 1 : 0), m = 1; m < c; m++)
1338
- p[m - 1] = arguments[m];
1339
- e.emit(d, ...p);
1340
- }), this.modules.languageDetector && (u.languageDetector = r(this.modules.languageDetector), u.languageDetector.init && u.languageDetector.init(u, this.options.detection, this.options)), this.modules.i18nFormat && (u.i18nFormat = r(this.modules.i18nFormat), u.i18nFormat.init && u.i18nFormat.init(this)), this.translator = new Z(this.services, this.options), this.translator.on("*", function(d) {
1341
- for (var c = arguments.length, p = new Array(c > 1 ? c - 1 : 0), m = 1; m < c; m++)
1342
- p[m - 1] = arguments[m];
1343
- e.emit(d, ...p);
1344
- }), this.modules.external.forEach((d) => {
1345
- d.init && d.init(this);
1346
- });
1347
- }
1348
- if (this.format = this.options.interpolation.format, s || (s = H), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1349
- const g = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1350
- g.length > 0 && g[0] !== "dev" && (this.options.lng = g[0]);
1351
- }
1352
- !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((g) => {
1353
- this[g] = function() {
1354
- return e.store[g](...arguments);
1355
- };
1356
- }), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((g) => {
1357
- this[g] = function() {
1358
- return e.store[g](...arguments), e;
1359
- };
1360
- });
1361
- const o = U(), f = () => {
1362
- const g = (h, u) => {
1363
- this.isInitialized && !this.initializedStoreOnce && this.logger.warn("init: i18next is already initialized. You should call init just once!"), this.isInitialized = !0, this.options.isClone || this.logger.log("initialized", this.options), this.emit("initialized", this.options), o.resolve(u), s(h, u);
1364
- };
1365
- if (this.languages && this.options.compatibilityAPI !== "v1" && !this.isInitialized)
1366
- return g(null, this.t.bind(this));
1367
- this.changeLanguage(this.options.lng, g);
1368
- };
1369
- return this.options.resources || !this.options.initImmediate ? f() : setTimeout(f, 0), o;
1370
- }
1371
- loadResources(e) {
1372
- let s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : H;
1373
- const n = typeof e == "string" ? e : this.language;
1374
- if (typeof e == "function" && (s = e), !this.options.resources || this.options.partialBundledLanguages) {
1375
- if (n && n.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0))
1376
- return s();
1377
- const r = [], a = (l) => {
1378
- if (!l || l === "cimode")
1379
- return;
1380
- this.services.languageUtils.toResolveHierarchy(l).forEach((f) => {
1381
- f !== "cimode" && r.indexOf(f) < 0 && r.push(f);
1382
- });
1383
- };
1384
- n ? a(n) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((o) => a(o)), this.options.preload && this.options.preload.forEach((l) => a(l)), this.services.backendConnector.load(r, this.options.ns, (l) => {
1385
- !l && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), s(l);
1386
- });
1387
- } else
1388
- s(null);
1389
- }
1390
- reloadResources(e, t, s) {
1391
- const n = U();
1392
- return e || (e = this.languages), t || (t = this.options.ns), s || (s = H), this.services.backendConnector.reload(e, t, (r) => {
1393
- n.resolve(), s(r);
1394
- }), n;
1395
- }
1396
- use(e) {
1397
- if (!e)
1398
- throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1399
- if (!e.type)
1400
- throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1401
- return e.type === "backend" && (this.modules.backend = e), (e.type === "logger" || e.log && e.warn && e.error) && (this.modules.logger = e), e.type === "languageDetector" && (this.modules.languageDetector = e), e.type === "i18nFormat" && (this.modules.i18nFormat = e), e.type === "postProcessor" && Se.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1402
- }
1403
- setResolvedLanguage(e) {
1404
- if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1))
1405
- for (let t = 0; t < this.languages.length; t++) {
1406
- const s = this.languages[t];
1407
- if (!(["cimode", "dev"].indexOf(s) > -1) && this.store.hasLanguageSomeTranslations(s)) {
1408
- this.resolvedLanguage = s;
1409
- break;
1410
- }
1411
- }
1412
- }
1413
- changeLanguage(e, t) {
1414
- var s = this;
1415
- this.isLanguageChangingTo = e;
1416
- const n = U();
1417
- this.emit("languageChanging", e);
1418
- const r = (o) => {
1419
- this.language = o, this.languages = this.services.languageUtils.toResolveHierarchy(o), this.resolvedLanguage = void 0, this.setResolvedLanguage(o);
1420
- }, a = (o, f) => {
1421
- f ? (r(f), this.translator.changeLanguage(f), this.isLanguageChangingTo = void 0, this.emit("languageChanged", f), this.logger.log("languageChanged", f)) : this.isLanguageChangingTo = void 0, n.resolve(function() {
1422
- return s.t(...arguments);
1423
- }), t && t(o, function() {
1424
- return s.t(...arguments);
1425
- });
1426
- }, l = (o) => {
1427
- !e && !o && this.services.languageDetector && (o = []);
1428
- const f = typeof o == "string" ? o : this.services.languageUtils.getBestMatchFromCodes(o);
1429
- f && (this.language || r(f), this.translator.language || this.translator.changeLanguage(f), this.services.languageDetector && this.services.languageDetector.cacheUserLanguage && this.services.languageDetector.cacheUserLanguage(f)), this.loadResources(f, (g) => {
1430
- a(g, f);
1431
- });
1432
- };
1433
- return !e && this.services.languageDetector && !this.services.languageDetector.async ? l(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(l) : this.services.languageDetector.detect(l) : l(e), n;
1434
- }
1435
- getFixedT(e, t, s) {
1436
- var n = this;
1437
- const r = function(a, l) {
1438
- let o;
1439
- if (typeof l != "object") {
1440
- for (var f = arguments.length, g = new Array(f > 2 ? f - 2 : 0), h = 2; h < f; h++)
1441
- g[h - 2] = arguments[h];
1442
- o = n.options.overloadTranslationOptionHandler([a, l].concat(g));
1443
- } else
1444
- o = {
1445
- ...l
1446
- };
1447
- o.lng = o.lng || r.lng, o.lngs = o.lngs || r.lngs, o.ns = o.ns || r.ns, o.keyPrefix = o.keyPrefix || s || r.keyPrefix;
1448
- const u = n.options.keySeparator || ".";
1449
- let d;
1450
- return o.keyPrefix && Array.isArray(a) ? d = a.map((c) => `${o.keyPrefix}${u}${c}`) : d = o.keyPrefix ? `${o.keyPrefix}${u}${a}` : a, n.t(d, o);
1451
- };
1452
- return typeof e == "string" ? r.lng = e : r.lngs = e, r.ns = t, r.keyPrefix = s, r;
1453
- }
1454
- t() {
1455
- return this.translator && this.translator.translate(...arguments);
1456
- }
1457
- exists() {
1458
- return this.translator && this.translator.exists(...arguments);
1459
- }
1460
- setDefaultNamespace(e) {
1461
- this.options.defaultNS = e;
1462
- }
1463
- hasLoadedNamespace(e) {
1464
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1465
- if (!this.isInitialized)
1466
- return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
1467
- if (!this.languages || !this.languages.length)
1468
- return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1469
- const s = t.lng || this.resolvedLanguage || this.languages[0], n = this.options ? this.options.fallbackLng : !1, r = this.languages[this.languages.length - 1];
1470
- if (s.toLowerCase() === "cimode")
1471
- return !0;
1472
- const a = (l, o) => {
1473
- const f = this.services.backendConnector.state[`${l}|${o}`];
1474
- return f === -1 || f === 2;
1475
- };
1476
- if (t.precheck) {
1477
- const l = t.precheck(this, a);
1478
- if (l !== void 0)
1479
- return l;
1480
- }
1481
- return !!(this.hasResourceBundle(s, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(s, e) && (!n || a(r, e)));
1482
- }
1483
- loadNamespaces(e, t) {
1484
- const s = U();
1485
- return this.options.ns ? (typeof e == "string" && (e = [e]), e.forEach((n) => {
1486
- this.options.ns.indexOf(n) < 0 && this.options.ns.push(n);
1487
- }), this.loadResources((n) => {
1488
- s.resolve(), t && t(n);
1489
- }), s) : (t && t(), Promise.resolve());
1490
- }
1491
- loadLanguages(e, t) {
1492
- const s = U();
1493
- typeof e == "string" && (e = [e]);
1494
- const n = this.options.preload || [], r = e.filter((a) => n.indexOf(a) < 0);
1495
- return r.length ? (this.options.preload = n.concat(r), this.loadResources((a) => {
1496
- s.resolve(), t && t(a);
1497
- }), s) : (t && t(), Promise.resolve());
1498
- }
1499
- dir(e) {
1500
- if (e || (e = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language)), !e)
1501
- return "rtl";
1502
- const t = ["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"], s = this.services && this.services.languageUtils || new fe(ce());
1503
- return t.indexOf(s.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1504
- }
1505
- static createInstance() {
1506
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 ? arguments[1] : void 0;
1507
- return new T(e, t);
1508
- }
1509
- cloneInstance() {
1510
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : H;
1511
- const s = e.forkResourceStore;
1512
- s && delete e.forkResourceStore;
1513
- const n = {
1514
- ...this.options,
1515
- ...e,
1516
- isClone: !0
1517
- }, r = new T(n);
1518
- return (e.debug !== void 0 || e.prefix !== void 0) && (r.logger = r.logger.clone(e)), ["store", "services", "language"].forEach((l) => {
1519
- r[l] = this[l];
1520
- }), r.services = {
1521
- ...this.services
1522
- }, r.services.utils = {
1523
- hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
1524
- }, s && (r.store = new le(this.store.data, n), r.services.resourceStore = r.store), r.translator = new Z(r.services, n), r.translator.on("*", function(l) {
1525
- for (var o = arguments.length, f = new Array(o > 1 ? o - 1 : 0), g = 1; g < o; g++)
1526
- f[g - 1] = arguments[g];
1527
- r.emit(l, ...f);
1528
- }), r.init(n, t), r.translator.options = n, r.translator.backendConnector.services.utils = {
1529
- hasLoadedNamespace: r.hasLoadedNamespace.bind(r)
1530
- }, r;
1531
- }
1532
- toJSON() {
1533
- return {
1534
- options: this.options,
1535
- store: this.store,
1536
- language: this.language,
1537
- languages: this.languages,
1538
- resolvedLanguage: this.resolvedLanguage
1539
- };
1540
- }
1541
- }
1542
- const b = T.createInstance();
1543
- b.createInstance = T.createInstance;
1544
- b.createInstance;
1545
- b.dir;
1546
- b.init;
1547
- b.loadResources;
1548
- b.reloadResources;
1549
- b.use;
1550
- b.changeLanguage;
1551
- b.getFixedT;
1552
- const J = b.t;
1553
- b.exists;
1554
- b.setDefaultNamespace;
1555
- b.hasLoadedNamespace;
1556
- b.loadNamespaces;
1557
- b.loadLanguages;
1558
- const Qe = {
1559
- es: {
1560
- translation: {
1561
- ...Ne
1562
- }
1563
- }
1564
- };
1565
- b.init({
1566
- resources: Qe,
1567
- lng: "es",
1568
- // language to use, more information here: https://www.i18next.com/overview/configuration-options#languages-namespaces-resources
1569
- // you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage
1570
- // if you're using a language detector, do not define the lng option
1571
- supportedLngs: ["es", "en"],
1572
- interpolation: {
1573
- escapeValue: !1
1574
- // react already safes from xss
1575
- },
1576
- debug: !1
1577
- });
1578
- const C = {
1579
- // EXAMPLE ERROR
1580
- "MP-001": {
1581
- code: 400,
1582
- type: "modal",
1583
- message: "errors.MP-001.message",
1584
- title: "errors.MP-001.title",
1585
- level: "info"
1586
- },
1587
- UNAUTHORIZED: {
1588
- level: "error",
1589
- type: "modal",
1590
- message: "errors.UnAuthorized.message",
1591
- title: "errors.UnAuthorized.title",
1592
- code: 310
1593
- },
1594
- "ERR-GENERAL-01": {
1595
- level: "error",
1596
- type: "modal",
1597
- message: "errors.ERR-GENERAL-01.message",
1598
- title: "errors.ERR-GENERAL-01.title",
1599
- code: 400
1600
- },
1601
- internalError: {
1602
- level: "error",
1603
- type: "modal",
1604
- message: "errors.internalError.message",
1605
- title: "errors.internalError.title",
1606
- code: 500
1607
- },
1608
- default: {
1609
- code: 520,
1610
- type: "modal",
1611
- message: "errors.default.message",
1612
- title: "errors.default.title",
1613
- level: "warning"
1614
- }
1615
- };
1616
- class _ extends Pe {
1617
- get(e = "default", t) {
1618
- var r, a;
1619
- if (e instanceof Error)
1620
- return this.logError(e.message), {
1621
- ...C.internalError,
1622
- title: J(C.internalError.title),
1623
- message: J(C.internalError.message),
1624
- uuid: t
1625
- };
1626
- const s = typeof e == "string" ? e : e.code ?? e.errorType, n = typeof e == "string" ? {} : { ...e };
1627
- return {
1628
- ...C[s] ?? C.default,
1629
- title: J(
1630
- ((r = C[s]) == null ? void 0 : r.title) ?? C.default.title,
1631
- n
1632
- ),
1633
- message: J(
1634
- ((a = C[s]) == null ? void 0 : a.message) ?? C.default.message,
1635
- n
1636
- ),
1637
- uuid: t
1638
- };
1639
- }
1640
- }
1641
- class ot extends $e {
1642
- constructor() {
1643
- super(...arguments);
1644
- $(this, "uuid", "");
1645
- $(this, "session", null);
1646
- }
1647
- setSession(t) {
1648
- this.session = t;
1649
- }
1650
- getSession() {
1651
- return this.session;
1652
- }
1653
- returnData(t, s, n) {
1654
- const r = this.encode(s, n);
1655
- t.status(200).json(r);
1656
- }
1657
- returnError(t, s) {
1658
- return s != null && s.uuid ? t.status(520).json(s) : t.status(520).json(new _().get(s, this.uuid));
1659
- }
1660
- get(t) {
1661
- return this.logDebug("get ApiMiddleware"), (s, n) => {
1662
- var r;
1663
- this.logDebug("return ApiMiddleware"), this.uuid = (r = s == null ? void 0 : s.body) == null ? void 0 : r.uuid, w(s).pipe(
1664
- N(
1665
- (a) => ie({
1666
- params: w(this.decode(a.body)),
1667
- headers: w(a.headers)
1668
- })
1669
- ),
1670
- N(
1671
- ({ params: a, headers: l }) => ie({
1672
- response: t(a, this.uuid, l),
1673
- headers: w(l),
1674
- params: w(a)
1675
- })
1676
- ),
1677
- N(({ params: a, response: l, headers: o }) => (this.logDebug(
1678
- `ApiMiddleware \x1B[37m <URL>: \x1B[33m ${s.url} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(o)} \x1B[37m <UUID> \x1B[33m ${s.body.uuid} \x1B[37m <PARAMS> \x1B[33m ${JSON.stringify(a)} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(l)}`
1679
- ), w(l))),
1680
- me((a) => {
1681
- var l;
1682
- return this.logError(
1683
- `ApiMiddleware <URL>: ${s == null ? void 0 : s.url} <HEADERS>: ${JSON.stringify(s == null ? void 0 : s.headers)} <UUID> ${(l = s == null ? void 0 : s.body) == null ? void 0 : l.uuid} <PARAMS> ${JSON.stringify(s == null ? void 0 : s.body)} <ERROR>: ${JSON.stringify(a)}`
1684
- ), this.returnError(n, a), ye;
1685
- })
1686
- ).subscribe({
1687
- next: (a) => {
1688
- this.logDebug("ApiMiddleware subscribe next", JSON.stringify(a)), this.returnData(n, a, this.uuid);
1689
- }
1690
- });
1691
- };
1692
- }
1693
- }
1694
- class lt extends Re {
1695
- constructor(t, s) {
1696
- super();
1697
- $(this, "apiUrl");
1698
- $(this, "method");
1699
- this.apiUrl = t, this.method = s ?? "POST";
1700
- }
1701
- errorHandler(t, s) {
1702
- if (t != null && t.errors)
1703
- throw new _().get(t.errors[0], s);
1704
- return !(t != null && t.errors);
1705
- }
1706
- fetchData(t = {}, s) {
1707
- return w(t).pipe(
1708
- N(
1709
- (n) => this.getHeaders().pipe(N((r) => w({ params: n, headers: r })))
1710
- ),
1711
- N(
1712
- ({ params: n, headers: r }) => pe(this.apiUrl, {
1713
- method: this.method,
1714
- headers: r,
1715
- body: this.method === "GET" ? null : JSON.stringify(n),
1716
- selector: (a) => a.json()
1717
- }).pipe(
1718
- N((a) => (this.logDebug(
1719
- `FetchServiceBE \x1B[37m <URL>: \x1B[33m ${this.apiUrl} \x1B[37m <UUID>: \x1B[33m ${s} \x1B[37m <HEADERS>: \x1B[33m ${JSON.stringify(
1720
- r
1721
- )} \x1B[37m <BODY>: \x1B[33m ${JSON.stringify(
1722
- n
1723
- )} \x1B[37m <RESPONSE>: \x1B[33m ${JSON.stringify(a)} \x1B[33m`
1724
- ), w(a)))
1725
- )
1726
- ),
1727
- be((n) => this.errorHandler(n, s))
1728
- );
1729
- }
1730
- }
1731
- class ut extends Ce {
1732
- constructor(t, s = "POST", n = {}) {
1733
- super();
1734
- $(this, "apiUrl");
1735
- $(this, "method");
1736
- $(this, "headers");
1737
- $(this, "isLoadingEnabled", !0);
1738
- this.apiUrl = t, this.method = s, this.headers = {
1739
- "Content-Type": "application/json",
1740
- ...n
1741
- };
1742
- }
1743
- setIsLoadingEnabled(t) {
1744
- this.isLoadingEnabled = t;
1745
- }
1746
- errorHandler(t) {
1747
- return t.code && (ne.getInstance().setSubject(t), M.getInstance().setSubject(!1)), !t.code;
1748
- }
1749
- fetchData(t = {}) {
1750
- const s = (/* @__PURE__ */ new Date()).toISOString(), n = re.v5(s, re.v5.URL), r = this.encode({ ...t }, n);
1751
- M.getInstance().setSubject(this.isLoadingEnabled);
1752
- const l = new URLSearchParams(window.location.search).get("flow") || "N/A";
1753
- return pe(this.apiUrl, {
1754
- method: this.method,
1755
- headers: { ...this.headers, flow: l },
1756
- body: r,
1757
- selector: (o) => o.json()
1758
- }).pipe(
1759
- N((o) => w(this.decode(o))),
1760
- N((o) => (this.logDebug(
1761
- `FetchServiceFE <URL>: ${this.apiUrl} <HEADERS>: ${JSON.stringify(this.headers)} <PARAMS> ${JSON.stringify(t)} <BODY> ${r} <RESPONSE>: ${JSON.stringify(o)}`
1762
- ), w(o))),
1763
- be(this.errorHandler),
1764
- N((o) => (M.getInstance().setSubject(!1), w(o))),
1765
- me((o) => (M.getInstance().setSubject(!1), ne.getInstance().setSubject(
1766
- new _().get(o, n)
1767
- ), ye))
1768
- );
1769
- }
1770
- }
1771
- export {
1772
- ot as ApiMiddleware,
1773
- _ as ErrorCatalog,
1774
- lt as FetchServiceBE,
1775
- ut as FetchServiceFE,
1776
- M as LoadingHandler,
1777
- ne as MessageHandler,
1778
- dt as RxSubjectManager,
1779
- ht as ServiceToken
1780
- };