@unidy.io/sdk 1.1.9 → 1.1.10

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 (518) hide show
  1. package/dist/cjs/app-globals-Pb3mNuRv.js +10 -0
  2. package/dist/cjs/app-globals-Pb3mNuRv.js.map +1 -0
  3. package/dist/cjs/{auth-B83pzi0f.js → auth-ChsE2RD7.js} +45 -13
  4. package/dist/cjs/auth-ChsE2RD7.js.map +1 -0
  5. package/dist/cjs/{auth-store-DPHWWmXf.js → auth-store-BO38Txmj.js} +8 -4
  6. package/dist/cjs/auth-store-BO38Txmj.js.map +1 -0
  7. package/dist/cjs/{component-utils-BpMyeVQo.js → component-utils-bu3SY4dE.js} +9 -2
  8. package/dist/cjs/component-utils-bu3SY4dE.js.map +1 -0
  9. package/dist/cjs/{flash-store-BuIBuQDx.js → flash-store-D5vGuIFc.js} +3 -3
  10. package/dist/cjs/{flash-store-BuIBuQDx.js.map → flash-store-D5vGuIFc.js.map} +1 -1
  11. package/dist/cjs/{i18n-BoDZ8kd2.js → i18n-B2T1e9Mf.js} +432 -596
  12. package/dist/cjs/i18n-B2T1e9Mf.js.map +1 -0
  13. package/dist/cjs/{index-B_N5xKgH.js → index-BzhKFIXk.js} +3416 -735
  14. package/dist/cjs/index-BzhKFIXk.js.map +1 -0
  15. package/dist/cjs/{index-R2MKLaem.js → index-DmDGhWTM.js} +1621 -550
  16. package/dist/cjs/index-DmDGhWTM.js.map +1 -0
  17. package/dist/cjs/{index-DLz3FT7T.js → index-DxENvy7x.js} +92 -23
  18. package/dist/cjs/index-DxENvy7x.js.map +1 -0
  19. package/dist/cjs/index.cjs.js +13 -13
  20. package/dist/cjs/loader.cjs.js +3 -3
  21. package/dist/cjs/{newsletter-helpers-D-V_8kiN.js → newsletter-helpers-B5P7q8Xk.js} +8 -8
  22. package/dist/cjs/{newsletter-helpers-D-V_8kiN.js.map → newsletter-helpers-B5P7q8Xk.js.map} +1 -1
  23. package/dist/cjs/{newsletter-store-BzytX7Qh.js → newsletter-store-f5zhJljn.js} +3 -3
  24. package/dist/cjs/{newsletter-store-BzytX7Qh.js.map → newsletter-store-f5zhJljn.js.map} +1 -1
  25. package/dist/cjs/{pagination-store-BEiW3MQd.js → pagination-store-DjGYEIqm.js} +3 -3
  26. package/dist/cjs/{pagination-store-BEiW3MQd.js.map → pagination-store-DjGYEIqm.js.map} +1 -1
  27. package/dist/cjs/{profile-helpers-B2h2III_.js → profile-helpers-BcLjojeG.js} +4 -4
  28. package/dist/cjs/{profile-helpers-B2h2III_.js.map → profile-helpers-BcLjojeG.js.map} +1 -1
  29. package/dist/cjs/{profile-store-P_BcYkef.js → profile-store-BWJ9qAcg.js} +3 -3
  30. package/dist/cjs/{profile-store-P_BcYkef.js.map → profile-store-BWJ9qAcg.js.map} +1 -1
  31. package/dist/cjs/sdk.cjs.js +31 -4
  32. package/dist/cjs/sdk.cjs.js.map +1 -1
  33. package/dist/cjs/u-conditional-render.cjs.entry.js +12 -12
  34. package/dist/cjs/u-config.cjs.entry.js +18 -14
  35. package/dist/cjs/u-config.entry.cjs.js.map +1 -1
  36. package/dist/cjs/u-email-field.cjs.entry.js +7 -7
  37. package/dist/cjs/u-error-message.cjs.entry.js +7 -7
  38. package/dist/cjs/u-error-message.entry.cjs.js.map +1 -1
  39. package/dist/cjs/u-field.u-raw-field.entry.cjs.js.map +1 -1
  40. package/dist/cjs/u-field_2.cjs.entry.js +17 -21
  41. package/dist/cjs/u-flash-message.cjs.entry.js +4 -4
  42. package/dist/cjs/u-full-profile.cjs.entry.js +6 -6
  43. package/dist/cjs/u-full-profile.entry.cjs.js.map +1 -1
  44. package/dist/cjs/u-logout-button.u-signed-in.entry.cjs.js.map +1 -1
  45. package/dist/cjs/u-logout-button_2.cjs.entry.js +16 -14
  46. package/dist/cjs/u-magic-code-field.cjs.entry.js +11 -11
  47. package/dist/cjs/u-magic-code-field.entry.cjs.js.map +1 -1
  48. package/dist/cjs/u-missing-field.cjs.entry.js +4 -4
  49. package/dist/cjs/u-missing-field.entry.cjs.js.map +1 -1
  50. package/dist/cjs/u-missing-fields-submit-button.cjs.entry.js +9 -9
  51. package/dist/cjs/u-missing-fields-submit-button.entry.cjs.js.map +1 -1
  52. package/dist/cjs/u-newsletter-checkbox.cjs.entry.js +12 -12
  53. package/dist/cjs/u-newsletter-logout-button.cjs.entry.js +19 -14
  54. package/dist/cjs/u-newsletter-logout-button.entry.cjs.js.map +1 -1
  55. package/dist/cjs/u-newsletter-preference-checkbox.cjs.entry.js +13 -13
  56. package/dist/cjs/u-newsletter-preference-checkbox.entry.cjs.js.map +1 -1
  57. package/dist/cjs/u-newsletter-resend-doi-button.cjs.entry.js +13 -13
  58. package/dist/cjs/u-newsletter-root.cjs.entry.js +12 -12
  59. package/dist/cjs/u-newsletter-toggle-subscription-button.cjs.entry.js +13 -13
  60. package/dist/cjs/u-pagination-button.cjs.entry.js +1 -1
  61. package/dist/cjs/u-pagination-button.entry.cjs.js.map +1 -1
  62. package/dist/cjs/u-pagination-page.cjs.entry.js +1 -1
  63. package/dist/cjs/u-pagination-page.entry.cjs.js.map +1 -1
  64. package/dist/cjs/u-passkey.cjs.entry.js +10 -10
  65. package/dist/cjs/u-passkey.entry.cjs.js.map +1 -1
  66. package/dist/cjs/u-password-field.cjs.entry.js +5 -5
  67. package/dist/cjs/u-profile.u-submit-button.entry.cjs.js.map +1 -1
  68. package/dist/cjs/u-profile_2.cjs.entry.js +17 -15
  69. package/dist/cjs/u-registration-button.cjs.entry.js +5 -5
  70. package/dist/cjs/u-registration-button.entry.cjs.js.map +1 -1
  71. package/dist/cjs/u-reset-password-button.cjs.entry.js +10 -10
  72. package/dist/cjs/u-send-magic-code-button.cjs.entry.js +10 -10
  73. package/dist/cjs/u-send-magic-code-button.entry.cjs.js.map +1 -1
  74. package/dist/cjs/u-signin-root.cjs.entry.js +6 -6
  75. package/dist/cjs/u-signin-step.cjs.entry.js +10 -10
  76. package/dist/cjs/u-signin-step.entry.cjs.js.map +1 -1
  77. package/dist/cjs/u-signin-strategy.cjs.entry.js +4 -4
  78. package/dist/cjs/u-social-login-button.cjs.entry.js +11 -11
  79. package/dist/cjs/u-social-login-button.entry.cjs.js.map +1 -1
  80. package/dist/cjs/u-spinner.cjs.entry.js +2 -2
  81. package/dist/cjs/u-spinner.entry.cjs.js.map +1 -1
  82. package/dist/cjs/u-ticketable-list.cjs.entry.js +13 -13
  83. package/dist/cjs/{unidy-store-7AbWnZ6g.js → unidy-store-zhdhlK0a.js} +3 -3
  84. package/dist/cjs/{unidy-store-7AbWnZ6g.js.map → unidy-store-zhdhlK0a.js.map} +1 -1
  85. package/dist/collection/api/client.js.map +1 -1
  86. package/dist/collection/api/index.js +2 -2
  87. package/dist/collection/api/index.js.map +1 -1
  88. package/dist/collection/auth/api/auth.js +12 -2
  89. package/dist/collection/auth/api/auth.js.map +1 -1
  90. package/dist/collection/auth/auth-helpers.js +18 -1
  91. package/dist/collection/auth/auth-helpers.js.map +1 -1
  92. package/dist/collection/auth/auth.js +17 -2
  93. package/dist/collection/auth/auth.js.map +1 -1
  94. package/dist/collection/auth/components/logout-button/logout-button.js +5 -3
  95. package/dist/collection/auth/components/logout-button/logout-button.js.map +1 -1
  96. package/dist/collection/auth/components/magic-code-field/magic-code-field.css +1 -1
  97. package/dist/collection/auth/components/magic-code-field/magic-code-field.js +1 -1
  98. package/dist/collection/auth/components/magic-code-field/magic-code-field.js.map +1 -1
  99. package/dist/collection/auth/components/missing-field/missing-field.js.map +1 -1
  100. package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js +3 -3
  101. package/dist/collection/auth/components/missing-fields-submit-button/missing-fields-submit-button.js.map +1 -1
  102. package/dist/collection/auth/components/passkey/passkey.js +2 -2
  103. package/dist/collection/auth/components/passkey/passkey.js.map +1 -1
  104. package/dist/collection/auth/components/password-field/password-field.js +1 -1
  105. package/dist/collection/auth/components/registration/registration-button.js +2 -2
  106. package/dist/collection/auth/components/registration/registration-button.js.map +1 -1
  107. package/dist/collection/auth/components/send-magic-code-button/send-magic-code-button.js +1 -1
  108. package/dist/collection/auth/components/send-magic-code-button/send-magic-code-button.js.map +1 -1
  109. package/dist/collection/auth/components/signed-in/signed-in.js.map +1 -1
  110. package/dist/collection/auth/components/signin-step/signin-step.js +1 -1
  111. package/dist/collection/auth/components/signin-step/signin-step.js.map +1 -1
  112. package/dist/collection/auth/components/social-logins/social-login-button.css +1 -1
  113. package/dist/collection/auth/components/social-logins/social-login-button.js +4 -4
  114. package/dist/collection/auth/components/social-logins/social-login-button.js.map +1 -1
  115. package/dist/collection/auth/index.js +1 -2
  116. package/dist/collection/auth/index.js.map +1 -1
  117. package/dist/collection/auth/store/auth-store.js +4 -0
  118. package/dist/collection/auth/store/auth-store.js.map +1 -1
  119. package/dist/collection/globalScript.js +1 -1
  120. package/dist/collection/globalScript.js.map +1 -1
  121. package/dist/collection/i18n.js +1 -1
  122. package/dist/collection/i18n.js.map +1 -1
  123. package/dist/collection/index.js +1 -1
  124. package/dist/collection/index.js.map +1 -1
  125. package/dist/collection/logger.js.map +1 -1
  126. package/dist/collection/newsletter/api/newsletters.js +1 -1
  127. package/dist/collection/newsletter/api/newsletters.js.map +1 -1
  128. package/dist/collection/newsletter/components/logout-button/logout-button.js +10 -5
  129. package/dist/collection/newsletter/components/logout-button/logout-button.js.map +1 -1
  130. package/dist/collection/newsletter/components/preference-checkbox/preference-checkbox.js +2 -3
  131. package/dist/collection/newsletter/components/preference-checkbox/preference-checkbox.js.map +1 -1
  132. package/dist/collection/newsletter/components/resend-doi-button/resend-doi-button.css +1 -1
  133. package/dist/collection/newsletter/components/toggle-subscription-button/toggle-subscription-button.css +1 -1
  134. package/dist/collection/profile/components/field/field.css +1 -1
  135. package/dist/collection/profile/components/field/field.js +1 -5
  136. package/dist/collection/profile/components/field/field.js.map +1 -1
  137. package/dist/collection/profile/components/full-profile/full-profile.css +1 -1
  138. package/dist/collection/profile/components/raw-field/raw-field.js +5 -5
  139. package/dist/collection/profile/components/raw-field/raw-field.js.map +1 -1
  140. package/dist/collection/profile/index.js +1 -2
  141. package/dist/collection/profile/index.js.map +1 -1
  142. package/dist/collection/profile/profile-helpers.js +1 -1
  143. package/dist/collection/profile/profile-helpers.js.map +1 -1
  144. package/dist/collection/shared/component-utils.js +7 -0
  145. package/dist/collection/shared/component-utils.js.map +1 -1
  146. package/dist/collection/shared/components/config/config.js +28 -4
  147. package/dist/collection/shared/components/config/config.js.map +1 -1
  148. package/dist/collection/shared/components/email-field/email-field.css +1 -1
  149. package/dist/collection/shared/components/error-message/error-message.js.map +1 -1
  150. package/dist/collection/shared/components/flash-message/flash-message.css +1 -1
  151. package/dist/collection/shared/components/spinner/spinner.css +1 -1
  152. package/dist/collection/shared/components/spinner/spinner.js +1 -1
  153. package/dist/collection/shared/components/spinner/spinner.js.map +1 -1
  154. package/dist/collection/shared/components/submit-button/submit-button.css +1 -1
  155. package/dist/collection/shared/components/submit-button/submit-button.js +2 -0
  156. package/dist/collection/shared/components/submit-button/submit-button.js.map +1 -1
  157. package/dist/collection/ticketable/api/get-with-schema.js.map +1 -1
  158. package/dist/collection/ticketable/api/schemas.js +1 -1
  159. package/dist/collection/ticketable/api/schemas.js.map +1 -1
  160. package/dist/collection/ticketable/api/subscriptions.js +2 -2
  161. package/dist/collection/ticketable/api/subscriptions.js.map +1 -1
  162. package/dist/collection/ticketable/api/tickets.js +2 -2
  163. package/dist/collection/ticketable/api/tickets.js.map +1 -1
  164. package/dist/collection/ticketable/components/pagination/pagination-button.js +1 -1
  165. package/dist/collection/ticketable/components/pagination/pagination-button.js.map +1 -1
  166. package/dist/collection/ticketable/components/pagination/pagination-page.js +1 -1
  167. package/dist/collection/ticketable/components/pagination/pagination-page.js.map +1 -1
  168. package/dist/collection/ticketable/index.js +1 -1
  169. package/dist/collection/ticketable/index.js.map +1 -1
  170. package/dist/components/auth-store.js +4 -0
  171. package/dist/components/auth-store.js.map +1 -1
  172. package/dist/components/auth.js +36 -4
  173. package/dist/components/auth.js.map +1 -1
  174. package/dist/components/component-utils.js +7 -0
  175. package/dist/components/component-utils.js.map +1 -1
  176. package/dist/components/exports.js +260 -104
  177. package/dist/components/exports.js.map +1 -1
  178. package/dist/components/field.js +4 -14
  179. package/dist/components/field.js.map +1 -1
  180. package/dist/components/i18n.js +429 -593
  181. package/dist/components/i18n.js.map +1 -1
  182. package/dist/components/index.js +424 -397
  183. package/dist/components/index.js.map +1 -1
  184. package/dist/components/index2.js +1562 -491
  185. package/dist/components/index2.js.map +1 -1
  186. package/dist/components/index3.js +90 -21
  187. package/dist/components/index3.js.map +1 -1
  188. package/dist/components/logger.js.map +1 -1
  189. package/dist/components/profile-helpers.js +1 -1
  190. package/dist/components/profile-helpers.js.map +1 -1
  191. package/dist/components/profile-store.js +1 -1
  192. package/dist/components/profile.js +3 -3
  193. package/dist/components/raw-field.js +11 -11
  194. package/dist/components/raw-field.js.map +1 -1
  195. package/dist/components/spinner.js +1 -1
  196. package/dist/components/spinner.js.map +1 -1
  197. package/dist/components/submit-button.js +3 -1
  198. package/dist/components/submit-button.js.map +1 -1
  199. package/dist/components/u-conditional-render.js +1 -1
  200. package/dist/components/u-config.js +10 -5
  201. package/dist/components/u-config.js.map +1 -1
  202. package/dist/components/u-email-field.js +1 -1
  203. package/dist/components/u-error-message.js.map +1 -1
  204. package/dist/components/u-flash-message.js +1 -1
  205. package/dist/components/u-full-profile.js +1 -1
  206. package/dist/components/u-full-profile.js.map +1 -1
  207. package/dist/components/u-logout-button.js +5 -3
  208. package/dist/components/u-logout-button.js.map +1 -1
  209. package/dist/components/u-magic-code-field.js +2 -2
  210. package/dist/components/u-magic-code-field.js.map +1 -1
  211. package/dist/components/u-missing-field.js +4 -10
  212. package/dist/components/u-missing-field.js.map +1 -1
  213. package/dist/components/u-missing-fields-submit-button.js +3 -3
  214. package/dist/components/u-missing-fields-submit-button.js.map +1 -1
  215. package/dist/components/u-newsletter-logout-button.js +9 -4
  216. package/dist/components/u-newsletter-logout-button.js.map +1 -1
  217. package/dist/components/u-newsletter-preference-checkbox.js +1 -1
  218. package/dist/components/u-newsletter-preference-checkbox.js.map +1 -1
  219. package/dist/components/u-newsletter-resend-doi-button.js +1 -1
  220. package/dist/components/u-newsletter-toggle-subscription-button.js +1 -1
  221. package/dist/components/u-pagination-button.js.map +1 -1
  222. package/dist/components/u-pagination-page.js.map +1 -1
  223. package/dist/components/u-passkey.js +1 -1
  224. package/dist/components/u-passkey.js.map +1 -1
  225. package/dist/components/u-registration-button.js +2 -2
  226. package/dist/components/u-registration-button.js.map +1 -1
  227. package/dist/components/u-send-magic-code-button.js +1 -1
  228. package/dist/components/u-send-magic-code-button.js.map +1 -1
  229. package/dist/components/u-signed-in.js.map +1 -1
  230. package/dist/components/u-signin-step.js +1 -1
  231. package/dist/components/u-signin-step.js.map +1 -1
  232. package/dist/components/u-social-login-button.js +8 -8
  233. package/dist/components/u-social-login-button.js.map +1 -1
  234. package/dist/components/u-ticketable-list.js +1 -1
  235. package/dist/esm/app-globals-BHWOrMsm.js +8 -0
  236. package/dist/esm/app-globals-BHWOrMsm.js.map +1 -0
  237. package/dist/esm/{auth-B0RIcDM-.js → auth-CAHM6e4m.js} +45 -13
  238. package/dist/esm/auth-CAHM6e4m.js.map +1 -0
  239. package/dist/esm/{auth-store-BGMYm_jK.js → auth-store-ItTnEMlF.js} +8 -4
  240. package/dist/esm/auth-store-ItTnEMlF.js.map +1 -0
  241. package/dist/esm/{component-utils-D1lzXl_Z.js → component-utils-BGq0leDV.js} +9 -2
  242. package/dist/esm/component-utils-BGq0leDV.js.map +1 -0
  243. package/dist/esm/{flash-store-CEvWSG0c.js → flash-store-CMXH65i_.js} +3 -3
  244. package/dist/esm/{flash-store-CEvWSG0c.js.map → flash-store-CMXH65i_.js.map} +1 -1
  245. package/dist/esm/{i18n-CLdWzy5J.js → i18n-OKf8uE5j.js} +432 -596
  246. package/dist/esm/i18n-OKf8uE5j.js.map +1 -0
  247. package/dist/esm/{index-Ci3aTmzp.js → index-COQ27Nb6.js} +3411 -734
  248. package/dist/esm/index-COQ27Nb6.js.map +1 -0
  249. package/dist/esm/{index-Bjp1XO-f.js → index-DVkRTYPC.js} +92 -23
  250. package/dist/esm/index-DVkRTYPC.js.map +1 -0
  251. package/dist/esm/{index-DSDkaHWI.js → index-Du3hUdhU.js} +1622 -551
  252. package/dist/esm/index-Du3hUdhU.js.map +1 -0
  253. package/dist/esm/index.js +11 -11
  254. package/dist/esm/loader.js +4 -4
  255. package/dist/esm/{newsletter-helpers-CONtbKYi.js → newsletter-helpers-ChXON0f4.js} +8 -8
  256. package/dist/esm/{newsletter-helpers-CONtbKYi.js.map → newsletter-helpers-ChXON0f4.js.map} +1 -1
  257. package/dist/esm/{newsletter-store-DBL1A203.js → newsletter-store-CIsyE51r.js} +3 -3
  258. package/dist/esm/{newsletter-store-DBL1A203.js.map → newsletter-store-CIsyE51r.js.map} +1 -1
  259. package/dist/esm/{pagination-store-DzdJOp-n.js → pagination-store-B9lk_lqK.js} +3 -3
  260. package/dist/esm/{pagination-store-DzdJOp-n.js.map → pagination-store-B9lk_lqK.js.map} +1 -1
  261. package/dist/esm/{profile-helpers-CglNd6Nw.js → profile-helpers-Beduxnin.js} +4 -4
  262. package/dist/esm/{profile-helpers-CglNd6Nw.js.map → profile-helpers-Beduxnin.js.map} +1 -1
  263. package/dist/esm/{profile-store-RmZB2PTc.js → profile-store-CsSDT9Tb.js} +4 -4
  264. package/dist/esm/{profile-store-RmZB2PTc.js.map → profile-store-CsSDT9Tb.js.map} +1 -1
  265. package/dist/esm/sdk.js +32 -5
  266. package/dist/esm/sdk.js.map +1 -1
  267. package/dist/esm/u-conditional-render.entry.js +12 -12
  268. package/dist/esm/u-config.entry.js +18 -14
  269. package/dist/esm/u-config.entry.js.map +1 -1
  270. package/dist/esm/u-email-field.entry.js +7 -7
  271. package/dist/esm/u-error-message.entry.js +7 -7
  272. package/dist/esm/u-error-message.entry.js.map +1 -1
  273. package/dist/esm/u-field.u-raw-field.entry.js.map +1 -1
  274. package/dist/esm/u-field_2.entry.js +17 -21
  275. package/dist/esm/u-flash-message.entry.js +4 -4
  276. package/dist/esm/u-full-profile.entry.js +6 -6
  277. package/dist/esm/u-full-profile.entry.js.map +1 -1
  278. package/dist/esm/u-logout-button.u-signed-in.entry.js.map +1 -1
  279. package/dist/esm/u-logout-button_2.entry.js +16 -14
  280. package/dist/esm/u-magic-code-field.entry.js +11 -11
  281. package/dist/esm/u-magic-code-field.entry.js.map +1 -1
  282. package/dist/esm/u-missing-field.entry.js +4 -4
  283. package/dist/esm/u-missing-field.entry.js.map +1 -1
  284. package/dist/esm/u-missing-fields-submit-button.entry.js +9 -9
  285. package/dist/esm/u-missing-fields-submit-button.entry.js.map +1 -1
  286. package/dist/esm/u-newsletter-checkbox.entry.js +12 -12
  287. package/dist/esm/u-newsletter-logout-button.entry.js +19 -14
  288. package/dist/esm/u-newsletter-logout-button.entry.js.map +1 -1
  289. package/dist/esm/u-newsletter-preference-checkbox.entry.js +13 -13
  290. package/dist/esm/u-newsletter-preference-checkbox.entry.js.map +1 -1
  291. package/dist/esm/u-newsletter-resend-doi-button.entry.js +13 -13
  292. package/dist/esm/u-newsletter-root.entry.js +12 -12
  293. package/dist/esm/u-newsletter-toggle-subscription-button.entry.js +13 -13
  294. package/dist/esm/u-pagination-button.entry.js +1 -1
  295. package/dist/esm/u-pagination-button.entry.js.map +1 -1
  296. package/dist/esm/u-pagination-page.entry.js +1 -1
  297. package/dist/esm/u-pagination-page.entry.js.map +1 -1
  298. package/dist/esm/u-passkey.entry.js +10 -10
  299. package/dist/esm/u-passkey.entry.js.map +1 -1
  300. package/dist/esm/u-password-field.entry.js +5 -5
  301. package/dist/esm/u-profile.u-submit-button.entry.js.map +1 -1
  302. package/dist/esm/u-profile_2.entry.js +17 -15
  303. package/dist/esm/u-registration-button.entry.js +5 -5
  304. package/dist/esm/u-registration-button.entry.js.map +1 -1
  305. package/dist/esm/u-reset-password-button.entry.js +10 -10
  306. package/dist/esm/u-send-magic-code-button.entry.js +10 -10
  307. package/dist/esm/u-send-magic-code-button.entry.js.map +1 -1
  308. package/dist/esm/u-signin-root.entry.js +6 -6
  309. package/dist/esm/u-signin-step.entry.js +10 -10
  310. package/dist/esm/u-signin-step.entry.js.map +1 -1
  311. package/dist/esm/u-signin-strategy.entry.js +4 -4
  312. package/dist/esm/u-social-login-button.entry.js +11 -11
  313. package/dist/esm/u-social-login-button.entry.js.map +1 -1
  314. package/dist/esm/u-spinner.entry.js +2 -2
  315. package/dist/esm/u-spinner.entry.js.map +1 -1
  316. package/dist/esm/u-ticketable-list.entry.js +13 -13
  317. package/dist/esm/{unidy-store-BldTAtO0.js → unidy-store-CAcMVdD8.js} +3 -3
  318. package/dist/esm/{unidy-store-BldTAtO0.js.map → unidy-store-CAcMVdD8.js.map} +1 -1
  319. package/dist/sdk/index.esm.js +1 -1
  320. package/dist/sdk/{p-93200fb4.entry.js → p-1bad3fd0.entry.js} +2 -2
  321. package/dist/sdk/{p-22e4d08b.entry.js → p-1d6982cd.entry.js} +2 -2
  322. package/dist/sdk/p-23d8e922.entry.js +2 -0
  323. package/dist/sdk/p-2855d3bb.entry.js +2 -0
  324. package/dist/sdk/p-2855d3bb.entry.js.map +1 -0
  325. package/dist/sdk/{p-339f32c1.entry.js → p-288f37c3.entry.js} +2 -2
  326. package/dist/sdk/{p-339f32c1.entry.js.map → p-288f37c3.entry.js.map} +1 -1
  327. package/dist/sdk/p-32842e98.entry.js +2 -0
  328. package/dist/sdk/p-32842e98.entry.js.map +1 -0
  329. package/dist/sdk/p-34af7470.entry.js +2 -0
  330. package/dist/sdk/p-39126514.entry.js +2 -0
  331. package/dist/sdk/{p-2af8b45f.entry.js.map → p-39126514.entry.js.map} +1 -1
  332. package/dist/sdk/{p-ad796888.entry.js → p-438f62e5.entry.js} +2 -2
  333. package/dist/sdk/{p-ad796888.entry.js.map → p-438f62e5.entry.js.map} +1 -1
  334. package/dist/sdk/{p-bb603b00.entry.js → p-46013b2f.entry.js} +2 -2
  335. package/dist/sdk/{p-08ff2de2.entry.js → p-46cdb255.entry.js} +2 -2
  336. package/dist/sdk/{p-a5db968f.entry.js → p-4d9bde6e.entry.js} +2 -2
  337. package/dist/sdk/{p-b0917777.entry.js → p-5c40c6ea.entry.js} +2 -2
  338. package/dist/sdk/p-5c8b31bd.entry.js +2 -0
  339. package/dist/sdk/p-5c8b31bd.entry.js.map +1 -0
  340. package/dist/sdk/{p-c31dbbb4.entry.js → p-69172b22.entry.js} +2 -2
  341. package/dist/sdk/p-69172b22.entry.js.map +1 -0
  342. package/dist/sdk/p-7381aca7.entry.js +2 -0
  343. package/dist/sdk/{p-6893d167.entry.js.map → p-7381aca7.entry.js.map} +1 -1
  344. package/dist/sdk/{p-D1lzXl_Z.js → p-BGq0leDV.js} +1 -1
  345. package/dist/sdk/p-BGq0leDV.js.map +1 -0
  346. package/dist/sdk/p-BR6L248H.js +2 -0
  347. package/dist/sdk/p-BR6L248H.js.map +1 -0
  348. package/dist/sdk/p-BhrvnKAS.js +2 -0
  349. package/dist/sdk/{p-Ce8zGAi1.js.map → p-BhrvnKAS.js.map} +1 -1
  350. package/dist/sdk/p-CMw6v6sC.js +2 -0
  351. package/dist/sdk/p-CMw6v6sC.js.map +1 -0
  352. package/dist/sdk/p-COQ27Nb6.js +14 -0
  353. package/dist/sdk/p-COQ27Nb6.js.map +1 -0
  354. package/dist/sdk/p-CSLU6kes.js +2 -0
  355. package/dist/sdk/{p-CPPYdoIv.js.map → p-CSLU6kes.js.map} +1 -1
  356. package/dist/sdk/p-Cai8JwlG.js +2 -0
  357. package/dist/sdk/p-Cai8JwlG.js.map +1 -0
  358. package/dist/sdk/{p-DYtgart8.js → p-CpJghKnM.js} +2 -2
  359. package/dist/sdk/{p-DYtgart8.js.map → p-CpJghKnM.js.map} +1 -1
  360. package/dist/sdk/p-DAn4FkxC.js +2 -0
  361. package/dist/sdk/{p-C0feI0p8.js.map → p-DAn4FkxC.js.map} +1 -1
  362. package/dist/sdk/p-FFRhPCmc.js +2 -0
  363. package/dist/sdk/{p-DA84OuuU.js.map → p-FFRhPCmc.js.map} +1 -1
  364. package/dist/sdk/p-Jrp0G45B.js +2 -0
  365. package/dist/sdk/{p-BlOjABPD.js.map → p-Jrp0G45B.js.map} +1 -1
  366. package/dist/sdk/p-MA26cw6g.js +2 -0
  367. package/dist/sdk/p-MA26cw6g.js.map +1 -0
  368. package/dist/sdk/p-P0eZf5rH.js +2 -0
  369. package/dist/sdk/p-P0eZf5rH.js.map +1 -0
  370. package/dist/sdk/{p-S3-2d2Qd.js → p-PSIHL0wP.js} +2 -2
  371. package/dist/sdk/{p-S3-2d2Qd.js.map → p-PSIHL0wP.js.map} +1 -1
  372. package/dist/sdk/p-a341c7f6.entry.js +2 -0
  373. package/dist/sdk/p-a341c7f6.entry.js.map +1 -0
  374. package/dist/sdk/p-a38cd448.entry.js +2 -0
  375. package/dist/sdk/{p-593c6dde.entry.js.map → p-a38cd448.entry.js.map} +1 -1
  376. package/dist/sdk/{p-87d10077.entry.js → p-a45ef398.entry.js} +2 -2
  377. package/dist/sdk/{p-87d10077.entry.js.map → p-a45ef398.entry.js.map} +1 -1
  378. package/dist/sdk/p-b5a6ad01.entry.js +2 -0
  379. package/dist/sdk/p-b5a6ad01.entry.js.map +1 -0
  380. package/dist/sdk/{p-9f59909b.entry.js → p-b93bf91d.entry.js} +2 -2
  381. package/dist/sdk/{p-9f59909b.entry.js.map → p-b93bf91d.entry.js.map} +1 -1
  382. package/dist/sdk/{p-09cd77e6.entry.js → p-baf5dcb7.entry.js} +2 -2
  383. package/dist/sdk/p-c07a43e2.entry.js +2 -0
  384. package/dist/sdk/p-c07a43e2.entry.js.map +1 -0
  385. package/dist/sdk/p-c98ad60d.entry.js +2 -0
  386. package/dist/sdk/p-c98ad60d.entry.js.map +1 -0
  387. package/dist/sdk/{p-f5615938.entry.js → p-d0c0fb6b.entry.js} +2 -2
  388. package/dist/sdk/p-d47aaf26.entry.js +2 -0
  389. package/dist/sdk/p-d47aaf26.entry.js.map +1 -0
  390. package/dist/sdk/p-e5ef30ef.entry.js +2 -0
  391. package/dist/sdk/p-eb348798.entry.js +2 -0
  392. package/dist/sdk/{p-73c2ec89.entry.js.map → p-eb348798.entry.js.map} +1 -1
  393. package/dist/sdk/p-f82f500d.entry.js +2 -0
  394. package/dist/sdk/p-f82f500d.entry.js.map +1 -0
  395. package/dist/sdk/p-f88ed6e8.entry.js +2 -0
  396. package/dist/sdk/p-f88ed6e8.entry.js.map +1 -0
  397. package/dist/sdk/{p-afc65acd.entry.js → p-f9affafe.entry.js} +2 -2
  398. package/dist/sdk/p-jyF1XwDG.js +2 -0
  399. package/dist/sdk/p-jyF1XwDG.js.map +1 -0
  400. package/dist/sdk/sdk.esm.js +1 -1
  401. package/dist/sdk/sdk.esm.js.map +1 -1
  402. package/dist/sdk/u-config.entry.esm.js.map +1 -1
  403. package/dist/sdk/u-error-message.entry.esm.js.map +1 -1
  404. package/dist/sdk/u-field.u-raw-field.entry.esm.js.map +1 -1
  405. package/dist/sdk/u-full-profile.entry.esm.js.map +1 -1
  406. package/dist/sdk/u-logout-button.u-signed-in.entry.esm.js.map +1 -1
  407. package/dist/sdk/u-magic-code-field.entry.esm.js.map +1 -1
  408. package/dist/sdk/u-missing-field.entry.esm.js.map +1 -1
  409. package/dist/sdk/u-missing-fields-submit-button.entry.esm.js.map +1 -1
  410. package/dist/sdk/u-newsletter-logout-button.entry.esm.js.map +1 -1
  411. package/dist/sdk/u-newsletter-preference-checkbox.entry.esm.js.map +1 -1
  412. package/dist/sdk/u-pagination-button.entry.esm.js.map +1 -1
  413. package/dist/sdk/u-pagination-page.entry.esm.js.map +1 -1
  414. package/dist/sdk/u-passkey.entry.esm.js.map +1 -1
  415. package/dist/sdk/u-profile.u-submit-button.entry.esm.js.map +1 -1
  416. package/dist/sdk/u-registration-button.entry.esm.js.map +1 -1
  417. package/dist/sdk/u-send-magic-code-button.entry.esm.js.map +1 -1
  418. package/dist/sdk/u-signin-step.entry.esm.js.map +1 -1
  419. package/dist/sdk/u-social-login-button.entry.esm.js.map +1 -1
  420. package/dist/sdk/u-spinner.entry.esm.js.map +1 -1
  421. package/dist/types/api/index.d.ts +2 -2
  422. package/dist/types/auth/api/auth.d.ts +3 -1
  423. package/dist/types/auth/auth-helpers.d.ts +1 -0
  424. package/dist/types/auth/auth.d.ts +9 -1
  425. package/dist/types/auth/components/logout-button/logout-button.d.ts +1 -1
  426. package/dist/types/auth/index.d.ts +3 -4
  427. package/dist/types/auth/store/auth-store.d.ts +2 -0
  428. package/dist/types/components.d.ts +8 -0
  429. package/dist/types/index.d.ts +2 -2
  430. package/dist/types/logger.d.ts +1 -1
  431. package/dist/types/newsletter/api/newsletters.d.ts +1 -1
  432. package/dist/types/newsletter/components/logout-button/logout-button.d.ts +2 -0
  433. package/dist/types/profile/components/field/field.d.ts +0 -1
  434. package/dist/types/profile/components/raw-field/raw-field.d.ts +2 -2
  435. package/dist/types/profile/index.d.ts +2 -3
  436. package/dist/types/shared/component-utils.d.ts +7 -0
  437. package/dist/types/shared/components/config/config.d.ts +1 -0
  438. package/dist/types/ticketable/api/get-with-schema.d.ts +1 -1
  439. package/dist/types/ticketable/index.d.ts +1 -1
  440. package/package.json +23 -18
  441. package/dist/cjs/app-globals-DSKjcXX_.js +0 -10
  442. package/dist/cjs/app-globals-DSKjcXX_.js.map +0 -1
  443. package/dist/cjs/auth-B83pzi0f.js.map +0 -1
  444. package/dist/cjs/auth-store-DPHWWmXf.js.map +0 -1
  445. package/dist/cjs/component-utils-BpMyeVQo.js.map +0 -1
  446. package/dist/cjs/i18n-BoDZ8kd2.js.map +0 -1
  447. package/dist/cjs/index-B_N5xKgH.js.map +0 -1
  448. package/dist/cjs/index-DLz3FT7T.js.map +0 -1
  449. package/dist/cjs/index-R2MKLaem.js.map +0 -1
  450. package/dist/esm/app-globals-CPU9ZcqZ.js +0 -8
  451. package/dist/esm/app-globals-CPU9ZcqZ.js.map +0 -1
  452. package/dist/esm/auth-B0RIcDM-.js.map +0 -1
  453. package/dist/esm/auth-store-BGMYm_jK.js.map +0 -1
  454. package/dist/esm/component-utils-D1lzXl_Z.js.map +0 -1
  455. package/dist/esm/i18n-CLdWzy5J.js.map +0 -1
  456. package/dist/esm/index-Bjp1XO-f.js.map +0 -1
  457. package/dist/esm/index-Ci3aTmzp.js.map +0 -1
  458. package/dist/esm/index-DSDkaHWI.js.map +0 -1
  459. package/dist/sdk/p-1176c407.entry.js +0 -2
  460. package/dist/sdk/p-1176c407.entry.js.map +0 -1
  461. package/dist/sdk/p-2a65bcbb.entry.js +0 -2
  462. package/dist/sdk/p-2a65bcbb.entry.js.map +0 -1
  463. package/dist/sdk/p-2af8b45f.entry.js +0 -2
  464. package/dist/sdk/p-56abb377.entry.js +0 -2
  465. package/dist/sdk/p-56abb377.entry.js.map +0 -1
  466. package/dist/sdk/p-593c6dde.entry.js +0 -2
  467. package/dist/sdk/p-5b627aea.entry.js +0 -2
  468. package/dist/sdk/p-5b627aea.entry.js.map +0 -1
  469. package/dist/sdk/p-628ccd68.entry.js +0 -2
  470. package/dist/sdk/p-675eb13d.entry.js +0 -2
  471. package/dist/sdk/p-675eb13d.entry.js.map +0 -1
  472. package/dist/sdk/p-6893d167.entry.js +0 -2
  473. package/dist/sdk/p-6a642433.entry.js +0 -2
  474. package/dist/sdk/p-73c2ec89.entry.js +0 -2
  475. package/dist/sdk/p-91bb8b59.entry.js +0 -2
  476. package/dist/sdk/p-91bb8b59.entry.js.map +0 -1
  477. package/dist/sdk/p-BZ1kW_eK.js +0 -2
  478. package/dist/sdk/p-BZ1kW_eK.js.map +0 -1
  479. package/dist/sdk/p-BlAULXyw.js +0 -2
  480. package/dist/sdk/p-BlAULXyw.js.map +0 -1
  481. package/dist/sdk/p-BlOjABPD.js +0 -2
  482. package/dist/sdk/p-C0feI0p8.js +0 -2
  483. package/dist/sdk/p-C3fhudPT.js +0 -2
  484. package/dist/sdk/p-C3fhudPT.js.map +0 -1
  485. package/dist/sdk/p-CFiZLMAA.js +0 -2
  486. package/dist/sdk/p-CFiZLMAA.js.map +0 -1
  487. package/dist/sdk/p-CPPYdoIv.js +0 -2
  488. package/dist/sdk/p-CbRhHGU5.js +0 -2
  489. package/dist/sdk/p-CbRhHGU5.js.map +0 -1
  490. package/dist/sdk/p-Ce8zGAi1.js +0 -2
  491. package/dist/sdk/p-Ci3aTmzp.js +0 -3
  492. package/dist/sdk/p-Ci3aTmzp.js.map +0 -1
  493. package/dist/sdk/p-D1lzXl_Z.js.map +0 -1
  494. package/dist/sdk/p-DA84OuuU.js +0 -2
  495. package/dist/sdk/p-DdUvQelg.js +0 -2
  496. package/dist/sdk/p-DdUvQelg.js.map +0 -1
  497. package/dist/sdk/p-b0728464.entry.js +0 -2
  498. package/dist/sdk/p-b0728464.entry.js.map +0 -1
  499. package/dist/sdk/p-c197fdb3.entry.js +0 -2
  500. package/dist/sdk/p-c197fdb3.entry.js.map +0 -1
  501. package/dist/sdk/p-c31dbbb4.entry.js.map +0 -1
  502. package/dist/sdk/p-c5bffd90.entry.js +0 -2
  503. package/dist/sdk/p-f0598e42.entry.js +0 -2
  504. package/dist/sdk/p-f0598e42.entry.js.map +0 -1
  505. package/dist/sdk/p-ffac964c.entry.js +0 -2
  506. package/dist/sdk/p-ffac964c.entry.js.map +0 -1
  507. /package/dist/sdk/{p-93200fb4.entry.js.map → p-1bad3fd0.entry.js.map} +0 -0
  508. /package/dist/sdk/{p-22e4d08b.entry.js.map → p-1d6982cd.entry.js.map} +0 -0
  509. /package/dist/sdk/{p-6a642433.entry.js.map → p-23d8e922.entry.js.map} +0 -0
  510. /package/dist/sdk/{p-c5bffd90.entry.js.map → p-34af7470.entry.js.map} +0 -0
  511. /package/dist/sdk/{p-bb603b00.entry.js.map → p-46013b2f.entry.js.map} +0 -0
  512. /package/dist/sdk/{p-08ff2de2.entry.js.map → p-46cdb255.entry.js.map} +0 -0
  513. /package/dist/sdk/{p-a5db968f.entry.js.map → p-4d9bde6e.entry.js.map} +0 -0
  514. /package/dist/sdk/{p-b0917777.entry.js.map → p-5c40c6ea.entry.js.map} +0 -0
  515. /package/dist/sdk/{p-09cd77e6.entry.js.map → p-baf5dcb7.entry.js.map} +0 -0
  516. /package/dist/sdk/{p-f5615938.entry.js.map → p-d0c0fb6b.entry.js.map} +0 -0
  517. /package/dist/sdk/{p-628ccd68.entry.js.map → p-e5ef30ef.entry.js.map} +0 -0
  518. /package/dist/sdk/{p-afc65acd.entry.js.map → p-f9affafe.entry.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var index = require('./index-B_N5xKgH.js');
4
- var unidyStore = require('./unidy-store-7AbWnZ6g.js');
3
+ var index = require('./index-BzhKFIXk.js');
4
+ var unidyStore = require('./unidy-store-zhdhlK0a.js');
5
5
 
6
6
  const isString = obj => typeof obj === 'string';
7
7
  const defer = () => {
@@ -63,7 +63,7 @@ const setPath = (object, path, newValue) => {
63
63
  e = `${p[p.length - 1]}.${e}`;
64
64
  p = p.slice(0, p.length - 1);
65
65
  last = getLastOfPath(object, p, Object);
66
- if (last && last.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
66
+ if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
67
67
  last.obj = undefined;
68
68
  }
69
69
  }
@@ -83,6 +83,7 @@ const getPath = (object, path) => {
83
83
  k
84
84
  } = getLastOfPath(object, path);
85
85
  if (!obj) return undefined;
86
+ if (!Object.prototype.hasOwnProperty.call(obj, k)) return undefined;
86
87
  return obj[k];
87
88
  };
88
89
  const getPathWithDefaults = (data, defaultData, key) => {
@@ -160,10 +161,12 @@ const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
160
161
  }
161
162
  return matched;
162
163
  };
