crmbonus-component-wake 2.0.125 → 2.0.126

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 (371) hide show
  1. package/dist/{esm → crmbonus-component-wake}/app-modal.entry.js +2 -3
  2. package/dist/crmbonus-component-wake/app-modal.entry.js.map +1 -0
  3. package/dist/{components/p-abbfbc98.js → crmbonus-component-wake/cart.helper-4e40ffa9.js} +3 -2
  4. package/dist/crmbonus-component-wake/cart.helper-4e40ffa9.js.map +1 -0
  5. package/dist/{esm/cart.helper-30a40560.js → crmbonus-component-wake/cart.helper-a921d7f9.js} +3 -2
  6. package/dist/crmbonus-component-wake/cart.helper-a921d7f9.js.map +1 -0
  7. package/dist/{components/p-2b3b8d6b.js → crmbonus-component-wake/countdown-timer.entry.js} +7 -27
  8. package/dist/crmbonus-component-wake/countdown-timer.entry.js.map +1 -0
  9. package/dist/{esm → crmbonus-component-wake}/crm-bonus-form.entry.js +4 -5
  10. package/dist/crmbonus-component-wake/{p-c23f3a07.entry.js.map → crm-bonus-form.entry.js.map} +1 -1
  11. package/dist/{esm → crmbonus-component-wake}/crm-bonus-note.entry.js +9 -10
  12. package/dist/crmbonus-component-wake/crm-bonus-note.entry.js.map +1 -0
  13. package/dist/{esm → crmbonus-component-wake}/crm-bonus.entry.js +8 -7
  14. package/dist/crmbonus-component-wake/crm-bonus.entry.js.map +1 -0
  15. package/dist/crmbonus-component-wake/crm-button.entry.js +20 -0
  16. package/dist/crmbonus-component-wake/crm-button.entry.js.map +1 -0
  17. package/dist/{esm/crm-giftback-form_2.entry.js → crmbonus-component-wake/crm-giftback-form.entry.js} +12 -27
  18. package/dist/crmbonus-component-wake/crm-giftback-form.entry.js.map +1 -0
  19. package/dist/{components/p-58b97429.js → crmbonus-component-wake/crm-tooltip.entry.js} +8 -27
  20. package/dist/crmbonus-component-wake/crm-tooltip.entry.js.map +1 -0
  21. package/dist/crmbonus-component-wake/crmbonus-component-wake.css +7 -1
  22. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js +48 -1
  23. package/dist/crmbonus-component-wake/crmbonus-component-wake.esm.js.map +1 -1
  24. package/dist/{esm/crmbonus.service-42fbd7fa.js → crmbonus-component-wake/crmbonus.service-67550994.js} +162 -90
  25. package/dist/crmbonus-component-wake/crmbonus.service-67550994.js.map +1 -0
  26. package/dist/{components/p-6eda79c3.js → crmbonus-component-wake/crmbonus.service-9f4c6fd7.js} +165 -93
  27. package/dist/crmbonus-component-wake/crmbonus.service-9f4c6fd7.js.map +1 -0
  28. package/dist/{components/p-b79c86a8.js → crmbonus-component-wake/giftback-finish.entry.js} +8 -25
  29. package/dist/crmbonus-component-wake/giftback-finish.entry.js.map +1 -0
  30. package/dist/{components/p-2671d669.js → crmbonus-component-wake/giftback-info.entry.js} +12 -52
  31. package/dist/crmbonus-component-wake/giftback-info.entry.js.map +1 -0
  32. package/dist/{components/p-6186ddcc.js → crmbonus-component-wake/giftback-pin.entry.js} +8 -38
  33. package/dist/crmbonus-component-wake/giftback-pin.entry.js.map +1 -0
  34. package/dist/{components/p-7c744cca.js → crmbonus-component-wake/giftback-progress.entry.js} +8 -37
  35. package/dist/crmbonus-component-wake/giftback-progress.entry.js.map +1 -0
  36. package/dist/{esm/i18n-e8150dff.js → crmbonus-component-wake/i18n-11138a2c.js} +16 -1
  37. package/dist/{esm/i18n-e8150dff.js.map → crmbonus-component-wake/i18n-11138a2c.js.map} +1 -1
  38. package/dist/crmbonus-component-wake/index-d0fd1dc0.js +3039 -0
  39. package/dist/crmbonus-component-wake/index-d0fd1dc0.js.map +1 -0
  40. package/dist/crmbonus-component-wake/index.esm.js +12 -1
  41. package/dist/crmbonus-component-wake/index.esm.js.map +1 -1
  42. package/dist/crmbonus-component-wake/loading-container.entry.js +18 -0
  43. package/dist/crmbonus-component-wake/loading-container.entry.js.map +1 -0
  44. package/dist/{esm → crmbonus-component-wake}/loading-spinner.entry.js +2 -3
  45. package/dist/crmbonus-component-wake/loading-spinner.entry.js.map +1 -0
  46. package/dist/{components/p-246a3e9d.js → crmbonus-component-wake/name-input.entry.js} +8 -37
  47. package/dist/crmbonus-component-wake/name-input.entry.js.map +1 -0
  48. package/dist/{esm → crmbonus-component-wake}/pedido-finalizado.entry.js +4 -4
  49. package/dist/crmbonus-component-wake/pedido-finalizado.entry.js.map +1 -0
  50. package/dist/{esm → crmbonus-component-wake}/phone-cancel-input.entry.js +1 -1
  51. package/dist/crmbonus-component-wake/phone-cancel-input.entry.js.map +1 -0
  52. package/dist/{components/p-6c546e48.js → crmbonus-component-wake/phone-form.entry.js} +8 -47
  53. package/dist/crmbonus-component-wake/phone-form.entry.js.map +1 -0
  54. package/dist/{esm → crmbonus-component-wake}/phone-input-mask.entry.js +2 -3
  55. package/dist/crmbonus-component-wake/phone-input-mask.entry.js.map +1 -0
  56. package/dist/{esm → crmbonus-component-wake}/phone-input.entry.js +1 -1
  57. package/dist/crmbonus-component-wake/phone-input.entry.js.map +1 -0
  58. package/dist/{components/p-83a12a8f.js → crmbonus-component-wake/pin-form.entry.js} +9 -56
  59. package/dist/crmbonus-component-wake/pin-form.entry.js.map +1 -0
  60. package/dist/crmbonus-component-wake/shadow-css-7ad5caf8.js +334 -0
  61. package/dist/crmbonus-component-wake/shadow-css-7ad5caf8.js.map +1 -0
  62. package/dist/{collection/utils/utils.js → crmbonus-component-wake/utils-96cf9ae0.js} +8 -5
  63. package/dist/crmbonus-component-wake/utils-96cf9ae0.js.map +1 -0
  64. package/dist/types/home/darlison/Projects/Bycoders/crmbonus/crmbonus-component/.stencil/env.d.ts +1 -1
  65. package/package.json +1 -1
  66. package/dist/cjs/app-globals-3a1e7e63.js +0 -7
  67. package/dist/cjs/app-globals-3a1e7e63.js.map +0 -1
  68. package/dist/cjs/app-modal.cjs.entry.js +0 -28
  69. package/dist/cjs/app-modal.cjs.entry.js.map +0 -1
  70. package/dist/cjs/cart.helper-d4d8d619.js +0 -77
  71. package/dist/cjs/cart.helper-d4d8d619.js.map +0 -1
  72. package/dist/cjs/countdown-timer_2.cjs.entry.js +0 -63
  73. package/dist/cjs/countdown-timer_2.cjs.entry.js.map +0 -1
  74. package/dist/cjs/crm-bonus-form.cjs.entry.js +0 -104
  75. package/dist/cjs/crm-bonus-form.cjs.entry.js.map +0 -1
  76. package/dist/cjs/crm-bonus-note.cjs.entry.js +0 -101
  77. package/dist/cjs/crm-bonus-note.cjs.entry.js.map +0 -1
  78. package/dist/cjs/crm-bonus.cjs.entry.js +0 -247
  79. package/dist/cjs/crm-bonus.cjs.entry.js.map +0 -1
  80. package/dist/cjs/crm-giftback-form_2.cjs.entry.js +0 -253
  81. package/dist/cjs/crm-giftback-form_2.cjs.entry.js.map +0 -1
  82. package/dist/cjs/crm-tooltip_4.cjs.entry.js +0 -211
  83. package/dist/cjs/crm-tooltip_4.cjs.entry.js.map +0 -1
  84. package/dist/cjs/crmbonus-component-wake.cjs.js +0 -27
  85. package/dist/cjs/crmbonus-component-wake.cjs.js.map +0 -1
  86. package/dist/cjs/crmbonus.service-9067d00d.js +0 -3877
  87. package/dist/cjs/crmbonus.service-9067d00d.js.map +0 -1
  88. package/dist/cjs/giftback-finish_4.cjs.entry.js +0 -131
  89. package/dist/cjs/giftback-finish_4.cjs.entry.js.map +0 -1
  90. package/dist/cjs/i18n-f2a6f60e.js +0 -2219
  91. package/dist/cjs/i18n-f2a6f60e.js.map +0 -1
  92. package/dist/cjs/index-6054ed44.js +0 -21
  93. package/dist/cjs/index-6054ed44.js.map +0 -1
  94. package/dist/cjs/index-d11684bd.js +0 -1599
  95. package/dist/cjs/index-d11684bd.js.map +0 -1
  96. package/dist/cjs/index.cjs.js +0 -11
  97. package/dist/cjs/index.cjs.js.map +0 -1
  98. package/dist/cjs/info.config.helper-c5d9f781.js +0 -16
  99. package/dist/cjs/info.config.helper-c5d9f781.js.map +0 -1
  100. package/dist/cjs/keys.storage-de7744aa.js +0 -17
  101. package/dist/cjs/keys.storage-de7744aa.js.map +0 -1
  102. package/dist/cjs/loader.cjs.js +0 -17
  103. package/dist/cjs/loader.cjs.js.map +0 -1
  104. package/dist/cjs/loading-spinner.cjs.entry.js +0 -24
  105. package/dist/cjs/loading-spinner.cjs.entry.js.map +0 -1
  106. package/dist/cjs/pedido-finalizado.cjs.entry.js +0 -39
  107. package/dist/cjs/pedido-finalizado.cjs.entry.js.map +0 -1
  108. package/dist/cjs/phone-cancel-input.cjs.entry.js +0 -25
  109. package/dist/cjs/phone-cancel-input.cjs.entry.js.map +0 -1
  110. package/dist/cjs/phone-input-mask.cjs.entry.js +0 -61
  111. package/dist/cjs/phone-input-mask.cjs.entry.js.map +0 -1
  112. package/dist/cjs/phone-input.cjs.entry.js +0 -25
  113. package/dist/cjs/phone-input.cjs.entry.js.map +0 -1
  114. package/dist/cjs/utils-e9413ee3.js +0 -25
  115. package/dist/cjs/utils-e9413ee3.js.map +0 -1
  116. package/dist/collection/assets/svg/info-circle-svgrepo-com.svg +0 -6
  117. package/dist/collection/assets/svg/money-dollars-svgrepo-com.svg +0 -6
  118. package/dist/collection/collection-manifest.json +0 -32
  119. package/dist/collection/components/button/crm-button.css +0 -22
  120. package/dist/collection/components/button/index.js +0 -76
  121. package/dist/collection/components/button/index.js.map +0 -1
  122. package/dist/collection/components/countdown-timer/countdown-timer.js +0 -81
  123. package/dist/collection/components/countdown-timer/countdown-timer.js.map +0 -1
  124. package/dist/collection/components/crm-bonus/assets/logo.svg +0 -18
  125. package/dist/collection/components/crm-bonus/assets/success-svgrepo-com.svg +0 -8
  126. package/dist/collection/components/crm-bonus/assets/svg/logo.svg +0 -18
  127. package/dist/collection/components/crm-bonus/assets/svg/success-svgrepo-com.svg +0 -8
  128. package/dist/collection/components/crm-bonus/crm-bonus.css +0 -84
  129. package/dist/collection/components/crm-bonus/crm-bonus.js +0 -311
  130. package/dist/collection/components/crm-bonus/crm-bonus.js.map +0 -1
  131. package/dist/collection/components/crm-bonus-form/crm-bonus-form.css +0 -19
  132. package/dist/collection/components/crm-bonus-form/crm-bonus-form.js +0 -348
  133. package/dist/collection/components/crm-bonus-form/crm-bonus-form.js.map +0 -1
  134. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-finish/giftback-finish.css +0 -10
  135. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-finish/giftback-finish.js +0 -20
  136. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-finish/giftback-finish.js.map +0 -1
  137. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-pin/giftback-pin.css +0 -70
  138. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-pin/giftback-pin.js +0 -126
  139. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-pin/giftback-pin.js.map +0 -1
  140. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-progress/giftback-progress.css +0 -110
  141. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-progress/giftback-progress.js +0 -127
  142. package/dist/collection/components/crm-bonus-form/subcomponents/giftback-progress/giftback-progress.js.map +0 -1
  143. package/dist/collection/components/crm-bonus-form/subcomponents/name-input/name-input.css +0 -108
  144. package/dist/collection/components/crm-bonus-form/subcomponents/name-input/name-input.js +0 -110
  145. package/dist/collection/components/crm-bonus-form/subcomponents/name-input/name-input.js.map +0 -1
  146. package/dist/collection/components/crm-bonus-form/subcomponents/phone/phone.input.js +0 -75
  147. package/dist/collection/components/crm-bonus-form/subcomponents/phone/phone.input.js.map +0 -1
  148. package/dist/collection/components/crm-bonus-form/subcomponents/phone-cancel/phone.cancel.input.js +0 -75
  149. package/dist/collection/components/crm-bonus-form/subcomponents/phone-cancel/phone.cancel.input.js.map +0 -1
  150. package/dist/collection/components/giftback-form/giftback-form.css +0 -75
  151. package/dist/collection/components/giftback-form/giftback-form.js +0 -410
  152. package/dist/collection/components/giftback-form/giftback-form.js.map +0 -1
  153. package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.css +0 -181
  154. package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js +0 -221
  155. package/dist/collection/components/giftback-form/subcomponents/giftback-info/giftback-info.js.map +0 -1
  156. package/dist/collection/components/giftback-form/subcomponents/giftback-message/giftback-massage.js +0 -11
  157. package/dist/collection/components/giftback-form/subcomponents/giftback-message/giftback-massage.js.map +0 -1
  158. package/dist/collection/components/giftback-form/subcomponents/phone-form/phone-form.js +0 -103
  159. package/dist/collection/components/giftback-form/subcomponents/phone-form/phone-form.js.map +0 -1
  160. package/dist/collection/components/giftback-form/subcomponents/pin-form/pin-form.css +0 -84
  161. package/dist/collection/components/giftback-form/subcomponents/pin-form/pin-form.js +0 -197
  162. package/dist/collection/components/giftback-form/subcomponents/pin-form/pin-form.js.map +0 -1
  163. package/dist/collection/components/loading-container/loading-container.css +0 -47
  164. package/dist/collection/components/loading-container/loading-container.js +0 -43
  165. package/dist/collection/components/loading-container/loading-container.js.map +0 -1
  166. package/dist/collection/components/loading-spinner/loading-spinner.css +0 -17
  167. package/dist/collection/components/loading-spinner/loading-spinner.js +0 -63
  168. package/dist/collection/components/loading-spinner/loading-spinner.js.map +0 -1
  169. package/dist/collection/components/modal/app-modal.css +0 -45
  170. package/dist/collection/components/modal/app-modal.js +0 -83
  171. package/dist/collection/components/modal/app-modal.js.map +0 -1
  172. package/dist/collection/components/note/crm-bonus-note.css +0 -71
  173. package/dist/collection/components/note/crm-bonus-note.js +0 -117
  174. package/dist/collection/components/note/crm-bonus-note.js.map +0 -1
  175. package/dist/collection/components/pedido/pedido.js +0 -52
  176. package/dist/collection/components/pedido/pedido.js.map +0 -1
  177. package/dist/collection/components/phone/phone-input-mask.css +0 -40
  178. package/dist/collection/components/phone/phone-input-mask.js +0 -125
  179. package/dist/collection/components/phone/phone-input-mask.js.map +0 -1
  180. package/dist/collection/components/tooltip/crm-tooltip.css +0 -49
  181. package/dist/collection/components/tooltip/tooltip.js +0 -61
  182. package/dist/collection/components/tooltip/tooltip.js.map +0 -1
  183. package/dist/collection/contants/index.js +0 -16
  184. package/dist/collection/contants/index.js.map +0 -1
  185. package/dist/collection/contants/mocks.js +0 -28
  186. package/dist/collection/contants/mocks.js.map +0 -1
  187. package/dist/collection/dto/pin.sent.js +0 -2
  188. package/dist/collection/dto/pin.sent.js.map +0 -1
  189. package/dist/collection/dto/update.order.dto.js +0 -2
  190. package/dist/collection/dto/update.order.dto.js.map +0 -1
  191. package/dist/collection/dto/validate.pin.bonus.js +0 -5
  192. package/dist/collection/dto/validate.pin.bonus.js.map +0 -1
  193. package/dist/collection/helpers/build.payload.helper.js +0 -25
  194. package/dist/collection/helpers/build.payload.helper.js.map +0 -1
  195. package/dist/collection/helpers/cart.helper.js +0 -27
  196. package/dist/collection/helpers/cart.helper.js.map +0 -1
  197. package/dist/collection/helpers/info.config.helper.js +0 -11
  198. package/dist/collection/helpers/info.config.helper.js.map +0 -1
  199. package/dist/collection/helpers/time.helper.js +0 -12
  200. package/dist/collection/helpers/time.helper.js.map +0 -1
  201. package/dist/collection/i18n/i18n.js +0 -35
  202. package/dist/collection/i18n/i18n.js.map +0 -1
  203. package/dist/collection/index.js +0 -11
  204. package/dist/collection/index.js.map +0 -1
  205. package/dist/collection/objectvalues/cart.wake.js +0 -46
  206. package/dist/collection/objectvalues/cart.wake.js.map +0 -1
  207. package/dist/collection/services/crmbonus.service.js +0 -118
  208. package/dist/collection/services/crmbonus.service.js.map +0 -1
  209. package/dist/collection/utils/keys.storage.js +0 -9
  210. package/dist/collection/utils/keys.storage.js.map +0 -1
  211. package/dist/collection/utils/utils.js.map +0 -1
  212. package/dist/components/app-modal.js +0 -46
  213. package/dist/components/app-modal.js.map +0 -1
  214. package/dist/components/countdown-timer.js +0 -8
  215. package/dist/components/countdown-timer.js.map +0 -1
  216. package/dist/components/crm-bonus-form.js +0 -165
  217. package/dist/components/crm-bonus-form.js.map +0 -1
  218. package/dist/components/crm-bonus-note.js +0 -139
  219. package/dist/components/crm-bonus-note.js.map +0 -1
  220. package/dist/components/crm-bonus.js +0 -337
  221. package/dist/components/crm-bonus.js.map +0 -1
  222. package/dist/components/crm-button.js +0 -8
  223. package/dist/components/crm-button.js.map +0 -1
  224. package/dist/components/crm-giftback-form.js +0 -8
  225. package/dist/components/crm-giftback-form.js.map +0 -1
  226. package/dist/components/crm-tooltip.js +0 -8
  227. package/dist/components/crm-tooltip.js.map +0 -1
  228. package/dist/components/giftback-finish.js +0 -8
  229. package/dist/components/giftback-finish.js.map +0 -1
  230. package/dist/components/giftback-info.js +0 -8
  231. package/dist/components/giftback-info.js.map +0 -1
  232. package/dist/components/giftback-pin.js +0 -8
  233. package/dist/components/giftback-pin.js.map +0 -1
  234. package/dist/components/giftback-progress.js +0 -8
  235. package/dist/components/giftback-progress.js.map +0 -1
  236. package/dist/components/index.js +0 -4
  237. package/dist/components/index.js.map +0 -1
  238. package/dist/components/loading-container.js +0 -8
  239. package/dist/components/loading-container.js.map +0 -1
  240. package/dist/components/loading-spinner.js +0 -8
  241. package/dist/components/loading-spinner.js.map +0 -1
  242. package/dist/components/name-input.js +0 -8
  243. package/dist/components/name-input.js.map +0 -1
  244. package/dist/components/p-11085d9b.js +0 -79
  245. package/dist/components/p-11085d9b.js.map +0 -1
  246. package/dist/components/p-246a3e9d.js.map +0 -1
  247. package/dist/components/p-2671d669.js.map +0 -1
  248. package/dist/components/p-2b3b8d6b.js.map +0 -1
  249. package/dist/components/p-3e84f78c.js +0 -1408
  250. package/dist/components/p-3e84f78c.js.map +0 -1
  251. package/dist/components/p-47f9da55.js +0 -46
  252. package/dist/components/p-47f9da55.js.map +0 -1
  253. package/dist/components/p-58b97429.js.map +0 -1
  254. package/dist/components/p-6186ddcc.js.map +0 -1
  255. package/dist/components/p-6c546e48.js.map +0 -1
  256. package/dist/components/p-6eda79c3.js.map +0 -1
  257. package/dist/components/p-75ba7b9a.js +0 -14
  258. package/dist/components/p-75ba7b9a.js.map +0 -1
  259. package/dist/components/p-7c744cca.js.map +0 -1
  260. package/dist/components/p-7cfea8fe.js +0 -19
  261. package/dist/components/p-7cfea8fe.js.map +0 -1
  262. package/dist/components/p-83a12a8f.js.map +0 -1
  263. package/dist/components/p-abbfbc98.js.map +0 -1
  264. package/dist/components/p-b79c86a8.js.map +0 -1
  265. package/dist/components/p-ba369e65.js +0 -21
  266. package/dist/components/p-ba369e65.js.map +0 -1
  267. package/dist/components/p-cc1ea33f.js +0 -36
  268. package/dist/components/p-cc1ea33f.js.map +0 -1
  269. package/dist/components/p-e18e11ae.js +0 -316
  270. package/dist/components/p-e18e11ae.js.map +0 -1
  271. package/dist/components/p-e8c19a64.js +0 -2217
  272. package/dist/components/p-e8c19a64.js.map +0 -1
  273. package/dist/components/p-f9aeffc1.js +0 -12
  274. package/dist/components/p-f9aeffc1.js.map +0 -1
  275. package/dist/components/p-fe9c3966.js +0 -39
  276. package/dist/components/p-fe9c3966.js.map +0 -1
  277. package/dist/components/pedido-finalizado.js +0 -54
  278. package/dist/components/pedido-finalizado.js.map +0 -1
  279. package/dist/components/phone-cancel-input.js +0 -55
  280. package/dist/components/phone-cancel-input.js.map +0 -1
  281. package/dist/components/phone-form.js +0 -8
  282. package/dist/components/phone-form.js.map +0 -1
  283. package/dist/components/phone-input-mask.js +0 -8
  284. package/dist/components/phone-input-mask.js.map +0 -1
  285. package/dist/components/phone-input.js +0 -55
  286. package/dist/components/phone-input.js.map +0 -1
  287. package/dist/components/pin-form.js +0 -8
  288. package/dist/components/pin-form.js.map +0 -1
  289. package/dist/crmbonus-component-wake/p-03b77c41.entry.js +0 -2
  290. package/dist/crmbonus-component-wake/p-03b77c41.entry.js.map +0 -1
  291. package/dist/crmbonus-component-wake/p-3d6152b1.js +0 -3
  292. package/dist/crmbonus-component-wake/p-3d6152b1.js.map +0 -1
  293. package/dist/crmbonus-component-wake/p-4fa63df0.entry.js +0 -2
  294. package/dist/crmbonus-component-wake/p-4fa63df0.entry.js.map +0 -1
  295. package/dist/crmbonus-component-wake/p-620ec1a3.entry.js +0 -2
  296. package/dist/crmbonus-component-wake/p-620ec1a3.entry.js.map +0 -1
  297. package/dist/crmbonus-component-wake/p-6eda79c3.js +0 -2
  298. package/dist/crmbonus-component-wake/p-6eda79c3.js.map +0 -1
  299. package/dist/crmbonus-component-wake/p-74206c91.entry.js +0 -2
  300. package/dist/crmbonus-component-wake/p-74206c91.entry.js.map +0 -1
  301. package/dist/crmbonus-component-wake/p-75ba7b9a.js +0 -2
  302. package/dist/crmbonus-component-wake/p-75ba7b9a.js.map +0 -1
  303. package/dist/crmbonus-component-wake/p-7b7fb354.entry.js +0 -2
  304. package/dist/crmbonus-component-wake/p-7b7fb354.entry.js.map +0 -1
  305. package/dist/crmbonus-component-wake/p-7cdb2c4a.entry.js +0 -2
  306. package/dist/crmbonus-component-wake/p-7cdb2c4a.entry.js.map +0 -1
  307. package/dist/crmbonus-component-wake/p-7cfea8fe.js +0 -2
  308. package/dist/crmbonus-component-wake/p-7cfea8fe.js.map +0 -1
  309. package/dist/crmbonus-component-wake/p-885fc30e.entry.js +0 -2
  310. package/dist/crmbonus-component-wake/p-885fc30e.entry.js.map +0 -1
  311. package/dist/crmbonus-component-wake/p-90716188.entry.js +0 -2
  312. package/dist/crmbonus-component-wake/p-90716188.entry.js.map +0 -1
  313. package/dist/crmbonus-component-wake/p-a33f7c24.entry.js +0 -2
  314. package/dist/crmbonus-component-wake/p-a33f7c24.entry.js.map +0 -1
  315. package/dist/crmbonus-component-wake/p-abbfbc98.js +0 -2
  316. package/dist/crmbonus-component-wake/p-abbfbc98.js.map +0 -1
  317. package/dist/crmbonus-component-wake/p-b7a8f915.entry.js +0 -2
  318. package/dist/crmbonus-component-wake/p-b7a8f915.entry.js.map +0 -1
  319. package/dist/crmbonus-component-wake/p-ba369e65.js +0 -2
  320. package/dist/crmbonus-component-wake/p-ba369e65.js.map +0 -1
  321. package/dist/crmbonus-component-wake/p-be3ddacc.entry.js +0 -2
  322. package/dist/crmbonus-component-wake/p-be3ddacc.entry.js.map +0 -1
  323. package/dist/crmbonus-component-wake/p-c23f3a07.entry.js +0 -2
  324. package/dist/crmbonus-component-wake/p-e1255160.js +0 -2
  325. package/dist/crmbonus-component-wake/p-e1255160.js.map +0 -1
  326. package/dist/crmbonus-component-wake/p-e8c19a64.js +0 -2
  327. package/dist/crmbonus-component-wake/p-e8c19a64.js.map +0 -1
  328. package/dist/crmbonus-component-wake/p-f9aeffc1.js +0 -2
  329. package/dist/crmbonus-component-wake/p-f9aeffc1.js.map +0 -1
  330. package/dist/crmbonus-component-wake/p-fad20959.entry.js +0 -2
  331. package/dist/crmbonus-component-wake/p-fad20959.entry.js.map +0 -1
  332. package/dist/env.js +0 -3
  333. package/dist/env.js.map +0 -1
  334. package/dist/esm/app-modal.entry.js.map +0 -1
  335. package/dist/esm/cart.helper-30a40560.js.map +0 -1
  336. package/dist/esm/countdown-timer_2.entry.js +0 -58
  337. package/dist/esm/countdown-timer_2.entry.js.map +0 -1
  338. package/dist/esm/crm-bonus-form.entry.js.map +0 -1
  339. package/dist/esm/crm-bonus-note.entry.js.map +0 -1
  340. package/dist/esm/crm-bonus.entry.js.map +0 -1
  341. package/dist/esm/crm-giftback-form_2.entry.js.map +0 -1
  342. package/dist/esm/crm-tooltip_4.entry.js +0 -204
  343. package/dist/esm/crm-tooltip_4.entry.js.map +0 -1
  344. package/dist/esm/crmbonus-component-wake.js +0 -22
  345. package/dist/esm/crmbonus-component-wake.js.map +0 -1
  346. package/dist/esm/crmbonus.service-42fbd7fa.js.map +0 -1
  347. package/dist/esm/giftback-finish_4.entry.js +0 -124
  348. package/dist/esm/giftback-finish_4.entry.js.map +0 -1
  349. package/dist/esm/index-e8724c8f.js +0 -1571
  350. package/dist/esm/index-e8724c8f.js.map +0 -1
  351. package/dist/esm/index.js +0 -3
  352. package/dist/esm/index.js.map +0 -1
  353. package/dist/esm/loader.js +0 -13
  354. package/dist/esm/loader.js.map +0 -1
  355. package/dist/esm/loading-spinner.entry.js.map +0 -1
  356. package/dist/esm/pedido-finalizado.entry.js.map +0 -1
  357. package/dist/esm/phone-cancel-input.entry.js.map +0 -1
  358. package/dist/esm/phone-input-mask.entry.js.map +0 -1
  359. package/dist/esm/phone-input.entry.js.map +0 -1
  360. package/dist/esm/utils-d642b4db.js +0 -21
  361. package/dist/esm/utils-d642b4db.js.map +0 -1
  362. package/dist/index.cjs.js +0 -1
  363. package/dist/index.js +0 -1
  364. /package/dist/{esm → crmbonus-component-wake}/app-globals-0f993ce5.js +0 -0
  365. /package/dist/{esm → crmbonus-component-wake}/app-globals-0f993ce5.js.map +0 -0
  366. /package/dist/{esm → crmbonus-component-wake}/index-5b567099.js +0 -0
  367. /package/dist/{esm → crmbonus-component-wake}/index-5b567099.js.map +0 -0
  368. /package/dist/{esm → crmbonus-component-wake}/info.config.helper-42d9ddf9.js +0 -0
  369. /package/dist/{esm → crmbonus-component-wake}/info.config.helper-42d9ddf9.js.map +0 -0
  370. /package/dist/{esm → crmbonus-component-wake}/keys.storage-8c76fcd7.js +0 -0
  371. /package/dist/{esm → crmbonus-component-wake}/keys.storage-8c76fcd7.js.map +0 -0
