wcz-test 6.26.0 → 6.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/DialogsContext-2Yy6yhzQ.js +6 -0
  2. package/dist/DialogsContext-2Yy6yhzQ.js.map +1 -0
  3. package/dist/{DialogsHooks-Dz4ExWPV.js → DialogsHooks-DzqOb2Zx.js} +47 -46
  4. package/dist/{DialogsHooks-Dz4ExWPV.js.map → DialogsHooks-DzqOb2Zx.js.map} +1 -1
  5. package/dist/{FileHooks-T3wXKu_b.js → FileHooks-C8Akmy_o.js} +21 -22
  6. package/dist/{FileHooks-T3wXKu_b.js.map → FileHooks-C8Akmy_o.js.map} +1 -1
  7. package/dist/RouterListItemButton-B6kAS_RK.js +640 -0
  8. package/dist/RouterListItemButton-B6kAS_RK.js.map +1 -0
  9. package/dist/_commonjsHelpers-DaMA6jEr.js +9 -0
  10. package/dist/_commonjsHelpers-DaMA6jEr.js.map +1 -0
  11. package/dist/components.js +6 -6
  12. package/dist/hooks.js +3 -3
  13. package/dist/index.d.ts +0 -3
  14. package/dist/index.js +599 -969
  15. package/dist/index.js.map +1 -1
  16. package/dist/queries.js +111 -113
  17. package/dist/queries.js.map +1 -1
  18. package/dist/utils-IWcYo8tM.js +106 -0
  19. package/dist/utils-IWcYo8tM.js.map +1 -0
  20. package/dist/utils.js +5 -5
  21. package/package.json +8 -13
  22. package/dist/DialogsContext-8xfQ3X-k.js +0 -285
  23. package/dist/DialogsContext-8xfQ3X-k.js.map +0 -1
  24. package/dist/RouterListItemButton-Dmqima3h.js +0 -661
  25. package/dist/RouterListItemButton-Dmqima3h.js.map +0 -1
  26. package/dist/_commonjsHelpers-ByX85dGu.js +0 -34
  27. package/dist/_commonjsHelpers-ByX85dGu.js.map +0 -1
  28. package/dist/env-BD4Wc07c.js +0 -76
  29. package/dist/env-BD4Wc07c.js.map +0 -1
  30. package/dist/i18next-Bx3TmZAT.js +0 -1337
  31. package/dist/i18next-Bx3TmZAT.js.map +0 -1
  32. package/dist/queryClient--EvGPhnh.js +0 -6
  33. package/dist/queryClient--EvGPhnh.js.map +0 -1
  34. package/dist/server.d.ts +0 -11
  35. package/dist/server.js +0 -98
  36. package/dist/server.js.map +0 -1
  37. package/dist/session-BCQDwl6n.js +0 -8581
  38. package/dist/session-BCQDwl6n.js.map +0 -1
  39. package/dist/utils-A7xW24zq.js +0 -1850
  40. package/dist/utils-A7xW24zq.js.map +0 -1