163
- const deepFind = function (obj, path) {
164
- let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
164
+ const deepFind = (obj, path, keySeparator = '.') => {
165
165
  if (!obj) return undefined;
166
- if (obj[path]) return obj[path];
166
+ if (obj[path]) {
167
+ if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
168
+ return obj[path];
169
+ }
167
170
  const tokens = path.split(keySeparator);
168
171
  let current = obj;
169
172
  for (let i = 0; i < tokens.length;) {
@@ -190,7 +193,7 @@ const deepFind = function (obj, path) {
190
193
  }
191
194
  return current;
192
195
  };
193
- const getCleanedCode = code => code && code.replace('_', '-');
196
+ const getCleanedCode = code => code?.replace('_', '-');
194
197
 
195
198
  const consoleLogger = {
196
199
  type: 'logger',
@@ -204,43 +207,29 @@ const consoleLogger = {
204
207
  this.output('error', args);
205
208
  },
206
209
  output(type, args) {
207
- if (console && console[type]) console[type].apply(console, args);
210
+ console?.[type]?.apply?.(console, args);
208
211
  }
209
212
  };
210
213
  class Logger {
211
- constructor(concreteLogger) {
212
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
214
+ constructor(concreteLogger, options = {}) {
213
215
  this.init(concreteLogger, options);
214
216
  }
215
- init(concreteLogger) {
216
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
217
+ init(concreteLogger, options = {}) {
217
218
  this.prefix = options.prefix || 'i18next:';
218
219
  this.logger = concreteLogger || consoleLogger;
219
220
  this.options = options;
220
221
  this.debug = options.debug;
221
222
  }
222
- log() {
223
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
224
- args[_key] = arguments[_key];
225
- }
223
+ log(...args) {
226
224
  return this.forward(args, 'log', '', true);
227
225
  }
228
- warn() {
229
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
230
- args[_key2] = arguments[_key2];
231
- }
226
+ warn(...args) {
232
227
  return this.forward(args, 'warn', '', true);
233
228
  }
234
- error() {
235
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
236
- args[_key3] = arguments[_key3];
237
- }
229
+ error(...args) {
238
230
  return this.forward(args, 'error', '');
239
231
  }
240
- deprecate() {
241
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
242
- args[_key4] = arguments[_key4];
243
- }
232
+ deprecate(...args) {
244
233
  return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
245
234
  }
246
235
  forward(args, lvl, prefix, debugOnly) {
@@ -284,14 +273,10 @@ class EventEmitter {
284
273
  }
285
274
  this.observers[event].delete(listener);
286
275
  }
287
- emit(event) {
288
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
289
- args[_key - 1] = arguments[_key];
290
- }
276
+ emit(event, ...args) {
291
277
  if (this.observers[event]) {
292
278
  const cloned = Array.from(this.observers[event].entries());
293
- cloned.forEach(_ref => {
294
- let [observer, numTimesAdded] = _ref;
279
+ cloned.forEach(([observer, numTimesAdded]) => {
295
280
  for (let i = 0; i < numTimesAdded; i++) {
296
281
  observer(...args);
297
282
  }
@@ -299,8 +284,7 @@ class EventEmitter {
299
284
  }
300
285
  if (this.observers['*']) {
301
286
  const cloned = Array.from(this.observers['*'].entries());
302
- cloned.forEach(_ref2 => {
303
- let [observer, numTimesAdded] = _ref2;
287
+ cloned.forEach(([observer, numTimesAdded]) => {
304
288
  for (let i = 0; i < numTimesAdded; i++) {
305
289
  observer.apply(observer, [event, ...args]);
306
290
  }
@@ -310,11 +294,10 @@ class EventEmitter {
310
294
  }
311
295
 
312
296
  class ResourceStore extends EventEmitter {
313
- constructor(data) {
314
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
315
- ns: ['translation'],
316
- defaultNS: 'translation'
317
- };
297
+ constructor(data, options = {
298
+ ns: ['translation'],
299
+ defaultNS: 'translation'
300
+ }) {
318
301
  super();
319
302
  this.data = data || {};
320
303
  this.options = options;
@@ -336,8 +319,7 @@ class ResourceStore extends EventEmitter {
336
319
  this.options.ns.splice(index, 1);
337
320
  }
338
321
  }
339
- getResource(lng, ns, key) {
340
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
322
+ getResource(lng, ns, key, options = {}) {
341
323
  const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
342
324
  const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
343
325
  let path;
@@ -362,12 +344,11 @@ class ResourceStore extends EventEmitter {
362
344
  key = path.slice(2).join('.');
363
345
  }
364
346
  if (result || !ignoreJSONStructure || !isString(key)) return result;
365
- return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
347
+ return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
366
348
  }
367
- addResource(lng, ns, key, value) {
368
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
369
- silent: false
370
- };
349
+ addResource(lng, ns, key, value, options = {
350
+ silent: false
351
+ }) {
371
352
  const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
372
353
  let path = [lng, ns];
373
354
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
@@ -380,10 +361,9 @@ class ResourceStore extends EventEmitter {
380
361
  setPath(this.data, path, value);
381
362
  if (!options.silent) this.emit('added', lng, ns, key, value);
382
363
  }
383
- addResources(lng, ns, resources) {
384
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
385
- silent: false
386
- };
364
+ addResources(lng, ns, resources, options = {
365
+ silent: false
366
+ }) {
387
367
  for (const m in resources) {
388
368
  if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
389
369
  silent: true
@@ -391,11 +371,10 @@ class ResourceStore extends EventEmitter {
391
371
  }
392
372
  if (!options.silent) this.emit('added', lng, ns, resources);
393
373
  }
394
- addResourceBundle(lng, ns, resources, deep, overwrite) {
395
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
396
- silent: false,
397
- skipCopy: false
398
- };
374
+ addResourceBundle(lng, ns, resources, deep, overwrite, options = {
375
+ silent: false,
376
+ skipCopy: false
377
+ }) {
399
378
  let path = [lng, ns];
400
379
  if (lng.indexOf('.') > -1) {
401
380
  path = lng.split('.');
@@ -429,10 +408,6 @@ class ResourceStore extends EventEmitter {
429
408
  }
430
409
  getResourceBundle(lng, ns) {
431
410
  if (!ns) ns = this.options.defaultNS;
432
- if (this.options.compatibilityAPI === 'v1') return {
433
- ...{},
434
- ...this.getResource(lng, ns)
435
- };
436
411
  return this.getResource(lng, ns);
437
412
  }
438
413
  getDataByLanguage(lng) {
@@ -455,16 +430,37 @@ var postProcessor = {
455
430
  },
456
431
  handle(processors, value, key, options, translator) {
457
432
  processors.forEach(processor => {
458
- if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
433
+ value = this.processors[processor]?.process(value, key, options, translator) ?? value;
459
434
  });
460
435
  return value;
461
436
  }
462
437
  };
463
438
 
439
+ const PATH_KEY = Symbol('i18next/PATH_KEY');
440
+ function createProxy() {
441
+ const state = [];
442
+ const handler = Object.create(null);
443
+ let proxy;
444
+ handler.get = (target, key) => {
445
+ proxy?.revoke?.();
446
+ if (key === PATH_KEY) return state;
447
+ state.push(key);
448
+ proxy = Proxy.revocable(target, handler);
449
+ return proxy.proxy;
450
+ };
451
+ return Proxy.revocable(Object.create(null), handler).proxy;
452
+ }
453
+ function keysFromSelector(selector, opts) {
454
+ const {
455
+ [PATH_KEY]: path
456
+ } = selector(createProxy());
457
+ return path.join(opts?.keySeparator ?? '.');
458
+ }
459
+
464
460
  const checkedLoadedFor = {};
461
+ const shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
465
462
  class Translator extends EventEmitter {
466
- constructor(services) {
467
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
463
+ constructor(services, options = {}) {
468
464
  super();
469
465
  copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
470
466
  this.options = options;
@@ -476,23 +472,28 @@ class Translator extends EventEmitter {
476
472
  changeLanguage(lng) {
477
473
  if (lng) this.language = lng;
478
474
  }
479
- exists(key) {
480
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
481
- interpolation: {}
475
+ exists(key, o = {
476
+ interpolation: {}
477
+ }) {
478
+ const opt = {
479
+ ...o
482
480
  };
483
- if (key === undefined || key === null) {
481
+ if (key == null) return false;
482
+ const resolved = this.resolve(key, opt);
483
+ if (resolved?.res === undefined) return false;
484
+ const isObject = shouldHandleAsObject(resolved.res);
485
+ if (opt.returnObjects === false && isObject) {
484
486
  return false;
485
487
  }
486
- const resolved = this.resolve(key, options);
487
- return resolved && resolved.res !== undefined;
488
+ return true;
488
489
  }
489
- extractFromKey(key, options) {
490
- let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
490
+ extractFromKey(key, opt) {
491
+ let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
491
492
  if (nsSeparator === undefined) nsSeparator = ':';
492
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
493
- let namespaces = options.ns || this.options.defaultNS || [];
493
+ const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
494
+ let namespaces = opt.ns || this.options.defaultNS || [];
494
495
  const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
495
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
496
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
496
497
  if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
497
498
  const m = key.match(this.interpolator.nestingRegexp);
498
499
  if (m && m.length > 0) {
@@ -510,28 +511,36 @@ class Translator extends EventEmitter {
510
511
  namespaces: isString(namespaces) ? [namespaces] : namespaces
511
512
  };
512
513
  }
513
- translate(keys, options, lastKey) {
514
- if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
515
- options = this.options.overloadTranslationOptionHandler(arguments);
514
+ translate(keys, o, lastKey) {
515
+ let opt = typeof o === 'object' ? {
516
+ ...o
517
+ } : o;
518
+ if (typeof opt !== 'object' && this.options.overloadTranslationOptionHandler) {
519
+ opt = this.options.overloadTranslationOptionHandler(arguments);
516
520
  }
517
- if (typeof options === 'object') options = {
518
- ...options
521
+ if (typeof opt === 'object') opt = {
522
+ ...opt
519
523
  };
520
- if (!options) options = {};
521
- if (keys === undefined || keys === null) return '';
524
+ if (!opt) opt = {};
525
+ if (keys == null) return '';
526
+ if (typeof keys === 'function') keys = keysFromSelector(keys, {
527
+ ...this.options,
528
+ ...opt
529
+ });
522
530
  if (!Array.isArray(keys)) keys = [String(keys)];
523
- const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
524
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
531
+ const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
532
+ const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
525
533
  const {
526
534
  key,
527
535
  namespaces
528
- } = this.extractFromKey(keys[keys.length - 1], options);
536
+ } = this.extractFromKey(keys[keys.length - 1], opt);
529
537
  const namespace = namespaces[namespaces.length - 1];
530
- const lng = options.lng || this.language;
531
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
532
- if (lng && lng.toLowerCase() === 'cimode') {
538
+ let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
539
+ if (nsSeparator === undefined) nsSeparator = ':';
540
+ const lng = opt.lng || this.language;
541
+ const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
542
+ if (lng?.toLowerCase() === 'cimode') {
533
543
  if (appendNamespaceToCIMode) {
534
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
535
544
  if (returnDetails) {
536
545
  return {
537
546
  res: `${namespace}${nsSeparator}${key}`,
@@ -539,7 +548,7 @@ class Translator extends EventEmitter {
539
548
  exactUsedKey: key,
540
549
  usedLng: lng,
541
550
  usedNS: namespace,
542
- usedParams: this.getUsedParamsDetails(options)
551
+ usedParams: this.getUsedParamsDetails(opt)
543
552
  };
544
553
  }
545
554
  return `${namespace}${nsSeparator}${key}`;
@@ -551,69 +560,84 @@ class Translator extends EventEmitter {
551
560
  exactUsedKey: key,
552
561
  usedLng: lng,
553
562
  usedNS: namespace,
554
- usedParams: this.getUsedParamsDetails(options)
563
+ usedParams: this.getUsedParamsDetails(opt)
555
564
  };
556
565
  }
557
566
  return key;
558
567
  }
559
- const resolved = this.resolve(keys, options);
560
- let res = resolved && resolved.res;
561
- const resUsedKey = resolved && resolved.usedKey || key;
562
- const resExactUsedKey = resolved && resolved.exactUsedKey || key;
563
- const resType = Object.prototype.toString.apply(res);
568
+ const resolved = this.resolve(keys, opt);
569
+ let res = resolved?.res;
570
+ const resUsedKey = resolved?.usedKey || key;
571
+ const resExactUsedKey = resolved?.exactUsedKey || key;
564
572
  const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
565
- const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
573
+ const joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
566
574
  const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
567
- const handleAsObject = !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
568
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(res))) {
569
- if (!options.returnObjects && !this.options.returnObjects) {
575
+ const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
576
+ const hasDefaultValue = Translator.hasDefaultValue(opt);
577
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : '';
578
+ const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
579
+ ordinal: false
580
+ }) : '';
581
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
582
+ const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
583
+ let resForObjHndl = res;
584
+ if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
585
+ resForObjHndl = defaultValue;
586
+ }
587
+ const handleAsObject = shouldHandleAsObject(resForObjHndl);
588
+ const resType = Object.prototype.toString.apply(resForObjHndl);
589
+ if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
590
+ if (!opt.returnObjects && !this.options.returnObjects) {
570
591
  if (!this.options.returnedObjectHandler) {
571
592
  this.logger.warn('accessing an object - but returnObjects options is not enabled!');
572
593
  }
573
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
574
- ...options,
594
+ const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
595
+ ...opt,
575
596
  ns: namespaces
576
597
  }) : `key '${key} (${this.language})' returned an object instead of string.`;
577
598
  if (returnDetails) {
578
599
  resolved.res = r;
579
- resolved.usedParams = this.getUsedParamsDetails(options);
600
+ resolved.usedParams = this.getUsedParamsDetails(opt);
580
601
  return resolved;
581
602
  }
582
603
  return r;
583
604
  }
584
605
  if (keySeparator) {
585
- const resTypeIsArray = Array.isArray(res);
606
+ const resTypeIsArray = Array.isArray(resForObjHndl);
586
607
  const copy = resTypeIsArray ? [] : {};
587
608
  const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
588
- for (const m in res) {
589
- if (Object.prototype.hasOwnProperty.call(res, m)) {
609
+ for (const m in resForObjHndl) {
610
+ if (Object.prototype.hasOwnProperty.call(resForObjHndl, m)) {
590
611
  const deepKey = `${newKeyToUse}${keySeparator}${m}`;
591
- copy[m] = this.translate(deepKey, {
592
- ...options,
593
- ...{
594
- joinArrays: false,
595
- ns: namespaces
596
- }
597
- });
598
- if (copy[m] === deepKey) copy[m] = res[m];
612
+ if (hasDefaultValue && !res) {
613
+ copy[m] = this.translate(deepKey, {
614
+ ...opt,
615
+ defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined,
616
+ ...{
617
+ joinArrays: false,
618
+ ns: namespaces
619
+ }
620
+ });
621
+ } else {
622
+ copy[m] = this.translate(deepKey, {
623
+ ...opt,
624
+ ...{
625
+ joinArrays: false,
626
+ ns: namespaces
627
+ }
628
+ });
629
+ }
630
+ if (copy[m] === deepKey) copy[m] = resForObjHndl[m];
599
631
  }
600
632
  }
601
633
  res = copy;
602
634
  }
603
635
  } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
604
636
  res = res.join(joinArrays);
605
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
637
+ if (res) res = this.extendTranslation(res, keys, opt, lastKey);
606
638
  } else {
607
639
  let usedDefault = false;
608
640
  let usedKey = false;
609
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
610
- const hasDefaultValue = Translator.hasDefaultValue(options);
611
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
612
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
613
- ordinal: false
614
- }) : '';
615
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
616
- const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
617
641
  if (!this.isValidLookup(res) && hasDefaultValue) {
618
642
  usedDefault = true;
619
643
  res = defaultValue;
@@ -622,47 +646,47 @@ class Translator extends EventEmitter {
622
646
  usedKey = true;
623
647
  res = key;
624
648
  }
625
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
649
+ const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
626
650
  const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
627
651
  const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
628
652
  if (usedKey || usedDefault || updateMissing) {
629
653
  this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
630
654
  if (keySeparator) {
631
655
  const fk = this.resolve(key, {
632
- ...options,
656
+ ...opt,
633
657
  keySeparator: false
634
658
  });
635
659
  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.');
636
660
  }
637
661
  let lngs = [];
638
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
662
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
639
663
  if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
640
664
  for (let i = 0; i < fallbackLngs.length; i++) {
641
665
  lngs.push(fallbackLngs[i]);
642
666
  }
643
667
  } else if (this.options.saveMissingTo === 'all') {
644
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
668
+ lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
645
669
  } else {
646
- lngs.push(options.lng || this.language);
670
+ lngs.push(opt.lng || this.language);
647
671
  }
648
672
  const send = (l, k, specificDefaultValue) => {
649
673
  const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
650
674
  if (this.options.missingKeyHandler) {
651
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
652
- } else if (this.backendConnector && this.backendConnector.saveMissing) {
653
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
675
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
676
+ } else if (this.backendConnector?.saveMissing) {
677
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
654
678
  }
655
679
  this.emit('missingKey', l, namespace, k, res);
656
680
  };
657
681
  if (this.options.saveMissing) {
658
682
  if (this.options.saveMissingPlurals && needsPluralHandling) {
659
683
  lngs.forEach(language => {
660
- const suffixes = this.pluralResolver.getSuffixes(language, options);
661
- if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
684
+ const suffixes = this.pluralResolver.getSuffixes(language, opt);
685
+ if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
662
686
  suffixes.push(`${this.options.pluralSeparator}zero`);
663
687
  }
664
688
  suffixes.forEach(suffix => {
665
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
689
+ send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
666
690
  });
667
691
  });
668
692
  } else {
@@ -670,87 +694,80 @@ class Translator extends EventEmitter {
670
694
  }
671
695
  }
672
696
  }
673
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
674
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
697
+ res = this.extendTranslation(res, keys, opt, resolved, lastKey);
698
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
699
+ res = `${namespace}${nsSeparator}${key}`;
700
+ }
675
701
  if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
676
- if (this.options.compatibilityAPI !== 'v1') {
677
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
678
- } else {
679
- res = this.options.parseMissingKeyHandler(res);
680
- }
702
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : undefined, opt);
681
703
  }
682
704
  }
683
705
  if (returnDetails) {
684
706
  resolved.res = res;
685
- resolved.usedParams = this.getUsedParamsDetails(options);
707
+ resolved.usedParams = this.getUsedParamsDetails(opt);
686
708
  return resolved;
687
709
  }
688
710
  return res;
689
711
  }
690
- extendTranslation(res, key, options, resolved, lastKey) {
691
- var _this = this;
692
- if (this.i18nFormat && this.i18nFormat.parse) {
712
+ extendTranslation(res, key, opt, resolved, lastKey) {
713
+ if (this.i18nFormat?.parse) {
693
714
  res = this.i18nFormat.parse(res, {
694
715
  ...this.options.interpolation.defaultVariables,
695
- ...options
696
- }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
716
+ ...opt
717
+ }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
697
718
  resolved
698
719
  });
699
- } else if (!options.skipInterpolation) {
700
- if (options.interpolation) this.interpolator.init({
701
- ...options,
720
+ } else if (!opt.skipInterpolation) {
721
+ if (opt.interpolation) this.interpolator.init({
722
+ ...opt,
702
723
  ...{
703
724
  interpolation: {
704
725
  ...this.options.interpolation,
705
- ...options.interpolation
726
+ ...opt.interpolation
706
727
  }
707
728
  }
708
729
  });
709
- const skipOnVariables = isString(res) && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
730
+ const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== undefined ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
710
731
  let nestBef;
711
732
  if (skipOnVariables) {
712
733
  const nb = res.match(this.interpolator.nestingRegexp);
713
734
  nestBef = nb && nb.length;
714
735
  }
715
- let data = options.replace && !isString(options.replace) ? options.replace : options;
736
+ let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
716
737
  if (this.options.interpolation.defaultVariables) data = {
717
738
  ...this.options.interpolation.defaultVariables,
718
739
  ...data
719
740
  };
720
- res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
741
+ res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
721
742
  if (skipOnVariables) {
722
743
  const na = res.match(this.interpolator.nestingRegexp);
723
744
  const nestAft = na && na.length;
724
- if (nestBef < nestAft) options.nest = false;
745
+ if (nestBef < nestAft) opt.nest = false;
725
746
  }
726
- if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
727
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
728
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
729
- args[_key] = arguments[_key];
730
- }
731
- if (lastKey && lastKey[0] === args[0] && !options.context) {
732
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
747
+ if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
748
+ if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
749
+ if (lastKey?.[0] === args[0] && !opt.context) {
750
+ this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
733
751
  return null;
734
752
  }
735
- return _this.translate(...args, key);
736
- }, options);
737
- if (options.interpolation) this.interpolator.reset();
753
+ return this.translate(...args, key);
754
+ }, opt);
755
+ if (opt.interpolation) this.interpolator.reset();
738
756
  }
739
- const postProcess = options.postProcess || this.options.postProcess;
757
+ const postProcess = opt.postProcess || this.options.postProcess;
740
758
  const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
741
- if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
759
+ if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
742
760
  res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
743
761
  i18nResolved: {
744
762
  ...resolved,
745
- usedParams: this.getUsedParamsDetails(options)
763
+ usedParams: this.getUsedParamsDetails(opt)
746
764
  },
747
- ...options
748
- } : options, this);
765
+ ...opt
766
+ } : opt, this);
749
767
  }
750
768
  return res;
751
769
  }
752
- resolve(keys) {
753
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
770
+ resolve(keys, opt = {}) {
754
771
  let found;
755
772
  let usedKey;
756
773
  let exactUsedKey;
@@ -759,19 +776,19 @@ class Translator extends EventEmitter {
759
776
  if (isString(keys)) keys = [keys];
760
777
  keys.forEach(k => {
761
778
  if (this.isValidLookup(found)) return;
762
- const extracted = this.extractFromKey(k, options);
779
+ const extracted = this.extractFromKey(k, opt);
763
780
  const key = extracted.key;
764
781
  usedKey = key;
765
782
  let namespaces = extracted.namespaces;
766
783
  if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
767
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
768
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
769
- const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
770
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
784
+ const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
785
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
786
+ const needsContextHandling = opt.context !== undefined && (isString(opt.context) || typeof opt.context === 'number') && opt.context !== '';
787
+ const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
771
788
  namespaces.forEach(ns => {
772
789
  if (this.isValidLookup(found)) return;
773
790
  usedNS = ns;
774
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
791
+ if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
775
792
  checkedLoadedFor[`${codes[0]}-${ns}`] = true;
776
793
  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!!!');
777
794
  }
@@ -779,30 +796,30 @@ class Translator extends EventEmitter {
779
796
  if (this.isValidLookup(found)) return;
780
797
  usedLng = code;
781
798
  const finalKeys = [key];
782
- if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
783
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
799
+ if (this.i18nFormat?.addLookupKeys) {
800
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
784
801
  } else {
785
802
  let pluralSuffix;
786
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
803
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
787
804
  const zeroSuffix = `${this.options.pluralSeparator}zero`;
788
805
  const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
789
806
  if (needsPluralHandling) {
790
- finalKeys.push(key + pluralSuffix);
791
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
807
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
792
808
  finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
793
809
  }
810
+ finalKeys.push(key + pluralSuffix);
794
811
  if (needsZeroSuffixLookup) {
795
812
  finalKeys.push(key + zeroSuffix);
796
813
  }
797
814
  }
798
815
  if (needsContextHandling) {
799
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
816
+ const contextKey = `${key}${this.options.contextSeparator || '_'}${opt.context}`;
800
817
  finalKeys.push(contextKey);
801
818
  if (needsPluralHandling) {
802
- finalKeys.push(contextKey + pluralSuffix);
803
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
819
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
804
820
  finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
805
821
  }
822
+ finalKeys.push(contextKey + pluralSuffix);
806
823
  if (needsZeroSuffixLookup) {
807
824
  finalKeys.push(contextKey + zeroSuffix);
808
825
  }
@@ -813,7 +830,7 @@ class Translator extends EventEmitter {
813
830
  while (possibleKey = finalKeys.pop()) {
814
831
  if (!this.isValidLookup(found)) {
815
832
  exactUsedKey = possibleKey;
816
- found = this.getResource(code, ns, possibleKey, options);
833
+ found = this.getResource(code, ns, possibleKey, opt);
817
834
  }
818
835
  }
819
836
  });
@@ -830,13 +847,11 @@ class Translator extends EventEmitter {
830
847
  isValidLookup(res) {
831
848
  return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
832
849
  }
833
- getResource(code, ns, key) {
834
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
835
- if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
850
+ getResource(code, ns, key, options = {}) {
851
+ if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
836
852
  return this.resourceStore.getResource(code, ns, key, options);
837
853
  }
838
- getUsedParamsDetails() {
839
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
854
+ getUsedParamsDetails(options = {}) {
840
855
  const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
841
856
  const useOptionsReplaceForData = options.replace && !isString(options.replace);
842
857
  let data = useOptionsReplaceForData ? options.replace : options;
@@ -870,7 +885,6 @@ class Translator extends EventEmitter {
870
885
  }
871
886
  }
872
887
 
873
- const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1);
874
888
  class LanguageUtil {
875
889
  constructor(options) {
876
890
  this.options = options;
@@ -894,31 +908,18 @@ class LanguageUtil {
894
908
  }
895
909
  formatLanguageCode(code) {
896
910
  if (isString(code) && code.indexOf('-') > -1) {
897
- if (typeof Intl !== 'undefined' && typeof Intl.getCanonicalLocales !== 'undefined') {
898
- try {
899
- let formattedCode = Intl.getCanonicalLocales(code)[0];
900
- if (formattedCode && this.options.lowerCaseLng) {
901
- formattedCode = formattedCode.toLowerCase();
902
- }
903
- if (formattedCode) return formattedCode;
904
- } catch (e) {}
911
+ let formattedCode;
912
+ try {
913
+ formattedCode = Intl.getCanonicalLocales(code)[0];
914
+ } catch (e) {}
915
+ if (formattedCode && this.options.lowerCaseLng) {
916
+ formattedCode = formattedCode.toLowerCase();
905
917
  }
906
- const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
907
- let p = code.split('-');
918
+ if (formattedCode) return formattedCode;
908
919
  if (this.options.lowerCaseLng) {
909
- p = p.map(part => part.toLowerCase());
910
- } else if (p.length === 2) {
911
- p[0] = p[0].toLowerCase();
912
- p[1] = p[1].toUpperCase();
913
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
914
- } else if (p.length === 3) {
915
- p[0] = p[0].toLowerCase();
916
- if (p[1].length === 2) p[1] = p[1].toUpperCase();
917
- if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
918
- if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
919
- if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
920
+ return code.toLowerCase();
920
921
  }
921
- return p.join('-');
922
+ return code;
922
923
  }
923
924
  return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
924
925
  }
@@ -939,6 +940,8 @@ class LanguageUtil {
939
940
  if (!found && this.options.supportedLngs) {
940
941
  codes.forEach(code => {
941
942
  if (found) return;
943
+ const lngScOnly = this.getScriptPartFromCode(code);
944
+ if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
942
945
  const lngOnly = this.getLanguagePartFromCode(code);
943
946
  if (this.isSupportedCode(lngOnly)) return found = lngOnly;
944
947
  found = this.options.supportedLngs.find(supportedLng => {
@@ -966,7 +969,7 @@ class LanguageUtil {
966
969
  return found || [];
967
970
  }
968
971
  toResolveHierarchy(code, fallbackCode) {
969
- const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
972
+ const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
970
973
  const codes = [];
971
974
  const addCode = c => {
972
975
  if (!c) return;
@@ -990,125 +993,6 @@ class LanguageUtil {
990
993
  }
991
994
  }
992
995
 
993
- let sets = [{
994
- lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
995
- nr: [1, 2],
996
- fc: 1
997
- }, {
998
- lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
999
- nr: [1, 2],
1000
- fc: 2
1001
- }, {
1002
- lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
1003
- nr: [1],
1004
- fc: 3
1005
- }, {
1006
- lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
1007
- nr: [1, 2, 5],
1008
- fc: 4
1009
- }, {
1010
- lngs: ['ar'],
1011
- nr: [0, 1, 2, 3, 11, 100],
1012
- fc: 5
1013
- }, {
1014
- lngs: ['cs', 'sk'],
1015
- nr: [1, 2, 5],
1016
- fc: 6
1017
- }, {
1018
- lngs: ['csb', 'pl'],
1019
- nr: [1, 2, 5],
1020
- fc: 7
1021
- }, {
1022
- lngs: ['cy'],
1023
- nr: [1, 2, 3, 8],
1024
- fc: 8
1025
- }, {
1026
- lngs: ['fr'],
1027
- nr: [1, 2],
1028
- fc: 9
1029
- }, {
1030
- lngs: ['ga'],
1031
- nr: [1, 2, 3, 7, 11],
1032
- fc: 10
1033
- }, {
1034
- lngs: ['gd'],
1035
- nr: [1, 2, 3, 20],
1036
- fc: 11
1037
- }, {
1038
- lngs: ['is'],
1039
- nr: [1, 2],
1040
- fc: 12
1041
- }, {
1042
- lngs: ['jv'],
1043
- nr: [0, 1],
1044
- fc: 13
1045
- }, {
1046
- lngs: ['kw'],
1047
- nr: [1, 2, 3, 4],
1048
- fc: 14
1049
- }, {
1050
- lngs: ['lt'],
1051
- nr: [1, 2, 10],
1052
- fc: 15
1053
- }, {
1054
- lngs: ['lv'],
1055
- nr: [1, 2, 0],
1056
- fc: 16
1057
- }, {
1058
- lngs: ['mk'],
1059
- nr: [1, 2],
1060
- fc: 17
1061
- }, {
1062
- lngs: ['mnk'],
1063
- nr: [0, 1, 2],
1064
- fc: 18
1065
- }, {
1066
- lngs: ['mt'],
1067
- nr: [1, 2, 11, 20],
1068
- fc: 19
1069
- }, {
1070
- lngs: ['or'],
1071
- nr: [2, 1],
1072
- fc: 2
1073
- }, {
1074
- lngs: ['ro'],
1075
- nr: [1, 2, 20],
1076
- fc: 20
1077
- }, {
1078
- lngs: ['sl'],
1079
- nr: [5, 1, 2, 3],
1080
- fc: 21
1081
- }, {
1082
- lngs: ['he', 'iw'],
1083
- nr: [1, 2, 20, 21],
1084
- fc: 22
1085
- }];
1086
- let _rulesPluralsTypes = {
1087
- 1: n => Number(n > 1),
1088
- 2: n => Number(n != 1),
1089
- 3: n => 0,
1090
- 4: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1091
- 5: n => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
1092
- 6: n => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
1093
- 7: n => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1094
- 8: n => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
1095
- 9: n => Number(n >= 2),
1096
- 10: n => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
1097
- 11: n => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
1098
- 12: n => Number(n % 10 != 1 || n % 100 == 11),
1099
- 13: n => Number(n !== 0),
1100
- 14: n => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
1101
- 15: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
1102
- 16: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
1103
- 17: n => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
1104
- 18: n => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
1105
- 19: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
1106
- 20: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
1107
- 21: n => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
1108
- 22: n => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
1109
- };
1110
- const nonIntlVersions = ['v1', 'v2', 'v3'];
1111
- const intlVersions = ['v4'];
1112
996
  const suffixesOrder = {
1113
997
  zero: 0,
1114
998
  one: 1,
@@ -1117,129 +1001,74 @@ const suffixesOrder = {
1117
1001
  many: 4,
1118
1002
  other: 5
1119
1003
  };
1120
- const createRules = () => {
1121
- const rules = {};
1122
- sets.forEach(set => {
1123
- set.lngs.forEach(l => {
1124
- rules[l] = {
1125
- numbers: set.nr,
1126
- plurals: _rulesPluralsTypes[set.fc]
1127
- };
1128
- });
1129
- });
1130
- return rules;
1004
+ const dummyRule = {
1005
+ select: count => count === 1 ? 'one' : 'other',
1006
+ resolvedOptions: () => ({
1007
+ pluralCategories: ['one', 'other']
1008
+ })
1131
1009
  };
1132
1010
  class PluralResolver {
1133
- constructor(languageUtils) {
1134
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1011
+ constructor(languageUtils, options = {}) {
1135
1012
  this.languageUtils = languageUtils;
1136
1013
  this.options = options;
1137
1014
  this.logger = baseLogger.create('pluralResolver');
1138
- if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
1139
- this.options.compatibilityJSON = 'v3';
1140
- this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
1141
- }
1142
- this.rules = createRules();
1143
1015
  this.pluralRulesCache = {};
1144
1016
  }
1145
- addRule(lng, obj) {
1146
- this.rules[lng] = obj;
1147
- }
1148
1017
  clearCache() {
1149
1018
  this.pluralRulesCache = {};
1150
1019
  }
1151
- getRule(code) {
1152
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1153
- if (this.shouldUseIntlApi()) {
1154
- const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
1155
- const type = options.ordinal ? 'ordinal' : 'cardinal';
1156
- const cacheKey = JSON.stringify({
1157
- cleanedCode,
1020
+ getRule(code, options = {}) {
1021
+ const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
1022
+ const type = options.ordinal ? 'ordinal' : 'cardinal';
1023
+ const cacheKey = JSON.stringify({
1024
+ cleanedCode,
1025
+ type
1026
+ });
1027
+ if (cacheKey in this.pluralRulesCache) {
1028
+ return this.pluralRulesCache[cacheKey];
1029
+ }
1030
+ let rule;
1031
+ try {
1032
+ rule = new Intl.PluralRules(cleanedCode, {
1158
1033
  type
1159
1034
  });
1160
- if (cacheKey in this.pluralRulesCache) {
1161
- return this.pluralRulesCache[cacheKey];
1035
+ } catch (err) {
1036
+ if (!Intl) {
1037
+ this.logger.error('No Intl support, please use an Intl polyfill!');
1038
+ return dummyRule;
1162
1039
  }
1163
- let rule;
1164
- try {
1165
- rule = new Intl.PluralRules(cleanedCode, {
1166
- type
1167
- });
1168
- } catch (err) {
1169
- if (!code.match(/-|_/)) return;
1170
- const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1171
- rule = this.getRule(lngPart, options);
1172
- }
1173
- this.pluralRulesCache[cacheKey] = rule;
1174
- return rule;
1040
+ if (!code.match(/-|_/)) return dummyRule;
1041
+ const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1042
+ rule = this.getRule(lngPart, options);
1175
1043
  }
1176
- return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
1044
+ this.pluralRulesCache[cacheKey] = rule;
1045
+ return rule;
1177
1046
  }
1178
- needsPlural(code) {
1179
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1180
- const rule = this.getRule(code, options);
1181
- if (this.shouldUseIntlApi()) {
1182
- return rule && rule.resolvedOptions().pluralCategories.length > 1;
1183
- }
1184
- return rule && rule.numbers.length > 1;
1047
+ needsPlural(code, options = {}) {
1048
+ let rule = this.getRule(code, options);
1049
+ if (!rule) rule = this.getRule('dev', options);
1050
+ return rule?.resolvedOptions().pluralCategories.length > 1;
1185
1051
  }
1186
- getPluralFormsOfKey(code, key) {
1187
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1052
+ getPluralFormsOfKey(code, key, options = {}) {
1188
1053
  return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1189
1054
  }
1190
- getSuffixes(code) {
1191
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1192
- const rule = this.getRule(code, options);
1193
- if (!rule) {
1194
- return [];
1195
- }
1196
- if (this.shouldUseIntlApi()) {
1197
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1198
- }
1199
- return rule.numbers.map(number => this.getSuffix(code, number, options));
1055
+ getSuffixes(code, options = {}) {
1056
+ let rule = this.getRule(code, options);
1057
+ if (!rule) rule = this.getRule('dev', options);
1058
+ if (!rule) return [];
1059
+ return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1200
1060
  }
1201
- getSuffix(code, count) {
1202
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1061
+ getSuffix(code, count, options = {}) {
1203
1062
  const rule = this.getRule(code, options);
1204
1063
  if (rule) {
1205
- if (this.shouldUseIntlApi()) {
1206
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1207
- }
1208
- return this.getSuffixRetroCompatible(rule, count);
1064
+ return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1209
1065
  }
1210
1066
  this.logger.warn(`no plural rule found for: ${code}`);
1211
- return '';
1212
- }
1213
- getSuffixRetroCompatible(rule, count) {
1214
- const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
1215
- let suffix = rule.numbers[idx];
1216
- if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1217
- if (suffix === 2) {
1218
- suffix = 'plural';
1219
- } else if (suffix === 1) {
1220
- suffix = '';
1221
- }
1222
- }
1223
- const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
1224
- if (this.options.compatibilityJSON === 'v1') {
1225
- if (suffix === 1) return '';
1226
- if (typeof suffix === 'number') return `_plural_${suffix.toString()}`;
1227
- return returnSuffix();
1228
- } else if (this.options.compatibilityJSON === 'v2') {
1229
- return returnSuffix();
1230
- } else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
1231
- return returnSuffix();
1232
- }
1233
- return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
1234
- }
1235
- shouldUseIntlApi() {
1236
- return !nonIntlVersions.includes(this.options.compatibilityJSON);
1067
+ return this.getSuffix('dev', count, options);
1237
1068
  }
1238
1069
  }
1239
1070
 
1240
- const deepFindWithDefaults = function (data, defaultData, key) {
1241
- let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1242
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1071
+ const deepFindWithDefaults = (data, defaultData, key, keySeparator = '.', ignoreJSONStructure = true) => {
1243
1072
  let path = getPathWithDefaults(data, defaultData, key);
1244
1073
  if (!path && ignoreJSONStructure && isString(key)) {
1245
1074
  path = deepFind(data, key, keySeparator);
@@ -1249,15 +1078,13 @@ const deepFindWithDefaults = function (data, defaultData, key) {
1249
1078
  };
1250
1079
  const regexSafe = val => val.replace(/\$/g, '$$$$');
1251
1080
  class Interpolator {
1252
- constructor() {
1253
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1081
+ constructor(options = {}) {
1254
1082
  this.logger = baseLogger.create('interpolator');
1255
1083
  this.options = options;
1256
- this.format = options.interpolation && options.interpolation.format || (value => value);
1084
+ this.format = options?.interpolation?.format || (value => value);
1257
1085
  this.init(options);
1258
1086
  }
1259
- init() {
1260
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1087
+ init(options = {}) {
1261
1088
  if (!options.interpolation) options.interpolation = {
1262
1089
  escapeValue: true
1263
1090
  };
@@ -1300,7 +1127,7 @@ class Interpolator {
1300
1127
  }
1301
1128
  resetRegExp() {
1302
1129
  const getOrResetRegExp = (existingRegExp, pattern) => {
1303
- if (existingRegExp && existingRegExp.source === pattern) {
1130
+ if (existingRegExp?.source === pattern) {
1304
1131
  existingRegExp.lastIndex = 0;
1305
1132
  return existingRegExp;
1306
1133
  }
@@ -1308,7 +1135,7 @@ class Interpolator {
1308
1135
  };
1309
1136
  this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1310
1137
  this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1311
- this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
1138
+ this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}((?:[^()"']+|"[^"]*"|'[^']*'|\\((?:[^()]|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`);
1312
1139
  }
1313
1140
  interpolate(str, data, lng, options) {
1314
1141
  let match;
@@ -1334,8 +1161,8 @@ class Interpolator {
1334
1161
  });
1335
1162
  };
1336
1163
  this.resetRegExp();
1337
- const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
1338
- const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1164
+ const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
1165
+ const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1339
1166
  const todos = [{
1340
1167
  regex: this.regexpUnescape,
1341
1168
  safeValue: val => regexSafe(val)
@@ -1380,8 +1207,7 @@ class Interpolator {
1380
1207
  });
1381
1208
  return str;
1382
1209
  }
1383
- nest(str, fc) {
1384
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1210
+ nest(str, fc, options = {}) {
1385
1211
  let match;
1386
1212
  let value;
1387
1213
  let clonedOptions;
@@ -1394,7 +1220,7 @@ class Interpolator {
1394
1220
  optionsString = this.interpolate(optionsString, clonedOptions);
1395
1221
  const matchedSingleQuotes = optionsString.match(/'/g);
1396
1222
  const matchedDoubleQuotes = optionsString.match(/"/g);
1397
- if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1223
+ if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1398
1224
  optionsString = optionsString.replace(/'/g, '"');
1399
1225
  }
1400
1226
  try {
@@ -1418,12 +1244,10 @@ class Interpolator {
1418
1244
  clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1419
1245
  clonedOptions.applyPostProcessor = false;
1420
1246
  delete clonedOptions.defaultValue;
1421
- let doReduce = false;
1422
- if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1423
- const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1424
- match[1] = r.shift();
1425
- formatters = r;
1426
- doReduce = true;
1247
+ const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf('}') + 1 : match[1].indexOf(this.formatSeparator);
1248
+ if (keyEndIndex !== -1) {
1249
+ formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map(elem => elem.trim()).filter(Boolean);
1250
+ match[1] = match[1].slice(0, keyEndIndex);
1427
1251
  }
1428
1252
  value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1429
1253
  if (value && match[0] === str && !isString(value)) return value;
@@ -1432,7 +1256,7 @@ class Interpolator {
1432
1256
  this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1433
1257
  value = '';
1434
1258
  }
1435
- if (doReduce) {
1259
+ if (formatters.length) {
1436
1260
  value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1437
1261
  ...options,
1438
1262
  interpolationkey: match[1].trim()
@@ -1478,68 +1302,68 @@ const parseFormatStr = formatStr => {
1478
1302
  };
1479
1303
  const createCachedFormatter = fn => {
1480
1304
  const cache = {};
1481
- return (val, lng, options) => {
1482
- let optForCache = options;
1483
- if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
1305
+ return (v, l, o) => {
1306
+ let optForCache = o;
1307
+ if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
1484
1308
  optForCache = {
1485
1309
  ...optForCache,
1486
- [options.interpolationkey]: undefined
1310
+ [o.interpolationkey]: undefined
1487
1311
  };
1488
1312
  }
1489
- const key = lng + JSON.stringify(optForCache);
1490
- let formatter = cache[key];
1491
- if (!formatter) {
1492
- formatter = fn(getCleanedCode(lng), options);
1493
- cache[key] = formatter;
1313
+ const key = l + JSON.stringify(optForCache);
1314
+ let frm = cache[key];
1315
+ if (!frm) {
1316
+ frm = fn(getCleanedCode(l), o);
1317
+ cache[key] = frm;
1494
1318
  }
1495
- return formatter(val);
1319
+ return frm(v);
1496
1320
  };
1497
1321
  };
1322
+ const createNonCachedFormatter = fn => (v, l, o) => fn(getCleanedCode(l), o)(v);
1498
1323
  class Formatter {
1499
- constructor() {
1500
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1324
+ constructor(options = {}) {
1501
1325
  this.logger = baseLogger.create('formatter');
1502
1326
  this.options = options;
1327
+ this.init(options);
1328
+ }
1329
+ init(services, options = {
1330
+ interpolation: {}
1331
+ }) {
1332
+ this.formatSeparator = options.interpolation.formatSeparator || ',';
1333
+ const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
1503
1334
  this.formats = {
1504
- number: createCachedFormatter((lng, opt) => {
1335
+ number: cf((lng, opt) => {
1505
1336
  const formatter = new Intl.NumberFormat(lng, {
1506
1337
  ...opt
1507
1338
  });
1508
1339
  return val => formatter.format(val);
1509
1340
  }),
1510
- currency: createCachedFormatter((lng, opt) => {
1341
+ currency: cf((lng, opt) => {
1511
1342
  const formatter = new Intl.NumberFormat(lng, {
1512
1343
  ...opt,
1513
1344
  style: 'currency'
1514
1345
  });
1515
1346
  return val => formatter.format(val);
1516
1347
  }),
1517
- datetime: createCachedFormatter((lng, opt) => {
1348
+ datetime: cf((lng, opt) => {
1518
1349
  const formatter = new Intl.DateTimeFormat(lng, {
1519
1350
  ...opt
1520
1351
  });
1521
1352
  return val => formatter.format(val);
1522
1353
  }),
1523
- relativetime: createCachedFormatter((lng, opt) => {
1354
+ relativetime: cf((lng, opt) => {
1524
1355
  const formatter = new Intl.RelativeTimeFormat(lng, {
1525
1356
  ...opt
1526
1357
  });
1527
1358
  return val => formatter.format(val, opt.range || 'day');
1528
1359
  }),
1529
- list: createCachedFormatter((lng, opt) => {
1360
+ list: cf((lng, opt) => {
1530
1361
  const formatter = new Intl.ListFormat(lng, {
1531
1362
  ...opt
1532
1363
  });
1533
1364
  return val => formatter.format(val);
1534
1365
  })
1535
1366
  };
1536
- this.init(options);
1537
- }
1538
- init(services) {
1539
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1540
- interpolation: {}
1541
- };
1542
- this.formatSeparator = options.interpolation.formatSeparator || ',';
1543
1367
  }
1544
1368
  add(name, fc) {
1545
1369
  this.formats[name.toLowerCase().trim()] = fc;
@@ -1547,8 +1371,7 @@ class Formatter {
1547
1371
  addCached(name, fc) {
1548
1372
  this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1549
1373
  }
1550
- format(value, format, lng) {
1551
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1374
+ format(value, format, lng, options = {}) {
1552
1375
  const formats = format.split(this.formatSeparator);
1553
1376
  if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1554
1377
  const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
@@ -1562,7 +1385,7 @@ class Formatter {
1562
1385
  if (this.formats[formatName]) {
1563
1386
  let formatted = mem;
1564
1387
  try {
1565
- const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
1388
+ const valOptions = options?.formatParams?.[options.interpolationkey] || {};
1566
1389
  const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1567
1390
  formatted = this.formats[formatName](mem, l, {
1568
1391
  ...formatOptions,
@@ -1589,8 +1412,7 @@ const removePending = (q, name) => {
1589
1412
  }
1590
1413
  };
1591
1414
  class Connector extends EventEmitter {
1592
- constructor(backend, store, services) {
1593
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1415
+ constructor(backend, store, services, options = {}) {
1594
1416
  super();
1595
1417
  this.backend = backend;
1596
1418
  this.store = store;
@@ -1605,9 +1427,7 @@ class Connector extends EventEmitter {
1605
1427
  this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1606
1428
  this.state = {};
1607
1429
  this.queue = [];
1608
- if (this.backend && this.backend.init) {
1609
- this.backend.init(services, options.backend, options);
1610
- }
1430
+ this.backend?.init?.(services, options.backend, options);
1611
1431
  }
1612
1432
  queueLoad(languages, namespaces, options, callback) {
1613
1433
  const toLoad = {};
@@ -1686,10 +1506,7 @@ class Connector extends EventEmitter {
1686
1506
  this.emit('loaded', loaded);
1687
1507
  this.queue = this.queue.filter(q => !q.done);
1688
1508
  }
1689
- read(lng, ns, fcName) {
1690
- let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1691
- let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1692
- let callback = arguments.length > 5 ? arguments[5] : undefined;
1509
+ read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
1693
1510
  if (!lng.length) return callback(null, {});
1694
1511
  if (this.readingCalls >= this.maxParallelReads) {
1695
1512
  this.waitingReads.push({
@@ -1733,9 +1550,7 @@ class Connector extends EventEmitter {
1733
1550
  }
1734
1551
  return fc(lng, ns, resolver);
1735
1552
  }
1736
- prepareLoading(languages, namespaces) {
1737
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1738
- let callback = arguments.length > 3 ? arguments[3] : undefined;
1553
+ prepareLoading(languages, namespaces, options = {}, callback) {
1739
1554
  if (!this.backend) {
1740
1555
  this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1741
1556
  return callback && callback();
@@ -1759,8 +1574,7 @@ class Connector extends EventEmitter {
1759
1574
  reload: true
1760
1575
  }, callback);
1761
1576
  }
1762
- loadOne(name) {
1763
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1577
+ loadOne(name, prefix = '') {
1764
1578
  const s = name.split('|');
1765
1579
  const lng = s[0];
1766
1580
  const ns = s[1];
@@ -1770,15 +1584,13 @@ class Connector extends EventEmitter {
1770
1584
  this.loaded(name, err, data);
1771
1585
  });
1772
1586
  }
1773
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1774
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1775
- let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1776
- if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
1587
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
1588
+ if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
1777
1589
  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!!!');
1778
1590
  return;
1779
1591
  }
1780
1592
  if (key === undefined || key === null || key === '') return;
1781
- if (this.backend && this.backend.create) {
1593
+ if (this.backend?.create) {
1782
1594
  const opts = {
1783
1595
  ...options,
1784
1596
  isUpdate
@@ -1811,7 +1623,7 @@ class Connector extends EventEmitter {
1811
1623
 
1812
1624
  const get = () => ({
1813
1625
  debug: false,
1814
- initImmediate: true,
1626
+ initAsync: true,
1815
1627
  ns: ['translation'],
1816
1628
  defaultNS: ['translation'],
1817
1629
  fallbackLng: ['dev'],
@@ -1867,15 +1679,17 @@ const get = () => ({
1867
1679
  nestingOptionsSeparator: ',',
1868
1680
  maxReplaces: 1000,
1869
1681
  skipOnVariables: true
1870
- }
1682
+ },
1683
+ cacheInBuiltFormats: true
1871
1684
  });
1872
1685
  const transformOptions = options => {
1873
1686
  if (isString(options.ns)) options.ns = [options.ns];
1874
1687
  if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1875
1688
  if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1876
- if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
1689
+ if (options.supportedLngs?.indexOf?.('cimode') < 0) {
1877
1690
  options.supportedLngs = options.supportedLngs.concat(['cimode']);
1878
1691
  }
1692
+ if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
1879
1693
  return options;
1880
1694
  };
1881
1695
 
@@ -1889,9 +1703,7 @@ const bindMemberFunctions = inst => {
1889
1703
  });
1890
1704
  };
1891
1705
  class I18n extends EventEmitter {
1892
- constructor() {
1893
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1894
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1706
+ constructor(options = {}, callback) {
1895
1707
  super();
1896
1708
  this.options = transformOptions(options);
1897
1709
  this.services = {};
@@ -1901,7 +1713,7 @@ class I18n extends EventEmitter {
1901
1713
  };
1902
1714
  bindMemberFunctions(this);
1903
1715
  if (callback && !this.isInitialized && !options.isClone) {
1904
- if (!this.options.initImmediate) {
1716
+ if (!this.options.initAsync) {
1905
1717
  this.init(options, callback);
1906
1718
  return this;
1907
1719
  }
@@ -1910,16 +1722,13 @@ class I18n extends EventEmitter {
1910
1722
  }, 0);
1911
1723
  }
1912
1724
  }
1913
- init() {
1914
- var _this = this;
1915
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1916
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1725
+ init(options = {}, callback) {
1917
1726
  this.isInitializing = true;
1918
1727
  if (typeof options === 'function') {
1919
1728
  callback = options;
1920
1729
  options = {};
1921
1730
  }
1922
- if (!options.defaultNS && options.defaultNS !== false && options.ns) {
1731
+ if (options.defaultNS == null && options.ns) {
1923
1732
  if (isString(options.ns)) {
1924
1733
  options.defaultNS = options.ns;
1925
1734
  } else if (options.ns.indexOf('translation') < 0) {
@@ -1932,18 +1741,19 @@ class I18n extends EventEmitter {
1932
1741
  ...this.options,
1933
1742
  ...transformOptions(options)
1934
1743
  };
1935
- if (this.options.compatibilityAPI !== 'v1') {
1936
- this.options.interpolation = {
1937
- ...defOpts.interpolation,
1938
- ...this.options.interpolation
1939
- };
1940
- }
1744
+ this.options.interpolation = {
1745
+ ...defOpts.interpolation,
1746
+ ...this.options.interpolation
1747
+ };
1941
1748
  if (options.keySeparator !== undefined) {
1942
1749
  this.options.userDefinedKeySeparator = options.keySeparator;
1943
1750
  }
1944
1751
  if (options.nsSeparator !== undefined) {
1945
1752
  this.options.userDefinedNsSeparator = options.nsSeparator;
1946
1753
  }
1754
+ if (typeof this.options.overloadTranslationOptionHandler !== 'function') {
1755
+ this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
1756
+ }
1947
1757
  const createClassOnDemand = ClassOrObject => {
1948
1758
  if (!ClassOrObject) return null;
1949
1759
  if (typeof ClassOrObject === 'function') return new ClassOrObject();
@@ -1958,7 +1768,7 @@ class I18n extends EventEmitter {
1958
1768
  let formatter;
1959
1769
  if (this.modules.formatter) {
1960
1770
  formatter = this.modules.formatter;
1961
- } else if (typeof Intl !== 'undefined') {
1771
+ } else {
1962
1772
  formatter = Formatter;
1963
1773
  }
1964
1774
  const lu = new LanguageUtil(this.options);
@@ -1969,12 +1779,15 @@ class I18n extends EventEmitter {
1969
1779
  s.languageUtils = lu;
1970
1780
  s.pluralResolver = new PluralResolver(lu, {
1971
1781
  prepend: this.options.pluralSeparator,
1972
- compatibilityJSON: this.options.compatibilityJSON,
1973
1782
  simplifyPluralSuffix: this.options.simplifyPluralSuffix
1974
1783
  });
1784
+ const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
1785
+ if (usingLegacyFormatFunction) {
1786
+ this.logger.deprecate(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
1787
+ }
1975
1788
  if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1976
1789
  s.formatter = createClassOnDemand(formatter);
1977
- s.formatter.init(s, this.options);
1790
+ if (s.formatter.init) s.formatter.init(s, this.options);
1978
1791
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1979
1792
  }
1980
1793
  s.interpolator = new Interpolator(this.options);
@@ -1982,11 +1795,8 @@ class I18n extends EventEmitter {
1982
1795
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1983
1796
  };
1984
1797
  s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1985
- s.backendConnector.on('*', function (event) {
1986
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1987
- args[_key - 1] = arguments[_key];
1988
- }
1989
- _this.emit(event, ...args);
1798
+ s.backendConnector.on('*', (event, ...args) => {
1799
+ this.emit(event, ...args);
1990
1800
  });
1991
1801
  if (this.modules.languageDetector) {
1992
1802
  s.languageDetector = createClassOnDemand(this.modules.languageDetector);
@@ -1997,11 +1807,8 @@ class I18n extends EventEmitter {
1997
1807
  if (s.i18nFormat.init) s.i18nFormat.init(this);
1998
1808
  }
1999
1809
  this.translator = new Translator(this.services, this.options);
2000
- this.translator.on('*', function (event) {
2001
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
2002
- args[_key2 - 1] = arguments[_key2];
2003
- }
2004
- _this.emit(event, ...args);
1810
+ this.translator.on('*', (event, ...args) => {
1811
+ this.emit(event, ...args);
2005
1812
  });
2006
1813
  this.modules.external.forEach(m => {
2007
1814
  if (m.init) m.init(this);
@@ -2018,15 +1825,13 @@ class I18n extends EventEmitter {
2018
1825
  }
2019
1826
  const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
2020
1827
  storeApi.forEach(fcName => {
2021
- this[fcName] = function () {
2022
- return _this.store[fcName](...arguments);
2023
- };
1828
+ this[fcName] = (...args) => this.store[fcName](...args);
2024
1829
  });
2025
1830
  const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
2026
1831
  storeApiChained.forEach(fcName => {
2027
- this[fcName] = function () {
2028
- _this.store[fcName](...arguments);
2029
- return _this;
1832
+ this[fcName] = (...args) => {
1833
+ this.store[fcName](...args);
1834
+ return this;
2030
1835
  };
2031
1836
  });
2032
1837
  const deferred = defer();
@@ -2040,23 +1845,22 @@ class I18n extends EventEmitter {
2040
1845
  deferred.resolve(t);
2041
1846
  callback(err, t);
2042
1847
  };
2043
- if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));
1848
+ if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
2044
1849
  this.changeLanguage(this.options.lng, finish);
2045
1850
  };
2046
- if (this.options.resources || !this.options.initImmediate) {
1851
+ if (this.options.resources || !this.options.initAsync) {
2047
1852
  load();
2048
1853
  } else {
2049
1854
  setTimeout(load, 0);
2050
1855
  }
2051
1856
  return deferred;
2052
1857
  }
2053
- loadResources(language) {
2054
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
1858
+ loadResources(language, callback = noop) {
2055
1859
  let usedCallback = callback;
2056
1860
  const usedLng = isString(language) ? language : this.language;
2057
1861
  if (typeof language === 'function') usedCallback = language;
2058
1862
  if (!this.options.resources || this.options.partialBundledLanguages) {
2059
- if (usedLng && usedLng.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
1863
+ if (usedLng?.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
2060
1864
  const toLoad = [];
2061
1865
  const append = lng => {
2062
1866
  if (!lng) return;
@@ -2073,9 +1877,7 @@ class I18n extends EventEmitter {
2073
1877
  } else {
2074
1878
  append(usedLng);
2075
1879
  }
2076
- if (this.options.preload) {
2077
- this.options.preload.forEach(l => append(l));
2078
- }
1880
+ this.options.preload?.forEach?.(l => append(l));
2079
1881
  this.services.backendConnector.load(toLoad, this.options.ns, e => {
2080
1882
  if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
2081
1883
  usedCallback(e);
@@ -2140,9 +1942,12 @@ class I18n extends EventEmitter {
2140
1942
  break;
2141
1943
  }
2142
1944
  }
1945
+ if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
1946
+ this.resolvedLanguage = l;
1947
+ this.languages.unshift(l);
1948
+ }
2143
1949
  }
2144
1950
  changeLanguage(lng, callback) {
2145
- var _this2 = this;
2146
1951
  this.isLanguageChangingTo = lng;
2147
1952
  const deferred = defer();
2148
1953
  this.emit('languageChanging', lng);
@@ -2154,30 +1959,29 @@ class I18n extends EventEmitter {
2154
1959
  };
2155
1960
  const done = (err, l) => {
2156
1961
  if (l) {
2157
- setLngProps(l);
2158
- this.translator.changeLanguage(l);
2159
- this.isLanguageChangingTo = undefined;
2160
- this.emit('languageChanged', l);
2161
- this.logger.log('languageChanged', l);
1962
+ if (this.isLanguageChangingTo === lng) {
1963
+ setLngProps(l);
1964
+ this.translator.changeLanguage(l);
1965
+ this.isLanguageChangingTo = undefined;
1966
+ this.emit('languageChanged', l);
1967
+ this.logger.log('languageChanged', l);
1968
+ }
2162
1969
  } else {
2163
1970
  this.isLanguageChangingTo = undefined;
2164
1971
  }
2165
- deferred.resolve(function () {
2166
- return _this2.t(...arguments);
2167
- });
2168
- if (callback) callback(err, function () {
2169
- return _this2.t(...arguments);
2170
- });
1972
+ deferred.resolve((...args) => this.t(...args));
1973
+ if (callback) callback(err, (...args) => this.t(...args));
2171
1974
  };
2172
1975
  const setLng = lngs => {
2173
1976
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
2174
- const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
1977
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
1978
+ const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
2175
1979
  if (l) {
2176
1980
  if (!this.language) {
2177
1981
  setLngProps(l);
2178
1982
  }
2179
1983
  if (!this.translator.language) this.translator.changeLanguage(l);
2180
- if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
1984
+ this.services.languageDetector?.cacheUserLanguage?.(l);
2181
1985
  }
2182
1986
  this.loadResources(l, err => {
2183
1987
  done(err, l);
@@ -2197,31 +2001,37 @@ class I18n extends EventEmitter {
2197
2001
  return deferred;
2198
2002
  }
2199
2003
  getFixedT(lng, ns, keyPrefix) {
2200
- var _this3 = this;
2201
- const fixedT = function (key, opts) {
2202
- let options;
2004
+ const fixedT = (key, opts, ...rest) => {
2005
+ let o;
2203
2006
  if (typeof opts !== 'object') {
2204
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2205
- rest[_key3 - 2] = arguments[_key3];
2206
- }
2207
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2007
+ o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2208
2008
  } else {
2209
- options = {
2009
+ o = {
2210
2010
  ...opts
2211
2011
  };
2212
2012
  }
2213
- options.lng = options.lng || fixedT.lng;
2214
- options.lngs = options.lngs || fixedT.lngs;
2215
- options.ns = options.ns || fixedT.ns;
2216
- if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2217
- const keySeparator = _this3.options.keySeparator || '.';
2013
+ o.lng = o.lng || fixedT.lng;
2014
+ o.lngs = o.lngs || fixedT.lngs;
2015
+ o.ns = o.ns || fixedT.ns;
2016
+ if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
2017
+ const keySeparator = this.options.keySeparator || '.';
2218
2018
  let resultKey;
2219
- if (options.keyPrefix && Array.isArray(key)) {
2220
- resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2019
+ if (o.keyPrefix && Array.isArray(key)) {
2020
+ resultKey = key.map(k => {
2021
+ if (typeof k === 'function') k = keysFromSelector(k, {
2022
+ ...this.options,
2023
+ ...opts
2024
+ });
2025
+ return `${o.keyPrefix}${keySeparator}${k}`;
2026
+ });
2221
2027
  } else {
2222
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2028
+ if (typeof key === 'function') key = keysFromSelector(key, {
2029
+ ...this.options,
2030
+ ...opts
2031
+ });
2032
+ resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
2223
2033
  }
2224
- return _this3.t(resultKey, options);
2034
+ return this.t(resultKey, o);
2225
2035
  };
2226
2036
  if (isString(lng)) {
2227
2037
  fixedT.lng = lng;
@@ -2232,17 +2042,16 @@ class I18n extends EventEmitter {
2232
2042
  fixedT.keyPrefix = keyPrefix;
2233
2043
  return fixedT;
2234
2044
  }
2235
- t() {
2236
- return this.translator && this.translator.translate(...arguments);
2045
+ t(...args) {
2046
+ return this.translator?.translate(...args);
2237
2047
  }
2238
- exists() {
2239
- return this.translator && this.translator.exists(...arguments);
2048
+ exists(...args) {
2049
+ return this.translator?.exists(...args);
2240
2050
  }
2241
2051
  setDefaultNamespace(ns) {
2242
2052
  this.options.defaultNS = ns;
2243
2053
  }
2244
- hasLoadedNamespace(ns) {
2245
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2054
+ hasLoadedNamespace(ns, options = {}) {
2246
2055
  if (!this.isInitialized) {
2247
2056
  this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2248
2057
  return false;
@@ -2301,20 +2110,26 @@ class I18n extends EventEmitter {
2301
2110
  return deferred;
2302
2111
  }
2303
2112
  dir(lng) {
2304
- if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
2113
+ if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
2305
2114
  if (!lng) return 'rtl';
2115
+ try {
2116
+ const l = new Intl.Locale(lng);
2117
+ if (l && l.getTextInfo) {
2118
+ const ti = l.getTextInfo();
2119
+ if (ti && ti.direction) return ti.direction;
2120
+ }
2121
+ } catch (e) {}
2306
2122
  const rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
2307
- const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
2123
+ const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
2124
+ if (lng.toLowerCase().indexOf('-latn') > 1) return 'ltr';
2308
2125
  return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2309
2126
  }
2310
- static createInstance() {
2311
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2312
- let callback = arguments.length > 1 ? arguments[1] : undefined;
2313
- return new I18n(options, callback);
2127
+ static createInstance(options = {}, callback) {
2128
+ const instance = new I18n(options, callback);
2129
+ instance.createInstance = I18n.createInstance;
2130
+ return instance;
2314
2131
  }
2315
- cloneInstance() {
2316
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2317
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2132
+ cloneInstance(options = {}, callback = noop) {
2318
2133
  const forkResourceStore = options.forkResourceStore;
2319
2134
  if (forkResourceStore) delete options.forkResourceStore;
2320
2135
  const mergedOptions = {
@@ -2339,14 +2154,36 @@ class I18n extends EventEmitter {
2339
2154
  hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2340
2155
  };
2341
2156
  if (forkResourceStore) {
2342
- clone.store = new ResourceStore(this.store.data, mergedOptions);
2157
+ const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
2158
+ prev[l] = {
2159
+ ...this.store.data[l]
2160
+ };
2161
+ prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
2162
+ acc[n] = {
2163
+ ...prev[l][n]
2164
+ };
2165
+ return acc;
2166
+ }, prev[l]);
2167
+ return prev;
2168
+ }, {});
2169
+ clone.store = new ResourceStore(clonedData, mergedOptions);
2343
2170
  clone.services.resourceStore = clone.store;
2344
2171
  }
2172
+ if (options.interpolation) {
2173
+ const defOpts = get();
2174
+ const mergedInterpolation = {
2175
+ ...defOpts.interpolation,
2176
+ ...this.options.interpolation,
2177
+ ...options.interpolation
2178
+ };
2179
+ const mergedForInterpolator = {
2180
+ ...mergedOptions,
2181
+ interpolation: mergedInterpolation
2182
+ };
2183
+ clone.services.interpolator = new Interpolator(mergedForInterpolator);
2184
+ }
2345
2185
  clone.translator = new Translator(clone.services, mergedOptions);
2346
- clone.translator.on('*', function (event) {
2347
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
2348
- args[_key4 - 1] = arguments[_key4];
2349
- }
2186
+ clone.translator.on('*', (event, ...args) => {
2350
2187
  clone.emit(event, ...args);
2351
2188
  });
2352
2189
  clone.init(mergedOptions, callback);
@@ -2367,7 +2204,6 @@ class I18n extends EventEmitter {
2367
2204
  }
2368
2205
  }
2369
2206
  const instance = I18n.createInstance();
2370
- instance.createInstance = I18n.createInstance;
2371
2207
 
2372
2208
  const auth$5 = {
2373
2209
  email: {
@@ -3231,6 +3067,6 @@ const t = (key, opts = {}) => instance.t(key, opts, { lng: unidyStore.unidyState
3231
3067
 
3232
3068
  exports.instance = instance;
3233
3069
  exports.t = t;
3234
- //# sourceMappingURL=i18n-BoDZ8kd2.js.map
3070
+ //# sourceMappingURL=i18n-B2T1e9Mf.js.map
3235
3071
 
3236
- //# sourceMappingURL=i18n-BoDZ8kd2.js.map
3072
+ //# sourceMappingURL=i18n-B2T1e9Mf.js.map