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