@pie-element/explicit-constructed-response 11.1.2-next.2 → 11.1.2

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 (108) hide show
  1. package/CHANGELOG.json +1102 -0
  2. package/CHANGELOG.md +2194 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +1 -0
  5. package/configure/CHANGELOG.json +652 -0
  6. package/configure/CHANGELOG.md +1935 -0
  7. package/configure/lib/alternateResponses.js +199 -0
  8. package/configure/lib/alternateResponses.js.map +1 -0
  9. package/configure/lib/alternateSection.js +329 -0
  10. package/configure/lib/alternateSection.js.map +1 -0
  11. package/configure/lib/defaults.js +184 -0
  12. package/configure/lib/defaults.js.map +1 -0
  13. package/configure/lib/ecr-toolbar.js +181 -0
  14. package/configure/lib/ecr-toolbar.js.map +1 -0
  15. package/configure/lib/index.js +161 -0
  16. package/configure/lib/index.js.map +1 -0
  17. package/configure/lib/main.js +501 -0
  18. package/configure/lib/main.js.map +1 -0
  19. package/configure/lib/markupUtils.js +70 -0
  20. package/configure/lib/markupUtils.js.map +1 -0
  21. package/configure/lib/utils.js +15 -0
  22. package/configure/lib/utils.js.map +1 -0
  23. package/configure/package.json +22 -0
  24. package/controller/CHANGELOG.json +517 -0
  25. package/controller/CHANGELOG.md +1344 -0
  26. package/controller/lib/defaults.js +23 -0
  27. package/controller/lib/defaults.js.map +1 -0
  28. package/controller/lib/index.js +368 -0
  29. package/controller/lib/index.js.map +1 -0
  30. package/controller/package.json +18 -0
  31. package/docs/config-schema.json +2629 -0
  32. package/docs/config-schema.json.md +1941 -0
  33. package/docs/demo/config.js +8 -0
  34. package/docs/demo/generate.js +20 -0
  35. package/docs/demo/index.html +1 -0
  36. package/docs/demo/session.js +10 -0
  37. package/docs/pie-schema.json +1130 -0
  38. package/docs/pie-schema.json.md +814 -0
  39. package/lib/index.js +91 -0
  40. package/lib/index.js.map +1 -0
  41. package/lib/main.js +205 -0
  42. package/lib/main.js.map +1 -0
  43. package/lib/print.js +71 -0
  44. package/lib/print.js.map +1 -0
  45. package/module/configure.js +1 -0
  46. package/module/controller.js +6534 -0
  47. package/module/demo.js +45 -0
  48. package/module/element.js +1 -0
  49. package/module/index.html +21 -0
  50. package/module/manifest.json +18 -0
  51. package/module/print-demo.js +83 -0
  52. package/module/print.html +18 -0
  53. package/module/print.js +1 -0
  54. package/package.json +25 -92
  55. package/configure.js +0 -2
  56. package/controller.js +0 -1
  57. package/dist/_virtual/_rolldown/runtime.js +0 -4
  58. package/dist/author/alternateResponses.d.ts +0 -34
  59. package/dist/author/alternateResponses.js +0 -113
  60. package/dist/author/alternateSection.d.ts +0 -58
  61. package/dist/author/alternateSection.js +0 -213
  62. package/dist/author/defaults.d.ts +0 -186
  63. package/dist/author/defaults.js +0 -128
  64. package/dist/author/ecr-toolbar.d.ts +0 -41
  65. package/dist/author/ecr-toolbar.js +0 -100
  66. package/dist/author/index.d.ts +0 -42
  67. package/dist/author/index.js +0 -96
  68. package/dist/author/main.d.ts +0 -38
  69. package/dist/author/main.js +0 -291
  70. package/dist/author/markupUtils.d.ts +0 -14
  71. package/dist/author/markupUtils.js +0 -13
  72. package/dist/author/utils.d.ts +0 -9
  73. package/dist/author/utils.js +0 -7
  74. package/dist/browser/author/index.js +0 -3378
  75. package/dist/browser/author/index.js.map +0 -1
  76. package/dist/browser/browser-BC3WygxE.js +0 -360
  77. package/dist/browser/browser-BC3WygxE.js.map +0 -1
  78. package/dist/browser/controller/index.js +0 -4152
  79. package/dist/browser/controller/index.js.map +0 -1
  80. package/dist/browser/delivery/index.js +0 -96
  81. package/dist/browser/delivery/index.js.map +0 -1
  82. package/dist/browser/dist-B5QyKMGD.js +0 -45663
  83. package/dist/browser/dist-B5QyKMGD.js.map +0 -1
  84. package/dist/browser/dist-D9ARZhQk.js +0 -1426
  85. package/dist/browser/dist-D9ARZhQk.js.map +0 -1
  86. package/dist/browser/explicit-constructed-response.css +0 -2
  87. package/dist/browser/main-Czk7a-Zt.js +0 -959
  88. package/dist/browser/main-Czk7a-Zt.js.map +0 -1
  89. package/dist/browser/print/index.js +0 -40
  90. package/dist/browser/print/index.js.map +0 -1
  91. package/dist/controller/defaults.d.ts +0 -25
  92. package/dist/controller/defaults.js +0 -19
  93. package/dist/controller/index.d.ts +0 -64
  94. package/dist/controller/index.js +0 -139
  95. package/dist/delivery/index.d.ts +0 -20
  96. package/dist/delivery/index.js +0 -66
  97. package/dist/delivery/main.d.ts +0 -48
  98. package/dist/delivery/main.js +0 -115
  99. package/dist/explicit-constructed-response.css +0 -2
  100. package/dist/index.d.ts +0 -1
  101. package/dist/index.iife.d.ts +0 -8
  102. package/dist/index.iife.js +0 -393
  103. package/dist/index.js +0 -2
  104. package/dist/node_modules/.bun/he@1.2.0/node_modules/he/he.js +0 -3993
  105. package/dist/print/index.d.ts +0 -15
  106. package/dist/print/index.js +0 -40
  107. package/dist/runtime-support.d.ts +0 -12
  108. package/dist/runtime-support.js +0 -12