@@ -1,1337 +0,0 @@
1
- const d = (o) => typeof o == "string", K = () => {
2
- let o, e;
3
- const t = new Promise((i, s) => {
4
- o = i, e = s;
5
- });
6
- return t.resolve = o, t.reject = e, t;
7
- }, se = (o) => o == null ? "" : "" + o, be = (o, e, t) => {
8
- o.forEach((i) => {
9
- e[i] && (t[i] = e[i]);
10
- });
11
- }, Le = /###/g, ie = (o) => o && o.indexOf("###") > -1 ? o.replace(Le, ".") : o, ne = (o) => !o || d(o), A = (o, e, t) => {
12
- const i = d(e) ? e.split(".") : e;
13
- let s = 0;
14
- for (; s < i.length - 1; ) {
15
- if (ne(o)) return {};
16
- const n = ie(i[s]);
17
- !o[n] && t && (o[n] = new t()), Object.prototype.hasOwnProperty.call(o, n) ? o = o[n] : o = {}, ++s;
18
- }
19
- return ne(o) ? {} : {
20
- obj: o,
21
- k: ie(i[s])
22
- };
23
- }, re = (o, e, t) => {
24
- const {
25
- obj: i,
26
- k: s
27
- } = A(o, e, Object);
28
- if (i !== void 0 || e.length === 1) {
29
- i[s] = t;
30
- return;
31
- }
32
- let n = e[e.length - 1], r = e.slice(0, e.length - 1), a = A(o, r, Object);
33
- for (; a.obj === void 0 && r.length; )
34
- n = `${r[r.length - 1]}.${n}`, r = r.slice(0, r.length - 1), a = A(o, r, Object), a?.obj && typeof a.obj[`${a.k}.${n}`] < "u" && (a.obj = void 0);
35
- a.obj[`${a.k}.${n}`] = t;
36
- }, ve = (o, e, t, i) => {
37
- const {
38
- obj: s,
39
- k: n
40
- } = A(o, e, Object);
41
- s[n] = s[n] || [], s[n].push(t);
42
- }, z = (o, e) => {
43
- const {
44
- obj: t,
45
- k: i
46
- } = A(o, e);
47
- if (t && Object.prototype.hasOwnProperty.call(t, i))
48
- return t[i];
49
- }, we = (o, e, t) => {
50
- const i = z(o, t);
51
- return i !== void 0 ? i : z(e, t);
52
- }, me = (o, e, t) => {
53
- for (const i in e)
54
- i !== "__proto__" && i !== "constructor" && (i in o ? d(o[i]) || o[i] instanceof String || d(e[i]) || e[i] instanceof String ? t && (o[i] = e[i]) : me(o[i], e[i], t) : o[i] = e[i]);
55
- return o;
56
- }, I = (o) => o.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
57
- var Ce = {
58
- "&": "&amp;",
59
- "<": "&lt;",
60
- ">": "&gt;",
61
- '"': "&quot;",
62
- "'": "&#39;",
63
- "/": "&#x2F;"
64
- };
65
- const Re = (o) => d(o) ? o.replace(/[&<>"'\/]/g, (e) => Ce[e]) : o;
66
- class Pe {
67
- constructor(e) {
68
- this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
69
- }
70
- getRegExp(e) {
71
- const t = this.regExpMap.get(e);
72
- if (t !== void 0)
73
- return t;
74
- const i = new RegExp(e);
75
- return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, i), this.regExpQueue.push(e), i;
76
- }
77
- }
78
- const $e = [" ", ",", "?", "!", ";"], Ne = new Pe(20), ke = (o, e, t) => {
79
- e = e || "", t = t || "";
80
- const i = $e.filter((r) => e.indexOf(r) < 0 && t.indexOf(r) < 0);
81
- if (i.length === 0) return !0;
82
- const s = Ne.getRegExp(`(${i.map((r) => r === "?" ? "\\?" : r).join("|")})`);
83
- let n = !s.test(o);
84
- if (!n) {
85
- const r = o.indexOf(t);
86
- r > 0 && !s.test(o.substring(0, r)) && (n = !0);
87
- }
88
- return n;
89
- }, G = (o, e, t = ".") => {
90
- if (!o) return;
91
- if (o[e])
92
- return Object.prototype.hasOwnProperty.call(o, e) ? o[e] : void 0;
93
- const i = e.split(t);
94
- let s = o;
95
- for (let n = 0; n < i.length; ) {
96
- if (!s || typeof s != "object")
97
- return;
98
- let r, a = "";
99
- for (let l = n; l < i.length; ++l)
100
- if (l !== n && (a += t), a += i[l], r = s[a], r !== void 0) {
101
- if (["string", "number", "boolean"].indexOf(typeof r) > -1 && l < i.length - 1)
102
- continue;
103
- n += l - n + 1;
104
- break;
105
- }
106
- s = r;
107
- }
108
- return s;
109
- }, H = (o) => o?.replace("_", "-"), Fe = {
110
- type: "logger",
111
- log(o) {
112
- this.output("log", o);
113
- },
114
- warn(o) {
115
- this.output("warn", o);
116
- },
117
- error(o) {
118
- this.output("error", o);
119
- },
120
- output(o, e) {
121
- console?.[o]?.apply?.(console, e);
122
- }
123
- };
124
- class J {
125
- constructor(e, t = {}) {
126
- this.init(e, t);
127
- }
128
- init(e, t = {}) {
129
- this.prefix = t.prefix || "i18next:", this.logger = e || Fe, this.options = t, this.debug = t.debug;
130
- }
131
- log(...e) {
132
- return this.forward(e, "log", "", !0);
133
- }
134
- warn(...e) {
135
- return this.forward(e, "warn", "", !0);
136
- }
137
- error(...e) {
138
- return this.forward(e, "error", "");
139
- }
140
- deprecate(...e) {
141
- return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
142
- }
143
- forward(e, t, i, s) {
144
- return s && !this.debug ? null : (d(e[0]) && (e[0] = `${i}${this.prefix} ${e[0]}`), this.logger[t](e));
145
- }
146
- create(e) {
147
- return new J(this.logger, {
148
- prefix: `${this.prefix}:${e}:`,
149
- ...this.options
150
- });
151
- }
152
- clone(e) {
153
- return e = e || this.options, e.prefix = e.prefix || this.prefix, new J(this.logger, e);
154
- }
155
- }
156
- var P = new J();
157
- class Y {
158
- constructor() {
159
- this.observers = {};
160
- }
161
- on(e, t) {
162
- return e.split(" ").forEach((i) => {
163
- this.observers[i] || (this.observers[i] = /* @__PURE__ */ new Map());
164
- const s = this.observers[i].get(t) || 0;
165
- this.observers[i].set(t, s + 1);
166
- }), this;
167
- }
168
- off(e, t) {
169
- if (this.observers[e]) {
170
- if (!t) {
171
- delete this.observers[e];
172
- return;
173
- }
174
- this.observers[e].delete(t);
175
- }
176
- }
177
- emit(e, ...t) {
178
- this.observers[e] && Array.from(this.observers[e].entries()).forEach(([s, n]) => {
179
- for (let r = 0; r < n; r++)
180
- s(...t);
181
- }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([s, n]) => {
182
- for (let r = 0; r < n; r++)
183
- s.apply(s, [e, ...t]);
184
- });
185
- }
186
- }
187
- class ae extends Y {
188
- constructor(e, t = {
189
- ns: ["translation"],
190
- defaultNS: "translation"
191
- }) {
192
- super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
193
- }
194
- addNamespaces(e) {
195
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
196
- }
197
- removeNamespaces(e) {
198
- const t = this.options.ns.indexOf(e);
199
- t > -1 && this.options.ns.splice(t, 1);
200
- }
201
- getResource(e, t, i, s = {}) {
202
- const n = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, r = s.ignoreJSONStructure !== void 0 ? s.ignoreJSONStructure : this.options.ignoreJSONStructure;
203
- let a;
204
- e.indexOf(".") > -1 ? a = e.split(".") : (a = [e, t], i && (Array.isArray(i) ? a.push(...i) : d(i) && n ? a.push(...i.split(n)) : a.push(i)));
205
- const l = z(this.data, a);
206
- return !l && !t && !i && e.indexOf(".") > -1 && (e = a[0], t = a[1], i = a.slice(2).join(".")), l || !r || !d(i) ? l : G(this.data?.[e]?.[t], i, n);
207
- }
208
- addResource(e, t, i, s, n = {
209
- silent: !1
210
- }) {
211
- const r = n.keySeparator !== void 0 ? n.keySeparator : this.options.keySeparator;
212
- let a = [e, t];
213
- i && (a = a.concat(r ? i.split(r) : i)), e.indexOf(".") > -1 && (a = e.split("."), s = t, t = a[1]), this.addNamespaces(t), re(this.data, a, s), n.silent || this.emit("added", e, t, i, s);
214
- }
215
- addResources(e, t, i, s = {
216
- silent: !1
217
- }) {
218
- for (const n in i)
219
- (d(i[n]) || Array.isArray(i[n])) && this.addResource(e, t, n, i[n], {
220
- silent: !0
221
- });
222
- s.silent || this.emit("added", e, t, i);
223
- }
224
- addResourceBundle(e, t, i, s, n, r = {
225
- silent: !1,
226
- skipCopy: !1
227
- }) {
228
- let a = [e, t];
229
- e.indexOf(".") > -1 && (a = e.split("."), s = i, i = t, t = a[1]), this.addNamespaces(t);
230
- let l = z(this.data, a) || {};
231
- r.skipCopy || (i = JSON.parse(JSON.stringify(i))), s ? me(l, i, n) : l = {
232
- ...l,
233
- ...i
234
- }, re(this.data, a, l), r.silent || this.emit("added", e, t, i);
235
- }
236
- removeResourceBundle(e, t) {
237
- this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
238
- }
239
- hasResourceBundle(e, t) {
240
- return this.getResource(e, t) !== void 0;
241
- }
242
- getResourceBundle(e, t) {
243
- return t || (t = this.options.defaultNS), this.getResource(e, t);
244
- }
245
- getDataByLanguage(e) {
246
- return this.data[e];
247
- }
248
- hasLanguageSomeTranslations(e) {
249
- const t = this.getDataByLanguage(e);
250
- return !!(t && Object.keys(t) || []).find((s) => t[s] && Object.keys(t[s]).length > 0);
251
- }
252
- toJSON() {
253
- return this.data;
254
- }
255
- }
256
- var xe = {
257
- processors: {},
258
- addPostProcessor(o) {
259
- this.processors[o.name] = o;
260
- },
261
- handle(o, e, t, i, s) {
262
- return o.forEach((n) => {
263
- e = this.processors[n]?.process(e, t, i, s) ?? e;
264
- }), e;
265
- }
266
- };
267
- const ye = /* @__PURE__ */ Symbol("i18next/PATH_KEY");
268
- function je() {
269
- const o = [], e = /* @__PURE__ */ Object.create(null);
270
- let t;
271
- return e.get = (i, s) => (t?.revoke?.(), s === ye ? o : (o.push(s), t = Proxy.revocable(i, e), t.proxy)), Proxy.revocable(/* @__PURE__ */ Object.create(null), e).proxy;
272
- }
273
- function Z(o, e) {
274
- const {
275
- [ye]: t
276
- } = o(je());
277
- return t.join(e?.keySeparator ?? ".");
278
- }
279
- const oe = {}, _ = (o) => !d(o) && typeof o != "boolean" && typeof o != "number";
280
- class W extends Y {
281
- constructor(e, t = {}) {
282
- super(), be(["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");
283
- }
284
- changeLanguage(e) {
285
- e && (this.language = e);
286
- }
287
- exists(e, t = {
288
- interpolation: {}
289
- }) {
290
- const i = {
291
- ...t
292
- };
293
- if (e == null) return !1;
294
- const s = this.resolve(e, i);
295
- if (s?.res === void 0) return !1;
296
- const n = _(s.res);
297
- return !(i.returnObjects === !1 && n);
298
- }
299
- extractFromKey(e, t) {
300
- let i = t.nsSeparator !== void 0 ? t.nsSeparator : this.options.nsSeparator;
301
- i === void 0 && (i = ":");
302
- const s = t.keySeparator !== void 0 ? t.keySeparator : this.options.keySeparator;
303
- let n = t.ns || this.options.defaultNS || [];
304
- const r = i && e.indexOf(i) > -1, a = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !ke(e, i, s);
305
- if (r && !a) {
306
- const l = e.match(this.interpolator.nestingRegexp);
307
- if (l && l.length > 0)
308
- return {
309
- key: e,
310
- namespaces: d(n) ? [n] : n
311
- };
312
- const u = e.split(i);
313
- (i !== s || i === s && this.options.ns.indexOf(u[0]) > -1) && (n = u.shift()), e = u.join(s);
314
- }
315
- return {
316
- key: e,
317
- namespaces: d(n) ? [n] : n
318
- };
319
- }
320
- translate(e, t, i) {
321
- let s = typeof t == "object" ? {
322
- ...t
323
- } : t;
324
- if (typeof s != "object" && this.options.overloadTranslationOptionHandler && (s = this.options.overloadTranslationOptionHandler(arguments)), typeof s == "object" && (s = {
325
- ...s
326
- }), s || (s = {}), e == null) return "";
327
- typeof e == "function" && (e = Z(e, {
328
- ...this.options,
329
- ...s
330
- })), Array.isArray(e) || (e = [String(e)]);
331
- const n = s.returnDetails !== void 0 ? s.returnDetails : this.options.returnDetails, r = s.keySeparator !== void 0 ? s.keySeparator : this.options.keySeparator, {
332
- key: a,
333
- namespaces: l
334
- } = this.extractFromKey(e[e.length - 1], s), u = l[l.length - 1];
335
- let h = s.nsSeparator !== void 0 ? s.nsSeparator : this.options.nsSeparator;
336
- h === void 0 && (h = ":");
337
- const f = s.lng || this.language, g = s.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
338
- if (f?.toLowerCase() === "cimode")
339
- return g ? n ? {
340
- res: `${u}${h}${a}`,
341
- usedKey: a,
342
- exactUsedKey: a,
343
- usedLng: f,
344
- usedNS: u,
345
- usedParams: this.getUsedParamsDetails(s)
346
- } : `${u}${h}${a}` : n ? {
347
- res: a,
348
- usedKey: a,
349
- exactUsedKey: a,
350
- usedLng: f,
351
- usedNS: u,
352
- usedParams: this.getUsedParamsDetails(s)
353
- } : a;
354
- const p = this.resolve(e, s);
355
- let c = p?.res;
356
- const m = p?.usedKey || a, y = p?.exactUsedKey || a, L = ["[object Number]", "[object Function]", "[object RegExp]"], x = s.joinArrays !== void 0 ? s.joinArrays : this.options.joinArrays, F = !this.i18nFormat || this.i18nFormat.handleAsObject, b = s.count !== void 0 && !d(s.count), N = W.hasDefaultValue(s), E = b ? this.pluralResolver.getSuffix(f, s.count, s) : "", T = s.ordinal && b ? this.pluralResolver.getSuffix(f, s.count, {
357
- ordinal: !1
358
- }) : "", X = b && !s.ordinal && s.count === 0, k = X && s[`defaultValue${this.options.pluralSeparator}zero`] || s[`defaultValue${E}`] || s[`defaultValue${T}`] || s.defaultValue;
359
- let w = c;
360
- F && !c && N && (w = k);
361
- const Se = _(w), Oe = Object.prototype.toString.apply(w);
362
- if (F && w && Se && L.indexOf(Oe) < 0 && !(d(x) && Array.isArray(w))) {
363
- if (!s.returnObjects && !this.options.returnObjects) {
364
- this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
365
- const C = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(m, w, {
366
- ...s,
367
- ns: l
368
- }) : `key '${a} (${this.language})' returned an object instead of string.`;
369
- return n ? (p.res = C, p.usedParams = this.getUsedParamsDetails(s), p) : C;
370
- }
371
- if (r) {
372
- const C = Array.isArray(w), v = C ? [] : {}, q = C ? y : m;
373
- for (const R in w)
374
- if (Object.prototype.hasOwnProperty.call(w, R)) {
375
- const $ = `${q}${r}${R}`;
376
- N && !c ? v[R] = this.translate($, {
377
- ...s,
378
- defaultValue: _(k) ? k[R] : void 0,
379
- joinArrays: !1,
380
- ns: l
381
- }) : v[R] = this.translate($, {
382
- ...s,
383
- joinArrays: !1,
384
- ns: l
385
- }), v[R] === $ && (v[R] = w[R]);
386
- }
387
- c = v;
388
- }
389
- } else if (F && d(x) && Array.isArray(c))
390
- c = c.join(x), c && (c = this.extendTranslation(c, e, s, i));
391
- else {
392
- let C = !1, v = !1;
393
- !this.isValidLookup(c) && N && (C = !0, c = k), this.isValidLookup(c) || (v = !0, c = a);
394
- const R = (s.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && v ? void 0 : c, $ = N && k !== c && this.options.updateMissing;
395
- if (v || C || $) {
396
- if (this.logger.log($ ? "updateKey" : "missingKey", f, u, a, $ ? k : c), r) {
397
- const O = this.resolve(a, {
398
- ...s,
399
- keySeparator: !1
400
- });
401
- O && O.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.");
402
- }
403
- let D = [];
404
- const M = this.languageUtils.getFallbackCodes(this.options.fallbackLng, s.lng || this.language);
405
- if (this.options.saveMissingTo === "fallback" && M && M[0])
406
- for (let O = 0; O < M.length; O++)
407
- D.push(M[O]);
408
- else this.options.saveMissingTo === "all" ? D = this.languageUtils.toResolveHierarchy(s.lng || this.language) : D.push(s.lng || this.language);
409
- const ee = (O, j, V) => {
410
- const te = N && V !== c ? V : R;
411
- this.options.missingKeyHandler ? this.options.missingKeyHandler(O, u, j, te, $, s) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(O, u, j, te, $, s), this.emit("missingKey", O, u, j, c);
412
- };
413
- this.options.saveMissing && (this.options.saveMissingPlurals && b ? D.forEach((O) => {
414
- const j = this.pluralResolver.getSuffixes(O, s);
415
- X && s[`defaultValue${this.options.pluralSeparator}zero`] && j.indexOf(`${this.options.pluralSeparator}zero`) < 0 && j.push(`${this.options.pluralSeparator}zero`), j.forEach((V) => {
416
- ee([O], a + V, s[`defaultValue${V}`] || k);
417
- });
418
- }) : ee(D, a, k));
419
- }
420
- c = this.extendTranslation(c, e, s, p, i), v && c === a && this.options.appendNamespaceToMissingKey && (c = `${u}${h}${a}`), (v || C) && this.options.parseMissingKeyHandler && (c = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${h}${a}` : a, C ? c : void 0, s));
421
- }
422
- return n ? (p.res = c, p.usedParams = this.getUsedParamsDetails(s), p) : c;
423
- }
424
- extendTranslation(e, t, i, s, n) {
425
- if (this.i18nFormat?.parse)
426
- e = this.i18nFormat.parse(e, {
427
- ...this.options.interpolation.defaultVariables,
428
- ...i
429
- }, i.lng || this.language || s.usedLng, s.usedNS, s.usedKey, {
430
- resolved: s
431
- });
432
- else if (!i.skipInterpolation) {
433
- i.interpolation && this.interpolator.init({
434
- ...i,
435
- interpolation: {
436
- ...this.options.interpolation,
437
- ...i.interpolation
438
- }
439
- });
440
- const l = d(e) && (i?.interpolation?.skipOnVariables !== void 0 ? i.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
441
- let u;
442
- if (l) {
443
- const f = e.match(this.interpolator.nestingRegexp);
444
- u = f && f.length;
445
- }
446
- let h = i.replace && !d(i.replace) ? i.replace : i;
447
- if (this.options.interpolation.defaultVariables && (h = {
448
- ...this.options.interpolation.defaultVariables,
449
- ...h
450
- }), e = this.interpolator.interpolate(e, h, i.lng || this.language || s.usedLng, i), l) {
451
- const f = e.match(this.interpolator.nestingRegexp), g = f && f.length;
452
- u < g && (i.nest = !1);
453
- }
454
- !i.lng && s && s.res && (i.lng = this.language || s.usedLng), i.nest !== !1 && (e = this.interpolator.nest(e, (...f) => n?.[0] === f[0] && !i.context ? (this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${t[0]}`), null) : this.translate(...f, t), i)), i.interpolation && this.interpolator.reset();
455
- }
456
- const r = i.postProcess || this.options.postProcess, a = d(r) ? [r] : r;
457
- return e != null && a?.length && i.applyPostProcessor !== !1 && (e = xe.handle(a, e, t, this.options && this.options.postProcessPassResolved ? {
458
- i18nResolved: {
459
- ...s,
460
- usedParams: this.getUsedParamsDetails(i)
461
- },
462
- ...i
463
- } : i, this)), e;
464
- }
465
- resolve(e, t = {}) {
466
- let i, s, n, r, a;
467
- return d(e) && (e = [e]), e.forEach((l) => {
468
- if (this.isValidLookup(i)) return;
469
- const u = this.extractFromKey(l, t), h = u.key;
470
- s = h;
471
- let f = u.namespaces;
472
- this.options.fallbackNS && (f = f.concat(this.options.fallbackNS));
473
- const g = t.count !== void 0 && !d(t.count), p = g && !t.ordinal && t.count === 0, c = t.context !== void 0 && (d(t.context) || typeof t.context == "number") && t.context !== "", m = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
474
- f.forEach((y) => {
475
- this.isValidLookup(i) || (a = y, !oe[`${m[0]}-${y}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(a) && (oe[`${m[0]}-${y}`] = !0, this.logger.warn(`key "${s}" for languages "${m.join(", ")}" won't get resolved as namespace "${a}" 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!!!")), m.forEach((L) => {
476
- if (this.isValidLookup(i)) return;
477
- r = L;
478
- const x = [h];
479
- if (this.i18nFormat?.addLookupKeys)
480
- this.i18nFormat.addLookupKeys(x, h, L, y, t);
481
- else {
482
- let b;
483
- g && (b = this.pluralResolver.getSuffix(L, t.count, t));
484
- const N = `${this.options.pluralSeparator}zero`, E = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
485
- if (g && (t.ordinal && b.indexOf(E) === 0 && x.push(h + b.replace(E, this.options.pluralSeparator)), x.push(h + b), p && x.push(h + N)), c) {
486
- const T = `${h}${this.options.contextSeparator || "_"}${t.context}`;
487
- x.push(T), g && (t.ordinal && b.indexOf(E) === 0 && x.push(T + b.replace(E, this.options.pluralSeparator)), x.push(T + b), p && x.push(T + N));
488
- }
489
- }
490
- let F;
491
- for (; F = x.pop(); )
492
- this.isValidLookup(i) || (n = F, i = this.getResource(L, y, F, t));
493
- }));
494
- });
495
- }), {
496
- res: i,
497
- usedKey: s,
498
- exactUsedKey: n,
499
- usedLng: r,
500
- usedNS: a
501
- };
502
- }
503
- isValidLookup(e) {
504
- return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
505
- }
506
- getResource(e, t, i, s = {}) {
507
- return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, i, s) : this.resourceStore.getResource(e, t, i, s);
508
- }
509
- getUsedParamsDetails(e = {}) {
510
- const t = ["defaultValue", "ordinal", "context", "replace", "lng", "lngs", "fallbackLng", "ns", "keySeparator", "nsSeparator", "returnObjects", "returnDetails", "joinArrays", "postProcess", "interpolation"], i = e.replace && !d(e.replace);
511
- let s = i ? e.replace : e;
512
- if (i && typeof e.count < "u" && (s.count = e.count), this.options.interpolation.defaultVariables && (s = {
513
- ...this.options.interpolation.defaultVariables,
514
- ...s
515
- }), !i) {
516
- s = {
517
- ...s
518
- };
519
- for (const n of t)
520
- delete s[n];
521
- }
522
- return s;
523
- }
524
- static hasDefaultValue(e) {
525
- const t = "defaultValue";
526
- for (const i in e)
527
- if (Object.prototype.hasOwnProperty.call(e, i) && t === i.substring(0, t.length) && e[i] !== void 0)
528
- return !0;
529
- return !1;
530
- }
531
- }
532
- class le {
533
- constructor(e) {
534
- this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = P.create("languageUtils");
535
- }
536
- getScriptPartFromCode(e) {
537
- if (e = H(e), !e || e.indexOf("-") < 0) return null;
538
- const t = e.split("-");
539
- return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
540
- }
541
- getLanguagePartFromCode(e) {
542
- if (e = H(e), !e || e.indexOf("-") < 0) return e;
543
- const t = e.split("-");
544
- return this.formatLanguageCode(t[0]);
545
- }
546
- formatLanguageCode(e) {
547
- if (d(e) && e.indexOf("-") > -1) {
548
- let t;
549
- try {
550
- t = Intl.getCanonicalLocales(e)[0];
551
- } catch {
552
- }
553
- return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
554
- }
555
- return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
556
- }
557
- isSupportedCode(e) {
558
- return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
559
- }
560
- getBestMatchFromCodes(e) {
561
- if (!e) return null;
562
- let t;
563
- return e.forEach((i) => {
564
- if (t) return;
565
- const s = this.formatLanguageCode(i);
566
- (!this.options.supportedLngs || this.isSupportedCode(s)) && (t = s);
567
- }), !t && this.options.supportedLngs && e.forEach((i) => {
568
- if (t) return;
569
- const s = this.getScriptPartFromCode(i);
570
- if (this.isSupportedCode(s)) return t = s;
571
- const n = this.getLanguagePartFromCode(i);
572
- if (this.isSupportedCode(n)) return t = n;
573
- t = this.options.supportedLngs.find((r) => {
574
- if (r === n) return r;
575
- if (!(r.indexOf("-") < 0 && n.indexOf("-") < 0) && (r.indexOf("-") > 0 && n.indexOf("-") < 0 && r.substring(0, r.indexOf("-")) === n || r.indexOf(n) === 0 && n.length > 1))
576
- return r;
577
- });
578
- }), t || (t = this.getFallbackCodes(this.options.fallbackLng)[0]), t;
579
- }
580
- getFallbackCodes(e, t) {
581
- if (!e) return [];
582
- if (typeof e == "function" && (e = e(t)), d(e) && (e = [e]), Array.isArray(e)) return e;
583
- if (!t) return e.default || [];
584
- let i = e[t];
585
- return i || (i = e[this.getScriptPartFromCode(t)]), i || (i = e[this.formatLanguageCode(t)]), i || (i = e[this.getLanguagePartFromCode(t)]), i || (i = e.default), i || [];
586
- }
587
- toResolveHierarchy(e, t) {
588
- const i = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), s = [], n = (r) => {
589
- r && (this.isSupportedCode(r) ? s.push(r) : this.logger.warn(`rejecting language code not found in supportedLngs: ${r}`));
590
- };
591
- return d(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && n(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && n(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && n(this.getLanguagePartFromCode(e))) : d(e) && n(this.formatLanguageCode(e)), i.forEach((r) => {
592
- s.indexOf(r) < 0 && n(this.formatLanguageCode(r));
593
- }), s;
594
- }
595
- }
596
- const ue = {
597
- zero: 0,
598
- one: 1,
599
- two: 2,
600
- few: 3,
601
- many: 4,
602
- other: 5
603
- }, fe = {
604
- select: (o) => o === 1 ? "one" : "other",
605
- resolvedOptions: () => ({
606
- pluralCategories: ["one", "other"]
607
- })
608
- };
609
- class Ee {
610
- constructor(e, t = {}) {
611
- this.languageUtils = e, this.options = t, this.logger = P.create("pluralResolver"), this.pluralRulesCache = {};
612
- }
613
- addRule(e, t) {
614
- this.rules[e] = t;
615
- }
616
- clearCache() {
617
- this.pluralRulesCache = {};
618
- }
619
- getRule(e, t = {}) {
620
- const i = H(e === "dev" ? "en" : e), s = t.ordinal ? "ordinal" : "cardinal", n = JSON.stringify({
621
- cleanedCode: i,
622
- type: s
623
- });
624
- if (n in this.pluralRulesCache)
625
- return this.pluralRulesCache[n];
626
- let r;
627
- try {
628
- r = new Intl.PluralRules(i, {
629
- type: s
630
- });
631
- } catch {
632
- if (!Intl)
633
- return this.logger.error("No Intl support, please use an Intl polyfill!"), fe;
634
- if (!e.match(/-|_/)) return fe;
635
- const l = this.languageUtils.getLanguagePartFromCode(e);
636
- r = this.getRule(l, t);
637
- }
638
- return this.pluralRulesCache[n] = r, r;
639
- }
640
- needsPlural(e, t = {}) {
641
- let i = this.getRule(e, t);
642
- return i || (i = this.getRule("dev", t)), i?.resolvedOptions().pluralCategories.length > 1;
643
- }
644
- getPluralFormsOfKey(e, t, i = {}) {
645
- return this.getSuffixes(e, i).map((s) => `${t}${s}`);
646
- }
647
- getSuffixes(e, t = {}) {
648
- let i = this.getRule(e, t);
649
- return i || (i = this.getRule("dev", t)), i ? i.resolvedOptions().pluralCategories.sort((s, n) => ue[s] - ue[n]).map((s) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${s}`) : [];
650
- }
651
- getSuffix(e, t, i = {}) {
652
- const s = this.getRule(e, i);
653
- return s ? `${this.options.prepend}${i.ordinal ? `ordinal${this.options.prepend}` : ""}${s.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, i));
654
- }
655
- }
656
- const he = (o, e, t, i = ".", s = !0) => {
657
- let n = we(o, e, t);
658
- return !n && s && d(t) && (n = G(o, t, i), n === void 0 && (n = G(e, t, i))), n;
659
- }, Q = (o) => o.replace(/\$/g, "$$$$");
660
- class ce {
661
- constructor(e = {}) {
662
- this.logger = P.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((t) => t), this.init(e);
663
- }
664
- init(e = {}) {
665
- e.interpolation || (e.interpolation = {
666
- escapeValue: !0
667
- });
668
- const {
669
- escape: t,
670
- escapeValue: i,
671
- useRawValueToEscape: s,
672
- prefix: n,
673
- prefixEscaped: r,
674
- suffix: a,
675
- suffixEscaped: l,
676
- formatSeparator: u,
677
- unescapeSuffix: h,
678
- unescapePrefix: f,
679
- nestingPrefix: g,
680
- nestingPrefixEscaped: p,
681
- nestingSuffix: c,
682
- nestingSuffixEscaped: m,
683
- nestingOptionsSeparator: y,
684
- maxReplaces: L,
685
- alwaysFormat: x
686
- } = e.interpolation;
687
- this.escape = t !== void 0 ? t : Re, this.escapeValue = i !== void 0 ? i : !0, this.useRawValueToEscape = s !== void 0 ? s : !1, this.prefix = n ? I(n) : r || "{{", this.suffix = a ? I(a) : l || "}}", this.formatSeparator = u || ",", this.unescapePrefix = h ? "" : f || "-", this.unescapeSuffix = this.unescapePrefix ? "" : h || "", this.nestingPrefix = g ? I(g) : p || I("$t("), this.nestingSuffix = c ? I(c) : m || I(")"), this.nestingOptionsSeparator = y || ",", this.maxReplaces = L || 1e3, this.alwaysFormat = x !== void 0 ? x : !1, this.resetRegExp();
688
- }
689
- reset() {
690
- this.options && this.init(this.options);
691
- }
692
- resetRegExp() {
693
- const e = (t, i) => t?.source === i ? (t.lastIndex = 0, t) : new RegExp(i, "g");
694
- this.regexp = e(this.regexp, `${this.prefix}(.+?)${this.suffix}`), this.regexpUnescape = e(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`), this.nestingRegexp = e(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
695
- }
696
- interpolate(e, t, i, s) {
697
- let n, r, a;
698
- const l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (p) => {
699
- if (p.indexOf(this.formatSeparator) < 0) {
700
- const L = he(t, l, p, this.options.keySeparator, this.options.ignoreJSONStructure);
701
- return this.alwaysFormat ? this.format(L, void 0, i, {
702
- ...s,
703
- ...t,
704
- interpolationkey: p
705
- }) : L;
706
- }
707
- const c = p.split(this.formatSeparator), m = c.shift().trim(), y = c.join(this.formatSeparator).trim();
708
- return this.format(he(t, l, m, this.options.keySeparator, this.options.ignoreJSONStructure), y, i, {
709
- ...s,
710
- ...t,
711
- interpolationkey: m
712
- });
713
- };
714
- this.resetRegExp();
715
- const h = s?.missingInterpolationHandler || this.options.missingInterpolationHandler, f = s?.interpolation?.skipOnVariables !== void 0 ? s.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
716
- return [{
717
- regex: this.regexpUnescape,
718
- safeValue: (p) => Q(p)
719
- }, {
720
- regex: this.regexp,
721
- safeValue: (p) => this.escapeValue ? Q(this.escape(p)) : Q(p)
722
- }].forEach((p) => {
723
- for (a = 0; n = p.regex.exec(e); ) {
724
- const c = n[1].trim();
725
- if (r = u(c), r === void 0)
726
- if (typeof h == "function") {
727
- const y = h(e, n, s);
728
- r = d(y) ? y : "";
729
- } else if (s && Object.prototype.hasOwnProperty.call(s, c))
730
- r = "";
731
- else if (f) {
732
- r = n[0];
733
- continue;
734
- } else
735
- this.logger.warn(`missed to pass in variable ${c} for interpolating ${e}`), r = "";
736
- else !d(r) && !this.useRawValueToEscape && (r = se(r));
737
- const m = p.safeValue(r);
738
- if (e = e.replace(n[0], m), f ? (p.regex.lastIndex += r.length, p.regex.lastIndex -= n[0].length) : p.regex.lastIndex = 0, a++, a >= this.maxReplaces)
739
- break;
740
- }
741
- }), e;
742
- }
743
- nest(e, t, i = {}) {
744
- let s, n, r;
745
- const a = (l, u) => {
746
- const h = this.nestingOptionsSeparator;
747
- if (l.indexOf(h) < 0) return l;
748
- const f = l.split(new RegExp(`${h}[ ]*{`));
749
- let g = `{${f[1]}`;
750
- l = f[0], g = this.interpolate(g, r);
751
- const p = g.match(/'/g), c = g.match(/"/g);
752
- ((p?.length ?? 0) % 2 === 0 && !c || c.length % 2 !== 0) && (g = g.replace(/'/g, '"'));
753
- try {
754
- r = JSON.parse(g), u && (r = {
755
- ...u,
756
- ...r
757
- });
758
- } catch (m) {
759
- return this.logger.warn(`failed parsing options string in nesting for key ${l}`, m), `${l}${h}${g}`;
760
- }
761
- return r.defaultValue && r.defaultValue.indexOf(this.prefix) > -1 && delete r.defaultValue, l;
762
- };
763
- for (; s = this.nestingRegexp.exec(e); ) {
764
- let l = [];
765
- r = {
766
- ...i
767
- }, r = r.replace && !d(r.replace) ? r.replace : r, r.applyPostProcessor = !1, delete r.defaultValue;
768
- const u = /{.*}/.test(s[1]) ? s[1].lastIndexOf("}") + 1 : s[1].indexOf(this.formatSeparator);
769
- if (u !== -1 && (l = s[1].slice(u).split(this.formatSeparator).map((h) => h.trim()).filter(Boolean), s[1] = s[1].slice(0, u)), n = t(a.call(this, s[1].trim(), r), r), n && s[0] === e && !d(n)) return n;
770
- d(n) || (n = se(n)), n || (this.logger.warn(`missed to resolve ${s[1]} for nesting ${e}`), n = ""), l.length && (n = l.reduce((h, f) => this.format(h, f, i.lng, {
771
- ...i,
772
- interpolationkey: s[1].trim()
773
- }), n.trim())), e = e.replace(s[0], n), this.regexp.lastIndex = 0;
774
- }
775
- return e;
776
- }
777
- }
778
- const Te = (o) => {
779
- let e = o.toLowerCase().trim();
780
- const t = {};
781
- if (o.indexOf("(") > -1) {
782
- const i = o.split("(");
783
- e = i[0].toLowerCase().trim();
784
- const s = i[1].substring(0, i[1].length - 1);
785
- e === "currency" && s.indexOf(":") < 0 ? t.currency || (t.currency = s.trim()) : e === "relativetime" && s.indexOf(":") < 0 ? t.range || (t.range = s.trim()) : s.split(";").forEach((r) => {
786
- if (r) {
787
- const [a, ...l] = r.split(":"), u = l.join(":").trim().replace(/^'+|'+$/g, ""), h = a.trim();
788
- t[h] || (t[h] = u), u === "false" && (t[h] = !1), u === "true" && (t[h] = !0), isNaN(u) || (t[h] = parseInt(u, 10));
789
- }
790
- });
791
- }
792
- return {
793
- formatName: e,
794
- formatOptions: t
795
- };
796
- }, de = (o) => {
797
- const e = {};
798
- return (t, i, s) => {
799
- let n = s;
800
- s && s.interpolationkey && s.formatParams && s.formatParams[s.interpolationkey] && s[s.interpolationkey] && (n = {
801
- ...n,
802
- [s.interpolationkey]: void 0
803
- });
804
- const r = i + JSON.stringify(n);
805
- let a = e[r];
806
- return a || (a = o(H(i), s), e[r] = a), a(t);
807
- };
808
- }, Ie = (o) => (e, t, i) => o(H(t), i)(e);
809
- class De {
810
- constructor(e = {}) {
811
- this.logger = P.create("formatter"), this.options = e, this.init(e);
812
- }
813
- init(e, t = {
814
- interpolation: {}
815
- }) {
816
- this.formatSeparator = t.interpolation.formatSeparator || ",";
817
- const i = t.cacheInBuiltFormats ? de : Ie;
818
- this.formats = {
819
- number: i((s, n) => {
820
- const r = new Intl.NumberFormat(s, {
821
- ...n
822
- });
823
- return (a) => r.format(a);
824
- }),
825
- currency: i((s, n) => {
826
- const r = new Intl.NumberFormat(s, {
827
- ...n,
828
- style: "currency"
829
- });
830
- return (a) => r.format(a);
831
- }),
832
- datetime: i((s, n) => {
833
- const r = new Intl.DateTimeFormat(s, {
834
- ...n
835
- });
836
- return (a) => r.format(a);
837
- }),
838
- relativetime: i((s, n) => {
839
- const r = new Intl.RelativeTimeFormat(s, {
840
- ...n
841
- });
842
- return (a) => r.format(a, n.range || "day");
843
- }),
844
- list: i((s, n) => {
845
- const r = new Intl.ListFormat(s, {
846
- ...n
847
- });
848
- return (a) => r.format(a);
849
- })
850
- };
851
- }
852
- add(e, t) {
853
- this.formats[e.toLowerCase().trim()] = t;
854
- }
855
- addCached(e, t) {
856
- this.formats[e.toLowerCase().trim()] = de(t);
857
- }
858
- format(e, t, i, s = {}) {
859
- const n = t.split(this.formatSeparator);
860
- if (n.length > 1 && n[0].indexOf("(") > 1 && n[0].indexOf(")") < 0 && n.find((a) => a.indexOf(")") > -1)) {
861
- const a = n.findIndex((l) => l.indexOf(")") > -1);
862
- n[0] = [n[0], ...n.splice(1, a)].join(this.formatSeparator);
863
- }
864
- return n.reduce((a, l) => {
865
- const {
866
- formatName: u,
867
- formatOptions: h
868
- } = Te(l);
869
- if (this.formats[u]) {
870
- let f = a;
871
- try {
872
- const g = s?.formatParams?.[s.interpolationkey] || {}, p = g.locale || g.lng || s.locale || s.lng || i;
873
- f = this.formats[u](a, p, {
874
- ...h,
875
- ...s,
876
- ...g
877
- });
878
- } catch (g) {
879
- this.logger.warn(g);
880
- }
881
- return f;
882
- } else
883
- this.logger.warn(`there was no format function for ${u}`);
884
- return a;
885
- }, e);
886
- }
887
- }
888
- const Ve = (o, e) => {
889
- o.pending[e] !== void 0 && (delete o.pending[e], o.pendingCount--);
890
- };
891
- class Ke extends Y {
892
- constructor(e, t, i, s = {}) {
893
- super(), this.backend = e, this.store = t, this.services = i, this.languageUtils = i.languageUtils, this.options = s, this.logger = P.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = s.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = s.maxRetries >= 0 ? s.maxRetries : 5, this.retryTimeout = s.retryTimeout >= 1 ? s.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(i, s.backend, s);
894
- }
895
- queueLoad(e, t, i, s) {
896
- const n = {}, r = {}, a = {}, l = {};
897
- return e.forEach((u) => {
898
- let h = !0;
899
- t.forEach((f) => {
900
- const g = `${u}|${f}`;
901
- !i.reload && this.store.hasResourceBundle(u, f) ? this.state[g] = 2 : this.state[g] < 0 || (this.state[g] === 1 ? r[g] === void 0 && (r[g] = !0) : (this.state[g] = 1, h = !1, r[g] === void 0 && (r[g] = !0), n[g] === void 0 && (n[g] = !0), l[f] === void 0 && (l[f] = !0)));
902
- }), h || (a[u] = !0);
903
- }), (Object.keys(n).length || Object.keys(r).length) && this.queue.push({
904
- pending: r,
905
- pendingCount: Object.keys(r).length,
906
- loaded: {},
907
- errors: [],
908
- callback: s
909
- }), {
910
- toLoad: Object.keys(n),
911
- pending: Object.keys(r),
912
- toLoadLanguages: Object.keys(a),
913
- toLoadNamespaces: Object.keys(l)
914
- };
915
- }
916
- loaded(e, t, i) {
917
- const s = e.split("|"), n = s[0], r = s[1];
918
- t && this.emit("failedLoading", n, r, t), !t && i && this.store.addResourceBundle(n, r, i, void 0, void 0, {
919
- skipCopy: !0
920
- }), this.state[e] = t ? -1 : 2, t && i && (this.state[e] = 0);
921
- const a = {};
922
- this.queue.forEach((l) => {
923
- ve(l.loaded, [n], r), Ve(l, e), t && l.errors.push(t), l.pendingCount === 0 && !l.done && (Object.keys(l.loaded).forEach((u) => {
924
- a[u] || (a[u] = {});
925
- const h = l.loaded[u];
926
- h.length && h.forEach((f) => {
927
- a[u][f] === void 0 && (a[u][f] = !0);
928
- });
929
- }), l.done = !0, l.errors.length ? l.callback(l.errors) : l.callback());
930
- }), this.emit("loaded", a), this.queue = this.queue.filter((l) => !l.done);
931
- }
932
- read(e, t, i, s = 0, n = this.retryTimeout, r) {
933
- if (!e.length) return r(null, {});
934
- if (this.readingCalls >= this.maxParallelReads) {
935
- this.waitingReads.push({
936
- lng: e,
937
- ns: t,
938
- fcName: i,
939
- tried: s,
940
- wait: n,
941
- callback: r
942
- });
943
- return;
944
- }
945
- this.readingCalls++;
946
- const a = (u, h) => {
947
- if (this.readingCalls--, this.waitingReads.length > 0) {
948
- const f = this.waitingReads.shift();
949
- this.read(f.lng, f.ns, f.fcName, f.tried, f.wait, f.callback);
950
- }
951
- if (u && h && s < this.maxRetries) {
952
- setTimeout(() => {
953
- this.read.call(this, e, t, i, s + 1, n * 2, r);
954
- }, n);
955
- return;
956
- }
957
- r(u, h);
958
- }, l = this.backend[i].bind(this.backend);
959
- if (l.length === 2) {
960
- try {
961
- const u = l(e, t);
962
- u && typeof u.then == "function" ? u.then((h) => a(null, h)).catch(a) : a(null, u);
963
- } catch (u) {
964
- a(u);
965
- }
966
- return;
967
- }
968
- return l(e, t, a);
969
- }
970
- prepareLoading(e, t, i = {}, s) {
971
- if (!this.backend)
972
- return this.logger.warn("No backend was added via i18next.use. Will not load resources."), s && s();
973
- d(e) && (e = this.languageUtils.toResolveHierarchy(e)), d(t) && (t = [t]);
974
- const n = this.queueLoad(e, t, i, s);
975
- if (!n.toLoad.length)
976
- return n.pending.length || s(), null;
977
- n.toLoad.forEach((r) => {
978
- this.loadOne(r);
979
- });
980
- }
981
- load(e, t, i) {
982
- this.prepareLoading(e, t, {}, i);
983
- }
984
- reload(e, t, i) {
985
- this.prepareLoading(e, t, {
986
- reload: !0
987
- }, i);
988
- }
989
- loadOne(e, t = "") {
990
- const i = e.split("|"), s = i[0], n = i[1];
991
- this.read(s, n, "read", void 0, void 0, (r, a) => {
992
- r && this.logger.warn(`${t}loading namespace ${n} for language ${s} failed`, r), !r && a && this.logger.log(`${t}loaded namespace ${n} for language ${s}`, a), this.loaded(e, r, a);
993
- });
994
- }
995
- saveMissing(e, t, i, s, n, r = {}, a = () => {
996
- }) {
997
- if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
998
- this.logger.warn(`did not save key "${i}" 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!!!");
999
- return;
1000
- }
1001
- if (!(i == null || i === "")) {
1002
- if (this.backend?.create) {
1003
- const l = {
1004
- ...r,
1005
- isUpdate: n
1006
- }, u = this.backend.create.bind(this.backend);
1007
- if (u.length < 6)
1008
- try {
1009
- let h;
1010
- u.length === 5 ? h = u(e, t, i, s, l) : h = u(e, t, i, s), h && typeof h.then == "function" ? h.then((f) => a(null, f)).catch(a) : a(null, h);
1011
- } catch (h) {
1012
- a(h);
1013
- }
1014
- else
1015
- u(e, t, i, s, a, l);
1016
- }
1017
- !e || !e[0] || this.store.addResource(e[0], t, i, s);
1018
- }
1019
- }
1020
- }
1021
- const pe = () => ({
1022
- debug: !1,
1023
- initAsync: !0,
1024
- ns: ["translation"],
1025
- defaultNS: ["translation"],
1026
- fallbackLng: ["dev"],
1027
- fallbackNS: !1,
1028
- supportedLngs: !1,
1029
- nonExplicitSupportedLngs: !1,
1030
- load: "all",
1031
- preload: !1,
1032
- simplifyPluralSuffix: !0,
1033
- keySeparator: ".",
1034
- nsSeparator: ":",
1035
- pluralSeparator: "_",
1036
- contextSeparator: "_",
1037
- partialBundledLanguages: !1,
1038
- saveMissing: !1,
1039
- updateMissing: !1,
1040
- saveMissingTo: "fallback",
1041
- saveMissingPlurals: !0,
1042
- missingKeyHandler: !1,
1043
- missingInterpolationHandler: !1,
1044
- postProcess: !1,
1045
- postProcessPassResolved: !1,
1046
- returnNull: !1,
1047
- returnEmptyString: !0,
1048
- returnObjects: !1,
1049
- joinArrays: !1,
1050
- returnedObjectHandler: !1,
1051
- parseMissingKeyHandler: !1,
1052
- appendNamespaceToMissingKey: !1,
1053
- appendNamespaceToCIMode: !1,
1054
- overloadTranslationOptionHandler: (o) => {
1055
- let e = {};
1056
- if (typeof o[1] == "object" && (e = o[1]), d(o[1]) && (e.defaultValue = o[1]), d(o[2]) && (e.tDescription = o[2]), typeof o[2] == "object" || typeof o[3] == "object") {
1057
- const t = o[3] || o[2];
1058
- Object.keys(t).forEach((i) => {
1059
- e[i] = t[i];
1060
- });
1061
- }
1062
- return e;
1063
- },
1064
- interpolation: {
1065
- escapeValue: !0,
1066
- format: (o) => o,
1067
- prefix: "{{",
1068
- suffix: "}}",
1069
- formatSeparator: ",",
1070
- unescapePrefix: "-",
1071
- nestingPrefix: "$t(",
1072
- nestingSuffix: ")",
1073
- nestingOptionsSeparator: ",",
1074
- maxReplaces: 1e3,
1075
- skipOnVariables: !0
1076
- },
1077
- cacheInBuiltFormats: !0
1078
- }), ge = (o) => (d(o.ns) && (o.ns = [o.ns]), d(o.fallbackLng) && (o.fallbackLng = [o.fallbackLng]), d(o.fallbackNS) && (o.fallbackNS = [o.fallbackNS]), o.supportedLngs?.indexOf?.("cimode") < 0 && (o.supportedLngs = o.supportedLngs.concat(["cimode"])), typeof o.initImmediate == "boolean" && (o.initAsync = o.initImmediate), o), B = () => {
1079
- }, Ae = (o) => {
1080
- Object.getOwnPropertyNames(Object.getPrototypeOf(o)).forEach((t) => {
1081
- typeof o[t] == "function" && (o[t] = o[t].bind(o));
1082
- });
1083
- };
1084
- class U extends Y {
1085
- constructor(e = {}, t) {
1086
- if (super(), this.options = ge(e), this.services = {}, this.logger = P, this.modules = {
1087
- external: []
1088
- }, Ae(this), t && !this.isInitialized && !e.isClone) {
1089
- if (!this.options.initAsync)
1090
- return this.init(e, t), this;
1091
- setTimeout(() => {
1092
- this.init(e, t);
1093
- }, 0);
1094
- }
1095
- }
1096
- init(e = {}, t) {
1097
- this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (d(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
1098
- const i = pe();
1099
- this.options = {
1100
- ...i,
1101
- ...this.options,
1102
- ...ge(e)
1103
- }, this.options.interpolation = {
1104
- ...i.interpolation,
1105
- ...this.options.interpolation
1106
- }, e.keySeparator !== void 0 && (this.options.userDefinedKeySeparator = e.keySeparator), e.nsSeparator !== void 0 && (this.options.userDefinedNsSeparator = e.nsSeparator), typeof this.options.overloadTranslationOptionHandler != "function" && (this.options.overloadTranslationOptionHandler = i.overloadTranslationOptionHandler);
1107
- const s = (u) => u ? typeof u == "function" ? new u() : u : null;
1108
- if (!this.options.isClone) {
1109
- this.modules.logger ? P.init(s(this.modules.logger), this.options) : P.init(null, this.options);
1110
- let u;
1111
- this.modules.formatter ? u = this.modules.formatter : u = De;
1112
- const h = new le(this.options);
1113
- this.store = new ae(this.options.resources, this.options);
1114
- const f = this.services;
1115
- f.logger = P, f.resourceStore = this.store, f.languageUtils = h, f.pluralResolver = new Ee(h, {
1116
- prepend: this.options.pluralSeparator,
1117
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1118
- }), this.options.interpolation.format && this.options.interpolation.format !== i.interpolation.format && this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"), u && (!this.options.interpolation.format || this.options.interpolation.format === i.interpolation.format) && (f.formatter = s(u), f.formatter.init && f.formatter.init(f, this.options), this.options.interpolation.format = f.formatter.format.bind(f.formatter)), f.interpolator = new ce(this.options), f.utils = {
1119
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1120
- }, f.backendConnector = new Ke(s(this.modules.backend), f.resourceStore, f, this.options), f.backendConnector.on("*", (p, ...c) => {
1121
- this.emit(p, ...c);
1122
- }), this.modules.languageDetector && (f.languageDetector = s(this.modules.languageDetector), f.languageDetector.init && f.languageDetector.init(f, this.options.detection, this.options)), this.modules.i18nFormat && (f.i18nFormat = s(this.modules.i18nFormat), f.i18nFormat.init && f.i18nFormat.init(this)), this.translator = new W(this.services, this.options), this.translator.on("*", (p, ...c) => {
1123
- this.emit(p, ...c);
1124
- }), this.modules.external.forEach((p) => {
1125
- p.init && p.init(this);
1126
- });
1127
- }
1128
- if (this.format = this.options.interpolation.format, t || (t = B), this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1129
- const u = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1130
- u.length > 0 && u[0] !== "dev" && (this.options.lng = u[0]);
1131
- }
1132
- !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), ["getResource", "hasResourceBundle", "getResourceBundle", "getDataByLanguage"].forEach((u) => {
1133
- this[u] = (...h) => this.store[u](...h);
1134
- }), ["addResource", "addResources", "addResourceBundle", "removeResourceBundle"].forEach((u) => {
1135
- this[u] = (...h) => (this.store[u](...h), this);
1136
- });
1137
- const a = K(), l = () => {
1138
- const u = (h, f) => {
1139
- this.isInitializing = !1, 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), a.resolve(f), t(h, f);
1140
- };
1141
- if (this.languages && !this.isInitialized) return u(null, this.t.bind(this));
1142
- this.changeLanguage(this.options.lng, u);
1143
- };
1144
- return this.options.resources || !this.options.initAsync ? l() : setTimeout(l, 0), a;
1145
- }
1146
- loadResources(e, t = B) {
1147
- let i = t;
1148
- const s = d(e) ? e : this.language;
1149
- if (typeof e == "function" && (i = e), !this.options.resources || this.options.partialBundledLanguages) {
1150
- if (s?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return i();
1151
- const n = [], r = (a) => {
1152
- if (!a || a === "cimode") return;
1153
- this.services.languageUtils.toResolveHierarchy(a).forEach((u) => {
1154
- u !== "cimode" && n.indexOf(u) < 0 && n.push(u);
1155
- });
1156
- };
1157
- s ? r(s) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((l) => r(l)), this.options.preload?.forEach?.((a) => r(a)), this.services.backendConnector.load(n, this.options.ns, (a) => {
1158
- !a && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), i(a);
1159
- });
1160
- } else
1161
- i(null);
1162
- }
1163
- reloadResources(e, t, i) {
1164
- const s = K();
1165
- return typeof e == "function" && (i = e, e = void 0), typeof t == "function" && (i = t, t = void 0), e || (e = this.languages), t || (t = this.options.ns), i || (i = B), this.services.backendConnector.reload(e, t, (n) => {
1166
- s.resolve(), i(n);
1167
- }), s;
1168
- }
1169
- use(e) {
1170
- if (!e) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1171
- if (!e.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1172
- 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" && xe.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1173
- }
1174
- setResolvedLanguage(e) {
1175
- if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
1176
- for (let t = 0; t < this.languages.length; t++) {
1177
- const i = this.languages[t];
1178
- if (!(["cimode", "dev"].indexOf(i) > -1) && this.store.hasLanguageSomeTranslations(i)) {
1179
- this.resolvedLanguage = i;
1180
- break;
1181
- }
1182
- }
1183
- !this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
1184
- }
1185
- }
1186
- changeLanguage(e, t) {
1187
- this.isLanguageChangingTo = e;
1188
- const i = K();
1189
- this.emit("languageChanging", e);
1190
- const s = (a) => {
1191
- this.language = a, this.languages = this.services.languageUtils.toResolveHierarchy(a), this.resolvedLanguage = void 0, this.setResolvedLanguage(a);
1192
- }, n = (a, l) => {
1193
- l ? this.isLanguageChangingTo === e && (s(l), this.translator.changeLanguage(l), this.isLanguageChangingTo = void 0, this.emit("languageChanged", l), this.logger.log("languageChanged", l)) : this.isLanguageChangingTo = void 0, i.resolve((...u) => this.t(...u)), t && t(a, (...u) => this.t(...u));
1194
- }, r = (a) => {
1195
- !e && !a && this.services.languageDetector && (a = []);
1196
- const l = d(a) ? a : a && a[0], u = this.store.hasLanguageSomeTranslations(l) ? l : this.services.languageUtils.getBestMatchFromCodes(d(a) ? [a] : a);
1197
- u && (this.language || s(u), this.translator.language || this.translator.changeLanguage(u), this.services.languageDetector?.cacheUserLanguage?.(u)), this.loadResources(u, (h) => {
1198
- n(h, u);
1199
- });
1200
- };
1201
- return !e && this.services.languageDetector && !this.services.languageDetector.async ? r(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(r) : this.services.languageDetector.detect(r) : r(e), i;
1202
- }
1203
- getFixedT(e, t, i) {
1204
- const s = (n, r, ...a) => {
1205
- let l;
1206
- typeof r != "object" ? l = this.options.overloadTranslationOptionHandler([n, r].concat(a)) : l = {
1207
- ...r
1208
- }, l.lng = l.lng || s.lng, l.lngs = l.lngs || s.lngs, l.ns = l.ns || s.ns, l.keyPrefix !== "" && (l.keyPrefix = l.keyPrefix || i || s.keyPrefix);
1209
- const u = this.options.keySeparator || ".";
1210
- let h;
1211
- return l.keyPrefix && Array.isArray(n) ? h = n.map((f) => (typeof f == "function" && (f = Z(f, {
1212
- ...this.options,
1213
- ...r
1214
- })), `${l.keyPrefix}${u}${f}`)) : (typeof n == "function" && (n = Z(n, {
1215
- ...this.options,
1216
- ...r
1217
- })), h = l.keyPrefix ? `${l.keyPrefix}${u}${n}` : n), this.t(h, l);
1218
- };
1219
- return d(e) ? s.lng = e : s.lngs = e, s.ns = t, s.keyPrefix = i, s;
1220
- }
1221
- t(...e) {
1222
- return this.translator?.translate(...e);
1223
- }
1224
- exists(...e) {
1225
- return this.translator?.exists(...e);
1226
- }
1227
- setDefaultNamespace(e) {
1228
- this.options.defaultNS = e;
1229
- }
1230
- hasLoadedNamespace(e, t = {}) {
1231
- if (!this.isInitialized)
1232
- return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
1233
- if (!this.languages || !this.languages.length)
1234
- return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1235
- const i = t.lng || this.resolvedLanguage || this.languages[0], s = this.options ? this.options.fallbackLng : !1, n = this.languages[this.languages.length - 1];
1236
- if (i.toLowerCase() === "cimode") return !0;
1237
- const r = (a, l) => {
1238
- const u = this.services.backendConnector.state[`${a}|${l}`];
1239
- return u === -1 || u === 0 || u === 2;
1240
- };
1241
- if (t.precheck) {
1242
- const a = t.precheck(this, r);
1243
- if (a !== void 0) return a;
1244
- }
1245
- return !!(this.hasResourceBundle(i, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || r(i, e) && (!s || r(n, e)));
1246
- }
1247
- loadNamespaces(e, t) {
1248
- const i = K();
1249
- return this.options.ns ? (d(e) && (e = [e]), e.forEach((s) => {
1250
- this.options.ns.indexOf(s) < 0 && this.options.ns.push(s);
1251
- }), this.loadResources((s) => {
1252
- i.resolve(), t && t(s);
1253
- }), i) : (t && t(), Promise.resolve());
1254
- }
1255
- loadLanguages(e, t) {
1256
- const i = K();
1257
- d(e) && (e = [e]);
1258
- const s = this.options.preload || [], n = e.filter((r) => s.indexOf(r) < 0 && this.services.languageUtils.isSupportedCode(r));
1259
- return n.length ? (this.options.preload = s.concat(n), this.loadResources((r) => {
1260
- i.resolve(), t && t(r);
1261
- }), i) : (t && t(), Promise.resolve());
1262
- }
1263
- dir(e) {
1264
- if (e || (e = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language)), !e) return "rtl";
1265
- try {
1266
- const s = new Intl.Locale(e);
1267
- if (s && s.getTextInfo) {
1268
- const n = s.getTextInfo();
1269
- if (n && n.direction) return n.direction;
1270
- }
1271
- } catch {
1272
- }
1273
- 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"], i = this.services?.languageUtils || new le(pe());
1274
- return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(i.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1275
- }
1276
- static createInstance(e = {}, t) {
1277
- const i = new U(e, t);
1278
- return i.createInstance = U.createInstance, i;
1279
- }
1280
- cloneInstance(e = {}, t = B) {
1281
- const i = e.forkResourceStore;
1282
- i && delete e.forkResourceStore;
1283
- const s = {
1284
- ...this.options,
1285
- ...e,
1286
- isClone: !0
1287
- }, n = new U(s);
1288
- if ((e.debug !== void 0 || e.prefix !== void 0) && (n.logger = n.logger.clone(e)), ["store", "services", "language"].forEach((a) => {
1289
- n[a] = this[a];
1290
- }), n.services = {
1291
- ...this.services
1292
- }, n.services.utils = {
1293
- hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
1294
- }, i) {
1295
- const a = Object.keys(this.store.data).reduce((l, u) => (l[u] = {
1296
- ...this.store.data[u]
1297
- }, l[u] = Object.keys(l[u]).reduce((h, f) => (h[f] = {
1298
- ...l[u][f]
1299
- }, h), l[u]), l), {});
1300
- n.store = new ae(a, s), n.services.resourceStore = n.store;
1301
- }
1302
- return e.interpolation && (n.services.interpolator = new ce(s)), n.translator = new W(n.services, s), n.translator.on("*", (a, ...l) => {
1303
- n.emit(a, ...l);
1304
- }), n.init(s, t), n.translator.options = s, n.translator.backendConnector.services.utils = {
1305
- hasLoadedNamespace: n.hasLoadedNamespace.bind(n)
1306
- }, n;
1307
- }
1308
- toJSON() {
1309
- return {
1310
- options: this.options,
1311
- store: this.store,
1312
- language: this.language,
1313
- languages: this.languages,
1314
- resolvedLanguage: this.resolvedLanguage
1315
- };
1316
- }
1317
- }
1318
- const S = U.createInstance();
1319
- S.createInstance;
1320
- S.dir;
1321
- S.init;
1322
- S.loadResources;
1323
- S.reloadResources;
1324
- S.use;
1325
- S.changeLanguage;
1326
- S.getFixedT;
1327
- const Ue = S.t;
1328
- S.exists;
1329
- S.setDefaultNamespace;
1330
- S.hasLoadedNamespace;
1331
- S.loadNamespaces;
1332
- S.loadLanguages;
1333
- export {
1334
- S as i,
1335
- Ue as t
1336
- };
1337
- //# sourceMappingURL=i18next-Bx3TmZAT.js.map