@sv-print/plugin-i18n 0.1.0

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