@incodetech/web 2.0.1 → 2.1.0-rc.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 (253) hide show
  1. package/dist/ae-signature/ae-signature.es.js +15 -13
  2. package/dist/ae-signature/styles.css +3 -17
  3. package/dist/ae-signature/styles2.css +15 -5
  4. package/dist/aligndevicelottie-DY_bX_p8.js +12769 -0
  5. package/dist/antifraud/antifraud.es.js +23 -16
  6. package/dist/authentication/authentication.es.js +42 -27
  7. package/dist/autoFocusTitle-BzkUiELM.js +29 -0
  8. package/dist/{back-horizontal-hint-B8Brxh3U.js → back-horizontal-hint-D_8LptLm.js} +26 -26
  9. package/dist/back-tutorial-vb1MxlrT.js +14597 -0
  10. package/dist/{back-vertical-hint-BBo36dxn.js → back-vertical-hint-C1evxxq2.js} +27 -27
  11. package/dist/backdevicelottie-HypPqBz7.js +16690 -0
  12. package/dist/base.css +1258 -104
  13. package/dist/blurdevicelottie-CBXtBFiJ.js +15951 -0
  14. package/dist/bottomSheet-F1GJfQx_.js +39 -0
  15. package/dist/browser-ponyfill-CLLvZCVg.js +441 -0
  16. package/dist/button-CM_hgyIP.js +35 -0
  17. package/dist/checkbox-BoeLHKgp.js +96 -0
  18. package/dist/consent/consent.es.js +89 -73
  19. package/dist/consent/styles.css +35 -22
  20. package/dist/countrySelector-mSWyHSy4.js +60 -0
  21. package/dist/cpf-ocr/cpf-ocr.es.js +2 -0
  22. package/dist/cpfOcr-MtpRztkG.js +92 -0
  23. package/dist/cpfOcr-jJkYCfsX.js +2 -0
  24. package/dist/cross-document-data-match/cross-document-data-match.es.js +20 -16
  25. package/dist/curp-validation/curp-validation.es.js +247 -203
  26. package/dist/customFields-DXXt9HGM.js +140 -0
  27. package/dist/customWatchlist-DsW04UF6.js +36 -0
  28. package/dist/dateInputComposed-C_mh4XBg.js +69 -0
  29. package/dist/dateInputComposed-Cy6a7ymh.js +1 -0
  30. package/dist/defineProperty-mefzVtTv.js +39 -0
  31. package/dist/document-capture/document-capture.es.js +2 -0
  32. package/dist/document-capture/styles.css +2 -5
  33. package/dist/documentCapture-8ypBJehw.js +2 -0
  34. package/dist/documentCapture-BDV_921m.js +880 -0
  35. package/dist/dropdownComposed-CEWBSdGl.js +1 -0
  36. package/dist/dropdownComposed-_fgAlo_C.js +380 -0
  37. package/dist/dynamic-forms/styles.css +25 -13
  38. package/dist/dynamicForms-DyfnsS7E.js +352 -0
  39. package/dist/ekyb/ekyb.es.js +2 -2
  40. package/dist/ekyb/styles.css +2 -0
  41. package/dist/ekybModule-CIPGmCvD.js +279 -0
  42. package/dist/ekybModule-DFoYpheB.js +2 -0
  43. package/dist/ekyc/ekyc.es.js +2 -2
  44. package/dist/ekyc/styles.css +9 -7
  45. package/dist/ekycModule-BGzwgjl1.js +2 -0
  46. package/dist/ekycModule-BuTaC5ct.js +257 -0
  47. package/dist/electronic-signature/electronic-signature.es.js +2 -2
  48. package/dist/electronic-signature-B-Q7M0wK.js +430 -0
  49. package/dist/email/email.es.js +199 -66
  50. package/dist/emailInput-KZmhjOdZ.js +39 -0
  51. package/dist/errorIcon-DJRZpd8j.js +26 -0
  52. package/dist/expiredId-Q1t6aVpk.js +85 -0
  53. package/dist/extensibility-Cs3KQQdC.js +3070 -0
  54. package/dist/extensibility.es.js +26 -25
  55. package/dist/face-match/face-match.es.js +2 -2
  56. package/dist/face-match/styles.css +0 -4
  57. package/dist/faceMatch--RDHJe4t.js +343 -0
  58. package/dist/faceMatch-yEKPYaym.js +2 -0
  59. package/dist/field-comparison/field-comparison.es.js +2 -0
  60. package/dist/field-comparison/styles.css +16 -0
  61. package/dist/fieldComparison-CAF86bTC.js +88 -0
  62. package/dist/fieldComparison-D0an7T_g.js +2 -0
  63. package/dist/fiscal-qr/fiscal-qr.es.js +224 -0
  64. package/dist/fiscal-qr/styles.css +71 -0
  65. package/dist/{flip-animation-CgwRsEmK.js → flip-animation-BGRvygw9.js} +4221 -4221
  66. package/dist/flow/flow.es.js +619 -484
  67. package/dist/flow/styles.css +378 -418
  68. package/dist/{front-horizontal-hint-DGGGi8e1.js → front-horizontal-hint-Uf5bHCsd.js} +70 -70
  69. package/dist/{front-vertical-hint-CNr5mE6Q.js → front-vertical-hint-DdWNA45v.js} +81 -81
  70. package/dist/frontdevicelottie-CLqitJhG.js +17314 -0
  71. package/dist/geolocation/geolocation.es.js +486 -395
  72. package/dist/glaredevicelottie-BS04U6Fc.js +14478 -0
  73. package/dist/governmentValidation/governmentValidation.es.js +166 -93
  74. package/dist/governmentValidation/styles.css +0 -17
  75. package/dist/homeScreen-BZnIEDrV.js +264 -0
  76. package/dist/hooks-Da_yP_Dr.js +149 -0
  77. package/dist/i18n-CoCO2ZuN.js +2971 -0
  78. package/dist/icons-Dbs9ZfYM.js +360 -0
  79. package/dist/id/id.es.js +583 -414
  80. package/dist/id/styles.css +59 -43
  81. package/dist/id-laser-h-DX8UbVNH.js +467 -0
  82. package/dist/id-laser-v-DhnHdjlB.js +490 -0
  83. package/dist/id-tutorial-lj4iKtYT.js +13165 -0
  84. package/dist/id-verification/id-verification.es.js +21 -17
  85. package/dist/idOcr-CjGbb4dB.js +123 -0
  86. package/dist/identity-reuse/identity-reuse.es.js +311 -182
  87. package/dist/identity-reuse/styles.css +134 -80
  88. package/dist/incode-logo-57XFniXU.js +4 -0
  89. package/dist/incodeComponent-wfnHlnXx.js +63 -0
  90. package/dist/incodeModule-BUDoTwT9.js +13 -0
  91. package/dist/index.es.js +16 -13
  92. package/dist/inputComposed-BEn7_nZd.js +1 -0
  93. package/dist/inputComposed-CQ4AsvZg.js +99 -0
  94. package/dist/loadingIcon-B0ysgiNq.js +148 -0
  95. package/dist/lottie_light-Dp9Bz3mf.js +9031 -0
  96. package/dist/mandatoryConsent-r0PQHmv-.js +107 -0
  97. package/dist/modal-nTSaG7nB.js +139 -0
  98. package/dist/modal.hooks-D2xhIuHA.js +195 -0
  99. package/dist/numberedStep-CEtwZqLp.js +13 -0
  100. package/dist/optionAccessibleLabel-CnA-mNAU.js +202 -0
  101. package/dist/otpInput-_JmtVwa0.js +195 -0
  102. package/dist/page-DxGQj7Gk.js +71 -0
  103. package/dist/{passport-horizontal-hint-Bgquwtac.js → passport-horizontal-hint-Bbm2mvSn.js} +55 -55
  104. package/dist/{passport-tutorial-DwRwtPVX.js → passport-tutorial-zT1ZoA-D.js} +7096 -7084
  105. package/dist/{passport-vertical-hint-BT1D5BrW.js → passport-vertical-hint-DJbCtBiM.js} +49 -49
  106. package/dist/pdf-BZA70WbM.js +22398 -0
  107. package/dist/pdfViewer-BK-yVIve.js +114 -0
  108. package/dist/phone/phone.es.js +214 -70
  109. package/dist/phoneInputComposed-DjNdsmPE.js +12142 -0
  110. package/dist/processing-BM-wT-1W.js +8 -0
  111. package/dist/qe-signature/qe-signature.es.js +15 -13
  112. package/dist/radioGroupComposed-BNuaopVr.js +215 -0
  113. package/dist/redirect-to-mobile/redirect-to-mobile.es.js +2774 -0
  114. package/dist/redirect-to-mobile/styles.css +19 -269
  115. package/dist/registerIncodeElement-77NGCDsy.js +11 -0
  116. package/dist/requiredLabelHint-DEadtiwx.js +17 -0
  117. package/dist/richText-Cf9aMOCk.js +3153 -0
  118. package/dist/rolldown-runtime--E5BIlTp.js +33 -0
  119. package/dist/selfie/selfie.es.js +54 -37
  120. package/dist/selfie/styles.css +0 -4
  121. package/dist/selfieTutorial-CtruLyO2.js +2689 -0
  122. package/dist/signature/signature.es.js +778 -405
  123. package/dist/snackbar-CxepGC3e.js +16 -0
  124. package/dist/spinner-B6RxGFrI.js +1 -0
  125. package/dist/spinner-D8a_2LvW.js +42 -0
  126. package/dist/statusPage-DMYPUwRZ.js +28 -0
  127. package/dist/successIcon-BAyDPT7I.js +30 -0
  128. package/dist/tabs-C8npVBbk.js +103 -0
  129. package/dist/themes/dark.css +5 -0
  130. package/dist/themes/light.css +4 -0
  131. package/dist/transitionSpinner-DRRz-NV8.js +26 -0
  132. package/dist/{tutorial-9vHAHvMK.js → tutorial-D1qaY2Tm.js} +1105 -856
  133. package/dist/types/ae-signature.d.ts +4 -1
  134. package/dist/types/antifraud.d.ts +9 -3
  135. package/dist/types/authentication.d.ts +4 -1
  136. package/dist/types/consent.d.ts +4 -1
  137. package/dist/types/cpf-ocr.d.ts +12 -0
  138. package/dist/types/cross-document-data-match.d.ts +4 -1
  139. package/dist/types/curp-validation.d.ts +9 -3
  140. package/dist/types/document-capture.d.ts +37 -0
  141. package/dist/types/ekyb.d.ts +4 -1
  142. package/dist/types/ekyc.d.ts +4 -1
  143. package/dist/types/electronic-signature.d.ts +4 -1
  144. package/dist/types/email.d.ts +4 -1
  145. package/dist/types/extensibility.d.ts +40 -15
  146. package/dist/types/face-match.d.ts +4 -1
  147. package/dist/types/field-comparison.d.ts +38 -0
  148. package/dist/types/fiscal-qr.d.ts +43 -0
  149. package/dist/types/flow.d.ts +5 -2
  150. package/dist/types/geolocation.d.ts +4 -1
  151. package/dist/types/governmentValidation.d.ts +4 -1
  152. package/dist/types/id-verification.d.ts +4 -1
  153. package/dist/types/id.d.ts +4 -1
  154. package/dist/types/identity-reuse.d.ts +4 -1
  155. package/dist/types/index.d.ts +20 -2
  156. package/dist/types/phone.d.ts +4 -1
  157. package/dist/types/qe-signature.d.ts +4 -1
  158. package/dist/types/redirect-to-mobile.d.ts +17 -0
  159. package/dist/types/selfie.d.ts +4 -1
  160. package/dist/types/signature.d.ts +4 -1
  161. package/dist/types/watchlist.d.ts +4 -1
  162. package/dist/types/workflow.d.ts +55 -11
  163. package/dist/typography-YLgHHuao.js +45 -0
  164. package/dist/uiConfig-D2_wawvr.js +25 -0
  165. package/dist/useModuleLoader-CeJ2jL25.js +672 -0
  166. package/dist/vendor-preact-DThS2ZQ_.js +955 -0
  167. package/dist/verificationResult-Do5SpZ6X.js +64 -0
  168. package/dist/verifiedByIncode-DjXOdCml.js +103 -0
  169. package/dist/watchlist/watchlist.es.js +31 -28
  170. package/dist/watchlistForBusiness-BFFXC9d-.js +80 -0
  171. package/dist/workflow/styles.css +449 -427
  172. package/dist/workflow/workflow.es.js +268 -182
  173. package/package.json +32 -10
  174. package/dist/aligndevicelottie-DoV8xKjh.js +0 -12757
  175. package/dist/autoFocusTitle-QexamZ4i.js +0 -16
  176. package/dist/back-tutorial-1NOQobGO.js +0 -14585
  177. package/dist/backdevicelottie-C_ceuqY7.js +0 -16678
  178. package/dist/blurdevicelottie-UO14Y0WC.js +0 -15939
  179. package/dist/bottomSheet-DE_8TFEC.js +0 -31
  180. package/dist/browser-ponyfill-jOkuz57z.js +0 -299
  181. package/dist/button-DcCUEn2n.js +0 -24
  182. package/dist/checkbox-Cl57ltq_.js +0 -85
  183. package/dist/countrySelector-CE-JgIsv.js +0 -58
  184. package/dist/cpfOcr-D_tbwbvh.js +0 -78
  185. package/dist/customFields-CW38fQUv.js +0 -127
  186. package/dist/customWatchlist-D9_yjEQd.js +0 -33
  187. package/dist/dateInputComposed-BpAGsjN6.js +0 -55
  188. package/dist/dateInputComposed-DU3o6PAV.js +0 -1
  189. package/dist/defineProperty-Dh8nSJpJ.js +0 -39
  190. package/dist/documentCapture-xX-JT7ZY.js +0 -763
  191. package/dist/dropdownComposed-DFRBG22E.js +0 -284
  192. package/dist/dropdownComposed-DwTzc2YU.js +0 -1
  193. package/dist/dynamicForms-CJP1Ia6Q.js +0 -262
  194. package/dist/ekybModule-BSs7mndb.js +0 -280
  195. package/dist/ekybModule-D9M3E2Gm.js +0 -2
  196. package/dist/ekycModule-CU9pt5YN.js +0 -246
  197. package/dist/ekycModule-CZw9cLno.js +0 -2
  198. package/dist/electronic-signature-COYXjGdd.js +0 -410
  199. package/dist/emailInput-DppGf9pv.js +0 -37
  200. package/dist/expiredId-BnmzE8T3.js +0 -70
  201. package/dist/extensibility-CzEJfRwo.js +0 -2586
  202. package/dist/faceMatch-B8j0g0Yo.js +0 -2
  203. package/dist/faceMatch-BV8UD7tj.js +0 -201
  204. package/dist/frontdevicelottie-Bu6f9fDE.js +0 -17302
  205. package/dist/glaredevicelottie-B10axYs_.js +0 -14466
  206. package/dist/homeScreen-DnP1jw9A.js +0 -227
  207. package/dist/hooks-BVnGysT7.js +0 -80
  208. package/dist/i18n-9s4OSqwi.js +0 -2010
  209. package/dist/icons-Cc7zwchP.js +0 -310
  210. package/dist/id-laser-h-mBAzHVOK.js +0 -467
  211. package/dist/id-laser-v-CrFg4bcJ.js +0 -483
  212. package/dist/id-tutorial-BCr42Pnn.js +0 -13153
  213. package/dist/idOcr-CCjfWQvH.js +0 -94
  214. package/dist/incode-logo-DX016usY.js +0 -4
  215. package/dist/incodeComponent-C1o4M0ZK.js +0 -50
  216. package/dist/incodeModule-BqCjVgEI.js +0 -18
  217. package/dist/inputComposed-APSw8C7o.js +0 -89
  218. package/dist/inputComposed-XYrarFxS.js +0 -1
  219. package/dist/loadingIcon-BN5YRQUb.js +0 -104
  220. package/dist/mandatoryConsent-DssKMC3v.js +0 -100
  221. package/dist/modal-NMxsQHAO.js +0 -135
  222. package/dist/modal.hooks-CAjcIFZK.js +0 -126
  223. package/dist/numberedStep-CT-alrK5.js +0 -11
  224. package/dist/optionAccessibleLabel-CzEeX3Q4.js +0 -140
  225. package/dist/otpInput-DqRA_egd.js +0 -145
  226. package/dist/page-C1yT4DLb.js +0 -69
  227. package/dist/pdf-BurGZ08w.js +0 -14967
  228. package/dist/pdfViewer-BGBNL1Ea.js +0 -63
  229. package/dist/phoneInputComposed-bvWhGLFZ.js +0 -11206
  230. package/dist/processing-G_y3o32b.js +0 -6
  231. package/dist/radioGroupComposed-BbmvxmD2.js +0 -177
  232. package/dist/redirectToMobile-C3k1gloW.js +0 -1514
  233. package/dist/requiredLabelHint-BLwgqozE.js +0 -13
  234. package/dist/richText-DbJ5sl2n.js +0 -1973
  235. package/dist/rolldown-runtime-CYMK-g2i.js +0 -20
  236. package/dist/selfieTutorial-BgrlUMXP.js +0 -2677
  237. package/dist/snackbar-BDp8x7Cv.js +0 -14
  238. package/dist/spinner-B4dcie2T.js +0 -1
  239. package/dist/spinner-CKnjVHxw.js +0 -39
  240. package/dist/statusPage-CUI7ApcU.js +0 -28
  241. package/dist/successIcon-DbILeIz_.js +0 -28
  242. package/dist/tabs-DaPyP71c.js +0 -78
  243. package/dist/transitionSpinner-PIEPU2Vx.js +0 -17
  244. package/dist/types/cpf-ocr/styles.d.ts +0 -1
  245. package/dist/types/document-capture/styles.d.ts +0 -1
  246. package/dist/types/redirect-to-mobile/styles.d.ts +0 -1
  247. package/dist/typography-CxjaknHN.js +0 -28
  248. package/dist/uiConfig-CwpQ-IM6.js +0 -20
  249. package/dist/useModuleLoader-BFiVA41N.js +0 -432
  250. package/dist/vendor-preact-D6SntenC.js +0 -958
  251. package/dist/verificationResult-BrVbUJ4U.js +0 -97
  252. package/dist/verifiedByIncode-ChZBpqNy.js +0 -101
  253. package/dist/watchlistForBusiness-BcSNtHCV.js +0 -77