@@ -1,2219 +0,0 @@
1
- 'use strict';
2
-
3
- const isString = obj => typeof obj === 'string';
4
- const defer = () => {
5
- let res;
6
- let rej;
7
- const promise = new Promise((resolve, reject) => {
8
- res = resolve;
9
- rej = reject;
10
- });
11
- promise.resolve = res;
12
- promise.reject = rej;
13
- return promise;
14
- };
15
- const makeString = object => {
16
- if (object == null) return '';
17
- return '' + object;
18
- };
19
- const copy = (a, s, t) => {
20
- a.forEach(m => {
21
- if (s[m]) t[m] = s[m];
22
- });
23
- };
24
- const lastOfPathSeparatorRegExp = /###/g;
25
- const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
26
- const canNotTraverseDeeper = object => !object || isString(object);
27
- const getLastOfPath = (object, path, Empty) => {
28
- const stack = !isString(path) ? path : path.split('.');
29
- let stackIndex = 0;
30
- while (stackIndex < stack.length - 1) {
31
- if (canNotTraverseDeeper(object)) return {};
32
- const key = cleanKey(stack[stackIndex]);
33
- if (!object[key] && Empty) object[key] = new Empty();
34
- if (Object.prototype.hasOwnProperty.call(object, key)) {
35
- object = object[key];
36
- } else {
37
- object = {};
38
- }
39
- ++stackIndex;
40
- }
41
- if (canNotTraverseDeeper(object)) return {};
42
- return {
43
- obj: object,
44
- k: cleanKey(stack[stackIndex])
45
- };
46
- };
47
- const setPath = (object, path, newValue) => {
48
- const {
49
- obj,
50
- k
51
- } = getLastOfPath(object, path, Object);
52
- if (obj !== undefined || path.length === 1) {
53
- obj[k] = newValue;
54
- return;
55
- }
56
- let e = path[path.length - 1];
57
- let p = path.slice(0, path.length - 1);
58
- let last = getLastOfPath(object, p, Object);
59
- while (last.obj === undefined && p.length) {
60
- e = `${p[p.length - 1]}.${e}`;
61
- p = p.slice(0, p.length - 1);
62
- last = getLastOfPath(object, p, Object);
63
- if (last?.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
64
- last.obj = undefined;
65
- }
66
- }
67
- last.obj[`${last.k}.${e}`] = newValue;
68
- };
69
- const pushPath = (object, path, newValue, concat) => {
70
- const {
71
- obj,
72
- k
73
- } = getLastOfPath(object, path, Object);
74
- obj[k] = obj[k] || [];
75
- obj[k].push(newValue);
76
- };
77
- const getPath = (object, path) => {
78
- const {
79
- obj,
80
- k
81
- } = getLastOfPath(object, path);
82
- if (!obj) return undefined;
83
- return obj[k];
84
- };
85
- const getPathWithDefaults = (data, defaultData, key) => {
86
- const value = getPath(data, key);
87
- if (value !== undefined) {
88
- return value;
89
- }
90
- return getPath(defaultData, key);
91
- };
92
- const deepExtend = (target, source, overwrite) => {
93
- for (const prop in source) {
94
- if (prop !== '__proto__' && prop !== 'constructor') {
95
- if (prop in target) {
96
- if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
97
- if (overwrite) target[prop] = source[prop];
98
- } else {
99
- deepExtend(target[prop], source[prop], overwrite);
100
- }
101
- } else {
102
- target[prop] = source[prop];
103
- }
104
- }
105
- }
106
- return target;
107
- };
108
- const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
109
- var _entityMap = {
110
- '&': '&amp;',
111
- '<': '&lt;',
112
- '>': '&gt;',
113
- '"': '&quot;',
114
- "'": '&#39;',
115
- '/': '&#x2F;'
116
- };
117
- const escape = data => {
118
- if (isString(data)) {
119
- return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
120
- }
121
- return data;
122
- };
123
- class RegExpCache {
124
- constructor(capacity) {
125
- this.capacity = capacity;
126
- this.regExpMap = new Map();
127
- this.regExpQueue = [];
128
- }
129
- getRegExp(pattern) {
130
- const regExpFromCache = this.regExpMap.get(pattern);
131
- if (regExpFromCache !== undefined) {
132
- return regExpFromCache;
133
- }
134
- const regExpNew = new RegExp(pattern);
135
- if (this.regExpQueue.length === this.capacity) {
136
- this.regExpMap.delete(this.regExpQueue.shift());
137
- }
138
- this.regExpMap.set(pattern, regExpNew);
139
- this.regExpQueue.push(pattern);
140
- return regExpNew;
141
- }
142
- }
143
- const chars = [' ', ',', '?', '!', ';'];
144
- const looksLikeObjectPathRegExpCache = new RegExpCache(20);
145
- const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
146
- nsSeparator = nsSeparator || '';
147
- keySeparator = keySeparator || '';
148
- const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
149
- if (possibleChars.length === 0) return true;
150
- const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
151
- let matched = !r.test(key);
152
- if (!matched) {
153
- const ki = key.indexOf(keySeparator);
154
- if (ki > 0 && !r.test(key.substring(0, ki))) {
155
- matched = true;
156
- }
157
- }
158
- return matched;
159
- };
160
- const deepFind = function (obj, path) {
161
- let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
162
- if (!obj) return undefined;
163
- if (obj[path]) return obj[path];
164
- const tokens = path.split(keySeparator);
165
- let current = obj;
166
- for (let i = 0; i < tokens.length;) {
167
- if (!current || typeof current !== 'object') {
168
- return undefined;
169
- }
170
- let next;
171
- let nextPath = '';
172
- for (let j = i; j < tokens.length; ++j) {
173
- if (j !== i) {
174
- nextPath += keySeparator;
175
- }
176
- nextPath += tokens[j];
177
- next = current[nextPath];
178
- if (next !== undefined) {
179
- if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
180
- continue;
181
- }
182
- i += j - i + 1;
183
- break;
184
- }
185
- }
186
- current = next;
187
- }
188
- return current;
189
- };
190
- const getCleanedCode = code => code?.replace('_', '-');
191
-
192
- const consoleLogger = {
193
- type: 'logger',
194
- log(args) {
195
- this.output('log', args);
196
- },
197
- warn(args) {
198
- this.output('warn', args);
199
- },
200
- error(args) {
201
- this.output('error', args);
202
- },
203
- output(type, args) {
204
- console?.[type]?.apply?.(console, args);
205
- }
206
- };
207
- class Logger {
208
- constructor(concreteLogger) {
209
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
210
- this.init(concreteLogger, options);
211
- }
212
- init(concreteLogger) {
213
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
214
- this.prefix = options.prefix || 'i18next:';
215
- this.logger = concreteLogger || consoleLogger;
216
- this.options = options;
217
- this.debug = options.debug;
218
- }
219
- log() {
220
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
221
- args[_key] = arguments[_key];
222
- }
223
- return this.forward(args, 'log', '', true);
224
- }
225
- warn() {
226
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
227
- args[_key2] = arguments[_key2];
228
- }
229
- return this.forward(args, 'warn', '', true);
230
- }
231
- error() {
232
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
233
- args[_key3] = arguments[_key3];
234
- }
235
- return this.forward(args, 'error', '');
236
- }
237
- deprecate() {
238
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
239
- args[_key4] = arguments[_key4];
240
- }
241
- return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
242
- }
243
- forward(args, lvl, prefix, debugOnly) {
244
- if (debugOnly && !this.debug) return null;
245
- if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
246
- return this.logger[lvl](args);
247
- }
248
- create(moduleName) {
249
- return new Logger(this.logger, {
250
- ...{
251
- prefix: `${this.prefix}:${moduleName}:`
252
- },
253
- ...this.options
254
- });
255
- }
256
- clone(options) {
257
- options = options || this.options;
258
- options.prefix = options.prefix || this.prefix;
259
- return new Logger(this.logger, options);
260
- }
261
- }
262
- var baseLogger = new Logger();
263
-
264
- class EventEmitter {
265
- constructor() {
266
- this.observers = {};
267
- }
268
- on(events, listener) {
269
- events.split(' ').forEach(event => {
270
- if (!this.observers[event]) this.observers[event] = new Map();
271
- const numListeners = this.observers[event].get(listener) || 0;
272
- this.observers[event].set(listener, numListeners + 1);
273
- });
274
- return this;
275
- }
276
- off(event, listener) {
277
- if (!this.observers[event]) return;
278
- if (!listener) {
279
- delete this.observers[event];
280
- return;
281
- }
282
- this.observers[event].delete(listener);
283
- }
284
- emit(event) {
285
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
286
- args[_key - 1] = arguments[_key];
287
- }
288
- if (this.observers[event]) {
289
- const cloned = Array.from(this.observers[event].entries());
290
- cloned.forEach(_ref => {
291
- let [observer, numTimesAdded] = _ref;
292
- for (let i = 0; i < numTimesAdded; i++) {
293
- observer(...args);
294
- }
295
- });
296
- }
297
- if (this.observers['*']) {
298
- const cloned = Array.from(this.observers['*'].entries());
299
- cloned.forEach(_ref2 => {
300
- let [observer, numTimesAdded] = _ref2;
301
- for (let i = 0; i < numTimesAdded; i++) {
302
- observer.apply(observer, [event, ...args]);
303
- }
304
- });
305
- }
306
- }
307
- }
308
-
309
- class ResourceStore extends EventEmitter {
310
- constructor(data) {
311
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
312
- ns: ['translation'],
313
- defaultNS: 'translation'
314
- };
315
- super();
316
- this.data = data || {};
317
- this.options = options;
318
- if (this.options.keySeparator === undefined) {
319
- this.options.keySeparator = '.';
320
- }
321
- if (this.options.ignoreJSONStructure === undefined) {
322
- this.options.ignoreJSONStructure = true;
323
- }
324
- }
325
- addNamespaces(ns) {
326
- if (this.options.ns.indexOf(ns) < 0) {
327
- this.options.ns.push(ns);
328
- }
329
- }
330
- removeNamespaces(ns) {
331
- const index = this.options.ns.indexOf(ns);
332
- if (index > -1) {
333
- this.options.ns.splice(index, 1);
334
- }
335
- }
336
- getResource(lng, ns, key) {
337
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
338
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
339
- const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
340
- let path;
341
- if (lng.indexOf('.') > -1) {
342
- path = lng.split('.');
343
- } else {
344
- path = [lng, ns];
345
- if (key) {
346
- if (Array.isArray(key)) {
347
- path.push(...key);
348
- } else if (isString(key) && keySeparator) {
349
- path.push(...key.split(keySeparator));
350
- } else {
351
- path.push(key);
352
- }
353
- }
354
- }
355
- const result = getPath(this.data, path);
356
- if (!result && !ns && !key && lng.indexOf('.') > -1) {
357
- lng = path[0];
358
- ns = path[1];
359
- key = path.slice(2).join('.');
360
- }
361
- if (result || !ignoreJSONStructure || !isString(key)) return result;
362
- return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
363
- }
364
- addResource(lng, ns, key, value) {
365
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
366
- silent: false
367
- };
368
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
369
- let path = [lng, ns];
370
- if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
371
- if (lng.indexOf('.') > -1) {
372
- path = lng.split('.');
373
- value = ns;
374
- ns = path[1];
375
- }
376
- this.addNamespaces(ns);
377
- setPath(this.data, path, value);
378
- if (!options.silent) this.emit('added', lng, ns, key, value);
379
- }
380
- addResources(lng, ns, resources) {
381
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
382
- silent: false
383
- };
384
- for (const m in resources) {
385
- if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
386
- silent: true
387
- });
388
- }
389
- if (!options.silent) this.emit('added', lng, ns, resources);
390
- }
391
- addResourceBundle(lng, ns, resources, deep, overwrite) {
392
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
393
- silent: false,
394
- skipCopy: false
395
- };
396
- let path = [lng, ns];
397
- if (lng.indexOf('.') > -1) {
398
- path = lng.split('.');
399
- deep = resources;
400
- resources = ns;
401
- ns = path[1];
402
- }
403
- this.addNamespaces(ns);
404
- let pack = getPath(this.data, path) || {};
405
- if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
406
- if (deep) {
407
- deepExtend(pack, resources, overwrite);
408
- } else {
409
- pack = {
410
- ...pack,
411
- ...resources
412
- };
413
- }
414
- setPath(this.data, path, pack);
415
- if (!options.silent) this.emit('added', lng, ns, resources);
416
- }
417
- removeResourceBundle(lng, ns) {
418
- if (this.hasResourceBundle(lng, ns)) {
419
- delete this.data[lng][ns];
420
- }
421
- this.removeNamespaces(ns);
422
- this.emit('removed', lng, ns);
423
- }
424
- hasResourceBundle(lng, ns) {
425
- return this.getResource(lng, ns) !== undefined;
426
- }
427
- getResourceBundle(lng, ns) {
428
- if (!ns) ns = this.options.defaultNS;
429
- return this.getResource(lng, ns);
430
- }
431
- getDataByLanguage(lng) {
432
- return this.data[lng];
433
- }
434
- hasLanguageSomeTranslations(lng) {
435
- const data = this.getDataByLanguage(lng);
436
- const n = data && Object.keys(data) || [];
437
- return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
438
- }
439
- toJSON() {
440
- return this.data;
441
- }
442
- }
443
-
444
- var postProcessor = {
445
- processors: {},
446
- addPostProcessor(module) {
447
- this.processors[module.name] = module;
448
- },
449
- handle(processors, value, key, options, translator) {
450
- processors.forEach(processor => {
451
- value = this.processors[processor]?.process(value, key, options, translator) ?? value;
452
- });
453
- return value;
454
- }
455
- };
456
-
457
- const checkedLoadedFor = {};
458
- class Translator extends EventEmitter {
459
- constructor(services) {
460
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
461
- super();
462
- copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
463
- this.options = options;
464
- if (this.options.keySeparator === undefined) {
465
- this.options.keySeparator = '.';
466
- }
467
- this.logger = baseLogger.create('translator');
468
- }
469
- changeLanguage(lng) {
470
- if (lng) this.language = lng;
471
- }
472
- exists(key) {
473
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
474
- interpolation: {}
475
- };
476
- if (key === undefined || key === null) {
477
- return false;
478
- }
479
- const resolved = this.resolve(key, options);
480
- return resolved?.res !== undefined;
481
- }
482
- extractFromKey(key, options) {
483
- let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
484
- if (nsSeparator === undefined) nsSeparator = ':';
485
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
486
- let namespaces = options.ns || this.options.defaultNS || [];
487
- const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
488
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
489
- if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
490
- const m = key.match(this.interpolator.nestingRegexp);
491
- if (m && m.length > 0) {
492
- return {
493
- key,
494
- namespaces: isString(namespaces) ? [namespaces] : namespaces
495
- };
496
- }
497
- const parts = key.split(nsSeparator);
498
- if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
499
- key = parts.join(keySeparator);
500
- }
501
- return {
502
- key,
503
- namespaces: isString(namespaces) ? [namespaces] : namespaces
504
- };
505
- }
506
- translate(keys, options, lastKey) {
507
- if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
508
- options = this.options.overloadTranslationOptionHandler(arguments);
509
- }
510
- if (typeof options === 'object') options = {
511
- ...options
512
- };
513
- if (!options) options = {};
514
- if (keys === undefined || keys === null) return '';
515
- if (!Array.isArray(keys)) keys = [String(keys)];
516
- const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
517
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
518
- const {
519
- key,
520
- namespaces
521
- } = this.extractFromKey(keys[keys.length - 1], options);
522
- const namespace = namespaces[namespaces.length - 1];
523
- const lng = options.lng || this.language;
524
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
525
- if (lng?.toLowerCase() === 'cimode') {
526
- if (appendNamespaceToCIMode) {
527
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
528
- if (returnDetails) {
529
- return {
530
- res: `${namespace}${nsSeparator}${key}`,
531
- usedKey: key,
532
- exactUsedKey: key,
533
- usedLng: lng,
534
- usedNS: namespace,
535
- usedParams: this.getUsedParamsDetails(options)
536
- };
537
- }
538
- return `${namespace}${nsSeparator}${key}`;
539
- }
540
- if (returnDetails) {
541
- return {
542
- res: key,
543
- usedKey: key,
544
- exactUsedKey: key,
545
- usedLng: lng,
546
- usedNS: namespace,
547
- usedParams: this.getUsedParamsDetails(options)
548
- };
549
- }
550
- return key;
551
- }
552
- const resolved = this.resolve(keys, options);
553
- let res = resolved?.res;
554
- const resUsedKey = resolved?.usedKey || key;
555
- const resExactUsedKey = resolved?.exactUsedKey || key;
556
- const resType = Object.prototype.toString.apply(res);
557
- const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
558
- const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
559
- const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
560
- const handleAsObject = !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
561
- if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(res))) {
562
- if (!options.returnObjects && !this.options.returnObjects) {
563
- if (!this.options.returnedObjectHandler) {
564
- this.logger.warn('accessing an object - but returnObjects options is not enabled!');
565
- }
566
- const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
567
- ...options,
568
- ns: namespaces
569
- }) : `key '${key} (${this.language})' returned an object instead of string.`;
570
- if (returnDetails) {
571
- resolved.res = r;
572
- resolved.usedParams = this.getUsedParamsDetails(options);
573
- return resolved;
574
- }
575
- return r;
576
- }
577
- if (keySeparator) {
578
- const resTypeIsArray = Array.isArray(res);
579
- const copy = resTypeIsArray ? [] : {};
580
- const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
581
- for (const m in res) {
582
- if (Object.prototype.hasOwnProperty.call(res, m)) {
583
- const deepKey = `${newKeyToUse}${keySeparator}${m}`;
584
- copy[m] = this.translate(deepKey, {
585
- ...options,
586
- ...{
587
- joinArrays: false,
588
- ns: namespaces
589
- }
590
- });
591
- if (copy[m] === deepKey) copy[m] = res[m];
592
- }
593
- }
594
- res = copy;
595
- }
596
- } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
597
- res = res.join(joinArrays);
598
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
599
- } else {
600
- let usedDefault = false;
601
- let usedKey = false;
602
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
603
- const hasDefaultValue = Translator.hasDefaultValue(options);
604
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
605
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
606
- ordinal: false
607
- }) : '';
608
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
609
- const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
610
- if (!this.isValidLookup(res) && hasDefaultValue) {
611
- usedDefault = true;
612
- res = defaultValue;
613
- }
614
- if (!this.isValidLookup(res)) {
615
- usedKey = true;
616
- res = key;
617
- }
618
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
619
- const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
620
- const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
621
- if (usedKey || usedDefault || updateMissing) {
622
- this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
623
- if (keySeparator) {
624
- const fk = this.resolve(key, {
625
- ...options,
626
- keySeparator: false
627
- });
628
- 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.');
629
- }
630
- let lngs = [];
631
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
632
- if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
633
- for (let i = 0; i < fallbackLngs.length; i++) {
634
- lngs.push(fallbackLngs[i]);
635
- }
636
- } else if (this.options.saveMissingTo === 'all') {
637
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
638
- } else {
639
- lngs.push(options.lng || this.language);
640
- }
641
- const send = (l, k, specificDefaultValue) => {
642
- const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
643
- if (this.options.missingKeyHandler) {
644
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
645
- } else if (this.backendConnector?.saveMissing) {
646
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
647
- }
648
- this.emit('missingKey', l, namespace, k, res);
649
- };
650
- if (this.options.saveMissing) {
651
- if (this.options.saveMissingPlurals && needsPluralHandling) {
652
- lngs.forEach(language => {
653
- const suffixes = this.pluralResolver.getSuffixes(language, options);
654
- if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
655
- suffixes.push(`${this.options.pluralSeparator}zero`);
656
- }
657
- suffixes.forEach(suffix => {
658
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
659
- });
660
- });
661
- } else {
662
- send(lngs, key, defaultValue);
663
- }
664
- }
665
- }
666
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
667
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
668
- if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
669
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
670
- }
671
- }
672
- if (returnDetails) {
673
- resolved.res = res;
674
- resolved.usedParams = this.getUsedParamsDetails(options);
675
- return resolved;
676
- }
677
- return res;
678
- }
679
- extendTranslation(res, key, options, resolved, lastKey) {
680
- var _this = this;
681
- if (this.i18nFormat?.parse) {
682
- res = this.i18nFormat.parse(res, {
683
- ...this.options.interpolation.defaultVariables,
684
- ...options
685
- }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
686
- resolved
687
- });
688
- } else if (!options.skipInterpolation) {
689
- if (options.interpolation) this.interpolator.init({
690
- ...options,
691
- ...{
692
- interpolation: {
693
- ...this.options.interpolation,
694
- ...options.interpolation
695
- }
696
- }
697
- });
698
- const skipOnVariables = isString(res) && (options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
699
- let nestBef;
700
- if (skipOnVariables) {
701
- const nb = res.match(this.interpolator.nestingRegexp);
702
- nestBef = nb && nb.length;
703
- }
704
- let data = options.replace && !isString(options.replace) ? options.replace : options;
705
- if (this.options.interpolation.defaultVariables) data = {
706
- ...this.options.interpolation.defaultVariables,
707
- ...data
708
- };
709
- res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
710
- if (skipOnVariables) {
711
- const na = res.match(this.interpolator.nestingRegexp);
712
- const nestAft = na && na.length;
713
- if (nestBef < nestAft) options.nest = false;
714
- }
715
- if (!options.lng && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
716
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
717
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
718
- args[_key] = arguments[_key];
719
- }
720
- if (lastKey?.[0] === args[0] && !options.context) {
721
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
722
- return null;
723
- }
724
- return _this.translate(...args, key);
725
- }, options);
726
- if (options.interpolation) this.interpolator.reset();
727
- }
728
- const postProcess = options.postProcess || this.options.postProcess;
729
- const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
730
- if (res !== undefined && res !== null && postProcessorNames?.length && options.applyPostProcessor !== false) {
731
- res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
732
- i18nResolved: {
733
- ...resolved,
734
- usedParams: this.getUsedParamsDetails(options)
735
- },
736
- ...options
737
- } : options, this);
738
- }
739
- return res;
740
- }
741
- resolve(keys) {
742
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
743
- let found;
744
- let usedKey;
745
- let exactUsedKey;
746
- let usedLng;
747
- let usedNS;
748
- if (isString(keys)) keys = [keys];
749
- keys.forEach(k => {
750
- if (this.isValidLookup(found)) return;
751
- const extracted = this.extractFromKey(k, options);
752
- const key = extracted.key;
753
- usedKey = key;
754
- let namespaces = extracted.namespaces;
755
- if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
756
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
757
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
758
- const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
759
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
760
- namespaces.forEach(ns => {
761
- if (this.isValidLookup(found)) return;
762
- usedNS = ns;
763
- if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils?.hasLoadedNamespace && !this.utils?.hasLoadedNamespace(usedNS)) {
764
- checkedLoadedFor[`${codes[0]}-${ns}`] = true;
765
- 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!!!');
766
- }
767
- codes.forEach(code => {
768
- if (this.isValidLookup(found)) return;
769
- usedLng = code;
770
- const finalKeys = [key];
771
- if (this.i18nFormat?.addLookupKeys) {
772
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
773
- } else {
774
- let pluralSuffix;
775
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
776
- const zeroSuffix = `${this.options.pluralSeparator}zero`;
777
- const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
778
- if (needsPluralHandling) {
779
- finalKeys.push(key + pluralSuffix);
780
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
781
- finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
782
- }
783
- if (needsZeroSuffixLookup) {
784
- finalKeys.push(key + zeroSuffix);
785
- }
786
- }
787
- if (needsContextHandling) {
788
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
789
- finalKeys.push(contextKey);
790
- if (needsPluralHandling) {
791
- finalKeys.push(contextKey + pluralSuffix);
792
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
793
- finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
794
- }
795
- if (needsZeroSuffixLookup) {
796
- finalKeys.push(contextKey + zeroSuffix);
797
- }
798
- }
799
- }
800
- }
801
- let possibleKey;
802
- while (possibleKey = finalKeys.pop()) {
803
- if (!this.isValidLookup(found)) {
804
- exactUsedKey = possibleKey;
805
- found = this.getResource(code, ns, possibleKey, options);
806
- }
807
- }
808
- });
809
- });
810
- });
811
- return {
812
- res: found,
813
- usedKey,
814
- exactUsedKey,
815
- usedLng,
816
- usedNS
817
- };
818
- }
819
- isValidLookup(res) {
820
- return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
821
- }
822
- getResource(code, ns, key) {
823
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
824
- if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
825
- return this.resourceStore.getResource(code, ns, key, options);
826
- }
827
- getUsedParamsDetails() {
828
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
829
- const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
830
- const useOptionsReplaceForData = options.replace && !isString(options.replace);
831
- let data = useOptionsReplaceForData ? options.replace : options;
832
- if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
833
- data.count = options.count;
834
- }
835
- if (this.options.interpolation.defaultVariables) {
836
- data = {
837
- ...this.options.interpolation.defaultVariables,
838
- ...data
839
- };
840
- }
841
- if (!useOptionsReplaceForData) {
842
- data = {
843
- ...data
844
- };
845
- for (const key of optionsKeys) {
846
- delete data[key];
847
- }
848
- }
849
- return data;
850
- }
851
- static hasDefaultValue(options) {
852
- const prefix = 'defaultValue';
853
- for (const option in options) {
854
- if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
855
- return true;
856
- }
857
- }
858
- return false;
859
- }
860
- }
861
-
862
- class LanguageUtil {
863
- constructor(options) {
864
- this.options = options;
865
- this.supportedLngs = this.options.supportedLngs || false;
866
- this.logger = baseLogger.create('languageUtils');
867
- }
868
- getScriptPartFromCode(code) {
869
- code = getCleanedCode(code);
870
- if (!code || code.indexOf('-') < 0) return null;
871
- const p = code.split('-');
872
- if (p.length === 2) return null;
873
- p.pop();
874
- if (p[p.length - 1].toLowerCase() === 'x') return null;
875
- return this.formatLanguageCode(p.join('-'));
876
- }
877
- getLanguagePartFromCode(code) {
878
- code = getCleanedCode(code);
879
- if (!code || code.indexOf('-') < 0) return code;
880
- const p = code.split('-');
881
- return this.formatLanguageCode(p[0]);
882
- }
883
- formatLanguageCode(code) {
884
- if (isString(code) && code.indexOf('-') > -1) {
885
- let formattedCode;
886
- try {
887
- formattedCode = Intl.getCanonicalLocales(code)[0];
888
- } catch (e) {}
889
- if (formattedCode && this.options.lowerCaseLng) {
890
- formattedCode = formattedCode.toLowerCase();
891
- }
892
- if (formattedCode) return formattedCode;
893
- if (this.options.lowerCaseLng) {
894
- return code.toLowerCase();
895
- }
896
- return code;
897
- }
898
- return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
899
- }
900
- isSupportedCode(code) {
901
- if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
902
- code = this.getLanguagePartFromCode(code);
903
- }
904
- return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
905
- }
906
- getBestMatchFromCodes(codes) {
907
- if (!codes) return null;
908
- let found;
909
- codes.forEach(code => {
910
- if (found) return;
911
- const cleanedLng = this.formatLanguageCode(code);
912
- if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
913
- });
914
- if (!found && this.options.supportedLngs) {
915
- codes.forEach(code => {
916
- if (found) return;
917
- const lngOnly = this.getLanguagePartFromCode(code);
918
- if (this.isSupportedCode(lngOnly)) return found = lngOnly;
919
- found = this.options.supportedLngs.find(supportedLng => {
920
- if (supportedLng === lngOnly) return supportedLng;
921
- if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
922
- if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
923
- if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
924
- });
925
- });
926
- }
927
- if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
928
- return found;
929
- }
930
- getFallbackCodes(fallbacks, code) {
931
- if (!fallbacks) return [];
932
- if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
933
- if (isString(fallbacks)) fallbacks = [fallbacks];
934
- if (Array.isArray(fallbacks)) return fallbacks;
935
- if (!code) return fallbacks.default || [];
936
- let found = fallbacks[code];
937
- if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
938
- if (!found) found = fallbacks[this.formatLanguageCode(code)];
939
- if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
940
- if (!found) found = fallbacks.default;
941
- return found || [];
942
- }
943
- toResolveHierarchy(code, fallbackCode) {
944
- const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
945
- const codes = [];
946
- const addCode = c => {
947
- if (!c) return;
948
- if (this.isSupportedCode(c)) {
949
- codes.push(c);
950
- } else {
951
- this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
952
- }
953
- };
954
- if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
955
- if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
956
- if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
957
- if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
958
- } else if (isString(code)) {
959
- addCode(this.formatLanguageCode(code));
960
- }
961
- fallbackCodes.forEach(fc => {
962
- if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
963
- });
964
- return codes;
965
- }
966
- }
967
-
968
- const suffixesOrder = {
969
- zero: 0,
970
- one: 1,
971
- two: 2,
972
- few: 3,
973
- many: 4,
974
- other: 5
975
- };
976
- const dummyRule = {
977
- select: count => count === 1 ? 'one' : 'other',
978
- resolvedOptions: () => ({
979
- pluralCategories: ['one', 'other']
980
- })
981
- };
982
- class PluralResolver {
983
- constructor(languageUtils) {
984
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
985
- this.languageUtils = languageUtils;
986
- this.options = options;
987
- this.logger = baseLogger.create('pluralResolver');
988
- this.pluralRulesCache = {};
989
- }
990
- addRule(lng, obj) {
991
- this.rules[lng] = obj;
992
- }
993
- clearCache() {
994
- this.pluralRulesCache = {};
995
- }
996
- getRule(code) {
997
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
998
- const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
999
- const type = options.ordinal ? 'ordinal' : 'cardinal';
1000
- const cacheKey = JSON.stringify({
1001
- cleanedCode,
1002
- type
1003
- });
1004
- if (cacheKey in this.pluralRulesCache) {
1005
- return this.pluralRulesCache[cacheKey];
1006
- }
1007
- let rule;
1008
- try {
1009
- rule = new Intl.PluralRules(cleanedCode, {
1010
- type
1011
- });
1012
- } catch (err) {
1013
- if (!Intl) {
1014
- this.logger.error('No Intl support, please use an Intl polyfill!');
1015
- return dummyRule;
1016
- }
1017
- if (!code.match(/-|_/)) return dummyRule;
1018
- const lngPart = this.languageUtils.getLanguagePartFromCode(code);
1019
- rule = this.getRule(lngPart, options);
1020
- }
1021
- this.pluralRulesCache[cacheKey] = rule;
1022
- return rule;
1023
- }
1024
- needsPlural(code) {
1025
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1026
- let rule = this.getRule(code, options);
1027
- if (!rule) rule = this.getRule('dev', options);
1028
- return rule?.resolvedOptions().pluralCategories.length > 1;
1029
- }
1030
- getPluralFormsOfKey(code, key) {
1031
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1032
- return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1033
- }
1034
- getSuffixes(code) {
1035
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1036
- let rule = this.getRule(code, options);
1037
- if (!rule) rule = this.getRule('dev', options);
1038
- if (!rule) return [];
1039
- return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1040
- }
1041
- getSuffix(code, count) {
1042
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1043
- const rule = this.getRule(code, options);
1044
- if (rule) {
1045
- return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
1046
- }
1047
- this.logger.warn(`no plural rule found for: ${code}`);
1048
- return this.getSuffix('dev', count, options);
1049
- }
1050
- }
1051
-
1052
- const deepFindWithDefaults = function (data, defaultData, key) {
1053
- let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1054
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1055
- let path = getPathWithDefaults(data, defaultData, key);
1056
- if (!path && ignoreJSONStructure && isString(key)) {
1057
- path = deepFind(data, key, keySeparator);
1058
- if (path === undefined) path = deepFind(defaultData, key, keySeparator);
1059
- }
1060
- return path;
1061
- };
1062
- const regexSafe = val => val.replace(/\$/g, '$$$$');
1063
- class Interpolator {
1064
- constructor() {
1065
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1066
- this.logger = baseLogger.create('interpolator');
1067
- this.options = options;
1068
- this.format = options?.interpolation?.format || (value => value);
1069
- this.init(options);
1070
- }
1071
- init() {
1072
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1073
- if (!options.interpolation) options.interpolation = {
1074
- escapeValue: true
1075
- };
1076
- const {
1077
- escape: escape$1,
1078
- escapeValue,
1079
- useRawValueToEscape,
1080
- prefix,
1081
- prefixEscaped,
1082
- suffix,
1083
- suffixEscaped,
1084
- formatSeparator,
1085
- unescapeSuffix,
1086
- unescapePrefix,
1087
- nestingPrefix,
1088
- nestingPrefixEscaped,
1089
- nestingSuffix,
1090
- nestingSuffixEscaped,
1091
- nestingOptionsSeparator,
1092
- maxReplaces,
1093
- alwaysFormat
1094
- } = options.interpolation;
1095
- this.escape = escape$1 !== undefined ? escape$1 : escape;
1096
- this.escapeValue = escapeValue !== undefined ? escapeValue : true;
1097
- this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
1098
- this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
1099
- this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
1100
- this.formatSeparator = formatSeparator || ',';
1101
- this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix || '-';
1102
- this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix || '';
1103
- this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
1104
- this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
1105
- this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
1106
- this.maxReplaces = maxReplaces || 1000;
1107
- this.alwaysFormat = alwaysFormat !== undefined ? alwaysFormat : false;
1108
- this.resetRegExp();
1109
- }
1110
- reset() {
1111
- if (this.options) this.init(this.options);
1112
- }
1113
- resetRegExp() {
1114
- const getOrResetRegExp = (existingRegExp, pattern) => {
1115
- if (existingRegExp?.source === pattern) {
1116
- existingRegExp.lastIndex = 0;
1117
- return existingRegExp;
1118
- }
1119
- return new RegExp(pattern, 'g');
1120
- };
1121
- this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
1122
- this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
1123
- this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
1124
- }
1125
- interpolate(str, data, lng, options) {
1126
- let match;
1127
- let value;
1128
- let replaces;
1129
- const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
1130
- const handleFormat = key => {
1131
- if (key.indexOf(this.formatSeparator) < 0) {
1132
- const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
1133
- return this.alwaysFormat ? this.format(path, undefined, lng, {
1134
- ...options,
1135
- ...data,
1136
- interpolationkey: key
1137
- }) : path;
1138
- }
1139
- const p = key.split(this.formatSeparator);
1140
- const k = p.shift().trim();
1141
- const f = p.join(this.formatSeparator).trim();
1142
- return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
1143
- ...options,
1144
- ...data,
1145
- interpolationkey: k
1146
- });
1147
- };
1148
- this.resetRegExp();
1149
- const missingInterpolationHandler = options?.missingInterpolationHandler || this.options.missingInterpolationHandler;
1150
- const skipOnVariables = options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
1151
- const todos = [{
1152
- regex: this.regexpUnescape,
1153
- safeValue: val => regexSafe(val)
1154
- }, {
1155
- regex: this.regexp,
1156
- safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
1157
- }];
1158
- todos.forEach(todo => {
1159
- replaces = 0;
1160
- while (match = todo.regex.exec(str)) {
1161
- const matchedVar = match[1].trim();
1162
- value = handleFormat(matchedVar);
1163
- if (value === undefined) {
1164
- if (typeof missingInterpolationHandler === 'function') {
1165
- const temp = missingInterpolationHandler(str, match, options);
1166
- value = isString(temp) ? temp : '';
1167
- } else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
1168
- value = '';
1169
- } else if (skipOnVariables) {
1170
- value = match[0];
1171
- continue;
1172
- } else {
1173
- this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
1174
- value = '';
1175
- }
1176
- } else if (!isString(value) && !this.useRawValueToEscape) {
1177
- value = makeString(value);
1178
- }
1179
- const safeValue = todo.safeValue(value);
1180
- str = str.replace(match[0], safeValue);
1181
- if (skipOnVariables) {
1182
- todo.regex.lastIndex += value.length;
1183
- todo.regex.lastIndex -= match[0].length;
1184
- } else {
1185
- todo.regex.lastIndex = 0;
1186
- }
1187
- replaces++;
1188
- if (replaces >= this.maxReplaces) {
1189
- break;
1190
- }
1191
- }
1192
- });
1193
- return str;
1194
- }
1195
- nest(str, fc) {
1196
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1197
- let match;
1198
- let value;
1199
- let clonedOptions;
1200
- const handleHasOptions = (key, inheritedOptions) => {
1201
- const sep = this.nestingOptionsSeparator;
1202
- if (key.indexOf(sep) < 0) return key;
1203
- const c = key.split(new RegExp(`${sep}[ ]*{`));
1204
- let optionsString = `{${c[1]}`;
1205
- key = c[0];
1206
- optionsString = this.interpolate(optionsString, clonedOptions);
1207
- const matchedSingleQuotes = optionsString.match(/'/g);
1208
- const matchedDoubleQuotes = optionsString.match(/"/g);
1209
- if ((matchedSingleQuotes?.length ?? 0) % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
1210
- optionsString = optionsString.replace(/'/g, '"');
1211
- }
1212
- try {
1213
- clonedOptions = JSON.parse(optionsString);
1214
- if (inheritedOptions) clonedOptions = {
1215
- ...inheritedOptions,
1216
- ...clonedOptions
1217
- };
1218
- } catch (e) {
1219
- this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
1220
- return `${key}${sep}${optionsString}`;
1221
- }
1222
- if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
1223
- return key;
1224
- };
1225
- while (match = this.nestingRegexp.exec(str)) {
1226
- let formatters = [];
1227
- clonedOptions = {
1228
- ...options
1229
- };
1230
- clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1231
- clonedOptions.applyPostProcessor = false;
1232
- delete clonedOptions.defaultValue;
1233
- let doReduce = false;
1234
- if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1235
- const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1236
- match[1] = r.shift();
1237
- formatters = r;
1238
- doReduce = true;
1239
- }
1240
- value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1241
- if (value && match[0] === str && !isString(value)) return value;
1242
- if (!isString(value)) value = makeString(value);
1243
- if (!value) {
1244
- this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1245
- value = '';
1246
- }
1247
- if (doReduce) {
1248
- value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1249
- ...options,
1250
- interpolationkey: match[1].trim()
1251
- }), value.trim());
1252
- }
1253
- str = str.replace(match[0], value);
1254
- this.regexp.lastIndex = 0;
1255
- }
1256
- return str;
1257
- }
1258
- }
1259
-
1260
- const parseFormatStr = formatStr => {
1261
- let formatName = formatStr.toLowerCase().trim();
1262
- const formatOptions = {};
1263
- if (formatStr.indexOf('(') > -1) {
1264
- const p = formatStr.split('(');
1265
- formatName = p[0].toLowerCase().trim();
1266
- const optStr = p[1].substring(0, p[1].length - 1);
1267
- if (formatName === 'currency' && optStr.indexOf(':') < 0) {
1268
- if (!formatOptions.currency) formatOptions.currency = optStr.trim();
1269
- } else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
1270
- if (!formatOptions.range) formatOptions.range = optStr.trim();
1271
- } else {
1272
- const opts = optStr.split(';');
1273
- opts.forEach(opt => {
1274
- if (opt) {
1275
- const [key, ...rest] = opt.split(':');
1276
- const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
1277
- const trimmedKey = key.trim();
1278
- if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
1279
- if (val === 'false') formatOptions[trimmedKey] = false;
1280
- if (val === 'true') formatOptions[trimmedKey] = true;
1281
- if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
1282
- }
1283
- });
1284
- }
1285
- }
1286
- return {
1287
- formatName,
1288
- formatOptions
1289
- };
1290
- };
1291
- const createCachedFormatter = fn => {
1292
- const cache = {};
1293
- return (val, lng, options) => {
1294
- let optForCache = options;
1295
- if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
1296
- optForCache = {
1297
- ...optForCache,
1298
- [options.interpolationkey]: undefined
1299
- };
1300
- }
1301
- const key = lng + JSON.stringify(optForCache);
1302
- let formatter = cache[key];
1303
- if (!formatter) {
1304
- formatter = fn(getCleanedCode(lng), options);
1305
- cache[key] = formatter;
1306
- }
1307
- return formatter(val);
1308
- };
1309
- };
1310
- class Formatter {
1311
- constructor() {
1312
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1313
- this.logger = baseLogger.create('formatter');
1314
- this.options = options;
1315
- this.formats = {
1316
- number: createCachedFormatter((lng, opt) => {
1317
- const formatter = new Intl.NumberFormat(lng, {
1318
- ...opt
1319
- });
1320
- return val => formatter.format(val);
1321
- }),
1322
- currency: createCachedFormatter((lng, opt) => {
1323
- const formatter = new Intl.NumberFormat(lng, {
1324
- ...opt,
1325
- style: 'currency'
1326
- });
1327
- return val => formatter.format(val);
1328
- }),
1329
- datetime: createCachedFormatter((lng, opt) => {
1330
- const formatter = new Intl.DateTimeFormat(lng, {
1331
- ...opt
1332
- });
1333
- return val => formatter.format(val);
1334
- }),
1335
- relativetime: createCachedFormatter((lng, opt) => {
1336
- const formatter = new Intl.RelativeTimeFormat(lng, {
1337
- ...opt
1338
- });
1339
- return val => formatter.format(val, opt.range || 'day');
1340
- }),
1341
- list: createCachedFormatter((lng, opt) => {
1342
- const formatter = new Intl.ListFormat(lng, {
1343
- ...opt
1344
- });
1345
- return val => formatter.format(val);
1346
- })
1347
- };
1348
- this.init(options);
1349
- }
1350
- init(services) {
1351
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1352
- interpolation: {}
1353
- };
1354
- this.formatSeparator = options.interpolation.formatSeparator || ',';
1355
- }
1356
- add(name, fc) {
1357
- this.formats[name.toLowerCase().trim()] = fc;
1358
- }
1359
- addCached(name, fc) {
1360
- this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1361
- }
1362
- format(value, format, lng) {
1363
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1364
- const formats = format.split(this.formatSeparator);
1365
- if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1366
- const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
1367
- formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
1368
- }
1369
- const result = formats.reduce((mem, f) => {
1370
- const {
1371
- formatName,
1372
- formatOptions
1373
- } = parseFormatStr(f);
1374
- if (this.formats[formatName]) {
1375
- let formatted = mem;
1376
- try {
1377
- const valOptions = options?.formatParams?.[options.interpolationkey] || {};
1378
- const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
1379
- formatted = this.formats[formatName](mem, l, {
1380
- ...formatOptions,
1381
- ...options,
1382
- ...valOptions
1383
- });
1384
- } catch (error) {
1385
- this.logger.warn(error);
1386
- }
1387
- return formatted;
1388
- } else {
1389
- this.logger.warn(`there was no format function for ${formatName}`);
1390
- }
1391
- return mem;
1392
- }, value);
1393
- return result;
1394
- }
1395
- }
1396
-
1397
- const removePending = (q, name) => {
1398
- if (q.pending[name] !== undefined) {
1399
- delete q.pending[name];
1400
- q.pendingCount--;
1401
- }
1402
- };
1403
- class Connector extends EventEmitter {
1404
- constructor(backend, store, services) {
1405
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1406
- super();
1407
- this.backend = backend;
1408
- this.store = store;
1409
- this.services = services;
1410
- this.languageUtils = services.languageUtils;
1411
- this.options = options;
1412
- this.logger = baseLogger.create('backendConnector');
1413
- this.waitingReads = [];
1414
- this.maxParallelReads = options.maxParallelReads || 10;
1415
- this.readingCalls = 0;
1416
- this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
1417
- this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
1418
- this.state = {};
1419
- this.queue = [];
1420
- this.backend?.init?.(services, options.backend, options);
1421
- }
1422
- queueLoad(languages, namespaces, options, callback) {
1423
- const toLoad = {};
1424
- const pending = {};
1425
- const toLoadLanguages = {};
1426
- const toLoadNamespaces = {};
1427
- languages.forEach(lng => {
1428
- let hasAllNamespaces = true;
1429
- namespaces.forEach(ns => {
1430
- const name = `${lng}|${ns}`;
1431
- if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
1432
- this.state[name] = 2;
1433
- } else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
1434
- if (pending[name] === undefined) pending[name] = true;
1435
- } else {
1436
- this.state[name] = 1;
1437
- hasAllNamespaces = false;
1438
- if (pending[name] === undefined) pending[name] = true;
1439
- if (toLoad[name] === undefined) toLoad[name] = true;
1440
- if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
1441
- }
1442
- });
1443
- if (!hasAllNamespaces) toLoadLanguages[lng] = true;
1444
- });
1445
- if (Object.keys(toLoad).length || Object.keys(pending).length) {
1446
- this.queue.push({
1447
- pending,
1448
- pendingCount: Object.keys(pending).length,
1449
- loaded: {},
1450
- errors: [],
1451
- callback
1452
- });
1453
- }
1454
- return {
1455
- toLoad: Object.keys(toLoad),
1456
- pending: Object.keys(pending),
1457
- toLoadLanguages: Object.keys(toLoadLanguages),
1458
- toLoadNamespaces: Object.keys(toLoadNamespaces)
1459
- };
1460
- }
1461
- loaded(name, err, data) {
1462
- const s = name.split('|');
1463
- const lng = s[0];
1464
- const ns = s[1];
1465
- if (err) this.emit('failedLoading', lng, ns, err);
1466
- if (!err && data) {
1467
- this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
1468
- skipCopy: true
1469
- });
1470
- }
1471
- this.state[name] = err ? -1 : 2;
1472
- if (err && data) this.state[name] = 0;
1473
- const loaded = {};
1474
- this.queue.forEach(q => {
1475
- pushPath(q.loaded, [lng], ns);
1476
- removePending(q, name);
1477
- if (err) q.errors.push(err);
1478
- if (q.pendingCount === 0 && !q.done) {
1479
- Object.keys(q.loaded).forEach(l => {
1480
- if (!loaded[l]) loaded[l] = {};
1481
- const loadedKeys = q.loaded[l];
1482
- if (loadedKeys.length) {
1483
- loadedKeys.forEach(n => {
1484
- if (loaded[l][n] === undefined) loaded[l][n] = true;
1485
- });
1486
- }
1487
- });
1488
- q.done = true;
1489
- if (q.errors.length) {
1490
- q.callback(q.errors);
1491
- } else {
1492
- q.callback();
1493
- }
1494
- }
1495
- });
1496
- this.emit('loaded', loaded);
1497
- this.queue = this.queue.filter(q => !q.done);
1498
- }
1499
- read(lng, ns, fcName) {
1500
- let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1501
- let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1502
- let callback = arguments.length > 5 ? arguments[5] : undefined;
1503
- if (!lng.length) return callback(null, {});
1504
- if (this.readingCalls >= this.maxParallelReads) {
1505
- this.waitingReads.push({
1506
- lng,
1507
- ns,
1508
- fcName,
1509
- tried,
1510
- wait,
1511
- callback
1512
- });
1513
- return;
1514
- }
1515
- this.readingCalls++;
1516
- const resolver = (err, data) => {
1517
- this.readingCalls--;
1518
- if (this.waitingReads.length > 0) {
1519
- const next = this.waitingReads.shift();
1520
- this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
1521
- }
1522
- if (err && data && tried < this.maxRetries) {
1523
- setTimeout(() => {
1524
- this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
1525
- }, wait);
1526
- return;
1527
- }
1528
- callback(err, data);
1529
- };
1530
- const fc = this.backend[fcName].bind(this.backend);
1531
- if (fc.length === 2) {
1532
- try {
1533
- const r = fc(lng, ns);
1534
- if (r && typeof r.then === 'function') {
1535
- r.then(data => resolver(null, data)).catch(resolver);
1536
- } else {
1537
- resolver(null, r);
1538
- }
1539
- } catch (err) {
1540
- resolver(err);
1541
- }
1542
- return;
1543
- }
1544
- return fc(lng, ns, resolver);
1545
- }
1546
- prepareLoading(languages, namespaces) {
1547
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1548
- let callback = arguments.length > 3 ? arguments[3] : undefined;
1549
- if (!this.backend) {
1550
- this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1551
- return callback && callback();
1552
- }
1553
- if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
1554
- if (isString(namespaces)) namespaces = [namespaces];
1555
- const toLoad = this.queueLoad(languages, namespaces, options, callback);
1556
- if (!toLoad.toLoad.length) {
1557
- if (!toLoad.pending.length) callback();
1558
- return null;
1559
- }
1560
- toLoad.toLoad.forEach(name => {
1561
- this.loadOne(name);
1562
- });
1563
- }
1564
- load(languages, namespaces, callback) {
1565
- this.prepareLoading(languages, namespaces, {}, callback);
1566
- }
1567
- reload(languages, namespaces, callback) {
1568
- this.prepareLoading(languages, namespaces, {
1569
- reload: true
1570
- }, callback);
1571
- }
1572
- loadOne(name) {
1573
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1574
- const s = name.split('|');
1575
- const lng = s[0];
1576
- const ns = s[1];
1577
- this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
1578
- if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
1579
- if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
1580
- this.loaded(name, err, data);
1581
- });
1582
- }
1583
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1584
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1585
- let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1586
- if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
1587
- 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!!!');
1588
- return;
1589
- }
1590
- if (key === undefined || key === null || key === '') return;
1591
- if (this.backend?.create) {
1592
- const opts = {
1593
- ...options,
1594
- isUpdate
1595
- };
1596
- const fc = this.backend.create.bind(this.backend);
1597
- if (fc.length < 6) {
1598
- try {
1599
- let r;
1600
- if (fc.length === 5) {
1601
- r = fc(languages, namespace, key, fallbackValue, opts);
1602
- } else {
1603
- r = fc(languages, namespace, key, fallbackValue);
1604
- }
1605
- if (r && typeof r.then === 'function') {
1606
- r.then(data => clb(null, data)).catch(clb);
1607
- } else {
1608
- clb(null, r);
1609
- }
1610
- } catch (err) {
1611
- clb(err);
1612
- }
1613
- } else {
1614
- fc(languages, namespace, key, fallbackValue, clb, opts);
1615
- }
1616
- }
1617
- if (!languages || !languages[0]) return;
1618
- this.store.addResource(languages[0], namespace, key, fallbackValue);
1619
- }
1620
- }
1621
-
1622
- const get = () => ({
1623
- debug: false,
1624
- initAsync: true,
1625
- ns: ['translation'],
1626
- defaultNS: ['translation'],
1627
- fallbackLng: ['dev'],
1628
- fallbackNS: false,
1629
- supportedLngs: false,
1630
- nonExplicitSupportedLngs: false,
1631
- load: 'all',
1632
- preload: false,
1633
- simplifyPluralSuffix: true,
1634
- keySeparator: '.',
1635
- nsSeparator: ':',
1636
- pluralSeparator: '_',
1637
- contextSeparator: '_',
1638
- partialBundledLanguages: false,
1639
- saveMissing: false,
1640
- updateMissing: false,
1641
- saveMissingTo: 'fallback',
1642
- saveMissingPlurals: true,
1643
- missingKeyHandler: false,
1644
- missingInterpolationHandler: false,
1645
- postProcess: false,
1646
- postProcessPassResolved: false,
1647
- returnNull: false,
1648
- returnEmptyString: true,
1649
- returnObjects: false,
1650
- joinArrays: false,
1651
- returnedObjectHandler: false,
1652
- parseMissingKeyHandler: false,
1653
- appendNamespaceToMissingKey: false,
1654
- appendNamespaceToCIMode: false,
1655
- overloadTranslationOptionHandler: args => {
1656
- let ret = {};
1657
- if (typeof args[1] === 'object') ret = args[1];
1658
- if (isString(args[1])) ret.defaultValue = args[1];
1659
- if (isString(args[2])) ret.tDescription = args[2];
1660
- if (typeof args[2] === 'object' || typeof args[3] === 'object') {
1661
- const options = args[3] || args[2];
1662
- Object.keys(options).forEach(key => {
1663
- ret[key] = options[key];
1664
- });
1665
- }
1666
- return ret;
1667
- },
1668
- interpolation: {
1669
- escapeValue: true,
1670
- format: value => value,
1671
- prefix: '{{',
1672
- suffix: '}}',
1673
- formatSeparator: ',',
1674
- unescapePrefix: '-',
1675
- nestingPrefix: '$t(',
1676
- nestingSuffix: ')',
1677
- nestingOptionsSeparator: ',',
1678
- maxReplaces: 1000,
1679
- skipOnVariables: true
1680
- }
1681
- });
1682
- const transformOptions = options => {
1683
- if (isString(options.ns)) options.ns = [options.ns];
1684
- if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
1685
- if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
1686
- if (options.supportedLngs?.indexOf?.('cimode') < 0) {
1687
- options.supportedLngs = options.supportedLngs.concat(['cimode']);
1688
- }
1689
- if (typeof options.initImmediate === 'boolean') options.initAsync = options.initImmediate;
1690
- return options;
1691
- };
1692
-
1693
- const noop = () => {};
1694
- const bindMemberFunctions = inst => {
1695
- const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
1696
- mems.forEach(mem => {
1697
- if (typeof inst[mem] === 'function') {
1698
- inst[mem] = inst[mem].bind(inst);
1699
- }
1700
- });
1701
- };
1702
- class I18n extends EventEmitter {
1703
- constructor() {
1704
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1705
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1706
- super();
1707
- this.options = transformOptions(options);
1708
- this.services = {};
1709
- this.logger = baseLogger;
1710
- this.modules = {
1711
- external: []
1712
- };
1713
- bindMemberFunctions(this);
1714
- if (callback && !this.isInitialized && !options.isClone) {
1715
- if (!this.options.initAsync) {
1716
- this.init(options, callback);
1717
- return this;
1718
- }
1719
- setTimeout(() => {
1720
- this.init(options, callback);
1721
- }, 0);
1722
- }
1723
- }
1724
- init() {
1725
- var _this = this;
1726
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1727
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1728
- this.isInitializing = true;
1729
- if (typeof options === 'function') {
1730
- callback = options;
1731
- options = {};
1732
- }
1733
- if (!options.defaultNS && options.defaultNS !== false && options.ns) {
1734
- if (isString(options.ns)) {
1735
- options.defaultNS = options.ns;
1736
- } else if (options.ns.indexOf('translation') < 0) {
1737
- options.defaultNS = options.ns[0];
1738
- }
1739
- }
1740
- const defOpts = get();
1741
- this.options = {
1742
- ...defOpts,
1743
- ...this.options,
1744
- ...transformOptions(options)
1745
- };
1746
- this.options.interpolation = {
1747
- ...defOpts.interpolation,
1748
- ...this.options.interpolation
1749
- };
1750
- if (options.keySeparator !== undefined) {
1751
- this.options.userDefinedKeySeparator = options.keySeparator;
1752
- }
1753
- if (options.nsSeparator !== undefined) {
1754
- this.options.userDefinedNsSeparator = options.nsSeparator;
1755
- }
1756
- const createClassOnDemand = ClassOrObject => {
1757
- if (!ClassOrObject) return null;
1758
- if (typeof ClassOrObject === 'function') return new ClassOrObject();
1759
- return ClassOrObject;
1760
- };
1761
- if (!this.options.isClone) {
1762
- if (this.modules.logger) {
1763
- baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
1764
- } else {
1765
- baseLogger.init(null, this.options);
1766
- }
1767
- let formatter;
1768
- if (this.modules.formatter) {
1769
- formatter = this.modules.formatter;
1770
- } else {
1771
- formatter = Formatter;
1772
- }
1773
- const lu = new LanguageUtil(this.options);
1774
- this.store = new ResourceStore(this.options.resources, this.options);
1775
- const s = this.services;
1776
- s.logger = baseLogger;
1777
- s.resourceStore = this.store;
1778
- s.languageUtils = lu;
1779
- s.pluralResolver = new PluralResolver(lu, {
1780
- prepend: this.options.pluralSeparator,
1781
- simplifyPluralSuffix: this.options.simplifyPluralSuffix
1782
- });
1783
- if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1784
- s.formatter = createClassOnDemand(formatter);
1785
- s.formatter.init(s, this.options);
1786
- this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1787
- }
1788
- s.interpolator = new Interpolator(this.options);
1789
- s.utils = {
1790
- hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1791
- };
1792
- s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1793
- s.backendConnector.on('*', function (event) {
1794
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1795
- args[_key - 1] = arguments[_key];
1796
- }
1797
- _this.emit(event, ...args);
1798
- });
1799
- if (this.modules.languageDetector) {
1800
- s.languageDetector = createClassOnDemand(this.modules.languageDetector);
1801
- if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
1802
- }
1803
- if (this.modules.i18nFormat) {
1804
- s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
1805
- if (s.i18nFormat.init) s.i18nFormat.init(this);
1806
- }
1807
- this.translator = new Translator(this.services, this.options);
1808
- this.translator.on('*', function (event) {
1809
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1810
- args[_key2 - 1] = arguments[_key2];
1811
- }
1812
- _this.emit(event, ...args);
1813
- });
1814
- this.modules.external.forEach(m => {
1815
- if (m.init) m.init(this);
1816
- });
1817
- }
1818
- this.format = this.options.interpolation.format;
1819
- if (!callback) callback = noop;
1820
- if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
1821
- const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1822
- if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
1823
- }
1824
- if (!this.services.languageDetector && !this.options.lng) {
1825
- this.logger.warn('init: no languageDetector is used and no lng is defined');
1826
- }
1827
- const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
1828
- storeApi.forEach(fcName => {
1829
- this[fcName] = function () {
1830
- return _this.store[fcName](...arguments);
1831
- };
1832
- });
1833
- const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
1834
- storeApiChained.forEach(fcName => {
1835
- this[fcName] = function () {
1836
- _this.store[fcName](...arguments);
1837
- return _this;
1838
- };
1839
- });
1840
- const deferred = defer();
1841
- const load = () => {
1842
- const finish = (err, t) => {
1843
- this.isInitializing = false;
1844
- if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
1845
- this.isInitialized = true;
1846
- if (!this.options.isClone) this.logger.log('initialized', this.options);
1847
- this.emit('initialized', this.options);
1848
- deferred.resolve(t);
1849
- callback(err, t);
1850
- };
1851
- if (this.languages && !this.isInitialized) return finish(null, this.t.bind(this));
1852
- this.changeLanguage(this.options.lng, finish);
1853
- };
1854
- if (this.options.resources || !this.options.initAsync) {
1855
- load();
1856
- } else {
1857
- setTimeout(load, 0);
1858
- }
1859
- return deferred;
1860
- }
1861
- loadResources(language) {
1862
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
1863
- let usedCallback = callback;
1864
- const usedLng = isString(language) ? language : this.language;
1865
- if (typeof language === 'function') usedCallback = language;
1866
- if (!this.options.resources || this.options.partialBundledLanguages) {
1867
- if (usedLng?.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
1868
- const toLoad = [];
1869
- const append = lng => {
1870
- if (!lng) return;
1871
- if (lng === 'cimode') return;
1872
- const lngs = this.services.languageUtils.toResolveHierarchy(lng);
1873
- lngs.forEach(l => {
1874
- if (l === 'cimode') return;
1875
- if (toLoad.indexOf(l) < 0) toLoad.push(l);
1876
- });
1877
- };
1878
- if (!usedLng) {
1879
- const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
1880
- fallbacks.forEach(l => append(l));
1881
- } else {
1882
- append(usedLng);
1883
- }
1884
- this.options.preload?.forEach?.(l => append(l));
1885
- this.services.backendConnector.load(toLoad, this.options.ns, e => {
1886
- if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
1887
- usedCallback(e);
1888
- });
1889
- } else {
1890
- usedCallback(null);
1891
- }
1892
- }
1893
- reloadResources(lngs, ns, callback) {
1894
- const deferred = defer();
1895
- if (typeof lngs === 'function') {
1896
- callback = lngs;
1897
- lngs = undefined;
1898
- }
1899
- if (typeof ns === 'function') {
1900
- callback = ns;
1901
- ns = undefined;
1902
- }
1903
- if (!lngs) lngs = this.languages;
1904
- if (!ns) ns = this.options.ns;
1905
- if (!callback) callback = noop;
1906
- this.services.backendConnector.reload(lngs, ns, err => {
1907
- deferred.resolve();
1908
- callback(err);
1909
- });
1910
- return deferred;
1911
- }
1912
- use(module) {
1913
- if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
1914
- if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
1915
- if (module.type === 'backend') {
1916
- this.modules.backend = module;
1917
- }
1918
- if (module.type === 'logger' || module.log && module.warn && module.error) {
1919
- this.modules.logger = module;
1920
- }
1921
- if (module.type === 'languageDetector') {
1922
- this.modules.languageDetector = module;
1923
- }
1924
- if (module.type === 'i18nFormat') {
1925
- this.modules.i18nFormat = module;
1926
- }
1927
- if (module.type === 'postProcessor') {
1928
- postProcessor.addPostProcessor(module);
1929
- }
1930
- if (module.type === 'formatter') {
1931
- this.modules.formatter = module;
1932
- }
1933
- if (module.type === '3rdParty') {
1934
- this.modules.external.push(module);
1935
- }
1936
- return this;
1937
- }
1938
- setResolvedLanguage(l) {
1939
- if (!l || !this.languages) return;
1940
- if (['cimode', 'dev'].indexOf(l) > -1) return;
1941
- for (let li = 0; li < this.languages.length; li++) {
1942
- const lngInLngs = this.languages[li];
1943
- if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
1944
- if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
1945
- this.resolvedLanguage = lngInLngs;
1946
- break;
1947
- }
1948
- }
1949
- }
1950
- changeLanguage(lng, callback) {
1951
- var _this2 = this;
1952
- this.isLanguageChangingTo = lng;
1953
- const deferred = defer();
1954
- this.emit('languageChanging', lng);
1955
- const setLngProps = l => {
1956
- this.language = l;
1957
- this.languages = this.services.languageUtils.toResolveHierarchy(l);
1958
- this.resolvedLanguage = undefined;
1959
- this.setResolvedLanguage(l);
1960
- };
1961
- const done = (err, l) => {
1962
- if (l) {
1963
- setLngProps(l);
1964
- this.translator.changeLanguage(l);
1965
- this.isLanguageChangingTo = undefined;
1966
- this.emit('languageChanged', l);
1967
- this.logger.log('languageChanged', l);
1968
- } else {
1969
- this.isLanguageChangingTo = undefined;
1970
- }
1971
- deferred.resolve(function () {
1972
- return _this2.t(...arguments);
1973
- });
1974
- if (callback) callback(err, function () {
1975
- return _this2.t(...arguments);
1976
- });
1977
- };
1978
- const setLng = lngs => {
1979
- if (!lng && !lngs && this.services.languageDetector) lngs = [];
1980
- const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
1981
- if (l) {
1982
- if (!this.language) {
1983
- setLngProps(l);
1984
- }
1985
- if (!this.translator.language) this.translator.changeLanguage(l);
1986
- this.services.languageDetector?.cacheUserLanguage?.(l);
1987
- }
1988
- this.loadResources(l, err => {
1989
- done(err, l);
1990
- });
1991
- };
1992
- if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
1993
- setLng(this.services.languageDetector.detect());
1994
- } else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
1995
- if (this.services.languageDetector.detect.length === 0) {
1996
- this.services.languageDetector.detect().then(setLng);
1997
- } else {
1998
- this.services.languageDetector.detect(setLng);
1999
- }
2000
- } else {
2001
- setLng(lng);
2002
- }
2003
- return deferred;
2004
- }
2005
- getFixedT(lng, ns, keyPrefix) {
2006
- var _this3 = this;
2007
- const fixedT = function (key, opts) {
2008
- let options;
2009
- if (typeof opts !== 'object') {
2010
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2011
- rest[_key3 - 2] = arguments[_key3];
2012
- }
2013
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2014
- } else {
2015
- options = {
2016
- ...opts
2017
- };
2018
- }
2019
- options.lng = options.lng || fixedT.lng;
2020
- options.lngs = options.lngs || fixedT.lngs;
2021
- options.ns = options.ns || fixedT.ns;
2022
- if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2023
- const keySeparator = _this3.options.keySeparator || '.';
2024
- let resultKey;
2025
- if (options.keyPrefix && Array.isArray(key)) {
2026
- resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
2027
- } else {
2028
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
2029
- }
2030
- return _this3.t(resultKey, options);
2031
- };
2032
- if (isString(lng)) {
2033
- fixedT.lng = lng;
2034
- } else {
2035
- fixedT.lngs = lng;
2036
- }
2037
- fixedT.ns = ns;
2038
- fixedT.keyPrefix = keyPrefix;
2039
- return fixedT;
2040
- }
2041
- t() {
2042
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2043
- args[_key4] = arguments[_key4];
2044
- }
2045
- return this.translator?.translate(...args);
2046
- }
2047
- exists() {
2048
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
2049
- args[_key5] = arguments[_key5];
2050
- }
2051
- return this.translator?.exists(...args);
2052
- }
2053
- setDefaultNamespace(ns) {
2054
- this.options.defaultNS = ns;
2055
- }
2056
- hasLoadedNamespace(ns) {
2057
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2058
- if (!this.isInitialized) {
2059
- this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2060
- return false;
2061
- }
2062
- if (!this.languages || !this.languages.length) {
2063
- this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
2064
- return false;
2065
- }
2066
- const lng = options.lng || this.resolvedLanguage || this.languages[0];
2067
- const fallbackLng = this.options ? this.options.fallbackLng : false;
2068
- const lastLng = this.languages[this.languages.length - 1];
2069
- if (lng.toLowerCase() === 'cimode') return true;
2070
- const loadNotPending = (l, n) => {
2071
- const loadState = this.services.backendConnector.state[`${l}|${n}`];
2072
- return loadState === -1 || loadState === 0 || loadState === 2;
2073
- };
2074
- if (options.precheck) {
2075
- const preResult = options.precheck(this, loadNotPending);
2076
- if (preResult !== undefined) return preResult;
2077
- }
2078
- if (this.hasResourceBundle(lng, ns)) return true;
2079
- if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
2080
- if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
2081
- return false;
2082
- }
2083
- loadNamespaces(ns, callback) {
2084
- const deferred = defer();
2085
- if (!this.options.ns) {
2086
- if (callback) callback();
2087
- return Promise.resolve();
2088
- }
2089
- if (isString(ns)) ns = [ns];
2090
- ns.forEach(n => {
2091
- if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
2092
- });
2093
- this.loadResources(err => {
2094
- deferred.resolve();
2095
- if (callback) callback(err);
2096
- });
2097
- return deferred;
2098
- }
2099
- loadLanguages(lngs, callback) {
2100
- const deferred = defer();
2101
- if (isString(lngs)) lngs = [lngs];
2102
- const preloaded = this.options.preload || [];
2103
- const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
2104
- if (!newLngs.length) {
2105
- if (callback) callback();
2106
- return Promise.resolve();
2107
- }
2108
- this.options.preload = preloaded.concat(newLngs);
2109
- this.loadResources(err => {
2110
- deferred.resolve();
2111
- if (callback) callback(err);
2112
- });
2113
- return deferred;
2114
- }
2115
- dir(lng) {
2116
- if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
2117
- if (!lng) return 'rtl';
2118
- 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'];
2119
- const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
2120
- return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2121
- }
2122
- static createInstance() {
2123
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2124
- let callback = arguments.length > 1 ? arguments[1] : undefined;
2125
- return new I18n(options, callback);
2126
- }
2127
- cloneInstance() {
2128
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2129
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2130
- const forkResourceStore = options.forkResourceStore;
2131
- if (forkResourceStore) delete options.forkResourceStore;
2132
- const mergedOptions = {
2133
- ...this.options,
2134
- ...options,
2135
- ...{
2136
- isClone: true
2137
- }
2138
- };
2139
- const clone = new I18n(mergedOptions);
2140
- if (options.debug !== undefined || options.prefix !== undefined) {
2141
- clone.logger = clone.logger.clone(options);
2142
- }
2143
- const membersToCopy = ['store', 'services', 'language'];
2144
- membersToCopy.forEach(m => {
2145
- clone[m] = this[m];
2146
- });
2147
- clone.services = {
2148
- ...this.services
2149
- };
2150
- clone.services.utils = {
2151
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2152
- };
2153
- if (forkResourceStore) {
2154
- clone.store = new ResourceStore(this.store.data, mergedOptions);
2155
- clone.services.resourceStore = clone.store;
2156
- }
2157
- clone.translator = new Translator(clone.services, mergedOptions);
2158
- clone.translator.on('*', function (event) {
2159
- for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
2160
- args[_key6 - 1] = arguments[_key6];
2161
- }
2162
- clone.emit(event, ...args);
2163
- });
2164
- clone.init(mergedOptions, callback);
2165
- clone.translator.options = mergedOptions;
2166
- clone.translator.backendConnector.services.utils = {
2167
- hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
2168
- };
2169
- return clone;
2170
- }
2171
- toJSON() {
2172
- return {
2173
- options: this.options,
2174
- store: this.store,
2175
- language: this.language,
2176
- languages: this.languages,
2177
- resolvedLanguage: this.resolvedLanguage
2178
- };
2179
- }
2180
- }
2181
- const instance = I18n.createInstance();
2182
- instance.createInstance = I18n.createInstance;
2183
-
2184
- instance.init({
2185
- lng: 'pt', // Idioma padrão
2186
- fallbackLng: 'en', // Idioma de fallback
2187
- interpolation: {
2188
- escapeValue: false
2189
- },
2190
- resources: {
2191
- en: {
2192
- translation: {
2193
- welcome: "Welcome",
2194
- description: "This is an example",
2195
- 'pin-sutitle': "Enter the 4-digit code sent via SMS to the number"
2196
- },
2197
- },
2198
- pt: {
2199
- translation: {
2200
- edit: "Editar",
2201
- welcome: "Bem-vindo",
2202
- description: "Este é um exemplo",
2203
- 'pin-sutitle': "Digite o código de 4 dígitos enviado por SMS ao número",
2204
- giftDescription: "Você tem até <strong>R$ {{amount}}</strong> de {{custom_name}}",
2205
- noGiftback: "Você não possui {{storename}} disponível para essa compra.",
2206
- noBonus: "Não há {{giftbackname}} disponível para essa compra.",
2207
- withApplyBonus: "{{giftbackname}} aplicado ao pedido: ",
2208
- maxAmount: "Você atingiu o valor máximo!",
2209
- labelamountPartial: "Ao utilizar um valor parcial, você perderá a quantia restante.",
2210
- labelUseGiftback: "Regra de utilização: Valor mínimo de compra de {{minimumPurchase}} reais para usar 100% do Giftback, válido até {{expírationDate}}",
2211
- backCart: "Retorne ao carrinho e verifique se há descontos disponíveis nessa compra"
2212
- },
2213
- },
2214
- },
2215
- });
2216
-
2217
- exports.instance = instance;
2218
-
2219
- //# sourceMappingURL=i18n-f2a6f60e.js.map