@@ -1,1426 +0,0 @@
1
- //#region ../../lib-react/translator/dist/en.js
2
- var e = {
3
- translation: {
4
- categorize: {
5
- limitMaxChoicesPerCategory: "You've reached the limit of {{maxChoicesPerCategory}} responses per area. To add another response, one must first be removed.",
6
- maxChoicesPerCategoryRestriction: "To change this value to {{maxChoicesPerCategory}}, each category must have {{maxChoicesPerCategory}} or fewer answer choice[s]."
7
- },
8
- ebsr: { part: "Part {{index}}" },
9
- numberLine: {
10
- addElementLimit_one: "You can only add {{count}} element",
11
- addElementLimit_other: "You can only add {{count}} elements",
12
- clearAll: "Clear all"
13
- },
14
- imageClozeAssociation: {
15
- reachedLimit_one: "You’ve reached the limit of {{count}} response per area. To add another response, one must first be removed.",
16
- reachedLimit_other: "Full"
17
- },
18
- drawingResponse: {
19
- fillColor: "Fill color",
20
- outlineColor: "Outline color",
21
- noFill: "No fill",
22
- lightblue: "Light blue",
23
- lightyellow: "Light yellow",
24
- red: "Red",
25
- orange: "Orange",
26
- yellow: "Yellow",
27
- violet: "Violet",
28
- blue: "Blue",
29
- green: "Green",
30
- white: "White",
31
- black: "Black",
32
- onDoubleClick: "Double click to edit this text. Press Enter to submit."
33
- },
34
- charting: {
35
- addCategory: "Add category",
36
- actions: "Actions",
37
- add: "Add",
38
- delete: "Delete",
39
- newLabel: "New label",
40
- reachedLimit_other: "There can't be more than {{count}} categories.",
41
- keyLegend: {
42
- incorrectAnswer: "Student incorrect answer",
43
- correctAnswer: "Student correct answer",
44
- correctKeyAnswer: "Answer key correct"
45
- }
46
- },
47
- graphing: {
48
- point: "Point",
49
- circle: "Circle",
50
- line: "Line",
51
- parabola: "Parabola",
52
- absolute: "Absolute Value",
53
- exponential: "Exponential",
54
- polygon: "Polygon",
55
- ray: "Ray",
56
- segment: "Segment",
57
- sine: "Sine",
58
- vector: "Vector",
59
- label: "Label",
60
- redo: "Redo",
61
- reset: "Reset"
62
- },
63
- mathInline: { primaryCorrectWithAlternates: "Note: The answer shown above is the primary correct answer specified by the author for this item, but other answers may also be recognized as correct." },
64
- multipleChoice: {
65
- minSelections: "Select at least {{minSelections}}.",
66
- maxSelections_one: "Only {{maxSelections}} answer is allowed.",
67
- maxSelections_other: "Only {{maxSelections}} answers are allowed.",
68
- minmaxSelections_equal: "Select {{minSelections}}.",
69
- minmaxSelections_range: "Select between {{minSelections}} and {{maxSelections}}."
70
- },
71
- selectText: {
72
- correctAnswerSelected: "Correct",
73
- correctAnswerNotSelected: "Correct Answer Not Selected",
74
- incorrectSelection: "Incorrect Selection",
75
- key: "Key"
76
- }
77
- },
78
- common: {
79
- undo: "Undo",
80
- clearAll: "Clear all",
81
- correct: "Correct",
82
- incorrect: "Incorrect",
83
- showCorrectAnswer: "Show correct answer",
84
- hideCorrectAnswer: "Hide correct answer",
85
- commonCorrectAnswerWithAlternates: "Note: The answer shown above is the most common correct answer for this item. One or more additional correct answers are also defined, and will also be recognized as correct.",
86
- warning: "Warning",
87
- showNote: "Show Note",
88
- hideNote: "Hide Note",
89
- cancel: "Cancel"
90
- }
91
- }, t = {
92
- translation: {
93
- categorize: {
94
- limitMaxChoicesPerCategory: "Has alcanzado el límite de {{maxChoicesPerCategory}} respuestas por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
95
- maxChoicesPerCategoryRestriction: "Para cambiar este valor a {{maxChoicesPerCategory}}, cada categoría debe tener {{maxChoicesPerCategory}} o menos opciones de respuesta"
96
- },
97
- ebsr: { part: "Parte {{index}}" },
98
- numberLine: {
99
- addElementLimit_one: "Solo puedes agregar {{count}} elemento",
100
- addElementLimit_other: "Solo puedes agregar {{count}} elementos",
101
- clearAll: "Borrar todo"
102
- },
103
- imageClozeAssociation: {
104
- reachedLimit_one: "Has alcanzado el límite de {{count}} respuesta por área. Para agregar otra respuesta, primero se debe eliminar una respuesta.",
105
- reachedLimit_other: "Lleno"
106
- },
107
- drawingResponse: {
108
- fillColor: "Color de relleno",
109
- outlineColor: "Color del contorno",
110
- noFill: "Sin relleno",
111
- lightblue: "Azul claro",
112
- lightyellow: "Amarillo claro",
113
- red: "Rojo",
114
- orange: "Naranja",
115
- yellow: "Amarillo",
116
- violet: "Violeta",
117
- blue: "Azul",
118
- green: "Verde",
119
- white: "Blanco",
120
- black: "Negro",
121
- onDoubleClick: "Haz doble clic para revisar este texto. Presiona el botón de ingreso para enviar"
122
- },
123
- charting: {
124
- addCategory: "Añadir categoría",
125
- actions: "Acciones",
126
- add: "Añadir",
127
- delete: "Eliminar",
128
- newLabel: "Nueva etiqueta",
129
- reachedLimit_other: "No puede haber más de {{count}} categorías.",
130
- keyLegend: {
131
- incorrectAnswer: "Respuesta incorrecta del estudiante",
132
- correctAnswer: "Respuesta correcta del estudiante",
133
- correctKeyAnswer: "Clave de respuesta correcta"
134
- }
135
- },
136
- graphing: {
137
- point: "Punto",
138
- circle: "Circulo",
139
- line: "Línea",
140
- parabola: "Parábola",
141
- absolute: "Valor absoluto",
142
- exponential: "Exponencial",
143
- polygon: "Polígono",
144
- ray: "Semirrecta",
145
- segment: "Segmento ",
146
- sine: "Seno",
147
- vector: "Vector",
148
- label: "Etiqueta",
149
- redo: "Rehacer",
150
- reset: "Reiniciar"
151
- },
152
- mathInline: { primaryCorrectWithAlternates: "Nota: La respuesta que se muestra arriba es la respuesta correcta principal especificada por el autor para esta pregunta, pero también se pueden reconocer otras respuestas como correctas." },
153
- multipleChoice: {
154
- minSelections: "Seleccione al menos {{minSelections}}.",
155
- maxSelections_one: "Sólo se permite {{maxSelections}} respuesta.",
156
- maxSelections_other: "Sólo se permiten {{maxSelections}} respuestas.",
157
- minmaxSelections_equal: "Seleccione {{minSelections}}.",
158
- minmaxSelections_range: "Seleccione entre {{minSelections}} y {{maxSelections}}."
159
- },
160
- selectText: {
161
- correctAnswerSelected: "Respuesta Correcta",
162
- correctAnswerNotSelected: "Respuesta Correcta No Seleccionada",
163
- incorrectSelection: "Selección Incorrecta",
164
- key: "Clave"
165
- }
166
- },
167
- common: {
168
- undo: "Deshacer",
169
- clearAll: "Borrar todo",
170
- correct: "Correct",
171
- incorrect: "Incorrect",
172
- showCorrectAnswer: "Mostrar respuesta correcta",
173
- hideCorrectAnswer: "Ocultar respuesta correcta",
174
- commonCorrectAnswerWithAlternates: "Nota: La respuesta que se muestra arriba es la respuesta correcta más común para esta pregunta. También se definen una o más respuestas correctas adicionales, y también se reconocerán como correctas.",
175
- warning: "Advertencia",
176
- showNote: "Mostrar Nota",
177
- hideNote: "Ocultar Nota",
178
- cancel: "Cancelar"
179
- }
180
- }, n = (e) => typeof e == "string", r = () => {
181
- let e, t, n = new Promise((n, r) => {
182
- e = n, t = r;
183
- });
184
- return n.resolve = e, n.reject = t, n;
185
- }, i = (e) => e == null ? "" : "" + e, a = (e, t, n) => {
186
- e.forEach((e) => {
187
- t[e] && (n[e] = t[e]);
188
- });
189
- }, o = /###/g, s = (e) => e && e.indexOf("###") > -1 ? e.replace(o, ".") : e, c = (e) => !e || n(e), l = (e, t, r) => {
190
- let i = n(t) ? t.split(".") : t, a = 0;
191
- for (; a < i.length - 1;) {
192
- if (c(e)) return {};
193
- let t = s(i[a]);
194
- !e[t] && r && (e[t] = new r()), e = Object.prototype.hasOwnProperty.call(e, t) ? e[t] : {}, ++a;
195
- }
196
- return c(e) ? {} : {
197
- obj: e,
198
- k: s(i[a])
199
- };
200
- }, u = (e, t, n) => {
201
- let { obj: r, k: i } = l(e, t, Object);
202
- if (r !== void 0 || t.length === 1) {
203
- r[i] = n;
204
- return;
205
- }
206
- let a = t[t.length - 1], o = t.slice(0, t.length - 1), s = l(e, o, Object);
207
- for (; s.obj === void 0 && o.length;) a = `${o[o.length - 1]}.${a}`, o = o.slice(0, o.length - 1), s = l(e, o, Object), s?.obj && s.obj[`${s.k}.${a}`] !== void 0 && (s.obj = void 0);
208
- s.obj[`${s.k}.${a}`] = n;
209
- }, d = (e, t, n, r) => {
210
- let { obj: i, k: a } = l(e, t, Object);
211
- i[a] = i[a] || [], i[a].push(n);
212
- }, f = (e, t) => {
213
- let { obj: n, k: r } = l(e, t);
214
- if (n && Object.prototype.hasOwnProperty.call(n, r)) return n[r];
215
- }, p = (e, t, n) => {
216
- let r = f(e, n);
217
- return r === void 0 ? f(t, n) : r;
218
- }, m = (e, t, r) => {
219
- for (let i in t) i !== "__proto__" && i !== "constructor" && (i in e ? n(e[i]) || e[i] instanceof String || n(t[i]) || t[i] instanceof String ? r && (e[i] = t[i]) : m(e[i], t[i], r) : e[i] = t[i]);
220
- return e;
221
- }, h = (e) => e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), g = {
222
- "&": "&amp;",
223
- "<": "&lt;",
224
- ">": "&gt;",
225
- "\"": "&quot;",
226
- "'": "&#39;",
227
- "/": "&#x2F;"
228
- }, _ = (e) => n(e) ? e.replace(/[&<>"'\/]/g, (e) => g[e]) : e, v = class {
229
- constructor(e) {
230
- this.capacity = e, this.regExpMap = /* @__PURE__ */ new Map(), this.regExpQueue = [];
231
- }
232
- getRegExp(e) {
233
- let t = this.regExpMap.get(e);
234
- if (t !== void 0) return t;
235
- let n = new RegExp(e);
236
- return this.regExpQueue.length === this.capacity && this.regExpMap.delete(this.regExpQueue.shift()), this.regExpMap.set(e, n), this.regExpQueue.push(e), n;
237
- }
238
- }, y = [
239
- " ",
240
- ",",
241
- "?",
242
- "!",
243
- ";"
244
- ], b = new v(20), x = (e, t, n) => {
245
- t ||= "", n ||= "";
246
- let r = y.filter((e) => t.indexOf(e) < 0 && n.indexOf(e) < 0);
247
- if (r.length === 0) return !0;
248
- let i = b.getRegExp(`(${r.map((e) => e === "?" ? "\\?" : e).join("|")})`), a = !i.test(e);
249
- if (!a) {
250
- let t = e.indexOf(n);
251
- t > 0 && !i.test(e.substring(0, t)) && (a = !0);
252
- }
253
- return a;
254
- }, S = (e, t, n = ".") => {
255
- if (!e) return;
256
- if (e[t]) return Object.prototype.hasOwnProperty.call(e, t) ? e[t] : void 0;
257
- let r = t.split(n), i = e;
258
- for (let e = 0; e < r.length;) {
259
- if (!i || typeof i != "object") return;
260
- let t, a = "";
261
- for (let o = e; o < r.length; ++o) if (o !== e && (a += n), a += r[o], t = i[a], t !== void 0) {
262
- if ([
263
- "string",
264
- "number",
265
- "boolean"
266
- ].indexOf(typeof t) > -1 && o < r.length - 1) continue;
267
- e += o - e + 1;
268
- break;
269
- }
270
- i = t;
271
- }
272
- return i;
273
- }, C = (e) => e?.replace(/_/g, "-"), w = {
274
- type: "logger",
275
- log(e) {
276
- this.output("log", e);
277
- },
278
- warn(e) {
279
- this.output("warn", e);
280
- },
281
- error(e) {
282
- this.output("error", e);
283
- },
284
- output(e, t) {
285
- console?.[e]?.apply?.(console, t);
286
- }
287
- }, T = new class e {
288
- constructor(e, t = {}) {
289
- this.init(e, t);
290
- }
291
- init(e, t = {}) {
292
- this.prefix = t.prefix || "i18next:", this.logger = e || w, this.options = t, this.debug = t.debug;
293
- }
294
- log(...e) {
295
- return this.forward(e, "log", "", !0);
296
- }
297
- warn(...e) {
298
- return this.forward(e, "warn", "", !0);
299
- }
300
- error(...e) {
301
- return this.forward(e, "error", "");
302
- }
303
- deprecate(...e) {
304
- return this.forward(e, "warn", "WARNING DEPRECATED: ", !0);
305
- }
306
- forward(e, t, r, i) {
307
- return i && !this.debug ? null : (n(e[0]) && (e[0] = `${r}${this.prefix} ${e[0]}`), this.logger[t](e));
308
- }
309
- create(t) {
310
- return new e(this.logger, {
311
- prefix: `${this.prefix}:${t}:`,
312
- ...this.options
313
- });
314
- }
315
- clone(t) {
316
- return t ||= this.options, t.prefix = t.prefix || this.prefix, new e(this.logger, t);
317
- }
318
- }(), E = class {
319
- constructor() {
320
- this.observers = {};
321
- }
322
- on(e, t) {
323
- return e.split(" ").forEach((e) => {
324
- this.observers[e] || (this.observers[e] = /* @__PURE__ */ new Map());
325
- let n = this.observers[e].get(t) || 0;
326
- this.observers[e].set(t, n + 1);
327
- }), this;
328
- }
329
- off(e, t) {
330
- if (this.observers[e]) {
331
- if (!t) {
332
- delete this.observers[e];
333
- return;
334
- }
335
- this.observers[e].delete(t);
336
- }
337
- }
338
- emit(e, ...t) {
339
- this.observers[e] && Array.from(this.observers[e].entries()).forEach(([e, n]) => {
340
- for (let r = 0; r < n; r++) e(...t);
341
- }), this.observers["*"] && Array.from(this.observers["*"].entries()).forEach(([n, r]) => {
342
- for (let i = 0; i < r; i++) n.apply(n, [e, ...t]);
343
- });
344
- }
345
- }, D = class extends E {
346
- constructor(e, t = {
347
- ns: ["translation"],
348
- defaultNS: "translation"
349
- }) {
350
- super(), this.data = e || {}, this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.options.ignoreJSONStructure === void 0 && (this.options.ignoreJSONStructure = !0);
351
- }
352
- addNamespaces(e) {
353
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
354
- }
355
- removeNamespaces(e) {
356
- let t = this.options.ns.indexOf(e);
357
- t > -1 && this.options.ns.splice(t, 1);
358
- }
359
- getResource(e, t, r, i = {}) {
360
- let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = i.ignoreJSONStructure === void 0 ? this.options.ignoreJSONStructure : i.ignoreJSONStructure, s;
361
- e.indexOf(".") > -1 ? s = e.split(".") : (s = [e, t], r && (Array.isArray(r) ? s.push(...r) : n(r) && a ? s.push(...r.split(a)) : s.push(r)));
362
- let c = f(this.data, s);
363
- return !c && !t && !r && e.indexOf(".") > -1 && (e = s[0], t = s[1], r = s.slice(2).join(".")), c || !o || !n(r) ? c : S(this.data?.[e]?.[t], r, a);
364
- }
365
- addResource(e, t, n, r, i = { silent: !1 }) {
366
- let a = i.keySeparator === void 0 ? this.options.keySeparator : i.keySeparator, o = [e, t];
367
- n && (o = o.concat(a ? n.split(a) : n)), e.indexOf(".") > -1 && (o = e.split("."), r = t, t = o[1]), this.addNamespaces(t), u(this.data, o, r), i.silent || this.emit("added", e, t, n, r);
368
- }
369
- addResources(e, t, r, i = { silent: !1 }) {
370
- for (let i in r) (n(r[i]) || Array.isArray(r[i])) && this.addResource(e, t, i, r[i], { silent: !0 });
371
- i.silent || this.emit("added", e, t, r);
372
- }
373
- addResourceBundle(e, t, n, r, i, a = {
374
- silent: !1,
375
- skipCopy: !1
376
- }) {
377
- let o = [e, t];
378
- e.indexOf(".") > -1 && (o = e.split("."), r = n, n = t, t = o[1]), this.addNamespaces(t);
379
- let s = f(this.data, o) || {};
380
- a.skipCopy || (n = JSON.parse(JSON.stringify(n))), r ? m(s, n, i) : s = {
381
- ...s,
382
- ...n
383
- }, u(this.data, o, s), a.silent || this.emit("added", e, t, n);
384
- }
385
- removeResourceBundle(e, t) {
386
- this.hasResourceBundle(e, t) && delete this.data[e][t], this.removeNamespaces(t), this.emit("removed", e, t);
387
- }
388
- hasResourceBundle(e, t) {
389
- return this.getResource(e, t) !== void 0;
390
- }
391
- getResourceBundle(e, t) {
392
- return t ||= this.options.defaultNS, this.getResource(e, t);
393
- }
394
- getDataByLanguage(e) {
395
- return this.data[e];
396
- }
397
- hasLanguageSomeTranslations(e) {
398
- let t = this.getDataByLanguage(e);
399
- return !!(t && Object.keys(t) || []).find((e) => t[e] && Object.keys(t[e]).length > 0);
400
- }
401
- toJSON() {
402
- return this.data;
403
- }
404
- }, O = {
405
- processors: {},
406
- addPostProcessor(e) {
407
- this.processors[e.name] = e;
408
- },
409
- handle(e, t, n, r, i) {
410
- return e.forEach((e) => {
411
- t = this.processors[e]?.process(t, n, r, i) ?? t;
412
- }), t;
413
- }
414
- }, k = Symbol("i18next/PATH_KEY");
415
- function A() {
416
- let e = [], t = Object.create(null), n;
417
- return t.get = (r, i) => (n?.revoke?.(), i === k ? e : (e.push(i), n = Proxy.revocable(r, t), n.proxy)), Proxy.revocable(Object.create(null), t).proxy;
418
- }
419
- function j(e, t) {
420
- let { [k]: n } = e(A()), r = t?.keySeparator ?? ".", i = t?.nsSeparator ?? ":";
421
- if (n.length > 1 && i) {
422
- let e = t?.ns, a = Array.isArray(e) ? e : null;
423
- if (a && a.length > 1 && a.slice(1).includes(n[0])) return `${n[0]}${i}${n.slice(1).join(r)}`;
424
- }
425
- return n.join(r);
426
- }
427
- var M = {}, N = (e) => !n(e) && typeof e != "boolean" && typeof e != "number", P = class e extends E {
428
- constructor(e, t = {}) {
429
- super(), a([
430
- "resourceStore",
431
- "languageUtils",
432
- "pluralResolver",
433
- "interpolator",
434
- "backendConnector",
435
- "i18nFormat",
436
- "utils"
437
- ], e, this), this.options = t, this.options.keySeparator === void 0 && (this.options.keySeparator = "."), this.logger = T.create("translator");
438
- }
439
- changeLanguage(e) {
440
- e && (this.language = e);
441
- }
442
- exists(e, t = { interpolation: {} }) {
443
- let n = { ...t };
444
- if (e == null) return !1;
445
- let r = this.resolve(e, n);
446
- if (r?.res === void 0) return !1;
447
- let i = N(r.res);
448
- return !(n.returnObjects === !1 && i);
449
- }
450
- extractFromKey(e, t) {
451
- let r = t.nsSeparator === void 0 ? this.options.nsSeparator : t.nsSeparator;
452
- r === void 0 && (r = ":");
453
- let i = t.keySeparator === void 0 ? this.options.keySeparator : t.keySeparator, a = t.ns || this.options.defaultNS || [], o = r && e.indexOf(r) > -1, s = !this.options.userDefinedKeySeparator && !t.keySeparator && !this.options.userDefinedNsSeparator && !t.nsSeparator && !x(e, r, i);
454
- if (o && !s) {
455
- let t = e.match(this.interpolator.nestingRegexp);
456
- if (t && t.length > 0) return {
457
- key: e,
458
- namespaces: n(a) ? [a] : a
459
- };
460
- let o = e.split(r);
461
- (r !== i || r === i && this.options.ns.indexOf(o[0]) > -1) && (a = o.shift()), e = o.join(i);
462
- }
463
- return {
464
- key: e,
465
- namespaces: n(a) ? [a] : a
466
- };
467
- }
468
- translate(t, r, i) {
469
- let a = typeof r == "object" ? { ...r } : r;
470
- if (typeof a != "object" && this.options.overloadTranslationOptionHandler && (a = this.options.overloadTranslationOptionHandler(arguments)), typeof a == "object" && (a = { ...a }), a ||= {}, t == null) return "";
471
- typeof t == "function" && (t = j(t, {
472
- ...this.options,
473
- ...a
474
- })), Array.isArray(t) || (t = [String(t)]), t = t.map((e) => typeof e == "function" ? j(e, {
475
- ...this.options,
476
- ...a
477
- }) : String(e));
478
- let o = a.returnDetails === void 0 ? this.options.returnDetails : a.returnDetails, s = a.keySeparator === void 0 ? this.options.keySeparator : a.keySeparator, { key: c, namespaces: l } = this.extractFromKey(t[t.length - 1], a), u = l[l.length - 1], d = a.nsSeparator === void 0 ? this.options.nsSeparator : a.nsSeparator;
479
- d === void 0 && (d = ":");
480
- let f = a.lng || this.language, p = a.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
481
- if (f?.toLowerCase() === "cimode") return p ? o ? {
482
- res: `${u}${d}${c}`,
483
- usedKey: c,
484
- exactUsedKey: c,
485
- usedLng: f,
486
- usedNS: u,
487
- usedParams: this.getUsedParamsDetails(a)
488
- } : `${u}${d}${c}` : o ? {
489
- res: c,
490
- usedKey: c,
491
- exactUsedKey: c,
492
- usedLng: f,
493
- usedNS: u,
494
- usedParams: this.getUsedParamsDetails(a)
495
- } : c;
496
- let m = this.resolve(t, a), h = m?.res, g = m?.usedKey || c, _ = m?.exactUsedKey || c, v = [
497
- "[object Number]",
498
- "[object Function]",
499
- "[object RegExp]"
500
- ], y = a.joinArrays === void 0 ? this.options.joinArrays : a.joinArrays, b = !this.i18nFormat || this.i18nFormat.handleAsObject, x = a.count !== void 0 && !n(a.count), S = e.hasDefaultValue(a), C = x ? this.pluralResolver.getSuffix(f, a.count, a) : "", w = a.ordinal && x ? this.pluralResolver.getSuffix(f, a.count, { ordinal: !1 }) : "", T = x && !a.ordinal && a.count === 0, E = T && a[`defaultValue${this.options.pluralSeparator}zero`] || a[`defaultValue${C}`] || a[`defaultValue${w}`] || a.defaultValue, D = h;
501
- b && !h && S && (D = E);
502
- let O = N(D), k = Object.prototype.toString.apply(D);
503
- if (b && D && O && v.indexOf(k) < 0 && !(n(y) && Array.isArray(D))) {
504
- if (!a.returnObjects && !this.options.returnObjects) {
505
- this.options.returnedObjectHandler || this.logger.warn("accessing an object - but returnObjects options is not enabled!");
506
- let e = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(g, D, {
507
- ...a,
508
- ns: l
509
- }) : `key '${c} (${this.language})' returned an object instead of string.`;
510
- return o ? (m.res = e, m.usedParams = this.getUsedParamsDetails(a), m) : e;
511
- }
512
- if (s) {
513
- let e = Array.isArray(D), t = e ? [] : {}, n = e ? _ : g;
514
- for (let e in D) if (Object.prototype.hasOwnProperty.call(D, e)) {
515
- let r = `${n}${s}${e}`;
516
- S && !h ? t[e] = this.translate(r, {
517
- ...a,
518
- defaultValue: N(E) ? E[e] : void 0,
519
- joinArrays: !1,
520
- ns: l
521
- }) : t[e] = this.translate(r, {
522
- ...a,
523
- joinArrays: !1,
524
- ns: l
525
- }), t[e] === r && (t[e] = D[e]);
526
- }
527
- h = t;
528
- }
529
- } else if (b && n(y) && Array.isArray(h)) h = h.join(y), h &&= this.extendTranslation(h, t, a, i);
530
- else {
531
- let e = !1, n = !1;
532
- !this.isValidLookup(h) && S && (e = !0, h = E), this.isValidLookup(h) || (n = !0, h = c);
533
- let r = (a.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && n ? void 0 : h, o = S && E !== h && this.options.updateMissing;
534
- if (n || e || o) {
535
- if (this.logger.log(o ? "updateKey" : "missingKey", f, u, c, o ? E : h), s) {
536
- let e = this.resolve(c, {
537
- ...a,
538
- keySeparator: !1
539
- });
540
- e && e.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.");
541
- }
542
- let e = [], t = this.languageUtils.getFallbackCodes(this.options.fallbackLng, a.lng || this.language);
543
- if (this.options.saveMissingTo === "fallback" && t && t[0]) for (let n = 0; n < t.length; n++) e.push(t[n]);
544
- else this.options.saveMissingTo === "all" ? e = this.languageUtils.toResolveHierarchy(a.lng || this.language) : e.push(a.lng || this.language);
545
- let n = (e, t, n) => {
546
- let i = S && n !== h ? n : r;
547
- this.options.missingKeyHandler ? this.options.missingKeyHandler(e, u, t, i, o, a) : this.backendConnector?.saveMissing && this.backendConnector.saveMissing(e, u, t, i, o, a), this.emit("missingKey", e, u, t, h);
548
- };
549
- this.options.saveMissing && (this.options.saveMissingPlurals && x ? e.forEach((e) => {
550
- let t = this.pluralResolver.getSuffixes(e, a);
551
- T && a[`defaultValue${this.options.pluralSeparator}zero`] && t.indexOf(`${this.options.pluralSeparator}zero`) < 0 && t.push(`${this.options.pluralSeparator}zero`), t.forEach((t) => {
552
- n([e], c + t, a[`defaultValue${t}`] || E);
553
- });
554
- }) : n(e, c, E));
555
- }
556
- h = this.extendTranslation(h, t, a, m, i), n && h === c && this.options.appendNamespaceToMissingKey && (h = `${u}${d}${c}`), (n || e) && this.options.parseMissingKeyHandler && (h = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${u}${d}${c}` : c, e ? h : void 0, a));
557
- }
558
- return o ? (m.res = h, m.usedParams = this.getUsedParamsDetails(a), m) : h;
559
- }
560
- extendTranslation(e, t, r, i, a) {
561
- if (this.i18nFormat?.parse) e = this.i18nFormat.parse(e, {
562
- ...this.options.interpolation.defaultVariables,
563
- ...r
564
- }, r.lng || this.language || i.usedLng, i.usedNS, i.usedKey, { resolved: i });
565
- else if (!r.skipInterpolation) {
566
- r.interpolation && this.interpolator.init({
567
- ...r,
568
- interpolation: {
569
- ...this.options.interpolation,
570
- ...r.interpolation
571
- }
572
- });
573
- let o = n(e) && (r?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : r.interpolation.skipOnVariables), s;
574
- if (o) {
575
- let t = e.match(this.interpolator.nestingRegexp);
576
- s = t && t.length;
577
- }
578
- let c = r.replace && !n(r.replace) ? r.replace : r;
579
- if (this.options.interpolation.defaultVariables && (c = {
580
- ...this.options.interpolation.defaultVariables,
581
- ...c
582
- }), e = this.interpolator.interpolate(e, c, r.lng || this.language || i.usedLng, r), o) {
583
- let t = e.match(this.interpolator.nestingRegexp), n = t && t.length;
584
- s < n && (r.nest = !1);
585
- }
586
- !r.lng && i && i.res && (r.lng = this.language || i.usedLng), r.nest !== !1 && (e = this.interpolator.nest(e, (...e) => a?.[0] === e[0] && !r.context ? (this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`), null) : this.translate(...e, t), r)), r.interpolation && this.interpolator.reset();
587
- }
588
- let o = r.postProcess || this.options.postProcess, s = n(o) ? [o] : o;
589
- return e != null && s?.length && r.applyPostProcessor !== !1 && (e = O.handle(s, e, t, this.options && this.options.postProcessPassResolved ? {
590
- i18nResolved: {
591
- ...i,
592
- usedParams: this.getUsedParamsDetails(r)
593
- },
594
- ...r
595
- } : r, this)), e;
596
- }
597
- resolve(e, t = {}) {
598
- let r, i, a, o, s;
599
- return n(e) && (e = [e]), Array.isArray(e) && (e = e.map((e) => typeof e == "function" ? j(e, {
600
- ...this.options,
601
- ...t
602
- }) : e)), e.forEach((e) => {
603
- if (this.isValidLookup(r)) return;
604
- let c = this.extractFromKey(e, t), l = c.key;
605
- i = l;
606
- let u = c.namespaces;
607
- this.options.fallbackNS && (u = u.concat(this.options.fallbackNS));
608
- let d = t.count !== void 0 && !n(t.count), f = d && !t.ordinal && t.count === 0, p = t.context !== void 0 && (n(t.context) || typeof t.context == "number") && t.context !== "", m = t.lngs ? t.lngs : this.languageUtils.toResolveHierarchy(t.lng || this.language, t.fallbackLng);
609
- u.forEach((e) => {
610
- this.isValidLookup(r) || (s = e, !M[`${m[0]}-${e}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(s) && (M[`${m[0]}-${e}`] = !0, this.logger.warn(`key "${i}" for languages "${m.join(", ")}" won't get resolved as namespace "${s}" 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((n) => {
611
- if (this.isValidLookup(r)) return;
612
- o = n;
613
- let i = [l];
614
- if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(i, l, n, e, t);
615
- else {
616
- let e;
617
- d && (e = this.pluralResolver.getSuffix(n, t.count, t));
618
- let r = `${this.options.pluralSeparator}zero`, a = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
619
- if (d && (t.ordinal && e.indexOf(a) === 0 && i.push(l + e.replace(a, this.options.pluralSeparator)), i.push(l + e), f && i.push(l + r)), p) {
620
- let n = `${l}${this.options.contextSeparator || "_"}${t.context}`;
621
- i.push(n), d && (t.ordinal && e.indexOf(a) === 0 && i.push(n + e.replace(a, this.options.pluralSeparator)), i.push(n + e), f && i.push(n + r));
622
- }
623
- }
624
- let s;
625
- for (; s = i.pop();) this.isValidLookup(r) || (a = s, r = this.getResource(n, e, s, t));
626
- }));
627
- });
628
- }), {
629
- res: r,
630
- usedKey: i,
631
- exactUsedKey: a,
632
- usedLng: o,
633
- usedNS: s
634
- };
635
- }
636
- isValidLookup(e) {
637
- return e !== void 0 && !(!this.options.returnNull && e === null) && !(!this.options.returnEmptyString && e === "");
638
- }
639
- getResource(e, t, n, r = {}) {
640
- return this.i18nFormat?.getResource ? this.i18nFormat.getResource(e, t, n, r) : this.resourceStore.getResource(e, t, n, r);
641
- }
642
- getUsedParamsDetails(e = {}) {
643
- let t = [
644
- "defaultValue",
645
- "ordinal",
646
- "context",
647
- "replace",
648
- "lng",
649
- "lngs",
650
- "fallbackLng",
651
- "ns",
652
- "keySeparator",
653
- "nsSeparator",
654
- "returnObjects",
655
- "returnDetails",
656
- "joinArrays",
657
- "postProcess",
658
- "interpolation"
659
- ], r = e.replace && !n(e.replace), i = r ? e.replace : e;
660
- if (r && e.count !== void 0 && (i.count = e.count), this.options.interpolation.defaultVariables && (i = {
661
- ...this.options.interpolation.defaultVariables,
662
- ...i
663
- }), !r) {
664
- i = { ...i };
665
- for (let e of t) delete i[e];
666
- }
667
- return i;
668
- }
669
- static hasDefaultValue(e) {
670
- for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t) && t.substring(0, 12) === "defaultValue" && e[t] !== void 0) return !0;
671
- return !1;
672
- }
673
- }, F = class {
674
- constructor(e) {
675
- this.options = e, this.supportedLngs = this.options.supportedLngs || !1, this.logger = T.create("languageUtils");
676
- }
677
- getScriptPartFromCode(e) {
678
- if (e = C(e), !e || e.indexOf("-") < 0) return null;
679
- let t = e.split("-");
680
- return t.length === 2 || (t.pop(), t[t.length - 1].toLowerCase() === "x") ? null : this.formatLanguageCode(t.join("-"));
681
- }
682
- getLanguagePartFromCode(e) {
683
- if (e = C(e), !e || e.indexOf("-") < 0) return e;
684
- let t = e.split("-");
685
- return this.formatLanguageCode(t[0]);
686
- }
687
- formatLanguageCode(e) {
688
- if (n(e) && e.indexOf("-") > -1) {
689
- let t;
690
- try {
691
- t = Intl.getCanonicalLocales(e)[0];
692
- } catch {}
693
- return t && this.options.lowerCaseLng && (t = t.toLowerCase()), t || (this.options.lowerCaseLng ? e.toLowerCase() : e);
694
- }
695
- return this.options.cleanCode || this.options.lowerCaseLng ? e.toLowerCase() : e;
696
- }
697
- isSupportedCode(e) {
698
- return (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) && (e = this.getLanguagePartFromCode(e)), !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(e) > -1;
699
- }
700
- getBestMatchFromCodes(e) {
701
- if (!e) return null;
702
- let t;
703
- return e.forEach((e) => {
704
- if (t) return;
705
- let n = this.formatLanguageCode(e);
706
- (!this.options.supportedLngs || this.isSupportedCode(n)) && (t = n);
707
- }), !t && this.options.supportedLngs && e.forEach((e) => {
708
- if (t) return;
709
- let n = this.getScriptPartFromCode(e);
710
- if (this.isSupportedCode(n)) return t = n;
711
- let r = this.getLanguagePartFromCode(e);
712
- if (this.isSupportedCode(r)) return t = r;
713
- t = this.options.supportedLngs.find((e) => {
714
- if (e === r || !(e.indexOf("-") < 0 && r.indexOf("-") < 0) && (e.indexOf("-") > 0 && r.indexOf("-") < 0 && e.substring(0, e.indexOf("-")) === r || e.indexOf(r) === 0 && r.length > 1)) return e;
715
- });
716
- }), t ||= this.getFallbackCodes(this.options.fallbackLng)[0], t;
717
- }
718
- getFallbackCodes(e, t) {
719
- if (!e) return [];
720
- if (typeof e == "function" && (e = e(t)), n(e) && (e = [e]), Array.isArray(e)) return e;
721
- if (!t) return e.default || [];
722
- let r = e[t];
723
- return r ||= e[this.getScriptPartFromCode(t)], r ||= e[this.formatLanguageCode(t)], r ||= e[this.getLanguagePartFromCode(t)], r ||= e.default, r || [];
724
- }
725
- toResolveHierarchy(e, t) {
726
- let r = this.getFallbackCodes((t === !1 ? [] : t) || this.options.fallbackLng || [], e), i = [], a = (e) => {
727
- e && (this.isSupportedCode(e) ? i.push(e) : this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`));
728
- };
729
- return n(e) && (e.indexOf("-") > -1 || e.indexOf("_") > -1) ? (this.options.load !== "languageOnly" && a(this.formatLanguageCode(e)), this.options.load !== "languageOnly" && this.options.load !== "currentOnly" && a(this.getScriptPartFromCode(e)), this.options.load !== "currentOnly" && a(this.getLanguagePartFromCode(e))) : n(e) && a(this.formatLanguageCode(e)), r.forEach((e) => {
730
- i.indexOf(e) < 0 && a(this.formatLanguageCode(e));
731
- }), i;
732
- }
733
- }, I = {
734
- zero: 0,
735
- one: 1,
736
- two: 2,
737
- few: 3,
738
- many: 4,
739
- other: 5
740
- }, L = {
741
- select: (e) => e === 1 ? "one" : "other",
742
- resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
743
- }, R = class {
744
- constructor(e, t = {}) {
745
- this.languageUtils = e, this.options = t, this.logger = T.create("pluralResolver"), this.pluralRulesCache = {};
746
- }
747
- clearCache() {
748
- this.pluralRulesCache = {};
749
- }
750
- getRule(e, t = {}) {
751
- let n = C(e === "dev" ? "en" : e), r = t.ordinal ? "ordinal" : "cardinal", i = JSON.stringify({
752
- cleanedCode: n,
753
- type: r
754
- });
755
- if (i in this.pluralRulesCache) return this.pluralRulesCache[i];
756
- let a;
757
- try {
758
- a = new Intl.PluralRules(n, { type: r });
759
- } catch {
760
- if (typeof Intl > "u") return this.logger.error("No Intl support, please use an Intl polyfill!"), L;
761
- if (!e.match(/-|_/)) return L;
762
- let n = this.languageUtils.getLanguagePartFromCode(e);
763
- a = this.getRule(n, t);
764
- }
765
- return this.pluralRulesCache[i] = a, a;
766
- }
767
- needsPlural(e, t = {}) {
768
- let n = this.getRule(e, t);
769
- return n ||= this.getRule("dev", t), n?.resolvedOptions().pluralCategories.length > 1;
770
- }
771
- getPluralFormsOfKey(e, t, n = {}) {
772
- return this.getSuffixes(e, n).map((e) => `${t}${e}`);
773
- }
774
- getSuffixes(e, t = {}) {
775
- let n = this.getRule(e, t);
776
- return n ||= this.getRule("dev", t), n ? n.resolvedOptions().pluralCategories.sort((e, t) => I[e] - I[t]).map((e) => `${this.options.prepend}${t.ordinal ? `ordinal${this.options.prepend}` : ""}${e}`) : [];
777
- }
778
- getSuffix(e, t, n = {}) {
779
- let r = this.getRule(e, n);
780
- return r ? `${this.options.prepend}${n.ordinal ? `ordinal${this.options.prepend}` : ""}${r.select(t)}` : (this.logger.warn(`no plural rule found for: ${e}`), this.getSuffix("dev", t, n));
781
- }
782
- }, z = (e, t, r, i = ".", a = !0) => {
783
- let o = p(e, t, r);
784
- return !o && a && n(r) && (o = S(e, r, i), o === void 0 && (o = S(t, r, i))), o;
785
- }, B = (e) => e.replace(/\$/g, "$$$$"), V = class {
786
- constructor(e = {}) {
787
- this.logger = T.create("interpolator"), this.options = e, this.format = e?.interpolation?.format || ((e) => e), this.init(e);
788
- }
789
- init(e = {}) {
790
- e.interpolation ||= { escapeValue: !0 };
791
- let { escape: t, escapeValue: n, useRawValueToEscape: r, prefix: i, prefixEscaped: a, suffix: o, suffixEscaped: s, formatSeparator: c, unescapeSuffix: l, unescapePrefix: u, nestingPrefix: d, nestingPrefixEscaped: f, nestingSuffix: p, nestingSuffixEscaped: m, nestingOptionsSeparator: g, maxReplaces: v, alwaysFormat: y } = e.interpolation;
792
- this.escape = t === void 0 ? _ : t, this.escapeValue = n === void 0 ? !0 : n, this.useRawValueToEscape = r === void 0 ? !1 : r, this.prefix = i ? h(i) : a || "{{", this.suffix = o ? h(o) : s || "}}", this.formatSeparator = c || ",", this.unescapePrefix = l ? "" : u || "-", this.unescapeSuffix = this.unescapePrefix ? "" : l || "", this.nestingPrefix = d ? h(d) : f || h("$t("), this.nestingSuffix = p ? h(p) : m || h(")"), this.nestingOptionsSeparator = g || ",", this.maxReplaces = v || 1e3, this.alwaysFormat = y === void 0 ? !1 : y, this.resetRegExp();
793
- }
794
- reset() {
795
- this.options && this.init(this.options);
796
- }
797
- resetRegExp() {
798
- let e = (e, t) => e?.source === t ? (e.lastIndex = 0, e) : new RegExp(t, "g");
799
- 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}`);
800
- }
801
- interpolate(e, t, r, a) {
802
- let o, s, c, l = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {}, u = (e) => {
803
- if (e.indexOf(this.formatSeparator) < 0) {
804
- let n = z(t, l, e, this.options.keySeparator, this.options.ignoreJSONStructure);
805
- return this.alwaysFormat ? this.format(n, void 0, r, {
806
- ...a,
807
- ...t,
808
- interpolationkey: e
809
- }) : n;
810
- }
811
- let n = e.split(this.formatSeparator), i = n.shift().trim(), o = n.join(this.formatSeparator).trim();
812
- return this.format(z(t, l, i, this.options.keySeparator, this.options.ignoreJSONStructure), o, r, {
813
- ...a,
814
- ...t,
815
- interpolationkey: i
816
- });
817
- };
818
- this.resetRegExp();
819
- let d = a?.missingInterpolationHandler || this.options.missingInterpolationHandler, f = a?.interpolation?.skipOnVariables === void 0 ? this.options.interpolation.skipOnVariables : a.interpolation.skipOnVariables;
820
- return [{
821
- regex: this.regexpUnescape,
822
- safeValue: (e) => B(e)
823
- }, {
824
- regex: this.regexp,
825
- safeValue: (e) => this.escapeValue ? B(this.escape(e)) : B(e)
826
- }].forEach((t) => {
827
- for (c = 0; o = t.regex.exec(e);) {
828
- let r = o[1].trim();
829
- if (s = u(r), s === void 0) if (typeof d == "function") {
830
- let t = d(e, o, a);
831
- s = n(t) ? t : "";
832
- } else if (a && Object.prototype.hasOwnProperty.call(a, r)) s = "";
833
- else if (f) {
834
- s = o[0];
835
- continue;
836
- } else this.logger.warn(`missed to pass in variable ${r} for interpolating ${e}`), s = "";
837
- else !n(s) && !this.useRawValueToEscape && (s = i(s));
838
- let l = t.safeValue(s);
839
- if (e = e.replace(o[0], l), f ? (t.regex.lastIndex += s.length, t.regex.lastIndex -= o[0].length) : t.regex.lastIndex = 0, c++, c >= this.maxReplaces) break;
840
- }
841
- }), e;
842
- }
843
- nest(e, t, r = {}) {
844
- let a, o, s, c = (e, t) => {
845
- let n = this.nestingOptionsSeparator;
846
- if (e.indexOf(n) < 0) return e;
847
- let r = e.split(RegExp(`${h(n)}[ ]*{`)), i = `{${r[1]}`;
848
- e = r[0], i = this.interpolate(i, s);
849
- let a = i.match(/'/g), o = i.match(/"/g);
850
- ((a?.length ?? 0) % 2 == 0 && !o || (o?.length ?? 0) % 2 != 0) && (i = i.replace(/'/g, "\""));
851
- try {
852
- s = JSON.parse(i), t && (s = {
853
- ...t,
854
- ...s
855
- });
856
- } catch (t) {
857
- return this.logger.warn(`failed parsing options string in nesting for key ${e}`, t), `${e}${n}${i}`;
858
- }
859
- return s.defaultValue && s.defaultValue.indexOf(this.prefix) > -1 && delete s.defaultValue, e;
860
- };
861
- for (; a = this.nestingRegexp.exec(e);) {
862
- let l = [];
863
- s = { ...r }, s = s.replace && !n(s.replace) ? s.replace : s, s.applyPostProcessor = !1, delete s.defaultValue;
864
- let u = /{.*}/.test(a[1]) ? a[1].lastIndexOf("}") + 1 : a[1].indexOf(this.formatSeparator);
865
- if (u !== -1 && (l = a[1].slice(u).split(this.formatSeparator).map((e) => e.trim()).filter(Boolean), a[1] = a[1].slice(0, u)), o = t(c.call(this, a[1].trim(), s), s), o && a[0] === e && !n(o)) return o;
866
- n(o) || (o = i(o)), o ||= (this.logger.warn(`missed to resolve ${a[1]} for nesting ${e}`), ""), l.length && (o = l.reduce((e, t) => this.format(e, t, r.lng, {
867
- ...r,
868
- interpolationkey: a[1].trim()
869
- }), o.trim())), e = e.replace(a[0], o), this.regexp.lastIndex = 0;
870
- }
871
- return e;
872
- }
873
- }, H = (e) => {
874
- let t = e.toLowerCase().trim(), n = {};
875
- if (e.indexOf("(") > -1) {
876
- let r = e.split("(");
877
- t = r[0].toLowerCase().trim();
878
- let i = r[1].substring(0, r[1].length - 1);
879
- t === "currency" && i.indexOf(":") < 0 ? n.currency ||= i.trim() : t === "relativetime" && i.indexOf(":") < 0 ? n.range ||= i.trim() : i.split(";").forEach((e) => {
880
- if (e) {
881
- let [t, ...r] = e.split(":"), i = r.join(":").trim().replace(/^'+|'+$/g, ""), a = t.trim();
882
- n[a] || (n[a] = i), i === "false" && (n[a] = !1), i === "true" && (n[a] = !0), isNaN(i) || (n[a] = parseInt(i, 10));
883
- }
884
- });
885
- }
886
- return {
887
- formatName: t,
888
- formatOptions: n
889
- };
890
- }, U = (e) => {
891
- let t = {};
892
- return (n, r, i) => {
893
- let a = i;
894
- i && i.interpolationkey && i.formatParams && i.formatParams[i.interpolationkey] && i[i.interpolationkey] && (a = {
895
- ...a,
896
- [i.interpolationkey]: void 0
897
- });
898
- let o = r + JSON.stringify(a), s = t[o];
899
- return s || (s = e(C(r), i), t[o] = s), s(n);
900
- };
901
- }, W = (e) => (t, n, r) => e(C(n), r)(t), G = class {
902
- constructor(e = {}) {
903
- this.logger = T.create("formatter"), this.options = e, this.init(e);
904
- }
905
- init(e, t = { interpolation: {} }) {
906
- this.formatSeparator = t.interpolation.formatSeparator || ",";
907
- let n = t.cacheInBuiltFormats ? U : W;
908
- this.formats = {
909
- number: n((e, t) => {
910
- let n = new Intl.NumberFormat(e, { ...t });
911
- return (e) => n.format(e);
912
- }),
913
- currency: n((e, t) => {
914
- let n = new Intl.NumberFormat(e, {
915
- ...t,
916
- style: "currency"
917
- });
918
- return (e) => n.format(e);
919
- }),
920
- datetime: n((e, t) => {
921
- let n = new Intl.DateTimeFormat(e, { ...t });
922
- return (e) => n.format(e);
923
- }),
924
- relativetime: n((e, t) => {
925
- let n = new Intl.RelativeTimeFormat(e, { ...t });
926
- return (e) => n.format(e, t.range || "day");
927
- }),
928
- list: n((e, t) => {
929
- let n = new Intl.ListFormat(e, { ...t });
930
- return (e) => n.format(e);
931
- })
932
- };
933
- }
934
- add(e, t) {
935
- this.formats[e.toLowerCase().trim()] = t;
936
- }
937
- addCached(e, t) {
938
- this.formats[e.toLowerCase().trim()] = U(t);
939
- }
940
- format(e, t, n, r = {}) {
941
- let i = t.split(this.formatSeparator);
942
- if (i.length > 1 && i[0].indexOf("(") > 1 && i[0].indexOf(")") < 0 && i.find((e) => e.indexOf(")") > -1)) {
943
- let e = i.findIndex((e) => e.indexOf(")") > -1);
944
- i[0] = [i[0], ...i.splice(1, e)].join(this.formatSeparator);
945
- }
946
- return i.reduce((e, t) => {
947
- let { formatName: i, formatOptions: a } = H(t);
948
- if (this.formats[i]) {
949
- let t = e;
950
- try {
951
- let o = r?.formatParams?.[r.interpolationkey] || {}, s = o.locale || o.lng || r.locale || r.lng || n;
952
- t = this.formats[i](e, s, {
953
- ...a,
954
- ...r,
955
- ...o
956
- });
957
- } catch (e) {
958
- this.logger.warn(e);
959
- }
960
- return t;
961
- } else this.logger.warn(`there was no format function for ${i}`);
962
- return e;
963
- }, e);
964
- }
965
- }, K = (e, t) => {
966
- e.pending[t] !== void 0 && (delete e.pending[t], e.pendingCount--);
967
- }, q = class extends E {
968
- constructor(e, t, n, r = {}) {
969
- super(), this.backend = e, this.store = t, this.services = n, this.languageUtils = n.languageUtils, this.options = r, this.logger = T.create("backendConnector"), this.waitingReads = [], this.maxParallelReads = r.maxParallelReads || 10, this.readingCalls = 0, this.maxRetries = r.maxRetries >= 0 ? r.maxRetries : 5, this.retryTimeout = r.retryTimeout >= 1 ? r.retryTimeout : 350, this.state = {}, this.queue = [], this.backend?.init?.(n, r.backend, r);
970
- }
971
- queueLoad(e, t, n, r) {
972
- let i = {}, a = {}, o = {}, s = {};
973
- return e.forEach((e) => {
974
- let r = !0;
975
- t.forEach((t) => {
976
- let o = `${e}|${t}`;
977
- !n.reload && this.store.hasResourceBundle(e, t) ? this.state[o] = 2 : this.state[o] < 0 || (this.state[o] === 1 ? a[o] === void 0 && (a[o] = !0) : (this.state[o] = 1, r = !1, a[o] === void 0 && (a[o] = !0), i[o] === void 0 && (i[o] = !0), s[t] === void 0 && (s[t] = !0)));
978
- }), r || (o[e] = !0);
979
- }), (Object.keys(i).length || Object.keys(a).length) && this.queue.push({
980
- pending: a,
981
- pendingCount: Object.keys(a).length,
982
- loaded: {},
983
- errors: [],
984
- callback: r
985
- }), {
986
- toLoad: Object.keys(i),
987
- pending: Object.keys(a),
988
- toLoadLanguages: Object.keys(o),
989
- toLoadNamespaces: Object.keys(s)
990
- };
991
- }
992
- loaded(e, t, n) {
993
- let r = e.split("|"), i = r[0], a = r[1];
994
- t && this.emit("failedLoading", i, a, t), !t && n && this.store.addResourceBundle(i, a, n, void 0, void 0, { skipCopy: !0 }), this.state[e] = t ? -1 : 2, t && n && (this.state[e] = 0);
995
- let o = {};
996
- this.queue.forEach((n) => {
997
- d(n.loaded, [i], a), K(n, e), t && n.errors.push(t), n.pendingCount === 0 && !n.done && (Object.keys(n.loaded).forEach((e) => {
998
- o[e] || (o[e] = {});
999
- let t = n.loaded[e];
1000
- t.length && t.forEach((t) => {
1001
- o[e][t] === void 0 && (o[e][t] = !0);
1002
- });
1003
- }), n.done = !0, n.errors.length ? n.callback(n.errors) : n.callback());
1004
- }), this.emit("loaded", o), this.queue = this.queue.filter((e) => !e.done);
1005
- }
1006
- read(e, t, n, r = 0, i = this.retryTimeout, a) {
1007
- if (!e.length) return a(null, {});
1008
- if (this.readingCalls >= this.maxParallelReads) {
1009
- this.waitingReads.push({
1010
- lng: e,
1011
- ns: t,
1012
- fcName: n,
1013
- tried: r,
1014
- wait: i,
1015
- callback: a
1016
- });
1017
- return;
1018
- }
1019
- this.readingCalls++;
1020
- let o = (o, s) => {
1021
- if (this.readingCalls--, this.waitingReads.length > 0) {
1022
- let e = this.waitingReads.shift();
1023
- this.read(e.lng, e.ns, e.fcName, e.tried, e.wait, e.callback);
1024
- }
1025
- if (o && s && r < this.maxRetries) {
1026
- setTimeout(() => {
1027
- this.read.call(this, e, t, n, r + 1, i * 2, a);
1028
- }, i);
1029
- return;
1030
- }
1031
- a(o, s);
1032
- }, s = this.backend[n].bind(this.backend);
1033
- if (s.length === 2) {
1034
- try {
1035
- let n = s(e, t);
1036
- n && typeof n.then == "function" ? n.then((e) => o(null, e)).catch(o) : o(null, n);
1037
- } catch (e) {
1038
- o(e);
1039
- }
1040
- return;
1041
- }
1042
- return s(e, t, o);
1043
- }
1044
- prepareLoading(e, t, r = {}, i) {
1045
- if (!this.backend) return this.logger.warn("No backend was added via i18next.use. Will not load resources."), i && i();
1046
- n(e) && (e = this.languageUtils.toResolveHierarchy(e)), n(t) && (t = [t]);
1047
- let a = this.queueLoad(e, t, r, i);
1048
- if (!a.toLoad.length) return a.pending.length || i(), null;
1049
- a.toLoad.forEach((e) => {
1050
- this.loadOne(e);
1051
- });
1052
- }
1053
- load(e, t, n) {
1054
- this.prepareLoading(e, t, {}, n);
1055
- }
1056
- reload(e, t, n) {
1057
- this.prepareLoading(e, t, { reload: !0 }, n);
1058
- }
1059
- loadOne(e, t = "") {
1060
- let n = e.split("|"), r = n[0], i = n[1];
1061
- this.read(r, i, "read", void 0, void 0, (n, a) => {
1062
- n && this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`, n), !n && a && this.logger.log(`${t}loaded namespace ${i} for language ${r}`, a), this.loaded(e, n, a);
1063
- });
1064
- }
1065
- saveMissing(e, t, n, r, i, a = {}, o = () => {}) {
1066
- if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(t)) {
1067
- this.logger.warn(`did not save key "${n}" 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!!!");
1068
- return;
1069
- }
1070
- if (!(n == null || n === "")) {
1071
- if (this.backend?.create) {
1072
- let s = {
1073
- ...a,
1074
- isUpdate: i
1075
- }, c = this.backend.create.bind(this.backend);
1076
- if (c.length < 6) try {
1077
- let i;
1078
- i = c.length === 5 ? c(e, t, n, r, s) : c(e, t, n, r), i && typeof i.then == "function" ? i.then((e) => o(null, e)).catch(o) : o(null, i);
1079
- } catch (e) {
1080
- o(e);
1081
- }
1082
- else c(e, t, n, r, o, s);
1083
- }
1084
- !e || !e[0] || this.store.addResource(e[0], t, n, r);
1085
- }
1086
- }
1087
- }, J = () => ({
1088
- debug: !1,
1089
- initAsync: !0,
1090
- ns: ["translation"],
1091
- defaultNS: ["translation"],
1092
- fallbackLng: ["dev"],
1093
- fallbackNS: !1,
1094
- supportedLngs: !1,
1095
- nonExplicitSupportedLngs: !1,
1096
- load: "all",
1097
- preload: !1,
1098
- simplifyPluralSuffix: !0,
1099
- keySeparator: ".",
1100
- nsSeparator: ":",
1101
- pluralSeparator: "_",
1102
- contextSeparator: "_",
1103
- partialBundledLanguages: !1,
1104
- saveMissing: !1,
1105
- updateMissing: !1,
1106
- saveMissingTo: "fallback",
1107
- saveMissingPlurals: !0,
1108
- missingKeyHandler: !1,
1109
- missingInterpolationHandler: !1,
1110
- postProcess: !1,
1111
- postProcessPassResolved: !1,
1112
- returnNull: !1,
1113
- returnEmptyString: !0,
1114
- returnObjects: !1,
1115
- joinArrays: !1,
1116
- returnedObjectHandler: !1,
1117
- parseMissingKeyHandler: !1,
1118
- appendNamespaceToMissingKey: !1,
1119
- appendNamespaceToCIMode: !1,
1120
- overloadTranslationOptionHandler: (e) => {
1121
- let t = {};
1122
- if (typeof e[1] == "object" && (t = e[1]), n(e[1]) && (t.defaultValue = e[1]), n(e[2]) && (t.tDescription = e[2]), typeof e[2] == "object" || typeof e[3] == "object") {
1123
- let n = e[3] || e[2];
1124
- Object.keys(n).forEach((e) => {
1125
- t[e] = n[e];
1126
- });
1127
- }
1128
- return t;
1129
- },
1130
- interpolation: {
1131
- escapeValue: !0,
1132
- format: (e) => e,
1133
- prefix: "{{",
1134
- suffix: "}}",
1135
- formatSeparator: ",",
1136
- unescapePrefix: "-",
1137
- nestingPrefix: "$t(",
1138
- nestingSuffix: ")",
1139
- nestingOptionsSeparator: ",",
1140
- maxReplaces: 1e3,
1141
- skipOnVariables: !0
1142
- },
1143
- cacheInBuiltFormats: !0
1144
- }), Y = (e) => (n(e.ns) && (e.ns = [e.ns]), n(e.fallbackLng) && (e.fallbackLng = [e.fallbackLng]), n(e.fallbackNS) && (e.fallbackNS = [e.fallbackNS]), e.supportedLngs?.indexOf?.("cimode") < 0 && (e.supportedLngs = e.supportedLngs.concat(["cimode"])), typeof e.initImmediate == "boolean" && (e.initAsync = e.initImmediate), e), X = () => {}, Z = (e) => {
1145
- Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach((t) => {
1146
- typeof e[t] == "function" && (e[t] = e[t].bind(e));
1147
- });
1148
- }, Q = "__i18next_supportNoticeShown", ee = () => !!(typeof globalThis < "u" && globalThis[Q] || typeof process < "u" && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE || typeof process < "u" && process.env), te = () => {
1149
- typeof globalThis < "u" && (globalThis[Q] = !0);
1150
- }, ne = (e) => !!(e?.modules?.backend?.name?.indexOf("Locize") > 0 || e?.modules?.backend?.constructor?.name?.indexOf("Locize") > 0 || e?.options?.backend?.backends && e.options.backend.backends.some((e) => e?.name?.indexOf("Locize") > 0 || e?.constructor?.name?.indexOf("Locize") > 0) || e?.options?.backend?.projectId || e?.options?.backend?.backendOptions && e.options.backend.backendOptions.some((e) => e?.projectId)), $ = class e extends E {
1151
- constructor(e = {}, t) {
1152
- if (super(), this.options = Y(e), this.services = {}, this.logger = T, this.modules = { external: [] }, Z(this), t && !this.isInitialized && !e.isClone) {
1153
- if (!this.options.initAsync) return this.init(e, t), this;
1154
- setTimeout(() => {
1155
- this.init(e, t);
1156
- }, 0);
1157
- }
1158
- }
1159
- init(e = {}, t) {
1160
- this.isInitializing = !0, typeof e == "function" && (t = e, e = {}), e.defaultNS == null && e.ns && (n(e.ns) ? e.defaultNS = e.ns : e.ns.indexOf("translation") < 0 && (e.defaultNS = e.ns[0]));
1161
- let i = J();
1162
- this.options = {
1163
- ...i,
1164
- ...this.options,
1165
- ...Y(e)
1166
- }, this.options.interpolation = {
1167
- ...i.interpolation,
1168
- ...this.options.interpolation
1169
- }, 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), this.options.showSupportNotice !== !1 && !ne(this) && !ee() && (typeof console < "u" && console.info !== void 0 && console.info("🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙"), te());
1170
- let a = (e) => e ? typeof e == "function" ? new e() : e : null;
1171
- if (!this.options.isClone) {
1172
- this.modules.logger ? T.init(a(this.modules.logger), this.options) : T.init(null, this.options);
1173
- let e;
1174
- e = this.modules.formatter ? this.modules.formatter : G;
1175
- let t = new F(this.options);
1176
- this.store = new D(this.options.resources, this.options);
1177
- let n = this.services;
1178
- n.logger = T, n.resourceStore = this.store, n.languageUtils = t, n.pluralResolver = new R(t, {
1179
- prepend: this.options.pluralSeparator,
1180
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1181
- }), 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"), e && (!this.options.interpolation.format || this.options.interpolation.format === i.interpolation.format) && (n.formatter = a(e), n.formatter.init && n.formatter.init(n, this.options), this.options.interpolation.format = n.formatter.format.bind(n.formatter)), n.interpolator = new V(this.options), n.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) }, n.backendConnector = new q(a(this.modules.backend), n.resourceStore, n, this.options), n.backendConnector.on("*", (e, ...t) => {
1182
- this.emit(e, ...t);
1183
- }), this.modules.languageDetector && (n.languageDetector = a(this.modules.languageDetector), n.languageDetector.init && n.languageDetector.init(n, this.options.detection, this.options)), this.modules.i18nFormat && (n.i18nFormat = a(this.modules.i18nFormat), n.i18nFormat.init && n.i18nFormat.init(this)), this.translator = new P(this.services, this.options), this.translator.on("*", (e, ...t) => {
1184
- this.emit(e, ...t);
1185
- }), this.modules.external.forEach((e) => {
1186
- e.init && e.init(this);
1187
- });
1188
- }
1189
- if (this.format = this.options.interpolation.format, t ||= X, this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1190
- let e = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1191
- e.length > 0 && e[0] !== "dev" && (this.options.lng = e[0]);
1192
- }
1193
- !this.services.languageDetector && !this.options.lng && this.logger.warn("init: no languageDetector is used and no lng is defined"), [
1194
- "getResource",
1195
- "hasResourceBundle",
1196
- "getResourceBundle",
1197
- "getDataByLanguage"
1198
- ].forEach((e) => {
1199
- this[e] = (...t) => this.store[e](...t);
1200
- }), [
1201
- "addResource",
1202
- "addResources",
1203
- "addResourceBundle",
1204
- "removeResourceBundle"
1205
- ].forEach((e) => {
1206
- this[e] = (...t) => (this.store[e](...t), this);
1207
- });
1208
- let o = r(), s = () => {
1209
- let e = (e, n) => {
1210
- 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), o.resolve(n), t(e, n);
1211
- };
1212
- if (this.languages && !this.isInitialized) return e(null, this.t.bind(this));
1213
- this.changeLanguage(this.options.lng, e);
1214
- };
1215
- return this.options.resources || !this.options.initAsync ? s() : setTimeout(s, 0), o;
1216
- }
1217
- loadResources(e, t = X) {
1218
- let r = t, i = n(e) ? e : this.language;
1219
- if (typeof e == "function" && (r = e), !this.options.resources || this.options.partialBundledLanguages) {
1220
- if (i?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return r();
1221
- let e = [], t = (t) => {
1222
- t && t !== "cimode" && this.services.languageUtils.toResolveHierarchy(t).forEach((t) => {
1223
- t !== "cimode" && e.indexOf(t) < 0 && e.push(t);
1224
- });
1225
- };
1226
- i ? t(i) : this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((e) => t(e)), this.options.preload?.forEach?.((e) => t(e)), this.services.backendConnector.load(e, this.options.ns, (e) => {
1227
- !e && !this.resolvedLanguage && this.language && this.setResolvedLanguage(this.language), r(e);
1228
- });
1229
- } else r(null);
1230
- }
1231
- reloadResources(e, t, n) {
1232
- let i = r();
1233
- return typeof e == "function" && (n = e, e = void 0), typeof t == "function" && (n = t, t = void 0), e ||= this.languages, t ||= this.options.ns, n ||= X, this.services.backendConnector.reload(e, t, (e) => {
1234
- i.resolve(), n(e);
1235
- }), i;
1236
- }
1237
- use(e) {
1238
- if (!e) throw Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1239
- if (!e.type) throw Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1240
- 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" && O.addPostProcessor(e), e.type === "formatter" && (this.modules.formatter = e), e.type === "3rdParty" && this.modules.external.push(e), this;
1241
- }
1242
- setResolvedLanguage(e) {
1243
- if (!(!e || !this.languages) && !(["cimode", "dev"].indexOf(e) > -1)) {
1244
- for (let e = 0; e < this.languages.length; e++) {
1245
- let t = this.languages[e];
1246
- if (!(["cimode", "dev"].indexOf(t) > -1) && this.store.hasLanguageSomeTranslations(t)) {
1247
- this.resolvedLanguage = t;
1248
- break;
1249
- }
1250
- }
1251
- !this.resolvedLanguage && this.languages.indexOf(e) < 0 && this.store.hasLanguageSomeTranslations(e) && (this.resolvedLanguage = e, this.languages.unshift(e));
1252
- }
1253
- }
1254
- changeLanguage(e, t) {
1255
- this.isLanguageChangingTo = e;
1256
- let i = r();
1257
- this.emit("languageChanging", e);
1258
- let a = (e) => {
1259
- this.language = e, this.languages = this.services.languageUtils.toResolveHierarchy(e), this.resolvedLanguage = void 0, this.setResolvedLanguage(e);
1260
- }, o = (n, r) => {
1261
- r ? this.isLanguageChangingTo === e && (a(r), this.translator.changeLanguage(r), this.isLanguageChangingTo = void 0, this.emit("languageChanged", r), this.logger.log("languageChanged", r)) : this.isLanguageChangingTo = void 0, i.resolve((...e) => this.t(...e)), t && t(n, (...e) => this.t(...e));
1262
- }, s = (t) => {
1263
- !e && !t && this.services.languageDetector && (t = []);
1264
- let r = n(t) ? t : t && t[0], i = this.store.hasLanguageSomeTranslations(r) ? r : this.services.languageUtils.getBestMatchFromCodes(n(t) ? [t] : t);
1265
- i && (this.language || a(i), this.translator.language || this.translator.changeLanguage(i), this.services.languageDetector?.cacheUserLanguage?.(i)), this.loadResources(i, (e) => {
1266
- o(e, i);
1267
- });
1268
- };
1269
- return !e && this.services.languageDetector && !this.services.languageDetector.async ? s(this.services.languageDetector.detect()) : !e && this.services.languageDetector && this.services.languageDetector.async ? this.services.languageDetector.detect.length === 0 ? this.services.languageDetector.detect().then(s) : this.services.languageDetector.detect(s) : s(e), i;
1270
- }
1271
- getFixedT(e, t, r) {
1272
- let i = (e, t, ...n) => {
1273
- let a;
1274
- a = typeof t == "object" ? { ...t } : this.options.overloadTranslationOptionHandler([e, t].concat(n)), a.lng = a.lng || i.lng, a.lngs = a.lngs || i.lngs, a.ns = a.ns || i.ns, a.keyPrefix !== "" && (a.keyPrefix = a.keyPrefix || r || i.keyPrefix);
1275
- let o = {
1276
- ...this.options,
1277
- ...a
1278
- };
1279
- typeof a.keyPrefix == "function" && (a.keyPrefix = j(a.keyPrefix, o));
1280
- let s = this.options.keySeparator || ".", c;
1281
- return a.keyPrefix && Array.isArray(e) ? c = e.map((e) => (typeof e == "function" && (e = j(e, o)), `${a.keyPrefix}${s}${e}`)) : (typeof e == "function" && (e = j(e, o)), c = a.keyPrefix ? `${a.keyPrefix}${s}${e}` : e), this.t(c, a);
1282
- };
1283
- return n(e) ? i.lng = e : i.lngs = e, i.ns = t, i.keyPrefix = r, i;
1284
- }
1285
- t(...e) {
1286
- return this.translator?.translate(...e);
1287
- }
1288
- exists(...e) {
1289
- return this.translator?.exists(...e);
1290
- }
1291
- setDefaultNamespace(e) {
1292
- this.options.defaultNS = e;
1293
- }
1294
- hasLoadedNamespace(e, t = {}) {
1295
- if (!this.isInitialized) return this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages), !1;
1296
- if (!this.languages || !this.languages.length) return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages), !1;
1297
- let n = t.lng || this.resolvedLanguage || this.languages[0], r = this.options ? this.options.fallbackLng : !1, i = this.languages[this.languages.length - 1];
1298
- if (n.toLowerCase() === "cimode") return !0;
1299
- let a = (e, t) => {
1300
- let n = this.services.backendConnector.state[`${e}|${t}`];
1301
- return n === -1 || n === 0 || n === 2;
1302
- };
1303
- if (t.precheck) {
1304
- let e = t.precheck(this, a);
1305
- if (e !== void 0) return e;
1306
- }
1307
- return !!(this.hasResourceBundle(n, e) || !this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages || a(n, e) && (!r || a(i, e)));
1308
- }
1309
- loadNamespaces(e, t) {
1310
- let i = r();
1311
- return this.options.ns ? (n(e) && (e = [e]), e.forEach((e) => {
1312
- this.options.ns.indexOf(e) < 0 && this.options.ns.push(e);
1313
- }), this.loadResources((e) => {
1314
- i.resolve(), t && t(e);
1315
- }), i) : (t && t(), Promise.resolve());
1316
- }
1317
- loadLanguages(e, t) {
1318
- let i = r();
1319
- n(e) && (e = [e]);
1320
- let a = this.options.preload || [], o = e.filter((e) => a.indexOf(e) < 0 && this.services.languageUtils.isSupportedCode(e));
1321
- return o.length ? (this.options.preload = a.concat(o), this.loadResources((e) => {
1322
- i.resolve(), t && t(e);
1323
- }), i) : (t && t(), Promise.resolve());
1324
- }
1325
- dir(e) {
1326
- if (e ||= this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language), !e) return "rtl";
1327
- try {
1328
- let t = new Intl.Locale(e);
1329
- if (t && t.getTextInfo) {
1330
- let e = t.getTextInfo();
1331
- if (e && e.direction) return e.direction;
1332
- }
1333
- } catch {}
1334
- let t = /* @__PURE__ */ "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".split("."), n = this.services?.languageUtils || new F(J());
1335
- return e.toLowerCase().indexOf("-latn") > 1 ? "ltr" : t.indexOf(n.getLanguagePartFromCode(e)) > -1 || e.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1336
- }
1337
- static createInstance(t = {}, n) {
1338
- let r = new e(t, n);
1339
- return r.createInstance = e.createInstance, r;
1340
- }
1341
- cloneInstance(t = {}, n = X) {
1342
- let r = t.forkResourceStore;
1343
- r && delete t.forkResourceStore;
1344
- let i = {
1345
- ...this.options,
1346
- ...t,
1347
- isClone: !0
1348
- }, a = new e(i);
1349
- if ((t.debug !== void 0 || t.prefix !== void 0) && (a.logger = a.logger.clone(t)), [
1350
- "store",
1351
- "services",
1352
- "language"
1353
- ].forEach((e) => {
1354
- a[e] = this[e];
1355
- }), a.services = { ...this.services }, a.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, r && (a.store = new D(Object.keys(this.store.data).reduce((e, t) => (e[t] = { ...this.store.data[t] }, e[t] = Object.keys(e[t]).reduce((n, r) => (n[r] = { ...e[t][r] }, n), e[t]), e), {}), i), a.services.resourceStore = a.store), t.interpolation) {
1356
- let e = {
1357
- ...J().interpolation,
1358
- ...this.options.interpolation,
1359
- ...t.interpolation
1360
- }, n = {
1361
- ...i,
1362
- interpolation: e
1363
- };
1364
- a.services.interpolator = new V(n);
1365
- }
1366
- return a.translator = new P(a.services, i), a.translator.on("*", (e, ...t) => {
1367
- a.emit(e, ...t);
1368
- }), a.init(i, n), a.translator.options = i, a.translator.backendConnector.services.utils = { hasLoadedNamespace: a.hasLoadedNamespace.bind(a) }, a;
1369
- }
1370
- toJSON() {
1371
- return {
1372
- options: this.options,
1373
- store: this.store,
1374
- language: this.language,
1375
- languages: this.languages,
1376
- resolvedLanguage: this.resolvedLanguage
1377
- };
1378
- }
1379
- }.createInstance();
1380
- //#endregion
1381
- //#region ../../lib-react/translator/dist/index.js
1382
- $.createInstance, $.dir, $.init, $.loadResources, $.reloadResources, $.use, $.changeLanguage, $.getFixedT, $.t, $.exists, $.setDefaultNamespace, $.hasLoadedNamespace, $.loadNamespaces, $.loadLanguages, $.init({
1383
- fallbackLng: "en",
1384
- lng: "en",
1385
- debug: !0,
1386
- resources: {
1387
- en: e,
1388
- es: t
1389
- }
1390
- });
1391
- var re = {
1392
- translator: {
1393
- ...$,
1394
- t: (e, t) => {
1395
- let { lng: n } = t;
1396
- switch (n) {
1397
- case "en_US":
1398
- case "en-US":
1399
- t.lng = "en";
1400
- break;
1401
- case "es_ES":
1402
- case "es-ES":
1403
- case "es_MX":
1404
- case "es-MX":
1405
- t.lng = "es";
1406
- break;
1407
- default: break;
1408
- }
1409
- return $.t(e, {
1410
- lng: n,
1411
- ...t
1412
- });
1413
- }
1414
- },
1415
- languageOptions: [{
1416
- value: "en_US",
1417
- label: "English (US)"
1418
- }, {
1419
- value: "es_ES",
1420
- label: "Spanish"
1421
- }]
1422
- };
1423
- //#endregion
1424
- export { re as t };
1425
-
1426
- //# sourceMappingURL=dist-D9ARZhQk.js.map