@@ -0,0 +1,2971 @@
1
+ import { r as __toESM } from "./rolldown-runtime--E5BIlTp.js";
2
+ import { _ as y, d as T, p as d, v as u, x as k, y as K } from "./vendor-preact-DThS2ZQ_.js";
3
+ //#region ../../node_modules/.pnpm/i18next@25.7.1_typescript@5.9.3/node_modules/i18next/dist/esm/i18next.js
4
+ var isString = (obj) => typeof obj === "string";
5
+ var defer = () => {
6
+ let res;
7
+ let rej;
8
+ const promise = new Promise((resolve, reject) => {
9
+ res = resolve;
10
+ rej = reject;
11
+ });
12
+ promise.resolve = res;
13
+ promise.reject = rej;
14
+ return promise;
15
+ };
16
+ var makeString = (object) => {
17
+ if (object == null) return "";
18
+ return "" + object;
19
+ };
20
+ var copy = (a, s, t) => {
21
+ a.forEach((m) => {
22
+ if (s[m]) t[m] = s[m];
23
+ });
24
+ };
25
+ var lastOfPathSeparatorRegExp = /###/g;
26
+ var cleanKey = (key) => key && key.indexOf("###") > -1 ? key.replace(lastOfPathSeparatorRegExp, ".") : key;
27
+ var canNotTraverseDeeper = (object) => !object || isString(object);
28
+ var getLastOfPath = (object, path, Empty) => {
29
+ const stack = !isString(path) ? path : path.split(".");
30
+ let stackIndex = 0;
31
+ while (stackIndex < stack.length - 1) {
32
+ if (canNotTraverseDeeper(object)) return {};
33
+ const key = cleanKey(stack[stackIndex]);
34
+ if (!object[key] && Empty) object[key] = new Empty();
35
+ if (Object.prototype.hasOwnProperty.call(object, key)) object = object[key];
36
+ else object = {};
37
+ ++stackIndex;
38
+ }
39
+ if (canNotTraverseDeeper(object)) return {};
40
+ return {
41
+ obj: object,
42
+ k: cleanKey(stack[stackIndex])
43
+ };
44
+ };
45
+ var setPath = (object, path, newValue) => {
46
+ const { obj, k } = getLastOfPath(object, path, Object);
47
+ if (obj !== void 0 || path.length === 1) {
48
+ obj[k] = newValue;
49
+ return;
50
+ }
51
+ let e = path[path.length - 1];
52
+ let p = path.slice(0, path.length - 1);
53
+ let last = getLastOfPath(object, p, Object);
54
+ while (last.obj === void 0 && p.length) {
55
+ e = `${p[p.length - 1]}.${e}`;
56
+ p = p.slice(0, p.length - 1);
57
+ last = getLastOfPath(object, p, Object);
58
+ if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== "undefined") last.obj = void 0;
59
+ }
60
+ last.obj[`${last.k}.${e}`] = newValue;
61
+ };
62
+ var pushPath = (object, path, newValue, concat) => {
63
+ const { obj, k } = getLastOfPath(object, path, Object);
64
+ obj[k] = obj[k] || [];
65
+ obj[k].push(newValue);
66
+ };
67
+ var getPath = (object, path) => {
68
+ const { obj, k } = getLastOfPath(object, path);
69
+ if (!obj) return void 0;
70
+ if (!Object.prototype.hasOwnProperty.call(obj, k)) return void 0;
71
+ return obj[k];
72
+ };
73
+ var getPathWithDefaults = (data, defaultData, key) => {
74
+ const value = getPath(data, key);
75
+ if (value !== void 0) return value;
76
+ return getPath(defaultData, key);
77
+ };
78
+ var deepExtend = (target, source, overwrite) => {
79
+ for (const prop in source) if (prop !== "__proto__" && prop !== "constructor") if (prop in target) if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
80
+ if (overwrite) target[prop] = source[prop];
81
+ } else deepExtend(target[prop], source[prop], overwrite);
82
+ else target[prop] = source[prop];
83
+ return target;
84
+ };
85
+ var regexEscape = (str) => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
86
+ var _entityMap = {
87
+ "&": "&amp;",
88
+ "<": "&lt;",
89
+ ">": "&gt;",
90
+ "\"": "&quot;",
91
+ "'": "&#39;",
92
+ "/": "&#x2F;"
93
+ };
94
+ var escape = (data) => {
95
+ if (isString(data)) return data.replace(/[&<>"'\/]/g, (s) => _entityMap[s]);
96
+ return data;
97
+ };
98
+ var RegExpCache = class {
99
+ constructor(capacity) {
100
+ this.capacity = capacity;
101
+ this.regExpMap = /* @__PURE__ */ new Map();
102
+ this.regExpQueue = [];
103
+ }
104
+ getRegExp(pattern) {
105
+ const regExpFromCache = this.regExpMap.get(pattern);
106
+ if (regExpFromCache !== void 0) return regExpFromCache;
107
+ const regExpNew = new RegExp(pattern);
108
+ if (this.regExpQueue.length === this.capacity) this.regExpMap.delete(this.regExpQueue.shift());
109
+ this.regExpMap.set(pattern, regExpNew);
110
+ this.regExpQueue.push(pattern);
111
+ return regExpNew;
112
+ }
113
+ };
114
+ var chars = [
115
+ " ",
116
+ ",",
117
+ "?",
118
+ "!",
119
+ ";"
120
+ ];
121
+ var looksLikeObjectPathRegExpCache = new RegExpCache(20);
122
+ var looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
123
+ nsSeparator = nsSeparator || "";
124
+ keySeparator = keySeparator || "";
125
+ const possibleChars = chars.filter((c) => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
126
+ if (possibleChars.length === 0) return true;
127
+ const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map((c) => c === "?" ? "\\?" : c).join("|")})`);
128
+ let matched = !r.test(key);
129
+ if (!matched) {
130
+ const ki = key.indexOf(keySeparator);
131
+ if (ki > 0 && !r.test(key.substring(0, ki))) matched = true;
132
+ }
133
+ return matched;
134
+ };
135
+ var deepFind = (obj, path, keySeparator = ".") => {
136
+ if (!obj) return void 0;
137
+ if (obj[path]) {
138
+ if (!Object.prototype.hasOwnProperty.call(obj, path)) return void 0;
139
+ return obj[path];
140
+ }
141
+ const tokens = path.split(keySeparator);
142
+ let current = obj;
143
+ for (let i = 0; i < tokens.length;) {
144
+ if (!current || typeof current !== "object") return;
145
+ let next;
146
+ let nextPath = "";
147
+ for (let j = i; j < tokens.length; ++j) {
148
+ if (j !== i) nextPath += keySeparator;
149
+ nextPath += tokens[j];
150
+ next = current[nextPath];
151
+ if (next !== void 0) {
152
+ if ([
153
+ "string",
154
+ "number",
155
+ "boolean"
156
+ ].indexOf(typeof next) > -1 && j < tokens.length - 1) continue;
157
+ i += j - i + 1;
158
+ break;
159
+ }
160
+ }
161
+ current = next;
162
+ }
163
+ return current;
164
+ };
165
+ var getCleanedCode = (code) => code?.replace("_", "-");
166
+ var consoleLogger = {
167
+ type: "logger",
168
+ log(args) {
169
+ this.output("log", args);
170
+ },
171
+ warn(args) {
172
+ this.output("warn", args);
173
+ },
174
+ error(args) {
175
+ this.output("error", args);
176
+ },
177
+ output(type, args) {
178
+ console?.[type]?.apply?.(console, args);
179
+ }
180
+ };
181
+ var baseLogger = new class Logger {
182
+ constructor(concreteLogger, options = {}) {
183
+ this.init(concreteLogger, options);
184
+ }
185
+ init(concreteLogger, options = {}) {
186
+ this.prefix = options.prefix || "i18next:";
187
+ this.logger = concreteLogger || consoleLogger;
188
+ this.options = options;
189
+ this.debug = options.debug;
190
+ }
191
+ log(...args) {
192
+ return this.forward(args, "log", "", true);
193
+ }
194
+ warn(...args) {
195
+ return this.forward(args, "warn", "", true);
196
+ }
197
+ error(...args) {
198
+ return this.forward(args, "error", "");
199
+ }
200
+ deprecate(...args) {
201
+ return this.forward(args, "warn", "WARNING DEPRECATED: ", true);
202
+ }
203
+ forward(args, lvl, prefix, debugOnly) {
204
+ if (debugOnly && !this.debug) return null;
205
+ if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
206
+ return this.logger[lvl](args);
207
+ }
208
+ create(moduleName) {
209
+ return new Logger(this.logger, {
210
+ prefix: `${this.prefix}:${moduleName}:`,
211
+ ...this.options
212
+ });
213
+ }
214
+ clone(options) {
215
+ options = options || this.options;
216
+ options.prefix = options.prefix || this.prefix;
217
+ return new Logger(this.logger, options);
218
+ }
219
+ }();
220
+ var EventEmitter = class {
221
+ constructor() {
222
+ this.observers = {};
223
+ }
224
+ on(events, listener) {
225
+ events.split(" ").forEach((event) => {
226
+ if (!this.observers[event]) this.observers[event] = /* @__PURE__ */ new Map();
227
+ const numListeners = this.observers[event].get(listener) || 0;
228
+ this.observers[event].set(listener, numListeners + 1);
229
+ });
230
+ return this;
231
+ }
232
+ off(event, listener) {
233
+ if (!this.observers[event]) return;
234
+ if (!listener) {
235
+ delete this.observers[event];
236
+ return;
237
+ }
238
+ this.observers[event].delete(listener);
239
+ }
240
+ emit(event, ...args) {
241
+ if (this.observers[event]) Array.from(this.observers[event].entries()).forEach(([observer, numTimesAdded]) => {
242
+ for (let i = 0; i < numTimesAdded; i++) observer(...args);
243
+ });
244
+ if (this.observers["*"]) Array.from(this.observers["*"].entries()).forEach(([observer, numTimesAdded]) => {
245
+ for (let i = 0; i < numTimesAdded; i++) observer.apply(observer, [event, ...args]);
246
+ });
247
+ }
248
+ };
249
+ var ResourceStore = class extends EventEmitter {
250
+ constructor(data, options = {
251
+ ns: ["translation"],
252
+ defaultNS: "translation"
253
+ }) {
254
+ super();
255
+ this.data = data || {};
256
+ this.options = options;
257
+ if (this.options.keySeparator === void 0) this.options.keySeparator = ".";
258
+ if (this.options.ignoreJSONStructure === void 0) this.options.ignoreJSONStructure = true;
259
+ }
260
+ addNamespaces(ns) {
261
+ if (this.options.ns.indexOf(ns) < 0) this.options.ns.push(ns);
262
+ }
263
+ removeNamespaces(ns) {
264
+ const index = this.options.ns.indexOf(ns);
265
+ if (index > -1) this.options.ns.splice(index, 1);
266
+ }
267
+ getResource(lng, ns, key, options = {}) {
268
+ const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
269
+ const ignoreJSONStructure = options.ignoreJSONStructure !== void 0 ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
270
+ let path;
271
+ if (lng.indexOf(".") > -1) path = lng.split(".");
272
+ else {
273
+ path = [lng, ns];
274
+ if (key) if (Array.isArray(key)) path.push(...key);
275
+ else if (isString(key) && keySeparator) path.push(...key.split(keySeparator));
276
+ else path.push(key);
277
+ }
278
+ const result = getPath(this.data, path);
279
+ if (!result && !ns && !key && lng.indexOf(".") > -1) {
280
+ lng = path[0];
281
+ ns = path[1];
282
+ key = path.slice(2).join(".");
283
+ }
284
+ if (result || !ignoreJSONStructure || !isString(key)) return result;
285
+ return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
286
+ }
287
+ addResource(lng, ns, key, value, options = { silent: false }) {
288
+ const keySeparator = options.keySeparator !== void 0 ? options.keySeparator : this.options.keySeparator;
289
+ let path = [lng, ns];
290
+ if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
291
+ if (lng.indexOf(".") > -1) {
292
+ path = lng.split(".");
293
+ value = ns;
294
+ ns = path[1];
295
+ }
296
+ this.addNamespaces(ns);
297
+ setPath(this.data, path, value);
298
+ if (!options.silent) this.emit("added", lng, ns, key, value);
299
+ }
300
+ addResources(lng, ns, resources, options = { silent: false }) {
301
+ for (const m in resources) if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], { silent: true });
302
+ if (!options.silent) this.emit("added", lng, ns, resources);
303
+ }
304
+ addResourceBundle(lng, ns, resources, deep, overwrite, options = {
305
+ silent: false,
306
+ skipCopy: false
307
+ }) {
308
+ let path = [lng, ns];
309
+ if (lng.indexOf(".") > -1) {
310
+ path = lng.split(".");
311
+ deep = resources;
312
+ resources = ns;
313
+ ns = path[1];
314
+ }
315
+ this.addNamespaces(ns);
316
+ let pack = getPath(this.data, path) || {};
317
+ if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
318
+ if (deep) deepExtend(pack, resources, overwrite);
319
+ else pack = {
320
+ ...pack,
321
+ ...resources
322
+ };
323
+ setPath(this.data, path, pack);
324
+ if (!options.silent) this.emit("added", lng, ns, resources);
325
+ }
326
+ removeResourceBundle(lng, ns) {
327
+ if (this.hasResourceBundle(lng, ns)) delete this.data[lng][ns];
328
+ this.removeNamespaces(ns);
329
+ this.emit("removed", lng, ns);
330
+ }
331
+ hasResourceBundle(lng, ns) {
332
+ return this.getResource(lng, ns) !== void 0;
333
+ }
334
+ getResourceBundle(lng, ns) {
335
+ if (!ns) ns = this.options.defaultNS;
336
+ return this.getResource(lng, ns);
337
+ }
338
+ getDataByLanguage(lng) {
339
+ return this.data[lng];
340
+ }
341
+ hasLanguageSomeTranslations(lng) {
342
+ const data = this.getDataByLanguage(lng);
343
+ return !!(data && Object.keys(data) || []).find((v) => data[v] && Object.keys(data[v]).length > 0);
344
+ }
345
+ toJSON() {
346
+ return this.data;
347
+ }
348
+ };
349
+ var postProcessor = {
350
+ processors: {},
351
+ addPostProcessor(module) {
352
+ this.processors[module.name] = module;
353
+ },
354
+ handle(processors, value, key, options, translator) {
355
+ processors.forEach((processor) => {
356
+ value = this.processors[processor]?.process(value, key, options, translator) ?? value;
357
+ });
358
+ return value;
359
+ }
360
+ };
361
+ var PATH_KEY = Symbol("i18next/PATH_KEY");
362
+ function createProxy() {
363
+ const state = [];
364
+ const handler = Object.create(null);
365
+ let proxy;
366
+ handler.get = (target, key) => {
367
+ proxy?.revoke?.();
368
+ if (key === PATH_KEY) return state;
369
+ state.push(key);
370
+ proxy = Proxy.revocable(target, handler);
371
+ return proxy.proxy;
372
+ };
373
+ return Proxy.revocable(Object.create(null), handler).proxy;
374
+ }
375
+ function keysFromSelector(selector, opts) {
376
+ const { [PATH_KEY]: path } = selector(createProxy());
377
+ return path.join(opts?.keySeparator ?? ".");
378
+ }
379
+ var checkedLoadedFor = {};
380
+ var shouldHandleAsObject = (res) => !isString(res) && typeof res !== "boolean" && typeof res !== "number";
381
+ var Translator = class Translator extends EventEmitter {
382
+ constructor(services, options = {}) {
383
+ super();
384
+ copy([
385
+ "resourceStore",
386
+ "languageUtils",
387
+ "pluralResolver",
388
+ "interpolator",
389
+ "backendConnector",
390
+ "i18nFormat",
391
+ "utils"
392
+ ], services, this);
393
+ this.options = options;
394
+ if (this.options.keySeparator === void 0) this.options.keySeparator = ".";
395
+ this.logger = baseLogger.create("translator");
396
+ }
397
+ changeLanguage(lng) {
398
+ if (lng) this.language = lng;
399
+ }
400
+ exists(key, o = { interpolation: {} }) {
401
+ const opt = { ...o };
402
+ if (key == null) return false;
403
+ const resolved = this.resolve(key, opt);
404
+ if (resolved?.res === void 0) return false;
405
+ const isObject = shouldHandleAsObject(resolved.res);
406
+ if (opt.returnObjects === false && isObject) return false;
407
+ return true;
408
+ }
409
+ extractFromKey(key, opt) {
410
+ let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
411
+ if (nsSeparator === void 0) nsSeparator = ":";
412
+ const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
413
+ let namespaces = opt.ns || this.options.defaultNS || [];
414
+ const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
415
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
416
+ if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
417
+ const m = key.match(this.interpolator.nestingRegexp);
418
+ if (m && m.length > 0) return {
419
+ key,
420
+ namespaces: isString(namespaces) ? [namespaces] : namespaces
421
+ };
422
+ const parts = key.split(nsSeparator);
423
+ if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
424
+ key = parts.join(keySeparator);
425
+ }
426
+ return {
427
+ key,
428
+ namespaces: isString(namespaces) ? [namespaces] : namespaces
429
+ };
430
+ }
431
+ translate(keys, o, lastKey) {
432
+ let opt = typeof o === "object" ? { ...o } : o;
433
+ if (typeof opt !== "object" && this.options.overloadTranslationOptionHandler) opt = this.options.overloadTranslationOptionHandler(arguments);
434
+ if (typeof opt === "object") opt = { ...opt };
435
+ if (!opt) opt = {};
436
+ if (keys == null) return "";
437
+ if (typeof keys === "function") keys = keysFromSelector(keys, {
438
+ ...this.options,
439
+ ...opt
440
+ });
441
+ if (!Array.isArray(keys)) keys = [String(keys)];
442
+ const returnDetails = opt.returnDetails !== void 0 ? opt.returnDetails : this.options.returnDetails;
443
+ const keySeparator = opt.keySeparator !== void 0 ? opt.keySeparator : this.options.keySeparator;
444
+ const { key, namespaces } = this.extractFromKey(keys[keys.length - 1], opt);
445
+ const namespace = namespaces[namespaces.length - 1];
446
+ let nsSeparator = opt.nsSeparator !== void 0 ? opt.nsSeparator : this.options.nsSeparator;
447
+ if (nsSeparator === void 0) nsSeparator = ":";
448
+ const lng = opt.lng || this.language;
449
+ const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
450
+ if (lng?.toLowerCase() === "cimode") {
451
+ if (appendNamespaceToCIMode) {
452
+ if (returnDetails) return {
453
+ res: `${namespace}${nsSeparator}${key}`,
454
+ usedKey: key,
455
+ exactUsedKey: key,
456
+ usedLng: lng,
457
+ usedNS: namespace,
458
+ usedParams: this.getUsedParamsDetails(opt)
459
+ };
460
+ return `${namespace}${nsSeparator}${key}`;
461
+ }
462
+ if (returnDetails) return {
463
+ res: key,
464
+ usedKey: key,
465
+ exactUsedKey: key,
466
+ usedLng: lng,
467
+ usedNS: namespace,
468
+ usedParams: this.getUsedParamsDetails(opt)
469
+ };
470
+ return key;
471
+ }
472
+ const resolved = this.resolve(keys, opt);
473
+ let res = resolved?.res;
474
+ const resUsedKey = resolved?.usedKey || key;
475
+ const resExactUsedKey = resolved?.exactUsedKey || key;
476
+ const noObject = [
477
+ "[object Number]",
478
+ "[object Function]",
479
+ "[object RegExp]"
480
+ ];
481
+ const joinArrays = opt.joinArrays !== void 0 ? opt.joinArrays : this.options.joinArrays;
482
+ const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
483
+ const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
484
+ const hasDefaultValue = Translator.hasDefaultValue(opt);
485
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : "";
486
+ const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, { ordinal: false }) : "";
487
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
488
+ const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
489
+ let resForObjHndl = res;
490
+ if (handleAsObjectInI18nFormat && !res && hasDefaultValue) resForObjHndl = defaultValue;
491
+ const handleAsObject = shouldHandleAsObject(resForObjHndl);
492
+ const resType = Object.prototype.toString.apply(resForObjHndl);
493
+ if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
494
+ if (!opt.returnObjects && !this.options.returnObjects) {
495
+ if (!this.options.returnedObjectHandler) this.logger.warn("accessing an object - but returnObjects options is not enabled!");
496
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
497
+ ...opt,
498
+ ns: namespaces
499
+ }) : `key '${key} (${this.language})' returned an object instead of string.`;
500
+ if (returnDetails) {
501
+ resolved.res = r;
502
+ resolved.usedParams = this.getUsedParamsDetails(opt);
503
+ return resolved;
504
+ }
505
+ return r;
506
+ }
507
+ if (keySeparator) {
508
+ const resTypeIsArray = Array.isArray(resForObjHndl);
509
+ const copy = resTypeIsArray ? [] : {};
510
+ const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
511
+ for (const m in resForObjHndl) if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
512
+ const deepKey = `${newKeyToUse}${keySeparator}${m}`;
513
+ if (hasDefaultValue && !res) copy[m] = this.translate(deepKey, {
514
+ ...opt,
515
+ defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : void 0,
516
+ joinArrays: false,
517
+ ns: namespaces
518
+ });
519
+ else copy[m] = this.translate(deepKey, {
520
+ ...opt,
521
+ joinArrays: false,
522
+ ns: namespaces
523
+ });
524
+ if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
525
+ }
526
+ res = copy;
527
+ }
528
+ } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
529
+ res = res.join(joinArrays);
530
+ if (res) res = this.extendTranslation(res, keys, opt, lastKey);
531
+ } else {
532
+ let usedDefault = false;
533
+ let usedKey = false;
534
+ if (!this.isValidLookup(res) && hasDefaultValue) {
535
+ usedDefault = true;
536
+ res = defaultValue;
537
+ }
538
+ if (!this.isValidLookup(res)) {
539
+ usedKey = true;
540
+ res = key;
541
+ }
542
+ const resForMissing = (opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey) && usedKey ? void 0 : res;
543
+ const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
544
+ if (usedKey || usedDefault || updateMissing) {
545
+ this.logger.log(updateMissing ? "updateKey" : "missingKey", lng, namespace, key, updateMissing ? defaultValue : res);
546
+ if (keySeparator) {
547
+ const fk = this.resolve(key, {
548
+ ...opt,
549
+ keySeparator: false
550
+ });
551
+ if (fk && fk.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.");
552
+ }
553
+ let lngs = [];
554
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
555
+ if (this.options.saveMissingTo === "fallback" && fallbackLngs && fallbackLngs[0]) for (let i = 0; i < fallbackLngs.length; i++) lngs.push(fallbackLngs[i]);
556
+ else if (this.options.saveMissingTo === "all") lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
557
+ else lngs.push(opt.lng || this.language);
558
+ const send = (l, k, specificDefaultValue) => {
559
+ const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
560
+ if (this.options.missingKeyHandler) this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
561
+ else if (this.backendConnector?.saveMissing) this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
562
+ this.emit("missingKey", l, namespace, k, res);
563
+ };
564
+ if (this.options.saveMissing) if (this.options.saveMissingPlurals && needsPluralHandling) lngs.forEach((language) => {
565
+ const suffixes = this.pluralResolver.getSuffixes(language, opt);
566
+ if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) suffixes.push(`${this.options.pluralSeparator}zero`);
567
+ suffixes.forEach((suffix) => {
568
+ send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
569
+ });
570
+ });
571
+ else send(lngs, key, defaultValue);
572
+ }
573
+ res = this.extendTranslation(res, keys, opt, resolved, lastKey);
574
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}${nsSeparator}${key}`;
575
+ if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : void 0, opt);
576
+ }
577
+ if (returnDetails) {
578
+ resolved.res = res;
579
+ resolved.usedParams = this.getUsedParamsDetails(opt);
580
+ return resolved;
581
+ }
582
+ return res;
583
+ }
584
+ extendTranslation(res, key, opt, resolved, lastKey) {
585
+ if (this.i18nFormat?.parse) res = this.i18nFormat.parse(res, {
586
+ ...this.options.interpolation.defaultVariables,
587
+ ...opt
588
+ }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, { resolved });
589
+ else if (!opt.skipInterpolation) {
590
+ if (opt.interpolation) this.interpolator.init({
591
+ ...opt,
592
+ interpolation: {
593
+ ...this.options.interpolation,
594
+ ...opt.interpolation
595
+ }
596
+ });
597
+ const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== void 0 ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
598
+ let nestBef;
599
+ if (skipOnVariables) {
600
+ const nb = res.match(this.interpolator.nestingRegexp);
601
+ nestBef = nb && nb.length;
602
+ }
603
+ let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
604
+ if (this.options.interpolation.defaultVariables) data = {
605
+ ...this.options.interpolation.defaultVariables,
606
+ ...data
607
+ };
608
+ res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
609
+ if (skipOnVariables) {
610
+ const na = res.match(this.interpolator.nestingRegexp);
611
+ const nestAft = na && na.length;
612
+ if (nestBef < nestAft) opt.nest = false;
613
+ }
614
+ if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
615
+ if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
616
+ if (lastKey?.[0] === args[0] && !opt.context) {
617
+ this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
618
+ return null;
619
+ }
620
+ return this.translate(...args, key);
621
+ }, opt);
622
+ if (opt.interpolation) this.interpolator.reset();
623
+ }
624
+ const postProcess = opt.postProcess || this.options.postProcess;
625
+ const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
626
+ if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
627
+ i18nResolved: {
628
+ ...resolved,
629
+ usedParams: this.getUsedParamsDetails(opt)
630
+ },
631
+ ...opt
632
+ } : opt, this);
633
+ return res;
634
+ }
635
+ resolve(keys, opt = {}) {
636
+ let found;
637
+ let usedKey;
638
+ let exactUsedKey;
639
+ let usedLng;
640
+ let usedNS;
641
+ if (isString(keys)) keys = [keys];
642
+ keys.forEach((k) => {
643
+ if (this.isValidLookup(found)) return;
644
+ const extracted = this.extractFromKey(k, opt);
645
+ const key = extracted.key;
646
+ usedKey = key;
647
+ let namespaces = extracted.namespaces;
648
+ if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
649
+ const needsPluralHandling = opt.count !== void 0 && !isString(opt.count);
650
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
651
+ const needsContextHandling = opt.context !== void 0 && (isString(opt.context) || typeof opt.context === "number") && opt.context !== "";
652
+ const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
653
+ namespaces.forEach((ns) => {
654
+ if (this.isValidLookup(found)) return;
655
+ usedNS = ns;
656
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
657
+ checkedLoadedFor[`${codes[0]}-${ns}`] = true;
658
+ this.logger.warn(`key "${usedKey}" for languages "${codes.join(", ")}" won't get resolved as namespace "${usedNS}" 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!!!");
659
+ }
660
+ codes.forEach((code) => {
661
+ if (this.isValidLookup(found)) return;
662
+ usedLng = code;
663
+ const finalKeys = [key];
664
+ if (this.i18nFormat?.addLookupKeys) this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
665
+ else {
666
+ let pluralSuffix;
667
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
668
+ const zeroSuffix = `${this.options.pluralSeparator}zero`;
669
+ const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
670
+ if (needsPluralHandling) {
671
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
672
+ finalKeys.push(key + pluralSuffix);
673
+ if (needsZeroSuffixLookup) finalKeys.push(key + zeroSuffix);
674
+ }
675
+ if (needsContextHandling) {
676
+ const contextKey = `${key}${this.options.contextSeparator || "_"}${opt.context}`;
677
+ finalKeys.push(contextKey);
678
+ if (needsPluralHandling) {
679
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
680
+ finalKeys.push(contextKey + pluralSuffix);
681
+ if (needsZeroSuffixLookup) finalKeys.push(contextKey + zeroSuffix);
682
+ }
683
+ }
684
+ }
685
+ let possibleKey;
686
+ while (possibleKey = finalKeys.pop()) if (!this.isValidLookup(found)) {
687
+ exactUsedKey = possibleKey;
688
+ found = this.getResource(code, ns, possibleKey, opt);
689
+ }
690
+ });
691
+ });
692
+ });
693
+ return {
694
+ res: found,
695
+ usedKey,
696
+ exactUsedKey,
697
+ usedLng,
698
+ usedNS
699
+ };
700
+ }
701
+ isValidLookup(res) {
702
+ return res !== void 0 && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === "");
703
+ }
704
+ getResource(code, ns, key, options = {}) {
705
+ if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
706
+ return this.resourceStore.getResource(code, ns, key, options);
707
+ }
708
+ getUsedParamsDetails(options = {}) {
709
+ const optionsKeys = [
710
+ "defaultValue",
711
+ "ordinal",
712
+ "context",
713
+ "replace",
714
+ "lng",
715
+ "lngs",
716
+ "fallbackLng",
717
+ "ns",
718
+ "keySeparator",
719
+ "nsSeparator",
720
+ "returnObjects",
721
+ "returnDetails",
722
+ "joinArrays",
723
+ "postProcess",
724
+ "interpolation"
725
+ ];
726
+ const useOptionsReplaceForData = options.replace && !isString(options.replace);
727
+ let data = useOptionsReplaceForData ? options.replace : options;
728
+ if (useOptionsReplaceForData && typeof options.count !== "undefined") data.count = options.count;
729
+ if (this.options.interpolation.defaultVariables) data = {
730
+ ...this.options.interpolation.defaultVariables,
731
+ ...data
732
+ };
733
+ if (!useOptionsReplaceForData) {
734
+ data = { ...data };
735
+ for (const key of optionsKeys) delete data[key];
736
+ }
737
+ return data;
738
+ }
739
+ static hasDefaultValue(options) {
740
+ const prefix = "defaultValue";
741
+ for (const option in options) if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, 12) && void 0 !== options[option]) return true;
742
+ return false;
743
+ }
744
+ };
745
+ var LanguageUtil = class {
746
+ constructor(options) {
747
+ this.options = options;
748
+ this.supportedLngs = this.options.supportedLngs || false;
749
+ this.logger = baseLogger.create("languageUtils");
750
+ }
751
+ getScriptPartFromCode(code) {
752
+ code = getCleanedCode(code);
753
+ if (!code || code.indexOf("-") < 0) return null;
754
+ const p = code.split("-");
755
+ if (p.length === 2) return null;
756
+ p.pop();
757
+ if (p[p.length - 1].toLowerCase() === "x") return null;
758
+ return this.formatLanguageCode(p.join("-"));
759
+ }
760
+ getLanguagePartFromCode(code) {
761
+ code = getCleanedCode(code);
762
+ if (!code || code.indexOf("-") < 0) return code;
763
+ const p = code.split("-");
764
+ return this.formatLanguageCode(p[0]);
765
+ }
766
+ formatLanguageCode(code) {
767
+ if (isString(code) && code.indexOf("-") > -1) {
768
+ let formattedCode;
769
+ try {
770
+ formattedCode = Intl.getCanonicalLocales(code)[0];
771
+ } catch (e) {}
772
+ if (formattedCode && this.options.lowerCaseLng) formattedCode = formattedCode.toLowerCase();
773
+ if (formattedCode) return formattedCode;
774
+ if (this.options.lowerCaseLng) return code.toLowerCase();
775
+ return code;
776
+ }
777
+ return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
778
+ }
779
+ isSupportedCode(code) {
780
+ if (this.options.load === "languageOnly" || this.options.nonExplicitSupportedLngs) code = this.getLanguagePartFromCode(code);
781
+ return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
782
+ }
783
+ getBestMatchFromCodes(codes) {
784
+ if (!codes) return null;
785
+ let found;
786
+ codes.forEach((code) => {
787
+ if (found) return;
788
+ const cleanedLng = this.formatLanguageCode(code);
789
+ if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
790
+ });
791
+ if (!found && this.options.supportedLngs) codes.forEach((code) => {
792
+ if (found) return;
793
+ const lngScOnly = this.getScriptPartFromCode(code);
794
+ if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
795
+ const lngOnly = this.getLanguagePartFromCode(code);
796
+ if (this.isSupportedCode(lngOnly)) return found = lngOnly;
797
+ found = this.options.supportedLngs.find((supportedLng) => {
798
+ if (supportedLng === lngOnly) return supportedLng;
799
+ if (supportedLng.indexOf("-") < 0 && lngOnly.indexOf("-") < 0) return;
800
+ if (supportedLng.indexOf("-") > 0 && lngOnly.indexOf("-") < 0 && supportedLng.substring(0, supportedLng.indexOf("-")) === lngOnly) return supportedLng;
801
+ if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
802
+ });
803
+ });
804
+ if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
805
+ return found;
806
+ }
807
+ getFallbackCodes(fallbacks, code) {
808
+ if (!fallbacks) return [];
809
+ if (typeof fallbacks === "function") fallbacks = fallbacks(code);
810
+ if (isString(fallbacks)) fallbacks = [fallbacks];
811
+ if (Array.isArray(fallbacks)) return fallbacks;
812
+ if (!code) return fallbacks.default || [];
813
+ let found = fallbacks[code];
814
+ if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
815
+ if (!found) found = fallbacks[this.formatLanguageCode(code)];
816
+ if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
817
+ if (!found) found = fallbacks.default;
818
+ return found || [];
819
+ }
820
+ toResolveHierarchy(code, fallbackCode) {
821
+ const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
822
+ const codes = [];
823
+ const addCode = (c) => {
824
+ if (!c) return;
825
+ if (this.isSupportedCode(c)) codes.push(c);
826
+ else this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
827
+ };
828
+ if (isString(code) && (code.indexOf("-") > -1 || code.indexOf("_") > -1)) {
829
+ if (this.options.load !== "languageOnly") addCode(this.formatLanguageCode(code));
830
+ if (this.options.load !== "languageOnly" && this.options.load !== "currentOnly") addCode(this.getScriptPartFromCode(code));
831
+ if (this.options.load !== "currentOnly") addCode(this.getLanguagePartFromCode(code));
832
+ } else if (isString(code)) addCode(this.formatLanguageCode(code));
833
+ fallbackCodes.forEach((fc) => {
834
+ if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
835
+ });
836
+ return codes;
837
+ }
838
+ };
839
+ var suffixesOrder = {
840
+ zero: 0,
841
+ one: 1,
842
+ two: 2,
843
+ few: 3,
844
+ many: 4,
845
+ other: 5
846
+ };
847
+ var dummyRule = {
848
+ select: (count) => count === 1 ? "one" : "other",
849
+ resolvedOptions: () => ({ pluralCategories: ["one", "other"] })
850
+ };
851
+ var PluralResolver = class {
852
+ constructor(languageUtils, options = {}) {
853
+ this.languageUtils = languageUtils;
854
+ this.options = options;
855
+ this.logger = baseLogger.create("pluralResolver");
856
+ this.pluralRulesCache = {};
857
+ }
858
+ addRule(lng, obj) {
859
+ this.rules[lng] = obj;
860
+ }
861
+ clearCache() {
862
+ this.pluralRulesCache = {};
863
+ }
864
+ getRule(code, options = {}) {
865
+ const cleanedCode = getCleanedCode(code === "dev" ? "en" : code);
866
+ const type = options.ordinal ? "ordinal" : "cardinal";
867
+ const cacheKey = JSON.stringify({
868
+ cleanedCode,
869
+ type
870
+ });
871
+ if (cacheKey in this.pluralRulesCache) return this.pluralRulesCache[cacheKey];
872
+ let rule;
873
+ try {
874
+ rule = new Intl.PluralRules(cleanedCode, { type });
875
+ } catch (err) {
876
+ if (!Intl) {
877
+ this.logger.error("No Intl support, please use an Intl polyfill!");
878
+ return dummyRule;
879
+ }
880
+ if (!code.match(/-|_/)) return dummyRule;
881
+ const lngPart = this.languageUtils.getLanguagePartFromCode(code);
882
+ rule = this.getRule(lngPart, options);
883
+ }
884
+ this.pluralRulesCache[cacheKey] = rule;
885
+ return rule;
886
+ }
887
+ needsPlural(code, options = {}) {
888
+ let rule = this.getRule(code, options);
889
+ if (!rule) rule = this.getRule("dev", options);
890
+ return rule?.resolvedOptions().pluralCategories.length > 1;
891
+ }
892
+ getPluralFormsOfKey(code, key, options = {}) {
893
+ return this.getSuffixes(code, options).map((suffix) => `${key}${suffix}`);
894
+ }
895
+ getSuffixes(code, options = {}) {
896
+ let rule = this.getRule(code, options);
897
+ if (!rule) rule = this.getRule("dev", options);
898
+ if (!rule) return [];
899
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map((pluralCategory) => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${pluralCategory}`);
900
+ }
901
+ getSuffix(code, count, options = {}) {
902
+ const rule = this.getRule(code, options);
903
+ if (rule) return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ""}${rule.select(count)}`;
904
+ this.logger.warn(`no plural rule found for: ${code}`);
905
+ return this.getSuffix("dev", count, options);
906
+ }
907
+ };
908
+ var deepFindWithDefaults = (data, defaultData, key, keySeparator = ".", ignoreJSONStructure = true) => {
909
+ let path = getPathWithDefaults(data, defaultData, key);
910
+ if (!path && ignoreJSONStructure && isString(key)) {
911
+ path = deepFind(data, key, keySeparator);
912
+ if (path === void 0) path = deepFind(defaultData, key, keySeparator);
913
+ }
914
+ return path;
915
+ };
916
+ var regexSafe = (val) => val.replace(/\$/g, "$$$$");
917
+ var Interpolator = class {
918
+ constructor(options = {}) {
919
+ this.logger = baseLogger.create("interpolator");
920
+ this.options = options;
921
+ this.format = options?.interpolation?.format || ((value) => value);
922
+ this.init(options);
923
+ }
924
+ init(options = {}) {
925
+ if (!options.interpolation) options.interpolation = { escapeValue: true };
926
+ const { escape: escape$1, escapeValue, useRawValueToEscape, prefix, prefixEscaped, suffix, suffixEscaped, formatSeparator, unescapeSuffix, unescapePrefix, nestingPrefix, nestingPrefixEscaped, nestingSuffix, nestingSuffixEscaped, nestingOptionsSeparator, maxReplaces, alwaysFormat } = options.interpolation;
927
+ this.escape = escape$1 !== void 0 ? escape$1 : escape;
928
+ this.escapeValue = escapeValue !== void 0 ? escapeValue : true;
929
+ this.useRawValueToEscape = useRawValueToEscape !== void 0 ? useRawValueToEscape : false;
930
+ this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || "{{";
931
+ this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || "}}";
932
+ this.formatSeparator = formatSeparator || ",";
933
+ this.unescapePrefix = unescapeSuffix ? "" : unescapePrefix || "-";
934
+ this.unescapeSuffix = this.unescapePrefix ? "" : unescapeSuffix || "";
935
+ this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape("$t(");
936
+ this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(")");
937
+ this.nestingOptionsSeparator = nestingOptionsSeparator || ",";
938
+ this.maxReplaces = maxReplaces || 1e3;
939
+ this.alwaysFormat = alwaysFormat !== void 0 ? alwaysFormat : false;
940
+ this.resetRegExp();
941
+ }
942
+ reset() {
943
+ if (this.options) this.init(this.options);
944
+ }
945
+ resetRegExp() {
946
+ const getOrResetRegExp = (existingRegExp, pattern) => {
947
+ if (existingRegExp?.source === pattern) {
948
+ existingRegExp.lastIndex = 0;
949
+ return existingRegExp;
950
+ }
951
+ return new RegExp(pattern, "g");
952
+ };
953
+ this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
954
+ this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
955
+ this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
956
+ }
957
+ interpolate(str, data, lng, options) {
958
+ let match;
959
+ let value;
960
+ let replaces;
961
+ const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
962
+ const handleFormat = (key) => {
963
+ if (key.indexOf(this.formatSeparator) < 0) {
964
+ const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
965
+ return this.alwaysFormat ? this.format(path, void 0, lng, {
966
+ ...options,
967
+ ...data,
968
+ interpolationkey: key
969
+ }) : path;
970
+ }
971
+ const p = key.split(this.formatSeparator);
972
+ const k = p.shift().trim();
973
+ const f = p.join(this.formatSeparator).trim();
974
+ return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
975
+ ...options,
976
+ ...data,
977
+ interpolationkey: k
978
+ });
979
+ };
980
+ this.resetRegExp();
981
+ const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
982
+ const skipOnVariables = options?.interpolation?.skipOnVariables !== void 0 ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
983
+ [{
984
+ regex: this.regexpUnescape,
985
+ safeValue: (val) => regexSafe(val)
986
+ }, {
987
+ regex: this.regexp,
988
+ safeValue: (val) => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
989
+ }].forEach((todo) => {
990
+ replaces = 0;
991
+ while (match = todo.regex.exec(str)) {
992
+ const matchedVar = match[1].trim();
993
+ value = handleFormat(matchedVar);
994
+ if (value === void 0) if (typeof missingInterpolationHandler === "function") {
995
+ const temp = missingInterpolationHandler(str, match, options);
996
+ value = isString(temp) ? temp : "";
997
+ } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) value = "";
998
+ else if (skipOnVariables) {
999
+ value = match[0];
1000
+ continue;
1001
+ } else {
1002
+ this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1003
+ value = "";
1004
+ }
1005
+ else if (!isString(value) && !this.useRawValueToEscape) value = makeString(value);
1006
+ const safeValue = todo.safeValue(value);
1007
+ str = str.replace(match[0], safeValue);
1008
+ if (skipOnVariables) {
1009
+ todo.regex.lastIndex += value.length;
1010
+ todo.regex.lastIndex -= match[0].length;
1011
+ } else todo.regex.lastIndex = 0;
1012
+ replaces++;
1013
+ if (replaces >= this.maxReplaces) break;
1014
+ }
1015
+ });
1016
+ return str;
1017
+ }
1018
+ nest(str, fc, options = {}) {
1019
+ let match;
1020
+ let value;
1021
+ let clonedOptions;
1022
+ const handleHasOptions = (key, inheritedOptions) => {
1023
+ const sep = this.nestingOptionsSeparator;
1024
+ if (key.indexOf(sep) < 0) return key;
1025
+ const c = key.split(new RegExp(`${sep}[ ]*{`));
1026
+ let optionsString = `{${c[1]}`;
1027
+ key = c[0];
1028
+ optionsString = this.interpolate(optionsString, clonedOptions);
1029
+ const matchedSingleQuotes = optionsString.match(/'/g);
1030
+ const matchedDoubleQuotes = optionsString.match(/"/g);
1031
+ if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) optionsString = optionsString.replace(/'/g, "\"");
1032
+ try {
1033
+ clonedOptions = JSON.parse(optionsString);
1034
+ if (inheritedOptions) clonedOptions = {
1035
+ ...inheritedOptions,
1036
+ ...clonedOptions
1037
+ };
1038
+ } catch (e) {
1039
+ this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1040
+ return `${key}${sep}${optionsString}`;
1041
+ }
1042
+ if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
1043
+ return key;
1044
+ };
1045
+ while (match = this.nestingRegexp.exec(str)) {
1046
+ let formatters = [];
1047
+ clonedOptions = { ...options };
1048
+ clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1049
+ clonedOptions.applyPostProcessor = false;
1050
+ delete clonedOptions.defaultValue;
1051
+ const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf("}") + 1 : match[1].indexOf(this.formatSeparator);
1052
+ if (keyEndIndex !== -1) {
1053
+ formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map((elem) => elem.trim()).filter(Boolean);
1054
+ match[1] = match[1].slice(0, keyEndIndex);
1055
+ }
1056
+ value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1057
+ if (value && match[0] === str && !isString(value)) return value;
1058
+ if (!isString(value)) value = makeString(value);
1059
+ if (!value) {
1060
+ this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1061
+ value = "";
1062
+ }
1063
+ if (formatters.length) value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1064
+ ...options,
1065
+ interpolationkey: match[1].trim()
1066
+ }), value.trim());
1067
+ str = str.replace(match[0], value);
1068
+ this.regexp.lastIndex = 0;
1069
+ }
1070
+ return str;
1071
+ }
1072
+ };
1073
+ var parseFormatStr = (formatStr) => {
1074
+ let formatName = formatStr.toLowerCase().trim();
1075
+ const formatOptions = {};
1076
+ if (formatStr.indexOf("(") > -1) {
1077
+ const p = formatStr.split("(");
1078
+ formatName = p[0].toLowerCase().trim();
1079
+ const optStr = p[1].substring(0, p[1].length - 1);
1080
+ if (formatName === "currency" && optStr.indexOf(":") < 0) {
1081
+ if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1082
+ } else if (formatName === "relativetime" && optStr.indexOf(":") < 0) {
1083
+ if (!formatOptions.range) formatOptions.range = optStr.trim();
1084
+ } else optStr.split(";").forEach((opt) => {
1085
+ if (opt) {
1086
+ const [key, ...rest] = opt.split(":");
1087
+ const val = rest.join(":").trim().replace(/^'+|'+$/g, "");
1088
+ const trimmedKey = key.trim();
1089
+ if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
1090
+ if (val === "false") formatOptions[trimmedKey] = false;
1091
+ if (val === "true") formatOptions[trimmedKey] = true;
1092
+ if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
1093
+ }
1094
+ });
1095
+ }
1096
+ return {
1097
+ formatName,
1098
+ formatOptions
1099
+ };
1100
+ };
1101
+ var createCachedFormatter = (fn) => {
1102
+ const cache = {};
1103
+ return (v, l, o) => {
1104
+ let optForCache = o;
1105
+ if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) optForCache = {
1106
+ ...optForCache,
1107
+ [o.interpolationkey]: void 0
1108
+ };
1109
+ const key = l + JSON.stringify(optForCache);
1110
+ let frm = cache[key];
1111
+ if (!frm) {
1112
+ frm = fn(getCleanedCode(l), o);
1113
+ cache[key] = frm;
1114
+ }
1115
+ return frm(v);
1116
+ };
1117
+ };
1118
+ var createNonCachedFormatter = (fn) => (v, l, o) => fn(getCleanedCode(l), o)(v);
1119
+ var Formatter = class {
1120
+ constructor(options = {}) {
1121
+ this.logger = baseLogger.create("formatter");
1122
+ this.options = options;
1123
+ this.init(options);
1124
+ }
1125
+ init(services, options = { interpolation: {} }) {
1126
+ this.formatSeparator = options.interpolation.formatSeparator || ",";
1127
+ const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
1128
+ this.formats = {
1129
+ number: cf((lng, opt) => {
1130
+ const formatter = new Intl.NumberFormat(lng, { ...opt });
1131
+ return (val) => formatter.format(val);
1132
+ }),
1133
+ currency: cf((lng, opt) => {
1134
+ const formatter = new Intl.NumberFormat(lng, {
1135
+ ...opt,
1136
+ style: "currency"
1137
+ });
1138
+ return (val) => formatter.format(val);
1139
+ }),
1140
+ datetime: cf((lng, opt) => {
1141
+ const formatter = new Intl.DateTimeFormat(lng, { ...opt });
1142
+ return (val) => formatter.format(val);
1143
+ }),
1144
+ relativetime: cf((lng, opt) => {
1145
+ const formatter = new Intl.RelativeTimeFormat(lng, { ...opt });
1146
+ return (val) => formatter.format(val, opt.range || "day");
1147
+ }),
1148
+ list: cf((lng, opt) => {
1149
+ const formatter = new Intl.ListFormat(lng, { ...opt });
1150
+ return (val) => formatter.format(val);
1151
+ })
1152
+ };
1153
+ }
1154
+ add(name, fc) {
1155
+ this.formats[name.toLowerCase().trim()] = fc;
1156
+ }
1157
+ addCached(name, fc) {
1158
+ this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1159
+ }
1160
+ format(value, format, lng, options = {}) {
1161
+ const formats = format.split(this.formatSeparator);
1162
+ if (formats.length > 1 && formats[0].indexOf("(") > 1 && formats[0].indexOf(")") < 0 && formats.find((f) => f.indexOf(")") > -1)) {
1163
+ const lastIndex = formats.findIndex((f) => f.indexOf(")") > -1);
1164
+ formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1165
+ }
1166
+ return formats.reduce((mem, f) => {
1167
+ const { formatName, formatOptions } = parseFormatStr(f);
1168
+ if (this.formats[formatName]) {
1169
+ let formatted = mem;
1170
+ try {
1171
+ const valOptions = options?.formatParams?.[options.interpolationkey] || {};
1172
+ const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1173
+ formatted = this.formats[formatName](mem, l, {
1174
+ ...formatOptions,
1175
+ ...options,
1176
+ ...valOptions
1177
+ });
1178
+ } catch (error) {
1179
+ this.logger.warn(error);
1180
+ }
1181
+ return formatted;
1182
+ } else this.logger.warn(`there was no format function for ${formatName}`);
1183
+ return mem;
1184
+ }, value);
1185
+ }
1186
+ };
1187
+ var removePending = (q, name) => {
1188
+ if (q.pending[name] !== void 0) {
1189
+ delete q.pending[name];
1190
+ q.pendingCount--;
1191
+ }
1192
+ };
1193
+ var Connector = class extends EventEmitter {
1194
+ constructor(backend, store, services, options = {}) {
1195
+ super();
1196
+ this.backend = backend;
1197
+ this.store = store;
1198
+ this.services = services;
1199
+ this.languageUtils = services.languageUtils;
1200
+ this.options = options;
1201
+ this.logger = baseLogger.create("backendConnector");
1202
+ this.waitingReads = [];
1203
+ this.maxParallelReads = options.maxParallelReads || 10;
1204
+ this.readingCalls = 0;
1205
+ this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1206
+ this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1207
+ this.state = {};
1208
+ this.queue = [];
1209
+ this.backend?.init?.(services, options.backend, options);
1210
+ }
1211
+ queueLoad(languages, namespaces, options, callback) {
1212
+ const toLoad = {};
1213
+ const pending = {};
1214
+ const toLoadLanguages = {};
1215
+ const toLoadNamespaces = {};
1216
+ languages.forEach((lng) => {
1217
+ let hasAllNamespaces = true;
1218
+ namespaces.forEach((ns) => {
1219
+ const name = `${lng}|${ns}`;
1220
+ if (!options.reload && this.store.hasResourceBundle(lng, ns)) this.state[name] = 2;
1221
+ else if (this.state[name] < 0);
1222
+ else if (this.state[name] === 1) {
1223
+ if (pending[name] === void 0) pending[name] = true;
1224
+ } else {
1225
+ this.state[name] = 1;
1226
+ hasAllNamespaces = false;
1227
+ if (pending[name] === void 0) pending[name] = true;
1228
+ if (toLoad[name] === void 0) toLoad[name] = true;
1229
+ if (toLoadNamespaces[ns] === void 0) toLoadNamespaces[ns] = true;
1230
+ }
1231
+ });
1232
+ if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1233
+ });
1234
+ if (Object.keys(toLoad).length || Object.keys(pending).length) this.queue.push({
1235
+ pending,
1236
+ pendingCount: Object.keys(pending).length,
1237
+ loaded: {},
1238
+ errors: [],
1239
+ callback
1240
+ });
1241
+ return {
1242
+ toLoad: Object.keys(toLoad),
1243
+ pending: Object.keys(pending),
1244
+ toLoadLanguages: Object.keys(toLoadLanguages),
1245
+ toLoadNamespaces: Object.keys(toLoadNamespaces)
1246
+ };
1247
+ }
1248
+ loaded(name, err, data) {
1249
+ const s = name.split("|");
1250
+ const lng = s[0];
1251
+ const ns = s[1];
1252
+ if (err) this.emit("failedLoading", lng, ns, err);
1253
+ if (!err && data) this.store.addResourceBundle(lng, ns, data, void 0, void 0, { skipCopy: true });
1254
+ this.state[name] = err ? -1 : 2;
1255
+ if (err && data) this.state[name] = 0;
1256
+ const loaded = {};
1257
+ this.queue.forEach((q) => {
1258
+ pushPath(q.loaded, [lng], ns);
1259
+ removePending(q, name);
1260
+ if (err) q.errors.push(err);
1261
+ if (q.pendingCount === 0 && !q.done) {
1262
+ Object.keys(q.loaded).forEach((l) => {
1263
+ if (!loaded[l]) loaded[l] = {};
1264
+ const loadedKeys = q.loaded[l];
1265
+ if (loadedKeys.length) loadedKeys.forEach((n) => {
1266
+ if (loaded[l][n] === void 0) loaded[l][n] = true;
1267
+ });
1268
+ });
1269
+ q.done = true;
1270
+ if (q.errors.length) q.callback(q.errors);
1271
+ else q.callback();
1272
+ }
1273
+ });
1274
+ this.emit("loaded", loaded);
1275
+ this.queue = this.queue.filter((q) => !q.done);
1276
+ }
1277
+ read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
1278
+ if (!lng.length) return callback(null, {});
1279
+ if (this.readingCalls >= this.maxParallelReads) {
1280
+ this.waitingReads.push({
1281
+ lng,
1282
+ ns,
1283
+ fcName,
1284
+ tried,
1285
+ wait,
1286
+ callback
1287
+ });
1288
+ return;
1289
+ }
1290
+ this.readingCalls++;
1291
+ const resolver = (err, data) => {
1292
+ this.readingCalls--;
1293
+ if (this.waitingReads.length > 0) {
1294
+ const next = this.waitingReads.shift();
1295
+ this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1296
+ }
1297
+ if (err && data && tried < this.maxRetries) {
1298
+ setTimeout(() => {
1299
+ this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1300
+ }, wait);
1301
+ return;
1302
+ }
1303
+ callback(err, data);
1304
+ };
1305
+ const fc = this.backend[fcName].bind(this.backend);
1306
+ if (fc.length === 2) {
1307
+ try {
1308
+ const r = fc(lng, ns);
1309
+ if (r && typeof r.then === "function") r.then((data) => resolver(null, data)).catch(resolver);
1310
+ else resolver(null, r);
1311
+ } catch (err) {
1312
+ resolver(err);
1313
+ }
1314
+ return;
1315
+ }
1316
+ return fc(lng, ns, resolver);
1317
+ }
1318
+ prepareLoading(languages, namespaces, options = {}, callback) {
1319
+ if (!this.backend) {
1320
+ this.logger.warn("No backend was added via i18next.use. Will not load resources.");
1321
+ return callback && callback();
1322
+ }
1323
+ if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1324
+ if (isString(namespaces)) namespaces = [namespaces];
1325
+ const toLoad = this.queueLoad(languages, namespaces, options, callback);
1326
+ if (!toLoad.toLoad.length) {
1327
+ if (!toLoad.pending.length) callback();
1328
+ return null;
1329
+ }
1330
+ toLoad.toLoad.forEach((name) => {
1331
+ this.loadOne(name);
1332
+ });
1333
+ }
1334
+ load(languages, namespaces, callback) {
1335
+ this.prepareLoading(languages, namespaces, {}, callback);
1336
+ }
1337
+ reload(languages, namespaces, callback) {
1338
+ this.prepareLoading(languages, namespaces, { reload: true }, callback);
1339
+ }
1340
+ loadOne(name, prefix = "") {
1341
+ const s = name.split("|");
1342
+ const lng = s[0];
1343
+ const ns = s[1];
1344
+ this.read(lng, ns, "read", void 0, void 0, (err, data) => {
1345
+ if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1346
+ if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1347
+ this.loaded(name, err, data);
1348
+ });
1349
+ }
1350
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
1351
+ if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
1352
+ this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" 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!!!");
1353
+ return;
1354
+ }
1355
+ if (key === void 0 || key === null || key === "") return;
1356
+ if (this.backend?.create) {
1357
+ const opts = {
1358
+ ...options,
1359
+ isUpdate
1360
+ };
1361
+ const fc = this.backend.create.bind(this.backend);
1362
+ if (fc.length < 6) try {
1363
+ let r;
1364
+ if (fc.length === 5) r = fc(languages, namespace, key, fallbackValue, opts);
1365
+ else r = fc(languages, namespace, key, fallbackValue);
1366
+ if (r && typeof r.then === "function") r.then((data) => clb(null, data)).catch(clb);
1367
+ else clb(null, r);
1368
+ } catch (err) {
1369
+ clb(err);
1370
+ }
1371
+ else fc(languages, namespace, key, fallbackValue, clb, opts);
1372
+ }
1373
+ if (!languages || !languages[0]) return;
1374
+ this.store.addResource(languages[0], namespace, key, fallbackValue);
1375
+ }
1376
+ };
1377
+ var get = () => ({
1378
+ debug: false,
1379
+ initAsync: true,
1380
+ ns: ["translation"],
1381
+ defaultNS: ["translation"],
1382
+ fallbackLng: ["dev"],
1383
+ fallbackNS: false,
1384
+ supportedLngs: false,
1385
+ nonExplicitSupportedLngs: false,
1386
+ load: "all",
1387
+ preload: false,
1388
+ simplifyPluralSuffix: true,
1389
+ keySeparator: ".",
1390
+ nsSeparator: ":",
1391
+ pluralSeparator: "_",
1392
+ contextSeparator: "_",
1393
+ partialBundledLanguages: false,
1394
+ saveMissing: false,
1395
+ updateMissing: false,
1396
+ saveMissingTo: "fallback",
1397
+ saveMissingPlurals: true,
1398
+ missingKeyHandler: false,
1399
+ missingInterpolationHandler: false,
1400
+ postProcess: false,
1401
+ postProcessPassResolved: false,
1402
+ returnNull: false,
1403
+ returnEmptyString: true,
1404
+ returnObjects: false,
1405
+ joinArrays: false,
1406
+ returnedObjectHandler: false,
1407
+ parseMissingKeyHandler: false,
1408
+ appendNamespaceToMissingKey: false,
1409
+ appendNamespaceToCIMode: false,
1410
+ overloadTranslationOptionHandler: (args) => {
1411
+ let ret = {};
1412
+ if (typeof args[1] === "object") ret = args[1];
1413
+ if (isString(args[1])) ret.defaultValue = args[1];
1414
+ if (isString(args[2])) ret.tDescription = args[2];
1415
+ if (typeof args[2] === "object" || typeof args[3] === "object") {
1416
+ const options = args[3] || args[2];
1417
+ Object.keys(options).forEach((key) => {
1418
+ ret[key] = options[key];
1419
+ });
1420
+ }
1421
+ return ret;
1422
+ },
1423
+ interpolation: {
1424
+ escapeValue: true,
1425
+ format: (value) => value,
1426
+ prefix: "{{",
1427
+ suffix: "}}",
1428
+ formatSeparator: ",",
1429
+ unescapePrefix: "-",
1430
+ nestingPrefix: "$t(",
1431
+ nestingSuffix: ")",
1432
+ nestingOptionsSeparator: ",",
1433
+ maxReplaces: 1e3,
1434
+ skipOnVariables: true
1435
+ },
1436
+ cacheInBuiltFormats: true
1437
+ });
1438
+ var transformOptions = (options) => {
1439
+ if (isString(options.ns)) options.ns = [options.ns];
1440
+ if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1441
+ if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1442
+ if (options.supportedLngs?.indexOf?.("cimode") < 0) options.supportedLngs = options.supportedLngs.concat(["cimode"]);
1443
+ if (typeof options.initImmediate === "boolean") options.initAsync = options.initImmediate;
1444
+ return options;
1445
+ };
1446
+ var noop = () => {};
1447
+ var bindMemberFunctions = (inst) => {
1448
+ Object.getOwnPropertyNames(Object.getPrototypeOf(inst)).forEach((mem) => {
1449
+ if (typeof inst[mem] === "function") inst[mem] = inst[mem].bind(inst);
1450
+ });
1451
+ };
1452
+ var instance = class I18n extends EventEmitter {
1453
+ constructor(options = {}, callback) {
1454
+ super();
1455
+ this.options = transformOptions(options);
1456
+ this.services = {};
1457
+ this.logger = baseLogger;
1458
+ this.modules = { external: [] };
1459
+ bindMemberFunctions(this);
1460
+ if (callback && !this.isInitialized && !options.isClone) {
1461
+ if (!this.options.initAsync) {
1462
+ this.init(options, callback);
1463
+ return this;
1464
+ }
1465
+ setTimeout(() => {
1466
+ this.init(options, callback);
1467
+ }, 0);
1468
+ }
1469
+ }
1470
+ init(options = {}, callback) {
1471
+ this.isInitializing = true;
1472
+ if (typeof options === "function") {
1473
+ callback = options;
1474
+ options = {};
1475
+ }
1476
+ if (options.defaultNS == null && options.ns) {
1477
+ if (isString(options.ns)) options.defaultNS = options.ns;
1478
+ else if (options.ns.indexOf("translation") < 0) options.defaultNS = options.ns[0];
1479
+ }
1480
+ const defOpts = get();
1481
+ this.options = {
1482
+ ...defOpts,
1483
+ ...this.options,
1484
+ ...transformOptions(options)
1485
+ };
1486
+ this.options.interpolation = {
1487
+ ...defOpts.interpolation,
1488
+ ...this.options.interpolation
1489
+ };
1490
+ if (options.keySeparator !== void 0) this.options.userDefinedKeySeparator = options.keySeparator;
1491
+ if (options.nsSeparator !== void 0) this.options.userDefinedNsSeparator = options.nsSeparator;
1492
+ const createClassOnDemand = (ClassOrObject) => {
1493
+ if (!ClassOrObject) return null;
1494
+ if (typeof ClassOrObject === "function") return new ClassOrObject();
1495
+ return ClassOrObject;
1496
+ };
1497
+ if (!this.options.isClone) {
1498
+ if (this.modules.logger) baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1499
+ else baseLogger.init(null, this.options);
1500
+ let formatter;
1501
+ if (this.modules.formatter) formatter = this.modules.formatter;
1502
+ else formatter = Formatter;
1503
+ const lu = new LanguageUtil(this.options);
1504
+ this.store = new ResourceStore(this.options.resources, this.options);
1505
+ const s = this.services;
1506
+ s.logger = baseLogger;
1507
+ s.resourceStore = this.store;
1508
+ s.languageUtils = lu;
1509
+ s.pluralResolver = new PluralResolver(lu, {
1510
+ prepend: this.options.pluralSeparator,
1511
+ simplifyPluralSuffix: this.options.simplifyPluralSuffix
1512
+ });
1513
+ if (this.options.interpolation.format && this.options.interpolation.format !== defOpts.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`);
1514
+ if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1515
+ s.formatter = createClassOnDemand(formatter);
1516
+ if (s.formatter.init) s.formatter.init(s, this.options);
1517
+ this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1518
+ }
1519
+ s.interpolator = new Interpolator(this.options);
1520
+ s.utils = { hasLoadedNamespace: this.hasLoadedNamespace.bind(this) };
1521
+ s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1522
+ s.backendConnector.on("*", (event, ...args) => {
1523
+ this.emit(event, ...args);
1524
+ });
1525
+ if (this.modules.languageDetector) {
1526
+ s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1527
+ if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1528
+ }
1529
+ if (this.modules.i18nFormat) {
1530
+ s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1531
+ if (s.i18nFormat.init) s.i18nFormat.init(this);
1532
+ }
1533
+ this.translator = new Translator(this.services, this.options);
1534
+ this.translator.on("*", (event, ...args) => {
1535
+ this.emit(event, ...args);
1536
+ });
1537
+ this.modules.external.forEach((m) => {
1538
+ if (m.init) m.init(this);
1539
+ });
1540
+ }
1541
+ this.format = this.options.interpolation.format;
1542
+ if (!callback) callback = noop;
1543
+ if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1544
+ const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1545
+ if (codes.length > 0 && codes[0] !== "dev") this.options.lng = codes[0];
1546
+ }
1547
+ if (!this.services.languageDetector && !this.options.lng) this.logger.warn("init: no languageDetector is used and no lng is defined");
1548
+ [
1549
+ "getResource",
1550
+ "hasResourceBundle",
1551
+ "getResourceBundle",
1552
+ "getDataByLanguage"
1553
+ ].forEach((fcName) => {
1554
+ this[fcName] = (...args) => this.store[fcName](...args);
1555
+ });
1556
+ [
1557
+ "addResource",
1558
+ "addResources",
1559
+ "addResourceBundle",
1560
+ "removeResourceBundle"
1561
+ ].forEach((fcName) => {
1562
+ this[fcName] = (...args) => {
1563
+ this.store[fcName](...args);
1564
+ return this;
1565
+ };
1566
+ });
1567
+ const deferred = defer();
1568
+ const load = () => {
1569
+ const finish = (err, t) => {
1570
+ this.isInitializing = false;
1571
+ if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn("init: i18next is already initialized. You should call init just once!");
1572
+ this.isInitialized = true;
1573
+ if (!this.options.isClone) this.logger.log("initialized", this.options);
1574
+ this.emit("initialized", this.options);
1575
+ deferred.resolve(t);
1576
+ callback(err, t);
1577
+ };
1578
+ if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
1579
+ this.changeLanguage(this.options.lng, finish);
1580
+ };
1581
+ if (this.options.resources || !this.options.initAsync) load();
1582
+ else setTimeout(load, 0);
1583
+ return deferred;
1584
+ }
1585
+ loadResources(language, callback = noop) {
1586
+ let usedCallback = callback;
1587
+ const usedLng = isString(language) ? language : this.language;
1588
+ if (typeof language === "function") usedCallback = language;
1589
+ if (!this.options.resources || this.options.partialBundledLanguages) {
1590
+ if (usedLng?.toLowerCase() === "cimode" && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
1591
+ const toLoad = [];
1592
+ const append = (lng) => {
1593
+ if (!lng) return;
1594
+ if (lng === "cimode") return;
1595
+ this.services.languageUtils.toResolveHierarchy(lng).forEach((l) => {
1596
+ if (l === "cimode") return;
1597
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
1598
+ });
1599
+ };
1600
+ if (!usedLng) this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((l) => append(l));
1601
+ else append(usedLng);
1602
+ this.options.preload?.forEach?.((l) => append(l));
1603
+ this.services.backendConnector.load(toLoad, this.options.ns, (e) => {
1604
+ if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
1605
+ usedCallback(e);
1606
+ });
1607
+ } else usedCallback(null);
1608
+ }
1609
+ reloadResources(lngs, ns, callback) {
1610
+ const deferred = defer();
1611
+ if (typeof lngs === "function") {
1612
+ callback = lngs;
1613
+ lngs = void 0;
1614
+ }
1615
+ if (typeof ns === "function") {
1616
+ callback = ns;
1617
+ ns = void 0;
1618
+ }
1619
+ if (!lngs) lngs = this.languages;
1620
+ if (!ns) ns = this.options.ns;
1621
+ if (!callback) callback = noop;
1622
+ this.services.backendConnector.reload(lngs, ns, (err) => {
1623
+ deferred.resolve();
1624
+ callback(err);
1625
+ });
1626
+ return deferred;
1627
+ }
1628
+ use(module) {
1629
+ if (!module) throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");
1630
+ if (!module.type) throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");
1631
+ if (module.type === "backend") this.modules.backend = module;
1632
+ if (module.type === "logger" || module.log && module.warn && module.error) this.modules.logger = module;
1633
+ if (module.type === "languageDetector") this.modules.languageDetector = module;
1634
+ if (module.type === "i18nFormat") this.modules.i18nFormat = module;
1635
+ if (module.type === "postProcessor") postProcessor.addPostProcessor(module);
1636
+ if (module.type === "formatter") this.modules.formatter = module;
1637
+ if (module.type === "3rdParty") this.modules.external.push(module);
1638
+ return this;
1639
+ }
1640
+ setResolvedLanguage(l) {
1641
+ if (!l || !this.languages) return;
1642
+ if (["cimode", "dev"].indexOf(l) > -1) return;
1643
+ for (let li = 0; li < this.languages.length; li++) {
1644
+ const lngInLngs = this.languages[li];
1645
+ if (["cimode", "dev"].indexOf(lngInLngs) > -1) continue;
1646
+ if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
1647
+ this.resolvedLanguage = lngInLngs;
1648
+ break;
1649
+ }
1650
+ }
1651
+ if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
1652
+ this.resolvedLanguage = l;
1653
+ this.languages.unshift(l);
1654
+ }
1655
+ }
1656
+ changeLanguage(lng, callback) {
1657
+ this.isLanguageChangingTo = lng;
1658
+ const deferred = defer();
1659
+ this.emit("languageChanging", lng);
1660
+ const setLngProps = (l) => {
1661
+ this.language = l;
1662
+ this.languages = this.services.languageUtils.toResolveHierarchy(l);
1663
+ this.resolvedLanguage = void 0;
1664
+ this.setResolvedLanguage(l);
1665
+ };
1666
+ const done = (err, l) => {
1667
+ if (l) {
1668
+ if (this.isLanguageChangingTo === lng) {
1669
+ setLngProps(l);
1670
+ this.translator.changeLanguage(l);
1671
+ this.isLanguageChangingTo = void 0;
1672
+ this.emit("languageChanged", l);
1673
+ this.logger.log("languageChanged", l);
1674
+ }
1675
+ } else this.isLanguageChangingTo = void 0;
1676
+ deferred.resolve((...args) => this.t(...args));
1677
+ if (callback) callback(err, (...args) => this.t(...args));
1678
+ };
1679
+ const setLng = (lngs) => {
1680
+ if (!lng && !lngs && this.services.languageDetector) lngs = [];
1681
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
1682
+ const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
1683
+ if (l) {
1684
+ if (!this.language) setLngProps(l);
1685
+ if (!this.translator.language) this.translator.changeLanguage(l);
1686
+ this.services.languageDetector?.cacheUserLanguage?.(l);
1687
+ }
1688
+ this.loadResources(l, (err) => {
1689
+ done(err, l);
1690
+ });
1691
+ };
1692
+ if (!lng && this.services.languageDetector && !this.services.languageDetector.async) setLng(this.services.languageDetector.detect());
1693
+ else if (!lng && this.services.languageDetector && this.services.languageDetector.async) if (this.services.languageDetector.detect.length === 0) this.services.languageDetector.detect().then(setLng);
1694
+ else this.services.languageDetector.detect(setLng);
1695
+ else setLng(lng);
1696
+ return deferred;
1697
+ }
1698
+ getFixedT(lng, ns, keyPrefix) {
1699
+ const fixedT = (key, opts, ...rest) => {
1700
+ let o;
1701
+ if (typeof opts !== "object") o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
1702
+ else o = { ...opts };
1703
+ o.lng = o.lng || fixedT.lng;
1704
+ o.lngs = o.lngs || fixedT.lngs;
1705
+ o.ns = o.ns || fixedT.ns;
1706
+ if (o.keyPrefix !== "") o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
1707
+ const keySeparator = this.options.keySeparator || ".";
1708
+ let resultKey;
1709
+ if (o.keyPrefix && Array.isArray(key)) resultKey = key.map((k) => {
1710
+ if (typeof k === "function") k = keysFromSelector(k, {
1711
+ ...this.options,
1712
+ ...opts
1713
+ });
1714
+ return `${o.keyPrefix}${keySeparator}${k}`;
1715
+ });
1716
+ else {
1717
+ if (typeof key === "function") key = keysFromSelector(key, {
1718
+ ...this.options,
1719
+ ...opts
1720
+ });
1721
+ resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
1722
+ }
1723
+ return this.t(resultKey, o);
1724
+ };
1725
+ if (isString(lng)) fixedT.lng = lng;
1726
+ else fixedT.lngs = lng;
1727
+ fixedT.ns = ns;
1728
+ fixedT.keyPrefix = keyPrefix;
1729
+ return fixedT;
1730
+ }
1731
+ t(...args) {
1732
+ return this.translator?.translate(...args);
1733
+ }
1734
+ exists(...args) {
1735
+ return this.translator?.exists(...args);
1736
+ }
1737
+ setDefaultNamespace(ns) {
1738
+ this.options.defaultNS = ns;
1739
+ }
1740
+ hasLoadedNamespace(ns, options = {}) {
1741
+ if (!this.isInitialized) {
1742
+ this.logger.warn("hasLoadedNamespace: i18next was not initialized", this.languages);
1743
+ return false;
1744
+ }
1745
+ if (!this.languages || !this.languages.length) {
1746
+ this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty", this.languages);
1747
+ return false;
1748
+ }
1749
+ const lng = options.lng || this.resolvedLanguage || this.languages[0];
1750
+ const fallbackLng = this.options ? this.options.fallbackLng : false;
1751
+ const lastLng = this.languages[this.languages.length - 1];
1752
+ if (lng.toLowerCase() === "cimode") return true;
1753
+ const loadNotPending = (l, n) => {
1754
+ const loadState = this.services.backendConnector.state[`${l}|${n}`];
1755
+ return loadState === -1 || loadState === 0 || loadState === 2;
1756
+ };
1757
+ if (options.precheck) {
1758
+ const preResult = options.precheck(this, loadNotPending);
1759
+ if (preResult !== void 0) return preResult;
1760
+ }
1761
+ if (this.hasResourceBundle(lng, ns)) return true;
1762
+ if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
1763
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
1764
+ return false;
1765
+ }
1766
+ loadNamespaces(ns, callback) {
1767
+ const deferred = defer();
1768
+ if (!this.options.ns) {
1769
+ if (callback) callback();
1770
+ return Promise.resolve();
1771
+ }
1772
+ if (isString(ns)) ns = [ns];
1773
+ ns.forEach((n) => {
1774
+ if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
1775
+ });
1776
+ this.loadResources((err) => {
1777
+ deferred.resolve();
1778
+ if (callback) callback(err);
1779
+ });
1780
+ return deferred;
1781
+ }
1782
+ loadLanguages(lngs, callback) {
1783
+ const deferred = defer();
1784
+ if (isString(lngs)) lngs = [lngs];
1785
+ const preloaded = this.options.preload || [];
1786
+ const newLngs = lngs.filter((lng) => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
1787
+ if (!newLngs.length) {
1788
+ if (callback) callback();
1789
+ return Promise.resolve();
1790
+ }
1791
+ this.options.preload = preloaded.concat(newLngs);
1792
+ this.loadResources((err) => {
1793
+ deferred.resolve();
1794
+ if (callback) callback(err);
1795
+ });
1796
+ return deferred;
1797
+ }
1798
+ dir(lng) {
1799
+ if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
1800
+ if (!lng) return "rtl";
1801
+ try {
1802
+ const l = new Intl.Locale(lng);
1803
+ if (l && l.getTextInfo) {
1804
+ const ti = l.getTextInfo();
1805
+ if (ti && ti.direction) return ti.direction;
1806
+ }
1807
+ } catch (e) {}
1808
+ const rtlLngs = [
1809
+ "ar",
1810
+ "shu",
1811
+ "sqr",
1812
+ "ssh",
1813
+ "xaa",
1814
+ "yhd",
1815
+ "yud",
1816
+ "aao",
1817
+ "abh",
1818
+ "abv",
1819
+ "acm",
1820
+ "acq",
1821
+ "acw",
1822
+ "acx",
1823
+ "acy",
1824
+ "adf",
1825
+ "ads",
1826
+ "aeb",
1827
+ "aec",
1828
+ "afb",
1829
+ "ajp",
1830
+ "apc",
1831
+ "apd",
1832
+ "arb",
1833
+ "arq",
1834
+ "ars",
1835
+ "ary",
1836
+ "arz",
1837
+ "auz",
1838
+ "avl",
1839
+ "ayh",
1840
+ "ayl",
1841
+ "ayn",
1842
+ "ayp",
1843
+ "bbz",
1844
+ "pga",
1845
+ "he",
1846
+ "iw",
1847
+ "ps",
1848
+ "pbt",
1849
+ "pbu",
1850
+ "pst",
1851
+ "prp",
1852
+ "prd",
1853
+ "ug",
1854
+ "ur",
1855
+ "ydd",
1856
+ "yds",
1857
+ "yih",
1858
+ "ji",
1859
+ "yi",
1860
+ "hbo",
1861
+ "men",
1862
+ "xmn",
1863
+ "fa",
1864
+ "jpr",
1865
+ "peo",
1866
+ "pes",
1867
+ "prs",
1868
+ "dv",
1869
+ "sam",
1870
+ "ckb"
1871
+ ];
1872
+ const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
1873
+ if (lng.toLowerCase().indexOf("-latn") > 1) return "ltr";
1874
+ return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf("-arab") > 1 ? "rtl" : "ltr";
1875
+ }
1876
+ static createInstance(options = {}, callback) {
1877
+ const instance = new I18n(options, callback);
1878
+ instance.createInstance = I18n.createInstance;
1879
+ return instance;
1880
+ }
1881
+ cloneInstance(options = {}, callback = noop) {
1882
+ const forkResourceStore = options.forkResourceStore;
1883
+ if (forkResourceStore) delete options.forkResourceStore;
1884
+ const mergedOptions = {
1885
+ ...this.options,
1886
+ ...options,
1887
+ isClone: true
1888
+ };
1889
+ const clone = new I18n(mergedOptions);
1890
+ if (options.debug !== void 0 || options.prefix !== void 0) clone.logger = clone.logger.clone(options);
1891
+ [
1892
+ "store",
1893
+ "services",
1894
+ "language"
1895
+ ].forEach((m) => {
1896
+ clone[m] = this[m];
1897
+ });
1898
+ clone.services = { ...this.services };
1899
+ clone.services.utils = { hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) };
1900
+ if (forkResourceStore) {
1901
+ clone.store = new ResourceStore(Object.keys(this.store.data).reduce((prev, l) => {
1902
+ prev[l] = { ...this.store.data[l] };
1903
+ prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
1904
+ acc[n] = { ...prev[l][n] };
1905
+ return acc;
1906
+ }, prev[l]);
1907
+ return prev;
1908
+ }, {}), mergedOptions);
1909
+ clone.services.resourceStore = clone.store;
1910
+ }
1911
+ if (options.interpolation) clone.services.interpolator = new Interpolator(mergedOptions);
1912
+ clone.translator = new Translator(clone.services, mergedOptions);
1913
+ clone.translator.on("*", (event, ...args) => {
1914
+ clone.emit(event, ...args);
1915
+ });
1916
+ clone.init(mergedOptions, callback);
1917
+ clone.translator.options = mergedOptions;
1918
+ clone.translator.backendConnector.services.utils = { hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone) };
1919
+ return clone;
1920
+ }
1921
+ toJSON() {
1922
+ return {
1923
+ options: this.options,
1924
+ store: this.store,
1925
+ language: this.language,
1926
+ languages: this.languages,
1927
+ resolvedLanguage: this.resolvedLanguage
1928
+ };
1929
+ }
1930
+ }.createInstance();
1931
+ instance.createInstance;
1932
+ instance.dir;
1933
+ instance.init;
1934
+ instance.loadResources;
1935
+ instance.reloadResources;
1936
+ instance.use;
1937
+ instance.changeLanguage;
1938
+ instance.getFixedT;
1939
+ instance.t;
1940
+ instance.exists;
1941
+ instance.setDefaultNamespace;
1942
+ instance.hasLoadedNamespace;
1943
+ instance.loadNamespaces;
1944
+ instance.loadLanguages;
1945
+ //#endregion
1946
+ //#region ../../node_modules/.pnpm/i18next-browser-languagedetector@8.2.0/node_modules/i18next-browser-languagedetector/dist/esm/i18nextBrowserLanguageDetector.js
1947
+ var { slice: slice$1, forEach } = [];
1948
+ function defaults(obj) {
1949
+ forEach.call(slice$1.call(arguments, 1), (source) => {
1950
+ if (source) {
1951
+ for (const prop in source) if (obj[prop] === void 0) obj[prop] = source[prop];
1952
+ }
1953
+ });
1954
+ return obj;
1955
+ }
1956
+ function hasXSS(input) {
1957
+ if (typeof input !== "string") return false;
1958
+ return [
1959
+ /<\s*script.*?>/i,
1960
+ /<\s*\/\s*script\s*>/i,
1961
+ /<\s*img.*?on\w+\s*=/i,
1962
+ /<\s*\w+\s*on\w+\s*=.*?>/i,
1963
+ /javascript\s*:/i,
1964
+ /vbscript\s*:/i,
1965
+ /expression\s*\(/i,
1966
+ /eval\s*\(/i,
1967
+ /alert\s*\(/i,
1968
+ /document\.cookie/i,
1969
+ /document\.write\s*\(/i,
1970
+ /window\.location/i,
1971
+ /innerHTML/i
1972
+ ].some((pattern) => pattern.test(input));
1973
+ }
1974
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
1975
+ var serializeCookie = function(name, val) {
1976
+ const opt = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : { path: "/" };
1977
+ let str = `${name}=${encodeURIComponent(val)}`;
1978
+ if (opt.maxAge > 0) {
1979
+ const maxAge = opt.maxAge - 0;
1980
+ if (Number.isNaN(maxAge)) throw new Error("maxAge should be a Number");
1981
+ str += `; Max-Age=${Math.floor(maxAge)}`;
1982
+ }
1983
+ if (opt.domain) {
1984
+ if (!fieldContentRegExp.test(opt.domain)) throw new TypeError("option domain is invalid");
1985
+ str += `; Domain=${opt.domain}`;
1986
+ }
1987
+ if (opt.path) {
1988
+ if (!fieldContentRegExp.test(opt.path)) throw new TypeError("option path is invalid");
1989
+ str += `; Path=${opt.path}`;
1990
+ }
1991
+ if (opt.expires) {
1992
+ if (typeof opt.expires.toUTCString !== "function") throw new TypeError("option expires is invalid");
1993
+ str += `; Expires=${opt.expires.toUTCString()}`;
1994
+ }
1995
+ if (opt.httpOnly) str += "; HttpOnly";
1996
+ if (opt.secure) str += "; Secure";
1997
+ if (opt.sameSite) switch (typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite) {
1998
+ case true:
1999
+ str += "; SameSite=Strict";
2000
+ break;
2001
+ case "lax":
2002
+ str += "; SameSite=Lax";
2003
+ break;
2004
+ case "strict":
2005
+ str += "; SameSite=Strict";
2006
+ break;
2007
+ case "none":
2008
+ str += "; SameSite=None";
2009
+ break;
2010
+ default: throw new TypeError("option sameSite is invalid");
2011
+ }
2012
+ if (opt.partitioned) str += "; Partitioned";
2013
+ return str;
2014
+ };
2015
+ var cookie = {
2016
+ create(name, value, minutes, domain) {
2017
+ let cookieOptions = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {
2018
+ path: "/",
2019
+ sameSite: "strict"
2020
+ };
2021
+ if (minutes) {
2022
+ cookieOptions.expires = /* @__PURE__ */ new Date();
2023
+ cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1e3);
2024
+ }
2025
+ if (domain) cookieOptions.domain = domain;
2026
+ document.cookie = serializeCookie(name, value, cookieOptions);
2027
+ },
2028
+ read(name) {
2029
+ const nameEQ = `${name}=`;
2030
+ const ca = document.cookie.split(";");
2031
+ for (let i = 0; i < ca.length; i++) {
2032
+ let c = ca[i];
2033
+ while (c.charAt(0) === " ") c = c.substring(1, c.length);
2034
+ if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
2035
+ }
2036
+ return null;
2037
+ },
2038
+ remove(name, domain) {
2039
+ this.create(name, "", -1, domain);
2040
+ }
2041
+ };
2042
+ var cookie$1 = {
2043
+ name: "cookie",
2044
+ lookup(_ref) {
2045
+ let { lookupCookie } = _ref;
2046
+ if (lookupCookie && typeof document !== "undefined") return cookie.read(lookupCookie) || void 0;
2047
+ },
2048
+ cacheUserLanguage(lng, _ref2) {
2049
+ let { lookupCookie, cookieMinutes, cookieDomain, cookieOptions } = _ref2;
2050
+ if (lookupCookie && typeof document !== "undefined") cookie.create(lookupCookie, lng, cookieMinutes, cookieDomain, cookieOptions);
2051
+ }
2052
+ };
2053
+ var querystring = {
2054
+ name: "querystring",
2055
+ lookup(_ref) {
2056
+ let { lookupQuerystring } = _ref;
2057
+ let found;
2058
+ if (typeof window !== "undefined") {
2059
+ let { search } = window.location;
2060
+ if (!window.location.search && window.location.hash?.indexOf("?") > -1) search = window.location.hash.substring(window.location.hash.indexOf("?"));
2061
+ const params = search.substring(1).split("&");
2062
+ for (let i = 0; i < params.length; i++) {
2063
+ const pos = params[i].indexOf("=");
2064
+ if (pos > 0) {
2065
+ if (params[i].substring(0, pos) === lookupQuerystring) found = params[i].substring(pos + 1);
2066
+ }
2067
+ }
2068
+ }
2069
+ return found;
2070
+ }
2071
+ };
2072
+ var hash = {
2073
+ name: "hash",
2074
+ lookup(_ref) {
2075
+ let { lookupHash, lookupFromHashIndex } = _ref;
2076
+ let found;
2077
+ if (typeof window !== "undefined") {
2078
+ const { hash } = window.location;
2079
+ if (hash && hash.length > 2) {
2080
+ const query = hash.substring(1);
2081
+ if (lookupHash) {
2082
+ const params = query.split("&");
2083
+ for (let i = 0; i < params.length; i++) {
2084
+ const pos = params[i].indexOf("=");
2085
+ if (pos > 0) {
2086
+ if (params[i].substring(0, pos) === lookupHash) found = params[i].substring(pos + 1);
2087
+ }
2088
+ }
2089
+ }
2090
+ if (found) return found;
2091
+ if (!found && lookupFromHashIndex > -1) {
2092
+ const language = hash.match(/\/([a-zA-Z-]*)/g);
2093
+ if (!Array.isArray(language)) return void 0;
2094
+ return language[typeof lookupFromHashIndex === "number" ? lookupFromHashIndex : 0]?.replace("/", "");
2095
+ }
2096
+ }
2097
+ }
2098
+ return found;
2099
+ }
2100
+ };
2101
+ var hasLocalStorageSupport = null;
2102
+ var localStorageAvailable = () => {
2103
+ if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
2104
+ try {
2105
+ hasLocalStorageSupport = typeof window !== "undefined" && window.localStorage !== null;
2106
+ if (!hasLocalStorageSupport) return false;
2107
+ const testKey = "i18next.translate.boo";
2108
+ window.localStorage.setItem(testKey, "foo");
2109
+ window.localStorage.removeItem(testKey);
2110
+ } catch (e) {
2111
+ hasLocalStorageSupport = false;
2112
+ }
2113
+ return hasLocalStorageSupport;
2114
+ };
2115
+ var localStorage$1 = {
2116
+ name: "localStorage",
2117
+ lookup(_ref) {
2118
+ let { lookupLocalStorage } = _ref;
2119
+ if (lookupLocalStorage && localStorageAvailable()) return window.localStorage.getItem(lookupLocalStorage) || void 0;
2120
+ },
2121
+ cacheUserLanguage(lng, _ref2) {
2122
+ let { lookupLocalStorage } = _ref2;
2123
+ if (lookupLocalStorage && localStorageAvailable()) window.localStorage.setItem(lookupLocalStorage, lng);
2124
+ }
2125
+ };
2126
+ var hasSessionStorageSupport = null;
2127
+ var sessionStorageAvailable = () => {
2128
+ if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
2129
+ try {
2130
+ hasSessionStorageSupport = typeof window !== "undefined" && window.sessionStorage !== null;
2131
+ if (!hasSessionStorageSupport) return false;
2132
+ const testKey = "i18next.translate.boo";
2133
+ window.sessionStorage.setItem(testKey, "foo");
2134
+ window.sessionStorage.removeItem(testKey);
2135
+ } catch (e) {
2136
+ hasSessionStorageSupport = false;
2137
+ }
2138
+ return hasSessionStorageSupport;
2139
+ };
2140
+ var sessionStorage = {
2141
+ name: "sessionStorage",
2142
+ lookup(_ref) {
2143
+ let { lookupSessionStorage } = _ref;
2144
+ if (lookupSessionStorage && sessionStorageAvailable()) return window.sessionStorage.getItem(lookupSessionStorage) || void 0;
2145
+ },
2146
+ cacheUserLanguage(lng, _ref2) {
2147
+ let { lookupSessionStorage } = _ref2;
2148
+ if (lookupSessionStorage && sessionStorageAvailable()) window.sessionStorage.setItem(lookupSessionStorage, lng);
2149
+ }
2150
+ };
2151
+ var navigator$1 = {
2152
+ name: "navigator",
2153
+ lookup(options) {
2154
+ const found = [];
2155
+ if (typeof navigator !== "undefined") {
2156
+ const { languages, userLanguage, language } = navigator;
2157
+ if (languages) for (let i = 0; i < languages.length; i++) found.push(languages[i]);
2158
+ if (userLanguage) found.push(userLanguage);
2159
+ if (language) found.push(language);
2160
+ }
2161
+ return found.length > 0 ? found : void 0;
2162
+ }
2163
+ };
2164
+ var htmlTag = {
2165
+ name: "htmlTag",
2166
+ lookup(_ref) {
2167
+ let { htmlTag } = _ref;
2168
+ let found;
2169
+ const internalHtmlTag = htmlTag || (typeof document !== "undefined" ? document.documentElement : null);
2170
+ if (internalHtmlTag && typeof internalHtmlTag.getAttribute === "function") found = internalHtmlTag.getAttribute("lang");
2171
+ return found;
2172
+ }
2173
+ };
2174
+ var path = {
2175
+ name: "path",
2176
+ lookup(_ref) {
2177
+ let { lookupFromPathIndex } = _ref;
2178
+ if (typeof window === "undefined") return void 0;
2179
+ const language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
2180
+ if (!Array.isArray(language)) return void 0;
2181
+ return language[typeof lookupFromPathIndex === "number" ? lookupFromPathIndex : 0]?.replace("/", "");
2182
+ }
2183
+ };
2184
+ var subdomain = {
2185
+ name: "subdomain",
2186
+ lookup(_ref) {
2187
+ let { lookupFromSubdomainIndex } = _ref;
2188
+ const internalLookupFromSubdomainIndex = typeof lookupFromSubdomainIndex === "number" ? lookupFromSubdomainIndex + 1 : 1;
2189
+ const language = typeof window !== "undefined" && window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
2190
+ if (!language) return void 0;
2191
+ return language[internalLookupFromSubdomainIndex];
2192
+ }
2193
+ };
2194
+ var canCookies = false;
2195
+ try {
2196
+ document.cookie;
2197
+ canCookies = true;
2198
+ } catch (e) {}
2199
+ var order = [
2200
+ "querystring",
2201
+ "cookie",
2202
+ "localStorage",
2203
+ "sessionStorage",
2204
+ "navigator",
2205
+ "htmlTag"
2206
+ ];
2207
+ if (!canCookies) order.splice(1, 1);
2208
+ var getDefaults$1 = () => ({
2209
+ order,
2210
+ lookupQuerystring: "lng",
2211
+ lookupCookie: "i18next",
2212
+ lookupLocalStorage: "i18nextLng",
2213
+ lookupSessionStorage: "i18nextLng",
2214
+ caches: ["localStorage"],
2215
+ excludeCacheFor: ["cimode"],
2216
+ convertDetectedLanguage: (l) => l
2217
+ });
2218
+ var Browser = class {
2219
+ constructor(services) {
2220
+ let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2221
+ this.type = "languageDetector";
2222
+ this.detectors = {};
2223
+ this.init(services, options);
2224
+ }
2225
+ init() {
2226
+ let services = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { languageUtils: {} };
2227
+ let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2228
+ let i18nOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2229
+ this.services = services;
2230
+ this.options = defaults(options, this.options || {}, getDefaults$1());
2231
+ if (typeof this.options.convertDetectedLanguage === "string" && this.options.convertDetectedLanguage.indexOf("15897") > -1) this.options.convertDetectedLanguage = (l) => l.replace("-", "_");
2232
+ if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
2233
+ this.i18nOptions = i18nOptions;
2234
+ this.addDetector(cookie$1);
2235
+ this.addDetector(querystring);
2236
+ this.addDetector(localStorage$1);
2237
+ this.addDetector(sessionStorage);
2238
+ this.addDetector(navigator$1);
2239
+ this.addDetector(htmlTag);
2240
+ this.addDetector(path);
2241
+ this.addDetector(subdomain);
2242
+ this.addDetector(hash);
2243
+ }
2244
+ addDetector(detector) {
2245
+ this.detectors[detector.name] = detector;
2246
+ return this;
2247
+ }
2248
+ detect() {
2249
+ let detectionOrder = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.options.order;
2250
+ let detected = [];
2251
+ detectionOrder.forEach((detectorName) => {
2252
+ if (this.detectors[detectorName]) {
2253
+ let lookup = this.detectors[detectorName].lookup(this.options);
2254
+ if (lookup && typeof lookup === "string") lookup = [lookup];
2255
+ if (lookup) detected = detected.concat(lookup);
2256
+ }
2257
+ });
2258
+ detected = detected.filter((d) => d !== void 0 && d !== null && !hasXSS(d)).map((d) => this.options.convertDetectedLanguage(d));
2259
+ if (this.services && this.services.languageUtils && this.services.languageUtils.getBestMatchFromCodes) return detected;
2260
+ return detected.length > 0 ? detected[0] : null;
2261
+ }
2262
+ cacheUserLanguage(lng) {
2263
+ let caches = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : this.options.caches;
2264
+ if (!caches) return;
2265
+ if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
2266
+ caches.forEach((cacheName) => {
2267
+ if (this.detectors[cacheName]) this.detectors[cacheName].cacheUserLanguage(lng, this.options);
2268
+ });
2269
+ }
2270
+ };
2271
+ Browser.type = "languageDetector";
2272
+ //#endregion
2273
+ //#region ../../node_modules/.pnpm/i18next-http-backend@3.0.2/node_modules/i18next-http-backend/esm/utils.js
2274
+ function _typeof$2(o) {
2275
+ "@babel/helpers - typeof";
2276
+ return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
2277
+ return typeof o;
2278
+ } : function(o) {
2279
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
2280
+ }, _typeof$2(o);
2281
+ }
2282
+ var arr = [];
2283
+ arr.forEach;
2284
+ arr.slice;
2285
+ function hasXMLHttpRequest() {
2286
+ return typeof XMLHttpRequest === "function" || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof$2(XMLHttpRequest)) === "object";
2287
+ }
2288
+ function isPromise(maybePromise) {
2289
+ return !!maybePromise && typeof maybePromise.then === "function";
2290
+ }
2291
+ function makePromise(maybePromise) {
2292
+ if (isPromise(maybePromise)) return maybePromise;
2293
+ return Promise.resolve(maybePromise);
2294
+ }
2295
+ //#endregion
2296
+ //#region ../../node_modules/.pnpm/i18next-http-backend@3.0.2/node_modules/i18next-http-backend/esm/request.js
2297
+ function ownKeys$1(e, r) {
2298
+ var t = Object.keys(e);
2299
+ if (Object.getOwnPropertySymbols) {
2300
+ var o = Object.getOwnPropertySymbols(e);
2301
+ r && (o = o.filter(function(r) {
2302
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
2303
+ })), t.push.apply(t, o);
2304
+ }
2305
+ return t;
2306
+ }
2307
+ function _objectSpread$1(e) {
2308
+ for (var r = 1; r < arguments.length; r++) {
2309
+ var t = null != arguments[r] ? arguments[r] : {};
2310
+ r % 2 ? ownKeys$1(Object(t), !0).forEach(function(r) {
2311
+ _defineProperty$1(e, r, t[r]);
2312
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function(r) {
2313
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
2314
+ });
2315
+ }
2316
+ return e;
2317
+ }
2318
+ function _defineProperty$1(e, r, t) {
2319
+ return (r = _toPropertyKey$1(r)) in e ? Object.defineProperty(e, r, {
2320
+ value: t,
2321
+ enumerable: !0,
2322
+ configurable: !0,
2323
+ writable: !0
2324
+ }) : e[r] = t, e;
2325
+ }
2326
+ function _toPropertyKey$1(t) {
2327
+ var i = _toPrimitive$1(t, "string");
2328
+ return "symbol" == _typeof$1(i) ? i : i + "";
2329
+ }
2330
+ function _toPrimitive$1(t, r) {
2331
+ if ("object" != _typeof$1(t) || !t) return t;
2332
+ var e = t[Symbol.toPrimitive];
2333
+ if (void 0 !== e) {
2334
+ var i = e.call(t, r || "default");
2335
+ if ("object" != _typeof$1(i)) return i;
2336
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2337
+ }
2338
+ return ("string" === r ? String : Number)(t);
2339
+ }
2340
+ function _typeof$1(o) {
2341
+ "@babel/helpers - typeof";
2342
+ return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
2343
+ return typeof o;
2344
+ } : function(o) {
2345
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
2346
+ }, _typeof$1(o);
2347
+ }
2348
+ var fetchApi = typeof fetch === "function" ? fetch : void 0;
2349
+ if (typeof global !== "undefined" && global.fetch) fetchApi = global.fetch;
2350
+ else if (typeof window !== "undefined" && window.fetch) fetchApi = window.fetch;
2351
+ var XmlHttpRequestApi;
2352
+ if (hasXMLHttpRequest()) {
2353
+ if (typeof global !== "undefined" && global.XMLHttpRequest) XmlHttpRequestApi = global.XMLHttpRequest;
2354
+ else if (typeof window !== "undefined" && window.XMLHttpRequest) XmlHttpRequestApi = window.XMLHttpRequest;
2355
+ }
2356
+ var ActiveXObjectApi;
2357
+ if (typeof ActiveXObject === "function") {
2358
+ if (typeof global !== "undefined" && global.ActiveXObject) ActiveXObjectApi = global.ActiveXObject;
2359
+ else if (typeof window !== "undefined" && window.ActiveXObject) ActiveXObjectApi = window.ActiveXObject;
2360
+ }
2361
+ if (typeof fetchApi !== "function") fetchApi = void 0;
2362
+ if (!fetchApi && !XmlHttpRequestApi && !ActiveXObjectApi) try {
2363
+ import("./browser-ponyfill-CLLvZCVg.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then(function(mod) {
2364
+ fetchApi = mod.default;
2365
+ }).catch(function() {});
2366
+ } catch (e) {}
2367
+ var addQueryString = function addQueryString(url, params) {
2368
+ if (params && _typeof$1(params) === "object") {
2369
+ var queryString = "";
2370
+ for (var paramName in params) queryString += "&" + encodeURIComponent(paramName) + "=" + encodeURIComponent(params[paramName]);
2371
+ if (!queryString) return url;
2372
+ url = url + (url.indexOf("?") !== -1 ? "&" : "?") + queryString.slice(1);
2373
+ }
2374
+ return url;
2375
+ };
2376
+ var fetchIt = function fetchIt(url, fetchOptions, callback, altFetch) {
2377
+ var resolver = function resolver(response) {
2378
+ if (!response.ok) return callback(response.statusText || "Error", { status: response.status });
2379
+ response.text().then(function(data) {
2380
+ callback(null, {
2381
+ status: response.status,
2382
+ data
2383
+ });
2384
+ }).catch(callback);
2385
+ };
2386
+ if (altFetch) {
2387
+ var altResponse = altFetch(url, fetchOptions);
2388
+ if (altResponse instanceof Promise) {
2389
+ altResponse.then(resolver).catch(callback);
2390
+ return;
2391
+ }
2392
+ }
2393
+ if (typeof fetch === "function") fetch(url, fetchOptions).then(resolver).catch(callback);
2394
+ else fetchApi(url, fetchOptions).then(resolver).catch(callback);
2395
+ };
2396
+ var omitFetchOptions = false;
2397
+ var requestWithFetch = function requestWithFetch(options, url, payload, callback) {
2398
+ if (options.queryStringParams) url = addQueryString(url, options.queryStringParams);
2399
+ var headers = _objectSpread$1({}, typeof options.customHeaders === "function" ? options.customHeaders() : options.customHeaders);
2400
+ if (typeof window === "undefined" && typeof global !== "undefined" && typeof global.process !== "undefined" && global.process.versions && global.process.versions.node) headers["User-Agent"] = "i18next-http-backend (node/".concat(global.process.version, "; ").concat(global.process.platform, " ").concat(global.process.arch, ")");
2401
+ if (payload) headers["Content-Type"] = "application/json";
2402
+ var reqOptions = typeof options.requestOptions === "function" ? options.requestOptions(payload) : options.requestOptions;
2403
+ var fetchOptions = _objectSpread$1({
2404
+ method: payload ? "POST" : "GET",
2405
+ body: payload ? options.stringify(payload) : void 0,
2406
+ headers
2407
+ }, omitFetchOptions ? {} : reqOptions);
2408
+ var altFetch = typeof options.alternateFetch === "function" && options.alternateFetch.length >= 1 ? options.alternateFetch : void 0;
2409
+ try {
2410
+ fetchIt(url, fetchOptions, callback, altFetch);
2411
+ } catch (e) {
2412
+ if (!reqOptions || Object.keys(reqOptions).length === 0 || !e.message || e.message.indexOf("not implemented") < 0) return callback(e);
2413
+ try {
2414
+ Object.keys(reqOptions).forEach(function(opt) {
2415
+ delete fetchOptions[opt];
2416
+ });
2417
+ fetchIt(url, fetchOptions, callback, altFetch);
2418
+ omitFetchOptions = true;
2419
+ } catch (err) {
2420
+ callback(err);
2421
+ }
2422
+ }
2423
+ };
2424
+ var requestWithXmlHttpRequest = function requestWithXmlHttpRequest(options, url, payload, callback) {
2425
+ if (payload && _typeof$1(payload) === "object") payload = addQueryString("", payload).slice(1);
2426
+ if (options.queryStringParams) url = addQueryString(url, options.queryStringParams);
2427
+ try {
2428
+ var x = XmlHttpRequestApi ? new XmlHttpRequestApi() : new ActiveXObjectApi("MSXML2.XMLHTTP.3.0");
2429
+ x.open(payload ? "POST" : "GET", url, 1);
2430
+ if (!options.crossDomain) x.setRequestHeader("X-Requested-With", "XMLHttpRequest");
2431
+ x.withCredentials = !!options.withCredentials;
2432
+ if (payload) x.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
2433
+ if (x.overrideMimeType) x.overrideMimeType("application/json");
2434
+ var h = options.customHeaders;
2435
+ h = typeof h === "function" ? h() : h;
2436
+ if (h) for (var i in h) x.setRequestHeader(i, h[i]);
2437
+ x.onreadystatechange = function() {
2438
+ x.readyState > 3 && callback(x.status >= 400 ? x.statusText : null, {
2439
+ status: x.status,
2440
+ data: x.responseText
2441
+ });
2442
+ };
2443
+ x.send(payload);
2444
+ } catch (e) {
2445
+ console && console.log(e);
2446
+ }
2447
+ };
2448
+ var request = function request(options, url, payload, callback) {
2449
+ if (typeof payload === "function") {
2450
+ callback = payload;
2451
+ payload = void 0;
2452
+ }
2453
+ callback = callback || function() {};
2454
+ if (fetchApi && url.indexOf("file:") !== 0) return requestWithFetch(options, url, payload, callback);
2455
+ if (hasXMLHttpRequest() || typeof ActiveXObject === "function") return requestWithXmlHttpRequest(options, url, payload, callback);
2456
+ callback(/* @__PURE__ */ new Error("No fetch and no xhr implementation found!"));
2457
+ };
2458
+ //#endregion
2459
+ //#region ../../node_modules/.pnpm/i18next-http-backend@3.0.2/node_modules/i18next-http-backend/esm/index.js
2460
+ function _typeof(o) {
2461
+ "@babel/helpers - typeof";
2462
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
2463
+ return typeof o;
2464
+ } : function(o) {
2465
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
2466
+ }, _typeof(o);
2467
+ }
2468
+ function ownKeys(e, r) {
2469
+ var t = Object.keys(e);
2470
+ if (Object.getOwnPropertySymbols) {
2471
+ var o = Object.getOwnPropertySymbols(e);
2472
+ r && (o = o.filter(function(r) {
2473
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
2474
+ })), t.push.apply(t, o);
2475
+ }
2476
+ return t;
2477
+ }
2478
+ function _objectSpread(e) {
2479
+ for (var r = 1; r < arguments.length; r++) {
2480
+ var t = null != arguments[r] ? arguments[r] : {};
2481
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
2482
+ _defineProperty(e, r, t[r]);
2483
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
2484
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
2485
+ });
2486
+ }
2487
+ return e;
2488
+ }
2489
+ function _classCallCheck(a, n) {
2490
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
2491
+ }
2492
+ function _defineProperties(e, r) {
2493
+ for (var t = 0; t < r.length; t++) {
2494
+ var o = r[t];
2495
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
2496
+ }
2497
+ }
2498
+ function _createClass(e, r, t) {
2499
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e;
2500
+ }
2501
+ function _defineProperty(e, r, t) {
2502
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
2503
+ value: t,
2504
+ enumerable: !0,
2505
+ configurable: !0,
2506
+ writable: !0
2507
+ }) : e[r] = t, e;
2508
+ }
2509
+ function _toPropertyKey(t) {
2510
+ var i = _toPrimitive(t, "string");
2511
+ return "symbol" == _typeof(i) ? i : i + "";
2512
+ }
2513
+ function _toPrimitive(t, r) {
2514
+ if ("object" != _typeof(t) || !t) return t;
2515
+ var e = t[Symbol.toPrimitive];
2516
+ if (void 0 !== e) {
2517
+ var i = e.call(t, r || "default");
2518
+ if ("object" != _typeof(i)) return i;
2519
+ throw new TypeError("@@toPrimitive must return a primitive value.");
2520
+ }
2521
+ return ("string" === r ? String : Number)(t);
2522
+ }
2523
+ var getDefaults = function getDefaults() {
2524
+ return {
2525
+ loadPath: "/locales/{{lng}}/{{ns}}.json",
2526
+ addPath: "/locales/add/{{lng}}/{{ns}}",
2527
+ parse: function parse(data) {
2528
+ return JSON.parse(data);
2529
+ },
2530
+ stringify: JSON.stringify,
2531
+ parsePayload: function parsePayload(namespace, key, fallbackValue) {
2532
+ return _defineProperty({}, key, fallbackValue || "");
2533
+ },
2534
+ parseLoadPayload: function parseLoadPayload(languages, namespaces) {},
2535
+ request,
2536
+ reloadInterval: typeof window !== "undefined" ? false : 3600 * 1e3,
2537
+ customHeaders: {},
2538
+ queryStringParams: {},
2539
+ crossDomain: false,
2540
+ withCredentials: false,
2541
+ overrideMimeType: false,
2542
+ requestOptions: {
2543
+ mode: "cors",
2544
+ credentials: "same-origin",
2545
+ cache: "default"
2546
+ }
2547
+ };
2548
+ };
2549
+ var Backend = function() {
2550
+ function Backend(services) {
2551
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2552
+ var allOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2553
+ _classCallCheck(this, Backend);
2554
+ this.services = services;
2555
+ this.options = options;
2556
+ this.allOptions = allOptions;
2557
+ this.type = "backend";
2558
+ this.init(services, options, allOptions);
2559
+ }
2560
+ return _createClass(Backend, [
2561
+ {
2562
+ key: "init",
2563
+ value: function init(services) {
2564
+ var _this = this;
2565
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2566
+ var allOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2567
+ this.services = services;
2568
+ this.options = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), this.options || {}), options);
2569
+ this.allOptions = allOptions;
2570
+ if (this.services && this.options.reloadInterval) {
2571
+ var timer = setInterval(function() {
2572
+ return _this.reload();
2573
+ }, this.options.reloadInterval);
2574
+ if (_typeof(timer) === "object" && typeof timer.unref === "function") timer.unref();
2575
+ }
2576
+ }
2577
+ },
2578
+ {
2579
+ key: "readMulti",
2580
+ value: function readMulti(languages, namespaces, callback) {
2581
+ this._readAny(languages, languages, namespaces, namespaces, callback);
2582
+ }
2583
+ },
2584
+ {
2585
+ key: "read",
2586
+ value: function read(language, namespace, callback) {
2587
+ this._readAny([language], language, [namespace], namespace, callback);
2588
+ }
2589
+ },
2590
+ {
2591
+ key: "_readAny",
2592
+ value: function _readAny(languages, loadUrlLanguages, namespaces, loadUrlNamespaces, callback) {
2593
+ var _this2 = this;
2594
+ var loadPath = this.options.loadPath;
2595
+ if (typeof this.options.loadPath === "function") loadPath = this.options.loadPath(languages, namespaces);
2596
+ loadPath = makePromise(loadPath);
2597
+ loadPath.then(function(resolvedLoadPath) {
2598
+ if (!resolvedLoadPath) return callback(null, {});
2599
+ var url = _this2.services.interpolator.interpolate(resolvedLoadPath, {
2600
+ lng: languages.join("+"),
2601
+ ns: namespaces.join("+")
2602
+ });
2603
+ _this2.loadUrl(url, callback, loadUrlLanguages, loadUrlNamespaces);
2604
+ });
2605
+ }
2606
+ },
2607
+ {
2608
+ key: "loadUrl",
2609
+ value: function loadUrl(url, callback, languages, namespaces) {
2610
+ var _this3 = this;
2611
+ var lng = typeof languages === "string" ? [languages] : languages;
2612
+ var ns = typeof namespaces === "string" ? [namespaces] : namespaces;
2613
+ var payload = this.options.parseLoadPayload(lng, ns);
2614
+ this.options.request(this.options, url, payload, function(err, res) {
2615
+ if (res && (res.status >= 500 && res.status < 600 || !res.status)) return callback("failed loading " + url + "; status code: " + res.status, true);
2616
+ if (res && res.status >= 400 && res.status < 500) return callback("failed loading " + url + "; status code: " + res.status, false);
2617
+ if (!res && err && err.message) {
2618
+ var errorMessage = err.message.toLowerCase();
2619
+ if ([
2620
+ "failed",
2621
+ "fetch",
2622
+ "network",
2623
+ "load"
2624
+ ].find(function(term) {
2625
+ return errorMessage.indexOf(term) > -1;
2626
+ })) return callback("failed loading " + url + ": " + err.message, true);
2627
+ }
2628
+ if (err) return callback(err, false);
2629
+ var ret, parseErr;
2630
+ try {
2631
+ if (typeof res.data === "string") ret = _this3.options.parse(res.data, languages, namespaces);
2632
+ else ret = res.data;
2633
+ } catch (e) {
2634
+ parseErr = "failed parsing " + url + " to json";
2635
+ }
2636
+ if (parseErr) return callback(parseErr, false);
2637
+ callback(null, ret);
2638
+ });
2639
+ }
2640
+ },
2641
+ {
2642
+ key: "create",
2643
+ value: function create(languages, namespace, key, fallbackValue, callback) {
2644
+ var _this4 = this;
2645
+ if (!this.options.addPath) return;
2646
+ if (typeof languages === "string") languages = [languages];
2647
+ var payload = this.options.parsePayload(namespace, key, fallbackValue);
2648
+ var finished = 0;
2649
+ var dataArray = [];
2650
+ var resArray = [];
2651
+ languages.forEach(function(lng) {
2652
+ var addPath = _this4.options.addPath;
2653
+ if (typeof _this4.options.addPath === "function") addPath = _this4.options.addPath(lng, namespace);
2654
+ var url = _this4.services.interpolator.interpolate(addPath, {
2655
+ lng,
2656
+ ns: namespace
2657
+ });
2658
+ _this4.options.request(_this4.options, url, payload, function(data, res) {
2659
+ finished += 1;
2660
+ dataArray.push(data);
2661
+ resArray.push(res);
2662
+ if (finished === languages.length) {
2663
+ if (typeof callback === "function") callback(dataArray, resArray);
2664
+ }
2665
+ });
2666
+ });
2667
+ }
2668
+ },
2669
+ {
2670
+ key: "reload",
2671
+ value: function reload() {
2672
+ var _this5 = this;
2673
+ var _this$services = this.services, backendConnector = _this$services.backendConnector, languageUtils = _this$services.languageUtils, logger = _this$services.logger;
2674
+ var currentLanguage = backendConnector.language;
2675
+ if (currentLanguage && currentLanguage.toLowerCase() === "cimode") return;
2676
+ var toLoad = [];
2677
+ var append = function append(lng) {
2678
+ languageUtils.toResolveHierarchy(lng).forEach(function(l) {
2679
+ if (toLoad.indexOf(l) < 0) toLoad.push(l);
2680
+ });
2681
+ };
2682
+ append(currentLanguage);
2683
+ if (this.allOptions.preload) this.allOptions.preload.forEach(function(l) {
2684
+ return append(l);
2685
+ });
2686
+ toLoad.forEach(function(lng) {
2687
+ _this5.allOptions.ns.forEach(function(ns) {
2688
+ backendConnector.read(lng, ns, "read", null, null, function(err, data) {
2689
+ if (err) logger.warn("loading namespace ".concat(ns, " for language ").concat(lng, " failed"), err);
2690
+ if (!err && data) logger.log("loaded namespace ".concat(ns, " for language ").concat(lng), data);
2691
+ backendConnector.loaded("".concat(lng, "|").concat(ns), err, data);
2692
+ });
2693
+ });
2694
+ });
2695
+ }
2696
+ }
2697
+ ]);
2698
+ }();
2699
+ Backend.type = "backend";
2700
+ //#endregion
2701
+ //#region src/i18n/languageMetadata.ts
2702
+ var languageMetadata = {
2703
+ en: { emoji: "🇺🇸" },
2704
+ "en-DG": { emoji: "🇬🇧" },
2705
+ es: { emoji: "🇪🇸" },
2706
+ "es-ES": { emoji: "🇪🇸" },
2707
+ sr: { emoji: "🇷🇸" },
2708
+ "sr-Latn": { emoji: "🇷🇸" },
2709
+ fr: { emoji: "🇫🇷" },
2710
+ "pt-BR": { emoji: "🇧🇷" },
2711
+ pt: { emoji: "🇵🇹" },
2712
+ bn: { emoji: "🇧🇩" },
2713
+ zh: { emoji: "🇨🇳" },
2714
+ hi: { emoji: "🇮🇳" },
2715
+ id: { emoji: "🇮🇩" },
2716
+ ms: { emoji: "🇲🇾" },
2717
+ tr: { emoji: "🇹🇷" },
2718
+ vi: { emoji: "🇻🇳" },
2719
+ ht: { emoji: "🇭🇹" },
2720
+ it: { emoji: "🇮🇹" },
2721
+ de: { emoji: "🇩🇪" },
2722
+ nl: { emoji: "🇳🇱" },
2723
+ "tl-PH": { emoji: "🇵🇭" },
2724
+ pl: { emoji: "🇵🇱" },
2725
+ hu: { emoji: "🇭🇺" },
2726
+ ro: { emoji: "🇷🇴" },
2727
+ hmn: { emoji: "🌐" },
2728
+ so: { emoji: "🇸🇴" },
2729
+ ca: { emoji: "🇪🇸" },
2730
+ "af-ZA": { emoji: "🇿🇦" },
2731
+ ar: { emoji: "🇸🇦" },
2732
+ "ar-EG": { emoji: "🇪🇬" },
2733
+ "ar-AE": { emoji: "🇦🇪" },
2734
+ "zh-CN": { emoji: "🇨🇳" },
2735
+ "zh-TW": { emoji: "🇹🇼" },
2736
+ "zh-HANT": { emoji: "🇹🇼" },
2737
+ "cs-CZ": { emoji: "🇨🇿" },
2738
+ "da-DK": { emoji: "🇩🇰" },
2739
+ "fi-FI": { emoji: "🇫🇮" },
2740
+ "fr-CA": { emoji: "🇨🇦" },
2741
+ "el-GR": { emoji: "🇬🇷" },
2742
+ he: { emoji: "🇮🇱" },
2743
+ ja: { emoji: "🇯🇵" },
2744
+ "ja-JP": { emoji: "🇯🇵" },
2745
+ "ko-KP": { emoji: "🇰🇵" },
2746
+ "nb-NO": { emoji: "🇳🇴" },
2747
+ "fa-IR": { emoji: "🇮🇷" },
2748
+ "pt-PT": { emoji: "🇵🇹" },
2749
+ "ru-RU": { emoji: "🇷🇺" },
2750
+ "sr-YU": { emoji: "🇷🇸" },
2751
+ "es-419": { emoji: "🌎" },
2752
+ "es-MX": { emoji: "🇲🇽" },
2753
+ "sv-SE": { emoji: "🇸🇪" },
2754
+ "th-TH": { emoji: "🇹🇭" },
2755
+ "uk-UA": { emoji: "🇺🇦" },
2756
+ am: { emoji: "🇪🇹" },
2757
+ az: { emoji: "🇦🇿" },
2758
+ bs: { emoji: "🇧🇦" },
2759
+ my: { emoji: "🇲🇲" },
2760
+ ceb: { emoji: "🇵🇭" },
2761
+ cs: { emoji: "🇨🇿" },
2762
+ et: { emoji: "🇪🇪" },
2763
+ ka: { emoji: "🇬🇪" },
2764
+ el: { emoji: "🇬🇷" },
2765
+ jv: { emoji: "🇮🇩" },
2766
+ kk: { emoji: "🇰🇿" },
2767
+ km: { emoji: "🇰🇭" },
2768
+ ko: { emoji: "🇰🇷" },
2769
+ ky: { emoji: "🇰🇬" },
2770
+ lo: { emoji: "🇱🇦" },
2771
+ lv: { emoji: "🇱🇻" },
2772
+ lt: { emoji: "🇱🇹" },
2773
+ mk: { emoji: "🇲🇰" },
2774
+ mn: { emoji: "🇲🇳" },
2775
+ ne: { emoji: "🇳🇵" },
2776
+ ru: { emoji: "🇷🇺" },
2777
+ sk: { emoji: "🇸🇰" },
2778
+ sl: { emoji: "🇸🇮" },
2779
+ sw: { emoji: "🇹🇿" },
2780
+ tl: { emoji: "🇵🇭" },
2781
+ th: { emoji: "🇹🇭" },
2782
+ uk: { emoji: "🇺🇦" },
2783
+ ur: { emoji: "🇵🇰" },
2784
+ uz: { emoji: "🇺🇿" },
2785
+ hr: { emoji: "🇭🇷" }
2786
+ };
2787
+ var supportedLanguages = Object.keys(languageMetadata);
2788
+ function getLanguageEmoji(language) {
2789
+ const directMatch = languageMetadata[language];
2790
+ if (directMatch) return directMatch.emoji;
2791
+ return languageMetadata[language.split("-")[0] || language]?.emoji ?? "🌐";
2792
+ }
2793
+ //#endregion
2794
+ //#region src/i18n/setup.ts
2795
+ var DEFAULT_I18N_LOAD_PATH = "https://api.i18nexus.com/project_resources/translations/{{lng}}/{{ns}}.json?api_key=cg41dUINoxdp8BaHDQLJhA";
2796
+ var LANGUAGE_STORAGE_KEY = "incode:i18n:language";
2797
+ var camelToStartCase = (text) => {
2798
+ const result = text.replace(/([A-Z])/g, " $1");
2799
+ return result.charAt(0).toUpperCase() + result.slice(1);
2800
+ };
2801
+ var keyToStartCase = (key) => {
2802
+ const splitKey = key.split(".");
2803
+ const missingKey = splitKey[splitKey.length - 1];
2804
+ return camelToStartCase(missingKey || "missing key");
2805
+ };
2806
+ var languageDetector = new Browser();
2807
+ languageDetector.addDetector({
2808
+ name: "navigatorOnlyLanguage",
2809
+ lookup() {
2810
+ if (typeof navigator === "undefined") return "en";
2811
+ const languageFromBrowser = navigator.language;
2812
+ if (supportedLanguages.includes(languageFromBrowser)) return languageFromBrowser;
2813
+ return languageFromBrowser.split("-")[0];
2814
+ }
2815
+ });
2816
+ function applyOverrides(i18nInstance, translations) {
2817
+ for (const [langCode, value] of Object.entries(translations)) if (value) i18nInstance.addResourceBundle(langCode, "default", value, true, true);
2818
+ }
2819
+ function readStoredLanguage() {
2820
+ try {
2821
+ if (typeof localStorage === "undefined") return null;
2822
+ return localStorage.getItem(LANGUAGE_STORAGE_KEY);
2823
+ } catch {
2824
+ return null;
2825
+ }
2826
+ }
2827
+ function createI18n(options = {}) {
2828
+ const { lang, loadPath, skipRemoteLoad, translations } = options;
2829
+ const i18nInstance = instance.createInstance();
2830
+ const storedLang = readStoredLanguage();
2831
+ const remoteLoadEnabled = skipRemoteLoad !== true;
2832
+ const resolvedLoadPath = loadPath ?? DEFAULT_I18N_LOAD_PATH;
2833
+ if (remoteLoadEnabled) i18nInstance.use(Backend);
2834
+ i18nInstance.use(languageDetector).init({
2835
+ lng: storedLang ?? lang,
2836
+ fallbackLng: "en",
2837
+ supportedLngs: supportedLanguages,
2838
+ ns: ["default"],
2839
+ defaultNS: "default",
2840
+ partialBundledLanguages: true,
2841
+ keySeparator: ".",
2842
+ interpolation: { escapeValue: false },
2843
+ backend: remoteLoadEnabled ? { loadPath: resolvedLoadPath } : void 0,
2844
+ detection: {
2845
+ order: [
2846
+ "querystring",
2847
+ "cookie",
2848
+ "localStorage",
2849
+ "sessionStorage",
2850
+ "navigatorOnlyLanguage",
2851
+ "htmlTag",
2852
+ "path",
2853
+ "subdomain"
2854
+ ],
2855
+ lookupQuerystring: "lang",
2856
+ lookupLocalStorage: LANGUAGE_STORAGE_KEY,
2857
+ lookupSessionStorage: LANGUAGE_STORAGE_KEY,
2858
+ caches: ["localStorage"]
2859
+ },
2860
+ initImmediate: false,
2861
+ parseMissingKeyHandler: keyToStartCase
2862
+ });
2863
+ if (translations) {
2864
+ applyOverrides(i18nInstance, translations);
2865
+ i18nInstance.on("loaded", () => {
2866
+ applyOverrides(i18nInstance, translations);
2867
+ });
2868
+ }
2869
+ return i18nInstance;
2870
+ }
2871
+ //#endregion
2872
+ //#region src/i18n/instance.ts
2873
+ var i18nInstance = null;
2874
+ function setI18nInstance(instance) {
2875
+ i18nInstance = instance;
2876
+ }
2877
+ function hasI18nInstance() {
2878
+ return i18nInstance !== null;
2879
+ }
2880
+ function getI18nInstance() {
2881
+ if (!i18nInstance) i18nInstance = createI18n();
2882
+ return i18nInstance;
2883
+ }
2884
+ //#endregion
2885
+ //#region src/shared/icons/arrowIcon.tsx
2886
+ var ArrowIcon = ({ class: className }) => /* @__PURE__ */ u("svg", {
2887
+ width: "13",
2888
+ height: "14",
2889
+ viewBox: "0 0 13 14",
2890
+ fill: "none",
2891
+ xmlns: "http://www.w3.org/2000/svg",
2892
+ "aria-hidden": "true",
2893
+ class: className,
2894
+ children: /* @__PURE__ */ u("path", {
2895
+ d: "M0 8.08009V5.92009H9.198L4.698 1.87009L6.228 0.340088L12.6 6.28009V7.70209L6.228 13.6601L4.698 12.1301L9.198 8.08009H0Z",
2896
+ fill: "currentColor"
2897
+ })
2898
+ });
2899
+ //#endregion
2900
+ //#region src/i18n/useTranslation.ts
2901
+ function useTranslation() {
2902
+ const i18nInstance = getI18nInstance();
2903
+ const [, forceUpdate] = d(0);
2904
+ const [ready, setReady] = d(i18nInstance.isInitialized);
2905
+ y(() => {
2906
+ const handleLanguageChanged = () => {
2907
+ forceUpdate((n) => n + 1);
2908
+ };
2909
+ const handleInitialized = () => {
2910
+ setReady(true);
2911
+ forceUpdate((n) => n + 1);
2912
+ };
2913
+ i18nInstance.on("languageChanged", handleLanguageChanged);
2914
+ i18nInstance.on("initialized", handleInitialized);
2915
+ i18nInstance.on("loaded", handleLanguageChanged);
2916
+ return () => {
2917
+ i18nInstance.off("languageChanged", handleLanguageChanged);
2918
+ i18nInstance.off("initialized", handleInitialized);
2919
+ i18nInstance.off("loaded", handleLanguageChanged);
2920
+ };
2921
+ }, [i18nInstance]);
2922
+ return {
2923
+ t: T(() => i18nInstance.t.bind(i18nInstance), [i18nInstance]),
2924
+ ready,
2925
+ i18n: i18nInstance
2926
+ };
2927
+ }
2928
+ //#endregion
2929
+ //#region src/i18n/Trans.tsx
2930
+ var Trans = ({ i18nKey, boldClass = "IncodeTransBold", arrowClass = "IncodeTransArrow", components, defaultValue }) => {
2931
+ const { t } = useTranslation();
2932
+ const text = defaultValue ? t(i18nKey, { defaultValue }) : t(i18nKey);
2933
+ const builtInPattern = "<strong>|<\\/strong>|<br\\s*\\/?>|<arrow\\s*\\/>";
2934
+ const componentPattern = components ? Object.keys(components).map((name) => `<${name}>|<\\/${name}>`).join("|") : "";
2935
+ const fullPattern = componentPattern ? `${builtInPattern}|${componentPattern}` : builtInPattern;
2936
+ const parts = text.split(new RegExp(`(${fullPattern})`, "g"));
2937
+ let isBold = false;
2938
+ let activeComponent = null;
2939
+ return /* @__PURE__ */ u(k, { children: parts.map((part, index) => {
2940
+ if (part === "<strong>") {
2941
+ isBold = true;
2942
+ return null;
2943
+ }
2944
+ if (part === "</strong>") {
2945
+ isBold = false;
2946
+ return null;
2947
+ }
2948
+ if (/^<br\s*\/?>$/.test(part)) return /* @__PURE__ */ u("br", {}, index);
2949
+ if (/^<arrow\s*\/>$/.test(part)) return /* @__PURE__ */ u(ArrowIcon, { class: arrowClass }, index);
2950
+ if (components) {
2951
+ const openMatch = part.match(/^<(\w+)>$/);
2952
+ if (openMatch && components[openMatch[1]]) {
2953
+ activeComponent = openMatch[1];
2954
+ return null;
2955
+ }
2956
+ const closeMatch = part.match(/^<\/(\w+)>$/);
2957
+ if (closeMatch && components[closeMatch[1]]) {
2958
+ activeComponent = null;
2959
+ return null;
2960
+ }
2961
+ }
2962
+ if (!part) return null;
2963
+ if (activeComponent && components) return K(components[activeComponent], { key: index }, part);
2964
+ return isBold ? /* @__PURE__ */ u("span", {
2965
+ class: boldClass,
2966
+ children: part
2967
+ }, index) : /* @__PURE__ */ u(k, { children: part }, index);
2968
+ }) });
2969
+ };
2970
+ //#endregion
2971
+ export { createI18n as a, supportedLanguages as c, setI18nInstance as i, useTranslation as n, readStoredLanguage as o, hasI18nInstance as r, getLanguageEmoji as s, Trans as t };